@@ -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 | |
@@ -390,6 +390,9 @@ discard block |
||
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | // Used to direct the user to another location. |
| 393 | +/** |
|
| 394 | + * @param string $location |
|
| 395 | + */ |
|
| 393 | 396 | function redirectLocation($location, $addForm = true) |
| 394 | 397 | { |
| 395 | 398 | global $upgradeurl, $upcontext, $command_line; |
@@ -1719,6 +1722,9 @@ discard block |
||
| 1719 | 1722 | return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path)); |
| 1720 | 1723 | } |
| 1721 | 1724 | |
| 1725 | +/** |
|
| 1726 | + * @param string $filename |
|
| 1727 | + */ |
|
| 1722 | 1728 | function parse_sql($filename) |
| 1723 | 1729 | { |
| 1724 | 1730 | global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning; |
@@ -2005,6 +2011,9 @@ discard block |
||
| 2005 | 2011 | return true; |
| 2006 | 2012 | } |
| 2007 | 2013 | |
| 2014 | +/** |
|
| 2015 | + * @param string $string |
|
| 2016 | + */ |
|
| 2008 | 2017 | function upgrade_query($string, $unbuffered = false) |
| 2009 | 2018 | { |
| 2010 | 2019 | global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings; |
@@ -4675,7 +4684,7 @@ discard block |
||
| 4675 | 4684 | * @param int $setSize The amount of entries after which to update the database. |
| 4676 | 4685 | * |
| 4677 | 4686 | * newCol needs to be a varbinary(16) null able field |
| 4678 | - * @return bool |
|
| 4687 | + * @return boolean|null |
|
| 4679 | 4688 | */ |
| 4680 | 4689 | function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100) |
| 4681 | 4690 | { |
@@ -100,11 +100,14 @@ discard block |
||
| 100 | 100 | ini_set('default_socket_timeout', 900); |
| 101 | 101 | } |
| 102 | 102 | // Clean the upgrade path if this is from the client. |
| 103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 103 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 104 | + for ($i = 1; |
|
| 105 | +} |
|
| 106 | +$i < $_SERVER['argc']; $i++) |
|
| 105 | 107 | { |
| 106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 108 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 109 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 110 | + } |
|
| 108 | 111 | } |
| 109 | 112 | |
| 110 | 113 | // Are we from the client? |
@@ -112,9 +115,9 @@ discard block |
||
| 112 | 115 | { |
| 113 | 116 | $command_line = true; |
| 114 | 117 | $disable_security = 1; |
| 115 | -} |
|
| 116 | -else |
|
| 118 | +} else { |
|
| 117 | 119 | $command_line = false; |
| 120 | +} |
|
| 118 | 121 | |
| 119 | 122 | // Load this now just because we can. |
| 120 | 123 | require_once($upgrade_path . '/Settings.php'); |
@@ -125,10 +128,12 @@ discard block |
||
| 125 | 128 | $upcontext['user'] = unserialize(base64_decode($upgradeData)); |
| 126 | 129 | |
| 127 | 130 | // Check for sensible values. |
| 128 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 129 | - $upcontext['user']['started'] = time(); |
|
| 130 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 131 | - $upcontext['user']['updated'] = 0; |
|
| 131 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 132 | + $upcontext['user']['started'] = time(); |
|
| 133 | + } |
|
| 134 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 135 | + $upcontext['user']['updated'] = 0; |
|
| 136 | + } |
|
| 132 | 137 | |
| 133 | 138 | $upcontext['started'] = $upcontext['user']['started']; |
| 134 | 139 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -185,8 +190,9 @@ discard block |
||
| 185 | 190 | 'db_error_skip' => true, |
| 186 | 191 | ) |
| 187 | 192 | ); |
| 188 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 189 | - $modSettings[$row['variable']] = $row['value']; |
|
| 193 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 194 | + $modSettings[$row['variable']] = $row['value']; |
|
| 195 | + } |
|
| 190 | 196 | $smcFunc['db_free_result']($request); |
| 191 | 197 | } |
| 192 | 198 | |
@@ -196,10 +202,12 @@ discard block |
||
| 196 | 202 | $modSettings['theme_url'] = 'Themes/default'; |
| 197 | 203 | $modSettings['images_url'] = 'Themes/default/images'; |
| 198 | 204 | } |
| 199 | -if (!isset($settings['default_theme_url'])) |
|
| 205 | +if (!isset($settings['default_theme_url'])) { |
|
| 200 | 206 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 201 | -if (!isset($settings['default_theme_dir'])) |
|
| 207 | +} |
|
| 208 | +if (!isset($settings['default_theme_dir'])) { |
|
| 202 | 209 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 210 | +} |
|
| 203 | 211 | |
| 204 | 212 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 205 | 213 | // Default title... |
@@ -217,13 +225,15 @@ discard block |
||
| 217 | 225 | $support_js = $upcontext['upgrade_status']['js']; |
| 218 | 226 | |
| 219 | 227 | // Only set this if the upgrader status says so. |
| 220 | - if (empty($is_debug)) |
|
| 221 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 228 | + if (empty($is_debug)) { |
|
| 229 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 230 | + } |
|
| 222 | 231 | |
| 223 | 232 | // Load the language. |
| 224 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 225 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 226 | -} |
|
| 233 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 234 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 235 | + } |
|
| 236 | + } |
|
| 227 | 237 | // Set the defaults. |
| 228 | 238 | else |
| 229 | 239 | { |
@@ -241,15 +251,18 @@ discard block |
||
| 241 | 251 | } |
| 242 | 252 | |
| 243 | 253 | // If this isn't the first stage see whether they are logging in and resuming. |
| 244 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 254 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 245 | 255 | checkLogin(); |
| 256 | +} |
|
| 246 | 257 | |
| 247 | -if ($command_line) |
|
| 258 | +if ($command_line) { |
|
| 248 | 259 | cmdStep0(); |
| 260 | +} |
|
| 249 | 261 | |
| 250 | 262 | // Don't error if we're using xml. |
| 251 | -if (isset($_GET['xml'])) |
|
| 263 | +if (isset($_GET['xml'])) { |
|
| 252 | 264 | $upcontext['return_error'] = true; |
| 265 | +} |
|
| 253 | 266 | |
| 254 | 267 | // Loop through all the steps doing each one as required. |
| 255 | 268 | $upcontext['overall_percent'] = 0; |
@@ -270,10 +283,11 @@ discard block |
||
| 270 | 283 | } |
| 271 | 284 | |
| 272 | 285 | // Call the step and if it returns false that means pause! |
| 273 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 274 | - break; |
|
| 275 | - elseif (function_exists($step[2])) |
|
| 276 | - $upcontext['current_step']++; |
|
| 286 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 287 | + break; |
|
| 288 | + } elseif (function_exists($step[2])) { |
|
| 289 | + $upcontext['current_step']++; |
|
| 290 | + } |
|
| 277 | 291 | } |
| 278 | 292 | $upcontext['overall_percent'] += $step[3]; |
| 279 | 293 | } |
@@ -312,17 +326,18 @@ discard block |
||
| 312 | 326 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 313 | 327 | if (!empty($command_line)) |
| 314 | 328 | { |
| 315 | - if (function_exists('debug_print_backtrace')) |
|
| 316 | - debug_print_backtrace(); |
|
| 329 | + if (function_exists('debug_print_backtrace')) { |
|
| 330 | + debug_print_backtrace(); |
|
| 331 | + } |
|
| 317 | 332 | |
| 318 | 333 | 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.'; |
| 319 | 334 | flush(); |
| 320 | 335 | die(); |
| 321 | 336 | } |
| 322 | 337 | |
| 323 | - if (!isset($_GET['xml'])) |
|
| 324 | - template_upgrade_above(); |
|
| 325 | - else |
|
| 338 | + if (!isset($_GET['xml'])) { |
|
| 339 | + template_upgrade_above(); |
|
| 340 | + } else |
|
| 326 | 341 | { |
| 327 | 342 | header('Content-Type: text/xml; charset=UTF-8'); |
| 328 | 343 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -344,21 +359,24 @@ discard block |
||
| 344 | 359 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(safe_serialize($upcontext['upgrade_status'])); |
| 345 | 360 | |
| 346 | 361 | // Custom stuff to pass back? |
| 347 | - if (!empty($upcontext['query_string'])) |
|
| 348 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 362 | + if (!empty($upcontext['query_string'])) { |
|
| 363 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 364 | + } |
|
| 349 | 365 | |
| 350 | 366 | call_user_func('template_' . $upcontext['sub_template']); |
| 351 | 367 | } |
| 352 | 368 | |
| 353 | 369 | // Was there an error? |
| 354 | - if (!empty($upcontext['forced_error_message'])) |
|
| 355 | - echo $upcontext['forced_error_message']; |
|
| 370 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 371 | + echo $upcontext['forced_error_message']; |
|
| 372 | + } |
|
| 356 | 373 | |
| 357 | 374 | // Show the footer. |
| 358 | - if (!isset($_GET['xml'])) |
|
| 359 | - template_upgrade_below(); |
|
| 360 | - else |
|
| 361 | - template_xml_below(); |
|
| 375 | + if (!isset($_GET['xml'])) { |
|
| 376 | + template_upgrade_below(); |
|
| 377 | + } else { |
|
| 378 | + template_xml_below(); |
|
| 379 | + } |
|
| 362 | 380 | } |
| 363 | 381 | |
| 364 | 382 | |
@@ -370,15 +388,19 @@ discard block |
||
| 370 | 388 | $seconds = intval($active % 60); |
| 371 | 389 | |
| 372 | 390 | $totalTime = ''; |
| 373 | - if ($hours > 0) |
|
| 374 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 375 | - if ($minutes > 0) |
|
| 376 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 377 | - if ($seconds > 0) |
|
| 378 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 391 | + if ($hours > 0) { |
|
| 392 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 393 | + } |
|
| 394 | + if ($minutes > 0) { |
|
| 395 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 396 | + } |
|
| 397 | + if ($seconds > 0) { |
|
| 398 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 399 | + } |
|
| 379 | 400 | |
| 380 | - if (!empty($totalTime)) |
|
| 381 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 401 | + if (!empty($totalTime)) { |
|
| 402 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 403 | + } |
|
| 382 | 404 | } |
| 383 | 405 | |
| 384 | 406 | // Bang - gone! |
@@ -391,8 +413,9 @@ discard block |
||
| 391 | 413 | global $upgradeurl, $upcontext, $command_line; |
| 392 | 414 | |
| 393 | 415 | // Command line users can't be redirected. |
| 394 | - if ($command_line) |
|
| 395 | - upgradeExit(true); |
|
| 416 | + if ($command_line) { |
|
| 417 | + upgradeExit(true); |
|
| 418 | + } |
|
| 396 | 419 | |
| 397 | 420 | // Are we providing the core info? |
| 398 | 421 | if ($addForm) |
@@ -415,19 +438,22 @@ discard block |
||
| 415 | 438 | global $modSettings, $sourcedir, $smcFunc; |
| 416 | 439 | |
| 417 | 440 | // Do the non-SSI stuff... |
| 418 | - if (function_exists('set_magic_quotes_runtime')) |
|
| 419 | - @set_magic_quotes_runtime(0); |
|
| 441 | + if (function_exists('set_magic_quotes_runtime')) { |
|
| 442 | + @set_magic_quotes_runtime(0); |
|
| 443 | + } |
|
| 420 | 444 | |
| 421 | 445 | error_reporting(E_ALL); |
| 422 | 446 | define('SMF', 1); |
| 423 | 447 | |
| 424 | 448 | // Start the session. |
| 425 | - if (@ini_get('session.save_handler') == 'user') |
|
| 426 | - @ini_set('session.save_handler', 'files'); |
|
| 449 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 450 | + @ini_set('session.save_handler', 'files'); |
|
| 451 | + } |
|
| 427 | 452 | @session_start(); |
| 428 | 453 | |
| 429 | - if (empty($smcFunc)) |
|
| 430 | - $smcFunc = array(); |
|
| 454 | + if (empty($smcFunc)) { |
|
| 455 | + $smcFunc = array(); |
|
| 456 | + } |
|
| 431 | 457 | |
| 432 | 458 | // We need this for authentication and some upgrade code |
| 433 | 459 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -440,8 +466,9 @@ discard block |
||
| 440 | 466 | initialize_inputs(); |
| 441 | 467 | |
| 442 | 468 | // Get the database going! |
| 443 | - if (empty($db_type)) |
|
| 444 | - $db_type = 'mysql'; |
|
| 469 | + if (empty($db_type)) { |
|
| 470 | + $db_type = 'mysql'; |
|
| 471 | + } |
|
| 445 | 472 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
| 446 | 473 | { |
| 447 | 474 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -450,17 +477,19 @@ discard block |
||
| 450 | 477 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
| 451 | 478 | |
| 452 | 479 | // Oh dear god!! |
| 453 | - if ($db_connection === null) |
|
| 454 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 480 | + if ($db_connection === null) { |
|
| 481 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 482 | + } |
|
| 455 | 483 | |
| 456 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 457 | - $smcFunc['db_query']('', ' |
|
| 484 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 485 | + $smcFunc['db_query']('', ' |
|
| 458 | 486 | SET NAMES {string:db_character_set}', |
| 459 | 487 | array( |
| 460 | 488 | 'db_error_skip' => true, |
| 461 | 489 | 'db_character_set' => $db_character_set, |
| 462 | 490 | ) |
| 463 | 491 | ); |
| 492 | + } |
|
| 464 | 493 | |
| 465 | 494 | // Load the modSettings data... |
| 466 | 495 | $request = $smcFunc['db_query']('', ' |
@@ -471,11 +500,11 @@ discard block |
||
| 471 | 500 | ) |
| 472 | 501 | ); |
| 473 | 502 | $modSettings = array(); |
| 474 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 475 | - $modSettings[$row['variable']] = $row['value']; |
|
| 503 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 504 | + $modSettings[$row['variable']] = $row['value']; |
|
| 505 | + } |
|
| 476 | 506 | $smcFunc['db_free_result']($request); |
| 477 | - } |
|
| 478 | - else |
|
| 507 | + } else |
|
| 479 | 508 | { |
| 480 | 509 | 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.'); |
| 481 | 510 | } |
@@ -489,9 +518,10 @@ discard block |
||
| 489 | 518 | cleanRequest(); |
| 490 | 519 | } |
| 491 | 520 | |
| 492 | - if (!isset($_GET['substep'])) |
|
| 493 | - $_GET['substep'] = 0; |
|
| 494 | -} |
|
| 521 | + if (!isset($_GET['substep'])) { |
|
| 522 | + $_GET['substep'] = 0; |
|
| 523 | + } |
|
| 524 | + } |
|
| 495 | 525 | |
| 496 | 526 | function initialize_inputs() |
| 497 | 527 | { |
@@ -521,8 +551,9 @@ discard block |
||
| 521 | 551 | $dh = opendir(dirname(__FILE__)); |
| 522 | 552 | while ($file = readdir($dh)) |
| 523 | 553 | { |
| 524 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 525 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 554 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 555 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 556 | + } |
|
| 526 | 557 | } |
| 527 | 558 | closedir($dh); |
| 528 | 559 | |
@@ -552,8 +583,9 @@ discard block |
||
| 552 | 583 | { |
| 553 | 584 | $upcontext['remote_files_available'] = false; |
| 554 | 585 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
| 555 | - if ($test) |
|
| 556 | - $upcontext['remote_files_available'] = true; |
|
| 586 | + if ($test) { |
|
| 587 | + $upcontext['remote_files_available'] = true; |
|
| 588 | + } |
|
| 557 | 589 | @fclose($test); |
| 558 | 590 | } |
| 559 | 591 | |
@@ -561,8 +593,9 @@ discard block |
||
| 561 | 593 | $temp = 'upgrade_php?step'; |
| 562 | 594 | while (strlen($temp) > 4) |
| 563 | 595 | { |
| 564 | - if (isset($_GET[$temp])) |
|
| 565 | - unset($_GET[$temp]); |
|
| 596 | + if (isset($_GET[$temp])) { |
|
| 597 | + unset($_GET[$temp]); |
|
| 598 | + } |
|
| 566 | 599 | $temp = substr($temp, 1); |
| 567 | 600 | } |
| 568 | 601 | |
@@ -589,29 +622,36 @@ discard block |
||
| 589 | 622 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $type . '.sql'); |
| 590 | 623 | |
| 591 | 624 | // Need legacy scripts? |
| 592 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 593 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
| 594 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 595 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 596 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 597 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 625 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 626 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
| 627 | + } |
|
| 628 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 629 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 630 | + } |
|
| 631 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 632 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 633 | + } |
|
| 598 | 634 | |
| 599 | 635 | // This needs to exist! |
| 600 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 601 | - 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>]'); |
|
| 602 | - else |
|
| 603 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 636 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 637 | + 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>]'); |
|
| 638 | + } else { |
|
| 639 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 640 | + } |
|
| 604 | 641 | |
| 605 | - if (!$check) |
|
| 606 | - // 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. |
|
| 642 | + if (!$check) { |
|
| 643 | + // 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. |
|
| 607 | 644 | 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.'); |
| 645 | + } |
|
| 608 | 646 | |
| 609 | 647 | // Do they meet the install requirements? |
| 610 | - if (!php_version_check()) |
|
| 611 | - 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.'); |
|
| 648 | + if (!php_version_check()) { |
|
| 649 | + 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.'); |
|
| 650 | + } |
|
| 612 | 651 | |
| 613 | - if (!db_version_check()) |
|
| 614 | - 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.'); |
|
| 652 | + if (!db_version_check()) { |
|
| 653 | + 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.'); |
|
| 654 | + } |
|
| 615 | 655 | |
| 616 | 656 | // Do some checks to make sure they have proper privileges |
| 617 | 657 | db_extend('packages'); |
@@ -626,14 +666,16 @@ discard block |
||
| 626 | 666 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 627 | 667 | |
| 628 | 668 | // Sorry... we need CREATE, ALTER and DROP |
| 629 | - if (!$create || !$alter || !$drop) |
|
| 630 | - 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.'); |
|
| 669 | + if (!$create || !$alter || !$drop) { |
|
| 670 | + 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.'); |
|
| 671 | + } |
|
| 631 | 672 | |
| 632 | 673 | // Do a quick version spot check. |
| 633 | 674 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 634 | 675 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 635 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 636 | - 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.'); |
|
| 676 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 677 | + 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.'); |
|
| 678 | + } |
|
| 637 | 679 | |
| 638 | 680 | // What absolutely needs to be writable? |
| 639 | 681 | $writable_files = array( |
@@ -655,12 +697,13 @@ discard block |
||
| 655 | 697 | quickFileWritable($custom_av_dir); |
| 656 | 698 | |
| 657 | 699 | // Are we good now? |
| 658 | - if (!is_writable($custom_av_dir)) |
|
| 659 | - 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)); |
|
| 660 | - elseif ($need_settings_update) |
|
| 700 | + if (!is_writable($custom_av_dir)) { |
|
| 701 | + 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)); |
|
| 702 | + } elseif ($need_settings_update) |
|
| 661 | 703 | { |
| 662 | - if (!function_exists('cache_put_data')) |
|
| 663 | - require_once($sourcedir . '/Load.php'); |
|
| 704 | + if (!function_exists('cache_put_data')) { |
|
| 705 | + require_once($sourcedir . '/Load.php'); |
|
| 706 | + } |
|
| 664 | 707 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 665 | 708 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 666 | 709 | } |
@@ -669,28 +712,33 @@ discard block |
||
| 669 | 712 | |
| 670 | 713 | // Check the cache directory. |
| 671 | 714 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 672 | - if (!file_exists($cachedir_temp)) |
|
| 673 | - @mkdir($cachedir_temp); |
|
| 674 | - if (!file_exists($cachedir_temp)) |
|
| 675 | - 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.'); |
|
| 676 | - |
|
| 677 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 678 | - 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>.'); |
|
| 679 | - elseif (!isset($_GET['skiplang'])) |
|
| 715 | + if (!file_exists($cachedir_temp)) { |
|
| 716 | + @mkdir($cachedir_temp); |
|
| 717 | + } |
|
| 718 | + if (!file_exists($cachedir_temp)) { |
|
| 719 | + 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.'); |
|
| 720 | + } |
|
| 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'])) |
|
| 680 | 725 | { |
| 681 | 726 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 682 | 727 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 683 | 728 | |
| 684 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 685 | - 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>]'); |
|
| 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>]'); |
|
| 731 | + } |
|
| 686 | 732 | } |
| 687 | 733 | |
| 688 | - if (!makeFilesWritable($writable_files)) |
|
| 689 | - return false; |
|
| 734 | + if (!makeFilesWritable($writable_files)) { |
|
| 735 | + return false; |
|
| 736 | + } |
|
| 690 | 737 | |
| 691 | 738 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 692 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 693 | - 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.'); |
|
| 739 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 740 | + 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.'); |
|
| 741 | + } |
|
| 694 | 742 | |
| 695 | 743 | // Upgrade the agreement. |
| 696 | 744 | elseif (isset($modSettings['agreement'])) |
@@ -701,8 +749,8 @@ discard block |
||
| 701 | 749 | } |
| 702 | 750 | |
| 703 | 751 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 704 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 705 | - $upcontext['warning'] = ' |
|
| 752 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 753 | + $upcontext['warning'] = ' |
|
| 706 | 754 | 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> |
| 707 | 755 | <ul> |
| 708 | 756 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -710,10 +758,12 @@ discard block |
||
| 710 | 758 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 711 | 759 | </ul> |
| 712 | 760 | 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.'; |
| 761 | + } |
|
| 713 | 762 | |
| 714 | 763 | // Either we're logged in or we're going to present the login. |
| 715 | - if (checkLogin()) |
|
| 716 | - return true; |
|
| 764 | + if (checkLogin()) { |
|
| 765 | + return true; |
|
| 766 | + } |
|
| 717 | 767 | |
| 718 | 768 | $upcontext += createToken('login'); |
| 719 | 769 | |
@@ -727,15 +777,17 @@ discard block |
||
| 727 | 777 | global $smcFunc, $db_type, $support_js; |
| 728 | 778 | |
| 729 | 779 | // Don't bother if the security is disabled. |
| 730 | - if ($disable_security) |
|
| 731 | - return true; |
|
| 780 | + if ($disable_security) { |
|
| 781 | + return true; |
|
| 782 | + } |
|
| 732 | 783 | |
| 733 | 784 | // Are we trying to login? |
| 734 | 785 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 735 | 786 | { |
| 736 | 787 | // If we've disabled security pick a suitable name! |
| 737 | - if (empty($_POST['user'])) |
|
| 738 | - $_POST['user'] = 'Administrator'; |
|
| 788 | + if (empty($_POST['user'])) { |
|
| 789 | + $_POST['user'] = 'Administrator'; |
|
| 790 | + } |
|
| 739 | 791 | |
| 740 | 792 | // Before 2.0 these column names were different! |
| 741 | 793 | $oldDB = false; |
@@ -750,16 +802,17 @@ discard block |
||
| 750 | 802 | 'db_error_skip' => true, |
| 751 | 803 | ) |
| 752 | 804 | ); |
| 753 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 754 | - $oldDB = true; |
|
| 805 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 806 | + $oldDB = true; |
|
| 807 | + } |
|
| 755 | 808 | $smcFunc['db_free_result']($request); |
| 756 | 809 | } |
| 757 | 810 | |
| 758 | 811 | // Get what we believe to be their details. |
| 759 | 812 | if (!$disable_security) |
| 760 | 813 | { |
| 761 | - if ($oldDB) |
|
| 762 | - $request = $smcFunc['db_query']('', ' |
|
| 814 | + if ($oldDB) { |
|
| 815 | + $request = $smcFunc['db_query']('', ' |
|
| 763 | 816 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 764 | 817 | additionalGroups AS additional_groups, lngfile |
| 765 | 818 | FROM {db_prefix}members |
@@ -769,8 +822,8 @@ discard block |
||
| 769 | 822 | 'db_error_skip' => true, |
| 770 | 823 | ) |
| 771 | 824 | ); |
| 772 | - else |
|
| 773 | - $request = $smcFunc['db_query']('', ' |
|
| 825 | + } else { |
|
| 826 | + $request = $smcFunc['db_query']('', ' |
|
| 774 | 827 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 775 | 828 | FROM {db_prefix}members |
| 776 | 829 | WHERE member_name = {string:member_name}', |
@@ -779,6 +832,7 @@ discard block |
||
| 779 | 832 | 'db_error_skip' => true, |
| 780 | 833 | ) |
| 781 | 834 | ); |
| 835 | + } |
|
| 782 | 836 | if ($smcFunc['db_num_rows']($request) != 0) |
| 783 | 837 | { |
| 784 | 838 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -786,13 +840,14 @@ discard block |
||
| 786 | 840 | $groups = explode(',', $addGroups); |
| 787 | 841 | $groups[] = $id_group; |
| 788 | 842 | |
| 789 | - foreach ($groups as $k => $v) |
|
| 790 | - $groups[$k] = (int) $v; |
|
| 843 | + foreach ($groups as $k => $v) { |
|
| 844 | + $groups[$k] = (int) $v; |
|
| 845 | + } |
|
| 791 | 846 | |
| 792 | 847 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 848 | + } else { |
|
| 849 | + $upcontext['username_incorrect'] = true; |
|
| 793 | 850 | } |
| 794 | - else |
|
| 795 | - $upcontext['username_incorrect'] = true; |
|
| 796 | 851 | $smcFunc['db_free_result']($request); |
| 797 | 852 | } |
| 798 | 853 | $upcontext['username'] = $_POST['user']; |
@@ -802,13 +857,14 @@ discard block |
||
| 802 | 857 | { |
| 803 | 858 | $upcontext['upgrade_status']['js'] = 1; |
| 804 | 859 | $support_js = 1; |
| 860 | + } else { |
|
| 861 | + $support_js = 0; |
|
| 805 | 862 | } |
| 806 | - else |
|
| 807 | - $support_js = 0; |
|
| 808 | 863 | |
| 809 | 864 | // Note down the version we are coming from. |
| 810 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 811 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 865 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 866 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 867 | + } |
|
| 812 | 868 | |
| 813 | 869 | // Didn't get anywhere? |
| 814 | 870 | 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'])) |
@@ -842,15 +898,15 @@ discard block |
||
| 842 | 898 | 'db_error_skip' => true, |
| 843 | 899 | ) |
| 844 | 900 | ); |
| 845 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 846 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 901 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 902 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 903 | + } |
|
| 847 | 904 | $smcFunc['db_free_result']($request); |
| 848 | 905 | } |
| 849 | 906 | |
| 850 | 907 | $upcontext['user']['id'] = $id_member; |
| 851 | 908 | $upcontext['user']['name'] = $name; |
| 852 | - } |
|
| 853 | - else |
|
| 909 | + } else |
|
| 854 | 910 | { |
| 855 | 911 | $upcontext['user']['id'] = 1; |
| 856 | 912 | $upcontext['user']['name'] = 'Administrator'; |
@@ -866,11 +922,11 @@ discard block |
||
| 866 | 922 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 867 | 923 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 868 | 924 | |
| 869 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 870 | - $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'] . '.'; |
|
| 871 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 872 | - $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'] . '.'; |
|
| 873 | - else |
|
| 925 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 926 | + $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'] . '.'; |
|
| 927 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 928 | + $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'] . '.'; |
|
| 929 | + } else |
|
| 874 | 930 | { |
| 875 | 931 | // Set this as the new language. |
| 876 | 932 | $upcontext['language'] = $user_language; |
@@ -914,8 +970,9 @@ discard block |
||
| 914 | 970 | unset($member_columns); |
| 915 | 971 | |
| 916 | 972 | // If we've not submitted then we're done. |
| 917 | - if (empty($_POST['upcont'])) |
|
| 918 | - return false; |
|
| 973 | + if (empty($_POST['upcont'])) { |
|
| 974 | + return false; |
|
| 975 | + } |
|
| 919 | 976 | |
| 920 | 977 | require_once($sourcedir . '/Subs-Admin.php'); |
| 921 | 978 | updateSettingsFile(array('image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'')); |
@@ -933,25 +990,26 @@ discard block |
||
| 933 | 990 | fwrite($fp, $out); |
| 934 | 991 | |
| 935 | 992 | $return_data = ''; |
| 936 | - while (!feof($fp)) |
|
| 937 | - $return_data .= fgets($fp, 128); |
|
| 993 | + while (!feof($fp)) { |
|
| 994 | + $return_data .= fgets($fp, 128); |
|
| 995 | + } |
|
| 938 | 996 | |
| 939 | 997 | fclose($fp); |
| 940 | 998 | |
| 941 | 999 | // Get the unique site ID. |
| 942 | 1000 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 943 | 1001 | |
| 944 | - if (!empty($ID[1])) |
|
| 945 | - $smcFunc['db_insert']('replace', |
|
| 1002 | + if (!empty($ID[1])) { |
|
| 1003 | + $smcFunc['db_insert']('replace', |
|
| 946 | 1004 | $db_prefix . 'settings', |
| 947 | 1005 | array('variable' => 'string', 'value' => 'string'), |
| 948 | 1006 | array('allow_sm_stats', $ID[1]), |
| 949 | 1007 | array('variable') |
| 950 | 1008 | ); |
| 1009 | + } |
|
| 951 | 1010 | } |
| 952 | - } |
|
| 953 | - else |
|
| 954 | - $smcFunc['db_query']('', ' |
|
| 1011 | + } else { |
|
| 1012 | + $smcFunc['db_query']('', ' |
|
| 955 | 1013 | DELETE FROM {db_prefix}settings |
| 956 | 1014 | WHERE variable = {string:allow_sm_stats}', |
| 957 | 1015 | array( |
@@ -959,6 +1017,7 @@ discard block |
||
| 959 | 1017 | 'db_error_skip' => true, |
| 960 | 1018 | ) |
| 961 | 1019 | ); |
| 1020 | + } |
|
| 962 | 1021 | |
| 963 | 1022 | // Deleting old karma stuff? |
| 964 | 1023 | if (!empty($_POST['delete_karma'])) |
@@ -973,20 +1032,22 @@ discard block |
||
| 973 | 1032 | ); |
| 974 | 1033 | |
| 975 | 1034 | // Cleaning up old karma member settings. |
| 976 | - if ($upcontext['karma_installed']['good']) |
|
| 977 | - $smcFunc['db_query']('', ' |
|
| 1035 | + if ($upcontext['karma_installed']['good']) { |
|
| 1036 | + $smcFunc['db_query']('', ' |
|
| 978 | 1037 | ALTER TABLE {db_prefix}members |
| 979 | 1038 | DROP karma_good', |
| 980 | 1039 | array() |
| 981 | 1040 | ); |
| 1041 | + } |
|
| 982 | 1042 | |
| 983 | 1043 | // Does karma bad was enable? |
| 984 | - if ($upcontext['karma_installed']['bad']) |
|
| 985 | - $smcFunc['db_query']('', ' |
|
| 1044 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1045 | + $smcFunc['db_query']('', ' |
|
| 986 | 1046 | ALTER TABLE {db_prefix}members |
| 987 | 1047 | DROP karma_bad', |
| 988 | 1048 | array() |
| 989 | 1049 | ); |
| 1050 | + } |
|
| 990 | 1051 | |
| 991 | 1052 | // Cleaning up old karma permissions. |
| 992 | 1053 | $smcFunc['db_query']('', ' |
@@ -999,18 +1060,20 @@ discard block |
||
| 999 | 1060 | } |
| 1000 | 1061 | |
| 1001 | 1062 | // Emptying the error log? |
| 1002 | - if (!empty($_POST['empty_error'])) |
|
| 1003 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1063 | + if (!empty($_POST['empty_error'])) { |
|
| 1064 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1004 | 1065 | TRUNCATE {db_prefix}log_errors', |
| 1005 | 1066 | array( |
| 1006 | 1067 | ) |
| 1007 | 1068 | ); |
| 1069 | + } |
|
| 1008 | 1070 | |
| 1009 | 1071 | $changes = array(); |
| 1010 | 1072 | |
| 1011 | 1073 | // If we're overriding the language follow it through. |
| 1012 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1013 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1074 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1075 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1076 | + } |
|
| 1014 | 1077 | |
| 1015 | 1078 | if (!empty($_POST['maint'])) |
| 1016 | 1079 | { |
@@ -1022,33 +1085,37 @@ discard block |
||
| 1022 | 1085 | { |
| 1023 | 1086 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1024 | 1087 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1025 | - } |
|
| 1026 | - else |
|
| 1088 | + } else |
|
| 1027 | 1089 | { |
| 1028 | 1090 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1029 | 1091 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1030 | 1092 | } |
| 1031 | 1093 | } |
| 1032 | 1094 | |
| 1033 | - if ($command_line) |
|
| 1034 | - echo ' * Updating Settings.php...'; |
|
| 1095 | + if ($command_line) { |
|
| 1096 | + echo ' * Updating Settings.php...'; |
|
| 1097 | + } |
|
| 1035 | 1098 | |
| 1036 | 1099 | // Backup the current one first. |
| 1037 | 1100 | copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
| 1038 | 1101 | |
| 1039 | 1102 | // Fix some old paths. |
| 1040 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1041 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1103 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1104 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1105 | + } |
|
| 1042 | 1106 | |
| 1043 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1044 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1107 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1108 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1109 | + } |
|
| 1045 | 1110 | |
| 1046 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1047 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1111 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1112 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1113 | + } |
|
| 1048 | 1114 | |
| 1049 | 1115 | // Not had the database type added before? |
| 1050 | - if (empty($db_type)) |
|
| 1051 | - $changes['db_type'] = 'mysql'; |
|
| 1116 | + if (empty($db_type)) { |
|
| 1117 | + $changes['db_type'] = 'mysql'; |
|
| 1118 | + } |
|
| 1052 | 1119 | |
| 1053 | 1120 | // If they have a "host:port" setup for the host, split that into separate values |
| 1054 | 1121 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1059,28 +1126,31 @@ discard block |
||
| 1059 | 1126 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1060 | 1127 | |
| 1061 | 1128 | // Only set this if we're not using the default port |
| 1062 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1063 | - $changes['db_port'] = (int) $db_port; |
|
| 1064 | - } |
|
| 1065 | - elseif (!empty($db_port)) |
|
| 1129 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1130 | + $changes['db_port'] = (int) $db_port; |
|
| 1131 | + } |
|
| 1132 | + } elseif (!empty($db_port)) |
|
| 1066 | 1133 | { |
| 1067 | 1134 | // If db_port is set and is the same as the default, set it to '' |
| 1068 | 1135 | if ($db_type == 'mysql') |
| 1069 | 1136 | { |
| 1070 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1071 | - $changes['db_port'] = '\'\''; |
|
| 1072 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1073 | - $changes['db_port'] = '\'\''; |
|
| 1137 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1138 | + $changes['db_port'] = '\'\''; |
|
| 1139 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1140 | + $changes['db_port'] = '\'\''; |
|
| 1141 | + } |
|
| 1074 | 1142 | } |
| 1075 | 1143 | } |
| 1076 | 1144 | |
| 1077 | 1145 | // Maybe we haven't had this option yet? |
| 1078 | - if (empty($packagesdir)) |
|
| 1079 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1146 | + if (empty($packagesdir)) { |
|
| 1147 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1148 | + } |
|
| 1080 | 1149 | |
| 1081 | 1150 | // Add support for $tasksdir var. |
| 1082 | - if (empty($tasksdir)) |
|
| 1083 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1151 | + if (empty($tasksdir)) { |
|
| 1152 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1153 | + } |
|
| 1084 | 1154 | |
| 1085 | 1155 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1086 | 1156 | |
@@ -1125,8 +1195,7 @@ discard block |
||
| 1125 | 1195 | $found_old = true; |
| 1126 | 1196 | // Replace the old line with the new code |
| 1127 | 1197 | $settings_file = str_replace('$db_last_error = ' . $db_last_error . ';', $error_catching_header . $error_catching, $settings_file); |
| 1128 | - } |
|
| 1129 | - else |
|
| 1198 | + } else |
|
| 1130 | 1199 | { |
| 1131 | 1200 | $found_old = false; |
| 1132 | 1201 | // We want the comments as well as the code... |
@@ -1157,8 +1226,9 @@ discard block |
||
| 1157 | 1226 | fclose($file); |
| 1158 | 1227 | } |
| 1159 | 1228 | |
| 1160 | - if ($command_line) |
|
| 1161 | - echo ' Successful.' . "\n"; |
|
| 1229 | + if ($command_line) { |
|
| 1230 | + echo ' Successful.' . "\n"; |
|
| 1231 | + } |
|
| 1162 | 1232 | |
| 1163 | 1233 | // Are we doing debug? |
| 1164 | 1234 | if (isset($_POST['debug'])) |
@@ -1168,8 +1238,9 @@ discard block |
||
| 1168 | 1238 | } |
| 1169 | 1239 | |
| 1170 | 1240 | // If we're not backing up then jump one. |
| 1171 | - if (empty($_POST['backup'])) |
|
| 1172 | - $upcontext['current_step']++; |
|
| 1241 | + if (empty($_POST['backup'])) { |
|
| 1242 | + $upcontext['current_step']++; |
|
| 1243 | + } |
|
| 1173 | 1244 | |
| 1174 | 1245 | // If we've got here then let's proceed to the next step! |
| 1175 | 1246 | return true; |
@@ -1184,8 +1255,9 @@ discard block |
||
| 1184 | 1255 | $upcontext['page_title'] = 'Backup Database'; |
| 1185 | 1256 | |
| 1186 | 1257 | // Done it already - js wise? |
| 1187 | - if (!empty($_POST['backup_done'])) |
|
| 1188 | - return true; |
|
| 1258 | + if (!empty($_POST['backup_done'])) { |
|
| 1259 | + return true; |
|
| 1260 | + } |
|
| 1189 | 1261 | |
| 1190 | 1262 | // Some useful stuff here. |
| 1191 | 1263 | db_extend(); |
@@ -1199,9 +1271,10 @@ discard block |
||
| 1199 | 1271 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1200 | 1272 | |
| 1201 | 1273 | $table_names = array(); |
| 1202 | - foreach ($tables as $table) |
|
| 1203 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1274 | + foreach ($tables as $table) { |
|
| 1275 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1204 | 1276 | $table_names[] = $table; |
| 1277 | + } |
|
| 1205 | 1278 | |
| 1206 | 1279 | $upcontext['table_count'] = count($table_names); |
| 1207 | 1280 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1211,12 +1284,14 @@ discard block |
||
| 1211 | 1284 | $file_steps = $upcontext['table_count']; |
| 1212 | 1285 | |
| 1213 | 1286 | // What ones have we already done? |
| 1214 | - foreach ($table_names as $id => $table) |
|
| 1215 | - if ($id < $_GET['substep']) |
|
| 1287 | + foreach ($table_names as $id => $table) { |
|
| 1288 | + if ($id < $_GET['substep']) |
|
| 1216 | 1289 | $upcontext['previous_tables'][] = $table; |
| 1290 | + } |
|
| 1217 | 1291 | |
| 1218 | - if ($command_line) |
|
| 1219 | - echo 'Backing Up Tables.'; |
|
| 1292 | + if ($command_line) { |
|
| 1293 | + echo 'Backing Up Tables.'; |
|
| 1294 | + } |
|
| 1220 | 1295 | |
| 1221 | 1296 | // If we don't support javascript we backup here. |
| 1222 | 1297 | if (!$support_js || isset($_GET['xml'])) |
@@ -1235,8 +1310,9 @@ discard block |
||
| 1235 | 1310 | backupTable($table_names[$substep]); |
| 1236 | 1311 | |
| 1237 | 1312 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1238 | - if (isset($_GET['xml'])) |
|
| 1239 | - return upgradeExit(); |
|
| 1313 | + if (isset($_GET['xml'])) { |
|
| 1314 | + return upgradeExit(); |
|
| 1315 | + } |
|
| 1240 | 1316 | } |
| 1241 | 1317 | |
| 1242 | 1318 | if ($command_line) |
@@ -1269,9 +1345,10 @@ discard block |
||
| 1269 | 1345 | |
| 1270 | 1346 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1271 | 1347 | |
| 1272 | - if ($command_line) |
|
| 1273 | - echo ' done.'; |
|
| 1274 | -} |
|
| 1348 | + if ($command_line) { |
|
| 1349 | + echo ' done.'; |
|
| 1350 | + } |
|
| 1351 | + } |
|
| 1275 | 1352 | |
| 1276 | 1353 | // Step 2: Everything. |
| 1277 | 1354 | function DatabaseChanges() |
@@ -1280,8 +1357,9 @@ discard block |
||
| 1280 | 1357 | global $upcontext, $support_js, $db_type; |
| 1281 | 1358 | |
| 1282 | 1359 | // Have we just completed this? |
| 1283 | - if (!empty($_POST['database_done'])) |
|
| 1284 | - return true; |
|
| 1360 | + if (!empty($_POST['database_done'])) { |
|
| 1361 | + return true; |
|
| 1362 | + } |
|
| 1285 | 1363 | |
| 1286 | 1364 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1287 | 1365 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1296,15 +1374,16 @@ discard block |
||
| 1296 | 1374 | ); |
| 1297 | 1375 | |
| 1298 | 1376 | // How many files are there in total? |
| 1299 | - if (isset($_GET['filecount'])) |
|
| 1300 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1301 | - else |
|
| 1377 | + if (isset($_GET['filecount'])) { |
|
| 1378 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1379 | + } else |
|
| 1302 | 1380 | { |
| 1303 | 1381 | $upcontext['file_count'] = 0; |
| 1304 | 1382 | foreach ($files as $file) |
| 1305 | 1383 | { |
| 1306 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1307 | - $upcontext['file_count']++; |
|
| 1384 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1385 | + $upcontext['file_count']++; |
|
| 1386 | + } |
|
| 1308 | 1387 | } |
| 1309 | 1388 | } |
| 1310 | 1389 | |
@@ -1314,9 +1393,9 @@ discard block |
||
| 1314 | 1393 | $upcontext['cur_file_num'] = 0; |
| 1315 | 1394 | foreach ($files as $file) |
| 1316 | 1395 | { |
| 1317 | - if ($did_not_do) |
|
| 1318 | - $did_not_do--; |
|
| 1319 | - else |
|
| 1396 | + if ($did_not_do) { |
|
| 1397 | + $did_not_do--; |
|
| 1398 | + } else |
|
| 1320 | 1399 | { |
| 1321 | 1400 | $upcontext['cur_file_num']++; |
| 1322 | 1401 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1343,12 +1422,13 @@ discard block |
||
| 1343 | 1422 | // Flag to move on to the next. |
| 1344 | 1423 | $upcontext['completed_step'] = true; |
| 1345 | 1424 | // Did we complete the whole file? |
| 1346 | - if ($nextFile) |
|
| 1347 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1425 | + if ($nextFile) { |
|
| 1426 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1427 | + } |
|
| 1348 | 1428 | return upgradeExit(); |
| 1429 | + } elseif ($support_js) { |
|
| 1430 | + break; |
|
| 1349 | 1431 | } |
| 1350 | - elseif ($support_js) |
|
| 1351 | - break; |
|
| 1352 | 1432 | } |
| 1353 | 1433 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1354 | 1434 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1373,8 +1453,9 @@ discard block |
||
| 1373 | 1453 | global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1374 | 1454 | |
| 1375 | 1455 | // Now it's nice to have some of the basic SMF source files. |
| 1376 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1377 | - redirectLocation('&ssi=1'); |
|
| 1456 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1457 | + redirectLocation('&ssi=1'); |
|
| 1458 | + } |
|
| 1378 | 1459 | |
| 1379 | 1460 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1380 | 1461 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1390,14 +1471,16 @@ discard block |
||
| 1390 | 1471 | // Are we in maintenance mode? |
| 1391 | 1472 | if (isset($upcontext['user']['main'])) |
| 1392 | 1473 | { |
| 1393 | - if ($command_line) |
|
| 1394 | - echo ' * '; |
|
| 1474 | + if ($command_line) { |
|
| 1475 | + echo ' * '; |
|
| 1476 | + } |
|
| 1395 | 1477 | $upcontext['removed_maintenance'] = true; |
| 1396 | 1478 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1397 | 1479 | } |
| 1398 | 1480 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1399 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1400 | - $changes['maintenance'] = 1; |
|
| 1481 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1482 | + $changes['maintenance'] = 1; |
|
| 1483 | + } |
|
| 1401 | 1484 | |
| 1402 | 1485 | // Wipe this out... |
| 1403 | 1486 | $upcontext['user'] = array(); |
@@ -1413,9 +1496,9 @@ discard block |
||
| 1413 | 1496 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1414 | 1497 | |
| 1415 | 1498 | // Now is the perfect time to fetch the SM files. |
| 1416 | - if ($command_line) |
|
| 1417 | - cli_scheduled_fetchSMfiles(); |
|
| 1418 | - else |
|
| 1499 | + if ($command_line) { |
|
| 1500 | + cli_scheduled_fetchSMfiles(); |
|
| 1501 | + } else |
|
| 1419 | 1502 | { |
| 1420 | 1503 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1421 | 1504 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1423,8 +1506,9 @@ discard block |
||
| 1423 | 1506 | } |
| 1424 | 1507 | |
| 1425 | 1508 | // Log what we've done. |
| 1426 | - if (empty($user_info['id'])) |
|
| 1427 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1509 | + if (empty($user_info['id'])) { |
|
| 1510 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1511 | + } |
|
| 1428 | 1512 | |
| 1429 | 1513 | // Log the action manually, so CLI still works. |
| 1430 | 1514 | $smcFunc['db_insert']('', |
@@ -1443,8 +1527,9 @@ discard block |
||
| 1443 | 1527 | |
| 1444 | 1528 | // Save the current database version. |
| 1445 | 1529 | $server_version = $smcFunc['db_server_info'](); |
| 1446 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1447 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1530 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1531 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1532 | + } |
|
| 1448 | 1533 | |
| 1449 | 1534 | if ($command_line) |
| 1450 | 1535 | { |
@@ -1456,8 +1541,9 @@ discard block |
||
| 1456 | 1541 | |
| 1457 | 1542 | // Make sure it says we're done. |
| 1458 | 1543 | $upcontext['overall_percent'] = 100; |
| 1459 | - if (isset($upcontext['step_progress'])) |
|
| 1460 | - unset($upcontext['step_progress']); |
|
| 1544 | + if (isset($upcontext['step_progress'])) { |
|
| 1545 | + unset($upcontext['step_progress']); |
|
| 1546 | + } |
|
| 1461 | 1547 | |
| 1462 | 1548 | $_GET['substep'] = 0; |
| 1463 | 1549 | return false; |
@@ -1468,8 +1554,9 @@ discard block |
||
| 1468 | 1554 | { |
| 1469 | 1555 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1470 | 1556 | |
| 1471 | - if (empty($modSettings['time_format'])) |
|
| 1472 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1557 | + if (empty($modSettings['time_format'])) { |
|
| 1558 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1559 | + } |
|
| 1473 | 1560 | |
| 1474 | 1561 | // What files do we want to get |
| 1475 | 1562 | $request = $smcFunc['db_query']('', ' |
@@ -1503,8 +1590,9 @@ discard block |
||
| 1503 | 1590 | $file_data = fetch_web_data($url); |
| 1504 | 1591 | |
| 1505 | 1592 | // If we got an error - give up - the site might be down. |
| 1506 | - if ($file_data === false) |
|
| 1507 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1593 | + if ($file_data === false) { |
|
| 1594 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1595 | + } |
|
| 1508 | 1596 | |
| 1509 | 1597 | // Save the file to the database. |
| 1510 | 1598 | $smcFunc['db_query']('substring', ' |
@@ -1546,8 +1634,9 @@ discard block |
||
| 1546 | 1634 | $themeData = array(); |
| 1547 | 1635 | foreach ($values as $variable => $value) |
| 1548 | 1636 | { |
| 1549 | - if (!isset($value) || $value === null) |
|
| 1550 | - $value = 0; |
|
| 1637 | + if (!isset($value) || $value === null) { |
|
| 1638 | + $value = 0; |
|
| 1639 | + } |
|
| 1551 | 1640 | |
| 1552 | 1641 | $themeData[] = array(0, 1, $variable, $value); |
| 1553 | 1642 | } |
@@ -1576,8 +1665,9 @@ discard block |
||
| 1576 | 1665 | |
| 1577 | 1666 | foreach ($values as $variable => $value) |
| 1578 | 1667 | { |
| 1579 | - if (empty($modSettings[$value[0]])) |
|
| 1580 | - continue; |
|
| 1668 | + if (empty($modSettings[$value[0]])) { |
|
| 1669 | + continue; |
|
| 1670 | + } |
|
| 1581 | 1671 | |
| 1582 | 1672 | $smcFunc['db_query']('', ' |
| 1583 | 1673 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1610,8 +1700,9 @@ discard block |
||
| 1610 | 1700 | |
| 1611 | 1701 | $settingsArray = file($boarddir . '/Settings_bak.php'); |
| 1612 | 1702 | |
| 1613 | - if (count($settingsArray) == 1) |
|
| 1614 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1703 | + if (count($settingsArray) == 1) { |
|
| 1704 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1705 | + } |
|
| 1615 | 1706 | |
| 1616 | 1707 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1617 | 1708 | { |
@@ -1624,9 +1715,9 @@ discard block |
||
| 1624 | 1715 | { |
| 1625 | 1716 | if (isset($settingsArray[$i]) && strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
| 1626 | 1717 | { |
| 1627 | - if ($val == '#remove#') |
|
| 1628 | - unset($settingsArray[$i]); |
|
| 1629 | - else |
|
| 1718 | + if ($val == '#remove#') { |
|
| 1719 | + unset($settingsArray[$i]); |
|
| 1720 | + } else |
|
| 1630 | 1721 | { |
| 1631 | 1722 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 1632 | 1723 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
@@ -1638,22 +1729,25 @@ discard block |
||
| 1638 | 1729 | } |
| 1639 | 1730 | if (isset($settingsArray[$i])) |
| 1640 | 1731 | { |
| 1641 | - if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') |
|
| 1642 | - $end = $i; |
|
| 1732 | + if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') { |
|
| 1733 | + $end = $i; |
|
| 1734 | + } |
|
| 1643 | 1735 | } |
| 1644 | 1736 | } |
| 1645 | 1737 | |
| 1646 | 1738 | // Assume end-of-file if the end wasn't found. |
| 1647 | - if (empty($end) || $end < 10) |
|
| 1648 | - $end = count($settingsArray); |
|
| 1739 | + if (empty($end) || $end < 10) { |
|
| 1740 | + $end = count($settingsArray); |
|
| 1741 | + } |
|
| 1649 | 1742 | |
| 1650 | 1743 | if (!empty($config_vars)) |
| 1651 | 1744 | { |
| 1652 | 1745 | $settingsArray[$end++] = ''; |
| 1653 | 1746 | foreach ($config_vars as $var => $val) |
| 1654 | 1747 | { |
| 1655 | - if ($val != '#remove#') |
|
| 1656 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 1748 | + if ($val != '#remove#') { |
|
| 1749 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 1750 | + } |
|
| 1657 | 1751 | } |
| 1658 | 1752 | } |
| 1659 | 1753 | // This should be the last line and even last bytes of the file. |
@@ -1666,8 +1760,9 @@ discard block |
||
| 1666 | 1760 | $fp = fopen($boarddir . '/Settings.php', 'r+'); |
| 1667 | 1761 | for ($i = 0; $i < $end; $i++) |
| 1668 | 1762 | { |
| 1669 | - if (isset($settingsArray[$i])) |
|
| 1670 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1763 | + if (isset($settingsArray[$i])) { |
|
| 1764 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1765 | + } |
|
| 1671 | 1766 | } |
| 1672 | 1767 | fwrite($fp, rtrim($settingsArray[$i])); |
| 1673 | 1768 | fclose($fp); |
@@ -1740,10 +1835,11 @@ discard block |
||
| 1740 | 1835 | { |
| 1741 | 1836 | global $support_js; |
| 1742 | 1837 | |
| 1743 | - if ($support_js) |
|
| 1744 | - return true; |
|
| 1745 | - else |
|
| 1746 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1838 | + if ($support_js) { |
|
| 1839 | + return true; |
|
| 1840 | + } else { |
|
| 1841 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1842 | + } |
|
| 1747 | 1843 | } |
| 1748 | 1844 | } |
| 1749 | 1845 | |
@@ -1761,8 +1857,9 @@ discard block |
||
| 1761 | 1857 | 'db_error_skip' => true, |
| 1762 | 1858 | ) |
| 1763 | 1859 | ); |
| 1764 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 1765 | - die('Unable to find members table!'); |
|
| 1860 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1861 | + die('Unable to find members table!'); |
|
| 1862 | + } |
|
| 1766 | 1863 | $table_status = $smcFunc['db_fetch_assoc']($request); |
| 1767 | 1864 | $smcFunc['db_free_result']($request); |
| 1768 | 1865 | |
@@ -1777,17 +1874,20 @@ discard block |
||
| 1777 | 1874 | ) |
| 1778 | 1875 | ); |
| 1779 | 1876 | // Got something? |
| 1780 | - if ($smcFunc['db_num_rows']($request) !== 0) |
|
| 1781 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 1877 | + if ($smcFunc['db_num_rows']($request) !== 0) { |
|
| 1878 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 1879 | + } |
|
| 1782 | 1880 | $smcFunc['db_free_result']($request); |
| 1783 | 1881 | |
| 1784 | 1882 | // Excellent! |
| 1785 | - if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) |
|
| 1786 | - $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
| 1883 | + if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) { |
|
| 1884 | + $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
| 1885 | + } |
|
| 1787 | 1886 | } |
| 1788 | 1887 | } |
| 1789 | - if (empty($db_collation)) |
|
| 1790 | - $db_collation = ''; |
|
| 1888 | + if (empty($db_collation)) { |
|
| 1889 | + $db_collation = ''; |
|
| 1890 | + } |
|
| 1791 | 1891 | |
| 1792 | 1892 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1793 | 1893 | |
@@ -1799,8 +1899,9 @@ discard block |
||
| 1799 | 1899 | $last_step = ''; |
| 1800 | 1900 | |
| 1801 | 1901 | // Make sure all newly created tables will have the proper characters set. |
| 1802 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1803 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1902 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1903 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1904 | + } |
|
| 1804 | 1905 | |
| 1805 | 1906 | // Count the total number of steps within this file - for progress. |
| 1806 | 1907 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1820,15 +1921,18 @@ discard block |
||
| 1820 | 1921 | $do_current = $substep >= $_GET['substep']; |
| 1821 | 1922 | |
| 1822 | 1923 | // Get rid of any comments in the beginning of the line... |
| 1823 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1824 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1924 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1925 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1926 | + } |
|
| 1825 | 1927 | |
| 1826 | 1928 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1827 | - if ($is_debug && !$support_js && $command_line) |
|
| 1828 | - flush(); |
|
| 1929 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1930 | + flush(); |
|
| 1931 | + } |
|
| 1829 | 1932 | |
| 1830 | - if (trim($line) === '') |
|
| 1831 | - continue; |
|
| 1933 | + if (trim($line) === '') { |
|
| 1934 | + continue; |
|
| 1935 | + } |
|
| 1832 | 1936 | |
| 1833 | 1937 | if (trim(substr($line, 0, 3)) === '---') |
| 1834 | 1938 | { |
@@ -1838,8 +1942,9 @@ discard block |
||
| 1838 | 1942 | if (trim($current_data) != '' && $type !== '}') |
| 1839 | 1943 | { |
| 1840 | 1944 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1841 | - if ($command_line) |
|
| 1842 | - echo $upcontext['error_message']; |
|
| 1945 | + if ($command_line) { |
|
| 1946 | + echo $upcontext['error_message']; |
|
| 1947 | + } |
|
| 1843 | 1948 | } |
| 1844 | 1949 | |
| 1845 | 1950 | if ($type == ' ') |
@@ -1857,17 +1962,18 @@ discard block |
||
| 1857 | 1962 | if ($do_current) |
| 1858 | 1963 | { |
| 1859 | 1964 | $upcontext['actioned_items'][] = $last_step; |
| 1860 | - if ($command_line) |
|
| 1861 | - echo ' * '; |
|
| 1965 | + if ($command_line) { |
|
| 1966 | + echo ' * '; |
|
| 1967 | + } |
|
| 1862 | 1968 | } |
| 1863 | - } |
|
| 1864 | - elseif ($type == '#') |
|
| 1969 | + } elseif ($type == '#') |
|
| 1865 | 1970 | { |
| 1866 | 1971 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1867 | 1972 | |
| 1868 | 1973 | $upcontext['current_debug_item_num']++; |
| 1869 | - if (trim($line) != '---#') |
|
| 1870 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1974 | + if (trim($line) != '---#') { |
|
| 1975 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1976 | + } |
|
| 1871 | 1977 | |
| 1872 | 1978 | // Have we already done something? |
| 1873 | 1979 | if (isset($_GET['xml']) && $done_something) |
@@ -1878,34 +1984,36 @@ discard block |
||
| 1878 | 1984 | |
| 1879 | 1985 | if ($do_current) |
| 1880 | 1986 | { |
| 1881 | - if (trim($line) == '---#' && $command_line) |
|
| 1882 | - echo ' done.', $endl; |
|
| 1883 | - elseif ($command_line) |
|
| 1884 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1885 | - elseif (trim($line) != '---#') |
|
| 1987 | + if (trim($line) == '---#' && $command_line) { |
|
| 1988 | + echo ' done.', $endl; |
|
| 1989 | + } elseif ($command_line) { |
|
| 1990 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1991 | + } elseif (trim($line) != '---#') |
|
| 1886 | 1992 | { |
| 1887 | - if ($is_debug) |
|
| 1888 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1993 | + if ($is_debug) { |
|
| 1994 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1995 | + } |
|
| 1889 | 1996 | } |
| 1890 | 1997 | } |
| 1891 | 1998 | |
| 1892 | 1999 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1893 | 2000 | { |
| 1894 | - if ($command_line) |
|
| 1895 | - echo ' * '; |
|
| 1896 | - else |
|
| 1897 | - $upcontext['actioned_items'][] = $last_step; |
|
| 2001 | + if ($command_line) { |
|
| 2002 | + echo ' * '; |
|
| 2003 | + } else { |
|
| 2004 | + $upcontext['actioned_items'][] = $last_step; |
|
| 2005 | + } |
|
| 1898 | 2006 | } |
| 1899 | 2007 | |
| 1900 | 2008 | // Small step - only if we're actually doing stuff. |
| 1901 | - if ($do_current) |
|
| 1902 | - nextSubstep(++$substep); |
|
| 1903 | - else |
|
| 1904 | - $substep++; |
|
| 1905 | - } |
|
| 1906 | - elseif ($type == '{') |
|
| 1907 | - $current_type = 'code'; |
|
| 1908 | - elseif ($type == '}') |
|
| 2009 | + if ($do_current) { |
|
| 2010 | + nextSubstep(++$substep); |
|
| 2011 | + } else { |
|
| 2012 | + $substep++; |
|
| 2013 | + } |
|
| 2014 | + } elseif ($type == '{') { |
|
| 2015 | + $current_type = 'code'; |
|
| 2016 | + } elseif ($type == '}') |
|
| 1909 | 2017 | { |
| 1910 | 2018 | $current_type = 'sql'; |
| 1911 | 2019 | |
@@ -1918,8 +2026,9 @@ discard block |
||
| 1918 | 2026 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1919 | 2027 | { |
| 1920 | 2028 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1921 | - if ($command_line) |
|
| 1922 | - echo $upcontext['error_message']; |
|
| 2029 | + if ($command_line) { |
|
| 2030 | + echo $upcontext['error_message']; |
|
| 2031 | + } |
|
| 1923 | 2032 | } |
| 1924 | 2033 | |
| 1925 | 2034 | // Done with code! |
@@ -1999,8 +2108,9 @@ discard block |
||
| 1999 | 2108 | $db_unbuffered = false; |
| 2000 | 2109 | |
| 2001 | 2110 | // Failure?! |
| 2002 | - if ($result !== false) |
|
| 2003 | - return $result; |
|
| 2111 | + if ($result !== false) { |
|
| 2112 | + return $result; |
|
| 2113 | + } |
|
| 2004 | 2114 | |
| 2005 | 2115 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 2006 | 2116 | // If MySQL we do something more clever. |
@@ -2028,54 +2138,61 @@ discard block |
||
| 2028 | 2138 | { |
| 2029 | 2139 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 2030 | 2140 | $result = mysqli_query($db_connection, $string); |
| 2031 | - if ($result !== false) |
|
| 2032 | - return $result; |
|
| 2141 | + if ($result !== false) { |
|
| 2142 | + return $result; |
|
| 2143 | + } |
|
| 2033 | 2144 | } |
| 2034 | - } |
|
| 2035 | - elseif ($mysqli_errno == 2013) |
|
| 2145 | + } elseif ($mysqli_errno == 2013) |
|
| 2036 | 2146 | { |
| 2037 | 2147 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 2038 | 2148 | mysqli_select_db($db_connection, $db_name); |
| 2039 | 2149 | if ($db_connection) |
| 2040 | 2150 | { |
| 2041 | 2151 | $result = mysqli_query($db_connection, $string); |
| 2042 | - if ($result !== false) |
|
| 2043 | - return $result; |
|
| 2152 | + if ($result !== false) { |
|
| 2153 | + return $result; |
|
| 2154 | + } |
|
| 2044 | 2155 | } |
| 2045 | 2156 | } |
| 2046 | 2157 | // Duplicate column name... should be okay ;). |
| 2047 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 2048 | - return false; |
|
| 2158 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2159 | + return false; |
|
| 2160 | + } |
|
| 2049 | 2161 | // Duplicate insert... make sure it's the proper type of query ;). |
| 2050 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 2051 | - return false; |
|
| 2162 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2163 | + return false; |
|
| 2164 | + } |
|
| 2052 | 2165 | // Creating an index on a non-existent column. |
| 2053 | - elseif ($mysqli_errno == 1072) |
|
| 2054 | - return false; |
|
| 2055 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 2056 | - return false; |
|
| 2166 | + elseif ($mysqli_errno == 1072) { |
|
| 2167 | + return false; |
|
| 2168 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2169 | + return false; |
|
| 2170 | + } |
|
| 2057 | 2171 | } |
| 2058 | 2172 | // If a table already exists don't go potty. |
| 2059 | 2173 | else |
| 2060 | 2174 | { |
| 2061 | 2175 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 2062 | 2176 | { |
| 2063 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 2064 | - return true; |
|
| 2065 | - } |
|
| 2066 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2177 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2178 | + return true; |
|
| 2179 | + } |
|
| 2180 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2067 | 2181 | { |
| 2068 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 2069 | - return true; |
|
| 2182 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2183 | + return true; |
|
| 2184 | + } |
|
| 2070 | 2185 | } |
| 2071 | 2186 | } |
| 2072 | 2187 | |
| 2073 | 2188 | // Get the query string so we pass everything. |
| 2074 | 2189 | $query_string = ''; |
| 2075 | - foreach ($_GET as $k => $v) |
|
| 2076 | - $query_string .= ';' . $k . '=' . $v; |
|
| 2077 | - if (strlen($query_string) != 0) |
|
| 2078 | - $query_string = '?' . substr($query_string, 1); |
|
| 2190 | + foreach ($_GET as $k => $v) { |
|
| 2191 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2192 | + } |
|
| 2193 | + if (strlen($query_string) != 0) { |
|
| 2194 | + $query_string = '?' . substr($query_string, 1); |
|
| 2195 | + } |
|
| 2079 | 2196 | |
| 2080 | 2197 | if ($command_line) |
| 2081 | 2198 | { |
@@ -2130,16 +2247,18 @@ discard block |
||
| 2130 | 2247 | { |
| 2131 | 2248 | $found |= 1; |
| 2132 | 2249 | // Do some checks on the data if we have it set. |
| 2133 | - if (isset($change['col_type'])) |
|
| 2134 | - $found &= $change['col_type'] === $column['type']; |
|
| 2135 | - if (isset($change['null_allowed'])) |
|
| 2136 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2137 | - if (isset($change['default'])) |
|
| 2138 | - $found &= $change['default'] === $column['default']; |
|
| 2250 | + if (isset($change['col_type'])) { |
|
| 2251 | + $found &= $change['col_type'] === $column['type']; |
|
| 2252 | + } |
|
| 2253 | + if (isset($change['null_allowed'])) { |
|
| 2254 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2255 | + } |
|
| 2256 | + if (isset($change['default'])) { |
|
| 2257 | + $found &= $change['default'] === $column['default']; |
|
| 2258 | + } |
|
| 2139 | 2259 | } |
| 2140 | 2260 | } |
| 2141 | - } |
|
| 2142 | - elseif ($change['type'] === 'index') |
|
| 2261 | + } elseif ($change['type'] === 'index') |
|
| 2143 | 2262 | { |
| 2144 | 2263 | $request = upgrade_query(' |
| 2145 | 2264 | SHOW INDEX |
@@ -2148,9 +2267,10 @@ discard block |
||
| 2148 | 2267 | { |
| 2149 | 2268 | $cur_index = array(); |
| 2150 | 2269 | |
| 2151 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2152 | - if ($row['Key_name'] === $change['name']) |
|
| 2270 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2271 | + if ($row['Key_name'] === $change['name']) |
|
| 2153 | 2272 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2273 | + } |
|
| 2154 | 2274 | |
| 2155 | 2275 | ksort($cur_index, SORT_NUMERIC); |
| 2156 | 2276 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2160,14 +2280,17 @@ discard block |
||
| 2160 | 2280 | } |
| 2161 | 2281 | |
| 2162 | 2282 | // If we're trying to add and it's added, we're done. |
| 2163 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2164 | - return true; |
|
| 2283 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2284 | + return true; |
|
| 2285 | + } |
|
| 2165 | 2286 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2166 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2167 | - return true; |
|
| 2287 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2288 | + return true; |
|
| 2289 | + } |
|
| 2168 | 2290 | // Otherwise is it just a test? |
| 2169 | - elseif ($is_test) |
|
| 2170 | - return false; |
|
| 2291 | + elseif ($is_test) { |
|
| 2292 | + return false; |
|
| 2293 | + } |
|
| 2171 | 2294 | |
| 2172 | 2295 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2173 | 2296 | $running = false; |
@@ -2178,8 +2301,9 @@ discard block |
||
| 2178 | 2301 | SHOW FULL PROCESSLIST'); |
| 2179 | 2302 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2180 | 2303 | { |
| 2181 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2182 | - $found = true; |
|
| 2304 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2305 | + $found = true; |
|
| 2306 | + } |
|
| 2183 | 2307 | } |
| 2184 | 2308 | |
| 2185 | 2309 | // Can't find it? Then we need to run it fools! |
@@ -2191,8 +2315,9 @@ discard block |
||
| 2191 | 2315 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2192 | 2316 | ' . $change['text'], true) !== false; |
| 2193 | 2317 | |
| 2194 | - if (!$success) |
|
| 2195 | - return false; |
|
| 2318 | + if (!$success) { |
|
| 2319 | + return false; |
|
| 2320 | + } |
|
| 2196 | 2321 | |
| 2197 | 2322 | // Return |
| 2198 | 2323 | $running = true; |
@@ -2234,8 +2359,9 @@ discard block |
||
| 2234 | 2359 | 'db_error_skip' => true, |
| 2235 | 2360 | ) |
| 2236 | 2361 | ); |
| 2237 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2238 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2362 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2363 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2364 | + } |
|
| 2239 | 2365 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2240 | 2366 | $smcFunc['db_free_result']($request); |
| 2241 | 2367 | |
@@ -2257,18 +2383,19 @@ discard block |
||
| 2257 | 2383 | ) |
| 2258 | 2384 | ); |
| 2259 | 2385 | // No results? Just forget it all together. |
| 2260 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2261 | - unset($table_row['Collation']); |
|
| 2262 | - else |
|
| 2263 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2386 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2387 | + unset($table_row['Collation']); |
|
| 2388 | + } else { |
|
| 2389 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2390 | + } |
|
| 2264 | 2391 | $smcFunc['db_free_result']($request); |
| 2265 | 2392 | } |
| 2266 | 2393 | |
| 2267 | 2394 | if ($column_fix) |
| 2268 | 2395 | { |
| 2269 | 2396 | // Make sure there are no NULL's left. |
| 2270 | - if ($null_fix) |
|
| 2271 | - $smcFunc['db_query']('', ' |
|
| 2397 | + if ($null_fix) { |
|
| 2398 | + $smcFunc['db_query']('', ' |
|
| 2272 | 2399 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2273 | 2400 | SET ' . $change['column'] . ' = {string:default} |
| 2274 | 2401 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2277,6 +2404,7 @@ discard block |
||
| 2277 | 2404 | 'db_error_skip' => true, |
| 2278 | 2405 | ) |
| 2279 | 2406 | ); |
| 2407 | + } |
|
| 2280 | 2408 | |
| 2281 | 2409 | // Do the actual alteration. |
| 2282 | 2410 | $smcFunc['db_query']('', ' |
@@ -2305,8 +2433,9 @@ discard block |
||
| 2305 | 2433 | } |
| 2306 | 2434 | |
| 2307 | 2435 | // Not a column we need to check on? |
| 2308 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2309 | - return; |
|
| 2436 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2437 | + return; |
|
| 2438 | + } |
|
| 2310 | 2439 | |
| 2311 | 2440 | // Break it up you (six|seven). |
| 2312 | 2441 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2325,13 +2454,13 @@ discard block |
||
| 2325 | 2454 | 'new_name' => $temp[2], |
| 2326 | 2455 | )); |
| 2327 | 2456 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2328 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2329 | - return; |
|
| 2457 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2458 | + return; |
|
| 2459 | + } |
|
| 2330 | 2460 | |
| 2331 | 2461 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2332 | 2462 | $smcFunc['db_free_result']($request); |
| 2333 | - } |
|
| 2334 | - else |
|
| 2463 | + } else |
|
| 2335 | 2464 | { |
| 2336 | 2465 | // Do this the old fashion, sure method way. |
| 2337 | 2466 | $request = $smcFunc['db_query']('', ' |
@@ -2342,21 +2471,24 @@ discard block |
||
| 2342 | 2471 | )); |
| 2343 | 2472 | // Mayday! |
| 2344 | 2473 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2345 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2346 | - return; |
|
| 2474 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2475 | + return; |
|
| 2476 | + } |
|
| 2347 | 2477 | |
| 2348 | 2478 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2349 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2350 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2479 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2480 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2351 | 2481 | { |
| 2352 | 2482 | $current_type = $row['Type']; |
| 2483 | + } |
|
| 2353 | 2484 | break; |
| 2354 | 2485 | } |
| 2355 | 2486 | } |
| 2356 | 2487 | |
| 2357 | 2488 | // If this doesn't match, the column may of been altered for a reason. |
| 2358 | - if (trim($current_type) != trim($temp[3])) |
|
| 2359 | - $temp[3] = $current_type; |
|
| 2489 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2490 | + $temp[3] = $current_type; |
|
| 2491 | + } |
|
| 2360 | 2492 | |
| 2361 | 2493 | // Piece this back together. |
| 2362 | 2494 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2368,8 +2500,9 @@ discard block |
||
| 2368 | 2500 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2369 | 2501 | global $step_progress, $is_debug, $upcontext; |
| 2370 | 2502 | |
| 2371 | - if ($_GET['substep'] < $substep) |
|
| 2372 | - $_GET['substep'] = $substep; |
|
| 2503 | + if ($_GET['substep'] < $substep) { |
|
| 2504 | + $_GET['substep'] = $substep; |
|
| 2505 | + } |
|
| 2373 | 2506 | |
| 2374 | 2507 | if ($command_line) |
| 2375 | 2508 | { |
@@ -2382,29 +2515,33 @@ discard block |
||
| 2382 | 2515 | } |
| 2383 | 2516 | |
| 2384 | 2517 | @set_time_limit(300); |
| 2385 | - if (function_exists('apache_reset_timeout')) |
|
| 2386 | - @apache_reset_timeout(); |
|
| 2518 | + if (function_exists('apache_reset_timeout')) { |
|
| 2519 | + @apache_reset_timeout(); |
|
| 2520 | + } |
|
| 2387 | 2521 | |
| 2388 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2389 | - return; |
|
| 2522 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2523 | + return; |
|
| 2524 | + } |
|
| 2390 | 2525 | |
| 2391 | 2526 | // Do we have some custom step progress stuff? |
| 2392 | 2527 | if (!empty($step_progress)) |
| 2393 | 2528 | { |
| 2394 | 2529 | $upcontext['substep_progress'] = 0; |
| 2395 | 2530 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2396 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2397 | - $upcontext['substep_progress'] = 99.9; |
|
| 2398 | - else |
|
| 2399 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2531 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2532 | + $upcontext['substep_progress'] = 99.9; |
|
| 2533 | + } else { |
|
| 2534 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2535 | + } |
|
| 2400 | 2536 | |
| 2401 | 2537 | // Make it nicely rounded. |
| 2402 | 2538 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2403 | 2539 | } |
| 2404 | 2540 | |
| 2405 | 2541 | // If this is XML we just exit right away! |
| 2406 | - if (isset($_GET['xml'])) |
|
| 2407 | - return upgradeExit(); |
|
| 2542 | + if (isset($_GET['xml'])) { |
|
| 2543 | + return upgradeExit(); |
|
| 2544 | + } |
|
| 2408 | 2545 | |
| 2409 | 2546 | // We're going to pause after this! |
| 2410 | 2547 | $upcontext['pause'] = true; |
@@ -2412,13 +2549,15 @@ discard block |
||
| 2412 | 2549 | $upcontext['query_string'] = ''; |
| 2413 | 2550 | foreach ($_GET as $k => $v) |
| 2414 | 2551 | { |
| 2415 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2416 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2552 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2553 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2554 | + } |
|
| 2417 | 2555 | } |
| 2418 | 2556 | |
| 2419 | 2557 | // Custom warning? |
| 2420 | - if (!empty($custom_warning)) |
|
| 2421 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2558 | + if (!empty($custom_warning)) { |
|
| 2559 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2560 | + } |
|
| 2422 | 2561 | |
| 2423 | 2562 | upgradeExit(); |
| 2424 | 2563 | } |
@@ -2433,25 +2572,26 @@ discard block |
||
| 2433 | 2572 | ob_implicit_flush(true); |
| 2434 | 2573 | @set_time_limit(600); |
| 2435 | 2574 | |
| 2436 | - if (!isset($_SERVER['argv'])) |
|
| 2437 | - $_SERVER['argv'] = array(); |
|
| 2575 | + if (!isset($_SERVER['argv'])) { |
|
| 2576 | + $_SERVER['argv'] = array(); |
|
| 2577 | + } |
|
| 2438 | 2578 | $_GET['maint'] = 1; |
| 2439 | 2579 | |
| 2440 | 2580 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2441 | 2581 | { |
| 2442 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2443 | - $_GET['lang'] = $match[1]; |
|
| 2444 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2445 | - continue; |
|
| 2446 | - elseif ($arg == '--no-maintenance') |
|
| 2447 | - $_GET['maint'] = 0; |
|
| 2448 | - elseif ($arg == '--debug') |
|
| 2449 | - $is_debug = true; |
|
| 2450 | - elseif ($arg == '--backup') |
|
| 2451 | - $_POST['backup'] = 1; |
|
| 2452 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2453 | - $_GET['conv'] = 1; |
|
| 2454 | - elseif ($i != 0) |
|
| 2582 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2583 | + $_GET['lang'] = $match[1]; |
|
| 2584 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2585 | + continue; |
|
| 2586 | + } elseif ($arg == '--no-maintenance') { |
|
| 2587 | + $_GET['maint'] = 0; |
|
| 2588 | + } elseif ($arg == '--debug') { |
|
| 2589 | + $is_debug = true; |
|
| 2590 | + } elseif ($arg == '--backup') { |
|
| 2591 | + $_POST['backup'] = 1; |
|
| 2592 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2593 | + $_GET['conv'] = 1; |
|
| 2594 | + } elseif ($i != 0) |
|
| 2455 | 2595 | { |
| 2456 | 2596 | echo 'SMF Command-line Upgrader |
| 2457 | 2597 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2465,10 +2605,12 @@ discard block |
||
| 2465 | 2605 | } |
| 2466 | 2606 | } |
| 2467 | 2607 | |
| 2468 | - if (!php_version_check()) |
|
| 2469 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2470 | - if (!db_version_check()) |
|
| 2471 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2608 | + if (!php_version_check()) { |
|
| 2609 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2610 | + } |
|
| 2611 | + if (!db_version_check()) { |
|
| 2612 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2613 | + } |
|
| 2472 | 2614 | |
| 2473 | 2615 | // Do some checks to make sure they have proper privileges |
| 2474 | 2616 | db_extend('packages'); |
@@ -2483,34 +2625,39 @@ discard block |
||
| 2483 | 2625 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2484 | 2626 | |
| 2485 | 2627 | // Sorry... we need CREATE, ALTER and DROP |
| 2486 | - if (!$create || !$alter || !$drop) |
|
| 2487 | - 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); |
|
| 2628 | + if (!$create || !$alter || !$drop) { |
|
| 2629 | + 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); |
|
| 2630 | + } |
|
| 2488 | 2631 | |
| 2489 | 2632 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2490 | 2633 | && @file_exists($sourcedir . '/QueryString.php') |
| 2491 | 2634 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2492 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2493 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2635 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2636 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2637 | + } |
|
| 2494 | 2638 | |
| 2495 | 2639 | // Do a quick version spot check. |
| 2496 | 2640 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2497 | 2641 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2498 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2499 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2642 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2643 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2644 | + } |
|
| 2500 | 2645 | |
| 2501 | 2646 | // Make sure Settings.php is writable. |
| 2502 | 2647 | quickFileWritable($boarddir . '/Settings.php'); |
| 2503 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2504 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2648 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2649 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2650 | + } |
|
| 2505 | 2651 | |
| 2506 | 2652 | // Make sure Settings_bak.php is writable. |
| 2507 | 2653 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2508 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2509 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2654 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2655 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2656 | + } |
|
| 2510 | 2657 | |
| 2511 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2512 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2513 | - elseif (isset($modSettings['agreement'])) |
|
| 2658 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2659 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2660 | + } elseif (isset($modSettings['agreement'])) |
|
| 2514 | 2661 | { |
| 2515 | 2662 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2516 | 2663 | fwrite($fp, $modSettings['agreement']); |
@@ -2520,31 +2667,36 @@ discard block |
||
| 2520 | 2667 | // Make sure Themes is writable. |
| 2521 | 2668 | quickFileWritable($modSettings['theme_dir']); |
| 2522 | 2669 | |
| 2523 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2524 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2670 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2671 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2672 | + } |
|
| 2525 | 2673 | |
| 2526 | 2674 | // Make sure cache directory exists and is writable! |
| 2527 | 2675 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2528 | - if (!file_exists($cachedir_temp)) |
|
| 2529 | - @mkdir($cachedir_temp); |
|
| 2676 | + if (!file_exists($cachedir_temp)) { |
|
| 2677 | + @mkdir($cachedir_temp); |
|
| 2678 | + } |
|
| 2530 | 2679 | |
| 2531 | 2680 | // Make sure the cache temp dir is writable. |
| 2532 | 2681 | quickFileWritable($cachedir_temp); |
| 2533 | 2682 | |
| 2534 | - if (!is_writable($cachedir_temp)) |
|
| 2535 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2683 | + if (!is_writable($cachedir_temp)) { |
|
| 2684 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2685 | + } |
|
| 2536 | 2686 | |
| 2537 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2538 | - print_error('Error: Unable to find language files!', true); |
|
| 2539 | - else |
|
| 2687 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2688 | + print_error('Error: Unable to find language files!', true); |
|
| 2689 | + } else |
|
| 2540 | 2690 | { |
| 2541 | 2691 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2542 | 2692 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2543 | 2693 | |
| 2544 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2545 | - print_error('Error: Language files out of date.', true); |
|
| 2546 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2547 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2694 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2695 | + print_error('Error: Language files out of date.', true); |
|
| 2696 | + } |
|
| 2697 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2698 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2699 | + } |
|
| 2548 | 2700 | |
| 2549 | 2701 | // Otherwise include it! |
| 2550 | 2702 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2573,8 +2725,7 @@ discard block |
||
| 2573 | 2725 | ); |
| 2574 | 2726 | |
| 2575 | 2727 | return true; |
| 2576 | - } |
|
| 2577 | - else |
|
| 2728 | + } else |
|
| 2578 | 2729 | { |
| 2579 | 2730 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2580 | 2731 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2618,8 +2769,9 @@ discard block |
||
| 2618 | 2769 | ) |
| 2619 | 2770 | ); |
| 2620 | 2771 | $db_charsets = array(); |
| 2621 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2622 | - $db_charsets[] = $row['Charset']; |
|
| 2772 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2773 | + $db_charsets[] = $row['Charset']; |
|
| 2774 | + } |
|
| 2623 | 2775 | |
| 2624 | 2776 | $smcFunc['db_free_result']($request); |
| 2625 | 2777 | |
@@ -2655,13 +2807,15 @@ discard block |
||
| 2655 | 2807 | // If there's a fulltext index, we need to drop it first... |
| 2656 | 2808 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2657 | 2809 | { |
| 2658 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2659 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2810 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2811 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2660 | 2812 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2813 | + } |
|
| 2661 | 2814 | $smcFunc['db_free_result']($request); |
| 2662 | 2815 | |
| 2663 | - if (isset($upcontext['fulltext_index'])) |
|
| 2664 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2816 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2817 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2818 | + } |
|
| 2665 | 2819 | } |
| 2666 | 2820 | |
| 2667 | 2821 | // Drop it and make a note... |
@@ -2851,8 +3005,9 @@ discard block |
||
| 2851 | 3005 | $replace = '%field%'; |
| 2852 | 3006 | |
| 2853 | 3007 | // Build a huge REPLACE statement... |
| 2854 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2855 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3008 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 3009 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3010 | + } |
|
| 2856 | 3011 | } |
| 2857 | 3012 | |
| 2858 | 3013 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2886,8 +3041,9 @@ discard block |
||
| 2886 | 3041 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 2887 | 3042 | |
| 2888 | 3043 | // Just to make sure it doesn't time out. |
| 2889 | - if (function_exists('apache_reset_timeout')) |
|
| 2890 | - @apache_reset_timeout(); |
|
| 3044 | + if (function_exists('apache_reset_timeout')) { |
|
| 3045 | + @apache_reset_timeout(); |
|
| 3046 | + } |
|
| 2891 | 3047 | |
| 2892 | 3048 | $table_charsets = array(); |
| 2893 | 3049 | |
@@ -2908,8 +3064,9 @@ discard block |
||
| 2908 | 3064 | { |
| 2909 | 3065 | list($charset) = explode('_', $collation); |
| 2910 | 3066 | |
| 2911 | - if (!isset($table_charsets[$charset])) |
|
| 2912 | - $table_charsets[$charset] = array(); |
|
| 3067 | + if (!isset($table_charsets[$charset])) { |
|
| 3068 | + $table_charsets[$charset] = array(); |
|
| 3069 | + } |
|
| 2913 | 3070 | |
| 2914 | 3071 | $table_charsets[$charset][] = $column_info; |
| 2915 | 3072 | } |
@@ -2949,10 +3106,11 @@ discard block |
||
| 2949 | 3106 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2950 | 3107 | { |
| 2951 | 3108 | $update = ''; |
| 2952 | - foreach ($table_charsets as $charset => $columns) |
|
| 2953 | - foreach ($columns as $column) |
|
| 3109 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3110 | + foreach ($columns as $column) |
|
| 2954 | 3111 | $update .= ' |
| 2955 | 3112 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3113 | + } |
|
| 2956 | 3114 | |
| 2957 | 3115 | $smcFunc['db_query']('', ' |
| 2958 | 3116 | UPDATE {raw:table_name} |
@@ -2977,8 +3135,9 @@ discard block |
||
| 2977 | 3135 | // Now do the actual conversion (if still needed). |
| 2978 | 3136 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2979 | 3137 | { |
| 2980 | - if ($command_line) |
|
| 2981 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3138 | + if ($command_line) { |
|
| 3139 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3140 | + } |
|
| 2982 | 3141 | |
| 2983 | 3142 | $smcFunc['db_query']('', ' |
| 2984 | 3143 | ALTER TABLE {raw:table_name} |
@@ -2988,8 +3147,9 @@ discard block |
||
| 2988 | 3147 | ) |
| 2989 | 3148 | ); |
| 2990 | 3149 | |
| 2991 | - if ($command_line) |
|
| 2992 | - echo " done.\n"; |
|
| 3150 | + if ($command_line) { |
|
| 3151 | + echo " done.\n"; |
|
| 3152 | + } |
|
| 2993 | 3153 | } |
| 2994 | 3154 | } |
| 2995 | 3155 | |
@@ -3019,8 +3179,8 @@ discard block |
||
| 3019 | 3179 | ); |
| 3020 | 3180 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3021 | 3181 | { |
| 3022 | - 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) |
|
| 3023 | - $smcFunc['db_query']('', ' |
|
| 3182 | + 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) { |
|
| 3183 | + $smcFunc['db_query']('', ' |
|
| 3024 | 3184 | UPDATE {db_prefix}log_actions |
| 3025 | 3185 | SET extra = {string:extra} |
| 3026 | 3186 | WHERE id_action = {int:current_action}', |
@@ -3029,6 +3189,7 @@ discard block |
||
| 3029 | 3189 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 3030 | 3190 | ) |
| 3031 | 3191 | ); |
| 3192 | + } |
|
| 3032 | 3193 | } |
| 3033 | 3194 | $smcFunc['db_free_result']($request); |
| 3034 | 3195 | |
@@ -3050,15 +3211,17 @@ discard block |
||
| 3050 | 3211 | // First thing's first - did we already do this? |
| 3051 | 3212 | if (!empty($modSettings['json_done'])) |
| 3052 | 3213 | { |
| 3053 | - if ($command_line) |
|
| 3054 | - return DeleteUpgrade(); |
|
| 3055 | - else |
|
| 3056 | - return true; |
|
| 3214 | + if ($command_line) { |
|
| 3215 | + return DeleteUpgrade(); |
|
| 3216 | + } else { |
|
| 3217 | + return true; |
|
| 3218 | + } |
|
| 3057 | 3219 | } |
| 3058 | 3220 | |
| 3059 | 3221 | // Done it already - js wise? |
| 3060 | - if (!empty($_POST['json_done'])) |
|
| 3061 | - return true; |
|
| 3222 | + if (!empty($_POST['json_done'])) { |
|
| 3223 | + return true; |
|
| 3224 | + } |
|
| 3062 | 3225 | |
| 3063 | 3226 | // List of tables affected by this function |
| 3064 | 3227 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3089,12 +3252,14 @@ discard block |
||
| 3089 | 3252 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3090 | 3253 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3091 | 3254 | |
| 3092 | - foreach ($keys as $id => $table) |
|
| 3093 | - if ($id < $_GET['substep']) |
|
| 3255 | + foreach ($keys as $id => $table) { |
|
| 3256 | + if ($id < $_GET['substep']) |
|
| 3094 | 3257 | $upcontext['previous_tables'][] = $table; |
| 3258 | + } |
|
| 3095 | 3259 | |
| 3096 | - if ($command_line) |
|
| 3097 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3260 | + if ($command_line) { |
|
| 3261 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3262 | + } |
|
| 3098 | 3263 | |
| 3099 | 3264 | if (!$support_js || isset($_GET['xml'])) |
| 3100 | 3265 | { |
@@ -3134,8 +3299,9 @@ discard block |
||
| 3134 | 3299 | |
| 3135 | 3300 | // Loop through and fix these... |
| 3136 | 3301 | $new_settings = array(); |
| 3137 | - if ($command_line) |
|
| 3138 | - echo "\n" . 'Fixing some settings...'; |
|
| 3302 | + if ($command_line) { |
|
| 3303 | + echo "\n" . 'Fixing some settings...'; |
|
| 3304 | + } |
|
| 3139 | 3305 | |
| 3140 | 3306 | foreach ($serialized_settings as $var) |
| 3141 | 3307 | { |
@@ -3143,22 +3309,24 @@ discard block |
||
| 3143 | 3309 | { |
| 3144 | 3310 | // Attempt to unserialize the setting |
| 3145 | 3311 | $temp = @safe_unserialize($modSettings[$var]); |
| 3146 | - if (!$temp && $command_line) |
|
| 3147 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3148 | - elseif ($temp !== false) |
|
| 3149 | - $new_settings[$var] = json_encode($temp); |
|
| 3312 | + if (!$temp && $command_line) { |
|
| 3313 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3314 | + } elseif ($temp !== false) { |
|
| 3315 | + $new_settings[$var] = json_encode($temp); |
|
| 3316 | + } |
|
| 3150 | 3317 | } |
| 3151 | 3318 | } |
| 3152 | 3319 | |
| 3153 | 3320 | // Update everything at once |
| 3154 | - if (!function_exists('cache_put_data')) |
|
| 3155 | - require_once($sourcedir . '/Load.php'); |
|
| 3321 | + if (!function_exists('cache_put_data')) { |
|
| 3322 | + require_once($sourcedir . '/Load.php'); |
|
| 3323 | + } |
|
| 3156 | 3324 | updateSettings($new_settings, true); |
| 3157 | 3325 | |
| 3158 | - if ($command_line) |
|
| 3159 | - echo ' done.'; |
|
| 3160 | - } |
|
| 3161 | - elseif ($table == 'themes') |
|
| 3326 | + if ($command_line) { |
|
| 3327 | + echo ' done.'; |
|
| 3328 | + } |
|
| 3329 | + } elseif ($table == 'themes') |
|
| 3162 | 3330 | { |
| 3163 | 3331 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3164 | 3332 | $query = $smcFunc['db_query']('', ' |
@@ -3177,10 +3345,11 @@ discard block |
||
| 3177 | 3345 | |
| 3178 | 3346 | if ($command_line) |
| 3179 | 3347 | { |
| 3180 | - if ($temp === false) |
|
| 3181 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3182 | - else |
|
| 3183 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3348 | + if ($temp === false) { |
|
| 3349 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3350 | + } else { |
|
| 3351 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3352 | + } |
|
| 3184 | 3353 | } |
| 3185 | 3354 | |
| 3186 | 3355 | if ($temp !== false) |
@@ -3200,15 +3369,15 @@ discard block |
||
| 3200 | 3369 | ) |
| 3201 | 3370 | ); |
| 3202 | 3371 | |
| 3203 | - if ($command_line) |
|
| 3204 | - echo ' done.'; |
|
| 3372 | + if ($command_line) { |
|
| 3373 | + echo ' done.'; |
|
| 3374 | + } |
|
| 3205 | 3375 | } |
| 3206 | 3376 | } |
| 3207 | 3377 | |
| 3208 | 3378 | $smcFunc['db_free_result']($query); |
| 3209 | 3379 | } |
| 3210 | - } |
|
| 3211 | - else |
|
| 3380 | + } else |
|
| 3212 | 3381 | { |
| 3213 | 3382 | // First item is always the key... |
| 3214 | 3383 | $key = $info[0]; |
@@ -3219,8 +3388,7 @@ discard block |
||
| 3219 | 3388 | { |
| 3220 | 3389 | $col_select = $info[1]; |
| 3221 | 3390 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3222 | - } |
|
| 3223 | - else |
|
| 3391 | + } else |
|
| 3224 | 3392 | { |
| 3225 | 3393 | $col_select = implode(', ', $info); |
| 3226 | 3394 | } |
@@ -3253,8 +3421,7 @@ discard block |
||
| 3253 | 3421 | if ($temp === false && $command_line) |
| 3254 | 3422 | { |
| 3255 | 3423 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3256 | - } |
|
| 3257 | - else |
|
| 3424 | + } else |
|
| 3258 | 3425 | { |
| 3259 | 3426 | $row[$col] = json_encode($temp); |
| 3260 | 3427 | |
@@ -3279,16 +3446,18 @@ discard block |
||
| 3279 | 3446 | } |
| 3280 | 3447 | } |
| 3281 | 3448 | |
| 3282 | - if ($command_line) |
|
| 3283 | - echo ' done.'; |
|
| 3449 | + if ($command_line) { |
|
| 3450 | + echo ' done.'; |
|
| 3451 | + } |
|
| 3284 | 3452 | |
| 3285 | 3453 | // Free up some memory... |
| 3286 | 3454 | $smcFunc['db_free_result']($query); |
| 3287 | 3455 | } |
| 3288 | 3456 | } |
| 3289 | 3457 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3290 | - if (isset($_GET['xml'])) |
|
| 3291 | - return upgradeExit(); |
|
| 3458 | + if (isset($_GET['xml'])) { |
|
| 3459 | + return upgradeExit(); |
|
| 3460 | + } |
|
| 3292 | 3461 | } |
| 3293 | 3462 | |
| 3294 | 3463 | if ($command_line) |
@@ -3303,8 +3472,9 @@ discard block |
||
| 3303 | 3472 | |
| 3304 | 3473 | $_GET['substep'] = 0; |
| 3305 | 3474 | // Make sure we move on! |
| 3306 | - if ($command_line) |
|
| 3307 | - return DeleteUpgrade(); |
|
| 3475 | + if ($command_line) { |
|
| 3476 | + return DeleteUpgrade(); |
|
| 3477 | + } |
|
| 3308 | 3478 | |
| 3309 | 3479 | return true; |
| 3310 | 3480 | } |
@@ -3324,14 +3494,16 @@ discard block |
||
| 3324 | 3494 | global $upcontext, $txt, $settings; |
| 3325 | 3495 | |
| 3326 | 3496 | // Don't call me twice! |
| 3327 | - if (!empty($upcontext['chmod_called'])) |
|
| 3328 | - return; |
|
| 3497 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3498 | + return; |
|
| 3499 | + } |
|
| 3329 | 3500 | |
| 3330 | 3501 | $upcontext['chmod_called'] = true; |
| 3331 | 3502 | |
| 3332 | 3503 | // Nothing? |
| 3333 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3334 | - return; |
|
| 3504 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3505 | + return; |
|
| 3506 | + } |
|
| 3335 | 3507 | |
| 3336 | 3508 | // Was it a problem with Windows? |
| 3337 | 3509 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3363,11 +3535,12 @@ discard block |
||
| 3363 | 3535 | 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\'); |
| 3364 | 3536 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3365 | 3537 | |
| 3366 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3367 | - echo ' |
|
| 3538 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3539 | + echo ' |
|
| 3368 | 3540 | content.write(\'<hr>\n\t\t\t\'); |
| 3369 | 3541 | 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\'); |
| 3370 | 3542 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3543 | + } |
|
| 3371 | 3544 | |
| 3372 | 3545 | echo ' |
| 3373 | 3546 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3375,17 +3548,19 @@ discard block |
||
| 3375 | 3548 | } |
| 3376 | 3549 | </script>'; |
| 3377 | 3550 | |
| 3378 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3379 | - echo ' |
|
| 3551 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3552 | + echo ' |
|
| 3380 | 3553 | <div class="error_message red"> |
| 3381 | 3554 | The following error was encountered when trying to connect:<br><br> |
| 3382 | 3555 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3383 | 3556 | </div> |
| 3384 | 3557 | <br>'; |
| 3558 | + } |
|
| 3385 | 3559 | |
| 3386 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3387 | - echo ' |
|
| 3560 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3561 | + echo ' |
|
| 3388 | 3562 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3563 | + } |
|
| 3389 | 3564 | |
| 3390 | 3565 | echo ' |
| 3391 | 3566 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3420,10 +3595,11 @@ discard block |
||
| 3420 | 3595 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
| 3421 | 3596 | </div>'; |
| 3422 | 3597 | |
| 3423 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3424 | - echo ' |
|
| 3598 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3599 | + echo ' |
|
| 3425 | 3600 | </form>'; |
| 3426 | -} |
|
| 3601 | + } |
|
| 3602 | + } |
|
| 3427 | 3603 | |
| 3428 | 3604 | function template_upgrade_above() |
| 3429 | 3605 | { |
@@ -3483,9 +3659,10 @@ discard block |
||
| 3483 | 3659 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3484 | 3660 | <ul>'; |
| 3485 | 3661 | |
| 3486 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3487 | - echo ' |
|
| 3662 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3663 | + echo ' |
|
| 3488 | 3664 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3665 | + } |
|
| 3489 | 3666 | |
| 3490 | 3667 | echo ' |
| 3491 | 3668 | </ul> |
@@ -3498,8 +3675,8 @@ discard block |
||
| 3498 | 3675 | </div> |
| 3499 | 3676 | </div>'; |
| 3500 | 3677 | |
| 3501 | - if (isset($upcontext['step_progress'])) |
|
| 3502 | - echo ' |
|
| 3678 | + if (isset($upcontext['step_progress'])) { |
|
| 3679 | + echo ' |
|
| 3503 | 3680 | <br> |
| 3504 | 3681 | <br> |
| 3505 | 3682 | <div id="progress_bar_step"> |
@@ -3508,6 +3685,7 @@ discard block |
||
| 3508 | 3685 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3509 | 3686 | </div> |
| 3510 | 3687 | </div>'; |
| 3688 | + } |
|
| 3511 | 3689 | |
| 3512 | 3690 | echo ' |
| 3513 | 3691 | <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> |
@@ -3538,32 +3716,36 @@ discard block |
||
| 3538 | 3716 | { |
| 3539 | 3717 | global $upcontext, $txt; |
| 3540 | 3718 | |
| 3541 | - if (!empty($upcontext['pause'])) |
|
| 3542 | - echo ' |
|
| 3719 | + if (!empty($upcontext['pause'])) { |
|
| 3720 | + echo ' |
|
| 3543 | 3721 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3544 | 3722 | |
| 3545 | 3723 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3546 | 3724 | <h3> |
| 3547 | 3725 | ', $txt['upgrade_paused_overload'], ' |
| 3548 | 3726 | </h3>'; |
| 3727 | + } |
|
| 3549 | 3728 | |
| 3550 | - if (!empty($upcontext['custom_warning'])) |
|
| 3551 | - echo ' |
|
| 3729 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3730 | + echo ' |
|
| 3552 | 3731 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3553 | 3732 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3554 | 3733 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3555 | 3734 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3556 | 3735 | </div>'; |
| 3736 | + } |
|
| 3557 | 3737 | |
| 3558 | 3738 | echo ' |
| 3559 | 3739 | <div class="righttext" style="margin: 1ex;">'; |
| 3560 | 3740 | |
| 3561 | - if (!empty($upcontext['continue'])) |
|
| 3562 | - echo ' |
|
| 3741 | + if (!empty($upcontext['continue'])) { |
|
| 3742 | + echo ' |
|
| 3563 | 3743 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
| 3564 | - if (!empty($upcontext['skip'])) |
|
| 3565 | - echo ' |
|
| 3744 | + } |
|
| 3745 | + if (!empty($upcontext['skip'])) { |
|
| 3746 | + echo ' |
|
| 3566 | 3747 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
| 3748 | + } |
|
| 3567 | 3749 | |
| 3568 | 3750 | echo ' |
| 3569 | 3751 | </div> |
@@ -3613,11 +3795,12 @@ discard block |
||
| 3613 | 3795 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3614 | 3796 | <smf>'; |
| 3615 | 3797 | |
| 3616 | - if (!empty($upcontext['get_data'])) |
|
| 3617 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3798 | + if (!empty($upcontext['get_data'])) { |
|
| 3799 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3618 | 3800 | echo ' |
| 3619 | 3801 | <get key="', $k, '">', $v, '</get>'; |
| 3620 | -} |
|
| 3802 | + } |
|
| 3803 | + } |
|
| 3621 | 3804 | |
| 3622 | 3805 | function template_xml_below() |
| 3623 | 3806 | { |
@@ -3658,8 +3841,8 @@ discard block |
||
| 3658 | 3841 | template_chmod(); |
| 3659 | 3842 | |
| 3660 | 3843 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3661 | - if ($upcontext['is_large_forum']) |
|
| 3662 | - echo ' |
|
| 3844 | + if ($upcontext['is_large_forum']) { |
|
| 3845 | + echo ' |
|
| 3663 | 3846 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3664 | 3847 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3665 | 3848 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3667,10 +3850,11 @@ discard block |
||
| 3667 | 3850 | ', $txt['upgrade_warning_lots_data'], ' |
| 3668 | 3851 | </div> |
| 3669 | 3852 | </div>'; |
| 3853 | + } |
|
| 3670 | 3854 | |
| 3671 | 3855 | // A warning message? |
| 3672 | - if (!empty($upcontext['warning'])) |
|
| 3673 | - echo ' |
|
| 3856 | + if (!empty($upcontext['warning'])) { |
|
| 3857 | + echo ' |
|
| 3674 | 3858 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3675 | 3859 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3676 | 3860 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3678,6 +3862,7 @@ discard block |
||
| 3678 | 3862 | ', $upcontext['warning'], ' |
| 3679 | 3863 | </div> |
| 3680 | 3864 | </div>'; |
| 3865 | + } |
|
| 3681 | 3866 | |
| 3682 | 3867 | // Paths are incorrect? |
| 3683 | 3868 | echo ' |
@@ -3693,20 +3878,22 @@ discard block |
||
| 3693 | 3878 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3694 | 3879 | { |
| 3695 | 3880 | $ago = time() - $upcontext['started']; |
| 3696 | - if ($ago < 60) |
|
| 3697 | - $ago = $ago . ' seconds'; |
|
| 3698 | - elseif ($ago < 3600) |
|
| 3699 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3700 | - else |
|
| 3701 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3881 | + if ($ago < 60) { |
|
| 3882 | + $ago = $ago . ' seconds'; |
|
| 3883 | + } elseif ($ago < 3600) { |
|
| 3884 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3885 | + } else { |
|
| 3886 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3887 | + } |
|
| 3702 | 3888 | |
| 3703 | 3889 | $active = time() - $upcontext['updated']; |
| 3704 | - if ($active < 60) |
|
| 3705 | - $updated = $active . ' seconds'; |
|
| 3706 | - elseif ($active < 3600) |
|
| 3707 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3708 | - else |
|
| 3709 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3890 | + if ($active < 60) { |
|
| 3891 | + $updated = $active . ' seconds'; |
|
| 3892 | + } elseif ($active < 3600) { |
|
| 3893 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3894 | + } else { |
|
| 3895 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3896 | + } |
|
| 3710 | 3897 | |
| 3711 | 3898 | echo ' |
| 3712 | 3899 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3715,16 +3902,18 @@ discard block |
||
| 3715 | 3902 | <div style="padding-left: 6ex;"> |
| 3716 | 3903 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3717 | 3904 | |
| 3718 | - if ($active < 600) |
|
| 3719 | - echo ' |
|
| 3905 | + if ($active < 600) { |
|
| 3906 | + echo ' |
|
| 3720 | 3907 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3908 | + } |
|
| 3721 | 3909 | |
| 3722 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3723 | - echo ' |
|
| 3910 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3911 | + echo ' |
|
| 3724 | 3912 | <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.'; |
| 3725 | - else |
|
| 3726 | - echo ' |
|
| 3913 | + } else { |
|
| 3914 | + echo ' |
|
| 3727 | 3915 | <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!'); |
| 3916 | + } |
|
| 3728 | 3917 | |
| 3729 | 3918 | echo ' |
| 3730 | 3919 | </div> |
@@ -3740,9 +3929,10 @@ discard block |
||
| 3740 | 3929 | <td> |
| 3741 | 3930 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
| 3742 | 3931 | |
| 3743 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3744 | - echo ' |
|
| 3932 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3933 | + echo ' |
|
| 3745 | 3934 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3935 | + } |
|
| 3746 | 3936 | |
| 3747 | 3937 | echo ' |
| 3748 | 3938 | </td> |
@@ -3753,9 +3943,10 @@ discard block |
||
| 3753 | 3943 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
| 3754 | 3944 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3755 | 3945 | |
| 3756 | - if (!empty($upcontext['password_failed'])) |
|
| 3757 | - echo ' |
|
| 3946 | + if (!empty($upcontext['password_failed'])) { |
|
| 3947 | + echo ' |
|
| 3758 | 3948 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3949 | + } |
|
| 3759 | 3950 | |
| 3760 | 3951 | echo ' |
| 3761 | 3952 | </td> |
@@ -3826,8 +4017,8 @@ discard block |
||
| 3826 | 4017 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3827 | 4018 | |
| 3828 | 4019 | // Warning message? |
| 3829 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3830 | - echo ' |
|
| 4020 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 4021 | + echo ' |
|
| 3831 | 4022 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3832 | 4023 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3833 | 4024 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3835,6 +4026,7 @@ discard block |
||
| 3835 | 4026 | ', $upcontext['upgrade_options_warning'], ' |
| 3836 | 4027 | </div> |
| 3837 | 4028 | </div>'; |
| 4029 | + } |
|
| 3838 | 4030 | |
| 3839 | 4031 | echo ' |
| 3840 | 4032 | <table> |
@@ -3877,8 +4069,8 @@ discard block |
||
| 3877 | 4069 | </td> |
| 3878 | 4070 | </tr>'; |
| 3879 | 4071 | |
| 3880 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3881 | - echo ' |
|
| 4072 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 4073 | + echo ' |
|
| 3882 | 4074 | <tr valign="top"> |
| 3883 | 4075 | <td width="2%"> |
| 3884 | 4076 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3887,6 +4079,7 @@ discard block |
||
| 3887 | 4079 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3888 | 4080 | </td> |
| 3889 | 4081 | </tr>'; |
| 4082 | + } |
|
| 3890 | 4083 | |
| 3891 | 4084 | echo ' |
| 3892 | 4085 | <tr valign="top"> |
@@ -3922,10 +4115,11 @@ discard block |
||
| 3922 | 4115 | <span id="debuginfo"></span>'; |
| 3923 | 4116 | |
| 3924 | 4117 | // Dont any tables so far? |
| 3925 | - if (!empty($upcontext['previous_tables'])) |
|
| 3926 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4118 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4119 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3927 | 4120 | echo ' |
| 3928 | 4121 | <br>Completed Table: "', $table, '".'; |
| 4122 | + } |
|
| 3929 | 4123 | |
| 3930 | 4124 | echo ' |
| 3931 | 4125 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3962,12 +4156,13 @@ discard block |
||
| 3962 | 4156 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3963 | 4157 | |
| 3964 | 4158 | // If debug flood the screen. |
| 3965 | - if ($is_debug) |
|
| 3966 | - echo ' |
|
| 4159 | + if ($is_debug) { |
|
| 4160 | + echo ' |
|
| 3967 | 4161 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3968 | 4162 | |
| 3969 | 4163 | if (document.getElementById(\'debuginfo\').scrollHeight) |
| 3970 | 4164 | document.getElementById(\'debuginfo\').scrollTop = document.getElementById(\'debuginfo\').scrollHeight;'; |
| 4165 | + } |
|
| 3971 | 4166 | |
| 3972 | 4167 | echo ' |
| 3973 | 4168 | // Get the next update... |
@@ -3999,8 +4194,9 @@ discard block |
||
| 3999 | 4194 | { |
| 4000 | 4195 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 4001 | 4196 | |
| 4002 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 4003 | - $is_debug = true; |
|
| 4197 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4198 | + $is_debug = true; |
|
| 4199 | + } |
|
| 4004 | 4200 | |
| 4005 | 4201 | echo ' |
| 4006 | 4202 | <h3>Executing database changes</h3> |
@@ -4015,8 +4211,9 @@ discard block |
||
| 4015 | 4211 | { |
| 4016 | 4212 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 4017 | 4213 | { |
| 4018 | - if ($num != 0) |
|
| 4019 | - echo ' Successful!'; |
|
| 4214 | + if ($num != 0) { |
|
| 4215 | + echo ' Successful!'; |
|
| 4216 | + } |
|
| 4020 | 4217 | echo '<br>' . $item; |
| 4021 | 4218 | } |
| 4022 | 4219 | if (!empty($upcontext['changes_complete'])) |
@@ -4029,28 +4226,32 @@ discard block |
||
| 4029 | 4226 | $seconds = intval($active % 60); |
| 4030 | 4227 | |
| 4031 | 4228 | $totalTime = ''; |
| 4032 | - if ($hours > 0) |
|
| 4033 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4034 | - if ($minutes > 0) |
|
| 4035 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4036 | - if ($seconds > 0) |
|
| 4037 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4229 | + if ($hours > 0) { |
|
| 4230 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4231 | + } |
|
| 4232 | + if ($minutes > 0) { |
|
| 4233 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4234 | + } |
|
| 4235 | + if ($seconds > 0) { |
|
| 4236 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4237 | + } |
|
| 4038 | 4238 | } |
| 4039 | 4239 | |
| 4040 | - if ($is_debug && !empty($totalTime)) |
|
| 4041 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4042 | - else |
|
| 4043 | - echo ' Successful!<br><br>'; |
|
| 4240 | + if ($is_debug && !empty($totalTime)) { |
|
| 4241 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4242 | + } else { |
|
| 4243 | + echo ' Successful!<br><br>'; |
|
| 4244 | + } |
|
| 4044 | 4245 | |
| 4045 | 4246 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 4046 | 4247 | } |
| 4047 | - } |
|
| 4048 | - else |
|
| 4248 | + } else |
|
| 4049 | 4249 | { |
| 4050 | 4250 | // Tell them how many files we have in total. |
| 4051 | - if ($upcontext['file_count'] > 1) |
|
| 4052 | - echo ' |
|
| 4251 | + if ($upcontext['file_count'] > 1) { |
|
| 4252 | + echo ' |
|
| 4053 | 4253 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4254 | + } |
|
| 4054 | 4255 | |
| 4055 | 4256 | echo ' |
| 4056 | 4257 | <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> |
@@ -4066,19 +4267,23 @@ discard block |
||
| 4066 | 4267 | $seconds = intval($active % 60); |
| 4067 | 4268 | |
| 4068 | 4269 | $totalTime = ''; |
| 4069 | - if ($hours > 0) |
|
| 4070 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4071 | - if ($minutes > 0) |
|
| 4072 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4073 | - if ($seconds > 0) |
|
| 4074 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4270 | + if ($hours > 0) { |
|
| 4271 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4272 | + } |
|
| 4273 | + if ($minutes > 0) { |
|
| 4274 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4275 | + } |
|
| 4276 | + if ($seconds > 0) { |
|
| 4277 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4278 | + } |
|
| 4075 | 4279 | } |
| 4076 | 4280 | |
| 4077 | 4281 | echo ' |
| 4078 | 4282 | <br><span id="upgradeCompleted">'; |
| 4079 | 4283 | |
| 4080 | - if (!empty($totalTime)) |
|
| 4081 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4284 | + if (!empty($totalTime)) { |
|
| 4285 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4286 | + } |
|
| 4082 | 4287 | |
| 4083 | 4288 | echo '</span> |
| 4084 | 4289 | <div id="debug_section" style="height: 200px; overflow: auto;"> |
@@ -4115,9 +4320,10 @@ discard block |
||
| 4115 | 4320 | var getData = ""; |
| 4116 | 4321 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4117 | 4322 | |
| 4118 | - if ($is_debug) |
|
| 4119 | - echo ' |
|
| 4323 | + if ($is_debug) { |
|
| 4324 | + echo ' |
|
| 4120 | 4325 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4326 | + } |
|
| 4121 | 4327 | |
| 4122 | 4328 | echo ' |
| 4123 | 4329 | function getNextItem() |
@@ -4157,9 +4363,10 @@ discard block |
||
| 4157 | 4363 | document.getElementById("error_block").style.display = ""; |
| 4158 | 4364 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4159 | 4365 | |
| 4160 | - if ($is_debug) |
|
| 4161 | - echo ' |
|
| 4366 | + if ($is_debug) { |
|
| 4367 | + echo ' |
|
| 4162 | 4368 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4369 | + } |
|
| 4163 | 4370 | |
| 4164 | 4371 | echo ' |
| 4165 | 4372 | } |
@@ -4180,9 +4387,10 @@ discard block |
||
| 4180 | 4387 | document.getElementById("error_block").style.display = ""; |
| 4181 | 4388 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4182 | 4389 | |
| 4183 | - if ($is_debug) |
|
| 4184 | - echo ' |
|
| 4390 | + if ($is_debug) { |
|
| 4391 | + echo ' |
|
| 4185 | 4392 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4393 | + } |
|
| 4186 | 4394 | |
| 4187 | 4395 | echo ' |
| 4188 | 4396 | } |
@@ -4241,8 +4449,8 @@ discard block |
||
| 4241 | 4449 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4242 | 4450 | {'; |
| 4243 | 4451 | |
| 4244 | - if ($is_debug) |
|
| 4245 | - echo ' |
|
| 4452 | + if ($is_debug) { |
|
| 4453 | + echo ' |
|
| 4246 | 4454 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4247 | 4455 | |
| 4248 | 4456 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4260,6 +4468,7 @@ discard block |
||
| 4260 | 4468 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4261 | 4469 | |
| 4262 | 4470 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4471 | + } |
|
| 4263 | 4472 | |
| 4264 | 4473 | echo ' |
| 4265 | 4474 | |
@@ -4267,9 +4476,10 @@ discard block |
||
| 4267 | 4476 | document.getElementById(\'contbutt\').disabled = 0; |
| 4268 | 4477 | document.getElementById(\'database_done\').value = 1;'; |
| 4269 | 4478 | |
| 4270 | - if ($upcontext['file_count'] > 1) |
|
| 4271 | - echo ' |
|
| 4479 | + if ($upcontext['file_count'] > 1) { |
|
| 4480 | + echo ' |
|
| 4272 | 4481 | document.getElementById(\'info1\').style.display = "none";'; |
| 4482 | + } |
|
| 4273 | 4483 | |
| 4274 | 4484 | echo ' |
| 4275 | 4485 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4282,9 +4492,10 @@ discard block |
||
| 4282 | 4492 | lastItem = 0; |
| 4283 | 4493 | prevFile = curFile;'; |
| 4284 | 4494 | |
| 4285 | - if ($is_debug) |
|
| 4286 | - echo ' |
|
| 4495 | + if ($is_debug) { |
|
| 4496 | + echo ' |
|
| 4287 | 4497 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4498 | + } |
|
| 4288 | 4499 | |
| 4289 | 4500 | echo ' |
| 4290 | 4501 | getNextItem(); |
@@ -4292,8 +4503,8 @@ discard block |
||
| 4292 | 4503 | }'; |
| 4293 | 4504 | |
| 4294 | 4505 | // If debug scroll the screen. |
| 4295 | - if ($is_debug) |
|
| 4296 | - echo ' |
|
| 4506 | + if ($is_debug) { |
|
| 4507 | + echo ' |
|
| 4297 | 4508 | if (iLastSubStepProgress == -1) |
| 4298 | 4509 | { |
| 4299 | 4510 | // Give it consistent dots. |
@@ -4312,6 +4523,7 @@ discard block |
||
| 4312 | 4523 | |
| 4313 | 4524 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4314 | 4525 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4526 | + } |
|
| 4315 | 4527 | |
| 4316 | 4528 | echo ' |
| 4317 | 4529 | // Update the page. |
@@ -4372,9 +4584,10 @@ discard block |
||
| 4372 | 4584 | }'; |
| 4373 | 4585 | |
| 4374 | 4586 | // Start things off assuming we've not errored. |
| 4375 | - if (empty($upcontext['error_message'])) |
|
| 4376 | - echo ' |
|
| 4587 | + if (empty($upcontext['error_message'])) { |
|
| 4588 | + echo ' |
|
| 4377 | 4589 | getNextItem();'; |
| 4590 | + } |
|
| 4378 | 4591 | |
| 4379 | 4592 | echo ' |
| 4380 | 4593 | </script>'; |
@@ -4391,18 +4604,21 @@ discard block |
||
| 4391 | 4604 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4392 | 4605 | <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>'; |
| 4393 | 4606 | |
| 4394 | - if (!empty($upcontext['error_message'])) |
|
| 4395 | - echo ' |
|
| 4607 | + if (!empty($upcontext['error_message'])) { |
|
| 4608 | + echo ' |
|
| 4396 | 4609 | <error>', $upcontext['error_message'], '</error>'; |
| 4610 | + } |
|
| 4397 | 4611 | |
| 4398 | - if (!empty($upcontext['error_string'])) |
|
| 4399 | - echo ' |
|
| 4612 | + if (!empty($upcontext['error_string'])) { |
|
| 4613 | + echo ' |
|
| 4400 | 4614 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4615 | + } |
|
| 4401 | 4616 | |
| 4402 | - if ($is_debug) |
|
| 4403 | - echo ' |
|
| 4617 | + if ($is_debug) { |
|
| 4618 | + echo ' |
|
| 4404 | 4619 | <curtime>', time(), '</curtime>'; |
| 4405 | -} |
|
| 4620 | + } |
|
| 4621 | + } |
|
| 4406 | 4622 | |
| 4407 | 4623 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4408 | 4624 | function template_convert_utf8() |
@@ -4419,18 +4635,20 @@ discard block |
||
| 4419 | 4635 | <span id="debuginfo"></span>'; |
| 4420 | 4636 | |
| 4421 | 4637 | // Done any tables so far? |
| 4422 | - if (!empty($upcontext['previous_tables'])) |
|
| 4423 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4638 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4639 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4424 | 4640 | echo ' |
| 4425 | 4641 | <br>Completed Table: "', $table, '".'; |
| 4642 | + } |
|
| 4426 | 4643 | |
| 4427 | 4644 | echo ' |
| 4428 | 4645 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4429 | 4646 | |
| 4430 | 4647 | // If we dropped their index, let's let them know |
| 4431 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
| 4432 | - echo ' |
|
| 4648 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
| 4649 | + echo ' |
|
| 4433 | 4650 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
| 4651 | + } |
|
| 4434 | 4652 | |
| 4435 | 4653 | echo ' |
| 4436 | 4654 | <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>'; |
@@ -4466,9 +4684,10 @@ discard block |
||
| 4466 | 4684 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4467 | 4685 | |
| 4468 | 4686 | // If debug flood the screen. |
| 4469 | - if ($is_debug) |
|
| 4470 | - echo ' |
|
| 4687 | + if ($is_debug) { |
|
| 4688 | + echo ' |
|
| 4471 | 4689 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
| 4690 | + } |
|
| 4472 | 4691 | |
| 4473 | 4692 | echo ' |
| 4474 | 4693 | // Get the next update... |
@@ -4510,19 +4729,21 @@ discard block |
||
| 4510 | 4729 | <span id="debuginfo"></span>'; |
| 4511 | 4730 | |
| 4512 | 4731 | // Dont any tables so far? |
| 4513 | - if (!empty($upcontext['previous_tables'])) |
|
| 4514 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4732 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4733 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4515 | 4734 | echo ' |
| 4516 | 4735 | <br>Completed Table: "', $table, '".'; |
| 4736 | + } |
|
| 4517 | 4737 | |
| 4518 | 4738 | echo ' |
| 4519 | 4739 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4520 | 4740 | <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>'; |
| 4521 | 4741 | |
| 4522 | 4742 | // Try to make sure substep was reset. |
| 4523 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4524 | - echo ' |
|
| 4743 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4744 | + echo ' |
|
| 4525 | 4745 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4746 | + } |
|
| 4526 | 4747 | |
| 4527 | 4748 | // Continue please! |
| 4528 | 4749 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4555,9 +4776,10 @@ discard block |
||
| 4555 | 4776 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4556 | 4777 | |
| 4557 | 4778 | // If debug flood the screen. |
| 4558 | - if ($is_debug) |
|
| 4559 | - echo ' |
|
| 4779 | + if ($is_debug) { |
|
| 4780 | + echo ' |
|
| 4560 | 4781 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
| 4782 | + } |
|
| 4561 | 4783 | |
| 4562 | 4784 | echo ' |
| 4563 | 4785 | // Get the next update... |
@@ -4592,8 +4814,8 @@ discard block |
||
| 4592 | 4814 | <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> |
| 4593 | 4815 | <form action="', $boardurl, '/index.php">'; |
| 4594 | 4816 | |
| 4595 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4596 | - echo ' |
|
| 4817 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4818 | + echo ' |
|
| 4597 | 4819 | <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> |
| 4598 | 4820 | <script> |
| 4599 | 4821 | function doTheDelete(theCheck) |
@@ -4605,6 +4827,7 @@ discard block |
||
| 4605 | 4827 | } |
| 4606 | 4828 | </script> |
| 4607 | 4829 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4830 | + } |
|
| 4608 | 4831 | |
| 4609 | 4832 | $active = time() - $upcontext['started']; |
| 4610 | 4833 | $hours = floor($active / 3600); |
@@ -4614,16 +4837,20 @@ discard block |
||
| 4614 | 4837 | if ($is_debug) |
| 4615 | 4838 | { |
| 4616 | 4839 | $totalTime = ''; |
| 4617 | - if ($hours > 0) |
|
| 4618 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4619 | - if ($minutes > 0) |
|
| 4620 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4621 | - if ($seconds > 0) |
|
| 4622 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4840 | + if ($hours > 0) { |
|
| 4841 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4842 | + } |
|
| 4843 | + if ($minutes > 0) { |
|
| 4844 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4845 | + } |
|
| 4846 | + if ($seconds > 0) { |
|
| 4847 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4848 | + } |
|
| 4623 | 4849 | } |
| 4624 | 4850 | |
| 4625 | - if ($is_debug && !empty($totalTime)) |
|
| 4626 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4851 | + if ($is_debug && !empty($totalTime)) { |
|
| 4852 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4853 | + } |
|
| 4627 | 4854 | |
| 4628 | 4855 | echo '<br> |
| 4629 | 4856 | 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> |
@@ -4690,16 +4917,19 @@ discard block |
||
| 4690 | 4917 | 'empty' => '', |
| 4691 | 4918 | 'limit' => $limit, |
| 4692 | 4919 | )); |
| 4693 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4694 | - $arIp[] = $row[$oldCol]; |
|
| 4920 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4921 | + $arIp[] = $row[$oldCol]; |
|
| 4922 | + } |
|
| 4695 | 4923 | $smcFunc['db_free_result']($request); |
| 4696 | 4924 | |
| 4697 | 4925 | // Special case, null ip could keep us in a loop. |
| 4698 | - if (is_null($arIp[0])) |
|
| 4699 | - unset($arIp[0]); |
|
| 4926 | + if (is_null($arIp[0])) { |
|
| 4927 | + unset($arIp[0]); |
|
| 4928 | + } |
|
| 4700 | 4929 | |
| 4701 | - if (empty($arIp)) |
|
| 4702 | - $is_done = true; |
|
| 4930 | + if (empty($arIp)) { |
|
| 4931 | + $is_done = true; |
|
| 4932 | + } |
|
| 4703 | 4933 | |
| 4704 | 4934 | $updates = array(); |
| 4705 | 4935 | $cases = array(); |
@@ -4708,16 +4938,18 @@ discard block |
||
| 4708 | 4938 | { |
| 4709 | 4939 | $arIp[$i] = trim($arIp[$i]); |
| 4710 | 4940 | |
| 4711 | - if (empty($arIp[$i])) |
|
| 4712 | - continue; |
|
| 4941 | + if (empty($arIp[$i])) { |
|
| 4942 | + continue; |
|
| 4943 | + } |
|
| 4713 | 4944 | |
| 4714 | 4945 | $updates['ip' . $i] = $arIp[$i]; |
| 4715 | 4946 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4716 | 4947 | |
| 4717 | 4948 | if ($setSize > 0 && $i % $setSize === 0) |
| 4718 | 4949 | { |
| 4719 | - if (count($updates) == 1) |
|
| 4720 | - continue; |
|
| 4950 | + if (count($updates) == 1) { |
|
| 4951 | + continue; |
|
| 4952 | + } |
|
| 4721 | 4953 | |
| 4722 | 4954 | $updates['whereSet'] = array_values($updates); |
| 4723 | 4955 | $smcFunc['db_query']('', ' |
@@ -4751,8 +4983,7 @@ discard block |
||
| 4751 | 4983 | 'ip' => $ip |
| 4752 | 4984 | )); |
| 4753 | 4985 | } |
| 4754 | - } |
|
| 4755 | - else |
|
| 4986 | + } else |
|
| 4756 | 4987 | { |
| 4757 | 4988 | $updates['whereSet'] = array_values($updates); |
| 4758 | 4989 | $smcFunc['db_query']('', ' |
@@ -4766,9 +4997,9 @@ discard block |
||
| 4766 | 4997 | $updates |
| 4767 | 4998 | ); |
| 4768 | 4999 | } |
| 5000 | + } else { |
|
| 5001 | + $is_done = true; |
|
| 4769 | 5002 | } |
| 4770 | - else |
|
| 4771 | - $is_done = true; |
|
| 4772 | 5003 | |
| 4773 | 5004 | $_GET['a'] += $limit; |
| 4774 | 5005 | $step_progress['current'] = $_GET['a']; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | /** |
| 142 | 142 | * Make files writable. First try to use regular chmod, but if that fails, try to use FTP. |
| 143 | 143 | * |
| 144 | - * @param $files |
|
| 144 | + * @param string[] $files |
|
| 145 | 145 | * @return bool |
| 146 | 146 | */ |
| 147 | 147 | function makeFilesWritable(&$files) |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | /** |
| 382 | 382 | * Prints an error to stderr. |
| 383 | 383 | * |
| 384 | - * @param $message |
|
| 384 | + * @param string $message |
|
| 385 | 385 | * @param bool $fatal |
| 386 | 386 | */ |
| 387 | 387 | function print_error($message, $fatal = false) |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | /** |
| 401 | 401 | * Throws a graphical error message. |
| 402 | 402 | * |
| 403 | - * @param $message |
|
| 403 | + * @param string $message |
|
| 404 | 404 | * @return bool |
| 405 | 405 | */ |
| 406 | 406 | function throw_error($message) |
@@ -14,66 +14,66 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | if (!defined('SMF_VERSION')) |
| 17 | - die('No direct access!'); |
|
| 17 | + die('No direct access!'); |
|
| 18 | 18 | |
| 19 | 19 | if (!function_exists('un_htmlspecialchars')) |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Undo the voodoo htmlspecialchars does. |
|
| 23 | - * |
|
| 24 | - * @param $string |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - function un_htmlspecialchars($string) |
|
| 28 | - { |
|
| 29 | - return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES)) + array(''' => '\'', ' ' => ' ')); |
|
| 30 | - } |
|
| 21 | + /** |
|
| 22 | + * Undo the voodoo htmlspecialchars does. |
|
| 23 | + * |
|
| 24 | + * @param $string |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + function un_htmlspecialchars($string) |
|
| 28 | + { |
|
| 29 | + return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES)) + array(''' => '\'', ' ' => ' ')); |
|
| 30 | + } |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | if (!function_exists('text2words')) |
| 34 | 34 | { |
| 35 | - /** |
|
| 36 | - * Split a sentence into words. |
|
| 37 | - * |
|
| 38 | - * @param $text |
|
| 39 | - * @return array |
|
| 40 | - */ |
|
| 41 | - function text2words($text) |
|
| 42 | - { |
|
| 43 | - // Step 1: Remove entities/things we don't consider words: |
|
| 44 | - $words = preg_replace('~(?:[\x0B\0\xA0\t\r\s\n(){}\\[\\]<>!@$%^*.,:+=`\~\?/\\\\]+|&(?:amp|lt|gt|quot);)+~', ' ', $text); |
|
| 45 | - |
|
| 46 | - // Step 2: Entities we left to letters, where applicable, lowercase. |
|
| 47 | - $words = preg_replace('~([^&\d]|^)[#;]~', '$1 ', un_htmlspecialchars(strtolower($words))); |
|
| 48 | - |
|
| 49 | - // Step 3: Ready to split apart and index! |
|
| 50 | - $words = explode(' ', $words); |
|
| 51 | - $returned_words = array(); |
|
| 52 | - foreach ($words as $word) |
|
| 53 | - { |
|
| 54 | - $word = trim($word, '-_\''); |
|
| 55 | - |
|
| 56 | - if ($word != '') |
|
| 57 | - $returned_words[] = substr($word, 0, 20); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - return array_unique($returned_words); |
|
| 61 | - } |
|
| 35 | + /** |
|
| 36 | + * Split a sentence into words. |
|
| 37 | + * |
|
| 38 | + * @param $text |
|
| 39 | + * @return array |
|
| 40 | + */ |
|
| 41 | + function text2words($text) |
|
| 42 | + { |
|
| 43 | + // Step 1: Remove entities/things we don't consider words: |
|
| 44 | + $words = preg_replace('~(?:[\x0B\0\xA0\t\r\s\n(){}\\[\\]<>!@$%^*.,:+=`\~\?/\\\\]+|&(?:amp|lt|gt|quot);)+~', ' ', $text); |
|
| 45 | + |
|
| 46 | + // Step 2: Entities we left to letters, where applicable, lowercase. |
|
| 47 | + $words = preg_replace('~([^&\d]|^)[#;]~', '$1 ', un_htmlspecialchars(strtolower($words))); |
|
| 48 | + |
|
| 49 | + // Step 3: Ready to split apart and index! |
|
| 50 | + $words = explode(' ', $words); |
|
| 51 | + $returned_words = array(); |
|
| 52 | + foreach ($words as $word) |
|
| 53 | + { |
|
| 54 | + $word = trim($word, '-_\''); |
|
| 55 | + |
|
| 56 | + if ($word != '') |
|
| 57 | + $returned_words[] = substr($word, 0, 20); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + return array_unique($returned_words); |
|
| 61 | + } |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | if (!function_exists('md5_hmac')) |
| 65 | 65 | { |
| 66 | - /** |
|
| 67 | - * Generate an MD5 hash using the HMAC method. |
|
| 68 | - * |
|
| 69 | - * @param string $data |
|
| 70 | - * @param string $key |
|
| 71 | - * @return string |
|
| 72 | - */ |
|
| 73 | - function md5_hmac($data, $key) |
|
| 74 | - { |
|
| 75 | - return hash_hmac('md5', $data, $key); |
|
| 76 | - } |
|
| 66 | + /** |
|
| 67 | + * Generate an MD5 hash using the HMAC method. |
|
| 68 | + * |
|
| 69 | + * @param string $data |
|
| 70 | + * @param string $key |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 73 | + function md5_hmac($data, $key) |
|
| 74 | + { |
|
| 75 | + return hash_hmac('md5', $data, $key); |
|
| 76 | + } |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -82,17 +82,17 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | function upgrade_clean_cache() |
| 84 | 84 | { |
| 85 | - global $cacheAPI, $sourcedir; |
|
| 85 | + global $cacheAPI, $sourcedir; |
|
| 86 | 86 | |
| 87 | - // Initialize the cache API if it does not have an instance yet. |
|
| 88 | - if (empty($cacheAPI)) |
|
| 89 | - { |
|
| 90 | - require_once($sourcedir . '/Load.php'); |
|
| 91 | - loadCacheAccelerator(); |
|
| 92 | - } |
|
| 87 | + // Initialize the cache API if it does not have an instance yet. |
|
| 88 | + if (empty($cacheAPI)) |
|
| 89 | + { |
|
| 90 | + require_once($sourcedir . '/Load.php'); |
|
| 91 | + loadCacheAccelerator(); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - // Just fall back to Load.php's clean_cache function. |
|
| 95 | - clean_cache(); |
|
| 94 | + // Just fall back to Load.php's clean_cache function. |
|
| 95 | + clean_cache(); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -102,40 +102,40 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | function getMemberGroups() |
| 104 | 104 | { |
| 105 | - global $smcFunc; |
|
| 106 | - static $member_groups = array(); |
|
| 105 | + global $smcFunc; |
|
| 106 | + static $member_groups = array(); |
|
| 107 | 107 | |
| 108 | - if (!empty($member_groups)) |
|
| 109 | - return $member_groups; |
|
| 108 | + if (!empty($member_groups)) |
|
| 109 | + return $member_groups; |
|
| 110 | 110 | |
| 111 | - $request = $smcFunc['db_query']('', ' |
|
| 111 | + $request = $smcFunc['db_query']('', ' |
|
| 112 | 112 | SELECT group_name, id_group |
| 113 | 113 | FROM {db_prefix}membergroups |
| 114 | 114 | WHERE id_group = {int:admin_group} OR id_group > {int:old_group}', |
| 115 | - array( |
|
| 116 | - 'admin_group' => 1, |
|
| 117 | - 'old_group' => 7, |
|
| 118 | - 'db_error_skip' => true, |
|
| 119 | - ) |
|
| 120 | - ); |
|
| 121 | - if ($request === false) |
|
| 122 | - { |
|
| 123 | - $request = $smcFunc['db_query']('', ' |
|
| 115 | + array( |
|
| 116 | + 'admin_group' => 1, |
|
| 117 | + 'old_group' => 7, |
|
| 118 | + 'db_error_skip' => true, |
|
| 119 | + ) |
|
| 120 | + ); |
|
| 121 | + if ($request === false) |
|
| 122 | + { |
|
| 123 | + $request = $smcFunc['db_query']('', ' |
|
| 124 | 124 | SELECT membergroup, id_group |
| 125 | 125 | FROM {db_prefix}membergroups |
| 126 | 126 | WHERE id_group = {int:admin_group} OR id_group > {int:old_group}', |
| 127 | - array( |
|
| 128 | - 'admin_group' => 1, |
|
| 129 | - 'old_group' => 7, |
|
| 130 | - 'db_error_skip' => true, |
|
| 131 | - ) |
|
| 132 | - ); |
|
| 133 | - } |
|
| 134 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 135 | - $member_groups[trim($row[0])] = $row[1]; |
|
| 136 | - $smcFunc['db_free_result']($request); |
|
| 137 | - |
|
| 138 | - return $member_groups; |
|
| 127 | + array( |
|
| 128 | + 'admin_group' => 1, |
|
| 129 | + 'old_group' => 7, |
|
| 130 | + 'db_error_skip' => true, |
|
| 131 | + ) |
|
| 132 | + ); |
|
| 133 | + } |
|
| 134 | + while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 135 | + $member_groups[trim($row[0])] = $row[1]; |
|
| 136 | + $smcFunc['db_free_result']($request); |
|
| 137 | + |
|
| 138 | + return $member_groups; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -146,197 +146,197 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | function makeFilesWritable(&$files) |
| 148 | 148 | { |
| 149 | - global $upcontext, $boarddir; |
|
| 150 | - |
|
| 151 | - if (empty($files)) |
|
| 152 | - return true; |
|
| 153 | - |
|
| 154 | - $failure = false; |
|
| 155 | - // On linux, it's easy - just use is_writable! |
|
| 156 | - if (substr(__FILE__, 1, 2) != ':\\') |
|
| 157 | - { |
|
| 158 | - $upcontext['systemos'] = 'linux'; |
|
| 159 | - |
|
| 160 | - foreach ($files as $k => $file) |
|
| 161 | - { |
|
| 162 | - if (!is_writable($file)) |
|
| 163 | - { |
|
| 164 | - @chmod($file, 0755); |
|
| 165 | - |
|
| 166 | - // Well, 755 hopefully worked... if not, try 777. |
|
| 167 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
| 168 | - $failure = true; |
|
| 169 | - // Otherwise remove it as it's good! |
|
| 170 | - else |
|
| 171 | - unset($files[$k]); |
|
| 172 | - } |
|
| 173 | - else |
|
| 174 | - unset($files[$k]); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - // Windows is trickier. Let's try opening for r+... |
|
| 178 | - else |
|
| 179 | - { |
|
| 180 | - $upcontext['systemos'] = 'windows'; |
|
| 181 | - |
|
| 182 | - foreach ($files as $k => $file) |
|
| 183 | - { |
|
| 184 | - // Folders can't be opened for write... but the index.php in them can ;). |
|
| 185 | - if (is_dir($file)) |
|
| 186 | - $file .= '/index.php'; |
|
| 187 | - |
|
| 188 | - // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
|
| 189 | - @chmod($file, 0777); |
|
| 190 | - $fp = @fopen($file, 'r+'); |
|
| 191 | - |
|
| 192 | - // Hmm, okay, try just for write in that case... |
|
| 193 | - if (!$fp) |
|
| 194 | - $fp = @fopen($file, 'w'); |
|
| 195 | - |
|
| 196 | - if (!$fp) |
|
| 197 | - $failure = true; |
|
| 198 | - else |
|
| 199 | - unset($files[$k]); |
|
| 200 | - @fclose($fp); |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - if (empty($files)) |
|
| 205 | - return true; |
|
| 206 | - |
|
| 207 | - if (!isset($_SERVER)) |
|
| 208 | - return !$failure; |
|
| 209 | - |
|
| 210 | - // What still needs to be done? |
|
| 211 | - $upcontext['chmod']['files'] = $files; |
|
| 212 | - |
|
| 213 | - // If it's windows it's a mess... |
|
| 214 | - if ($failure && substr(__FILE__, 1, 2) == ':\\') |
|
| 215 | - { |
|
| 216 | - $upcontext['chmod']['ftp_error'] = 'total_mess'; |
|
| 217 | - |
|
| 218 | - return false; |
|
| 219 | - } |
|
| 220 | - // We're going to have to use... FTP! |
|
| 221 | - elseif ($failure) |
|
| 222 | - { |
|
| 223 | - // Load any session data we might have... |
|
| 224 | - if (!isset($_POST['ftp_username']) && isset($_SESSION['installer_temp_ftp'])) |
|
| 225 | - { |
|
| 226 | - $upcontext['chmod']['server'] = $_SESSION['installer_temp_ftp']['server']; |
|
| 227 | - $upcontext['chmod']['port'] = $_SESSION['installer_temp_ftp']['port']; |
|
| 228 | - $upcontext['chmod']['username'] = $_SESSION['installer_temp_ftp']['username']; |
|
| 229 | - $upcontext['chmod']['password'] = $_SESSION['installer_temp_ftp']['password']; |
|
| 230 | - $upcontext['chmod']['path'] = $_SESSION['installer_temp_ftp']['path']; |
|
| 231 | - } |
|
| 232 | - // Or have we submitted? |
|
| 233 | - elseif (isset($_POST['ftp_username'])) |
|
| 234 | - { |
|
| 235 | - $upcontext['chmod']['server'] = $_POST['ftp_server']; |
|
| 236 | - $upcontext['chmod']['port'] = $_POST['ftp_port']; |
|
| 237 | - $upcontext['chmod']['username'] = $_POST['ftp_username']; |
|
| 238 | - $upcontext['chmod']['password'] = $_POST['ftp_password']; |
|
| 239 | - $upcontext['chmod']['path'] = $_POST['ftp_path']; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - if (isset($upcontext['chmod']['username'])) |
|
| 243 | - { |
|
| 244 | - $ftp = new ftp_connection($upcontext['chmod']['server'], $upcontext['chmod']['port'], $upcontext['chmod']['username'], $upcontext['chmod']['password']); |
|
| 245 | - |
|
| 246 | - if ($ftp->error === false) |
|
| 247 | - { |
|
| 248 | - // Try it without /home/abc just in case they messed up. |
|
| 249 | - if (!$ftp->chdir($upcontext['chmod']['path'])) |
|
| 250 | - { |
|
| 251 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message; |
|
| 252 | - $ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $upcontext['chmod']['path'])); |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - if (!isset($ftp) || $ftp->error !== false) |
|
| 258 | - { |
|
| 259 | - if (!isset($ftp)) |
|
| 260 | - $ftp = new ftp_connection(null); |
|
| 261 | - // Save the error so we can mess with listing... |
|
| 262 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
| 263 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 264 | - |
|
| 265 | - list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
|
| 266 | - |
|
| 267 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
| 268 | - $upcontext['chmod']['path'] = $detect_path; |
|
| 269 | - |
|
| 270 | - if (!isset($upcontext['chmod']['username'])) |
|
| 271 | - $upcontext['chmod']['username'] = $username; |
|
| 272 | - |
|
| 273 | - // Don't forget the login token. |
|
| 274 | - $upcontext += createToken('login'); |
|
| 275 | - |
|
| 276 | - return false; |
|
| 277 | - } |
|
| 278 | - else |
|
| 279 | - { |
|
| 280 | - // We want to do a relative path for FTP. |
|
| 281 | - if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
|
| 282 | - { |
|
| 283 | - $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
|
| 284 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
| 285 | - $ftp_root = substr($ftp_root, 0, -1); |
|
| 286 | - } |
|
| 287 | - else |
|
| 288 | - $ftp_root = $boarddir; |
|
| 289 | - |
|
| 290 | - // Save the info for next time! |
|
| 291 | - $_SESSION['installer_temp_ftp'] = array( |
|
| 292 | - 'server' => $upcontext['chmod']['server'], |
|
| 293 | - 'port' => $upcontext['chmod']['port'], |
|
| 294 | - 'username' => $upcontext['chmod']['username'], |
|
| 295 | - 'password' => $upcontext['chmod']['password'], |
|
| 296 | - 'path' => $upcontext['chmod']['path'], |
|
| 297 | - 'root' => $ftp_root, |
|
| 298 | - ); |
|
| 299 | - |
|
| 300 | - foreach ($files as $k => $file) |
|
| 301 | - { |
|
| 302 | - if (!is_writable($file)) |
|
| 303 | - $ftp->chmod($file, 0755); |
|
| 304 | - if (!is_writable($file)) |
|
| 305 | - $ftp->chmod($file, 0777); |
|
| 306 | - |
|
| 307 | - // Assuming that didn't work calculate the path without the boarddir. |
|
| 308 | - if (!is_writable($file)) |
|
| 309 | - { |
|
| 310 | - if (strpos($file, $boarddir) === 0) |
|
| 311 | - { |
|
| 312 | - $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
|
| 313 | - $ftp->chmod($ftp_file, 0755); |
|
| 314 | - if (!is_writable($file)) |
|
| 315 | - $ftp->chmod($ftp_file, 0777); |
|
| 316 | - // Sometimes an extra slash can help... |
|
| 317 | - $ftp_file = '/' . $ftp_file; |
|
| 318 | - if (!is_writable($file)) |
|
| 319 | - $ftp->chmod($ftp_file, 0755); |
|
| 320 | - if (!is_writable($file)) |
|
| 321 | - $ftp->chmod($ftp_file, 0777); |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - if (is_writable($file)) |
|
| 326 | - unset($files[$k]); |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - $ftp->close(); |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - // What remains? |
|
| 334 | - $upcontext['chmod']['files'] = $files; |
|
| 335 | - |
|
| 336 | - if (empty($files)) |
|
| 337 | - return true; |
|
| 338 | - |
|
| 339 | - return false; |
|
| 149 | + global $upcontext, $boarddir; |
|
| 150 | + |
|
| 151 | + if (empty($files)) |
|
| 152 | + return true; |
|
| 153 | + |
|
| 154 | + $failure = false; |
|
| 155 | + // On linux, it's easy - just use is_writable! |
|
| 156 | + if (substr(__FILE__, 1, 2) != ':\\') |
|
| 157 | + { |
|
| 158 | + $upcontext['systemos'] = 'linux'; |
|
| 159 | + |
|
| 160 | + foreach ($files as $k => $file) |
|
| 161 | + { |
|
| 162 | + if (!is_writable($file)) |
|
| 163 | + { |
|
| 164 | + @chmod($file, 0755); |
|
| 165 | + |
|
| 166 | + // Well, 755 hopefully worked... if not, try 777. |
|
| 167 | + if (!is_writable($file) && !@chmod($file, 0777)) |
|
| 168 | + $failure = true; |
|
| 169 | + // Otherwise remove it as it's good! |
|
| 170 | + else |
|
| 171 | + unset($files[$k]); |
|
| 172 | + } |
|
| 173 | + else |
|
| 174 | + unset($files[$k]); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + // Windows is trickier. Let's try opening for r+... |
|
| 178 | + else |
|
| 179 | + { |
|
| 180 | + $upcontext['systemos'] = 'windows'; |
|
| 181 | + |
|
| 182 | + foreach ($files as $k => $file) |
|
| 183 | + { |
|
| 184 | + // Folders can't be opened for write... but the index.php in them can ;). |
|
| 185 | + if (is_dir($file)) |
|
| 186 | + $file .= '/index.php'; |
|
| 187 | + |
|
| 188 | + // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
|
| 189 | + @chmod($file, 0777); |
|
| 190 | + $fp = @fopen($file, 'r+'); |
|
| 191 | + |
|
| 192 | + // Hmm, okay, try just for write in that case... |
|
| 193 | + if (!$fp) |
|
| 194 | + $fp = @fopen($file, 'w'); |
|
| 195 | + |
|
| 196 | + if (!$fp) |
|
| 197 | + $failure = true; |
|
| 198 | + else |
|
| 199 | + unset($files[$k]); |
|
| 200 | + @fclose($fp); |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + if (empty($files)) |
|
| 205 | + return true; |
|
| 206 | + |
|
| 207 | + if (!isset($_SERVER)) |
|
| 208 | + return !$failure; |
|
| 209 | + |
|
| 210 | + // What still needs to be done? |
|
| 211 | + $upcontext['chmod']['files'] = $files; |
|
| 212 | + |
|
| 213 | + // If it's windows it's a mess... |
|
| 214 | + if ($failure && substr(__FILE__, 1, 2) == ':\\') |
|
| 215 | + { |
|
| 216 | + $upcontext['chmod']['ftp_error'] = 'total_mess'; |
|
| 217 | + |
|
| 218 | + return false; |
|
| 219 | + } |
|
| 220 | + // We're going to have to use... FTP! |
|
| 221 | + elseif ($failure) |
|
| 222 | + { |
|
| 223 | + // Load any session data we might have... |
|
| 224 | + if (!isset($_POST['ftp_username']) && isset($_SESSION['installer_temp_ftp'])) |
|
| 225 | + { |
|
| 226 | + $upcontext['chmod']['server'] = $_SESSION['installer_temp_ftp']['server']; |
|
| 227 | + $upcontext['chmod']['port'] = $_SESSION['installer_temp_ftp']['port']; |
|
| 228 | + $upcontext['chmod']['username'] = $_SESSION['installer_temp_ftp']['username']; |
|
| 229 | + $upcontext['chmod']['password'] = $_SESSION['installer_temp_ftp']['password']; |
|
| 230 | + $upcontext['chmod']['path'] = $_SESSION['installer_temp_ftp']['path']; |
|
| 231 | + } |
|
| 232 | + // Or have we submitted? |
|
| 233 | + elseif (isset($_POST['ftp_username'])) |
|
| 234 | + { |
|
| 235 | + $upcontext['chmod']['server'] = $_POST['ftp_server']; |
|
| 236 | + $upcontext['chmod']['port'] = $_POST['ftp_port']; |
|
| 237 | + $upcontext['chmod']['username'] = $_POST['ftp_username']; |
|
| 238 | + $upcontext['chmod']['password'] = $_POST['ftp_password']; |
|
| 239 | + $upcontext['chmod']['path'] = $_POST['ftp_path']; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + if (isset($upcontext['chmod']['username'])) |
|
| 243 | + { |
|
| 244 | + $ftp = new ftp_connection($upcontext['chmod']['server'], $upcontext['chmod']['port'], $upcontext['chmod']['username'], $upcontext['chmod']['password']); |
|
| 245 | + |
|
| 246 | + if ($ftp->error === false) |
|
| 247 | + { |
|
| 248 | + // Try it without /home/abc just in case they messed up. |
|
| 249 | + if (!$ftp->chdir($upcontext['chmod']['path'])) |
|
| 250 | + { |
|
| 251 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message; |
|
| 252 | + $ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $upcontext['chmod']['path'])); |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + if (!isset($ftp) || $ftp->error !== false) |
|
| 258 | + { |
|
| 259 | + if (!isset($ftp)) |
|
| 260 | + $ftp = new ftp_connection(null); |
|
| 261 | + // Save the error so we can mess with listing... |
|
| 262 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
| 263 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 264 | + |
|
| 265 | + list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
|
| 266 | + |
|
| 267 | + if ($found_path || !isset($upcontext['chmod']['path'])) |
|
| 268 | + $upcontext['chmod']['path'] = $detect_path; |
|
| 269 | + |
|
| 270 | + if (!isset($upcontext['chmod']['username'])) |
|
| 271 | + $upcontext['chmod']['username'] = $username; |
|
| 272 | + |
|
| 273 | + // Don't forget the login token. |
|
| 274 | + $upcontext += createToken('login'); |
|
| 275 | + |
|
| 276 | + return false; |
|
| 277 | + } |
|
| 278 | + else |
|
| 279 | + { |
|
| 280 | + // We want to do a relative path for FTP. |
|
| 281 | + if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
|
| 282 | + { |
|
| 283 | + $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
|
| 284 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
| 285 | + $ftp_root = substr($ftp_root, 0, -1); |
|
| 286 | + } |
|
| 287 | + else |
|
| 288 | + $ftp_root = $boarddir; |
|
| 289 | + |
|
| 290 | + // Save the info for next time! |
|
| 291 | + $_SESSION['installer_temp_ftp'] = array( |
|
| 292 | + 'server' => $upcontext['chmod']['server'], |
|
| 293 | + 'port' => $upcontext['chmod']['port'], |
|
| 294 | + 'username' => $upcontext['chmod']['username'], |
|
| 295 | + 'password' => $upcontext['chmod']['password'], |
|
| 296 | + 'path' => $upcontext['chmod']['path'], |
|
| 297 | + 'root' => $ftp_root, |
|
| 298 | + ); |
|
| 299 | + |
|
| 300 | + foreach ($files as $k => $file) |
|
| 301 | + { |
|
| 302 | + if (!is_writable($file)) |
|
| 303 | + $ftp->chmod($file, 0755); |
|
| 304 | + if (!is_writable($file)) |
|
| 305 | + $ftp->chmod($file, 0777); |
|
| 306 | + |
|
| 307 | + // Assuming that didn't work calculate the path without the boarddir. |
|
| 308 | + if (!is_writable($file)) |
|
| 309 | + { |
|
| 310 | + if (strpos($file, $boarddir) === 0) |
|
| 311 | + { |
|
| 312 | + $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
|
| 313 | + $ftp->chmod($ftp_file, 0755); |
|
| 314 | + if (!is_writable($file)) |
|
| 315 | + $ftp->chmod($ftp_file, 0777); |
|
| 316 | + // Sometimes an extra slash can help... |
|
| 317 | + $ftp_file = '/' . $ftp_file; |
|
| 318 | + if (!is_writable($file)) |
|
| 319 | + $ftp->chmod($ftp_file, 0755); |
|
| 320 | + if (!is_writable($file)) |
|
| 321 | + $ftp->chmod($ftp_file, 0777); |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + if (is_writable($file)) |
|
| 326 | + unset($files[$k]); |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + $ftp->close(); |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + // What remains? |
|
| 334 | + $upcontext['chmod']['files'] = $files; |
|
| 335 | + |
|
| 336 | + if (empty($files)) |
|
| 337 | + return true; |
|
| 338 | + |
|
| 339 | + return false; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
@@ -347,24 +347,24 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | function quickFileWritable($file) |
| 349 | 349 | { |
| 350 | - if (is_writable($file)) |
|
| 351 | - return true; |
|
| 350 | + if (is_writable($file)) |
|
| 351 | + return true; |
|
| 352 | 352 | |
| 353 | - @chmod($file, 0755); |
|
| 353 | + @chmod($file, 0755); |
|
| 354 | 354 | |
| 355 | - // Try 755 and 775 first since 777 doesn't always work and could be a risk... |
|
| 356 | - $chmod_values = array(0755, 0775, 0777); |
|
| 355 | + // Try 755 and 775 first since 777 doesn't always work and could be a risk... |
|
| 356 | + $chmod_values = array(0755, 0775, 0777); |
|
| 357 | 357 | |
| 358 | - foreach ($chmod_values as $val) |
|
| 359 | - { |
|
| 360 | - // If it's writable, break out of the loop |
|
| 361 | - if (is_writable($file)) |
|
| 362 | - break; |
|
| 363 | - else |
|
| 364 | - @chmod($file, $val); |
|
| 365 | - } |
|
| 358 | + foreach ($chmod_values as $val) |
|
| 359 | + { |
|
| 360 | + // If it's writable, break out of the loop |
|
| 361 | + if (is_writable($file)) |
|
| 362 | + break; |
|
| 363 | + else |
|
| 364 | + @chmod($file, $val); |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | - return is_writable($file); |
|
| 367 | + return is_writable($file); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | function smf_strtolower($string) |
| 377 | 377 | { |
| 378 | - return mb_strtolower($string, 'UTF-8'); |
|
| 378 | + return mb_strtolower($string, 'UTF-8'); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -386,15 +386,15 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | function print_error($message, $fatal = false) |
| 388 | 388 | { |
| 389 | - static $fp = null; |
|
| 389 | + static $fp = null; |
|
| 390 | 390 | |
| 391 | - if ($fp === null) |
|
| 392 | - $fp = fopen('php://stderr', 'wb'); |
|
| 391 | + if ($fp === null) |
|
| 392 | + $fp = fopen('php://stderr', 'wb'); |
|
| 393 | 393 | |
| 394 | - fwrite($fp, $message . "\n"); |
|
| 394 | + fwrite($fp, $message . "\n"); |
|
| 395 | 395 | |
| 396 | - if ($fatal) |
|
| 397 | - exit; |
|
| 396 | + if ($fatal) |
|
| 397 | + exit; |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -405,12 +405,12 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | function throw_error($message) |
| 407 | 407 | { |
| 408 | - global $upcontext; |
|
| 408 | + global $upcontext; |
|
| 409 | 409 | |
| 410 | - $upcontext['error_msg'] = $message; |
|
| 411 | - $upcontext['sub_template'] = 'error_message'; |
|
| 410 | + $upcontext['error_msg'] = $message; |
|
| 411 | + $upcontext['sub_template'] = 'error_message'; |
|
| 412 | 412 | |
| 413 | - return false; |
|
| 413 | + return false; |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | function smf_mysql_fetch_assoc($rs) |
| 424 | 424 | { |
| 425 | - return mysqli_fetch_assoc($rs); |
|
| 425 | + return mysqli_fetch_assoc($rs); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | /** |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | */ |
| 432 | 432 | function smf_mysql_fetch_row($rs) |
| 433 | 433 | { |
| 434 | - return mysqli_fetch_row($rs); |
|
| 434 | + return mysqli_fetch_row($rs); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | */ |
| 440 | 440 | function smf_mysql_free_result($rs) |
| 441 | 441 | { |
| 442 | - mysqli_free_result($rs); |
|
| 442 | + mysqli_free_result($rs); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | */ |
| 449 | 449 | function smf_mysql_insert_id($rs) |
| 450 | 450 | { |
| 451 | - return mysqli_insert_id($rs); |
|
| 451 | + return mysqli_insert_id($rs); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | function smf_mysql_num_rows($rs) |
| 459 | 459 | { |
| 460 | - return mysqli_num_rows($rs); |
|
| 460 | + return mysqli_num_rows($rs); |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | /** |
@@ -465,6 +465,6 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | function smf_mysql_real_escape_string($string) |
| 467 | 467 | { |
| 468 | - global $db_connection; |
|
| 469 | - mysqli_real_escape_string($db_connection, $string); |
|
| 468 | + global $db_connection; |
|
| 469 | + mysqli_real_escape_string($db_connection, $string); |
|
| 470 | 470 | } |
| 471 | 471 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * This file contains helper functions for upgrade.php |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF_VERSION')) |
|
| 16 | +if (!defined('SMF_VERSION')) { |
|
| 17 | 17 | die('No direct access!'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | if (!function_exists('un_htmlspecialchars')) |
| 20 | 21 | { |
@@ -53,8 +54,9 @@ discard block |
||
| 53 | 54 | { |
| 54 | 55 | $word = trim($word, '-_\''); |
| 55 | 56 | |
| 56 | - if ($word != '') |
|
| 57 | - $returned_words[] = substr($word, 0, 20); |
|
| 57 | + if ($word != '') { |
|
| 58 | + $returned_words[] = substr($word, 0, 20); |
|
| 59 | + } |
|
| 58 | 60 | } |
| 59 | 61 | |
| 60 | 62 | return array_unique($returned_words); |
@@ -105,8 +107,9 @@ discard block |
||
| 105 | 107 | global $smcFunc; |
| 106 | 108 | static $member_groups = array(); |
| 107 | 109 | |
| 108 | - if (!empty($member_groups)) |
|
| 109 | - return $member_groups; |
|
| 110 | + if (!empty($member_groups)) { |
|
| 111 | + return $member_groups; |
|
| 112 | + } |
|
| 110 | 113 | |
| 111 | 114 | $request = $smcFunc['db_query']('', ' |
| 112 | 115 | SELECT group_name, id_group |
@@ -131,8 +134,9 @@ discard block |
||
| 131 | 134 | ) |
| 132 | 135 | ); |
| 133 | 136 | } |
| 134 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 135 | - $member_groups[trim($row[0])] = $row[1]; |
|
| 137 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 138 | + $member_groups[trim($row[0])] = $row[1]; |
|
| 139 | + } |
|
| 136 | 140 | $smcFunc['db_free_result']($request); |
| 137 | 141 | |
| 138 | 142 | return $member_groups; |
@@ -148,8 +152,9 @@ discard block |
||
| 148 | 152 | { |
| 149 | 153 | global $upcontext, $boarddir; |
| 150 | 154 | |
| 151 | - if (empty($files)) |
|
| 152 | - return true; |
|
| 155 | + if (empty($files)) { |
|
| 156 | + return true; |
|
| 157 | + } |
|
| 153 | 158 | |
| 154 | 159 | $failure = false; |
| 155 | 160 | // On linux, it's easy - just use is_writable! |
@@ -164,14 +169,16 @@ discard block |
||
| 164 | 169 | @chmod($file, 0755); |
| 165 | 170 | |
| 166 | 171 | // Well, 755 hopefully worked... if not, try 777. |
| 167 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
| 168 | - $failure = true; |
|
| 172 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
| 173 | + $failure = true; |
|
| 174 | + } |
|
| 169 | 175 | // Otherwise remove it as it's good! |
| 170 | - else |
|
| 171 | - unset($files[$k]); |
|
| 176 | + else { |
|
| 177 | + unset($files[$k]); |
|
| 178 | + } |
|
| 179 | + } else { |
|
| 180 | + unset($files[$k]); |
|
| 172 | 181 | } |
| 173 | - else |
|
| 174 | - unset($files[$k]); |
|
| 175 | 182 | } |
| 176 | 183 | } |
| 177 | 184 | // Windows is trickier. Let's try opening for r+... |
@@ -182,30 +189,35 @@ discard block |
||
| 182 | 189 | foreach ($files as $k => $file) |
| 183 | 190 | { |
| 184 | 191 | // Folders can't be opened for write... but the index.php in them can ;). |
| 185 | - if (is_dir($file)) |
|
| 186 | - $file .= '/index.php'; |
|
| 192 | + if (is_dir($file)) { |
|
| 193 | + $file .= '/index.php'; |
|
| 194 | + } |
|
| 187 | 195 | |
| 188 | 196 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 189 | 197 | @chmod($file, 0777); |
| 190 | 198 | $fp = @fopen($file, 'r+'); |
| 191 | 199 | |
| 192 | 200 | // Hmm, okay, try just for write in that case... |
| 193 | - if (!$fp) |
|
| 194 | - $fp = @fopen($file, 'w'); |
|
| 201 | + if (!$fp) { |
|
| 202 | + $fp = @fopen($file, 'w'); |
|
| 203 | + } |
|
| 195 | 204 | |
| 196 | - if (!$fp) |
|
| 197 | - $failure = true; |
|
| 198 | - else |
|
| 199 | - unset($files[$k]); |
|
| 205 | + if (!$fp) { |
|
| 206 | + $failure = true; |
|
| 207 | + } else { |
|
| 208 | + unset($files[$k]); |
|
| 209 | + } |
|
| 200 | 210 | @fclose($fp); |
| 201 | 211 | } |
| 202 | 212 | } |
| 203 | 213 | |
| 204 | - if (empty($files)) |
|
| 205 | - return true; |
|
| 214 | + if (empty($files)) { |
|
| 215 | + return true; |
|
| 216 | + } |
|
| 206 | 217 | |
| 207 | - if (!isset($_SERVER)) |
|
| 208 | - return !$failure; |
|
| 218 | + if (!isset($_SERVER)) { |
|
| 219 | + return !$failure; |
|
| 220 | + } |
|
| 209 | 221 | |
| 210 | 222 | // What still needs to be done? |
| 211 | 223 | $upcontext['chmod']['files'] = $files; |
@@ -256,36 +268,40 @@ discard block |
||
| 256 | 268 | |
| 257 | 269 | if (!isset($ftp) || $ftp->error !== false) |
| 258 | 270 | { |
| 259 | - if (!isset($ftp)) |
|
| 260 | - $ftp = new ftp_connection(null); |
|
| 271 | + if (!isset($ftp)) { |
|
| 272 | + $ftp = new ftp_connection(null); |
|
| 273 | + } |
|
| 261 | 274 | // Save the error so we can mess with listing... |
| 262 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
| 263 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 275 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
| 276 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 277 | + } |
|
| 264 | 278 | |
| 265 | 279 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 266 | 280 | |
| 267 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
| 268 | - $upcontext['chmod']['path'] = $detect_path; |
|
| 281 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
| 282 | + $upcontext['chmod']['path'] = $detect_path; |
|
| 283 | + } |
|
| 269 | 284 | |
| 270 | - if (!isset($upcontext['chmod']['username'])) |
|
| 271 | - $upcontext['chmod']['username'] = $username; |
|
| 285 | + if (!isset($upcontext['chmod']['username'])) { |
|
| 286 | + $upcontext['chmod']['username'] = $username; |
|
| 287 | + } |
|
| 272 | 288 | |
| 273 | 289 | // Don't forget the login token. |
| 274 | 290 | $upcontext += createToken('login'); |
| 275 | 291 | |
| 276 | 292 | return false; |
| 277 | - } |
|
| 278 | - else |
|
| 293 | + } else |
|
| 279 | 294 | { |
| 280 | 295 | // We want to do a relative path for FTP. |
| 281 | 296 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
| 282 | 297 | { |
| 283 | 298 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
| 284 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
| 285 | - $ftp_root = substr($ftp_root, 0, -1); |
|
| 299 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
| 300 | + $ftp_root = substr($ftp_root, 0, -1); |
|
| 301 | + } |
|
| 302 | + } else { |
|
| 303 | + $ftp_root = $boarddir; |
|
| 286 | 304 | } |
| 287 | - else |
|
| 288 | - $ftp_root = $boarddir; |
|
| 289 | 305 | |
| 290 | 306 | // Save the info for next time! |
| 291 | 307 | $_SESSION['installer_temp_ftp'] = array( |
@@ -299,10 +315,12 @@ discard block |
||
| 299 | 315 | |
| 300 | 316 | foreach ($files as $k => $file) |
| 301 | 317 | { |
| 302 | - if (!is_writable($file)) |
|
| 303 | - $ftp->chmod($file, 0755); |
|
| 304 | - if (!is_writable($file)) |
|
| 305 | - $ftp->chmod($file, 0777); |
|
| 318 | + if (!is_writable($file)) { |
|
| 319 | + $ftp->chmod($file, 0755); |
|
| 320 | + } |
|
| 321 | + if (!is_writable($file)) { |
|
| 322 | + $ftp->chmod($file, 0777); |
|
| 323 | + } |
|
| 306 | 324 | |
| 307 | 325 | // Assuming that didn't work calculate the path without the boarddir. |
| 308 | 326 | if (!is_writable($file)) |
@@ -311,19 +329,23 @@ discard block |
||
| 311 | 329 | { |
| 312 | 330 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
| 313 | 331 | $ftp->chmod($ftp_file, 0755); |
| 314 | - if (!is_writable($file)) |
|
| 315 | - $ftp->chmod($ftp_file, 0777); |
|
| 332 | + if (!is_writable($file)) { |
|
| 333 | + $ftp->chmod($ftp_file, 0777); |
|
| 334 | + } |
|
| 316 | 335 | // Sometimes an extra slash can help... |
| 317 | 336 | $ftp_file = '/' . $ftp_file; |
| 318 | - if (!is_writable($file)) |
|
| 319 | - $ftp->chmod($ftp_file, 0755); |
|
| 320 | - if (!is_writable($file)) |
|
| 321 | - $ftp->chmod($ftp_file, 0777); |
|
| 337 | + if (!is_writable($file)) { |
|
| 338 | + $ftp->chmod($ftp_file, 0755); |
|
| 339 | + } |
|
| 340 | + if (!is_writable($file)) { |
|
| 341 | + $ftp->chmod($ftp_file, 0777); |
|
| 342 | + } |
|
| 322 | 343 | } |
| 323 | 344 | } |
| 324 | 345 | |
| 325 | - if (is_writable($file)) |
|
| 326 | - unset($files[$k]); |
|
| 346 | + if (is_writable($file)) { |
|
| 347 | + unset($files[$k]); |
|
| 348 | + } |
|
| 327 | 349 | } |
| 328 | 350 | |
| 329 | 351 | $ftp->close(); |
@@ -333,8 +355,9 @@ discard block |
||
| 333 | 355 | // What remains? |
| 334 | 356 | $upcontext['chmod']['files'] = $files; |
| 335 | 357 | |
| 336 | - if (empty($files)) |
|
| 337 | - return true; |
|
| 358 | + if (empty($files)) { |
|
| 359 | + return true; |
|
| 360 | + } |
|
| 338 | 361 | |
| 339 | 362 | return false; |
| 340 | 363 | } |
@@ -347,8 +370,9 @@ discard block |
||
| 347 | 370 | */ |
| 348 | 371 | function quickFileWritable($file) |
| 349 | 372 | { |
| 350 | - if (is_writable($file)) |
|
| 351 | - return true; |
|
| 373 | + if (is_writable($file)) { |
|
| 374 | + return true; |
|
| 375 | + } |
|
| 352 | 376 | |
| 353 | 377 | @chmod($file, 0755); |
| 354 | 378 | |
@@ -358,10 +382,11 @@ discard block |
||
| 358 | 382 | foreach ($chmod_values as $val) |
| 359 | 383 | { |
| 360 | 384 | // If it's writable, break out of the loop |
| 361 | - if (is_writable($file)) |
|
| 362 | - break; |
|
| 363 | - else |
|
| 364 | - @chmod($file, $val); |
|
| 385 | + if (is_writable($file)) { |
|
| 386 | + break; |
|
| 387 | + } else { |
|
| 388 | + @chmod($file, $val); |
|
| 389 | + } |
|
| 365 | 390 | } |
| 366 | 391 | |
| 367 | 392 | return is_writable($file); |
@@ -388,14 +413,16 @@ discard block |
||
| 388 | 413 | { |
| 389 | 414 | static $fp = null; |
| 390 | 415 | |
| 391 | - if ($fp === null) |
|
| 392 | - $fp = fopen('php://stderr', 'wb'); |
|
| 416 | + if ($fp === null) { |
|
| 417 | + $fp = fopen('php://stderr', 'wb'); |
|
| 418 | + } |
|
| 393 | 419 | |
| 394 | 420 | fwrite($fp, $message . "\n"); |
| 395 | 421 | |
| 396 | - if ($fatal) |
|
| 397 | - exit; |
|
| 398 | -} |
|
| 422 | + if ($fatal) { |
|
| 423 | + exit; |
|
| 424 | + } |
|
| 425 | + } |
|
| 399 | 426 | |
| 400 | 427 | /** |
| 401 | 428 | * Throws a graphical error message. |