@@ -121,7 +121,7 @@ |
||
121 | 121 | |
122 | 122 | $files = array_unique(array_merge($always_update, array_filter( |
123 | 123 | explode("\n", shell_exec('git diff --name-only v' . $prev_version . '...HEAD')), |
124 | - function ($filename) |
|
124 | + function($filename) |
|
125 | 125 | { |
126 | 126 | return file_exists($filename) && strpos(mime_content_type($filename), 'text/') === 0; |
127 | 127 | } |
@@ -448,7 +448,7 @@ |
||
448 | 448 | function array_column($input, $column_key, $index_key = null) |
449 | 449 | { |
450 | 450 | $arr = array_map( |
451 | - function ($d) use ($column_key, $index_key) { |
|
451 | + function($d) use ($column_key, $index_key) { |
|
452 | 452 | if (!isset($d[$column_key])) { |
453 | 453 | return; |
454 | 454 | } |
@@ -13,7 +13,8 @@ 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 | 18 | die('No direct access!'); |
18 | 19 | } |
19 | 20 | |
@@ -37,7 +38,8 @@ discard block |
||
37 | 38 | { |
38 | 39 | static $member_groups = []; |
39 | 40 | |
40 | - if (!empty($member_groups)) { |
|
41 | + if (!empty($member_groups)) |
|
42 | + { |
|
41 | 43 | return $member_groups; |
42 | 44 | } |
43 | 45 | |
@@ -53,7 +55,8 @@ discard block |
||
53 | 55 | ], |
54 | 56 | ); |
55 | 57 | |
56 | - if ($request === false) { |
|
58 | + if ($request === false) |
|
59 | + { |
|
57 | 60 | $request = SMF\Db\DatabaseApi::$db->query( |
58 | 61 | '', |
59 | 62 | 'SELECT membergroup, id_group |
@@ -67,7 +70,8 @@ discard block |
||
67 | 70 | ); |
68 | 71 | } |
69 | 72 | |
70 | - while ($row = SMF\Db\DatabaseApi::$db->fetch_row($request)) { |
|
73 | + while ($row = SMF\Db\DatabaseApi::$db->fetch_row($request)) |
|
74 | + { |
|
71 | 75 | $member_groups[trim($row[0])] = $row[1]; |
72 | 76 | } |
73 | 77 | SMF\Db\DatabaseApi::$db->free_result($request); |
@@ -85,46 +89,58 @@ discard block |
||
85 | 89 | { |
86 | 90 | global $upcontext; |
87 | 91 | |
88 | - if (empty($files)) { |
|
92 | + if (empty($files)) |
|
93 | + { |
|
89 | 94 | return true; |
90 | 95 | } |
91 | 96 | |
92 | 97 | $failure = false; |
93 | 98 | |
94 | 99 | // On linux, it's easy - just use is_writable! |
95 | - if (substr(__FILE__, 1, 2) != ':\\') { |
|
100 | + if (substr(__FILE__, 1, 2) != ':\\') |
|
101 | + { |
|
96 | 102 | $upcontext['systemos'] = 'linux'; |
97 | 103 | |
98 | - foreach ($files as $k => $file) { |
|
104 | + foreach ($files as $k => $file) |
|
105 | + { |
|
99 | 106 | // Some files won't exist, try to address up front |
100 | - if (!file_exists($file)) { |
|
107 | + if (!file_exists($file)) |
|
108 | + { |
|
101 | 109 | @touch($file); |
102 | 110 | } |
103 | 111 | |
104 | 112 | // NOW do the writable check... |
105 | - if (!is_writable($file)) { |
|
113 | + if (!is_writable($file)) |
|
114 | + { |
|
106 | 115 | @chmod($file, 0755); |
107 | 116 | |
108 | 117 | // Well, 755 hopefully worked... if not, try 777. |
109 | - if (!is_writable($file) && !@chmod($file, 0777)) { |
|
118 | + if (!is_writable($file) && !@chmod($file, 0777)) |
|
119 | + { |
|
110 | 120 | $failure = true; |
111 | 121 | } |
112 | 122 | // Otherwise remove it as it's good! |
113 | - else { |
|
123 | + else |
|
124 | + { |
|
114 | 125 | unset($files[$k]); |
115 | 126 | } |
116 | - } else { |
|
127 | + } |
|
128 | + else |
|
129 | + { |
|
117 | 130 | unset($files[$k]); |
118 | 131 | } |
119 | 132 | } |
120 | 133 | } |
121 | 134 | // Windows is trickier. Let's try opening for r+... |
122 | - else { |
|
135 | + else |
|
136 | + { |
|
123 | 137 | $upcontext['systemos'] = 'windows'; |
124 | 138 | |
125 | - foreach ($files as $k => $file) { |
|
139 | + foreach ($files as $k => $file) |
|
140 | + { |
|
126 | 141 | // Folders can't be opened for write... but the index.php in them can ;). |
127 | - if (is_dir($file)) { |
|
142 | + if (is_dir($file)) |
|
143 | + { |
|
128 | 144 | $file .= '/index.php'; |
129 | 145 | } |
130 | 146 | |
@@ -133,24 +149,30 @@ discard block |
||
133 | 149 | $fp = @fopen($file, 'r+'); |
134 | 150 | |
135 | 151 | // Hmm, okay, try just for write in that case... |
136 | - if (!$fp) { |
|
152 | + if (!$fp) |
|
153 | + { |
|
137 | 154 | $fp = @fopen($file, 'w'); |
138 | 155 | } |
139 | 156 | |
140 | - if (!$fp) { |
|
157 | + if (!$fp) |
|
158 | + { |
|
141 | 159 | $failure = true; |
142 | - } else { |
|
160 | + } |
|
161 | + else |
|
162 | + { |
|
143 | 163 | unset($files[$k]); |
144 | 164 | } |
145 | 165 | @fclose($fp); |
146 | 166 | } |
147 | 167 | } |
148 | 168 | |
149 | - if (empty($files)) { |
|
169 | + if (empty($files)) |
|
170 | + { |
|
150 | 171 | return true; |
151 | 172 | } |
152 | 173 | |
153 | - if (!isset($_SERVER)) { |
|
174 | + if (!isset($_SERVER)) |
|
175 | + { |
|
154 | 176 | return !$failure; |
155 | 177 | } |
156 | 178 | |
@@ -158,16 +180,19 @@ discard block |
||
158 | 180 | $upcontext['chmod']['files'] = $files; |
159 | 181 | |
160 | 182 | // If it's windows it's a mess... |
161 | - if ($failure && substr(__FILE__, 1, 2) == ':\\') { |
|
183 | + if ($failure && substr(__FILE__, 1, 2) == ':\\') |
|
184 | + { |
|
162 | 185 | $upcontext['chmod']['ftp_error'] = 'total_mess'; |
163 | 186 | |
164 | 187 | return false; |
165 | 188 | } |
166 | 189 | |
167 | 190 | // We're going to have to use... FTP! |
168 | - if ($failure) { |
|
191 | + if ($failure) |
|
192 | + { |
|
169 | 193 | // Load any session data we might have... |
170 | - if (!isset($_POST['ftp_username']) && isset($_SESSION['installer_temp_ftp'])) { |
|
194 | + if (!isset($_POST['ftp_username']) && isset($_SESSION['installer_temp_ftp'])) |
|
195 | + { |
|
171 | 196 | $upcontext['chmod']['server'] = $_SESSION['installer_temp_ftp']['server']; |
172 | 197 | $upcontext['chmod']['port'] = $_SESSION['installer_temp_ftp']['port']; |
173 | 198 | $upcontext['chmod']['username'] = $_SESSION['installer_temp_ftp']['username']; |
@@ -175,7 +200,8 @@ discard block |
||
175 | 200 | $upcontext['chmod']['path'] = $_SESSION['installer_temp_ftp']['path']; |
176 | 201 | } |
177 | 202 | // Or have we submitted? |
178 | - elseif (isset($_POST['ftp_username'])) { |
|
203 | + elseif (isset($_POST['ftp_username'])) |
|
204 | + { |
|
179 | 205 | $upcontext['chmod']['server'] = $_POST['ftp_server']; |
180 | 206 | $upcontext['chmod']['port'] = $_POST['ftp_port']; |
181 | 207 | $upcontext['chmod']['username'] = $_POST['ftp_username']; |
@@ -185,34 +211,42 @@ discard block |
||
185 | 211 | |
186 | 212 | require_once \SMF\Config::$sourcedir . '/PackageManager/FtpConnection.php'; |
187 | 213 | |
188 | - if (isset($upcontext['chmod']['username'])) { |
|
214 | + if (isset($upcontext['chmod']['username'])) |
|
215 | + { |
|
189 | 216 | $ftp = new \SMF\PackageManager\FtpConnection($upcontext['chmod']['server'], $upcontext['chmod']['port'], $upcontext['chmod']['username'], $upcontext['chmod']['password']); |
190 | 217 | |
191 | - if ($ftp->error === false) { |
|
218 | + if ($ftp->error === false) |
|
219 | + { |
|
192 | 220 | // Try it without /home/abc just in case they messed up. |
193 | - if (!$ftp->chdir($upcontext['chmod']['path'])) { |
|
221 | + if (!$ftp->chdir($upcontext['chmod']['path'])) |
|
222 | + { |
|
194 | 223 | $upcontext['chmod']['ftp_error'] = $ftp->last_message; |
195 | 224 | $ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $upcontext['chmod']['path'])); |
196 | 225 | } |
197 | 226 | } |
198 | 227 | } |
199 | 228 | |
200 | - if (!isset($ftp) || $ftp->error !== false) { |
|
201 | - if (!isset($ftp)) { |
|
229 | + if (!isset($ftp) || $ftp->error !== false) |
|
230 | + { |
|
231 | + if (!isset($ftp)) |
|
232 | + { |
|
202 | 233 | $ftp = new \SMF\PackageManager\FtpConnection(null); |
203 | 234 | } |
204 | 235 | // Save the error so we can mess with listing... |
205 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
236 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
237 | + { |
|
206 | 238 | $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
207 | 239 | } |
208 | 240 | |
209 | 241 | list($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
210 | 242 | |
211 | - if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
243 | + if ($found_path || !isset($upcontext['chmod']['path'])) |
|
244 | + { |
|
212 | 245 | $upcontext['chmod']['path'] = $detect_path; |
213 | 246 | } |
214 | 247 | |
215 | - if (!isset($upcontext['chmod']['username'])) { |
|
248 | + if (!isset($upcontext['chmod']['username'])) |
|
249 | + { |
|
216 | 250 | $upcontext['chmod']['username'] = $username; |
217 | 251 | } |
218 | 252 | |
@@ -224,13 +258,17 @@ discard block |
||
224 | 258 | |
225 | 259 | |
226 | 260 | // We want to do a relative path for FTP. |
227 | - if (!in_array($upcontext['chmod']['path'], ['', '/'])) { |
|
261 | + if (!in_array($upcontext['chmod']['path'], ['', '/'])) |
|
262 | + { |
|
228 | 263 | $ftp_root = strtr(\SMF\Config::$boarddir, [$upcontext['chmod']['path'] => '']); |
229 | 264 | |
230 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
265 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
266 | + { |
|
231 | 267 | $ftp_root = substr($ftp_root, 0, -1); |
232 | 268 | } |
233 | - } else { |
|
269 | + } |
|
270 | + else |
|
271 | + { |
|
234 | 272 | $ftp_root = \SMF\Config::$boarddir; |
235 | 273 | } |
236 | 274 | |
@@ -244,38 +282,47 @@ discard block |
||
244 | 282 | 'root' => $ftp_root, |
245 | 283 | ]; |
246 | 284 | |
247 | - foreach ($files as $k => $file) { |
|
248 | - if (!is_writable($file)) { |
|
285 | + foreach ($files as $k => $file) |
|
286 | + { |
|
287 | + if (!is_writable($file)) |
|
288 | + { |
|
249 | 289 | $ftp->chmod($file, 0755); |
250 | 290 | } |
251 | 291 | |
252 | - if (!is_writable($file)) { |
|
292 | + if (!is_writable($file)) |
|
293 | + { |
|
253 | 294 | $ftp->chmod($file, 0777); |
254 | 295 | } |
255 | 296 | |
256 | 297 | // Assuming that didn't work calculate the path without the boarddir. |
257 | - if (!is_writable($file)) { |
|
258 | - if (strpos($file, \SMF\Config::$boarddir) === 0) { |
|
298 | + if (!is_writable($file)) |
|
299 | + { |
|
300 | + if (strpos($file, \SMF\Config::$boarddir) === 0) |
|
301 | + { |
|
259 | 302 | $ftp_file = strtr($file, [$_SESSION['installer_temp_ftp']['root'] => '']); |
260 | 303 | $ftp->chmod($ftp_file, 0755); |
261 | 304 | |
262 | - if (!is_writable($file)) { |
|
305 | + if (!is_writable($file)) |
|
306 | + { |
|
263 | 307 | $ftp->chmod($ftp_file, 0777); |
264 | 308 | } |
265 | 309 | // Sometimes an extra slash can help... |
266 | 310 | $ftp_file = '/' . $ftp_file; |
267 | 311 | |
268 | - if (!is_writable($file)) { |
|
312 | + if (!is_writable($file)) |
|
313 | + { |
|
269 | 314 | $ftp->chmod($ftp_file, 0755); |
270 | 315 | } |
271 | 316 | |
272 | - if (!is_writable($file)) { |
|
317 | + if (!is_writable($file)) |
|
318 | + { |
|
273 | 319 | $ftp->chmod($ftp_file, 0777); |
274 | 320 | } |
275 | 321 | } |
276 | 322 | } |
277 | 323 | |
278 | - if (is_writable($file)) { |
|
324 | + if (is_writable($file)) |
|
325 | + { |
|
279 | 326 | unset($files[$k]); |
280 | 327 | } |
281 | 328 | } |
@@ -299,12 +346,14 @@ discard block |
||
299 | 346 | function quickFileWritable($file) |
300 | 347 | { |
301 | 348 | // Some files won't exist, try to address up front |
302 | - if (!file_exists($file)) { |
|
349 | + if (!file_exists($file)) |
|
350 | + { |
|
303 | 351 | @touch($file); |
304 | 352 | } |
305 | 353 | |
306 | 354 | // NOW do the writable check... |
307 | - if (is_writable($file)) { |
|
355 | + if (is_writable($file)) |
|
356 | + { |
|
308 | 357 | return true; |
309 | 358 | } |
310 | 359 | |
@@ -313,9 +362,11 @@ discard block |
||
313 | 362 | // Try 755 and 775 first since 777 doesn't always work and could be a risk... |
314 | 363 | $chmod_values = [0755, 0775, 0777]; |
315 | 364 | |
316 | - foreach ($chmod_values as $val) { |
|
365 | + foreach ($chmod_values as $val) |
|
366 | + { |
|
317 | 367 | // If it's writable, break out of the loop |
318 | - if (is_writable($file)) { |
|
368 | + if (is_writable($file)) |
|
369 | + { |
|
319 | 370 | break; |
320 | 371 | } |
321 | 372 | |
@@ -333,7 +384,8 @@ discard block |
||
333 | 384 | */ |
334 | 385 | function deleteFile($file) |
335 | 386 | { |
336 | - if (!file_exists($file)) { |
|
387 | + if (!file_exists($file)) |
|
388 | + { |
|
337 | 389 | return; |
338 | 390 | } |
339 | 391 | |
@@ -354,13 +406,15 @@ discard block |
||
354 | 406 | { |
355 | 407 | static $fp = null; |
356 | 408 | |
357 | - if ($fp === null) { |
|
409 | + if ($fp === null) |
|
410 | + { |
|
358 | 411 | $fp = fopen('php://stderr', 'wb'); |
359 | 412 | } |
360 | 413 | |
361 | 414 | fwrite($fp, $message . "\n"); |
362 | 415 | |
363 | - if ($fatal) { |
|
416 | + if ($fatal) |
|
417 | + { |
|
364 | 418 | exit; |
365 | 419 | } |
366 | 420 | } |
@@ -444,16 +498,20 @@ discard block |
||
444 | 498 | * @param $index to use as index if specified |
445 | 499 | * @return array of values of specified $col from $array |
446 | 500 | */ |
447 | -if (!function_exists('array_column')) { |
|
501 | +if (!function_exists('array_column')) |
|
502 | +{ |
|
448 | 503 | function array_column($input, $column_key, $index_key = null) |
449 | 504 | { |
450 | 505 | $arr = array_map( |
451 | - function ($d) use ($column_key, $index_key) { |
|
452 | - if (!isset($d[$column_key])) { |
|
506 | + function ($d) use ($column_key, $index_key) |
|
507 | + { |
|
508 | + if (!isset($d[$column_key])) |
|
509 | + { |
|
453 | 510 | return; |
454 | 511 | } |
455 | 512 | |
456 | - if ($index_key !== null) { |
|
513 | + if ($index_key !== null) |
|
514 | + { |
|
457 | 515 | return [$d[$index_key] => $d[$column_key]]; |
458 | 516 | } |
459 | 517 | |
@@ -462,10 +520,12 @@ discard block |
||
462 | 520 | $input, |
463 | 521 | ); |
464 | 522 | |
465 | - if ($index_key !== null) { |
|
523 | + if ($index_key !== null) |
|
524 | + { |
|
466 | 525 | $tmp = []; |
467 | 526 | |
468 | - foreach ($arr as $ar) { |
|
527 | + foreach ($arr as $ar) |
|
528 | + { |
|
469 | 529 | $tmp[key($ar)] = current($ar); |
470 | 530 | } |
471 | 531 | $arr = $tmp; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'mysql' => [ |
55 | 55 | 'name' => 'MySQL', |
56 | 56 | 'version' => '5.6.0', |
57 | - 'version_check' => function () { |
|
57 | + 'version_check' => function() { |
|
58 | 58 | if (!function_exists('mysqli_fetch_row')) { |
59 | 59 | return false; |
60 | 60 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | 'postgresql' => [ |
67 | 67 | 'name' => 'PostgreSQL', |
68 | 68 | 'version' => '9.6', |
69 | - 'version_check' => function () { |
|
69 | + 'version_check' => function() { |
|
70 | 70 | if (!function_exists('pg_version')) { |
71 | 71 | return false; |
72 | 72 | } |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | $to = explode('/', $lang_dir); |
597 | 597 | $relPath = $to; |
598 | 598 | |
599 | - foreach($from as $depth => $dir) { |
|
599 | + foreach ($from as $depth => $dir) { |
|
600 | 600 | if ($dir === $to[$depth]) { |
601 | 601 | array_shift($relPath); |
602 | 602 | } else { |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | // PHP currently has a terrible handling with unserialize in which errors are fatal and not catchable. Lets borrow some code from the RFC that intends to fix this |
1109 | 1109 | // https://wiki.php.net/rfc/improve_unserialize_error_handling |
1110 | 1110 | try { |
1111 | - set_error_handler(static function ($severity, $message, $file, $line) { |
|
1111 | + set_error_handler(static function($severity, $message, $file, $line) { |
|
1112 | 1112 | throw new \ErrorException($message, 0, $severity, $file, $line); |
1113 | 1113 | }); |
1114 | 1114 | $ser_test = @unserialize(Config::$modSettings['attachmentUploadDir']); |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | } |
1136 | 1136 | // An array already? |
1137 | 1137 | elseif (is_array(Config::$modSettings['attachmentUploadDir'])) { |
1138 | - foreach(Config::$modSettings['attachmentUploadDir'] as $dir) { |
|
1138 | + foreach (Config::$modSettings['attachmentUploadDir'] as $dir) { |
|
1139 | 1139 | if (!empty($dir) && !is_dir($dir)) { |
1140 | 1140 | $attdr_problem_found = true; |
1141 | 1141 | } |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | // Serialized? |
1145 | 1145 | elseif ($ser_test !== false) { |
1146 | 1146 | if (is_array($ser_test)) { |
1147 | - foreach($ser_test as $dir) { |
|
1147 | + foreach ($ser_test as $dir) { |
|
1148 | 1148 | if (!empty($dir) && !is_dir($dir)) { |
1149 | 1149 | $attdr_problem_found = true; |
1150 | 1150 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | // Json? Note the test returns null if encoding was unsuccessful |
1159 | 1159 | elseif ($json_test !== null) { |
1160 | 1160 | if (is_array($json_test)) { |
1161 | - foreach($json_test as $dir) { |
|
1161 | + foreach ($json_test as $dir) { |
|
1162 | 1162 | if (!is_dir($dir)) { |
1163 | 1163 | $attdr_problem_found = true; |
1164 | 1164 | } |
@@ -2231,7 +2231,7 @@ discard block |
||
2231 | 2231 | // will return 4437 (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE) |
2232 | 2232 | // as it does so. |
2233 | 2233 | set_error_handler( |
2234 | - function ($errno, $errstr, $errfile, $errline) use ($support_js) { |
|
2234 | + function($errno, $errstr, $errfile, $errline) use ($support_js) { |
|
2235 | 2235 | if ($support_js) { |
2236 | 2236 | return true; |
2237 | 2237 | } |
@@ -3254,101 +3254,101 @@ discard block |
||
3254 | 3254 | ]; |
3255 | 3255 | |
3256 | 3256 | // Default to ISO-8859-1 unless we detected another supported charset |
3257 | - $upcontext['charset_detected'] = (isset($lang_charsets[Config::$language], $charsets[strtr(strtolower($upcontext['charset_detected']),['utf' => 'UTF', 'iso' => 'ISO'])])) ? $lang_charsets[Config::$language] : 'ISO-8859-1'; |
|
3257 | + $upcontext['charset_detected'] = (isset($lang_charsets[Config::$language], $charsets[strtr(strtolower($upcontext['charset_detected']), ['utf' => 'UTF', 'iso' => 'ISO'])])) ? $lang_charsets[Config::$language] : 'ISO-8859-1'; |
|
3258 | 3258 | |
3259 | 3259 | $upcontext['charset_list'] = array_keys($charsets); |
3260 | 3260 | |
3261 | 3261 | // Translation table for the character sets not native for MySQL. |
3262 | 3262 | $translation_tables = [ |
3263 | 3263 | 'windows-1255' => [ |
3264 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
3265 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
3266 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
3267 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
3268 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
3269 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
3270 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
3271 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
3272 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
3273 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
3274 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
3275 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
3276 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
3277 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
3278 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
3279 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
3280 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
3281 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
3282 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
3283 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
3284 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
3285 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
3286 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
3287 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
3288 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
3289 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
3290 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
3291 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
3292 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
3293 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
3294 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
3295 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
3296 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
3297 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
3298 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
3299 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
3300 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
3301 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
3302 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
3303 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
3304 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
3305 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
3264 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
3265 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
3266 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
3267 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
3268 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
3269 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
3270 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
3271 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
3272 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
3273 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
3274 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
3275 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
3276 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
3277 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
3278 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
3279 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
3280 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
3281 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
3282 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
3283 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
3284 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
3285 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
3286 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
3287 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
3288 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
3289 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
3290 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
3291 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
3292 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
3293 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
3294 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
3295 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
3296 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
3297 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
3298 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
3299 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
3300 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
3301 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
3302 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
3303 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
3304 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
3305 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
3306 | 3306 | '0xFA' => '0xD7AA', |
3307 | 3307 | ], |
3308 | 3308 | 'windows-1253' => [ |
3309 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
3310 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
3311 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
3312 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
3313 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
3314 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
3315 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
3316 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
3317 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
3318 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
3319 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
3320 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
3321 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
3322 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
3323 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
3324 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
3325 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
3326 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
3327 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
3328 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
3329 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
3330 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
3331 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
3332 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
3333 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
3334 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
3335 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
3336 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
3337 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
3338 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
3339 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
3340 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
3341 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
3342 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
3343 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
3344 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
3345 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
3346 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
3347 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
3348 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
3349 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
3350 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
3351 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
3309 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
3310 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
3311 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
3312 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
3313 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
3314 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
3315 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
3316 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
3317 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
3318 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
3319 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
3320 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
3321 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
3322 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
3323 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
3324 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
3325 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
3326 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
3327 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
3328 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
3329 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
3330 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
3331 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
3332 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
3333 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
3334 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
3335 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
3336 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
3337 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
3338 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
3339 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
3340 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
3341 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
3342 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
3343 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
3344 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
3345 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
3346 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
3347 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
3348 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
3349 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
3350 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
3351 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
3352 | 3352 | ], |
3353 | 3353 | ]; |
3354 | 3354 | |
@@ -3365,7 +3365,7 @@ discard block |
||
3365 | 3365 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
3366 | 3366 | $queryTables = Db::$db->list_tables(false, Config::$db_prefix . '%'); |
3367 | 3367 | |
3368 | - $queryTables = array_values(array_filter($queryTables, function ($v) { |
|
3368 | + $queryTables = array_values(array_filter($queryTables, function($v) { |
|
3369 | 3369 | return stripos($v, 'backup_') !== 0; |
3370 | 3370 | })); |
3371 | 3371 | |
@@ -3619,7 +3619,7 @@ discard block |
||
3619 | 3619 | // This bit fixes incorrect string lengths, which can happen if the character encoding was changed (e.g. conversion to UTF-8) |
3620 | 3620 | $new_string = preg_replace_callback( |
3621 | 3621 | '~\bs:(\d+):"(.*?)";(?=$|[bidsaO]:|[{}}]|N;)~s', |
3622 | - function ($matches) { |
|
3622 | + function($matches) { |
|
3623 | 3623 | return 's:' . strlen($matches[2]) . ':"' . $matches[2] . '";'; |
3624 | 3624 | }, |
3625 | 3625 | $string, |
@@ -34,7 +34,8 @@ discard block |
||
34 | 34 | define('MYSQL_TITLE', 'MySQL'); |
35 | 35 | define('SMF_USER_AGENT', 'Mozilla/5.0 (' . php_uname('s') . ' ' . php_uname('m') . ') AppleWebKit/605.1.15 (KHTML, like Gecko) SMF/' . strtr(SMF_VERSION, ' ', '.')); |
36 | 36 | |
37 | -if (!defined('TIME_START')) { |
|
37 | +if (!defined('TIME_START')) |
|
38 | +{ |
|
38 | 39 | define('TIME_START', microtime(true)); |
39 | 40 | } |
40 | 41 | |
@@ -54,8 +55,10 @@ discard block |
||
54 | 55 | 'mysql' => [ |
55 | 56 | 'name' => 'MySQL', |
56 | 57 | 'version' => '5.6.0', |
57 | - 'version_check' => function () { |
|
58 | - if (!function_exists('mysqli_fetch_row')) { |
|
58 | + 'version_check' => function () |
|
59 | + { |
|
60 | + if (!function_exists('mysqli_fetch_row')) |
|
61 | + { |
|
59 | 62 | return false; |
60 | 63 | } |
61 | 64 | |
@@ -66,8 +69,10 @@ discard block |
||
66 | 69 | 'postgresql' => [ |
67 | 70 | 'name' => 'PostgreSQL', |
68 | 71 | 'version' => '9.6', |
69 | - 'version_check' => function () { |
|
70 | - if (!function_exists('pg_version')) { |
|
72 | + 'version_check' => function () |
|
73 | + { |
|
74 | + if (!function_exists('pg_version')) |
|
75 | + { |
|
71 | 76 | return false; |
72 | 77 | } |
73 | 78 | $version = pg_version(); |
@@ -134,35 +139,44 @@ discard block |
||
134 | 139 | @ini_set('memory_limit', '512M'); |
135 | 140 | |
136 | 141 | // Clean the upgrade path if this is from the client. |
137 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
138 | - for ($i = 1; $i < $_SERVER['argc']; $i++) { |
|
142 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
143 | +{ |
|
144 | + for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
145 | + { |
|
139 | 146 | // Provide the help without possible errors if the environment isn't sane. |
140 | - if (in_array($_SERVER['argv'][$i], ['-h', '--help'])) { |
|
147 | + if (in_array($_SERVER['argv'][$i], ['-h', '--help'])) |
|
148 | + { |
|
141 | 149 | cmdStep0(); |
142 | 150 | |
143 | 151 | exit; |
144 | 152 | } |
145 | 153 | |
146 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
154 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
155 | + { |
|
147 | 156 | $upgrade_path = realpath(substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]); |
148 | 157 | } |
149 | 158 | |
150 | 159 | // Cases where we do php other/upgrade.php --path=./ |
151 | - if ($upgrade_path == './' && isset($_SERVER['PWD'])) { |
|
160 | + if ($upgrade_path == './' && isset($_SERVER['PWD'])) |
|
161 | + { |
|
152 | 162 | $upgrade_path = realpath($_SERVER['PWD']); |
153 | 163 | } |
154 | 164 | // Cases where we do php upgrade.php --path=../ |
155 | - elseif ($upgrade_path == '../' && isset($_SERVER['PWD'])) { |
|
165 | + elseif ($upgrade_path == '../' && isset($_SERVER['PWD'])) |
|
166 | + { |
|
156 | 167 | $upgrade_path = dirname(realpath($_SERVER['PWD'])); |
157 | 168 | } |
158 | 169 | } |
159 | 170 | } |
160 | 171 | |
161 | 172 | // Are we from the client? |
162 | -if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
173 | +if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
174 | +{ |
|
163 | 175 | $command_line = true; |
164 | 176 | $disable_security = true; |
165 | -} else { |
|
177 | +} |
|
178 | +else |
|
179 | +{ |
|
166 | 180 | $command_line = false; |
167 | 181 | } |
168 | 182 | |
@@ -173,8 +187,10 @@ discard block |
||
173 | 187 | foreach ([ |
174 | 188 | dirname(__FILE__) . '/upgrade-helper.php', |
175 | 189 | SMF_SETTINGS_FILE, |
176 | -] as $required_file) { |
|
177 | - if (!file_exists($required_file)) { |
|
190 | +] as $required_file) |
|
191 | +{ |
|
192 | + if (!file_exists($required_file)) |
|
193 | + { |
|
178 | 194 | die(basename($required_file) . ' was not found where it was expected: ' . $required_file . '! Make sure you have uploaded ALL files from the upgrade package to your forum\'s root directory. The upgrader cannot continue.'); |
179 | 195 | } |
180 | 196 | |
@@ -187,26 +203,31 @@ discard block |
||
187 | 203 | Utils::load(); |
188 | 204 | |
189 | 205 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
190 | -if (isset(Config::$language)) { |
|
206 | +if (isset(Config::$language)) |
|
207 | +{ |
|
191 | 208 | Config::$language = str_ireplace('-utf8', '', basename(Config::$language, '.lng')); |
192 | 209 | } |
193 | 210 | |
194 | 211 | // Figure out a valid language request (if any) |
195 | 212 | // Can't use $_GET until it's been cleaned, so do this manually and VERY restrictively! This even strips off those '-utf8' bits that we don't want. |
196 | -if (isset($_SERVER['QUERY_STRING']) && preg_match('~\blang=(\w+)~', $_SERVER['QUERY_STRING'], $matches)) { |
|
213 | +if (isset($_SERVER['QUERY_STRING']) && preg_match('~\blang=(\w+)~', $_SERVER['QUERY_STRING'], $matches)) |
|
214 | +{ |
|
197 | 215 | $upcontext['lang'] = $matches[1]; |
198 | 216 | } |
199 | 217 | |
200 | 218 | // Are we logged in? |
201 | -if (isset($upgradeData)) { |
|
219 | +if (isset($upgradeData)) |
|
220 | +{ |
|
202 | 221 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
203 | 222 | |
204 | 223 | // Check for sensible values. |
205 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
224 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
225 | + { |
|
206 | 226 | $upcontext['user']['started'] = time(); |
207 | 227 | } |
208 | 228 | |
209 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
229 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
230 | + { |
|
210 | 231 | $upcontext['user']['updated'] = 0; |
211 | 232 | } |
212 | 233 | |
@@ -219,7 +240,8 @@ discard block |
||
219 | 240 | } |
220 | 241 | |
221 | 242 | // Nothing sensible? |
222 | -if (empty($upcontext['updated'])) { |
|
243 | +if (empty($upcontext['updated'])) |
|
244 | +{ |
|
223 | 245 | $upcontext['started'] = time(); |
224 | 246 | $upcontext['updated'] = 0; |
225 | 247 | $upcontext['skip_db_substeps'] = false; |
@@ -239,19 +261,22 @@ discard block |
||
239 | 261 | loadEssentialData(); |
240 | 262 | |
241 | 263 | // Are we going to be mimic'ing SSI at this point? |
242 | -if (isset($_GET['ssi'])) { |
|
264 | +if (isset($_GET['ssi'])) |
|
265 | +{ |
|
243 | 266 | User::load(); |
244 | 267 | User::$me->loadPermissions(); |
245 | 268 | Config::reloadModSettings(); |
246 | 269 | } |
247 | 270 | |
248 | 271 | // Don't do security check if on Yabbse |
249 | -if (!isset(Config::$modSettings['smfVersion'])) { |
|
272 | +if (!isset(Config::$modSettings['smfVersion'])) |
|
273 | +{ |
|
250 | 274 | $disable_security = true; |
251 | 275 | } |
252 | 276 | |
253 | 277 | // This only exists if we're on SMF ;) |
254 | -if (isset(Config::$modSettings['smfVersion'])) { |
|
278 | +if (isset(Config::$modSettings['smfVersion'])) |
|
279 | +{ |
|
255 | 280 | $request = Db::$db->query( |
256 | 281 | '', |
257 | 282 | 'SELECT variable, value |
@@ -267,40 +292,47 @@ discard block |
||
267 | 292 | ], |
268 | 293 | ); |
269 | 294 | |
270 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
295 | + while ($row = Db::$db->fetch_assoc($request)) |
|
296 | + { |
|
271 | 297 | Config::$modSettings[$row['variable']] = $row['value']; |
272 | 298 | } |
273 | 299 | Db::$db->free_result($request); |
274 | 300 | } |
275 | 301 | |
276 | -if (!isset(Config::$modSettings['theme_url'])) { |
|
302 | +if (!isset(Config::$modSettings['theme_url'])) |
|
303 | +{ |
|
277 | 304 | Config::$modSettings['theme_dir'] = Config::$boarddir . '/Themes/default'; |
278 | 305 | Config::$modSettings['theme_url'] = 'Themes/default'; |
279 | 306 | Config::$modSettings['images_url'] = 'Themes/default/images'; |
280 | 307 | } |
281 | 308 | |
282 | -if (!isset($settings['default_theme_url'])) { |
|
309 | +if (!isset($settings['default_theme_url'])) |
|
310 | +{ |
|
283 | 311 | $settings['default_theme_url'] = Config::$modSettings['theme_url']; |
284 | 312 | } |
285 | 313 | |
286 | -if (!isset($settings['default_theme_dir'])) { |
|
314 | +if (!isset($settings['default_theme_dir'])) |
|
315 | +{ |
|
287 | 316 | $settings['default_theme_dir'] = Config::$modSettings['theme_dir']; |
288 | 317 | } |
289 | 318 | |
290 | 319 | // Old DBs won't have this |
291 | -if (!isset(Config::$modSettings['rand_seed'])) { |
|
320 | +if (!isset(Config::$modSettings['rand_seed'])) |
|
321 | +{ |
|
292 | 322 | Config::generateSeed(); |
293 | 323 | } |
294 | 324 | |
295 | 325 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
296 | -if (Config::httpsOn()) { |
|
326 | +if (Config::httpsOn()) |
|
327 | +{ |
|
297 | 328 | $settings['default_theme_url'] = strtr($settings['default_theme_url'], ['http://' => 'https://']); |
298 | 329 | } |
299 | 330 | |
300 | 331 | $upcontext['is_large_forum'] = (empty(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] <= '1.1 RC1') && !empty(Config::$modSettings['totalMessages']) && Config::$modSettings['totalMessages'] > 75000; |
301 | 332 | |
302 | 333 | // Have we got tracking data - if so use it (It will be clean!) |
303 | -if (isset($_GET['data'])) { |
|
334 | +if (isset($_GET['data'])) |
|
335 | +{ |
|
304 | 336 | global $is_debug; |
305 | 337 | |
306 | 338 | $upcontext['upgrade_status'] = json_decode(base64_decode($_GET['data']), true); |
@@ -310,12 +342,14 @@ discard block |
||
310 | 342 | $support_js = $upcontext['upgrade_status']['js']; |
311 | 343 | |
312 | 344 | // Only set this if the upgrader status says so. |
313 | - if (empty($is_debug)) { |
|
345 | + if (empty($is_debug)) |
|
346 | + { |
|
314 | 347 | $is_debug = $upcontext['upgrade_status']['debug']; |
315 | 348 | } |
316 | 349 | } |
317 | 350 | // Set the defaults. |
318 | -else { |
|
351 | +else |
|
352 | +{ |
|
319 | 353 | $upcontext['current_step'] = 0; |
320 | 354 | $upcontext['rid'] = mt_rand(0, 5000); |
321 | 355 | $upcontext['upgrade_status'] = [ |
@@ -336,41 +370,49 @@ discard block |
||
336 | 370 | $upcontext['page_title'] = Lang::$txt['updating_smf_installation']; |
337 | 371 | |
338 | 372 | // If this isn't the first stage see whether they are logging in and resuming. |
339 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
373 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
374 | +{ |
|
340 | 375 | checkLogin(); |
341 | 376 | } |
342 | 377 | |
343 | -if ($command_line) { |
|
378 | +if ($command_line) |
|
379 | +{ |
|
344 | 380 | cmdStep0(); |
345 | 381 | } |
346 | 382 | |
347 | 383 | // Don't error if we're using xml. |
348 | -if (isset($_GET['xml'])) { |
|
384 | +if (isset($_GET['xml'])) |
|
385 | +{ |
|
349 | 386 | $upcontext['return_error'] = true; |
350 | 387 | } |
351 | 388 | |
352 | 389 | // Loop through all the steps doing each one as required. |
353 | 390 | $upcontext['overall_percent'] = 0; |
354 | 391 | |
355 | -foreach ($upcontext['steps'] as $num => $step) { |
|
356 | - if ($num >= $upcontext['current_step']) { |
|
392 | +foreach ($upcontext['steps'] as $num => $step) |
|
393 | +{ |
|
394 | + if ($num >= $upcontext['current_step']) |
|
395 | + { |
|
357 | 396 | // The current weight of this step in terms of overall progress. |
358 | 397 | $upcontext['step_weight'] = $step[3]; |
359 | 398 | // Make sure we reset the skip button. |
360 | 399 | $upcontext['skip'] = false; |
361 | 400 | |
362 | 401 | // We cannot proceed if we're not logged in. |
363 | - if ($num != 0 && !$disable_security && $upcontext['user']['pass'] != $upcontext['upgrade_status']['pass']) { |
|
402 | + if ($num != 0 && !$disable_security && $upcontext['user']['pass'] != $upcontext['upgrade_status']['pass']) |
|
403 | + { |
|
364 | 404 | $upcontext['steps'][0][2](); |
365 | 405 | break; |
366 | 406 | } |
367 | 407 | |
368 | 408 | // Call the step and if it returns false that means pause! |
369 | - if (function_exists($step[2]) && $step[2]() === false) { |
|
409 | + if (function_exists($step[2]) && $step[2]() === false) |
|
410 | + { |
|
370 | 411 | break; |
371 | 412 | } |
372 | 413 | |
373 | - if (function_exists($step[2])) { |
|
414 | + if (function_exists($step[2])) |
|
415 | + { |
|
374 | 416 | //Start each new step with this unset, so the 'normal' template is called first |
375 | 417 | unset($_GET['xml'], $upcontext['custom_warning']); |
376 | 418 | //Clear out warnings at the start of each step |
@@ -390,7 +432,8 @@ discard block |
||
390 | 432 | global $upcontext, $upgradeurl, $command_line, $is_debug; |
391 | 433 | |
392 | 434 | // Save where we are... |
393 | - if (!empty($upcontext['current_step']) && !empty($upcontext['user']['id'])) { |
|
435 | + if (!empty($upcontext['current_step']) && !empty($upcontext['user']['id'])) |
|
436 | + { |
|
394 | 437 | $upcontext['user']['step'] = $upcontext['current_step']; |
395 | 438 | $upcontext['user']['substep'] = $_GET['substep']; |
396 | 439 | $upcontext['user']['updated'] = time(); |
@@ -402,17 +445,21 @@ discard block |
||
402 | 445 | } |
403 | 446 | |
404 | 447 | // Handle the progress of the step, if any. |
405 | - if (!empty($upcontext['step_progress']) && isset($upcontext['steps'][$upcontext['current_step']])) { |
|
448 | + if (!empty($upcontext['step_progress']) && isset($upcontext['steps'][$upcontext['current_step']])) |
|
449 | + { |
|
406 | 450 | $upcontext['step_progress'] = round($upcontext['step_progress'], 1); |
407 | 451 | $upcontext['overall_percent'] += $upcontext['step_progress'] * ($upcontext['steps'][$upcontext['current_step']][3] / 100); |
408 | 452 | } |
409 | 453 | $upcontext['overall_percent'] = (int) $upcontext['overall_percent']; |
410 | 454 | |
411 | 455 | // We usually dump our templates out. |
412 | - if (!$fallThrough) { |
|
456 | + if (!$fallThrough) |
|
457 | + { |
|
413 | 458 | // This should not happen my dear... HELP ME DEVELOPERS!! |
414 | - if (!empty($command_line)) { |
|
415 | - if (function_exists('debug_print_backtrace')) { |
|
459 | + if (!empty($command_line)) |
|
460 | + { |
|
461 | + if (function_exists('debug_print_backtrace')) |
|
462 | + { |
|
416 | 463 | debug_print_backtrace(); |
417 | 464 | } |
418 | 465 | |
@@ -422,15 +469,20 @@ discard block |
||
422 | 469 | die(); |
423 | 470 | } |
424 | 471 | |
425 | - if (!isset($_GET['xml'])) { |
|
472 | + if (!isset($_GET['xml'])) |
|
473 | + { |
|
426 | 474 | template_upgrade_above(); |
427 | - } else { |
|
475 | + } |
|
476 | + else |
|
477 | + { |
|
428 | 478 | header('content-type: text/xml; charset=UTF-8'); |
429 | 479 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
430 | 480 | $upcontext['get_data'] = []; |
431 | 481 | |
432 | - foreach ($_GET as $k => $v) { |
|
433 | - if (substr($k, 0, 3) != 'amp' && !in_array($k, ['xml', 'substep', 'lang', 'data', 'step', 'filecount'])) { |
|
482 | + foreach ($_GET as $k => $v) |
|
483 | + { |
|
484 | + if (substr($k, 0, 3) != 'amp' && !in_array($k, ['xml', 'substep', 'lang', 'data', 'step', 'filecount'])) |
|
485 | + { |
|
434 | 486 | $upcontext['get_data'][$k] = $v; |
435 | 487 | } |
436 | 488 | } |
@@ -438,48 +490,63 @@ discard block |
||
438 | 490 | } |
439 | 491 | |
440 | 492 | // Call the template. |
441 | - if (isset($upcontext['sub_template'])) { |
|
493 | + if (isset($upcontext['sub_template'])) |
|
494 | + { |
|
442 | 495 | $upcontext['upgrade_status']['curstep'] = $upcontext['current_step']; |
443 | 496 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
444 | 497 | |
445 | 498 | // Custom stuff to pass back? |
446 | - if (!empty($upcontext['query_string'])) { |
|
499 | + if (!empty($upcontext['query_string'])) |
|
500 | + { |
|
447 | 501 | $upcontext['form_url'] .= $upcontext['query_string']; |
448 | 502 | } |
449 | 503 | |
450 | 504 | // Call the appropriate subtemplate |
451 | - if (is_callable('template_' . $upcontext['sub_template'])) { |
|
505 | + if (is_callable('template_' . $upcontext['sub_template'])) |
|
506 | + { |
|
452 | 507 | call_user_func('template_' . $upcontext['sub_template']); |
453 | - } else { |
|
508 | + } |
|
509 | + else |
|
510 | + { |
|
454 | 511 | die(sprintf(Lang::$txt['error_invalid_template'], $upcontext['sub_template'])); |
455 | 512 | } |
456 | 513 | } |
457 | 514 | |
458 | 515 | // Was there an error? |
459 | - if (!empty($upcontext['forced_error_message'])) { |
|
516 | + if (!empty($upcontext['forced_error_message'])) |
|
517 | + { |
|
460 | 518 | echo $upcontext['forced_error_message']; |
461 | 519 | } |
462 | 520 | |
463 | 521 | // Show the footer. |
464 | - if (!isset($_GET['xml'])) { |
|
522 | + if (!isset($_GET['xml'])) |
|
523 | + { |
|
465 | 524 | template_upgrade_below(); |
466 | - } else { |
|
525 | + } |
|
526 | + else |
|
527 | + { |
|
467 | 528 | template_xml_below(); |
468 | 529 | } |
469 | 530 | } |
470 | 531 | |
471 | 532 | // Show the upgrade time for CLI when we are completely done, if in debug mode. |
472 | - if (!empty($command_line) && $is_debug) { |
|
533 | + if (!empty($command_line) && $is_debug) |
|
534 | + { |
|
473 | 535 | $active = time() - $upcontext['started']; |
474 | 536 | $hours = floor($active / 3600); |
475 | 537 | $minutes = intval(($active / 60) % 60); |
476 | 538 | $seconds = intval($active % 60); |
477 | 539 | |
478 | - if ($hours > 0) { |
|
540 | + if ($hours > 0) |
|
541 | + { |
|
479 | 542 | echo "\n" . '', sprintf(Lang::$txt['upgrade_completed_time_hms'], $hours, $minutes, $seconds), '' . "\n"; |
480 | - } elseif ($minutes > 0) { |
|
543 | + } |
|
544 | + elseif ($minutes > 0) |
|
545 | + { |
|
481 | 546 | echo "\n" . '', sprintf(Lang::$txt['upgrade_completed_time_ms'], $minutes, $seconds), '' . "\n"; |
482 | - } elseif ($seconds > 0) { |
|
547 | + } |
|
548 | + elseif ($seconds > 0) |
|
549 | + { |
|
483 | 550 | echo "\n" . '', sprintf(Lang::$txt['upgrade_completed_time_s'], $seconds), '' . "\n"; |
484 | 551 | } |
485 | 552 | } |
@@ -497,11 +564,13 @@ discard block |
||
497 | 564 | $settingsFile = $upgrade_path . '/Settings.php'; |
498 | 565 | |
499 | 566 | // Check for a custom path in index.php. |
500 | - if (is_file($upgrade_path . '/index.php')) { |
|
567 | + if (is_file($upgrade_path . '/index.php')) |
|
568 | + { |
|
501 | 569 | $index_contents = file_get_contents($upgrade_path . '/index.php'); |
502 | 570 | |
503 | 571 | // The standard path. |
504 | - if (strpos($index_contents, "define('SMF_SETTINGS_FILE', __DIR__ . '/Settings.php');") !== false) { |
|
572 | + if (strpos($index_contents, "define('SMF_SETTINGS_FILE', __DIR__ . '/Settings.php');") !== false) |
|
573 | + { |
|
505 | 574 | $settingsFile = $upgrade_path . '/Settings.php'; |
506 | 575 | } |
507 | 576 | // A custom path defined in a simple string. |
@@ -515,10 +584,12 @@ discard block |
||
515 | 584 | // then the closing quotation mark. |
516 | 585 | '\\3' . |
517 | 586 | ')' . |
518 | - '\s*\)\s*;~u', $index_contents, $matches)) { |
|
587 | + '\s*\)\s*;~u', $index_contents, $matches)) |
|
588 | + { |
|
519 | 589 | $possibleSettingsFile = strtr(substr($matches[2], 1, -1), ['\\' . $matches[3] => $matches[3]]); |
520 | 590 | |
521 | - if (is_file($possibleSettingsFile)) { |
|
591 | + if (is_file($possibleSettingsFile)) |
|
592 | + { |
|
522 | 593 | $settingsFile = $possibleSettingsFile; |
523 | 594 | } |
524 | 595 | } |
@@ -539,46 +610,59 @@ discard block |
||
539 | 610 | // Do we know where to look for the language files, or shall we just guess for now? |
540 | 611 | $temp = isset(Config::$modSettings['theme_dir']) ? Config::$modSettings['theme_dir'] . '/languages' : $upgrade_path . '/Themes/default/languages'; |
541 | 612 | |
542 | - if ($lang_dir != $temp) { |
|
613 | + if ($lang_dir != $temp) |
|
614 | + { |
|
543 | 615 | $lang_dir = $temp; |
544 | 616 | $detected_languages = []; |
545 | 617 | } |
546 | 618 | |
547 | 619 | // Override the language file? |
548 | - if (isset($upcontext['language'])) { |
|
620 | + if (isset($upcontext['language'])) |
|
621 | + { |
|
549 | 622 | $_SESSION['upgrader_langfile'] = 'Install.' . $upcontext['language'] . '.php'; |
550 | - } elseif (isset($upcontext['lang'])) { |
|
623 | + } |
|
624 | + elseif (isset($upcontext['lang'])) |
|
625 | + { |
|
551 | 626 | $_SESSION['upgrader_langfile'] = 'Install.' . $upcontext['lang'] . '.php'; |
552 | - } elseif (isset(Config::$language)) { |
|
627 | + } |
|
628 | + elseif (isset(Config::$language)) |
|
629 | + { |
|
553 | 630 | $_SESSION['upgrader_langfile'] = 'Install.' . Config::$language . '.php'; |
554 | 631 | } |
555 | 632 | |
556 | 633 | // Avoid pointless repetition |
557 | - if (isset($_SESSION['upgrader_langfile']) && $loaded_langfile == $lang_dir . '/' . $_SESSION['upgrader_langfile']) { |
|
634 | + if (isset($_SESSION['upgrader_langfile']) && $loaded_langfile == $lang_dir . '/' . $_SESSION['upgrader_langfile']) |
|
635 | + { |
|
558 | 636 | return; |
559 | 637 | } |
560 | 638 | |
561 | 639 | // Now try to find the language files |
562 | - if (empty($detected_languages)) { |
|
640 | + if (empty($detected_languages)) |
|
641 | + { |
|
563 | 642 | // Make sure the languages directory actually exists. |
564 | - if (file_exists($lang_dir)) { |
|
643 | + if (file_exists($lang_dir)) |
|
644 | + { |
|
565 | 645 | // Find all the "Install" language files in the directory. |
566 | 646 | $dir = dir($lang_dir); |
567 | 647 | |
568 | - while ($entry = $dir->read()) { |
|
648 | + while ($entry = $dir->read()) |
|
649 | + { |
|
569 | 650 | // Skip any old '-utf8' language files that might be lying around |
570 | - if (strpos($entry, '-utf8') !== false) { |
|
651 | + if (strpos($entry, '-utf8') !== false) |
|
652 | + { |
|
571 | 653 | continue; |
572 | 654 | } |
573 | 655 | |
574 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
656 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
657 | + { |
|
575 | 658 | $detected_languages[$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
576 | 659 | } |
577 | 660 | } |
578 | 661 | $dir->close(); |
579 | 662 | } |
580 | 663 | // Our guess was wrong, but that's fine. We'll try again after Config::$modSettings['theme_dir'] is defined. |
581 | - elseif (!isset(Config::$modSettings['theme_dir'])) { |
|
664 | + elseif (!isset(Config::$modSettings['theme_dir'])) |
|
665 | + { |
|
582 | 666 | // Define a few essential strings for now. |
583 | 667 | Lang::$txt['error_db_connect_settings'] = 'Cannot connect to the database server.<br><br>Please check that the database info variables are correct in Settings.php.'; |
584 | 668 | Lang::$txt['error_sourcefile_missing'] = 'Unable to find the Sources/%1$s file. Please make sure it was uploaded properly, and then try again.'; |
@@ -591,18 +675,24 @@ discard block |
||
591 | 675 | } |
592 | 676 | |
593 | 677 | // Didn't find any, show an error message! |
594 | - if (empty($detected_languages)) { |
|
678 | + if (empty($detected_languages)) |
|
679 | + { |
|
595 | 680 | $from = explode('/', $command_line ? $upgrade_path : $_SERVER['PHP_SELF']); |
596 | 681 | $to = explode('/', $lang_dir); |
597 | 682 | $relPath = $to; |
598 | 683 | |
599 | - foreach($from as $depth => $dir) { |
|
600 | - if ($dir === $to[$depth]) { |
|
684 | + foreach($from as $depth => $dir) |
|
685 | + { |
|
686 | + if ($dir === $to[$depth]) |
|
687 | + { |
|
601 | 688 | array_shift($relPath); |
602 | - } else { |
|
689 | + } |
|
690 | + else |
|
691 | + { |
|
603 | 692 | $remaining = count($from) - $depth; |
604 | 693 | |
605 | - if ($remaining > 1) { |
|
694 | + if ($remaining > 1) |
|
695 | + { |
|
606 | 696 | $padLength = (count($relPath) + $remaining - 1) * -1; |
607 | 697 | $relPath = array_pad($relPath, $padLength, '..'); |
608 | 698 | break; |
@@ -614,7 +704,8 @@ discard block |
||
614 | 704 | $relPath = implode(DIRECTORY_SEPARATOR, $relPath); |
615 | 705 | |
616 | 706 | // Command line? |
617 | - if ($command_line) { |
|
707 | + if ($command_line) |
|
708 | + { |
|
618 | 709 | echo 'This upgrader was unable to find the upgrader\'s language file or files. They should be found under:', "\n", |
619 | 710 | $relPath, "\n", |
620 | 711 | 'In some cases, FTP clients do not properly upload files with this many folders. Please double check to make sure you have uploaded all the files in the distribution', "\n", |
@@ -660,12 +751,14 @@ discard block |
||
660 | 751 | } |
661 | 752 | |
662 | 753 | // Make sure it exists. If it doesn't, reset it. |
663 | - if (!isset($_SESSION['upgrader_langfile']) || preg_match('~[^\w.-]~', $_SESSION['upgrader_langfile']) === 1 || !file_exists($lang_dir . '/' . $_SESSION['upgrader_langfile'])) { |
|
754 | + if (!isset($_SESSION['upgrader_langfile']) || preg_match('~[^\w.-]~', $_SESSION['upgrader_langfile']) === 1 || !file_exists($lang_dir . '/' . $_SESSION['upgrader_langfile'])) |
|
755 | + { |
|
664 | 756 | // Use the first one... |
665 | 757 | list($_SESSION['upgrader_langfile']) = array_keys($detected_languages); |
666 | 758 | |
667 | 759 | // If we have English and some other language, use the other language. |
668 | - if ($_SESSION['upgrader_langfile'] == 'Install.english.php' && count($detected_languages) > 1) { |
|
760 | + if ($_SESSION['upgrader_langfile'] == 'Install.english.php' && count($detected_languages) > 1) |
|
761 | + { |
|
669 | 762 | list(, $_SESSION['upgrader_langfile']) = array_keys($detected_languages); |
670 | 763 | } |
671 | 764 | } |
@@ -686,17 +779,20 @@ discard block |
||
686 | 779 | global $upgradeurl, $upcontext, $command_line; |
687 | 780 | |
688 | 781 | // Command line users can't be redirected. |
689 | - if ($command_line) { |
|
782 | + if ($command_line) |
|
783 | + { |
|
690 | 784 | upgradeExit(true); |
691 | 785 | } |
692 | 786 | |
693 | 787 | // Are we providing the core info? |
694 | - if ($addForm) { |
|
788 | + if ($addForm) |
|
789 | + { |
|
695 | 790 | $upcontext['upgrade_status']['curstep'] = $upcontext['current_step']; |
696 | 791 | $location = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])) . $location; |
697 | 792 | } |
698 | 793 | |
699 | - while (@ob_end_clean()) { |
|
794 | + while (@ob_end_clean()) |
|
795 | + { |
|
700 | 796 | header('location: ' . strtr($location, ['&' => '&'])); |
701 | 797 | } |
702 | 798 | |
@@ -710,11 +806,13 @@ discard block |
||
710 | 806 | global $utf8; |
711 | 807 | |
712 | 808 | // Report all errors if admin wants them or this is a pre-release version. |
713 | - if (!empty(Config::$db_show_debug) || strspn(SMF_VERSION, '1234567890.') !== strlen(SMF_VERSION)) { |
|
809 | + if (!empty(Config::$db_show_debug) || strspn(SMF_VERSION, '1234567890.') !== strlen(SMF_VERSION)) |
|
810 | + { |
|
714 | 811 | error_reporting(E_ALL); |
715 | 812 | } |
716 | 813 | // Otherwise, report all errors except for deprecation notices. |
717 | - else { |
|
814 | + else |
|
815 | + { |
|
718 | 816 | error_reporting(E_ALL & ~E_DEPRECATED); |
719 | 817 | } |
720 | 818 | |
@@ -724,7 +822,8 @@ discard block |
||
724 | 822 | header('X-Content-Type-Options: nosniff'); |
725 | 823 | |
726 | 824 | // Start the session. |
727 | - if (@ini_get('session.save_handler') == 'user') { |
|
825 | + if (@ini_get('session.save_handler') == 'user') |
|
826 | + { |
|
728 | 827 | @ini_set('session.save_handler', 'files'); |
729 | 828 | } |
730 | 829 | @session_start(); |
@@ -739,7 +838,8 @@ discard block |
||
739 | 838 | $utf8 = (empty(Config::$modSettings['global_character_set']) ? Lang::$txt['lang_character_set'] : Config::$modSettings['global_character_set']) === 'UTF-8'; |
740 | 839 | |
741 | 840 | // Get the database going! |
742 | - if (empty(Config::$db_type) || Config::$db_type == 'mysqli') { |
|
841 | + if (empty(Config::$db_type) || Config::$db_type == 'mysqli') |
|
842 | + { |
|
743 | 843 | Config::$db_type = 'mysql'; |
744 | 844 | // If overriding Config::$db_type, need to set its settings.php entry too |
745 | 845 | $changes = []; |
@@ -749,26 +849,33 @@ discard block |
||
749 | 849 | |
750 | 850 | require_once Config::$sourcedir . '/Autoloader.php'; |
751 | 851 | |
752 | - if (class_exists('SMF\\Db\\APIs\\' . Db::getClass(Config::$db_type))) { |
|
852 | + if (class_exists('SMF\\Db\\APIs\\' . Db::getClass(Config::$db_type))) |
|
853 | + { |
|
753 | 854 | // Make the connection... |
754 | - if (empty(Db::$db_connection)) { |
|
855 | + if (empty(Db::$db_connection)) |
|
856 | + { |
|
755 | 857 | Db::load(['non_fatal' => true]); |
756 | - } else { |
|
858 | + } |
|
859 | + else |
|
860 | + { |
|
757 | 861 | // If we've returned here, ping/reconnect to be safe |
758 | 862 | Db::$db->ping(Db::$db_connection); |
759 | 863 | } |
760 | 864 | |
761 | 865 | // Oh dear god!! |
762 | - if (Db::$db_connection === null) { |
|
866 | + if (Db::$db_connection === null) |
|
867 | + { |
|
763 | 868 | // Get error info... Recast just in case we get false or 0... |
764 | 869 | $error_message = Db::$db->connect_error(); |
765 | 870 | |
766 | - if (empty($error_message)) { |
|
871 | + if (empty($error_message)) |
|
872 | + { |
|
767 | 873 | $error_message = ''; |
768 | 874 | } |
769 | 875 | $error_number = Db::$db->connect_errno(); |
770 | 876 | |
771 | - if (empty($error_number)) { |
|
877 | + if (empty($error_number)) |
|
878 | + { |
|
772 | 879 | $error_number = ''; |
773 | 880 | } |
774 | 881 | $db_error = (!empty($error_number) ? $error_number . ': ' : '') . $error_message; |
@@ -776,7 +883,8 @@ discard block |
||
776 | 883 | die(Lang::$txt['error_db_connect_settings'] . '<br><br>' . $db_error); |
777 | 884 | } |
778 | 885 | |
779 | - if (Config::$db_type == 'mysql' && isset(Config::$db_character_set) && preg_match('~^\w+$~', Config::$db_character_set) === 1) { |
|
886 | + if (Config::$db_type == 'mysql' && isset(Config::$db_character_set) && preg_match('~^\w+$~', Config::$db_character_set) === 1) |
|
887 | + { |
|
780 | 888 | Db::$db->query( |
781 | 889 | '', |
782 | 890 | 'SET NAMES {string:db_character_set}', |
@@ -798,20 +906,25 @@ discard block |
||
798 | 906 | ); |
799 | 907 | Config::$modSettings = []; |
800 | 908 | |
801 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
909 | + while ($row = Db::$db->fetch_assoc($request)) |
|
910 | + { |
|
802 | 911 | Config::$modSettings[$row['variable']] = $row['value']; |
803 | 912 | } |
804 | 913 | Db::$db->free_result($request); |
805 | - } else { |
|
914 | + } |
|
915 | + else |
|
916 | + { |
|
806 | 917 | return die(sprintf(Lang::$txt['error_sourcefile_missing'], 'Db/APIs/' . Db::getClass(Config::$db_type) . '.php')); |
807 | 918 | } |
808 | 919 | |
809 | 920 | // If they don't have the file, they're going to get a warning anyway so we won't need to clean request vars. |
810 | - if (class_exists('SMF\\QueryString') && php_version_check()) { |
|
921 | + if (class_exists('SMF\\QueryString') && php_version_check()) |
|
922 | + { |
|
811 | 923 | QueryString::cleanRequest(); |
812 | 924 | } |
813 | 925 | |
814 | - if (!isset($_GET['substep'])) { |
|
926 | + if (!isset($_GET['substep'])) |
|
927 | + { |
|
815 | 928 | $_GET['substep'] = 0; |
816 | 929 | } |
817 | 930 | } |
@@ -830,7 +943,8 @@ discard block |
||
830 | 943 | ignore_user_abort(true); |
831 | 944 | |
832 | 945 | // This is really quite simple; if ?delete is on the URL, delete the upgrader... |
833 | - if (isset($_GET['delete'])) { |
|
946 | + if (isset($_GET['delete'])) |
|
947 | + { |
|
834 | 948 | deleteFile(__FILE__); |
835 | 949 | |
836 | 950 | // And the extra little files ;). |
@@ -843,8 +957,10 @@ discard block |
||
843 | 957 | |
844 | 958 | $dh = opendir(dirname(__FILE__)); |
845 | 959 | |
846 | - while ($file = readdir($dh)) { |
|
847 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
960 | + while ($file = readdir($dh)) |
|
961 | + { |
|
962 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
963 | + { |
|
848 | 964 | deleteFile(dirname(__FILE__) . '/' . $file); |
849 | 965 | } |
850 | 966 | } |
@@ -875,8 +991,10 @@ discard block |
||
875 | 991 | // Something is causing this to happen, and it's annoying. Stop it. |
876 | 992 | $temp = 'upgrade_php?step'; |
877 | 993 | |
878 | - while (strlen($temp) > 4) { |
|
879 | - if (isset($_GET[$temp])) { |
|
994 | + while (strlen($temp) > 4) |
|
995 | + { |
|
996 | + if (isset($_GET[$temp])) |
|
997 | + { |
|
880 | 998 | unset($_GET[$temp]); |
881 | 999 | } |
882 | 1000 | $temp = substr($temp, 1); |
@@ -902,36 +1020,43 @@ discard block |
||
902 | 1020 | && @file_exists(dirname(__FILE__) . '/upgrade_3-0_' . Db::getClass(Config::$db_type) . '.sql'); |
903 | 1021 | |
904 | 1022 | // Need legacy scripts? |
905 | - if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < 3.0) { |
|
1023 | + if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < 3.0) |
|
1024 | + { |
|
906 | 1025 | $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . Db::getClass(Config::$db_type) . '.sql'); |
907 | 1026 | } |
908 | 1027 | |
909 | - if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < 2.1) { |
|
1028 | + if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < 2.1) |
|
1029 | + { |
|
910 | 1030 | $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . Db::getClass(Config::$db_type) . '.sql'); |
911 | 1031 | } |
912 | 1032 | |
913 | - if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < 2.0) { |
|
1033 | + if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < 2.0) |
|
1034 | + { |
|
914 | 1035 | $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
915 | 1036 | } |
916 | 1037 | |
917 | - if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < 1.1) { |
|
1038 | + if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < 1.1) |
|
1039 | + { |
|
918 | 1040 | $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
919 | 1041 | } |
920 | 1042 | |
921 | 1043 | // We don't need "-utf8" files anymore... |
922 | 1044 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
923 | 1045 | |
924 | - if (!$check) { |
|
1046 | + if (!$check) |
|
1047 | + { |
|
925 | 1048 | // 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. |
926 | 1049 | return throw_error(Lang::$txt['error_upgrade_files_missing']); |
927 | 1050 | } |
928 | 1051 | |
929 | 1052 | // Do they meet the install requirements? |
930 | - if (!php_version_check()) { |
|
1053 | + if (!php_version_check()) |
|
1054 | + { |
|
931 | 1055 | return throw_error(Lang::$txt['error_php_too_low']); |
932 | 1056 | } |
933 | 1057 | |
934 | - if (!db_version_check()) { |
|
1058 | + if (!db_version_check()) |
|
1059 | + { |
|
935 | 1060 | return throw_error(sprintf(Lang::$txt['error_db_too_low'], $databases[Config::$db_type]['name'])); |
936 | 1061 | } |
937 | 1062 | |
@@ -945,7 +1070,8 @@ discard block |
||
945 | 1070 | $drop = Db::$db->drop_table('{db_prefix}priv_check'); |
946 | 1071 | |
947 | 1072 | // Sorry... we need CREATE, ALTER and DROP |
948 | - if (!$create || !$alter || !$drop) { |
|
1073 | + if (!$create || !$alter || !$drop) |
|
1074 | + { |
|
949 | 1075 | return throw_error(sprintf(Lang::$txt['error_db_privileges'], $databases[Config::$db_type]['name'])); |
950 | 1076 | } |
951 | 1077 | |
@@ -953,7 +1079,8 @@ discard block |
||
953 | 1079 | $temp = substr(@implode('', @file(Config::$boarddir . '/index.php')), 0, 4096); |
954 | 1080 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
955 | 1081 | |
956 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
1082 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
1083 | + { |
|
957 | 1084 | return throw_error(Lang::$txt['error_upgrade_old_files']); |
958 | 1085 | } |
959 | 1086 | |
@@ -964,7 +1091,8 @@ discard block |
||
964 | 1091 | ]; |
965 | 1092 | |
966 | 1093 | // Only check for minified writable files if we have it enabled or not set. |
967 | - if (!empty(Config::$modSettings['minimize_files']) || !isset(Config::$modSettings['minimize_files'])) { |
|
1094 | + if (!empty(Config::$modSettings['minimize_files']) || !isset(Config::$modSettings['minimize_files'])) |
|
1095 | + { |
|
968 | 1096 | $writable_files += [ |
969 | 1097 | Config::$modSettings['theme_dir'] . '/css/minified.css', |
970 | 1098 | Config::$modSettings['theme_dir'] . '/scripts/minified.js', |
@@ -982,12 +1110,15 @@ discard block |
||
982 | 1110 | quickFileWritable($custom_av_dir); |
983 | 1111 | |
984 | 1112 | // Are we good now? |
985 | - if (!is_writable($custom_av_dir)) { |
|
1113 | + if (!is_writable($custom_av_dir)) |
|
1114 | + { |
|
986 | 1115 | return throw_error(sprintf(Lang::$txt['error_dir_not_writable'], $custom_av_dir)); |
987 | 1116 | } |
988 | 1117 | |
989 | - if ($need_settings_update) { |
|
990 | - if (!function_exists('cache_put_data')) { |
|
1118 | + if ($need_settings_update) |
|
1119 | + { |
|
1120 | + if (!function_exists('cache_put_data')) |
|
1121 | + { |
|
991 | 1122 | require_once Config::$sourcedir . '/Cache/CacheApi.php'; |
992 | 1123 | } |
993 | 1124 | |
@@ -998,47 +1129,56 @@ discard block |
||
998 | 1129 | // Check the cache directory. |
999 | 1130 | $cachedir_temp = empty(Config::$cachedir) ? Config::$boarddir . '/cache' : Config::$cachedir; |
1000 | 1131 | |
1001 | - if (!file_exists($cachedir_temp)) { |
|
1132 | + if (!file_exists($cachedir_temp)) |
|
1133 | + { |
|
1002 | 1134 | @mkdir($cachedir_temp); |
1003 | 1135 | } |
1004 | 1136 | |
1005 | - if (!file_exists($cachedir_temp)) { |
|
1137 | + if (!file_exists($cachedir_temp)) |
|
1138 | + { |
|
1006 | 1139 | return throw_error(Lang::$txt['error_cache_not_found']); |
1007 | 1140 | } |
1008 | 1141 | |
1009 | 1142 | quickFileWritable($cachedir_temp . '/db_last_error.php'); |
1010 | 1143 | |
1011 | - if (!file_exists(Config::$modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')) { |
|
1144 | + if (!file_exists(Config::$modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')) |
|
1145 | + { |
|
1012 | 1146 | return throw_error(sprintf(Lang::$txt['error_lang_index_missing'], $upcontext['language'], $upgradeurl)); |
1013 | 1147 | } |
1014 | 1148 | |
1015 | - if (!isset($_GET['skiplang'])) { |
|
1149 | + if (!isset($_GET['skiplang'])) |
|
1150 | + { |
|
1016 | 1151 | $temp = substr(@implode('', @file(Config::$modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
1017 | 1152 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
1018 | 1153 | |
1019 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
1154 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
1155 | + { |
|
1020 | 1156 | return throw_error(sprintf(Lang::$txt['error_upgrade_old_lang_files'], $upcontext['language'], $upgradeurl)); |
1021 | 1157 | } |
1022 | 1158 | } |
1023 | 1159 | |
1024 | - if (!makeFilesWritable($writable_files)) { |
|
1160 | + if (!makeFilesWritable($writable_files)) |
|
1161 | + { |
|
1025 | 1162 | return false; |
1026 | 1163 | } |
1027 | 1164 | |
1028 | 1165 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
1029 | - if (isset(Config::$modSettings['agreement']) && (!is_writable(Config::$boarddir) || file_exists(Config::$boarddir . '/agreement.txt')) && !is_writable(Config::$boarddir . '/agreement.txt')) { |
|
1166 | + if (isset(Config::$modSettings['agreement']) && (!is_writable(Config::$boarddir) || file_exists(Config::$boarddir . '/agreement.txt')) && !is_writable(Config::$boarddir . '/agreement.txt')) |
|
1167 | + { |
|
1030 | 1168 | return throw_error(Lang::$txt['error_agreement_not_writable']); |
1031 | 1169 | } |
1032 | 1170 | |
1033 | 1171 | // Upgrade the agreement. |
1034 | - if (isset(Config::$modSettings['agreement'])) { |
|
1172 | + if (isset(Config::$modSettings['agreement'])) |
|
1173 | + { |
|
1035 | 1174 | $fp = fopen(Config::$boarddir . '/agreement.txt', 'w'); |
1036 | 1175 | fwrite($fp, Config::$modSettings['agreement']); |
1037 | 1176 | fclose($fp); |
1038 | 1177 | } |
1039 | 1178 | |
1040 | 1179 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
1041 | - if (strtr(Config::$boarddir, ['/' => '', '\\' => '']) != strtr($upgrade_path, ['/' => '', '\\' => ''])) { |
|
1180 | + if (strtr(Config::$boarddir, ['/' => '', '\\' => '']) != strtr($upgrade_path, ['/' => '', '\\' => ''])) |
|
1181 | + { |
|
1042 | 1182 | $upcontext['warning'] = ' |
1043 | 1183 | ' . sprintf(Lang::$txt['upgrade_forumdir_settings'], Config::$boarddir, $upgrade_path) . '<br> |
1044 | 1184 | <ul> |
@@ -1050,19 +1190,22 @@ discard block |
||
1050 | 1190 | } |
1051 | 1191 | |
1052 | 1192 | // Confirm mbstring is loaded... |
1053 | - if (!extension_loaded('mbstring')) { |
|
1193 | + if (!extension_loaded('mbstring')) |
|
1194 | + { |
|
1054 | 1195 | return throw_error(Lang::$txt['install_no_mbstring']); |
1055 | 1196 | } |
1056 | 1197 | |
1057 | 1198 | // Confirm fileinfo is loaded... |
1058 | - if (!extension_loaded('fileinfo')) { |
|
1199 | + if (!extension_loaded('fileinfo')) |
|
1200 | + { |
|
1059 | 1201 | return throw_error(Lang::$txt['install_no_fileinfo']); |
1060 | 1202 | } |
1061 | 1203 | |
1062 | 1204 | // Check for https stream support. |
1063 | 1205 | $supported_streams = stream_get_wrappers(); |
1064 | 1206 | |
1065 | - if (!in_array('https', $supported_streams)) { |
|
1207 | + if (!in_array('https', $supported_streams)) |
|
1208 | + { |
|
1066 | 1209 | $upcontext['custom_warning'] = Lang::$txt['install_no_https']; |
1067 | 1210 | } |
1068 | 1211 | |
@@ -1070,7 +1213,8 @@ discard block |
||
1070 | 1213 | checkFolders(); |
1071 | 1214 | |
1072 | 1215 | // Either we're logged in or we're going to present the login. |
1073 | - if (checkLogin()) { |
|
1216 | + if (checkLogin()) |
|
1217 | + { |
|
1074 | 1218 | return true; |
1075 | 1219 | } |
1076 | 1220 | |
@@ -1089,15 +1233,20 @@ discard block |
||
1089 | 1233 | |
1090 | 1234 | // First, check the avatar directory... |
1091 | 1235 | // Note it wasn't specified in yabbse, but there was no smfVersion either. |
1092 | - if (!empty(Config::$modSettings['smfVersion']) && !is_dir(Config::$modSettings['avatar_directory'])) { |
|
1236 | + if (!empty(Config::$modSettings['smfVersion']) && !is_dir(Config::$modSettings['avatar_directory'])) |
|
1237 | + { |
|
1093 | 1238 | $warnings .= Lang::$txt['warning_av_missing']; |
1094 | 1239 | } |
1095 | 1240 | |
1096 | 1241 | // Next, check the custom avatar directory... Note this is optional in 2.0. |
1097 | - if (!empty(Config::$modSettings['custom_avatar_dir']) && !is_dir(Config::$modSettings['custom_avatar_dir'])) { |
|
1098 | - if (empty($warnings)) { |
|
1242 | + if (!empty(Config::$modSettings['custom_avatar_dir']) && !is_dir(Config::$modSettings['custom_avatar_dir'])) |
|
1243 | + { |
|
1244 | + if (empty($warnings)) |
|
1245 | + { |
|
1099 | 1246 | $warnings = Lang::$txt['warning_custom_av_missing']; |
1100 | - } else { |
|
1247 | + } |
|
1248 | + else |
|
1249 | + { |
|
1101 | 1250 | $warnings .= '<br><br>' . Lang::$txt['warning_custom_av_missing']; |
1102 | 1251 | } |
1103 | 1252 | } |
@@ -1107,21 +1256,30 @@ discard block |
||
1107 | 1256 | |
1108 | 1257 | // PHP currently has a terrible handling with unserialize in which errors are fatal and not catchable. Lets borrow some code from the RFC that intends to fix this |
1109 | 1258 | // https://wiki.php.net/rfc/improve_unserialize_error_handling |
1110 | - try { |
|
1111 | - set_error_handler(static function ($severity, $message, $file, $line) { |
|
1259 | + try |
|
1260 | + { |
|
1261 | + set_error_handler(static function ($severity, $message, $file, $line) |
|
1262 | + { |
|
1112 | 1263 | throw new \ErrorException($message, 0, $severity, $file, $line); |
1113 | 1264 | }); |
1114 | 1265 | $ser_test = @unserialize(Config::$modSettings['attachmentUploadDir']); |
1115 | - } catch (\Throwable $e) { |
|
1266 | + } |
|
1267 | + catch (\Throwable $e) |
|
1268 | + { |
|
1116 | 1269 | $ser_test = false; |
1117 | - } finally { |
|
1270 | + } |
|
1271 | + finally |
|
1272 | + { |
|
1118 | 1273 | restore_error_handler(); |
1119 | 1274 | } |
1120 | 1275 | |
1121 | 1276 | // Json is simple, it can be caught. |
1122 | - try { |
|
1277 | + try |
|
1278 | + { |
|
1123 | 1279 | $json_test = @json_decode(Config::$modSettings['attachmentUploadDir'], true); |
1124 | - } catch (\Throwable $e) { |
|
1280 | + } |
|
1281 | + catch (\Throwable $e) |
|
1282 | + { |
|
1125 | 1283 | $json_test = null; |
1126 | 1284 | } |
1127 | 1285 | |
@@ -1130,71 +1288,102 @@ discard block |
||
1130 | 1288 | // String? |
1131 | 1289 | $attdr_problem_found = false; |
1132 | 1290 | |
1133 | - if ($string_test === true) { |
|
1291 | + if ($string_test === true) |
|
1292 | + { |
|
1134 | 1293 | // OK... |
1135 | 1294 | } |
1136 | 1295 | // An array already? |
1137 | - elseif (is_array(Config::$modSettings['attachmentUploadDir'])) { |
|
1138 | - foreach(Config::$modSettings['attachmentUploadDir'] as $dir) { |
|
1139 | - if (!empty($dir) && !is_dir($dir)) { |
|
1296 | + elseif (is_array(Config::$modSettings['attachmentUploadDir'])) |
|
1297 | + { |
|
1298 | + foreach(Config::$modSettings['attachmentUploadDir'] as $dir) |
|
1299 | + { |
|
1300 | + if (!empty($dir) && !is_dir($dir)) |
|
1301 | + { |
|
1140 | 1302 | $attdr_problem_found = true; |
1141 | 1303 | } |
1142 | 1304 | } |
1143 | 1305 | } |
1144 | 1306 | // Serialized? |
1145 | - elseif ($ser_test !== false) { |
|
1146 | - if (is_array($ser_test)) { |
|
1147 | - foreach($ser_test as $dir) { |
|
1148 | - if (!empty($dir) && !is_dir($dir)) { |
|
1307 | + elseif ($ser_test !== false) |
|
1308 | + { |
|
1309 | + if (is_array($ser_test)) |
|
1310 | + { |
|
1311 | + foreach($ser_test as $dir) |
|
1312 | + { |
|
1313 | + if (!empty($dir) && !is_dir($dir)) |
|
1314 | + { |
|
1149 | 1315 | $attdr_problem_found = true; |
1150 | 1316 | } |
1151 | 1317 | } |
1152 | - } else { |
|
1153 | - if (!empty($ser_test) && !is_dir($ser_test)) { |
|
1318 | + } |
|
1319 | + else |
|
1320 | + { |
|
1321 | + if (!empty($ser_test) && !is_dir($ser_test)) |
|
1322 | + { |
|
1154 | 1323 | $attdr_problem_found = true; |
1155 | 1324 | } |
1156 | 1325 | } |
1157 | 1326 | } |
1158 | 1327 | // Json? Note the test returns null if encoding was unsuccessful |
1159 | - elseif ($json_test !== null) { |
|
1160 | - if (is_array($json_test)) { |
|
1161 | - foreach($json_test as $dir) { |
|
1162 | - if (!is_dir($dir)) { |
|
1328 | + elseif ($json_test !== null) |
|
1329 | + { |
|
1330 | + if (is_array($json_test)) |
|
1331 | + { |
|
1332 | + foreach($json_test as $dir) |
|
1333 | + { |
|
1334 | + if (!is_dir($dir)) |
|
1335 | + { |
|
1163 | 1336 | $attdr_problem_found = true; |
1164 | 1337 | } |
1165 | 1338 | } |
1166 | - } else { |
|
1167 | - if (!is_dir($json_test)) { |
|
1339 | + } |
|
1340 | + else |
|
1341 | + { |
|
1342 | + if (!is_dir($json_test)) |
|
1343 | + { |
|
1168 | 1344 | $attdr_problem_found = true; |
1169 | 1345 | } |
1170 | 1346 | } |
1171 | 1347 | } |
1172 | 1348 | // Unclear, needs a look... |
1173 | - else { |
|
1349 | + else |
|
1350 | + { |
|
1174 | 1351 | $attdr_problem_found = true; |
1175 | 1352 | } |
1176 | 1353 | |
1177 | - if ($attdr_problem_found) { |
|
1178 | - if (empty($warnings)) { |
|
1354 | + if ($attdr_problem_found) |
|
1355 | + { |
|
1356 | + if (empty($warnings)) |
|
1357 | + { |
|
1179 | 1358 | $warnings = Lang::$txt['warning_att_dir_missing']; |
1180 | - } else { |
|
1359 | + } |
|
1360 | + else |
|
1361 | + { |
|
1181 | 1362 | $warnings .= '<br><br>' . Lang::$txt['warning_att_dir_missing']; |
1182 | 1363 | } |
1183 | 1364 | } |
1184 | 1365 | |
1185 | 1366 | // Might be using CLI |
1186 | - if ($command_line) { |
|
1367 | + if ($command_line) |
|
1368 | + { |
|
1187 | 1369 | // Change brs to new lines & display |
1188 | - if (!empty($warnings)) { |
|
1370 | + if (!empty($warnings)) |
|
1371 | + { |
|
1189 | 1372 | $warnings = str_replace('<br>', "\n", $warnings); |
1190 | 1373 | echo "\n\n" . $warnings . "\n\n"; |
1191 | 1374 | } |
1192 | - } else { |
|
1375 | + } |
|
1376 | + else |
|
1377 | + { |
|
1193 | 1378 | // Might be adding to an existing warning... |
1194 | - if (!empty($warnings)) { |
|
1195 | - if (empty($upcontext['custom_warning'])) { |
|
1379 | + if (!empty($warnings)) |
|
1380 | + { |
|
1381 | + if (empty($upcontext['custom_warning'])) |
|
1382 | + { |
|
1196 | 1383 | $upcontext['custom_warning'] = $warnings; |
1197 | - } else { |
|
1384 | + } |
|
1385 | + else |
|
1386 | + { |
|
1198 | 1387 | $upcontext['custom_warning'] .= '<br><br>' . $warnings; |
1199 | 1388 | } |
1200 | 1389 | } |
@@ -1208,16 +1397,19 @@ discard block |
||
1208 | 1397 | global $support_js; |
1209 | 1398 | |
1210 | 1399 | // Are we trying to login? |
1211 | - if (isset($_POST['contbutt']) && (!empty($_POST['user']) || $disable_security)) { |
|
1400 | + if (isset($_POST['contbutt']) && (!empty($_POST['user']) || $disable_security)) |
|
1401 | + { |
|
1212 | 1402 | // If we've disabled security pick a suitable name! |
1213 | - if (empty($_POST['user'])) { |
|
1403 | + if (empty($_POST['user'])) |
|
1404 | + { |
|
1214 | 1405 | $_POST['user'] = 'Administrator'; |
1215 | 1406 | } |
1216 | 1407 | |
1217 | 1408 | // Before 2.0 these column names were different! |
1218 | 1409 | $oldDB = false; |
1219 | 1410 | |
1220 | - if (empty(Config::$db_type) || Config::$db_type == 'mysql') { |
|
1411 | + if (empty(Config::$db_type) || Config::$db_type == 'mysql') |
|
1412 | + { |
|
1221 | 1413 | $request = Db::$db->query( |
1222 | 1414 | '', |
1223 | 1415 | 'SHOW COLUMNS |
@@ -1229,15 +1421,18 @@ discard block |
||
1229 | 1421 | ], |
1230 | 1422 | ); |
1231 | 1423 | |
1232 | - if (Db::$db->num_rows($request) != 0) { |
|
1424 | + if (Db::$db->num_rows($request) != 0) |
|
1425 | + { |
|
1233 | 1426 | $oldDB = true; |
1234 | 1427 | } |
1235 | 1428 | Db::$db->free_result($request); |
1236 | 1429 | } |
1237 | 1430 | |
1238 | 1431 | // Get what we believe to be their details. |
1239 | - if (!$disable_security) { |
|
1240 | - if ($oldDB) { |
|
1432 | + if (!$disable_security) |
|
1433 | + { |
|
1434 | + if ($oldDB) |
|
1435 | + { |
|
1241 | 1436 | $request = Db::$db->query( |
1242 | 1437 | '', |
1243 | 1438 | 'SELECT id_member, memberName AS member_name, passwd, id_group, |
@@ -1249,7 +1444,9 @@ discard block |
||
1249 | 1444 | 'db_error_skip' => true, |
1250 | 1445 | ], |
1251 | 1446 | ); |
1252 | - } else { |
|
1447 | + } |
|
1448 | + else |
|
1449 | + { |
|
1253 | 1450 | $request = Db::$db->query( |
1254 | 1451 | '', |
1255 | 1452 | 'SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
@@ -1262,13 +1459,15 @@ discard block |
||
1262 | 1459 | ); |
1263 | 1460 | } |
1264 | 1461 | |
1265 | - if (Db::$db->num_rows($request) != 0) { |
|
1462 | + if (Db::$db->num_rows($request) != 0) |
|
1463 | + { |
|
1266 | 1464 | list($id_member, $name, $password, $id_group, $addGroups, $user_language) = Db::$db->fetch_row($request); |
1267 | 1465 | |
1268 | 1466 | $groups = explode(',', $addGroups); |
1269 | 1467 | $groups[] = $id_group; |
1270 | 1468 | |
1271 | - foreach ($groups as $k => $v) { |
|
1469 | + foreach ($groups as $k => $v) |
|
1470 | + { |
|
1272 | 1471 | $groups[$k] = (int) $v; |
1273 | 1472 | } |
1274 | 1473 | |
@@ -1276,7 +1475,9 @@ discard block |
||
1276 | 1475 | |
1277 | 1476 | // We don't use "-utf8" anymore... |
1278 | 1477 | $user_language = str_ireplace('-utf8', '', $user_language); |
1279 | - } else { |
|
1478 | + } |
|
1479 | + else |
|
1480 | + { |
|
1280 | 1481 | $upcontext['username_incorrect'] = true; |
1281 | 1482 | } |
1282 | 1483 | |
@@ -1285,37 +1486,47 @@ discard block |
||
1285 | 1486 | $upcontext['username'] = $_POST['user']; |
1286 | 1487 | |
1287 | 1488 | // Track whether javascript works! |
1288 | - if (isset($_POST['js_works'])) { |
|
1289 | - if (!empty($_POST['js_works'])) { |
|
1489 | + if (isset($_POST['js_works'])) |
|
1490 | + { |
|
1491 | + if (!empty($_POST['js_works'])) |
|
1492 | + { |
|
1290 | 1493 | $upcontext['upgrade_status']['js'] = 1; |
1291 | 1494 | $support_js = 1; |
1292 | - } else { |
|
1495 | + } |
|
1496 | + else |
|
1497 | + { |
|
1293 | 1498 | $support_js = 0; |
1294 | 1499 | } |
1295 | 1500 | } |
1296 | 1501 | |
1297 | 1502 | // Note down the version we are coming from. |
1298 | - if (!empty(Config::$modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
1503 | + if (!empty(Config::$modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
1504 | + { |
|
1299 | 1505 | $upcontext['user']['version'] = Config::$modSettings['smfVersion']; |
1300 | 1506 | } |
1301 | 1507 | |
1302 | 1508 | // Didn't get anywhere? |
1303 | - if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !Security::hashVerifyPassword((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) { |
|
1509 | + if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !Security::hashVerifyPassword((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
|
1510 | + { |
|
1304 | 1511 | // MD5? |
1305 | 1512 | $md5pass = hash_hmac('md5', $_REQUEST['passwrd'], strtolower($_POST['user'])); |
1306 | 1513 | |
1307 | - if ($md5pass != $password) { |
|
1514 | + if ($md5pass != $password) |
|
1515 | + { |
|
1308 | 1516 | $upcontext['password_failed'] = true; |
1309 | 1517 | // Disable the hashing this time. |
1310 | 1518 | $upcontext['disable_login_hashing'] = true; |
1311 | 1519 | } |
1312 | 1520 | } |
1313 | 1521 | |
1314 | - if ((empty($upcontext['password_failed']) && !empty($name)) || $disable_security) { |
|
1522 | + if ((empty($upcontext['password_failed']) && !empty($name)) || $disable_security) |
|
1523 | + { |
|
1315 | 1524 | // Set the password. |
1316 | - if (!$disable_security) { |
|
1525 | + if (!$disable_security) |
|
1526 | + { |
|
1317 | 1527 | // Do we actually have permission? |
1318 | - if (!in_array(1, $groups)) { |
|
1528 | + if (!in_array(1, $groups)) |
|
1529 | + { |
|
1319 | 1530 | $request = Db::$db->query( |
1320 | 1531 | '', |
1321 | 1532 | 'SELECT permission |
@@ -1329,7 +1540,8 @@ discard block |
||
1329 | 1540 | ], |
1330 | 1541 | ); |
1331 | 1542 | |
1332 | - if (Db::$db->num_rows($request) == 0) { |
|
1543 | + if (Db::$db->num_rows($request) == 0) |
|
1544 | + { |
|
1333 | 1545 | return throw_error(Lang::$txt['error_not_admin']); |
1334 | 1546 | } |
1335 | 1547 | Db::$db->free_result($request); |
@@ -1337,7 +1549,9 @@ discard block |
||
1337 | 1549 | |
1338 | 1550 | $upcontext['user']['id'] = $id_member; |
1339 | 1551 | $upcontext['user']['name'] = $name; |
1340 | - } else { |
|
1552 | + } |
|
1553 | + else |
|
1554 | + { |
|
1341 | 1555 | $upcontext['user']['id'] = 1; |
1342 | 1556 | $upcontext['user']['name'] = 'Administrator'; |
1343 | 1557 | } |
@@ -1347,16 +1561,22 @@ discard block |
||
1347 | 1561 | $upcontext['upgrade_status']['pass'] = $upcontext['user']['pass']; |
1348 | 1562 | |
1349 | 1563 | // Set the language to that of the user? |
1350 | - if (isset($user_language) && $user_language != $upcontext['language'] && file_exists(Config::$modSettings['theme_dir'] . '/languages/index.' . basename($user_language, '.lng') . '.php')) { |
|
1564 | + if (isset($user_language) && $user_language != $upcontext['language'] && file_exists(Config::$modSettings['theme_dir'] . '/languages/index.' . basename($user_language, '.lng') . '.php')) |
|
1565 | + { |
|
1351 | 1566 | $user_language = basename($user_language, '.lng'); |
1352 | 1567 | $temp = substr(@implode('', @file(Config::$modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
1353 | 1568 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
1354 | 1569 | |
1355 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
1570 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
1571 | + { |
|
1356 | 1572 | $upcontext['upgrade_options_warning'] = sprintf(Lang::$txt['warning_lang_old'], $user_language, $upcontext['language']); |
1357 | - } elseif (!file_exists(Config::$modSettings['theme_dir'] . '/languages/Install.' . $user_language . '.php')) { |
|
1573 | + } |
|
1574 | + elseif (!file_exists(Config::$modSettings['theme_dir'] . '/languages/Install.' . $user_language . '.php')) |
|
1575 | + { |
|
1358 | 1576 | $upcontext['upgrade_options_warning'] = sprintf(Lang::$txt['warning_lang_missing'], $user_language, $upcontext['language']); |
1359 | - } else { |
|
1577 | + } |
|
1578 | + else |
|
1579 | + { |
|
1360 | 1580 | // Set this as the new language. |
1361 | 1581 | $upcontext['language'] = $user_language; |
1362 | 1582 | $upcontext['upgrade_status']['lang'] = $upcontext['language']; |
@@ -1367,7 +1587,8 @@ discard block |
||
1367 | 1587 | } |
1368 | 1588 | |
1369 | 1589 | // If we're resuming set the step and substep to be correct. |
1370 | - if (isset($_POST['cont'])) { |
|
1590 | + if (isset($_POST['cont'])) |
|
1591 | + { |
|
1371 | 1592 | $upcontext['current_step'] = $upcontext['user']['step']; |
1372 | 1593 | $_GET['substep'] = $upcontext['user']['substep']; |
1373 | 1594 | } |
@@ -1399,7 +1620,8 @@ discard block |
||
1399 | 1620 | unset($member_columns); |
1400 | 1621 | |
1401 | 1622 | // If we've not submitted then we're done. |
1402 | - if (empty($_POST['upcont'])) { |
|
1623 | + if (empty($_POST['upcont'])) |
|
1624 | + { |
|
1403 | 1625 | return false; |
1404 | 1626 | } |
1405 | 1627 | |
@@ -1407,19 +1629,23 @@ discard block |
||
1407 | 1629 | setSqlMode(false); |
1408 | 1630 | |
1409 | 1631 | // Firstly, if they're enabling SM stat collection just do it. |
1410 | - if (!empty($_POST['stats']) && substr(Config::$boardurl, 0, 16) != 'http://localhost' && empty(Config::$modSettings['allow_sm_stats']) && empty(Config::$modSettings['enable_sm_stats'])) { |
|
1632 | + if (!empty($_POST['stats']) && substr(Config::$boardurl, 0, 16) != 'http://localhost' && empty(Config::$modSettings['allow_sm_stats']) && empty(Config::$modSettings['enable_sm_stats'])) |
|
1633 | + { |
|
1411 | 1634 | $upcontext['allow_sm_stats'] = true; |
1412 | 1635 | |
1413 | 1636 | // Don't register if we still have a key. |
1414 | - if (empty(Config::$modSettings['sm_stats_key'])) { |
|
1637 | + if (empty(Config::$modSettings['sm_stats_key'])) |
|
1638 | + { |
|
1415 | 1639 | // Attempt to register the site etc. |
1416 | 1640 | $fp = @fsockopen('www.simplemachines.org', 443, $errno, $errstr); |
1417 | 1641 | |
1418 | - if (!$fp) { |
|
1642 | + if (!$fp) |
|
1643 | + { |
|
1419 | 1644 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
1420 | 1645 | } |
1421 | 1646 | |
1422 | - if ($fp) { |
|
1647 | + if ($fp) |
|
1648 | + { |
|
1423 | 1649 | $out = 'GET /smf/stats/register_stats.php?site=' . base64_encode(Config::$boardurl) . ' HTTP/1.1' . "\r\n"; |
1424 | 1650 | $out .= 'Host: www.simplemachines.org' . "\r\n"; |
1425 | 1651 | $out .= 'Connection: Close' . "\r\n\r\n"; |
@@ -1427,7 +1653,8 @@ discard block |
||
1427 | 1653 | |
1428 | 1654 | $return_data = ''; |
1429 | 1655 | |
1430 | - while (!feof($fp)) { |
|
1656 | + while (!feof($fp)) |
|
1657 | + { |
|
1431 | 1658 | $return_data .= fgets($fp, 128); |
1432 | 1659 | } |
1433 | 1660 | |
@@ -1436,7 +1663,8 @@ discard block |
||
1436 | 1663 | // Get the unique site ID. |
1437 | 1664 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1438 | 1665 | |
1439 | - if (!empty($ID[1])) { |
|
1666 | + if (!empty($ID[1])) |
|
1667 | + { |
|
1440 | 1668 | Db::$db->insert( |
1441 | 1669 | 'replace', |
1442 | 1670 | Config::$db_prefix . 'settings', |
@@ -1449,7 +1677,9 @@ discard block |
||
1449 | 1677 | ); |
1450 | 1678 | } |
1451 | 1679 | } |
1452 | - } else { |
|
1680 | + } |
|
1681 | + else |
|
1682 | + { |
|
1453 | 1683 | Db::$db->insert( |
1454 | 1684 | 'replace', |
1455 | 1685 | Config::$db_prefix . 'settings', |
@@ -1460,7 +1690,8 @@ discard block |
||
1460 | 1690 | } |
1461 | 1691 | } |
1462 | 1692 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1463 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1693 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1694 | + { |
|
1464 | 1695 | Db::$db->query( |
1465 | 1696 | '', |
1466 | 1697 | 'DELETE FROM {db_prefix}settings |
@@ -1484,66 +1715,81 @@ discard block |
||
1484 | 1715 | $changes = []; |
1485 | 1716 | |
1486 | 1717 | // Add proxy settings. |
1487 | - if (!isset(Config::$image_proxy_secret) || Config::$image_proxy_secret == 'smfisawesome') { |
|
1718 | + if (!isset(Config::$image_proxy_secret) || Config::$image_proxy_secret == 'smfisawesome') |
|
1719 | + { |
|
1488 | 1720 | $changes['image_proxy_secret'] = bin2hex(random_bytes(10)); |
1489 | 1721 | } |
1490 | 1722 | |
1491 | - if (!isset(Config::$image_proxy_maxsize)) { |
|
1723 | + if (!isset(Config::$image_proxy_maxsize)) |
|
1724 | + { |
|
1492 | 1725 | $changes['image_proxy_maxsize'] = 5190; |
1493 | 1726 | } |
1494 | 1727 | |
1495 | - if (!isset(Config::$image_proxy_enabled)) { |
|
1728 | + if (!isset(Config::$image_proxy_enabled)) |
|
1729 | + { |
|
1496 | 1730 | $changes['image_proxy_enabled'] = false; |
1497 | 1731 | } |
1498 | 1732 | |
1499 | 1733 | // If Config::$boardurl reflects https, set force_ssl |
1500 | - if (!function_exists('cache_put_data')) { |
|
1734 | + if (!function_exists('cache_put_data')) |
|
1735 | + { |
|
1501 | 1736 | require_once Config::$sourcedir . '/Cache/CacheApi.php'; |
1502 | 1737 | } |
1503 | 1738 | |
1504 | - if (stripos(Config::$boardurl, 'https://') !== false && !isset(Config::$modSettings['force_ssl'])) { |
|
1739 | + if (stripos(Config::$boardurl, 'https://') !== false && !isset(Config::$modSettings['force_ssl'])) |
|
1740 | + { |
|
1505 | 1741 | Config::updateModSettings(['force_ssl' => '1']); |
1506 | 1742 | } |
1507 | 1743 | |
1508 | 1744 | // If we're overriding the language follow it through. |
1509 | - if (isset($upcontext['lang']) && file_exists(Config::$modSettings['theme_dir'] . '/languages/index.' . $upcontext['lang'] . '.php')) { |
|
1745 | + if (isset($upcontext['lang']) && file_exists(Config::$modSettings['theme_dir'] . '/languages/index.' . $upcontext['lang'] . '.php')) |
|
1746 | + { |
|
1510 | 1747 | $changes['language'] = $upcontext['lang']; |
1511 | 1748 | } |
1512 | 1749 | |
1513 | - if (!empty($_POST['maint'])) { |
|
1750 | + if (!empty($_POST['maint'])) |
|
1751 | + { |
|
1514 | 1752 | $changes['maintenance'] = 2; |
1515 | 1753 | // Remember what it was... |
1516 | 1754 | $upcontext['user']['main'] = Config::$maintenance; |
1517 | 1755 | |
1518 | - if (!empty($_POST['maintitle'])) { |
|
1756 | + if (!empty($_POST['maintitle'])) |
|
1757 | + { |
|
1519 | 1758 | $changes['mtitle'] = $_POST['maintitle']; |
1520 | 1759 | $changes['mmessage'] = $_POST['mainmessage']; |
1521 | - } else { |
|
1760 | + } |
|
1761 | + else |
|
1762 | + { |
|
1522 | 1763 | $changes['mtitle'] = Lang::$txt['mtitle']; |
1523 | 1764 | $changes['mmessage'] = Lang::$txt['mmessage']; |
1524 | 1765 | } |
1525 | 1766 | } |
1526 | 1767 | |
1527 | - if ($command_line) { |
|
1768 | + if ($command_line) |
|
1769 | + { |
|
1528 | 1770 | echo ' * Updating Settings.php...'; |
1529 | 1771 | } |
1530 | 1772 | |
1531 | 1773 | // Fix some old paths. |
1532 | - if (substr(Config::$boarddir, 0, 1) == '.') { |
|
1774 | + if (substr(Config::$boarddir, 0, 1) == '.') |
|
1775 | + { |
|
1533 | 1776 | $changes['boarddir'] = fixRelativePath(Config::$boarddir); |
1534 | 1777 | } |
1535 | 1778 | |
1536 | - if (substr(Config::$sourcedir, 0, 1) == '.') { |
|
1779 | + if (substr(Config::$sourcedir, 0, 1) == '.') |
|
1780 | + { |
|
1537 | 1781 | $changes['sourcedir'] = fixRelativePath(Config::$sourcedir); |
1538 | 1782 | } |
1539 | 1783 | |
1540 | - if (empty(Config::$cachedir) || substr(Config::$cachedir, 0, 1) == '.') { |
|
1784 | + if (empty(Config::$cachedir) || substr(Config::$cachedir, 0, 1) == '.') |
|
1785 | + { |
|
1541 | 1786 | $changes['cachedir'] = fixRelativePath(Config::$boarddir) . '/cache'; |
1542 | 1787 | } |
1543 | 1788 | |
1544 | 1789 | // Migrate cache settings. |
1545 | 1790 | // Accelerator setting didn't exist previously; use 'smf' file based caching as default if caching had been enabled. |
1546 | - if (!isset(Config::$cache_enable)) { |
|
1791 | + if (!isset(Config::$cache_enable)) |
|
1792 | + { |
|
1547 | 1793 | $changes += [ |
1548 | 1794 | 'cache_accelerator' => upgradeCacheSettings(), |
1549 | 1795 | 'cache_enable' => !empty(Config::$modSettings['cache_enable']) ? Config::$modSettings['cache_enable'] : 0, |
@@ -1553,38 +1799,47 @@ discard block |
||
1553 | 1799 | |
1554 | 1800 | // If they have a "host:port" setup for the host, split that into separate values |
1555 | 1801 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
1556 | - if (strpos(Config::$db_server, ':') !== false && Config::$db_type == 'mysql') { |
|
1802 | + if (strpos(Config::$db_server, ':') !== false && Config::$db_type == 'mysql') |
|
1803 | + { |
|
1557 | 1804 | list(Config::$db_server, Config::$db_port) = explode(':', Config::$db_server); |
1558 | 1805 | |
1559 | 1806 | $changes['db_server'] = Config::$db_server; |
1560 | 1807 | |
1561 | 1808 | // Only set this if we're not using the default port |
1562 | - if (Config::$db_port != ini_get('mysqli.default_port')) { |
|
1809 | + if (Config::$db_port != ini_get('mysqli.default_port')) |
|
1810 | + { |
|
1563 | 1811 | $changes['db_port'] = (int) Config::$db_port; |
1564 | 1812 | } |
1565 | 1813 | } |
1566 | 1814 | |
1567 | 1815 | // If db_port is set and is the same as the default, set it to 0. |
1568 | - if (!empty(Config::$db_port)) { |
|
1569 | - if (Config::$db_type == 'mysql' && Config::$db_port == ini_get('mysqli.default_port')) { |
|
1816 | + if (!empty(Config::$db_port)) |
|
1817 | + { |
|
1818 | + if (Config::$db_type == 'mysql' && Config::$db_port == ini_get('mysqli.default_port')) |
|
1819 | + { |
|
1570 | 1820 | $changes['db_port'] = 0; |
1571 | - } elseif (Config::$db_type == 'postgresql' && Config::$db_port == 5432) { |
|
1821 | + } |
|
1822 | + elseif (Config::$db_type == 'postgresql' && Config::$db_port == 5432) |
|
1823 | + { |
|
1572 | 1824 | $changes['db_port'] = 0; |
1573 | 1825 | } |
1574 | 1826 | } |
1575 | 1827 | |
1576 | 1828 | // Maybe we haven't had this option yet? |
1577 | - if (empty(Config::$packagesdir)) { |
|
1829 | + if (empty(Config::$packagesdir)) |
|
1830 | + { |
|
1578 | 1831 | $changes['packagesdir'] = fixRelativePath(Config::$boarddir) . '/Packages'; |
1579 | 1832 | } |
1580 | 1833 | |
1581 | 1834 | // Add support for $tasksdir var. |
1582 | - if (empty(Config::$tasksdir)) { |
|
1835 | + if (empty(Config::$tasksdir)) |
|
1836 | + { |
|
1583 | 1837 | $changes['tasksdir'] = fixRelativePath(Config::$sourcedir) . '/Tasks'; |
1584 | 1838 | } |
1585 | 1839 | |
1586 | 1840 | // Make sure we fix the language as well. |
1587 | - if (stristr(Config::$language, '-utf8')) { |
|
1841 | + if (stristr(Config::$language, '-utf8')) |
|
1842 | + { |
|
1588 | 1843 | $changes['language'] = str_ireplace('-utf8', '', Config::$language); |
1589 | 1844 | } |
1590 | 1845 | |
@@ -1596,22 +1851,27 @@ discard block |
||
1596 | 1851 | // Update Settings.php with the new settings, and rebuild if they selected that option. |
1597 | 1852 | $res = Config::updateSettingsFile($changes, false, !empty($_POST['migrateSettings'])); |
1598 | 1853 | |
1599 | - if ($command_line && $res) { |
|
1854 | + if ($command_line && $res) |
|
1855 | + { |
|
1600 | 1856 | echo ' Successful.' . "\n"; |
1601 | - } elseif ($command_line && !$res) { |
|
1857 | + } |
|
1858 | + elseif ($command_line && !$res) |
|
1859 | + { |
|
1602 | 1860 | echo ' FAILURE.' . "\n"; |
1603 | 1861 | |
1604 | 1862 | die; |
1605 | 1863 | } |
1606 | 1864 | |
1607 | 1865 | // Are we doing debug? |
1608 | - if (isset($_POST['debug'])) { |
|
1866 | + if (isset($_POST['debug'])) |
|
1867 | + { |
|
1609 | 1868 | $upcontext['upgrade_status']['debug'] = true; |
1610 | 1869 | $is_debug = true; |
1611 | 1870 | } |
1612 | 1871 | |
1613 | 1872 | // If we're not backing up then jump one. |
1614 | - if (empty($_POST['backup'])) { |
|
1873 | + if (empty($_POST['backup'])) |
|
1874 | + { |
|
1615 | 1875 | $upcontext['current_step']++; |
1616 | 1876 | } |
1617 | 1877 | |
@@ -1628,7 +1888,8 @@ discard block |
||
1628 | 1888 | $upcontext['page_title'] = Lang::$txt['backup_database']; |
1629 | 1889 | |
1630 | 1890 | // Done it already - js wise? |
1631 | - if (!empty($_POST['backup_done'])) { |
|
1891 | + if (!empty($_POST['backup_done'])) |
|
1892 | + { |
|
1632 | 1893 | return true; |
1633 | 1894 | } |
1634 | 1895 | |
@@ -1642,8 +1903,10 @@ discard block |
||
1642 | 1903 | |
1643 | 1904 | $table_names = []; |
1644 | 1905 | |
1645 | - foreach ($tables as $table) { |
|
1646 | - if (substr($table, 0, 7) !== 'backup_') { |
|
1906 | + foreach ($tables as $table) |
|
1907 | + { |
|
1908 | + if (substr($table, 0, 7) !== 'backup_') |
|
1909 | + { |
|
1647 | 1910 | $table_names[] = $table; |
1648 | 1911 | } |
1649 | 1912 | } |
@@ -1656,20 +1919,25 @@ discard block |
||
1656 | 1919 | $file_steps = $upcontext['table_count']; |
1657 | 1920 | |
1658 | 1921 | // What ones have we already done? |
1659 | - foreach ($table_names as $id => $table) { |
|
1660 | - if ($id < $_GET['substep']) { |
|
1922 | + foreach ($table_names as $id => $table) |
|
1923 | + { |
|
1924 | + if ($id < $_GET['substep']) |
|
1925 | + { |
|
1661 | 1926 | $upcontext['previous_tables'][] = $table; |
1662 | 1927 | } |
1663 | 1928 | } |
1664 | 1929 | |
1665 | - if ($command_line) { |
|
1930 | + if ($command_line) |
|
1931 | + { |
|
1666 | 1932 | echo 'Backing Up Tables.'; |
1667 | 1933 | } |
1668 | 1934 | |
1669 | 1935 | // If we don't support javascript we backup here. |
1670 | - if (!$support_js || isset($_GET['xml'])) { |
|
1936 | + if (!$support_js || isset($_GET['xml'])) |
|
1937 | + { |
|
1671 | 1938 | // Backup each table! |
1672 | - for ($substep = $_GET['substep'], $n = count($table_names); $substep < $n; $substep++) { |
|
1939 | + for ($substep = $_GET['substep'], $n = count($table_names); $substep < $n; $substep++) |
|
1940 | + { |
|
1673 | 1941 | $upcontext['cur_table_name'] = str_replace(Config::$db_prefix, '', ($table_names[$substep + 1] ?? $table_names[$substep])); |
1674 | 1942 | $upcontext['cur_table_num'] = $substep + 1; |
1675 | 1943 | |
@@ -1681,12 +1949,14 @@ discard block |
||
1681 | 1949 | backupTable($table_names[$substep]); |
1682 | 1950 | |
1683 | 1951 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1684 | - if (isset($_GET['xml'])) { |
|
1952 | + if (isset($_GET['xml'])) |
|
1953 | + { |
|
1685 | 1954 | return upgradeExit(); |
1686 | 1955 | } |
1687 | 1956 | } |
1688 | 1957 | |
1689 | - if ($command_line) { |
|
1958 | + if ($command_line) |
|
1959 | + { |
|
1690 | 1960 | echo "\n" . ' Successful.\'' . "\n"; |
1691 | 1961 | flush(); |
1692 | 1962 | } |
@@ -1709,14 +1979,16 @@ discard block |
||
1709 | 1979 | { |
1710 | 1980 | global $command_line; |
1711 | 1981 | |
1712 | - if ($command_line) { |
|
1982 | + if ($command_line) |
|
1983 | + { |
|
1713 | 1984 | echo "\n" . ' +++ Backing up \"' . str_replace(Config::$db_prefix, '', $table) . '"...'; |
1714 | 1985 | flush(); |
1715 | 1986 | } |
1716 | 1987 | |
1717 | 1988 | Db::$db->backup_table($table, 'backup_' . $table); |
1718 | 1989 | |
1719 | - if ($command_line) { |
|
1990 | + if ($command_line) |
|
1991 | + { |
|
1720 | 1992 | echo ' done.'; |
1721 | 1993 | } |
1722 | 1994 | } |
@@ -1727,7 +1999,8 @@ discard block |
||
1727 | 1999 | global $upcontext, $support_js; |
1728 | 2000 | |
1729 | 2001 | // Have we just completed this? |
1730 | - if (!empty($_POST['database_done'])) { |
|
2002 | + if (!empty($_POST['database_done'])) |
|
2003 | + { |
|
1731 | 2004 | return true; |
1732 | 2005 | } |
1733 | 2006 | |
@@ -1750,13 +2023,18 @@ discard block |
||
1750 | 2023 | ]; |
1751 | 2024 | |
1752 | 2025 | // How many files are there in total? |
1753 | - if (isset($_GET['filecount'])) { |
|
2026 | + if (isset($_GET['filecount'])) |
|
2027 | + { |
|
1754 | 2028 | $upcontext['file_count'] = (int) $_GET['filecount']; |
1755 | - } else { |
|
2029 | + } |
|
2030 | + else |
|
2031 | + { |
|
1756 | 2032 | $upcontext['file_count'] = 0; |
1757 | 2033 | |
1758 | - foreach ($files as $file) { |
|
1759 | - if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < $file[1]) { |
|
2034 | + foreach ($files as $file) |
|
2035 | + { |
|
2036 | + if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < $file[1]) |
|
2037 | + { |
|
1760 | 2038 | $upcontext['file_count']++; |
1761 | 2039 | } |
1762 | 2040 | } |
@@ -1767,15 +2045,20 @@ discard block |
||
1767 | 2045 | $upcontext['step_progress'] = 0; |
1768 | 2046 | $upcontext['cur_file_num'] = 0; |
1769 | 2047 | |
1770 | - foreach ($files as $file) { |
|
1771 | - if ($did_not_do) { |
|
2048 | + foreach ($files as $file) |
|
2049 | + { |
|
2050 | + if ($did_not_do) |
|
2051 | + { |
|
1772 | 2052 | $did_not_do--; |
1773 | - } else { |
|
2053 | + } |
|
2054 | + else |
|
2055 | + { |
|
1774 | 2056 | $upcontext['cur_file_num']++; |
1775 | 2057 | $upcontext['cur_file_name'] = $file[0]; |
1776 | 2058 | |
1777 | 2059 | // Do we actually need to do this still? |
1778 | - if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < $file[1]) { |
|
2060 | + if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] < $file[1]) |
|
2061 | + { |
|
1779 | 2062 | // Use STRICT mode on more recent steps |
1780 | 2063 | setSqlMode($file[3]); |
1781 | 2064 | |
@@ -1791,7 +2074,8 @@ discard block |
||
1791 | 2074 | |
1792 | 2075 | Config::$modSettings = []; |
1793 | 2076 | |
1794 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
2077 | + while ($row = Db::$db->fetch_assoc($request)) |
|
2078 | + { |
|
1795 | 2079 | Config::$modSettings[$row['variable']] = $row['value']; |
1796 | 2080 | } |
1797 | 2081 | |
@@ -1799,7 +2083,8 @@ discard block |
||
1799 | 2083 | |
1800 | 2084 | // Some theme settings are in Config::$modSettings |
1801 | 2085 | // Note we still might be doing yabbse (no smf ver) |
1802 | - if (isset(Config::$modSettings['smfVersion'])) { |
|
2086 | + if (isset(Config::$modSettings['smfVersion'])) |
|
2087 | + { |
|
1803 | 2088 | $request = Db::$db->query( |
1804 | 2089 | '', |
1805 | 2090 | 'SELECT variable, value |
@@ -1815,14 +2100,16 @@ discard block |
||
1815 | 2100 | ], |
1816 | 2101 | ); |
1817 | 2102 | |
1818 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
2103 | + while ($row = Db::$db->fetch_assoc($request)) |
|
2104 | + { |
|
1819 | 2105 | Config::$modSettings[$row['variable']] = $row['value']; |
1820 | 2106 | } |
1821 | 2107 | |
1822 | 2108 | Db::$db->free_result($request); |
1823 | 2109 | } |
1824 | 2110 | |
1825 | - if (!isset(Config::$modSettings['theme_url'])) { |
|
2111 | + if (!isset(Config::$modSettings['theme_url'])) |
|
2112 | + { |
|
1826 | 2113 | Config::$modSettings['theme_dir'] = Config::$boarddir . '/Themes/default'; |
1827 | 2114 | Config::$modSettings['theme_url'] = 'Themes/default'; |
1828 | 2115 | Config::$modSettings['images_url'] = 'Themes/default/images'; |
@@ -1831,7 +2118,8 @@ discard block |
||
1831 | 2118 | // Now process the file... |
1832 | 2119 | $nextFile = parse_sql(dirname(__FILE__) . '/' . $file[0]); |
1833 | 2120 | |
1834 | - if ($nextFile) { |
|
2121 | + if ($nextFile) |
|
2122 | + { |
|
1835 | 2123 | // Only update the version of this if complete. |
1836 | 2124 | Db::$db->insert( |
1837 | 2125 | 'replace', |
@@ -1845,19 +2133,22 @@ discard block |
||
1845 | 2133 | } |
1846 | 2134 | |
1847 | 2135 | // If this is XML we only do this stuff once. |
1848 | - if (isset($_GET['xml'])) { |
|
2136 | + if (isset($_GET['xml'])) |
|
2137 | + { |
|
1849 | 2138 | // Flag to move on to the next. |
1850 | 2139 | $upcontext['completed_step'] = true; |
1851 | 2140 | |
1852 | 2141 | // Did we complete the whole file? |
1853 | - if ($nextFile) { |
|
2142 | + if ($nextFile) |
|
2143 | + { |
|
1854 | 2144 | $upcontext['current_debug_item_num'] = -1; |
1855 | 2145 | } |
1856 | 2146 | |
1857 | 2147 | return upgradeExit(); |
1858 | 2148 | } |
1859 | 2149 | |
1860 | - if ($support_js) { |
|
2150 | + if ($support_js) |
|
2151 | + { |
|
1861 | 2152 | break; |
1862 | 2153 | } |
1863 | 2154 | } |
@@ -1869,7 +2160,8 @@ discard block |
||
1869 | 2160 | $_GET['substep'] = 0; |
1870 | 2161 | |
1871 | 2162 | // So the template knows we're done. |
1872 | - if (!$support_js) { |
|
2163 | + if (!$support_js) |
|
2164 | + { |
|
1873 | 2165 | $upcontext['changes_complete'] = true; |
1874 | 2166 | |
1875 | 2167 | return true; |
@@ -1881,13 +2173,17 @@ discard block |
||
1881 | 2173 | // Different versions of the files use different sql_modes |
1882 | 2174 | function setSqlMode($strict = true) |
1883 | 2175 | { |
1884 | - if (Config::$db_type != 'mysql') { |
|
2176 | + if (Config::$db_type != 'mysql') |
|
2177 | + { |
|
1885 | 2178 | return; |
1886 | 2179 | } |
1887 | 2180 | |
1888 | - if ($strict) { |
|
2181 | + if ($strict) |
|
2182 | + { |
|
1889 | 2183 | $mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT'; |
1890 | - } else { |
|
2184 | + } |
|
2185 | + else |
|
2186 | + { |
|
1891 | 2187 | $mode = ''; |
1892 | 2188 | } |
1893 | 2189 | |
@@ -1903,7 +2199,8 @@ discard block |
||
1903 | 2199 | global $settings; |
1904 | 2200 | |
1905 | 2201 | // Now it's nice to have some of the basic SMF source files. |
1906 | - if (!isset($_GET['ssi']) && !$command_line) { |
|
2202 | + if (!isset($_GET['ssi']) && !$command_line) |
|
2203 | + { |
|
1907 | 2204 | redirectLocation('&ssi=1'); |
1908 | 2205 | } |
1909 | 2206 | |
@@ -1932,7 +2229,8 @@ discard block |
||
1932 | 2229 | && fileinode(realpath(Config::$tasksdir)) !== fileinode(realpath(dirname(Config::$tasksdir) . '/Tasks')) |
1933 | 2230 | ) { |
1934 | 2231 | // Move everything in 'Tasks' to 'tasks'. |
1935 | - foreach (glob(realpath(dirname(Config::$tasksdir) . '/Tasks') . DIRECTORY_SEPARATOR . '*') as $path) { |
|
2232 | + foreach (glob(realpath(dirname(Config::$tasksdir) . '/Tasks') . DIRECTORY_SEPARATOR . '*') as $path) |
|
2233 | + { |
|
1936 | 2234 | rename($path, realpath(Config::$tasksdir) . DIRECTORY_SEPARATOR . basename($path)); |
1937 | 2235 | } |
1938 | 2236 | |
@@ -1949,15 +2247,18 @@ discard block |
||
1949 | 2247 | } |
1950 | 2248 | |
1951 | 2249 | // Are we in maintenance mode? |
1952 | - if (isset($upcontext['user']['main'])) { |
|
1953 | - if ($command_line) { |
|
2250 | + if (isset($upcontext['user']['main'])) |
|
2251 | + { |
|
2252 | + if ($command_line) |
|
2253 | + { |
|
1954 | 2254 | echo ' * '; |
1955 | 2255 | } |
1956 | 2256 | $upcontext['removed_maintenance'] = true; |
1957 | 2257 | $changes['maintenance'] = $upcontext['user']['main']; |
1958 | 2258 | } |
1959 | 2259 | // Otherwise if somehow we are in 2 let's go to 1. |
1960 | - elseif (!empty(Config::$maintenance) && Config::$maintenance == 2) { |
|
2260 | + elseif (!empty(Config::$maintenance) && Config::$maintenance == 2) |
|
2261 | + { |
|
1961 | 2262 | $changes['maintenance'] = 1; |
1962 | 2263 | } |
1963 | 2264 | |
@@ -1973,23 +2274,29 @@ discard block |
||
1973 | 2274 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1974 | 2275 | |
1975 | 2276 | // Now is the perfect time to fetch the SM files. |
1976 | - if ($command_line) { |
|
2277 | + if ($command_line) |
|
2278 | + { |
|
1977 | 2279 | cli_scheduled_fetchSMfiles(); |
1978 | - } else { |
|
2280 | + } |
|
2281 | + else |
|
2282 | + { |
|
1979 | 2283 | (new TaskRunner())->runScheduledTasks(['fetchSMfiles']); // Now go get those files! |
1980 | 2284 | |
1981 | 2285 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
1982 | - if (Config::httpsOn()) { |
|
2286 | + if (Config::httpsOn()) |
|
2287 | + { |
|
1983 | 2288 | $settings['default_theme_url'] = strtr($settings['default_theme_url'], ['http://' => 'https://']); |
1984 | 2289 | } |
1985 | 2290 | } |
1986 | 2291 | |
1987 | 2292 | // Log what we've done. |
1988 | - if (!isset(User::$me)) { |
|
2293 | + if (!isset(User::$me)) |
|
2294 | + { |
|
1989 | 2295 | User::load(); |
1990 | 2296 | } |
1991 | 2297 | |
1992 | - if (empty(User::$me->id) && !empty($upcontext['user']['id'])) { |
|
2298 | + if (empty(User::$me->id) && !empty($upcontext['user']['id'])) |
|
2299 | + { |
|
1993 | 2300 | User::setMe($upcontext['user']['id']); |
1994 | 2301 | } |
1995 | 2302 | |
@@ -2011,7 +2318,8 @@ discard block |
||
2011 | 2318 | ); |
2012 | 2319 | User::setMe(0); |
2013 | 2320 | |
2014 | - if ($command_line) { |
|
2321 | + if ($command_line) |
|
2322 | + { |
|
2015 | 2323 | echo $endl; |
2016 | 2324 | echo 'Upgrade Complete!', $endl; |
2017 | 2325 | echo 'Please delete this file as soon as possible for security reasons.', $endl; |
@@ -2022,7 +2330,8 @@ discard block |
||
2022 | 2330 | // Make sure it says we're done. |
2023 | 2331 | $upcontext['overall_percent'] = 100; |
2024 | 2332 | |
2025 | - if (isset($upcontext['step_progress'])) { |
|
2333 | + if (isset($upcontext['step_progress'])) |
|
2334 | + { |
|
2026 | 2335 | unset($upcontext['step_progress']); |
2027 | 2336 | } |
2028 | 2337 | |
@@ -2034,7 +2343,8 @@ discard block |
||
2034 | 2343 | // Just like the built in one, but setup for CLI to not use themes. |
2035 | 2344 | function cli_scheduled_fetchSMfiles() |
2036 | 2345 | { |
2037 | - if (empty(Config::$modSettings['time_format'])) { |
|
2346 | + if (empty(Config::$modSettings['time_format'])) |
|
2347 | + { |
|
2038 | 2348 | Config::$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
2039 | 2349 | } |
2040 | 2350 | |
@@ -2049,7 +2359,8 @@ discard block |
||
2049 | 2359 | |
2050 | 2360 | $js_files = []; |
2051 | 2361 | |
2052 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
2362 | + while ($row = Db::$db->fetch_assoc($request)) |
|
2363 | + { |
|
2053 | 2364 | $js_files[$row['id_file']] = [ |
2054 | 2365 | 'filename' => $row['filename'], |
2055 | 2366 | 'path' => $row['path'], |
@@ -2058,7 +2369,8 @@ discard block |
||
2058 | 2369 | } |
2059 | 2370 | Db::$db->free_result($request); |
2060 | 2371 | |
2061 | - foreach ($js_files as $ID_FILE => $file) { |
|
2372 | + foreach ($js_files as $ID_FILE => $file) |
|
2373 | + { |
|
2062 | 2374 | // Create the url |
2063 | 2375 | $server = empty($file['path']) || substr($file['path'], 0, 7) != 'http://' ? 'https://www.simplemachines.org' : ''; |
2064 | 2376 | $url = $server . (!empty($file['path']) ? $file['path'] : $file['path']) . $file['filename'] . (!empty($file['parameters']) ? '?' . $file['parameters'] : ''); |
@@ -2067,7 +2379,8 @@ discard block |
||
2067 | 2379 | $file_data = WebFetchApi::fetch($url); |
2068 | 2380 | |
2069 | 2381 | // If we got an error - give up - the site might be down. |
2070 | - if ($file_data === false) { |
|
2382 | + if ($file_data === false) |
|
2383 | + { |
|
2071 | 2384 | return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
2072 | 2385 | } |
2073 | 2386 | |
@@ -2112,15 +2425,18 @@ discard block |
||
2112 | 2425 | |
2113 | 2426 | $themeData = []; |
2114 | 2427 | |
2115 | - foreach ($values as $variable => $value) { |
|
2116 | - if (!isset($value) || $value === null) { |
|
2428 | + foreach ($values as $variable => $value) |
|
2429 | + { |
|
2430 | + if (!isset($value) || $value === null) |
|
2431 | + { |
|
2117 | 2432 | $value = 0; |
2118 | 2433 | } |
2119 | 2434 | |
2120 | 2435 | $themeData[] = [0, 1, $variable, $value]; |
2121 | 2436 | } |
2122 | 2437 | |
2123 | - if (!empty($themeData)) { |
|
2438 | + if (!empty($themeData)) |
|
2439 | + { |
|
2124 | 2440 | Db::$db->insert( |
2125 | 2441 | 'ignore', |
2126 | 2442 | Config::$db_prefix . 'themes', |
@@ -2141,8 +2457,10 @@ discard block |
||
2141 | 2457 | 'view_newest_pm_first' => 'viewNewestFirst', |
2142 | 2458 | ]; |
2143 | 2459 | |
2144 | - foreach ($values as $variable => $value) { |
|
2145 | - if (empty(Config::$modSettings[$value[0]])) { |
|
2460 | + foreach ($values as $variable => $value) |
|
2461 | + { |
|
2462 | + if (empty(Config::$modSettings[$value[0]])) |
|
2463 | + { |
|
2146 | 2464 | continue; |
2147 | 2465 | } |
2148 | 2466 | |
@@ -2231,12 +2549,15 @@ discard block |
||
2231 | 2549 | // will return 4437 (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE) |
2232 | 2550 | // as it does so. |
2233 | 2551 | set_error_handler( |
2234 | - function ($errno, $errstr, $errfile, $errline) use ($support_js) { |
|
2235 | - if ($support_js) { |
|
2552 | + function ($errno, $errstr, $errfile, $errline) use ($support_js) |
|
2553 | + { |
|
2554 | + if ($support_js) |
|
2555 | + { |
|
2236 | 2556 | return true; |
2237 | 2557 | } |
2238 | 2558 | |
2239 | - if ((error_reporting() != 0) && (error_reporting() != (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE))) { |
|
2559 | + if ((error_reporting() != 0) && (error_reporting() != (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE))) |
|
2560 | + { |
|
2240 | 2561 | echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
2241 | 2562 | } |
2242 | 2563 | }, |
@@ -2244,9 +2565,12 @@ discard block |
||
2244 | 2565 | |
2245 | 2566 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
2246 | 2567 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
2247 | - if (Config::$db_type == 'mysql') { |
|
2568 | + if (Config::$db_type == 'mysql') |
|
2569 | + { |
|
2248 | 2570 | $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
2249 | - } else { |
|
2571 | + } |
|
2572 | + else |
|
2573 | + { |
|
2250 | 2574 | $db_collation = ''; |
2251 | 2575 | } |
2252 | 2576 | |
@@ -2275,37 +2599,46 @@ discard block |
||
2275 | 2599 | |
2276 | 2600 | $done_something = false; |
2277 | 2601 | |
2278 | - foreach ($lines as $line_number => $line) { |
|
2602 | + foreach ($lines as $line_number => $line) |
|
2603 | + { |
|
2279 | 2604 | $do_current = $substep >= $_GET['substep']; |
2280 | 2605 | |
2281 | 2606 | // Get rid of any comments in the beginning of the line... |
2282 | - if (substr(trim($line), 0, 2) === '/*') { |
|
2607 | + if (substr(trim($line), 0, 2) === '/*') |
|
2608 | + { |
|
2283 | 2609 | $line = preg_replace('~/\*.+?\*/~', '', $line); |
2284 | 2610 | } |
2285 | 2611 | |
2286 | 2612 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
2287 | - if ($is_debug && !$support_js && $command_line) { |
|
2613 | + if ($is_debug && !$support_js && $command_line) |
|
2614 | + { |
|
2288 | 2615 | flush(); |
2289 | 2616 | } |
2290 | 2617 | |
2291 | - if (trim($line) === '') { |
|
2618 | + if (trim($line) === '') |
|
2619 | + { |
|
2292 | 2620 | continue; |
2293 | 2621 | } |
2294 | 2622 | |
2295 | - if (trim(substr($line, 0, 3)) === '---') { |
|
2623 | + if (trim(substr($line, 0, 3)) === '---') |
|
2624 | + { |
|
2296 | 2625 | $type = substr($line, 3, 1); |
2297 | 2626 | |
2298 | 2627 | // An error?? |
2299 | - if (trim($current_data) != '' && $type !== '}') { |
|
2628 | + if (trim($current_data) != '' && $type !== '}') |
|
2629 | + { |
|
2300 | 2630 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
2301 | 2631 | |
2302 | - if ($command_line) { |
|
2632 | + if ($command_line) |
|
2633 | + { |
|
2303 | 2634 | echo $upcontext['error_message']; |
2304 | 2635 | } |
2305 | 2636 | } |
2306 | 2637 | |
2307 | - if ($type == ' ') { |
|
2308 | - if (!$support_js && $do_current && $_GET['substep'] != 0 && $command_line) { |
|
2638 | + if ($type == ' ') |
|
2639 | + { |
|
2640 | + if (!$support_js && $do_current && $_GET['substep'] != 0 && $command_line) |
|
2641 | + { |
|
2309 | 2642 | echo ' Successful.', $endl; |
2310 | 2643 | flush(); |
2311 | 2644 | } |
@@ -2314,68 +2647,94 @@ discard block |
||
2314 | 2647 | $upcontext['current_item_num']++; |
2315 | 2648 | $upcontext['current_item_name'] = $last_step; |
2316 | 2649 | |
2317 | - if ($do_current) { |
|
2650 | + if ($do_current) |
|
2651 | + { |
|
2318 | 2652 | $upcontext['actioned_items'][] = $last_step; |
2319 | 2653 | |
2320 | - if ($command_line) { |
|
2654 | + if ($command_line) |
|
2655 | + { |
|
2321 | 2656 | echo ' * '; |
2322 | 2657 | } |
2323 | 2658 | |
2324 | 2659 | // Starting a new main step in our DB changes, so it's time to reset this. |
2325 | 2660 | $upcontext['skip_db_substeps'] = false; |
2326 | 2661 | } |
2327 | - } elseif ($type == '#') { |
|
2662 | + } |
|
2663 | + elseif ($type == '#') |
|
2664 | + { |
|
2328 | 2665 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
2329 | 2666 | |
2330 | 2667 | $upcontext['current_debug_item_num']++; |
2331 | 2668 | |
2332 | - if (trim($line) != '---#') { |
|
2669 | + if (trim($line) != '---#') |
|
2670 | + { |
|
2333 | 2671 | $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
2334 | 2672 | } |
2335 | 2673 | |
2336 | 2674 | // Have we already done something? |
2337 | - if (isset($_GET['xml']) && $done_something) { |
|
2675 | + if (isset($_GET['xml']) && $done_something) |
|
2676 | + { |
|
2338 | 2677 | restore_error_handler(); |
2339 | 2678 | |
2340 | 2679 | return $upcontext['current_debug_item_num'] >= $upcontext['debug_items'] ? true : false; |
2341 | 2680 | } |
2342 | 2681 | |
2343 | - if ($do_current) { |
|
2344 | - if (trim($line) == '---#' && $command_line) { |
|
2682 | + if ($do_current) |
|
2683 | + { |
|
2684 | + if (trim($line) == '---#' && $command_line) |
|
2685 | + { |
|
2345 | 2686 | echo ' done.', $endl; |
2346 | - } elseif ($command_line) { |
|
2687 | + } |
|
2688 | + elseif ($command_line) |
|
2689 | + { |
|
2347 | 2690 | echo ' +++ ', rtrim(substr($line, 4)); |
2348 | - } elseif (trim($line) != '---#') { |
|
2349 | - if ($is_debug) { |
|
2691 | + } |
|
2692 | + elseif (trim($line) != '---#') |
|
2693 | + { |
|
2694 | + if ($is_debug) |
|
2695 | + { |
|
2350 | 2696 | $upcontext['actioned_items'][] = $upcontext['current_debug_item_name']; |
2351 | 2697 | } |
2352 | 2698 | } |
2353 | 2699 | } |
2354 | 2700 | |
2355 | - if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) { |
|
2356 | - if ($command_line) { |
|
2701 | + if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
|
2702 | + { |
|
2703 | + if ($command_line) |
|
2704 | + { |
|
2357 | 2705 | echo ' * '; |
2358 | - } else { |
|
2706 | + } |
|
2707 | + else |
|
2708 | + { |
|
2359 | 2709 | $upcontext['actioned_items'][] = $last_step; |
2360 | 2710 | } |
2361 | 2711 | } |
2362 | 2712 | |
2363 | 2713 | // Small step - only if we're actually doing stuff. |
2364 | - if ($do_current) { |
|
2714 | + if ($do_current) |
|
2715 | + { |
|
2365 | 2716 | nextSubstep(++$substep); |
2366 | - } else { |
|
2717 | + } |
|
2718 | + else |
|
2719 | + { |
|
2367 | 2720 | $substep++; |
2368 | 2721 | } |
2369 | - } elseif ($type == '{') { |
|
2722 | + } |
|
2723 | + elseif ($type == '{') |
|
2724 | + { |
|
2370 | 2725 | $current_type = 'code'; |
2371 | - } elseif ($type == '}') { |
|
2726 | + } |
|
2727 | + elseif ($type == '}') |
|
2728 | + { |
|
2372 | 2729 | $current_type = 'sql'; |
2373 | 2730 | |
2374 | - if (!$do_current || !empty($upcontext['skip_db_substeps'])) { |
|
2731 | + if (!$do_current || !empty($upcontext['skip_db_substeps'])) |
|
2732 | + { |
|
2375 | 2733 | $current_data = ''; |
2376 | 2734 | |
2377 | 2735 | // Avoid confusion when skipping something we normally would have done |
2378 | - if ($do_current) { |
|
2736 | + if ($do_current) |
|
2737 | + { |
|
2379 | 2738 | $done_something = true; |
2380 | 2739 | } |
2381 | 2740 | |
@@ -2383,10 +2742,12 @@ discard block |
||
2383 | 2742 | } |
2384 | 2743 | |
2385 | 2744 | // @todo Update this to a try/catch for PHP 7+, because eval() now throws an exception for parse errors instead of returning false |
2386 | - if (eval('use SMF\Config; use SMF\Utils; use SMF\Lang; use SMF\Db\DatabaseApi as Db; use SMF\Security; global $db_prefix, $modSettings, $smcFunc, $txt, $upcontext, $db_name; ' . $current_data) === false) { |
|
2745 | + if (eval('use SMF\Config; use SMF\Utils; use SMF\Lang; use SMF\Db\DatabaseApi as Db; use SMF\Security; global $db_prefix, $modSettings, $smcFunc, $txt, $upcontext, $db_name; ' . $current_data) === false) |
|
2746 | + { |
|
2387 | 2747 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
2388 | 2748 | |
2389 | - if ($command_line) { |
|
2749 | + if ($command_line) |
|
2750 | + { |
|
2390 | 2751 | echo $upcontext['error_message']; |
2391 | 2752 | } |
2392 | 2753 | } |
@@ -2401,12 +2762,16 @@ discard block |
||
2401 | 2762 | |
2402 | 2763 | $current_data .= $line; |
2403 | 2764 | |
2404 | - if (substr(rtrim($current_data), -1) === ';' && $current_type === 'sql') { |
|
2405 | - if ((!$support_js || isset($_GET['xml']))) { |
|
2406 | - if (!$do_current || !empty($upcontext['skip_db_substeps'])) { |
|
2765 | + if (substr(rtrim($current_data), -1) === ';' && $current_type === 'sql') |
|
2766 | + { |
|
2767 | + if ((!$support_js || isset($_GET['xml']))) |
|
2768 | + { |
|
2769 | + if (!$do_current || !empty($upcontext['skip_db_substeps'])) |
|
2770 | + { |
|
2407 | 2771 | $current_data = ''; |
2408 | 2772 | |
2409 | - if ($do_current) { |
|
2773 | + if ($do_current) |
|
2774 | + { |
|
2410 | 2775 | $done_something = true; |
2411 | 2776 | } |
2412 | 2777 | |
@@ -2436,7 +2801,8 @@ discard block |
||
2436 | 2801 | $current_data = ''; |
2437 | 2802 | } |
2438 | 2803 | // If this is xml based and we're just getting the item name then that's grand. |
2439 | - elseif ($support_js && !isset($_GET['xml']) && $upcontext['current_debug_item_name'] != '' && $do_current) { |
|
2804 | + elseif ($support_js && !isset($_GET['xml']) && $upcontext['current_debug_item_name'] != '' && $do_current) |
|
2805 | + { |
|
2440 | 2806 | restore_error_handler(); |
2441 | 2807 | |
2442 | 2808 | return false; |
@@ -2450,7 +2816,8 @@ discard block |
||
2450 | 2816 | // Put back the error handler. |
2451 | 2817 | restore_error_handler(); |
2452 | 2818 | |
2453 | - if ($command_line) { |
|
2819 | + if ($command_line) |
|
2820 | + { |
|
2454 | 2821 | echo ' Successful.' . "\n"; |
2455 | 2822 | flush(); |
2456 | 2823 | } |
@@ -2473,14 +2840,16 @@ discard block |
||
2473 | 2840 | Db::$unbuffered = false; |
2474 | 2841 | |
2475 | 2842 | // Failure?! |
2476 | - if ($result !== false) { |
|
2843 | + if ($result !== false) |
|
2844 | + { |
|
2477 | 2845 | return $result; |
2478 | 2846 | } |
2479 | 2847 | |
2480 | 2848 | $db_error_message = Db::$db->error(Db::$db_connection); |
2481 | 2849 | |
2482 | 2850 | // If MySQL we do something more clever. |
2483 | - if (Config::$db_type == 'mysql') { |
|
2851 | + if (Config::$db_type == 'mysql') |
|
2852 | + { |
|
2484 | 2853 | $mysqli_errno = mysqli_errno(Db::$db_connection); |
2485 | 2854 | $error_query = in_array(substr(trim($string), 0, 11), ['INSERT INTO', 'UPDATE IGNO', 'ALTER TABLE', 'DROP TABLE ', 'ALTER IGNOR', 'INSERT IGNO']); |
2486 | 2855 | |
@@ -2497,54 +2866,73 @@ discard block |
||
2497 | 2866 | // 1146: Table doesn't exist. |
2498 | 2867 | // 2013: Lost connection to server during query. |
2499 | 2868 | |
2500 | - if ($mysqli_errno == 1016) { |
|
2501 | - if (preg_match('~\'([^\.\']+)~', $db_error_message, $match) != 0 && !empty($match[1])) { |
|
2869 | + if ($mysqli_errno == 1016) |
|
2870 | + { |
|
2871 | + if (preg_match('~\'([^\.\']+)~', $db_error_message, $match) != 0 && !empty($match[1])) |
|
2872 | + { |
|
2502 | 2873 | mysqli_query(Db::$db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
2503 | 2874 | $result = mysqli_query(Db::$db_connection, $string); |
2504 | 2875 | |
2505 | - if ($result !== false) { |
|
2876 | + if ($result !== false) |
|
2877 | + { |
|
2506 | 2878 | return $result; |
2507 | 2879 | } |
2508 | 2880 | } |
2509 | - } elseif ($mysqli_errno == 2013) { |
|
2881 | + } |
|
2882 | + elseif ($mysqli_errno == 2013) |
|
2883 | + { |
|
2510 | 2884 | Db::$db_connection = mysqli_connect(Config::$db_server, Config::$db_user, Config::$db_passwd); |
2511 | 2885 | mysqli_select_db(Db::$db_connection, Config::$db_name); |
2512 | 2886 | |
2513 | - if (Db::$db_connection) { |
|
2887 | + if (Db::$db_connection) |
|
2888 | + { |
|
2514 | 2889 | $result = mysqli_query(Db::$db_connection, $string); |
2515 | 2890 | |
2516 | - if ($result !== false) { |
|
2891 | + if ($result !== false) |
|
2892 | + { |
|
2517 | 2893 | return $result; |
2518 | 2894 | } |
2519 | 2895 | } |
2520 | 2896 | } |
2521 | 2897 | // Duplicate column name... should be okay ;). |
2522 | - elseif (in_array($mysqli_errno, [1060, 1061, 1068, 1091])) { |
|
2898 | + elseif (in_array($mysqli_errno, [1060, 1061, 1068, 1091])) |
|
2899 | + { |
|
2523 | 2900 | return false; |
2524 | 2901 | } |
2525 | 2902 | // Duplicate insert... make sure it's the proper type of query ;). |
2526 | - elseif (in_array($mysqli_errno, [1054, 1062, 1146]) && $error_query) { |
|
2903 | + elseif (in_array($mysqli_errno, [1054, 1062, 1146]) && $error_query) |
|
2904 | + { |
|
2527 | 2905 | return false; |
2528 | 2906 | } |
2529 | 2907 | // Creating an index on a non-existent column. |
2530 | - elseif ($mysqli_errno == 1072) { |
|
2908 | + elseif ($mysqli_errno == 1072) |
|
2909 | + { |
|
2531 | 2910 | return false; |
2532 | - } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
2911 | + } |
|
2912 | + elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
2913 | + { |
|
2533 | 2914 | return false; |
2534 | 2915 | } |
2535 | 2916 | // Testing for legacy tables or columns? Needed for 1.0 & 1.1 scripts. |
2536 | - elseif (in_array($mysqli_errno, [1054, 1146]) && in_array(substr(trim($string), 0, 7), ['SELECT ', 'SHOW CO'])) { |
|
2917 | + elseif (in_array($mysqli_errno, [1054, 1146]) && in_array(substr(trim($string), 0, 7), ['SELECT ', 'SHOW CO'])) |
|
2918 | + { |
|
2537 | 2919 | return false; |
2538 | 2920 | } |
2539 | 2921 | } |
2540 | 2922 | // If a table already exists don't go potty. |
2541 | - else { |
|
2542 | - if (in_array(substr(trim($string), 0, 8), ['CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'])) { |
|
2543 | - if (strpos($db_error_message, 'exist') !== false) { |
|
2923 | + else |
|
2924 | + { |
|
2925 | + if (in_array(substr(trim($string), 0, 8), ['CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'])) |
|
2926 | + { |
|
2927 | + if (strpos($db_error_message, 'exist') !== false) |
|
2928 | + { |
|
2544 | 2929 | return true; |
2545 | 2930 | } |
2546 | - } elseif (strpos(trim($string), 'INSERT ') !== false) { |
|
2547 | - if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) { |
|
2931 | + } |
|
2932 | + elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2933 | + { |
|
2934 | + if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) |
|
2935 | + { |
|
2548 | 2936 | return true; |
2549 | 2937 | } |
2550 | 2938 | } |
@@ -2553,22 +2941,26 @@ discard block |
||
2553 | 2941 | // Get the query string so we pass everything. |
2554 | 2942 | $query_string = ''; |
2555 | 2943 | |
2556 | - foreach ($_GET as $k => $v) { |
|
2944 | + foreach ($_GET as $k => $v) |
|
2945 | + { |
|
2557 | 2946 | $query_string .= ';' . $k . '=' . $v; |
2558 | 2947 | } |
2559 | 2948 | |
2560 | - if (strlen($query_string) != 0) { |
|
2949 | + if (strlen($query_string) != 0) |
|
2950 | + { |
|
2561 | 2951 | $query_string = '?' . substr($query_string, 1); |
2562 | 2952 | } |
2563 | 2953 | |
2564 | - if ($command_line) { |
|
2954 | + if ($command_line) |
|
2955 | + { |
|
2565 | 2956 | echo 'Unsuccessful! Database error message:', "\n", $db_error_message, "\n"; |
2566 | 2957 | |
2567 | 2958 | die; |
2568 | 2959 | } |
2569 | 2960 | |
2570 | 2961 | // Bit of a bodge - do we want the error? |
2571 | - if (!empty($upcontext['return_error'])) { |
|
2962 | + if (!empty($upcontext['return_error'])) |
|
2963 | + { |
|
2572 | 2964 | $upcontext['error_message'] = $db_error_message; |
2573 | 2965 | $upcontext['error_string'] = $string; |
2574 | 2966 | |
@@ -2601,38 +2993,49 @@ discard block |
||
2601 | 2993 | // Firstly, check whether the current index/column exists. |
2602 | 2994 | $found = false; |
2603 | 2995 | |
2604 | - if ($change['type'] === 'column') { |
|
2996 | + if ($change['type'] === 'column') |
|
2997 | + { |
|
2605 | 2998 | $columns = Db::$db->list_columns('{db_prefix}' . $change['table'], true); |
2606 | 2999 | |
2607 | - foreach ($columns as $column) { |
|
3000 | + foreach ($columns as $column) |
|
3001 | + { |
|
2608 | 3002 | // Found it? |
2609 | - if ($column['name'] === $change['name']) { |
|
3003 | + if ($column['name'] === $change['name']) |
|
3004 | + { |
|
2610 | 3005 | $found |= true; |
2611 | 3006 | |
2612 | 3007 | // Do some checks on the data if we have it set. |
2613 | - if (isset($change['col_type'])) { |
|
3008 | + if (isset($change['col_type'])) |
|
3009 | + { |
|
2614 | 3010 | $found &= $change['col_type'] === $column['type']; |
2615 | 3011 | } |
2616 | 3012 | |
2617 | - if (isset($change['null_allowed'])) { |
|
3013 | + if (isset($change['null_allowed'])) |
|
3014 | + { |
|
2618 | 3015 | $found &= $column['null'] == $change['null_allowed']; |
2619 | 3016 | } |
2620 | 3017 | |
2621 | - if (isset($change['default'])) { |
|
3018 | + if (isset($change['default'])) |
|
3019 | + { |
|
2622 | 3020 | $found &= $change['default'] === $column['default']; |
2623 | 3021 | } |
2624 | 3022 | } |
2625 | 3023 | } |
2626 | - } elseif ($change['type'] === 'index') { |
|
3024 | + } |
|
3025 | + elseif ($change['type'] === 'index') |
|
3026 | + { |
|
2627 | 3027 | $request = upgrade_query(' |
2628 | 3028 | SHOW INDEX |
2629 | 3029 | FROM ' . Config::$db_prefix . $change['table']); |
2630 | 3030 | |
2631 | - if ($request !== false) { |
|
3031 | + if ($request !== false) |
|
3032 | + { |
|
2632 | 3033 | $cur_index = []; |
2633 | 3034 | |
2634 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
2635 | - if ($row['Key_name'] === $change['name']) { |
|
3035 | + while ($row = Db::$db->fetch_assoc($request)) |
|
3036 | + { |
|
3037 | + if ($row['Key_name'] === $change['name']) |
|
3038 | + { |
|
2636 | 3039 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2637 | 3040 | } |
2638 | 3041 | } |
@@ -2645,17 +3048,20 @@ discard block |
||
2645 | 3048 | } |
2646 | 3049 | |
2647 | 3050 | // If we're trying to add and it's added, we're done. |
2648 | - if ($found && in_array($change['method'], ['add', 'change'])) { |
|
3051 | + if ($found && in_array($change['method'], ['add', 'change'])) |
|
3052 | + { |
|
2649 | 3053 | return true; |
2650 | 3054 | } |
2651 | 3055 | |
2652 | 3056 | // Otherwise if we're removing and it wasn't found we're also done. |
2653 | - if (!$found && in_array($change['method'], ['remove', 'change_remove'])) { |
|
3057 | + if (!$found && in_array($change['method'], ['remove', 'change_remove'])) |
|
3058 | + { |
|
2654 | 3059 | return true; |
2655 | 3060 | } |
2656 | 3061 | |
2657 | 3062 | // Otherwise is it just a test? |
2658 | - if ($is_test) { |
|
3063 | + if ($is_test) |
|
3064 | + { |
|
2659 | 3065 | return false; |
2660 | 3066 | } |
2661 | 3067 | |
@@ -2663,25 +3069,30 @@ discard block |
||
2663 | 3069 | $running = false; |
2664 | 3070 | $found = false; |
2665 | 3071 | |
2666 | - while (1 == 1) { |
|
3072 | + while (1 == 1) |
|
3073 | + { |
|
2667 | 3074 | $request = upgrade_query(' |
2668 | 3075 | SHOW FULL PROCESSLIST'); |
2669 | 3076 | |
2670 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
2671 | - if (strpos($row['Info'], 'ALTER TABLE ' . Config::$db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
3077 | + while ($row = Db::$db->fetch_assoc($request)) |
|
3078 | + { |
|
3079 | + if (strpos($row['Info'], 'ALTER TABLE ' . Config::$db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
3080 | + { |
|
2672 | 3081 | $found = true; |
2673 | 3082 | } |
2674 | 3083 | } |
2675 | 3084 | |
2676 | 3085 | // Can't find it? Then we need to run it fools! |
2677 | - if (!$found && !$running) { |
|
3086 | + if (!$found && !$running) |
|
3087 | + { |
|
2678 | 3088 | Db::$db->free_result($request); |
2679 | 3089 | |
2680 | 3090 | $success = upgrade_query(' |
2681 | 3091 | ALTER TABLE ' . Config::$db_prefix . $change['table'] . ' |
2682 | 3092 | ' . $change['text'], true) !== false; |
2683 | 3093 | |
2684 | - if (!$success) { |
|
3094 | + if (!$success) |
|
3095 | + { |
|
2685 | 3096 | return false; |
2686 | 3097 | } |
2687 | 3098 | |
@@ -2689,7 +3100,8 @@ discard block |
||
2689 | 3100 | $running = true; |
2690 | 3101 | } |
2691 | 3102 | // What if we've not found it, but we'd ran it already? Must of completed. |
2692 | - elseif (!$found) { |
|
3103 | + elseif (!$found) |
|
3104 | + { |
|
2693 | 3105 | Db::$db->free_result($request); |
2694 | 3106 | |
2695 | 3107 | return true; |
@@ -2725,7 +3137,8 @@ discard block |
||
2725 | 3137 | ], |
2726 | 3138 | ); |
2727 | 3139 | |
2728 | - if (Db::$db->num_rows($request) === 0) { |
|
3140 | + if (Db::$db->num_rows($request) === 0) |
|
3141 | + { |
|
2729 | 3142 | die('Unable to find column ' . $change['column'] . ' inside table ' . Config::$db_prefix . $change['table']); |
2730 | 3143 | } |
2731 | 3144 | $table_row = Db::$db->fetch_assoc($request); |
@@ -2738,7 +3151,8 @@ discard block |
||
2738 | 3151 | $null_fix = strtolower($table_row['Null']) === 'yes' && !$change['null_allowed']; |
2739 | 3152 | |
2740 | 3153 | // Get the character set that goes with the collation of the column. |
2741 | - if ($column_fix && !empty($table_row['Collation'])) { |
|
3154 | + if ($column_fix && !empty($table_row['Collation'])) |
|
3155 | + { |
|
2742 | 3156 | $request = Db::$db->query( |
2743 | 3157 | '', |
2744 | 3158 | 'SHOW COLLATION |
@@ -2750,17 +3164,22 @@ discard block |
||
2750 | 3164 | ); |
2751 | 3165 | |
2752 | 3166 | // No results? Just forget it all together. |
2753 | - if (Db::$db->num_rows($request) === 0) { |
|
3167 | + if (Db::$db->num_rows($request) === 0) |
|
3168 | + { |
|
2754 | 3169 | unset($table_row['Collation']); |
2755 | - } else { |
|
3170 | + } |
|
3171 | + else |
|
3172 | + { |
|
2756 | 3173 | $collation_info = Db::$db->fetch_assoc($request); |
2757 | 3174 | } |
2758 | 3175 | Db::$db->free_result($request); |
2759 | 3176 | } |
2760 | 3177 | |
2761 | - if ($column_fix) { |
|
3178 | + if ($column_fix) |
|
3179 | + { |
|
2762 | 3180 | // Make sure there are no NULL's left. |
2763 | - if ($null_fix) { |
|
3181 | + if ($null_fix) |
|
3182 | + { |
|
2764 | 3183 | Db::$db->query( |
2765 | 3184 | '', |
2766 | 3185 | 'UPDATE {db_prefix}' . $change['table'] . ' |
@@ -2793,12 +3212,15 @@ discard block |
||
2793 | 3212 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2794 | 3213 | global $step_progress, $is_debug, $upcontext; |
2795 | 3214 | |
2796 | - if ($_GET['substep'] < $substep) { |
|
3215 | + if ($_GET['substep'] < $substep) |
|
3216 | + { |
|
2797 | 3217 | $_GET['substep'] = $substep; |
2798 | 3218 | } |
2799 | 3219 | |
2800 | - if ($command_line) { |
|
2801 | - if (time() - $start_time > 1 && empty($is_debug)) { |
|
3220 | + if ($command_line) |
|
3221 | + { |
|
3222 | + if (time() - $start_time > 1 && empty($is_debug)) |
|
3223 | + { |
|
2802 | 3224 | echo '.'; |
2803 | 3225 | $start_time = time(); |
2804 | 3226 | } |
@@ -2808,22 +3230,28 @@ discard block |
||
2808 | 3230 | |
2809 | 3231 | @set_time_limit(300); |
2810 | 3232 | |
2811 | - if (function_exists('apache_reset_timeout')) { |
|
3233 | + if (function_exists('apache_reset_timeout')) |
|
3234 | + { |
|
2812 | 3235 | @apache_reset_timeout(); |
2813 | 3236 | } |
2814 | 3237 | |
2815 | - if (time() - $start_time <= $timeLimitThreshold) { |
|
3238 | + if (time() - $start_time <= $timeLimitThreshold) |
|
3239 | + { |
|
2816 | 3240 | return; |
2817 | 3241 | } |
2818 | 3242 | |
2819 | 3243 | // Do we have some custom step progress stuff? |
2820 | - if (!empty($step_progress)) { |
|
3244 | + if (!empty($step_progress)) |
|
3245 | + { |
|
2821 | 3246 | $upcontext['substep_progress'] = 0; |
2822 | 3247 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2823 | 3248 | |
2824 | - if ($step_progress['current'] > $step_progress['total']) { |
|
3249 | + if ($step_progress['current'] > $step_progress['total']) |
|
3250 | + { |
|
2825 | 3251 | $upcontext['substep_progress'] = 99.9; |
2826 | - } else { |
|
3252 | + } |
|
3253 | + else |
|
3254 | + { |
|
2827 | 3255 | $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
2828 | 3256 | } |
2829 | 3257 | |
@@ -2832,7 +3260,8 @@ discard block |
||
2832 | 3260 | } |
2833 | 3261 | |
2834 | 3262 | // If this is XML we just exit right away! |
2835 | - if (isset($_GET['xml'])) { |
|
3263 | + if (isset($_GET['xml'])) |
|
3264 | + { |
|
2836 | 3265 | return upgradeExit(); |
2837 | 3266 | } |
2838 | 3267 | |
@@ -2841,14 +3270,17 @@ discard block |
||
2841 | 3270 | |
2842 | 3271 | $upcontext['query_string'] = ''; |
2843 | 3272 | |
2844 | - foreach ($_GET as $k => $v) { |
|
2845 | - if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
3273 | + foreach ($_GET as $k => $v) |
|
3274 | + { |
|
3275 | + if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
3276 | + { |
|
2846 | 3277 | $upcontext['query_string'] .= ';' . $k . '=' . $v; |
2847 | 3278 | } |
2848 | 3279 | } |
2849 | 3280 | |
2850 | 3281 | // Custom warning? |
2851 | - if (!empty($custom_warning)) { |
|
3282 | + if (!empty($custom_warning)) |
|
3283 | + { |
|
2852 | 3284 | $upcontext['custom_warning'] = $custom_warning; |
2853 | 3285 | } |
2854 | 3286 | |
@@ -2861,34 +3293,54 @@ discard block |
||
2861 | 3293 | global $is_debug; |
2862 | 3294 | $start_time = time(); |
2863 | 3295 | |
2864 | - while (ob_get_level() > 0) { |
|
3296 | + while (ob_get_level() > 0) |
|
3297 | + { |
|
2865 | 3298 | ob_end_clean(); |
2866 | 3299 | } |
2867 | 3300 | ob_implicit_flush(1); |
2868 | 3301 | |
2869 | - if (!isset($_SERVER['argv'])) { |
|
3302 | + if (!isset($_SERVER['argv'])) |
|
3303 | + { |
|
2870 | 3304 | $_SERVER['argv'] = []; |
2871 | 3305 | } |
2872 | 3306 | $_GET['maint'] = 1; |
2873 | 3307 | |
2874 | - foreach ($_SERVER['argv'] as $i => $arg) { |
|
2875 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
3308 | + foreach ($_SERVER['argv'] as $i => $arg) |
|
3309 | + { |
|
3310 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
3311 | + { |
|
2876 | 3312 | $upcontext['lang'] = $match[1]; |
2877 | - } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
3313 | + } |
|
3314 | + elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
3315 | + { |
|
2878 | 3316 | continue; |
2879 | - } elseif ($arg == '--no-maintenance') { |
|
3317 | + } |
|
3318 | + elseif ($arg == '--no-maintenance') |
|
3319 | + { |
|
2880 | 3320 | $_GET['maint'] = 0; |
2881 | - } elseif ($arg == '--debug') { |
|
3321 | + } |
|
3322 | + elseif ($arg == '--debug') |
|
3323 | + { |
|
2882 | 3324 | $is_debug = true; |
2883 | - } elseif ($arg == '--backup') { |
|
3325 | + } |
|
3326 | + elseif ($arg == '--backup') |
|
3327 | + { |
|
2884 | 3328 | $_POST['backup'] = 1; |
2885 | - } elseif ($arg == '--rebuild-settings') { |
|
3329 | + } |
|
3330 | + elseif ($arg == '--rebuild-settings') |
|
3331 | + { |
|
2886 | 3332 | $_POST['migrateSettings'] = 1; |
2887 | - } elseif ($arg == '--allow-stats') { |
|
3333 | + } |
|
3334 | + elseif ($arg == '--allow-stats') |
|
3335 | + { |
|
2888 | 3336 | $_POST['stats'] = 1; |
2889 | - } elseif ($arg == '--template' && (file_exists(Config::$boarddir . '/template.php') || file_exists(Config::$boarddir . '/template.html') && !file_exists(Config::$modSettings['theme_dir'] . '/converted'))) { |
|
3337 | + } |
|
3338 | + elseif ($arg == '--template' && (file_exists(Config::$boarddir . '/template.php') || file_exists(Config::$boarddir . '/template.html') && !file_exists(Config::$modSettings['theme_dir'] . '/converted'))) |
|
3339 | + { |
|
2890 | 3340 | $_GET['conv'] = 1; |
2891 | - } elseif ($i != 0) { |
|
3341 | + } |
|
3342 | + elseif ($i != 0) |
|
3343 | + { |
|
2892 | 3344 | echo 'SMF Command-line Upgrader |
2893 | 3345 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
2894 | 3346 | |
@@ -2905,11 +3357,13 @@ discard block |
||
2905 | 3357 | } |
2906 | 3358 | } |
2907 | 3359 | |
2908 | - if (!php_version_check()) { |
|
3360 | + if (!php_version_check()) |
|
3361 | + { |
|
2909 | 3362 | print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
2910 | 3363 | } |
2911 | 3364 | |
2912 | - if (!db_version_check()) { |
|
3365 | + if (!db_version_check()) |
|
3366 | + { |
|
2913 | 3367 | print_error('Error: ' . $databases[Config::$db_type]['name'] . ' ' . $databases[Config::$db_type]['version'] . ' does not match minimum requirements.', true); |
2914 | 3368 | } |
2915 | 3369 | |
@@ -2923,7 +3377,8 @@ discard block |
||
2923 | 3377 | $drop = Db::$db->drop_table('{db_prefix}priv_check'); |
2924 | 3378 | |
2925 | 3379 | // Sorry... we need CREATE, ALTER and DROP |
2926 | - if (!$create || !$alter || !$drop) { |
|
3380 | + if (!$create || !$alter || !$drop) |
|
3381 | + { |
|
2927 | 3382 | print_error('The ' . $databases[Config::$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); |
2928 | 3383 | } |
2929 | 3384 | |
@@ -2931,7 +3386,8 @@ discard block |
||
2931 | 3386 | && @file_exists(Config::$sourcedir . '/QueryString.php') |
2932 | 3387 | && @file_exists(Config::$sourcedir . '/Actions/Admin/Boards.php'); |
2933 | 3388 | |
2934 | - if (!$check && !isset(Config::$modSettings['smfVersion'])) { |
|
3389 | + if (!$check && !isset(Config::$modSettings['smfVersion'])) |
|
3390 | + { |
|
2935 | 3391 | print_error('Error: Some files are missing or out-of-date.', true); |
2936 | 3392 | } |
2937 | 3393 | |
@@ -2939,27 +3395,33 @@ discard block |
||
2939 | 3395 | $temp = substr(@implode('', @file(Config::$boarddir . '/index.php')), 0, 4096); |
2940 | 3396 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2941 | 3397 | |
2942 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
3398 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
3399 | + { |
|
2943 | 3400 | print_error('Error: Some files have not yet been updated properly.'); |
2944 | 3401 | } |
2945 | 3402 | |
2946 | 3403 | // Make sure Settings.php is writable. |
2947 | 3404 | quickFileWritable(SMF_SETTINGS_FILE); |
2948 | 3405 | |
2949 | - if (!is_writable(SMF_SETTINGS_FILE)) { |
|
3406 | + if (!is_writable(SMF_SETTINGS_FILE)) |
|
3407 | + { |
|
2950 | 3408 | print_error('Error: Unable to obtain write access to "' . basename(SMF_SETTINGS_FILE) . '".', true); |
2951 | 3409 | } |
2952 | 3410 | |
2953 | 3411 | // Make sure Settings_bak.php is writable. |
2954 | 3412 | quickFileWritable(SMF_SETTINGS_BACKUP_FILE); |
2955 | 3413 | |
2956 | - if (!is_writable(SMF_SETTINGS_BACKUP_FILE)) { |
|
3414 | + if (!is_writable(SMF_SETTINGS_BACKUP_FILE)) |
|
3415 | + { |
|
2957 | 3416 | print_error('Error: Unable to obtain write access to "' . basename(SMF_SETTINGS_BACKUP_FILE) . '".'); |
2958 | 3417 | } |
2959 | 3418 | |
2960 | - if (isset(Config::$modSettings['agreement']) && (!is_writable(Config::$boarddir) || file_exists(Config::$boarddir . '/agreement.txt')) && !is_writable(Config::$boarddir . '/agreement.txt')) { |
|
3419 | + if (isset(Config::$modSettings['agreement']) && (!is_writable(Config::$boarddir) || file_exists(Config::$boarddir . '/agreement.txt')) && !is_writable(Config::$boarddir . '/agreement.txt')) |
|
3420 | + { |
|
2961 | 3421 | print_error('Error: Unable to obtain write access to "agreement.txt".'); |
2962 | - } elseif (isset(Config::$modSettings['agreement'])) { |
|
3422 | + } |
|
3423 | + elseif (isset(Config::$modSettings['agreement'])) |
|
3424 | + { |
|
2963 | 3425 | $fp = fopen(Config::$boarddir . '/agreement.txt', 'w'); |
2964 | 3426 | fwrite($fp, Config::$modSettings['agreement']); |
2965 | 3427 | fclose($fp); |
@@ -2968,42 +3430,51 @@ discard block |
||
2968 | 3430 | // Make sure Themes is writable. |
2969 | 3431 | quickFileWritable(Config::$modSettings['theme_dir']); |
2970 | 3432 | |
2971 | - if (!is_writable(Config::$modSettings['theme_dir']) && !isset(Config::$modSettings['smfVersion'])) { |
|
3433 | + if (!is_writable(Config::$modSettings['theme_dir']) && !isset(Config::$modSettings['smfVersion'])) |
|
3434 | + { |
|
2972 | 3435 | print_error('Error: Unable to obtain write access to "Themes".'); |
2973 | 3436 | } |
2974 | 3437 | |
2975 | 3438 | // Make sure cache directory exists and is writable! |
2976 | 3439 | $cachedir_temp = empty(Config::$cachedir) ? Config::$boarddir . '/cache' : Config::$cachedir; |
2977 | 3440 | |
2978 | - if (!file_exists($cachedir_temp)) { |
|
3441 | + if (!file_exists($cachedir_temp)) |
|
3442 | + { |
|
2979 | 3443 | @mkdir($cachedir_temp); |
2980 | 3444 | } |
2981 | 3445 | |
2982 | 3446 | // Make sure the cache temp dir is writable. |
2983 | 3447 | quickFileWritable($cachedir_temp); |
2984 | 3448 | |
2985 | - if (!is_writable($cachedir_temp)) { |
|
3449 | + if (!is_writable($cachedir_temp)) |
|
3450 | + { |
|
2986 | 3451 | print_error('Error: Unable to obtain write access to "cache".', true); |
2987 | 3452 | } |
2988 | 3453 | |
2989 | 3454 | // Make sure db_last_error.php is writable. |
2990 | 3455 | quickFileWritable($cachedir_temp . '/db_last_error.php'); |
2991 | 3456 | |
2992 | - if (!is_writable($cachedir_temp . '/db_last_error.php')) { |
|
3457 | + if (!is_writable($cachedir_temp . '/db_last_error.php')) |
|
3458 | + { |
|
2993 | 3459 | print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
2994 | 3460 | } |
2995 | 3461 | |
2996 | - if (!file_exists(Config::$modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')) { |
|
3462 | + if (!file_exists(Config::$modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')) |
|
3463 | + { |
|
2997 | 3464 | print_error('Error: Unable to find language files!', true); |
2998 | - } else { |
|
3465 | + } |
|
3466 | + else |
|
3467 | + { |
|
2999 | 3468 | $temp = substr(@implode('', @file(Config::$modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
3000 | 3469 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
3001 | 3470 | |
3002 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
3471 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
3472 | + { |
|
3003 | 3473 | print_error('Error: Language files out of date.', true); |
3004 | 3474 | } |
3005 | 3475 | |
3006 | - if (!file_exists(Config::$modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
3476 | + if (!file_exists(Config::$modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
3477 | + { |
|
3007 | 3478 | print_error('Error: Install language is missing for selected language.', true); |
3008 | 3479 | } |
3009 | 3480 | |
@@ -3021,10 +3492,14 @@ discard block |
||
3021 | 3492 | quickFileWritable($custom_av_dir); |
3022 | 3493 | |
3023 | 3494 | // Are we good now? |
3024 | - if (!is_writable($custom_av_dir)) { |
|
3495 | + if (!is_writable($custom_av_dir)) |
|
3496 | + { |
|
3025 | 3497 | print_error(sprintf(Lang::$txt['error_dir_not_writable'], $custom_av_dir)); |
3026 | - } elseif ($need_settings_update) { |
|
3027 | - if (!function_exists('cache_put_data')) { |
|
3498 | + } |
|
3499 | + elseif ($need_settings_update) |
|
3500 | + { |
|
3501 | + if (!function_exists('cache_put_data')) |
|
3502 | + { |
|
3028 | 3503 | require_once Config::$sourcedir . '/Cache/CacheApi.php'; |
3029 | 3504 | } |
3030 | 3505 | |
@@ -3049,8 +3524,10 @@ discard block |
||
3049 | 3524 | global $command_line, $support_js; |
3050 | 3525 | |
3051 | 3526 | // Done it already? |
3052 | - if (!empty($_POST['utf8_done'])) { |
|
3053 | - if ($command_line) { |
|
3527 | + if (!empty($_POST['utf8_done'])) |
|
3528 | + { |
|
3529 | + if ($command_line) |
|
3530 | + { |
|
3054 | 3531 | return DeleteUpgrade(); |
3055 | 3532 | } |
3056 | 3533 | |
@@ -3058,7 +3535,8 @@ discard block |
||
3058 | 3535 | } |
3059 | 3536 | |
3060 | 3537 | // First make sure they aren't already on UTF-8 before we go anywhere... |
3061 | - if (Config::$db_type == 'postgresql' || (Config::$db_character_set === 'utf8' && !empty(Config::$modSettings['global_character_set']) && Config::$modSettings['global_character_set'] === 'UTF-8')) { |
|
3538 | + if (Config::$db_type == 'postgresql' || (Config::$db_character_set === 'utf8' && !empty(Config::$modSettings['global_character_set']) && Config::$modSettings['global_character_set'] === 'UTF-8')) |
|
3539 | + { |
|
3062 | 3540 | Db::$db->insert( |
3063 | 3541 | 'replace', |
3064 | 3542 | '{db_prefix}settings', |
@@ -3067,7 +3545,8 @@ discard block |
||
3067 | 3545 | ['variable'], |
3068 | 3546 | ); |
3069 | 3547 | |
3070 | - if ($command_line) { |
|
3548 | + if ($command_line) |
|
3549 | + { |
|
3071 | 3550 | return DeleteUpgrade(); |
3072 | 3551 | } |
3073 | 3552 | |
@@ -3119,7 +3598,8 @@ discard block |
||
3119 | 3598 | ); |
3120 | 3599 | $db_charsets = []; |
3121 | 3600 | |
3122 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
3601 | + while ($row = Db::$db->fetch_assoc($request)) |
|
3602 | + { |
|
3123 | 3603 | $db_charsets[] = $row['Charset']; |
3124 | 3604 | } |
3125 | 3605 | |
@@ -3157,21 +3637,26 @@ discard block |
||
3157 | 3637 | $upcontext['dropping_index'] = false; |
3158 | 3638 | |
3159 | 3639 | // If there's a fulltext index, we need to drop it first... |
3160 | - if ($request !== false || Db::$db->num_rows($request) != 0) { |
|
3161 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
3162 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) { |
|
3640 | + if ($request !== false || Db::$db->num_rows($request) != 0) |
|
3641 | + { |
|
3642 | + while ($row = Db::$db->fetch_assoc($request)) |
|
3643 | + { |
|
3644 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
3645 | + { |
|
3163 | 3646 | $upcontext['fulltext_index'][] = $row['Key_name']; |
3164 | 3647 | } |
3165 | 3648 | } |
3166 | 3649 | Db::$db->free_result($request); |
3167 | 3650 | |
3168 | - if (isset($upcontext['fulltext_index'])) { |
|
3651 | + if (isset($upcontext['fulltext_index'])) |
|
3652 | + { |
|
3169 | 3653 | $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
3170 | 3654 | } |
3171 | 3655 | } |
3172 | 3656 | |
3173 | 3657 | // Drop it and make a note... |
3174 | - if (!empty($upcontext['fulltext_index'])) { |
|
3658 | + if (!empty($upcontext['fulltext_index'])) |
|
3659 | + { |
|
3175 | 3660 | $upcontext['dropping_index'] = true; |
3176 | 3661 | |
3177 | 3662 | Db::$db->query( |
@@ -3353,11 +3838,13 @@ discard block |
||
3353 | 3838 | ]; |
3354 | 3839 | |
3355 | 3840 | // Make some preparations. |
3356 | - if (isset($translation_tables[$upcontext['charset_detected']])) { |
|
3841 | + if (isset($translation_tables[$upcontext['charset_detected']])) |
|
3842 | + { |
|
3357 | 3843 | $replace = '%field%'; |
3358 | 3844 | |
3359 | 3845 | // Build a huge REPLACE statement... |
3360 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
3846 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
3847 | + { |
|
3361 | 3848 | $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
3362 | 3849 | } |
3363 | 3850 | } |
@@ -3365,15 +3852,18 @@ discard block |
||
3365 | 3852 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
3366 | 3853 | $queryTables = Db::$db->list_tables(false, Config::$db_prefix . '%'); |
3367 | 3854 | |
3368 | - $queryTables = array_values(array_filter($queryTables, function ($v) { |
|
3855 | + $queryTables = array_values(array_filter($queryTables, function ($v) |
|
3856 | + { |
|
3369 | 3857 | return stripos($v, 'backup_') !== 0; |
3370 | 3858 | })); |
3371 | 3859 | |
3372 | 3860 | $upcontext['table_count'] = count($queryTables); |
3373 | 3861 | |
3374 | 3862 | // What ones have we already done? |
3375 | - foreach ($queryTables as $id => $table) { |
|
3376 | - if ($id < $_GET['substep']) { |
|
3863 | + foreach ($queryTables as $id => $table) |
|
3864 | + { |
|
3865 | + if ($id < $_GET['substep']) |
|
3866 | + { |
|
3377 | 3867 | $upcontext['previous_tables'][] = $table; |
3378 | 3868 | } |
3379 | 3869 | } |
@@ -3383,14 +3873,16 @@ discard block |
||
3383 | 3873 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
3384 | 3874 | |
3385 | 3875 | // Make sure we're ready & have painted the template before proceeding |
3386 | - if ($support_js && !isset($_GET['xml'])) { |
|
3876 | + if ($support_js && !isset($_GET['xml'])) |
|
3877 | + { |
|
3387 | 3878 | $_GET['substep'] = 0; |
3388 | 3879 | |
3389 | 3880 | return false; |
3390 | 3881 | } |
3391 | 3882 | |
3392 | 3883 | // We want to start at the first table. |
3393 | - for ($substep = $_GET['substep'], $n = count($queryTables); $substep < $n; $substep++) { |
|
3884 | + for ($substep = $_GET['substep'], $n = count($queryTables); $substep < $n; $substep++) |
|
3885 | + { |
|
3394 | 3886 | $table = $queryTables[$substep]; |
3395 | 3887 | |
3396 | 3888 | $getTableStatus = Db::$db->query( |
@@ -3414,7 +3906,8 @@ discard block |
||
3414 | 3906 | nextSubstep($substep); |
3415 | 3907 | |
3416 | 3908 | // Just to make sure it doesn't time out. |
3417 | - if (function_exists('apache_reset_timeout')) { |
|
3909 | + if (function_exists('apache_reset_timeout')) |
|
3910 | + { |
|
3418 | 3911 | @apache_reset_timeout(); |
3419 | 3912 | } |
3420 | 3913 | |
@@ -3429,17 +3922,22 @@ discard block |
||
3429 | 3922 | ], |
3430 | 3923 | ); |
3431 | 3924 | |
3432 | - while ($column_info = Db::$db->fetch_assoc($queryColumns)) { |
|
3925 | + while ($column_info = Db::$db->fetch_assoc($queryColumns)) |
|
3926 | + { |
|
3433 | 3927 | // Only text'ish columns have a character set and need converting. |
3434 | - if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) { |
|
3928 | + if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
3929 | + { |
|
3435 | 3930 | $collation = empty($column_info['Collation']) || $column_info['Collation'] === 'NULL' ? $table_info['Collation'] : $column_info['Collation']; |
3436 | 3931 | |
3437 | - if (!empty($collation) && $collation !== 'NULL') { |
|
3932 | + if (!empty($collation) && $collation !== 'NULL') |
|
3933 | + { |
|
3438 | 3934 | list($charset) = explode('_', $collation); |
3439 | 3935 | |
3440 | 3936 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
3441 | - if ($charset != 'utf8') { |
|
3442 | - if (!isset($table_charsets[$charset])) { |
|
3937 | + if ($charset != 'utf8') |
|
3938 | + { |
|
3939 | + if (!isset($table_charsets[$charset])) |
|
3940 | + { |
|
3443 | 3941 | $table_charsets[$charset] = []; |
3444 | 3942 | } |
3445 | 3943 | |
@@ -3451,13 +3949,17 @@ discard block |
||
3451 | 3949 | Db::$db->free_result($queryColumns); |
3452 | 3950 | |
3453 | 3951 | // Only change the non-utf8 columns identified above |
3454 | - if (count($table_charsets) > 0) { |
|
3952 | + if (count($table_charsets) > 0) |
|
3953 | + { |
|
3455 | 3954 | $updates_blob = ''; |
3456 | 3955 | $updates_text = ''; |
3457 | 3956 | |
3458 | - foreach ($table_charsets as $charset => $columns) { |
|
3459 | - if ($charset !== $charsets[$upcontext['charset_detected']]) { |
|
3460 | - foreach ($columns as $column) { |
|
3957 | + foreach ($table_charsets as $charset => $columns) |
|
3958 | + { |
|
3959 | + if ($charset !== $charsets[$upcontext['charset_detected']]) |
|
3960 | + { |
|
3961 | + foreach ($columns as $column) |
|
3962 | + { |
|
3461 | 3963 | $updates_blob .= ' |
3462 | 3964 | CHANGE COLUMN `' . $column['Field'] . '` `' . $column['Field'] . '` ' . strtr($column['Type'], ['text' => 'blob', 'char' => 'binary']) . ($column['Null'] === 'YES' ? ' NULL' : ' NOT NULL') . (strpos($column['Type'], 'char') === false ? '' : ' default \'' . $column['Default'] . '\'') . ','; |
3463 | 3965 | $updates_text .= ' |
@@ -3477,11 +3979,14 @@ discard block |
||
3477 | 3979 | ); |
3478 | 3980 | |
3479 | 3981 | // Convert the character set if MySQL has no native support for it. |
3480 | - if (isset($translation_tables[$upcontext['charset_detected']])) { |
|
3982 | + if (isset($translation_tables[$upcontext['charset_detected']])) |
|
3983 | + { |
|
3481 | 3984 | $update = ''; |
3482 | 3985 | |
3483 | - foreach ($table_charsets as $charset => $columns) { |
|
3484 | - foreach ($columns as $column) { |
|
3986 | + foreach ($table_charsets as $charset => $columns) |
|
3987 | + { |
|
3988 | + foreach ($columns as $column) |
|
3989 | + { |
|
3485 | 3990 | $update .= ' |
3486 | 3991 | ' . $column['Field'] . ' = ' . strtr($replace, ['%field%' => $column['Field']]) . ','; |
3487 | 3992 | } |
@@ -3510,8 +4015,10 @@ discard block |
||
3510 | 4015 | } |
3511 | 4016 | |
3512 | 4017 | // Now do the actual conversion (if still needed). |
3513 | - if ($charsets[$upcontext['charset_detected']] !== 'utf8') { |
|
3514 | - if ($command_line) { |
|
4018 | + if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
|
4019 | + { |
|
4020 | + if ($command_line) |
|
4021 | + { |
|
3515 | 4022 | echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
3516 | 4023 | } |
3517 | 4024 | |
@@ -3524,13 +4031,15 @@ discard block |
||
3524 | 4031 | ], |
3525 | 4032 | ); |
3526 | 4033 | |
3527 | - if ($command_line) { |
|
4034 | + if ($command_line) |
|
4035 | + { |
|
3528 | 4036 | echo " done.\n"; |
3529 | 4037 | } |
3530 | 4038 | } |
3531 | 4039 | |
3532 | 4040 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3533 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
4041 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
4042 | + { |
|
3534 | 4043 | return upgradeExit(); |
3535 | 4044 | } |
3536 | 4045 | } |
@@ -3561,8 +4070,10 @@ discard block |
||
3561 | 4070 | ], |
3562 | 4071 | ); |
3563 | 4072 | |
3564 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
3565 | - if (@Utils::safeUnserialize($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) { |
|
4073 | + while ($row = Db::$db->fetch_assoc($request)) |
|
4074 | + { |
|
4075 | + if (@Utils::safeUnserialize($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) |
|
4076 | + { |
|
3566 | 4077 | Db::$db->query( |
3567 | 4078 | '', |
3568 | 4079 | 'UPDATE {db_prefix}log_actions |
@@ -3577,14 +4088,16 @@ discard block |
||
3577 | 4088 | } |
3578 | 4089 | Db::$db->free_result($request); |
3579 | 4090 | |
3580 | - if ($upcontext['dropping_index'] && $command_line) { |
|
4091 | + if ($upcontext['dropping_index'] && $command_line) |
|
4092 | + { |
|
3581 | 4093 | echo "\n" . '', Lang::$txt['upgrade_fulltext_error'], ''; |
3582 | 4094 | flush(); |
3583 | 4095 | } |
3584 | 4096 | |
3585 | 4097 | |
3586 | 4098 | // Make sure we move on! |
3587 | - if ($command_line) { |
|
4099 | + if ($command_line) |
|
4100 | + { |
|
3588 | 4101 | return DeleteUpgrade(); |
3589 | 4102 | } |
3590 | 4103 | |
@@ -3601,25 +4114,32 @@ discard block |
||
3601 | 4114 | */ |
3602 | 4115 | function upgrade_unserialize($string) |
3603 | 4116 | { |
3604 | - if (!is_string($string)) { |
|
4117 | + if (!is_string($string)) |
|
4118 | + { |
|
3605 | 4119 | $data = false; |
3606 | 4120 | } |
3607 | 4121 | // Might be JSON already. |
3608 | - elseif (strpos($string, '{') === 0) { |
|
4122 | + elseif (strpos($string, '{') === 0) |
|
4123 | + { |
|
3609 | 4124 | $data = @json_decode($string, true); |
3610 | 4125 | |
3611 | - if (is_null($data)) { |
|
4126 | + if (is_null($data)) |
|
4127 | + { |
|
3612 | 4128 | $data = false; |
3613 | 4129 | } |
3614 | - } elseif (in_array(substr($string, 0, 2), ['b:', 'i:', 'd:', 's:', 'a:', 'N;'])) { |
|
4130 | + } |
|
4131 | + elseif (in_array(substr($string, 0, 2), ['b:', 'i:', 'd:', 's:', 'a:', 'N;'])) |
|
4132 | + { |
|
3615 | 4133 | $data = @Utils::safeUnserialize($string); |
3616 | 4134 | |
3617 | 4135 | // The serialized data is broken. |
3618 | - if ($data === false) { |
|
4136 | + if ($data === false) |
|
4137 | + { |
|
3619 | 4138 | // This bit fixes incorrect string lengths, which can happen if the character encoding was changed (e.g. conversion to UTF-8) |
3620 | 4139 | $new_string = preg_replace_callback( |
3621 | 4140 | '~\bs:(\d+):"(.*?)";(?=$|[bidsaO]:|[{}}]|N;)~s', |
3622 | - function ($matches) { |
|
4141 | + function ($matches) |
|
4142 | + { |
|
3623 | 4143 | return 's:' . strlen($matches[2]) . ':"' . $matches[2] . '";'; |
3624 | 4144 | }, |
3625 | 4145 | $string, |
@@ -3632,7 +4152,8 @@ discard block |
||
3632 | 4152 | } |
3633 | 4153 | } |
3634 | 4154 | // Just a plain string, then. |
3635 | - else { |
|
4155 | + else |
|
4156 | + { |
|
3636 | 4157 | $data = false; |
3637 | 4158 | } |
3638 | 4159 | |
@@ -3646,8 +4167,10 @@ discard block |
||
3646 | 4167 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'serialize_json_xml' : 'serialize_json'; |
3647 | 4168 | |
3648 | 4169 | // First thing's first - did we already do this? |
3649 | - if (!empty(Config::$modSettings['json_done'])) { |
|
3650 | - if ($command_line) { |
|
4170 | + if (!empty(Config::$modSettings['json_done'])) |
|
4171 | + { |
|
4172 | + if ($command_line) |
|
4173 | + { |
|
3651 | 4174 | return ConvertUtf8(); |
3652 | 4175 | } |
3653 | 4176 | |
@@ -3655,12 +4178,14 @@ discard block |
||
3655 | 4178 | } |
3656 | 4179 | |
3657 | 4180 | // Needed when writing settings |
3658 | - if (!function_exists('cache_put_data')) { |
|
4181 | + if (!function_exists('cache_put_data')) |
|
4182 | + { |
|
3659 | 4183 | require_once Config::$sourcedir . '/Cache/CacheApi.php'; |
3660 | 4184 | } |
3661 | 4185 | |
3662 | 4186 | // Done it already - js wise? |
3663 | - if (!empty($_POST['json_done'])) { |
|
4187 | + if (!empty($_POST['json_done'])) |
|
4188 | + { |
|
3664 | 4189 | Config::updateModSettings(['json_done' => true]); |
3665 | 4190 | |
3666 | 4191 | return true; |
@@ -3696,19 +4221,24 @@ discard block |
||
3696 | 4221 | $upcontext['cur_table_name'] = $keys[$_GET['substep']] ?? $keys[0]; |
3697 | 4222 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
3698 | 4223 | |
3699 | - foreach ($keys as $id => $table) { |
|
3700 | - if ($id < $_GET['substep']) { |
|
4224 | + foreach ($keys as $id => $table) |
|
4225 | + { |
|
4226 | + if ($id < $_GET['substep']) |
|
4227 | + { |
|
3701 | 4228 | $upcontext['previous_tables'][] = $table; |
3702 | 4229 | } |
3703 | 4230 | } |
3704 | 4231 | |
3705 | - if ($command_line) { |
|
4232 | + if ($command_line) |
|
4233 | + { |
|
3706 | 4234 | echo 'Converting data from serialize() to json_encode().'; |
3707 | 4235 | } |
3708 | 4236 | |
3709 | - if (!$support_js || isset($_GET['xml'])) { |
|
4237 | + if (!$support_js || isset($_GET['xml'])) |
|
4238 | + { |
|
3710 | 4239 | // Fix the data in each table |
3711 | - for ($substep = $_GET['substep']; $substep < $upcontext['table_count']; $substep++) { |
|
4240 | + for ($substep = $_GET['substep']; $substep < $upcontext['table_count']; $substep++) |
|
4241 | + { |
|
3712 | 4242 | $upcontext['cur_table_name'] = $keys[$substep + 1] ?? $keys[$substep]; |
3713 | 4243 | $upcontext['cur_table_num'] = $substep + 1; |
3714 | 4244 | |
@@ -3724,7 +4254,8 @@ discard block |
||
3724 | 4254 | $info = $tables[$table]; |
3725 | 4255 | |
3726 | 4256 | // Now the fun - build our queries and all that fun stuff |
3727 | - if ($table == 'settings') { |
|
4257 | + if ($table == 'settings') |
|
4258 | + { |
|
3728 | 4259 | // Now a few settings... |
3729 | 4260 | $serialized_settings = [ |
3730 | 4261 | 'attachment_basedirectories', |
@@ -3742,18 +4273,24 @@ discard block |
||
3742 | 4273 | // Loop through and fix these... |
3743 | 4274 | $new_settings = []; |
3744 | 4275 | |
3745 | - if ($command_line) { |
|
4276 | + if ($command_line) |
|
4277 | + { |
|
3746 | 4278 | echo "\n" . 'Fixing some settings...'; |
3747 | 4279 | } |
3748 | 4280 | |
3749 | - foreach ($serialized_settings as $var) { |
|
3750 | - if (isset(Config::$modSettings[$var])) { |
|
4281 | + foreach ($serialized_settings as $var) |
|
4282 | + { |
|
4283 | + if (isset(Config::$modSettings[$var])) |
|
4284 | + { |
|
3751 | 4285 | // Attempt to unserialize the setting |
3752 | 4286 | $temp = upgrade_unserialize(Config::$modSettings[$var]); |
3753 | 4287 | |
3754 | - if (!$temp && $command_line) { |
|
4288 | + if (!$temp && $command_line) |
|
4289 | + { |
|
3755 | 4290 | echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
3756 | - } elseif ($temp !== false) { |
|
4291 | + } |
|
4292 | + elseif ($temp !== false) |
|
4293 | + { |
|
3757 | 4294 | $new_settings[$var] = json_encode($temp); |
3758 | 4295 | } |
3759 | 4296 | } |
@@ -3762,10 +4299,13 @@ discard block |
||
3762 | 4299 | // Update everything at once |
3763 | 4300 | Config::updateModSettings($new_settings, true); |
3764 | 4301 | |
3765 | - if ($command_line) { |
|
4302 | + if ($command_line) |
|
4303 | + { |
|
3766 | 4304 | echo ' done.'; |
3767 | 4305 | } |
3768 | - } elseif ($table == 'themes') { |
|
4306 | + } |
|
4307 | + elseif ($table == 'themes') |
|
4308 | + { |
|
3769 | 4309 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3770 | 4310 | $query = Db::$db->query( |
3771 | 4311 | '', |
@@ -3776,19 +4316,26 @@ discard block |
||
3776 | 4316 | ], |
3777 | 4317 | ); |
3778 | 4318 | |
3779 | - if (Db::$db->num_rows($query) != 0) { |
|
3780 | - while ($row = Db::$db->fetch_assoc($query)) { |
|
4319 | + if (Db::$db->num_rows($query) != 0) |
|
4320 | + { |
|
4321 | + while ($row = Db::$db->fetch_assoc($query)) |
|
4322 | + { |
|
3781 | 4323 | $temp = upgrade_unserialize($row['value']); |
3782 | 4324 | |
3783 | - if ($command_line) { |
|
3784 | - if ($temp === false) { |
|
4325 | + if ($command_line) |
|
4326 | + { |
|
4327 | + if ($temp === false) |
|
4328 | + { |
|
3785 | 4329 | echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
3786 | - } else { |
|
4330 | + } |
|
4331 | + else |
|
4332 | + { |
|
3787 | 4333 | echo "\n" . 'Fixing admin preferences...'; |
3788 | 4334 | } |
3789 | 4335 | } |
3790 | 4336 | |
3791 | - if ($temp !== false) { |
|
4337 | + if ($temp !== false) |
|
4338 | + { |
|
3792 | 4339 | $row['value'] = json_encode($temp); |
3793 | 4340 | |
3794 | 4341 | // Even though we have all values from the table, UPDATE is still faster than REPLACE |
@@ -3807,7 +4354,8 @@ discard block |
||
3807 | 4354 | ], |
3808 | 4355 | ); |
3809 | 4356 | |
3810 | - if ($command_line) { |
|
4357 | + if ($command_line) |
|
4358 | + { |
|
3811 | 4359 | echo ' done.'; |
3812 | 4360 | } |
3813 | 4361 | } |
@@ -3815,16 +4363,21 @@ discard block |
||
3815 | 4363 | |
3816 | 4364 | Db::$db->free_result($query); |
3817 | 4365 | } |
3818 | - } else { |
|
4366 | + } |
|
4367 | + else |
|
4368 | + { |
|
3819 | 4369 | // First item is always the key... |
3820 | 4370 | $key = $info[0]; |
3821 | 4371 | unset($info[0]); |
3822 | 4372 | |
3823 | 4373 | // Now we know what columns we have and such... |
3824 | - if (count($info) == 2 && $info[2] === true) { |
|
4374 | + if (count($info) == 2 && $info[2] === true) |
|
4375 | + { |
|
3825 | 4376 | $col_select = $info[1]; |
3826 | 4377 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3827 | - } else { |
|
4378 | + } |
|
4379 | + else |
|
4380 | + { |
|
3828 | 4381 | $col_select = implode(', ', $info); |
3829 | 4382 | } |
3830 | 4383 | |
@@ -3835,25 +4388,32 @@ discard block |
||
3835 | 4388 | [], |
3836 | 4389 | ); |
3837 | 4390 | |
3838 | - if (Db::$db->num_rows($query) != 0) { |
|
3839 | - if ($command_line) { |
|
4391 | + if (Db::$db->num_rows($query) != 0) |
|
4392 | + { |
|
4393 | + if ($command_line) |
|
4394 | + { |
|
3840 | 4395 | echo "\n" . ' +++ Fixing the "' . $table . '" table...'; |
3841 | 4396 | flush(); |
3842 | 4397 | } |
3843 | 4398 | |
3844 | - while ($row = Db::$db->fetch_assoc($query)) { |
|
4399 | + while ($row = Db::$db->fetch_assoc($query)) |
|
4400 | + { |
|
3845 | 4401 | $update = ''; |
3846 | 4402 | |
3847 | 4403 | // We already know what our key is... |
3848 | - foreach ($info as $col) { |
|
3849 | - if ($col !== true && $row[$col] != '') { |
|
4404 | + foreach ($info as $col) |
|
4405 | + { |
|
4406 | + if ($col !== true && $row[$col] != '') |
|
4407 | + { |
|
3850 | 4408 | $temp = upgrade_unserialize($row[$col]); |
3851 | 4409 | |
3852 | 4410 | // Oh well... |
3853 | - if ($temp === false) { |
|
4411 | + if ($temp === false) |
|
4412 | + { |
|
3854 | 4413 | $temp = []; |
3855 | 4414 | |
3856 | - if ($command_line) { |
|
4415 | + if ($command_line) |
|
4416 | + { |
|
3857 | 4417 | echo "\nFailed to unserialize " . $row[$col] . ". Setting to empty value.\n"; |
3858 | 4418 | } |
3859 | 4419 | } |
@@ -3869,7 +4429,8 @@ discard block |
||
3869 | 4429 | $vars[$key] = $row[$key]; |
3870 | 4430 | |
3871 | 4431 | // In a few cases, we might have empty data, so don't try to update in those situations... |
3872 | - if (!empty($update)) { |
|
4432 | + if (!empty($update)) |
|
4433 | + { |
|
3873 | 4434 | Db::$db->query( |
3874 | 4435 | '', |
3875 | 4436 | 'UPDATE {db_prefix}' . $table . ' |
@@ -3880,7 +4441,8 @@ discard block |
||
3880 | 4441 | } |
3881 | 4442 | } |
3882 | 4443 | |
3883 | - if ($command_line) { |
|
4444 | + if ($command_line) |
|
4445 | + { |
|
3884 | 4446 | echo ' done.'; |
3885 | 4447 | } |
3886 | 4448 | |
@@ -3890,12 +4452,14 @@ discard block |
||
3890 | 4452 | } |
3891 | 4453 | |
3892 | 4454 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3893 | - if (isset($_GET['xml'])) { |
|
4455 | + if (isset($_GET['xml'])) |
|
4456 | + { |
|
3894 | 4457 | return upgradeExit(); |
3895 | 4458 | } |
3896 | 4459 | } |
3897 | 4460 | |
3898 | - if ($command_line) { |
|
4461 | + if ($command_line) |
|
4462 | + { |
|
3899 | 4463 | echo "\n" . 'Successful.' . "\n"; |
3900 | 4464 | flush(); |
3901 | 4465 | } |
@@ -3907,7 +4471,8 @@ discard block |
||
3907 | 4471 | $_GET['substep'] = 0; |
3908 | 4472 | |
3909 | 4473 | // Make sure we move on! |
3910 | - if ($command_line) { |
|
4474 | + if ($command_line) |
|
4475 | + { |
|
3911 | 4476 | return ConvertUtf8(); |
3912 | 4477 | } |
3913 | 4478 | |
@@ -3930,19 +4495,22 @@ discard block |
||
3930 | 4495 | global $upcontext, $settings; |
3931 | 4496 | |
3932 | 4497 | // Don't call me twice! |
3933 | - if (!empty($upcontext['chmod_called'])) { |
|
4498 | + if (!empty($upcontext['chmod_called'])) |
|
4499 | + { |
|
3934 | 4500 | return; |
3935 | 4501 | } |
3936 | 4502 | |
3937 | 4503 | $upcontext['chmod_called'] = true; |
3938 | 4504 | |
3939 | 4505 | // Nothing? |
3940 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
4506 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
4507 | + { |
|
3941 | 4508 | return; |
3942 | 4509 | } |
3943 | 4510 | |
3944 | 4511 | // Was it a problem with Windows? |
3945 | - if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') { |
|
4512 | + if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
|
4513 | + { |
|
3946 | 4514 | echo ' |
3947 | 4515 | <div class="error"> |
3948 | 4516 | <p>', Lang::$txt['upgrade_writable_files'], '</p> |
@@ -3970,7 +4538,8 @@ discard block |
||
3970 | 4538 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>', Lang::$txt['upgrade_ftp_files'], '</h4>\n\t\t\t\'); |
3971 | 4539 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
3972 | 4540 | |
3973 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
4541 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
4542 | + { |
|
3974 | 4543 | echo ' |
3975 | 4544 | content.write(\'<hr>\n\t\t\t\'); |
3976 | 4545 | content.write(\'<p>', Lang::$txt['upgrade_ftp_shell'], '</p>\n\t\t\t\'); |
@@ -3983,7 +4552,8 @@ discard block |
||
3983 | 4552 | } |
3984 | 4553 | </script>'; |
3985 | 4554 | |
3986 | - if (!empty($upcontext['chmod']['ftp_error'])) { |
|
4555 | + if (!empty($upcontext['chmod']['ftp_error'])) |
|
4556 | + { |
|
3987 | 4557 | echo ' |
3988 | 4558 | <div class="error"> |
3989 | 4559 | <p>', Lang::$txt['upgrade_ftp_error'], '<p> |
@@ -3991,7 +4561,8 @@ discard block |
||
3991 | 4561 | </div>'; |
3992 | 4562 | } |
3993 | 4563 | |
3994 | - if (empty($upcontext['chmod_in_form'])) { |
|
4564 | + if (empty($upcontext['chmod_in_form'])) |
|
4565 | + { |
|
3995 | 4566 | echo ' |
3996 | 4567 | <form action="', $upcontext['form_url'], '" method="post">'; |
3997 | 4568 | } |
@@ -4036,7 +4607,8 @@ discard block |
||
4036 | 4607 | <input type="submit" value="', Lang::$txt['ftp_connect'], '" class="button"> |
4037 | 4608 | </div>'; |
4038 | 4609 | |
4039 | - if (empty($upcontext['chmod_in_form'])) { |
|
4610 | + if (empty($upcontext['chmod_in_form'])) |
|
4611 | + { |
|
4040 | 4612 | echo ' |
4041 | 4613 | </form>'; |
4042 | 4614 | } |
@@ -4098,7 +4670,8 @@ discard block |
||
4098 | 4670 | <h2>', Lang::$txt['upgrade_progress'], '</h2> |
4099 | 4671 | <ul class="steps_list">'; |
4100 | 4672 | |
4101 | - foreach ($upcontext['steps'] as $num => $step) { |
|
4673 | + foreach ($upcontext['steps'] as $num => $step) |
|
4674 | + { |
|
4102 | 4675 | echo ' |
4103 | 4676 | <li', $num == $upcontext['current_step'] ? ' class="stepcurrent"' : '', '> |
4104 | 4677 | ', Lang::$txt['upgrade_step'], ' ', $step[0], ': ', Lang::$txt[$step[1]], ' |
@@ -4116,7 +4689,8 @@ discard block |
||
4116 | 4689 | <span id="overall_text">', $upcontext['overall_percent'], '%</span> |
4117 | 4690 | </div>'; |
4118 | 4691 | |
4119 | - if (isset($upcontext['step_progress'])) { |
|
4692 | + if (isset($upcontext['step_progress'])) |
|
4693 | + { |
|
4120 | 4694 | echo ' |
4121 | 4695 | <div id="progress_bar_step" class="progress_bar progress_yellow"> |
4122 | 4696 | <h3>', Lang::$txt['upgrade_step_progress'], '</h3> |
@@ -4152,7 +4726,8 @@ discard block |
||
4152 | 4726 | { |
4153 | 4727 | global $upcontext; |
4154 | 4728 | |
4155 | - if (!empty($upcontext['pause'])) { |
|
4729 | + if (!empty($upcontext['pause'])) |
|
4730 | + { |
|
4156 | 4731 | echo ' |
4157 | 4732 | <em>', Lang::$txt['upgrade_incomplete'], '.</em><br> |
4158 | 4733 | |
@@ -4162,7 +4737,8 @@ discard block |
||
4162 | 4737 | </h3>'; |
4163 | 4738 | } |
4164 | 4739 | |
4165 | - if (!empty($upcontext['custom_warning'])) { |
|
4740 | + if (!empty($upcontext['custom_warning'])) |
|
4741 | + { |
|
4166 | 4742 | echo ' |
4167 | 4743 | <div class="errorbox"> |
4168 | 4744 | <h3>', Lang::$txt['upgrade_note'], '</h3> |
@@ -4173,12 +4749,14 @@ discard block |
||
4173 | 4749 | echo ' |
4174 | 4750 | <div class="righttext buttons">'; |
4175 | 4751 | |
4176 | - if (!empty($upcontext['continue'])) { |
|
4752 | + if (!empty($upcontext['continue'])) |
|
4753 | + { |
|
4177 | 4754 | echo ' |
4178 | 4755 | <input type="submit" id="contbutt" name="contbutt" value="', Lang::$txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
4179 | 4756 | } |
4180 | 4757 | |
4181 | - if (!empty($upcontext['skip'])) { |
|
4758 | + if (!empty($upcontext['skip'])) |
|
4759 | + { |
|
4182 | 4760 | echo ' |
4183 | 4761 | <input type="submit" id="skip" name="skip" value="', Lang::$txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
4184 | 4762 | } |
@@ -4199,7 +4777,8 @@ discard block |
||
4199 | 4777 | </div>'; |
4200 | 4778 | |
4201 | 4779 | // Are we on a pause? |
4202 | - if (!empty($upcontext['pause'])) { |
|
4780 | + if (!empty($upcontext['pause'])) |
|
4781 | + { |
|
4203 | 4782 | echo ' |
4204 | 4783 | <script> |
4205 | 4784 | window.onload = doAutoSubmit; |
@@ -4233,8 +4812,10 @@ discard block |
||
4233 | 4812 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
4234 | 4813 | <smf>'; |
4235 | 4814 | |
4236 | - if (!empty($upcontext['get_data'])) { |
|
4237 | - foreach ($upcontext['get_data'] as $k => $v) { |
|
4815 | + if (!empty($upcontext['get_data'])) |
|
4816 | + { |
|
4817 | + foreach ($upcontext['get_data'] as $k => $v) |
|
4818 | + { |
|
4238 | 4819 | echo ' |
4239 | 4820 | <get key="', $k, '">', $v, '</get>'; |
4240 | 4821 | } |
@@ -4279,7 +4860,8 @@ discard block |
||
4279 | 4860 | template_chmod(); |
4280 | 4861 | |
4281 | 4862 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
4282 | - if ($upcontext['is_large_forum']) { |
|
4863 | + if ($upcontext['is_large_forum']) |
|
4864 | + { |
|
4283 | 4865 | echo ' |
4284 | 4866 | <div class="errorbox"> |
4285 | 4867 | <h3>', Lang::$txt['upgrade_warning'], '</h3> |
@@ -4288,7 +4870,8 @@ discard block |
||
4288 | 4870 | } |
4289 | 4871 | |
4290 | 4872 | // A warning message? |
4291 | - if (!empty($upcontext['warning'])) { |
|
4873 | + if (!empty($upcontext['warning'])) |
|
4874 | + { |
|
4292 | 4875 | echo ' |
4293 | 4876 | <div class="errorbox"> |
4294 | 4877 | <h3>', Lang::$txt['upgrade_warning'], '</h3> |
@@ -4304,7 +4887,8 @@ discard block |
||
4304 | 4887 | </div>'; |
4305 | 4888 | |
4306 | 4889 | // Is there someone already doing this? |
4307 | - if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) { |
|
4890 | + if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
|
4891 | + { |
|
4308 | 4892 | $ago = time() - $upcontext['started']; |
4309 | 4893 | $ago_hours = floor($ago / 3600); |
4310 | 4894 | $ago_minutes = (int) (((int) ($ago / 60)) % 60); |
@@ -4324,18 +4908,24 @@ discard block |
||
4324 | 4908 | <p>', sprintf(Lang::$txt[$agoTxt], $ago_seconds, $ago_minutes, $ago_hours), '</p> |
4325 | 4909 | <p>', sprintf(Lang::$txt[$updatedTxt], $updated_seconds, $updated_minutes, $updated_hours), '</p>'; |
4326 | 4910 | |
4327 | - if ($updated < 600) { |
|
4911 | + if ($updated < 600) |
|
4912 | + { |
|
4328 | 4913 | echo ' |
4329 | 4914 | <p>', Lang::$txt['upgrade_run_script'], ' ', $upcontext['user']['name'], ' ', Lang::$txt['upgrade_run_script2'], '</p>'; |
4330 | 4915 | } |
4331 | 4916 | |
4332 | - if ($updated > $upcontext['inactive_timeout']) { |
|
4917 | + if ($updated > $upcontext['inactive_timeout']) |
|
4918 | + { |
|
4333 | 4919 | echo ' |
4334 | 4920 | <p>', Lang::$txt['upgrade_run'], '</p>'; |
4335 | - } elseif ($upcontext['inactive_timeout'] > 120) { |
|
4921 | + } |
|
4922 | + elseif ($upcontext['inactive_timeout'] > 120) |
|
4923 | + { |
|
4336 | 4924 | echo ' |
4337 | 4925 | <p>', sprintf(Lang::$txt['upgrade_script_timeout_minutes'], $upcontext['user']['name'], round($upcontext['inactive_timeout'] / 60, 1)), '</p>'; |
4338 | - } else { |
|
4926 | + } |
|
4927 | + else |
|
4928 | + { |
|
4339 | 4929 | echo ' |
4340 | 4930 | <p>', sprintf(Lang::$txt['upgrade_script_timeout_seconds'], $upcontext['user']['name'], $upcontext['inactive_timeout']), '</p>'; |
4341 | 4931 | } |
@@ -4354,7 +4944,8 @@ discard block |
||
4354 | 4944 | <dd> |
4355 | 4945 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
4356 | 4946 | |
4357 | - if (!empty($upcontext['username_incorrect'])) { |
|
4947 | + if (!empty($upcontext['username_incorrect'])) |
|
4948 | + { |
|
4358 | 4949 | echo ' |
4359 | 4950 | <div class="smalltext red">', Lang::$txt['upgrade_wrong_username'], '</div>'; |
4360 | 4951 | } |
@@ -4367,7 +4958,8 @@ discard block |
||
4367 | 4958 | <dd> |
4368 | 4959 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '>'; |
4369 | 4960 | |
4370 | - if (!empty($upcontext['password_failed'])) { |
|
4961 | + if (!empty($upcontext['password_failed'])) |
|
4962 | + { |
|
4371 | 4963 | echo ' |
4372 | 4964 | <div class="smalltext red">', Lang::$txt['upgrade_wrong_password'], '</div>'; |
4373 | 4965 | } |
@@ -4376,7 +4968,8 @@ discard block |
||
4376 | 4968 | </dd>'; |
4377 | 4969 | |
4378 | 4970 | // Can they continue? |
4379 | - if (!empty($upcontext['user']['id']) && time() - $upcontext['user']['updated'] >= $upcontext['inactive_timeout'] && $upcontext['user']['step'] > 1) { |
|
4971 | + if (!empty($upcontext['user']['id']) && time() - $upcontext['user']['updated'] >= $upcontext['inactive_timeout'] && $upcontext['user']['step'] > 1) |
|
4972 | + { |
|
4380 | 4973 | echo ' |
4381 | 4974 | <dd> |
4382 | 4975 | <label for="cont"><input type="checkbox" id="cont" name="cont" checked>', Lang::$txt['upgrade_continue_step'], '</label> |
@@ -4437,7 +5030,8 @@ discard block |
||
4437 | 5030 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
4438 | 5031 | |
4439 | 5032 | // Warning message? |
4440 | - if (!empty($upcontext['upgrade_options_warning'])) { |
|
5033 | + if (!empty($upcontext['upgrade_options_warning'])) |
|
5034 | + { |
|
4441 | 5035 | echo ' |
4442 | 5036 | <div class="errorbox"> |
4443 | 5037 | <h3>', Lang::$txt['upgrade_warning'], '</h3> |
@@ -4472,7 +5066,8 @@ discard block |
||
4472 | 5066 | <label for="empty_error">', Lang::$txt['upgrade_empty_errorlog'], '</label> |
4473 | 5067 | </li>'; |
4474 | 5068 | |
4475 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
5069 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
5070 | + { |
|
4476 | 5071 | echo ' |
4477 | 5072 | <li> |
4478 | 5073 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
@@ -4482,7 +5077,8 @@ discard block |
||
4482 | 5077 | |
4483 | 5078 | // If attachment step has been run previously, offer an option to do it again. |
4484 | 5079 | // Helpful if folks had improper attachment folders specified previously. |
4485 | - if (!empty(Config::$modSettings['attachments_21_done'])) { |
|
5080 | + if (!empty(Config::$modSettings['attachments_21_done'])) |
|
5081 | + { |
|
4486 | 5082 | echo ' |
4487 | 5083 | <li> |
4488 | 5084 | <input type="checkbox" name="reprocess_attachments" id="reprocess_attachments" value="1"> |
@@ -4528,8 +5124,10 @@ discard block |
||
4528 | 5124 | </div>'; |
4529 | 5125 | |
4530 | 5126 | // Dont any tables so far? |
4531 | - if (!empty($upcontext['previous_tables'])) { |
|
4532 | - foreach ($upcontext['previous_tables'] as $table) { |
|
5127 | + if (!empty($upcontext['previous_tables'])) |
|
5128 | + { |
|
5129 | + foreach ($upcontext['previous_tables'] as $table) |
|
5130 | + { |
|
4533 | 5131 | echo ' |
4534 | 5132 | <br>', Lang::$txt['upgrade_completed_table'], ' "', $table, '".'; |
4535 | 5133 | } |
@@ -4545,7 +5143,8 @@ discard block |
||
4545 | 5143 | $upcontext['continue'] = $support_js ? 2 : 1; |
4546 | 5144 | |
4547 | 5145 | // If javascript allows we want to do this using XML. |
4548 | - if ($support_js) { |
|
5146 | + if ($support_js) |
|
5147 | + { |
|
4549 | 5148 | echo ' |
4550 | 5149 | <script> |
4551 | 5150 | var lastTable = ', $upcontext['cur_table_num'], '; |
@@ -4571,7 +5170,8 @@ discard block |
||
4571 | 5170 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4572 | 5171 | |
4573 | 5172 | // If debug flood the screen. |
4574 | - if ($is_debug) { |
|
5173 | + if ($is_debug) |
|
5174 | + { |
|
4575 | 5175 | echo ' |
4576 | 5176 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', Lang::$txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4577 | 5177 | |
@@ -4610,7 +5210,8 @@ discard block |
||
4610 | 5210 | { |
4611 | 5211 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
4612 | 5212 | |
4613 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
5213 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
5214 | + { |
|
4614 | 5215 | $is_debug = true; |
4615 | 5216 | } |
4616 | 5217 | |
@@ -4623,33 +5224,43 @@ discard block |
||
4623 | 5224 | <input type="hidden" name="database_done" id="database_done" value="0">'; |
4624 | 5225 | |
4625 | 5226 | // No javascript looks rubbish! |
4626 | - if (!$support_js) { |
|
4627 | - foreach ($upcontext['actioned_items'] as $num => $item) { |
|
4628 | - if ($num != 0) { |
|
5227 | + if (!$support_js) |
|
5228 | + { |
|
5229 | + foreach ($upcontext['actioned_items'] as $num => $item) |
|
5230 | + { |
|
5231 | + if ($num != 0) |
|
5232 | + { |
|
4629 | 5233 | echo ' Successful!'; |
4630 | 5234 | } |
4631 | 5235 | echo '<br>' . $item; |
4632 | 5236 | } |
4633 | 5237 | |
4634 | 5238 | // Only tell deubbers how much time they wasted waiting for the upgrade because they don't have javascript. |
4635 | - if (!empty($upcontext['changes_complete'])) { |
|
4636 | - if ($is_debug) { |
|
5239 | + if (!empty($upcontext['changes_complete'])) |
|
5240 | + { |
|
5241 | + if ($is_debug) |
|
5242 | + { |
|
4637 | 5243 | $active = time() - $upcontext['started']; |
4638 | 5244 | $hours = floor($active / 3600); |
4639 | 5245 | $minutes = intval(($active / 60) % 60); |
4640 | 5246 | $seconds = intval($active % 60); |
4641 | 5247 | |
4642 | 5248 | echo '', sprintf(Lang::$txt['upgrade_success_time_db'], $seconds, $minutes, $hours), '<br>'; |
4643 | - } else { |
|
5249 | + } |
|
5250 | + else |
|
5251 | + { |
|
4644 | 5252 | echo '', Lang::$txt['upgrade_success'], '<br>'; |
4645 | 5253 | } |
4646 | 5254 | |
4647 | 5255 | echo ' |
4648 | 5256 | <p id="commess">', Lang::$txt['upgrade_db_complete'], '</p>'; |
4649 | 5257 | } |
4650 | - } else { |
|
5258 | + } |
|
5259 | + else |
|
5260 | + { |
|
4651 | 5261 | // Tell them how many files we have in total. |
4652 | - if ($upcontext['file_count'] > 1) { |
|
5262 | + if ($upcontext['file_count'] > 1) |
|
5263 | + { |
|
4653 | 5264 | echo ' |
4654 | 5265 | <strong id="info1">', Lang::$txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
4655 | 5266 | } |
@@ -4660,9 +5271,11 @@ discard block |
||
4660 | 5271 | </h3> |
4661 | 5272 | <p id="commess" class="', !empty($upcontext['changes_complete']) || $upcontext['current_debug_item_num'] == $upcontext['debug_items'] ? 'inline_block' : 'hidden', '">', Lang::$txt['upgrade_db_complete2'], '</p>'; |
4662 | 5273 | |
4663 | - if ($is_debug) { |
|
5274 | + if ($is_debug) |
|
5275 | + { |
|
4664 | 5276 | // Let our debuggers know how much time was spent, but not wasted since JS handled refreshing the page! |
4665 | - if ($upcontext['current_debug_item_num'] == $upcontext['debug_items']) { |
|
5277 | + if ($upcontext['current_debug_item_num'] == $upcontext['debug_items']) |
|
5278 | + { |
|
4666 | 5279 | $active = time() - $upcontext['started']; |
4667 | 5280 | $hours = floor($active / 3600); |
4668 | 5281 | $minutes = intval(($active / 60) % 60); |
@@ -4670,7 +5283,9 @@ discard block |
||
4670 | 5283 | |
4671 | 5284 | echo ' |
4672 | 5285 | <p id="upgradeCompleted">', sprintf(Lang::$txt['upgrade_success_time_db'], $seconds, $minutes, $hours), '</p>'; |
4673 | - } else { |
|
5286 | + } |
|
5287 | + else |
|
5288 | + { |
|
4674 | 5289 | echo ' |
4675 | 5290 | <p id="upgradeCompleted"></p>'; |
4676 | 5291 | } |
@@ -4693,7 +5308,8 @@ discard block |
||
4693 | 5308 | $upcontext['continue'] = $support_js ? 2 : 1; |
4694 | 5309 | |
4695 | 5310 | // If javascript allows we want to do this using XML. |
4696 | - if ($support_js) { |
|
5311 | + if ($support_js) |
|
5312 | + { |
|
4697 | 5313 | echo ' |
4698 | 5314 | <script> |
4699 | 5315 | var lastItem = ', $upcontext['current_debug_item_num'], '; |
@@ -4708,7 +5324,8 @@ discard block |
||
4708 | 5324 | var getData = ""; |
4709 | 5325 | var debugItems = ', $upcontext['debug_items'], ';'; |
4710 | 5326 | |
4711 | - if ($is_debug) { |
|
5327 | + if ($is_debug) |
|
5328 | + { |
|
4712 | 5329 | echo ' |
4713 | 5330 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
4714 | 5331 | } |
@@ -4752,7 +5369,8 @@ discard block |
||
4752 | 5369 | document.getElementById("error_block").classList.remove("hidden"); |
4753 | 5370 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4754 | 5371 | |
4755 | - if ($is_debug) { |
|
5372 | + if ($is_debug) |
|
5373 | + { |
|
4756 | 5374 | echo ' |
4757 | 5375 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4758 | 5376 | } |
@@ -4776,7 +5394,8 @@ discard block |
||
4776 | 5394 | document.getElementById("error_block").classList.remove("hidden"); |
4777 | 5395 | setInnerHTML(document.getElementById("error_message"), "', Lang::$txt['upgrade_loop'], '" + sDebugName);'; |
4778 | 5396 | |
4779 | - if ($is_debug) { |
|
5397 | + if ($is_debug) |
|
5398 | + { |
|
4780 | 5399 | echo ' |
4781 | 5400 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4782 | 5401 | } |
@@ -4838,7 +5457,8 @@ discard block |
||
4838 | 5457 | {'; |
4839 | 5458 | |
4840 | 5459 | // Database Changes, tell us how much time we spen to do this. If this gets updated via JS. |
4841 | - if ($is_debug) { |
|
5460 | + if ($is_debug) |
|
5461 | + { |
|
4842 | 5462 | echo ' |
4843 | 5463 | document.getElementById(\'debug_section\').classList.add("hidden"); |
4844 | 5464 | |
@@ -4862,7 +5482,8 @@ discard block |
||
4862 | 5482 | document.getElementById(\'contbutt\').disabled = 0; |
4863 | 5483 | document.getElementById(\'database_done\').value = 1;'; |
4864 | 5484 | |
4865 | - if ($upcontext['file_count'] > 1) { |
|
5485 | + if ($upcontext['file_count'] > 1) |
|
5486 | + { |
|
4866 | 5487 | echo ' |
4867 | 5488 | document.getElementById(\'info1\').classList.add(\'hidden\');'; |
4868 | 5489 | } |
@@ -4878,7 +5499,8 @@ discard block |
||
4878 | 5499 | lastItem = 0; |
4879 | 5500 | prevFile = curFile;'; |
4880 | 5501 | |
4881 | - if ($is_debug) { |
|
5502 | + if ($is_debug) |
|
5503 | + { |
|
4882 | 5504 | echo ' |
4883 | 5505 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
4884 | 5506 | } |
@@ -4889,7 +5511,8 @@ discard block |
||
4889 | 5511 | }'; |
4890 | 5512 | |
4891 | 5513 | // If debug scroll the screen. |
4892 | - if ($is_debug) { |
|
5514 | + if ($is_debug) |
|
5515 | + { |
|
4893 | 5516 | echo ' |
4894 | 5517 | if (iLastSubStepProgress == -1) |
4895 | 5518 | { |
@@ -4918,7 +5541,8 @@ discard block |
||
4918 | 5541 | setInnerHTML(document.getElementById(\'item_num\'), iItemNum); |
4919 | 5542 | setInnerHTML(document.getElementById(\'cur_item_name\'), sItemName);'; |
4920 | 5543 | |
4921 | - if ($upcontext['file_count'] > 1) { |
|
5544 | + if ($upcontext['file_count'] > 1) |
|
5545 | + { |
|
4922 | 5546 | echo ' |
4923 | 5547 | setInnerHTML(document.getElementById(\'file_done\'), curFile); |
4924 | 5548 | setInnerHTML(document.getElementById(\'item_count\'), totalItems);'; |
@@ -4971,7 +5595,8 @@ discard block |
||
4971 | 5595 | }'; |
4972 | 5596 | |
4973 | 5597 | // Start things off assuming we've not errored. |
4974 | - if (empty($upcontext['error_message'])) { |
|
5598 | + if (empty($upcontext['error_message'])) |
|
5599 | + { |
|
4975 | 5600 | echo ' |
4976 | 5601 | getNextItem();'; |
4977 | 5602 | } |
@@ -4992,17 +5617,20 @@ discard block |
||
4992 | 5617 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
4993 | 5618 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', $upcontext['substep_progress'] ?? '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '" skipped="', empty($upcontext['skip_db_substeps']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
4994 | 5619 | |
4995 | - if (!empty($upcontext['error_message'])) { |
|
5620 | + if (!empty($upcontext['error_message'])) |
|
5621 | + { |
|
4996 | 5622 | echo ' |
4997 | 5623 | <error>', $upcontext['error_message'], '</error>'; |
4998 | 5624 | } |
4999 | 5625 | |
5000 | - if (!empty($upcontext['error_string'])) { |
|
5626 | + if (!empty($upcontext['error_string'])) |
|
5627 | + { |
|
5001 | 5628 | echo ' |
5002 | 5629 | <sql>', $upcontext['error_string'], '</sql>'; |
5003 | 5630 | } |
5004 | 5631 | |
5005 | - if ($is_debug) { |
|
5632 | + if ($is_debug) |
|
5633 | + { |
|
5006 | 5634 | echo ' |
5007 | 5635 | <curtime>', time(), '</curtime>'; |
5008 | 5636 | } |
@@ -5023,8 +5651,10 @@ discard block |
||
5023 | 5651 | </div>'; |
5024 | 5652 | |
5025 | 5653 | // Done any tables so far? |
5026 | - if (!empty($upcontext['previous_tables'])) { |
|
5027 | - foreach ($upcontext['previous_tables'] as $table) { |
|
5654 | + if (!empty($upcontext['previous_tables'])) |
|
5655 | + { |
|
5656 | + foreach ($upcontext['previous_tables'] as $table) |
|
5657 | + { |
|
5028 | 5658 | echo ' |
5029 | 5659 | <br>', Lang::$txt['upgrade_completed_table'], ' "', $table, '".'; |
5030 | 5660 | } |
@@ -5036,7 +5666,8 @@ discard block |
||
5036 | 5666 | </h3>'; |
5037 | 5667 | |
5038 | 5668 | // If we dropped their index, let's let them know |
5039 | - if ($upcontext['dropping_index']) { |
|
5669 | + if ($upcontext['dropping_index']) |
|
5670 | + { |
|
5040 | 5671 | echo ' |
5041 | 5672 | <p id="indexmsg" class="', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline_block' : 'hidden', '>', Lang::$txt['upgrade_fulltext'], '</p>'; |
5042 | 5673 | } |
@@ -5049,7 +5680,8 @@ discard block |
||
5049 | 5680 | $upcontext['continue'] = $support_js ? 2 : 1; |
5050 | 5681 | |
5051 | 5682 | // If javascript allows we want to do this using XML. |
5052 | - if ($support_js) { |
|
5683 | + if ($support_js) |
|
5684 | + { |
|
5053 | 5685 | echo ' |
5054 | 5686 | <script> |
5055 | 5687 | var lastTable = ', $upcontext['cur_table_num'], '; |
@@ -5075,7 +5707,8 @@ discard block |
||
5075 | 5707 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
5076 | 5708 | |
5077 | 5709 | // If debug flood the screen. |
5078 | - if ($is_debug) { |
|
5710 | + if ($is_debug) |
|
5711 | + { |
|
5079 | 5712 | echo ' |
5080 | 5713 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', Lang::$txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
5081 | 5714 | |
@@ -5127,8 +5760,10 @@ discard block |
||
5127 | 5760 | </div>'; |
5128 | 5761 | |
5129 | 5762 | // Dont any tables so far? |
5130 | - if (!empty($upcontext['previous_tables'])) { |
|
5131 | - foreach ($upcontext['previous_tables'] as $table) { |
|
5763 | + if (!empty($upcontext['previous_tables'])) |
|
5764 | + { |
|
5765 | + foreach ($upcontext['previous_tables'] as $table) |
|
5766 | + { |
|
5132 | 5767 | echo ' |
5133 | 5768 | <br>', Lang::$txt['upgrade_completed_table'], ' "', $table, '".'; |
5134 | 5769 | } |
@@ -5141,7 +5776,8 @@ discard block |
||
5141 | 5776 | <p id="commess" class="', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline_block' : 'hidden', '">', Lang::$txt['upgrade_json_completed'], '</p>'; |
5142 | 5777 | |
5143 | 5778 | // Try to make sure substep was reset. |
5144 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
5779 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
5780 | + { |
|
5145 | 5781 | echo ' |
5146 | 5782 | <input type="hidden" name="substep" id="substep" value="0">'; |
5147 | 5783 | } |
@@ -5150,7 +5786,8 @@ discard block |
||
5150 | 5786 | $upcontext['continue'] = $support_js ? 2 : 1; |
5151 | 5787 | |
5152 | 5788 | // If javascript allows we want to do this using XML. |
5153 | - if ($support_js) { |
|
5789 | + if ($support_js) |
|
5790 | + { |
|
5154 | 5791 | echo ' |
5155 | 5792 | <script> |
5156 | 5793 | var lastTable = ', $upcontext['cur_table_num'], '; |
@@ -5176,7 +5813,8 @@ discard block |
||
5176 | 5813 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
5177 | 5814 | |
5178 | 5815 | // If debug flood the screen. |
5179 | - if ($is_debug) { |
|
5816 | + if ($is_debug) |
|
5817 | + { |
|
5180 | 5818 | echo ' |
5181 | 5819 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', Lang::$txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
5182 | 5820 | |
@@ -5218,7 +5856,8 @@ discard block |
||
5218 | 5856 | <h3>', sprintf(Lang::$txt['upgrade_done'], Config::$boardurl), '</h3> |
5219 | 5857 | <form action="', Config::$boardurl, '/index.php">'; |
5220 | 5858 | |
5221 | - if (!empty($upcontext['can_delete_script'])) { |
|
5859 | + if (!empty($upcontext['can_delete_script'])) |
|
5860 | + { |
|
5222 | 5861 | echo ' |
5223 | 5862 | <label> |
5224 | 5863 | <input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', Lang::$txt['upgrade_delete_now'], ' |
@@ -5236,17 +5875,23 @@ discard block |
||
5236 | 5875 | } |
5237 | 5876 | |
5238 | 5877 | // Show Upgrade time in debug mode when we completed the upgrade process totally |
5239 | - if ($is_debug) { |
|
5878 | + if ($is_debug) |
|
5879 | + { |
|
5240 | 5880 | $active = time() - $upcontext['started']; |
5241 | 5881 | $hours = floor($active / 3600); |
5242 | 5882 | $minutes = intval((int) ($active / 60) % 60); |
5243 | 5883 | $seconds = intval((int) $active % 60); |
5244 | 5884 | |
5245 | - if ($hours > 0) { |
|
5885 | + if ($hours > 0) |
|
5886 | + { |
|
5246 | 5887 | echo '', sprintf(Lang::$txt['upgrade_completed_time_hms'], $seconds, $minutes, $hours), ''; |
5247 | - } elseif ($minutes > 0) { |
|
5888 | + } |
|
5889 | + elseif ($minutes > 0) |
|
5890 | + { |
|
5248 | 5891 | echo '', sprintf(Lang::$txt['upgrade_completed_time_ms'], $seconds, $minutes), ''; |
5249 | - } elseif ($seconds > 0) { |
|
5892 | + } |
|
5893 | + elseif ($seconds > 0) |
|
5894 | + { |
|
5250 | 5895 | echo '', sprintf(Lang::$txt['upgrade_completed_time_s'], $seconds), ''; |
5251 | 5896 | } |
5252 | 5897 | } |
@@ -5290,7 +5935,8 @@ discard block |
||
5290 | 5935 | ], |
5291 | 5936 | ); |
5292 | 5937 | |
5293 | - if (Db::$db->num_rows($request) !== 1) { |
|
5938 | + if (Db::$db->num_rows($request) !== 1) |
|
5939 | + { |
|
5294 | 5940 | Db::$db->free_result($request); |
5295 | 5941 | |
5296 | 5942 | return; |
@@ -5298,7 +5944,8 @@ discard block |
||
5298 | 5944 | Db::$db->free_result($request); |
5299 | 5945 | |
5300 | 5946 | // Setup progress bar |
5301 | - if (!isset($_GET['total_fixes']) || !isset($_GET['a'])) { |
|
5947 | + if (!isset($_GET['total_fixes']) || !isset($_GET['a'])) |
|
5948 | + { |
|
5302 | 5949 | $request = Db::$db->query( |
5303 | 5950 | '', |
5304 | 5951 | 'SELECT COUNT(DISTINCT {raw:old_col}) |
@@ -5322,7 +5969,8 @@ discard block |
||
5322 | 5969 | // Main process loop |
5323 | 5970 | $is_done = false; |
5324 | 5971 | |
5325 | - while (!$is_done) { |
|
5972 | + while (!$is_done) |
|
5973 | + { |
|
5326 | 5974 | // Keep looping at the current step. |
5327 | 5975 | nextSubstep($current_substep); |
5328 | 5976 | |
@@ -5344,13 +5992,15 @@ discard block |
||
5344 | 5992 | ], |
5345 | 5993 | ); |
5346 | 5994 | |
5347 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
5995 | + while ($row = Db::$db->fetch_assoc($request)) |
|
5996 | + { |
|
5348 | 5997 | $arIp[] = $row[$oldCol]; |
5349 | 5998 | } |
5350 | 5999 | |
5351 | 6000 | Db::$db->free_result($request); |
5352 | 6001 | |
5353 | - if (empty($arIp)) { |
|
6002 | + if (empty($arIp)) |
|
6003 | + { |
|
5354 | 6004 | $is_done = true; |
5355 | 6005 | } |
5356 | 6006 | |
@@ -5359,12 +6009,14 @@ discard block |
||
5359 | 6009 | $cases = []; |
5360 | 6010 | $count = count($arIp); |
5361 | 6011 | |
5362 | - for ($i = 0; $i < $count; $i++) { |
|
6012 | + for ($i = 0; $i < $count; $i++) |
|
6013 | + { |
|
5363 | 6014 | $new_ip = trim($arIp[$i]); |
5364 | 6015 | |
5365 | 6016 | $new_ip = filter_var($new_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6); |
5366 | 6017 | |
5367 | - if ($new_ip === false) { |
|
6018 | + if ($new_ip === false) |
|
6019 | + { |
|
5368 | 6020 | $new_ip = ''; |
5369 | 6021 | } |
5370 | 6022 | |
@@ -5373,7 +6025,8 @@ discard block |
||
5373 | 6025 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:newip' . $i . '}'; |
5374 | 6026 | |
5375 | 6027 | // Execute updates every $setSize & also when done with contents of $arIp |
5376 | - if ((($i + 1) == $count) || (($i + 1) % $setSize === 0)) { |
|
6028 | + if ((($i + 1) == $count) || (($i + 1) % $setSize === 0)) |
|
6029 | + { |
|
5377 | 6030 | $updates['whereSet'] = array_values($updates); |
5378 | 6031 | Db::$db->query( |
5379 | 6032 | '', |
@@ -5414,7 +6067,8 @@ discard block |
||
5414 | 6067 | { |
5415 | 6068 | $columns = Db::$db->list_columns($targetTable, true); |
5416 | 6069 | |
5417 | - if (isset($columns[$column])) { |
|
6070 | + if (isset($columns[$column])) |
|
6071 | + { |
|
5418 | 6072 | return $columns[$column]; |
5419 | 6073 | } |
5420 | 6074 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | 'mysql' => [ |
69 | 69 | 'name' => 'MySQL', |
70 | 70 | 'version' => '5.6.0', |
71 | - 'version_check' => function () { |
|
71 | + 'version_check' => function() { |
|
72 | 72 | if (!function_exists('mysqli_fetch_row')) { |
73 | 73 | return false; |
74 | 74 | } |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | 'default_password' => 'mysql.default_password', |
81 | 81 | 'default_host' => 'mysql.default_host', |
82 | 82 | 'default_port' => 'mysql.default_port', |
83 | - 'utf8_support' => function () { |
|
83 | + 'utf8_support' => function() { |
|
84 | 84 | return true; |
85 | 85 | }, |
86 | 86 | 'utf8_version' => '5.0.22', |
87 | - 'utf8_version_check' => function () { |
|
87 | + 'utf8_version_check' => function() { |
|
88 | 88 | return mysqli_get_server_info(Db::$db->connection); |
89 | 89 | }, |
90 | 90 | 'alter_support' => true, |
91 | - 'validate_prefix' => function (&$value) { |
|
91 | + 'validate_prefix' => function(&$value) { |
|
92 | 92 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
93 | 93 | |
94 | 94 | return true; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | 'postgresql' => [ |
98 | 98 | 'name' => 'PostgreSQL', |
99 | 99 | 'version' => '9.6', |
100 | - 'version_check' => function () { |
|
100 | + 'version_check' => function() { |
|
101 | 101 | $request = pg_query(Db::$db->connection, 'SELECT version()'); |
102 | 102 | list($version) = pg_fetch_row($request); |
103 | 103 | list($pgl, $version) = explode(' ', $version); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | }, |
107 | 107 | 'supported' => function_exists('pg_connect'), |
108 | 108 | 'always_has_db' => true, |
109 | - 'utf8_support' => function () { |
|
109 | + 'utf8_support' => function() { |
|
110 | 110 | $request = pg_query(Db::$db->connection, 'SHOW SERVER_ENCODING'); |
111 | 111 | |
112 | 112 | list($charcode) = pg_fetch_row($request); |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | return (bool) ($charcode == 'UTF8'); |
115 | 115 | }, |
116 | 116 | 'utf8_version' => '8.0', |
117 | - 'utf8_version_check' => function () { |
|
117 | + 'utf8_version_check' => function() { |
|
118 | 118 | $request = pg_query(Db::$db->connection, 'SELECT version()'); |
119 | 119 | list($version) = pg_fetch_row($request); |
120 | 120 | list($pgl, $version) = explode(' ', $version); |
121 | 121 | |
122 | 122 | return $version; |
123 | 123 | }, |
124 | - 'validate_prefix' => function (&$value) { |
|
124 | + 'validate_prefix' => function(&$value) { |
|
125 | 125 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
126 | 126 | |
127 | 127 | // Is it reserved? |
@@ -35,7 +35,8 @@ discard block |
||
35 | 35 | define('MYSQL_TITLE', 'MySQL'); |
36 | 36 | define('SMF_USER_AGENT', 'Mozilla/5.0 (' . php_uname('s') . ' ' . php_uname('m') . ') AppleWebKit/605.1.15 (KHTML, like Gecko) SMF/' . strtr(SMF_VERSION, ' ', '.')); |
37 | 37 | |
38 | -if (!defined('TIME_START')) { |
|
38 | +if (!defined('TIME_START')) |
|
39 | +{ |
|
39 | 40 | define('TIME_START', microtime(true)); |
40 | 41 | } |
41 | 42 | |
@@ -47,7 +48,8 @@ discard block |
||
47 | 48 | // Don't have PHP support, do you? |
48 | 49 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
49 | 50 | |
50 | -if (!defined('SMF')) { |
|
51 | +if (!defined('SMF')) |
|
52 | +{ |
|
51 | 53 | define('SMF', 1); |
52 | 54 | } |
53 | 55 | |
@@ -68,8 +70,10 @@ discard block |
||
68 | 70 | 'mysql' => [ |
69 | 71 | 'name' => 'MySQL', |
70 | 72 | 'version' => '5.6.0', |
71 | - 'version_check' => function () { |
|
72 | - if (!function_exists('mysqli_fetch_row')) { |
|
73 | + 'version_check' => function () |
|
74 | + { |
|
75 | + if (!function_exists('mysqli_fetch_row')) |
|
76 | + { |
|
73 | 77 | return false; |
74 | 78 | } |
75 | 79 | |
@@ -80,15 +84,18 @@ discard block |
||
80 | 84 | 'default_password' => 'mysql.default_password', |
81 | 85 | 'default_host' => 'mysql.default_host', |
82 | 86 | 'default_port' => 'mysql.default_port', |
83 | - 'utf8_support' => function () { |
|
87 | + 'utf8_support' => function () |
|
88 | + { |
|
84 | 89 | return true; |
85 | 90 | }, |
86 | 91 | 'utf8_version' => '5.0.22', |
87 | - 'utf8_version_check' => function () { |
|
92 | + 'utf8_version_check' => function () |
|
93 | + { |
|
88 | 94 | return mysqli_get_server_info(Db::$db->connection); |
89 | 95 | }, |
90 | 96 | 'alter_support' => true, |
91 | - 'validate_prefix' => function (&$value) { |
|
97 | + 'validate_prefix' => function (&$value) |
|
98 | + { |
|
92 | 99 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
93 | 100 | |
94 | 101 | return true; |
@@ -97,7 +104,8 @@ discard block |
||
97 | 104 | 'postgresql' => [ |
98 | 105 | 'name' => 'PostgreSQL', |
99 | 106 | 'version' => '9.6', |
100 | - 'version_check' => function () { |
|
107 | + 'version_check' => function () |
|
108 | + { |
|
101 | 109 | $request = pg_query(Db::$db->connection, 'SELECT version()'); |
102 | 110 | list($version) = pg_fetch_row($request); |
103 | 111 | list($pgl, $version) = explode(' ', $version); |
@@ -106,7 +114,8 @@ discard block |
||
106 | 114 | }, |
107 | 115 | 'supported' => function_exists('pg_connect'), |
108 | 116 | 'always_has_db' => true, |
109 | - 'utf8_support' => function () { |
|
117 | + 'utf8_support' => function () |
|
118 | + { |
|
110 | 119 | $request = pg_query(Db::$db->connection, 'SHOW SERVER_ENCODING'); |
111 | 120 | |
112 | 121 | list($charcode) = pg_fetch_row($request); |
@@ -114,23 +123,27 @@ discard block |
||
114 | 123 | return (bool) ($charcode == 'UTF8'); |
115 | 124 | }, |
116 | 125 | 'utf8_version' => '8.0', |
117 | - 'utf8_version_check' => function () { |
|
126 | + 'utf8_version_check' => function () |
|
127 | + { |
|
118 | 128 | $request = pg_query(Db::$db->connection, 'SELECT version()'); |
119 | 129 | list($version) = pg_fetch_row($request); |
120 | 130 | list($pgl, $version) = explode(' ', $version); |
121 | 131 | |
122 | 132 | return $version; |
123 | 133 | }, |
124 | - 'validate_prefix' => function (&$value) { |
|
134 | + 'validate_prefix' => function (&$value) |
|
135 | + { |
|
125 | 136 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
126 | 137 | |
127 | 138 | // Is it reserved? |
128 | - if ($value == 'pg_') { |
|
139 | + if ($value == 'pg_') |
|
140 | + { |
|
129 | 141 | return Lang::$txt['error_db_prefix_reserved']; |
130 | 142 | } |
131 | 143 | |
132 | 144 | // Is the prefix numeric? |
133 | - if (preg_match('~^\d~', $value)) { |
|
145 | + if (preg_match('~^\d~', $value)) |
|
146 | + { |
|
134 | 147 | return Lang::$txt['error_db_prefix_numeric']; |
135 | 148 | } |
136 | 149 | |
@@ -167,19 +180,23 @@ discard block |
||
167 | 180 | // Loop through all the steps doing each one as required. |
168 | 181 | $incontext['overall_percent'] = 0; |
169 | 182 | |
170 | -foreach ($incontext['steps'] as $num => $step) { |
|
171 | - if ($num >= $incontext['current_step']) { |
|
183 | +foreach ($incontext['steps'] as $num => $step) |
|
184 | +{ |
|
185 | + if ($num >= $incontext['current_step']) |
|
186 | + { |
|
172 | 187 | // The current weight of this step in terms of overall progress. |
173 | 188 | $incontext['step_weight'] = $step[3]; |
174 | 189 | // Make sure we reset the skip button. |
175 | 190 | $incontext['skip'] = false; |
176 | 191 | |
177 | 192 | // Call the step and if it returns false that means pause! |
178 | - if (function_exists($step[2]) && $step[2]() === false) { |
|
193 | + if (function_exists($step[2]) && $step[2]() === false) |
|
194 | + { |
|
179 | 195 | break; |
180 | 196 | } |
181 | 197 | |
182 | - if (function_exists($step[2])) { |
|
198 | + if (function_exists($step[2])) |
|
199 | + { |
|
183 | 200 | $incontext['current_step']++; |
184 | 201 | } |
185 | 202 | |
@@ -197,45 +214,56 @@ discard block |
||
197 | 214 | global $databases; |
198 | 215 | |
199 | 216 | // Just so people using older versions of PHP aren't left in the cold. |
200 | - if (!isset($_SERVER['PHP_SELF'])) { |
|
217 | + if (!isset($_SERVER['PHP_SELF'])) |
|
218 | + { |
|
201 | 219 | $_SERVER['PHP_SELF'] = $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] ?? 'install.php'; |
202 | 220 | } |
203 | 221 | |
204 | 222 | // In pre-release versions, report all errors. |
205 | - if (strspn(SMF_VERSION, '1234567890.') !== strlen(SMF_VERSION)) { |
|
223 | + if (strspn(SMF_VERSION, '1234567890.') !== strlen(SMF_VERSION)) |
|
224 | + { |
|
206 | 225 | error_reporting(E_ALL); |
207 | 226 | } |
208 | 227 | // Otherwise, report all errors except for deprecation notices. |
209 | - else { |
|
228 | + else |
|
229 | + { |
|
210 | 230 | error_reporting(E_ALL & ~E_DEPRECATED); |
211 | 231 | } |
212 | 232 | |
213 | 233 | // Fun. Low PHP version... |
214 | - if (!isset($_GET)) { |
|
234 | + if (!isset($_GET)) |
|
235 | + { |
|
215 | 236 | $GLOBALS['_GET']['step'] = 0; |
216 | 237 | |
217 | 238 | return; |
218 | 239 | } |
219 | 240 | |
220 | - if (!isset($_GET['obgz'])) { |
|
241 | + if (!isset($_GET['obgz'])) |
|
242 | + { |
|
221 | 243 | ob_start(); |
222 | 244 | |
223 | - if (ini_get('session.save_handler') == 'user') { |
|
245 | + if (ini_get('session.save_handler') == 'user') |
|
246 | + { |
|
224 | 247 | @ini_set('session.save_handler', 'files'); |
225 | 248 | } |
226 | 249 | |
227 | - if (function_exists('session_start')) { |
|
250 | + if (function_exists('session_start')) |
|
251 | + { |
|
228 | 252 | @session_start(); |
229 | 253 | } |
230 | - } else { |
|
254 | + } |
|
255 | + else |
|
256 | + { |
|
231 | 257 | ob_start('ob_gzhandler'); |
232 | 258 | |
233 | - if (ini_get('session.save_handler') == 'user') { |
|
259 | + if (ini_get('session.save_handler') == 'user') |
|
260 | + { |
|
234 | 261 | @ini_set('session.save_handler', 'files'); |
235 | 262 | } |
236 | 263 | session_start(); |
237 | 264 | |
238 | - if (!headers_sent()) { |
|
265 | + if (!headers_sent()) |
|
266 | + { |
|
239 | 267 | echo '<!DOCTYPE html> |
240 | 268 | <html> |
241 | 269 | <head> |
@@ -251,14 +279,17 @@ discard block |
||
251 | 279 | } |
252 | 280 | |
253 | 281 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
254 | - if (isset($_GET['delete'])) { |
|
255 | - if (isset($_SESSION['installer_temp_ftp'])) { |
|
282 | + if (isset($_GET['delete'])) |
|
283 | + { |
|
284 | + if (isset($_SESSION['installer_temp_ftp'])) |
|
285 | + { |
|
256 | 286 | $ftp = new FtpConnection($_SESSION['installer_temp_ftp']['server'], $_SESSION['installer_temp_ftp']['port'], $_SESSION['installer_temp_ftp']['username'], $_SESSION['installer_temp_ftp']['password']); |
257 | 287 | $ftp->chdir($_SESSION['installer_temp_ftp']['path']); |
258 | 288 | |
259 | 289 | $ftp->unlink('install.php'); |
260 | 290 | |
261 | - foreach ($databases as $key => $dummy) { |
|
291 | + foreach ($databases as $key => $dummy) |
|
292 | + { |
|
262 | 293 | $type = ($key == 'mysqli') ? 'mysql' : $key; |
263 | 294 | $ftp->unlink('install_' . DB_SCRIPT_VERSION . '_' . Db::getClass($type) . '.sql'); |
264 | 295 | } |
@@ -266,10 +297,13 @@ discard block |
||
266 | 297 | $ftp->close(); |
267 | 298 | |
268 | 299 | unset($_SESSION['installer_temp_ftp']); |
269 | - } else { |
|
300 | + } |
|
301 | + else |
|
302 | + { |
|
270 | 303 | @unlink(__FILE__); |
271 | 304 | |
272 | - foreach ($databases as $key => $dummy) { |
|
305 | + foreach ($databases as $key => $dummy) |
|
306 | + { |
|
273 | 307 | $type = ($key == 'mysqli') ? 'mysql' : $key; |
274 | 308 | @unlink(Config::$boarddir . '/install_' . DB_SCRIPT_VERSION . '_' . Db::getClass($type) . '.sql'); |
275 | 309 | } |
@@ -278,9 +312,12 @@ discard block |
||
278 | 312 | // Now just redirect to a blank.png... |
279 | 313 | $secure = false; |
280 | 314 | |
281 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
315 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
316 | + { |
|
282 | 317 | $secure = true; |
283 | - } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
318 | + } |
|
319 | + elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
320 | + { |
|
284 | 321 | $secure = true; |
285 | 322 | } |
286 | 323 | |
@@ -290,22 +327,28 @@ discard block |
||
290 | 327 | } |
291 | 328 | |
292 | 329 | // PHP 5 might cry if we don't do this now. |
293 | - if (function_exists('date_default_timezone_set')) { |
|
330 | + if (function_exists('date_default_timezone_set')) |
|
331 | + { |
|
294 | 332 | // Get PHP's default timezone, if set |
295 | 333 | $ini_tz = ini_get('date.timezone'); |
296 | 334 | |
297 | - if (!empty($ini_tz)) { |
|
335 | + if (!empty($ini_tz)) |
|
336 | + { |
|
298 | 337 | $timezone_id = $ini_tz; |
299 | - } else { |
|
338 | + } |
|
339 | + else |
|
340 | + { |
|
300 | 341 | $timezone_id = ''; |
301 | 342 | } |
302 | 343 | |
303 | 344 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
304 | - if (!in_array($timezone_id, timezone_identifiers_list())) { |
|
345 | + if (!in_array($timezone_id, timezone_identifiers_list())) |
|
346 | + { |
|
305 | 347 | $server_offset = @mktime(0, 0, 0, 1, 1, 1970) * -1; |
306 | 348 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
307 | 349 | |
308 | - if (empty($timezone_id)) { |
|
350 | + if (empty($timezone_id)) |
|
351 | + { |
|
309 | 352 | $timezone_id = 'UTC'; |
310 | 353 | } |
311 | 354 | } |
@@ -328,12 +371,15 @@ discard block |
||
328 | 371 | $incontext['detected_languages'] = []; |
329 | 372 | |
330 | 373 | // Make sure the languages directory actually exists. |
331 | - if (file_exists(Config::$boarddir . '/Themes/default/languages')) { |
|
374 | + if (file_exists(Config::$boarddir . '/Themes/default/languages')) |
|
375 | + { |
|
332 | 376 | // Find all the "Install" language files in the directory. |
333 | 377 | $dir = dir(Config::$boarddir . '/Themes/default/languages'); |
334 | 378 | |
335 | - while ($entry = $dir->read()) { |
|
336 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
379 | + while ($entry = $dir->read()) |
|
380 | + { |
|
381 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
382 | + { |
|
337 | 383 | $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
338 | 384 | } |
339 | 385 | } |
@@ -341,7 +387,8 @@ discard block |
||
341 | 387 | } |
342 | 388 | |
343 | 389 | // Didn't find any, show an error message! |
344 | - if (empty($incontext['detected_languages'])) { |
|
390 | + if (empty($incontext['detected_languages'])) |
|
391 | + { |
|
345 | 392 | // Let's not cache this message, eh? |
346 | 393 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
347 | 394 | header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
@@ -382,19 +429,24 @@ discard block |
||
382 | 429 | } |
383 | 430 | |
384 | 431 | // Override the language file? |
385 | - if (isset($_GET['lang_file'])) { |
|
432 | + if (isset($_GET['lang_file'])) |
|
433 | + { |
|
386 | 434 | $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
387 | - } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
435 | + } |
|
436 | + elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
437 | + { |
|
388 | 438 | $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
389 | 439 | } |
390 | 440 | |
391 | 441 | // Make sure it exists, if it doesn't reset it. |
392 | - if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(Config::$boarddir . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) { |
|
442 | + if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(Config::$boarddir . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
|
443 | + { |
|
393 | 444 | // Use the first one... |
394 | 445 | list($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
395 | 446 | |
396 | 447 | // If we have english and some other language, use the other language. We Americans hate english :P. |
397 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
448 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
449 | + { |
|
398 | 450 | list(, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
399 | 451 | } |
400 | 452 | } |
@@ -415,7 +467,8 @@ discard block |
||
415 | 467 | Config::$modSettings['disableQueryCheck'] = true; |
416 | 468 | |
417 | 469 | // Connect the database. |
418 | - if (empty(Db::$db->connection)) { |
|
470 | + if (empty(Db::$db->connection)) |
|
471 | + { |
|
419 | 472 | Db::load(); |
420 | 473 | } |
421 | 474 | } |
@@ -429,19 +482,23 @@ discard block |
||
429 | 482 | header('content-type: text/html; charset=' . (Lang::$txt['lang_character_set'] ?? 'UTF-8')); |
430 | 483 | |
431 | 484 | // We usually dump our templates out. |
432 | - if (!$fallThrough) { |
|
485 | + if (!$fallThrough) |
|
486 | + { |
|
433 | 487 | // The top install bit. |
434 | 488 | template_install_above(); |
435 | 489 | |
436 | 490 | // Call the template. |
437 | - if (isset($incontext['sub_template'])) { |
|
491 | + if (isset($incontext['sub_template'])) |
|
492 | + { |
|
438 | 493 | $incontext['form_url'] = $installurl . '?step=' . $incontext['current_step']; |
439 | 494 | |
440 | 495 | call_user_func('template_' . $incontext['sub_template']); |
441 | 496 | } |
442 | 497 | // @todo REMOVE THIS!! |
443 | - else { |
|
444 | - if (function_exists('doStep' . $_GET['step'])) { |
|
498 | + else |
|
499 | + { |
|
500 | + if (function_exists('doStep' . $_GET['step'])) |
|
501 | + { |
|
445 | 502 | call_user_func('doStep' . $_GET['step']); |
446 | 503 | } |
447 | 504 | } |
@@ -461,7 +518,8 @@ discard block |
||
461 | 518 | $incontext['sub_template'] = 'welcome_message'; |
462 | 519 | |
463 | 520 | // Done the submission? |
464 | - if (isset($_POST['contbutt'])) { |
|
521 | + if (isset($_POST['contbutt'])) |
|
522 | + { |
|
465 | 523 | return true; |
466 | 524 | } |
467 | 525 | |
@@ -470,79 +528,97 @@ discard block |
||
470 | 528 | |
471 | 529 | $settingsDefs = Config::getSettingsDefs(); |
472 | 530 | |
473 | - foreach (['db_passwd', 'boardurl'] as $var) { |
|
474 | - if (!empty(Config::${$var}) && Config::${$var} != $settingsDefs[$var]['default']) { |
|
531 | + foreach (['db_passwd', 'boardurl'] as $var) |
|
532 | + { |
|
533 | + if (!empty(Config::${$var}) && Config::${$var} != $settingsDefs[$var]['default']) |
|
534 | + { |
|
475 | 535 | $probably_installed++; |
476 | 536 | } |
477 | 537 | } |
478 | 538 | |
479 | - if ($probably_installed == 2) { |
|
539 | + if ($probably_installed == 2) |
|
540 | + { |
|
480 | 541 | $incontext['warning'] = Lang::$txt['error_already_installed']; |
481 | 542 | } |
482 | 543 | |
483 | 544 | // Is some database support even compiled in? |
484 | 545 | $incontext['supported_databases'] = []; |
485 | 546 | |
486 | - foreach ($databases as $key => $db) { |
|
487 | - if ($db['supported']) { |
|
547 | + foreach ($databases as $key => $db) |
|
548 | + { |
|
549 | + if ($db['supported']) |
|
550 | + { |
|
488 | 551 | $type = ($key == 'mysqli') ? 'mysql' : $key; |
489 | 552 | |
490 | - if (!file_exists(Config::$boarddir . '/install_' . DB_SCRIPT_VERSION . '_' . Db::getClass($type) . '.sql')) { |
|
553 | + if (!file_exists(Config::$boarddir . '/install_' . DB_SCRIPT_VERSION . '_' . Db::getClass($type) . '.sql')) |
|
554 | + { |
|
491 | 555 | $databases[$key]['supported'] = false; |
492 | 556 | $notFoundSQLFile = true; |
493 | 557 | Lang::$txt['error_db_script_missing'] = sprintf(Lang::$txt['error_db_script_missing'], 'install_' . DB_SCRIPT_VERSION . '_' . Db::getClass($type) . '.sql'); |
494 | - } else { |
|
558 | + } |
|
559 | + else |
|
560 | + { |
|
495 | 561 | $incontext['supported_databases'][] = $db; |
496 | 562 | } |
497 | 563 | } |
498 | 564 | } |
499 | 565 | |
500 | 566 | // Check the PHP version. |
501 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
567 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
568 | + { |
|
502 | 569 | $error = 'error_php_too_low'; |
503 | 570 | } |
504 | 571 | // Make sure we have a supported database |
505 | - elseif (empty($incontext['supported_databases'])) { |
|
572 | + elseif (empty($incontext['supported_databases'])) |
|
573 | + { |
|
506 | 574 | $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
507 | 575 | } |
508 | 576 | // How about session support? Some crazy sysadmin remove it? |
509 | - elseif (!function_exists('session_start')) { |
|
577 | + elseif (!function_exists('session_start')) |
|
578 | + { |
|
510 | 579 | $error = 'error_session_missing'; |
511 | 580 | } |
512 | 581 | // Make sure they uploaded all the files. |
513 | - elseif (!file_exists(Config::$boarddir . '/index.php')) { |
|
582 | + elseif (!file_exists(Config::$boarddir . '/index.php')) |
|
583 | + { |
|
514 | 584 | $error = 'error_missing_files'; |
515 | 585 | } |
516 | 586 | // Very simple check on the session.save_path for Windows. |
517 | 587 | // @todo Move this down later if they don't use database-driven sessions? |
518 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
588 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
589 | + { |
|
519 | 590 | $error = 'error_session_save_path'; |
520 | 591 | } |
521 | 592 | |
522 | 593 | // Since each of the three messages would look the same, anyway... |
523 | - if (isset($error)) { |
|
594 | + if (isset($error)) |
|
595 | + { |
|
524 | 596 | $incontext['error'] = Lang::$txt[$error]; |
525 | 597 | } |
526 | 598 | |
527 | 599 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
528 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
600 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
601 | + { |
|
529 | 602 | $incontext['error'] = Lang::$txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . Lang::$txt['error_message_click'] . '</a> ' . Lang::$txt['error_message_bad_try_again']; |
530 | 603 | } |
531 | 604 | |
532 | 605 | // Confirm mbstring is loaded... |
533 | - if (!extension_loaded('mbstring')) { |
|
606 | + if (!extension_loaded('mbstring')) |
|
607 | + { |
|
534 | 608 | $incontext['error'] = Lang::$txt['install_no_mbstring']; |
535 | 609 | } |
536 | 610 | |
537 | 611 | // Confirm fileinfo is loaded... |
538 | - if (!extension_loaded('fileinfo')) { |
|
612 | + if (!extension_loaded('fileinfo')) |
|
613 | + { |
|
539 | 614 | $incontext['error'] = Lang::$txt['install_no_fileinfo']; |
540 | 615 | } |
541 | 616 | |
542 | 617 | // Check for https stream support. |
543 | 618 | $supported_streams = stream_get_wrappers(); |
544 | 619 | |
545 | - if (!in_array('https', $supported_streams)) { |
|
620 | + if (!in_array('https', $supported_streams)) |
|
621 | + { |
|
546 | 622 | $incontext['warning'] = Lang::$txt['install_no_https']; |
547 | 623 | } |
548 | 624 | |
@@ -570,49 +646,60 @@ discard block |
||
570 | 646 | 'cache/db_last_error.php', |
571 | 647 | ]; |
572 | 648 | |
573 | - foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
649 | + foreach ($incontext['detected_languages'] as $lang => $temp) |
|
650 | + { |
|
574 | 651 | $extra_files[] = 'Themes/default/languages/' . $lang; |
575 | 652 | } |
576 | 653 | |
577 | 654 | // With mod_security installed, we could attempt to fix it with .htaccess. |
578 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
655 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
656 | + { |
|
579 | 657 | $writable_files[] = file_exists(Config::$boarddir . '/.htaccess') ? '.htaccess' : '.'; |
580 | 658 | } |
581 | 659 | |
582 | 660 | $failed_files = []; |
583 | 661 | |
584 | 662 | // On linux, it's easy - just use is_writable! |
585 | - if (substr(__FILE__, 1, 2) != ':\\') { |
|
663 | + if (substr(__FILE__, 1, 2) != ':\\') |
|
664 | + { |
|
586 | 665 | $incontext['systemos'] = 'linux'; |
587 | 666 | |
588 | - foreach ($writable_files as $file) { |
|
667 | + foreach ($writable_files as $file) |
|
668 | + { |
|
589 | 669 | // Some files won't exist, try to address up front |
590 | - if (!file_exists(Config::$boarddir . '/' . $file)) { |
|
670 | + if (!file_exists(Config::$boarddir . '/' . $file)) |
|
671 | + { |
|
591 | 672 | @touch(Config::$boarddir . '/' . $file); |
592 | 673 | } |
593 | 674 | |
594 | 675 | // NOW do the writable check... |
595 | - if (!is_writable(Config::$boarddir . '/' . $file)) { |
|
676 | + if (!is_writable(Config::$boarddir . '/' . $file)) |
|
677 | + { |
|
596 | 678 | @chmod(Config::$boarddir . '/' . $file, 0755); |
597 | 679 | |
598 | 680 | // Well, 755 hopefully worked... if not, try 777. |
599 | - if (!is_writable(Config::$boarddir . '/' . $file) && !@chmod(Config::$boarddir . '/' . $file, 0777)) { |
|
681 | + if (!is_writable(Config::$boarddir . '/' . $file) && !@chmod(Config::$boarddir . '/' . $file, 0777)) |
|
682 | + { |
|
600 | 683 | $failed_files[] = $file; |
601 | 684 | } |
602 | 685 | } |
603 | 686 | } |
604 | 687 | |
605 | - foreach ($extra_files as $file) { |
|
688 | + foreach ($extra_files as $file) |
|
689 | + { |
|
606 | 690 | @chmod(Config::$boarddir . (empty($file) ? '' : '/' . $file), 0777); |
607 | 691 | } |
608 | 692 | } |
609 | 693 | // Windows is trickier. Let's try opening for r+... |
610 | - else { |
|
694 | + else |
|
695 | + { |
|
611 | 696 | $incontext['systemos'] = 'windows'; |
612 | 697 | |
613 | - foreach ($writable_files as $file) { |
|
698 | + foreach ($writable_files as $file) |
|
699 | + { |
|
614 | 700 | // Folders can't be opened for write... but the index.php in them can ;) |
615 | - if (is_dir(Config::$boarddir . '/' . $file)) { |
|
701 | + if (is_dir(Config::$boarddir . '/' . $file)) |
|
702 | + { |
|
616 | 703 | $file .= '/index.php'; |
617 | 704 | } |
618 | 705 | |
@@ -621,25 +708,29 @@ discard block |
||
621 | 708 | $fp = @fopen(Config::$boarddir . '/' . $file, 'r+'); |
622 | 709 | |
623 | 710 | // Hmm, okay, try just for write in that case... |
624 | - if (!is_resource($fp)) { |
|
711 | + if (!is_resource($fp)) |
|
712 | + { |
|
625 | 713 | $fp = @fopen(Config::$boarddir . '/' . $file, 'w'); |
626 | 714 | } |
627 | 715 | |
628 | - if (!is_resource($fp)) { |
|
716 | + if (!is_resource($fp)) |
|
717 | + { |
|
629 | 718 | $failed_files[] = $file; |
630 | 719 | } |
631 | 720 | |
632 | 721 | @fclose($fp); |
633 | 722 | } |
634 | 723 | |
635 | - foreach ($extra_files as $file) { |
|
724 | + foreach ($extra_files as $file) |
|
725 | + { |
|
636 | 726 | @chmod(Config::$boarddir . (empty($file) ? '' : '/' . $file), 0777); |
637 | 727 | } |
638 | 728 | } |
639 | 729 | |
640 | 730 | $failure = count($failed_files) >= 1; |
641 | 731 | |
642 | - if (!isset($_SERVER)) { |
|
732 | + if (!isset($_SERVER)) |
|
733 | + { |
|
643 | 734 | return !$failure; |
644 | 735 | } |
645 | 736 | |
@@ -647,7 +738,8 @@ discard block |
||
647 | 738 | $incontext['failed_files'] = $failed_files; |
648 | 739 | |
649 | 740 | // It's not going to be possible to use FTP on windows to solve the problem... |
650 | - if ($failure && substr(__FILE__, 1, 2) == ':\\') { |
|
741 | + if ($failure && substr(__FILE__, 1, 2) == ':\\') |
|
742 | + { |
|
651 | 743 | $incontext['error'] = Lang::$txt['error_windows_chmod'] . ' |
652 | 744 | <ul class="error_content"> |
653 | 745 | <li>' . implode('</li> |
@@ -658,9 +750,11 @@ discard block |
||
658 | 750 | } |
659 | 751 | |
660 | 752 | // We're going to have to use... FTP! |
661 | - if ($failure) { |
|
753 | + if ($failure) |
|
754 | + { |
|
662 | 755 | // Load any session data we might have... |
663 | - if (!isset($_POST['ftp_username']) && isset($_SESSION['installer_temp_ftp'])) { |
|
756 | + if (!isset($_POST['ftp_username']) && isset($_SESSION['installer_temp_ftp'])) |
|
757 | + { |
|
664 | 758 | $_POST['ftp_server'] = $_SESSION['installer_temp_ftp']['server']; |
665 | 759 | $_POST['ftp_port'] = $_SESSION['installer_temp_ftp']['port']; |
666 | 760 | $_POST['ftp_username'] = $_SESSION['installer_temp_ftp']['username']; |
@@ -670,34 +764,42 @@ discard block |
||
670 | 764 | |
671 | 765 | $incontext['ftp_errors'] = []; |
672 | 766 | |
673 | - if (isset($_POST['ftp_username'])) { |
|
767 | + if (isset($_POST['ftp_username'])) |
|
768 | + { |
|
674 | 769 | $ftp = new FtpConnection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']); |
675 | 770 | |
676 | - if ($ftp->error === false) { |
|
771 | + if ($ftp->error === false) |
|
772 | + { |
|
677 | 773 | // Try it without /home/abc just in case they messed up. |
678 | - if (!$ftp->chdir($_POST['ftp_path'])) { |
|
774 | + if (!$ftp->chdir($_POST['ftp_path'])) |
|
775 | + { |
|
679 | 776 | $incontext['ftp_errors'][] = $ftp->last_message; |
680 | 777 | $ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $_POST['ftp_path'])); |
681 | 778 | } |
682 | 779 | } |
683 | 780 | } |
684 | 781 | |
685 | - if (!isset($ftp) || $ftp->error !== false) { |
|
686 | - if (!isset($ftp)) { |
|
782 | + if (!isset($ftp) || $ftp->error !== false) |
|
783 | + { |
|
784 | + if (!isset($ftp)) |
|
785 | + { |
|
687 | 786 | $ftp = new FtpConnection(null); |
688 | 787 | } |
689 | 788 | // Save the error so we can mess with listing... |
690 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
789 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
790 | + { |
|
691 | 791 | $incontext['ftp_errors'][] = $ftp->last_message; |
692 | 792 | } |
693 | 793 | |
694 | 794 | list($username, $detect_path, $found_path) = $ftp->detect_path(Config::$boarddir); |
695 | 795 | |
696 | - if (empty($_POST['ftp_path']) && $found_path) { |
|
796 | + if (empty($_POST['ftp_path']) && $found_path) |
|
797 | + { |
|
697 | 798 | $_POST['ftp_path'] = $detect_path; |
698 | 799 | } |
699 | 800 | |
700 | - if (!isset($_POST['ftp_username'])) { |
|
801 | + if (!isset($_POST['ftp_username'])) |
|
802 | + { |
|
701 | 803 | $_POST['ftp_username'] = $username; |
702 | 804 | } |
703 | 805 | |
@@ -724,16 +826,20 @@ discard block |
||
724 | 826 | |
725 | 827 | $failed_files_updated = []; |
726 | 828 | |
727 | - foreach ($failed_files as $file) { |
|
728 | - if (!is_writable(Config::$boarddir . '/' . $file)) { |
|
829 | + foreach ($failed_files as $file) |
|
830 | + { |
|
831 | + if (!is_writable(Config::$boarddir . '/' . $file)) |
|
832 | + { |
|
729 | 833 | $ftp->chmod($file, 0755); |
730 | 834 | } |
731 | 835 | |
732 | - if (!is_writable(Config::$boarddir . '/' . $file)) { |
|
836 | + if (!is_writable(Config::$boarddir . '/' . $file)) |
|
837 | + { |
|
733 | 838 | $ftp->chmod($file, 0777); |
734 | 839 | } |
735 | 840 | |
736 | - if (!is_writable(Config::$boarddir . '/' . $file)) { |
|
841 | + if (!is_writable(Config::$boarddir . '/' . $file)) |
|
842 | + { |
|
737 | 843 | $failed_files_updated[] = $file; |
738 | 844 | $incontext['ftp_errors'][] = rtrim($ftp->last_message) . ' -> ' . $file . "\n"; |
739 | 845 | } |
@@ -742,7 +848,8 @@ discard block |
||
742 | 848 | $ftp->close(); |
743 | 849 | |
744 | 850 | // Are there any errors left? |
745 | - if (count($failed_files_updated) >= 1) { |
|
851 | + if (count($failed_files_updated) >= 1) |
|
852 | + { |
|
746 | 853 | // Guess there are... |
747 | 854 | $incontext['failed_files'] = $failed_files_updated; |
748 | 855 | |
@@ -777,22 +884,28 @@ discard block |
||
777 | 884 | |
778 | 885 | $foundOne = false; |
779 | 886 | |
780 | - foreach ($databases as $key => $db) { |
|
887 | + foreach ($databases as $key => $db) |
|
888 | + { |
|
781 | 889 | // Override with the defaults for this DB if appropriate. |
782 | - if ($db['supported']) { |
|
890 | + if ($db['supported']) |
|
891 | + { |
|
783 | 892 | $incontext['supported_databases'][$key] = $db; |
784 | 893 | |
785 | - if (!$foundOne) { |
|
786 | - if (isset($db['default_host'])) { |
|
894 | + if (!$foundOne) |
|
895 | + { |
|
896 | + if (isset($db['default_host'])) |
|
897 | + { |
|
787 | 898 | $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
788 | 899 | } |
789 | 900 | |
790 | - if (isset($db['default_user'])) { |
|
901 | + if (isset($db['default_user'])) |
|
902 | + { |
|
791 | 903 | $incontext['db']['user'] = ini_get($db['default_user']); |
792 | 904 | $incontext['db']['name'] = ini_get($db['default_user']); |
793 | 905 | } |
794 | 906 | |
795 | - if (isset($db['default_password'])) { |
|
907 | + if (isset($db['default_password'])) |
|
908 | + { |
|
796 | 909 | $incontext['db']['pass'] = ini_get($db['default_password']); |
797 | 910 | } |
798 | 911 | |
@@ -806,28 +919,34 @@ discard block |
||
806 | 919 | } |
807 | 920 | |
808 | 921 | // Override for repost. |
809 | - if (isset($_POST['db_user'])) { |
|
922 | + if (isset($_POST['db_user'])) |
|
923 | + { |
|
810 | 924 | $incontext['db']['user'] = $_POST['db_user']; |
811 | 925 | $incontext['db']['name'] = $_POST['db_name']; |
812 | 926 | $incontext['db']['server'] = $_POST['db_server']; |
813 | 927 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
814 | 928 | |
815 | - if (!empty($_POST['db_port'])) { |
|
929 | + if (!empty($_POST['db_port'])) |
|
930 | + { |
|
816 | 931 | $incontext['db']['port'] = $_POST['db_port']; |
817 | 932 | } |
818 | - } else { |
|
933 | + } |
|
934 | + else |
|
935 | + { |
|
819 | 936 | $incontext['db']['prefix'] = 'smf_'; |
820 | 937 | } |
821 | 938 | |
822 | 939 | // Are we submitting? |
823 | - if (isset($_POST['db_type'])) { |
|
940 | + if (isset($_POST['db_type'])) |
|
941 | + { |
|
824 | 942 | // What type are they trying? |
825 | 943 | $db_type = preg_replace('~[^A-Za-z0-9]~', '', $_POST['db_type']); |
826 | 944 | $db_prefix = $_POST['db_prefix']; |
827 | 945 | // Validate the prefix. |
828 | 946 | $valid_prefix = $databases[$db_type]['validate_prefix']($db_prefix); |
829 | 947 | |
830 | - if ($valid_prefix !== true) { |
|
948 | + if ($valid_prefix !== true) |
|
949 | + { |
|
831 | 950 | $incontext['error'] = $valid_prefix; |
832 | 951 | |
833 | 952 | return false; |
@@ -846,17 +965,22 @@ discard block |
||
846 | 965 | ]; |
847 | 966 | |
848 | 967 | // Only set the port if we're not using the default |
849 | - if (!empty($_POST['db_port'])) { |
|
968 | + if (!empty($_POST['db_port'])) |
|
969 | + { |
|
850 | 970 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
851 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
971 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
972 | + { |
|
852 | 973 | $vars['db_port'] = (int) $_POST['db_port']; |
853 | - } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
974 | + } |
|
975 | + elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
976 | + { |
|
854 | 977 | $vars['db_port'] = (int) $_POST['db_port']; |
855 | 978 | } |
856 | 979 | } |
857 | 980 | |
858 | 981 | // God I hope it saved! |
859 | - if (!installer_updateSettingsFile($vars)) { |
|
982 | + if (!installer_updateSettingsFile($vars)) |
|
983 | + { |
|
860 | 984 | $incontext['error'] = Lang::$txt['settings_error']; |
861 | 985 | |
862 | 986 | return false; |
@@ -866,7 +990,8 @@ discard block |
||
866 | 990 | Config::load(); |
867 | 991 | |
868 | 992 | // Better find the database file! |
869 | - if (!file_exists(Config::$sourcedir . '/Db/APIs/' . Db::getClass(Config::$db_type) . '.php')) { |
|
993 | + if (!file_exists(Config::$sourcedir . '/Db/APIs/' . Db::getClass(Config::$db_type) . '.php')) |
|
994 | + { |
|
870 | 995 | $incontext['error'] = sprintf(Lang::$txt['error_db_file'], 'Db/APIs/' . Db::getClass(Config::$db_type) . '.php'); |
871 | 996 | |
872 | 997 | return false; |
@@ -880,16 +1005,19 @@ discard block |
||
880 | 1005 | Db::load(['non_fatal' => true, 'dont_select_db' => !$needsDB]); |
881 | 1006 | |
882 | 1007 | // Still no connection? Big fat error message :P. |
883 | - if (!Db::$db->connection) { |
|
1008 | + if (!Db::$db->connection) |
|
1009 | + { |
|
884 | 1010 | // Get error info... Recast just in case we get false or 0... |
885 | 1011 | $error_message = Db::$db->connect_error(); |
886 | 1012 | |
887 | - if (empty($error_message)) { |
|
1013 | + if (empty($error_message)) |
|
1014 | + { |
|
888 | 1015 | $error_message = ''; |
889 | 1016 | } |
890 | 1017 | $error_number = Db::$db->connect_errno(); |
891 | 1018 | |
892 | - if (empty($error_number)) { |
|
1019 | + if (empty($error_number)) |
|
1020 | + { |
|
893 | 1021 | $error_number = ''; |
894 | 1022 | } |
895 | 1023 | $db_error = (!empty($error_number) ? $error_number . ': ' : '') . $error_message; |
@@ -901,14 +1029,16 @@ discard block |
||
901 | 1029 | |
902 | 1030 | // Do they meet the install requirements? |
903 | 1031 | // @todo Old client, new server? |
904 | - if (version_compare($databases[Config::$db_type]['version'], preg_replace('~^\D*|\-.+?$~', '', $databases[Config::$db_type]['version_check']())) > 0) { |
|
1032 | + if (version_compare($databases[Config::$db_type]['version'], preg_replace('~^\D*|\-.+?$~', '', $databases[Config::$db_type]['version_check']())) > 0) |
|
1033 | + { |
|
905 | 1034 | $incontext['error'] = Lang::$txt['error_db_too_low']; |
906 | 1035 | |
907 | 1036 | return false; |
908 | 1037 | } |
909 | 1038 | |
910 | 1039 | // Let's try that database on for size... assuming we haven't already lost the opportunity. |
911 | - if (Db::$db->name != '' && !$needsDB) { |
|
1040 | + if (Db::$db->name != '' && !$needsDB) |
|
1041 | + { |
|
912 | 1042 | Db::$db->query( |
913 | 1043 | '', |
914 | 1044 | 'CREATE DATABASE IF NOT EXISTS `' . Db::$db->name . '`', |
@@ -920,7 +1050,8 @@ discard block |
||
920 | 1050 | ); |
921 | 1051 | |
922 | 1052 | // Okay, let's try the prefix if it didn't work... |
923 | - if (!Db::$db->select(Db::$db->name, Db::$db->connection) && Db::$db->name != '') { |
|
1053 | + if (!Db::$db->select(Db::$db->name, Db::$db->connection) && Db::$db->name != '') |
|
1054 | + { |
|
924 | 1055 | Db::$db->query( |
925 | 1056 | '', |
926 | 1057 | 'CREATE DATABASE IF NOT EXISTS `' . Db::$db->prefix . Db::$db->name . '`', |
@@ -931,14 +1062,16 @@ discard block |
||
931 | 1062 | Db::$db->connection, |
932 | 1063 | ); |
933 | 1064 | |
934 | - if (Db::$db->select(Db::$db->prefix . Db::$db->name, Db::$db->connection)) { |
|
1065 | + if (Db::$db->select(Db::$db->prefix . Db::$db->name, Db::$db->connection)) |
|
1066 | + { |
|
935 | 1067 | Db::$db->name = Db::$db->prefix . Db::$db->name; |
936 | 1068 | installer_updateSettingsFile(['db_name' => Db::$db->name]); |
937 | 1069 | } |
938 | 1070 | } |
939 | 1071 | |
940 | 1072 | // Okay, now let's try to connect... |
941 | - if (!Db::$db->select(Db::$db->name, Db::$db->connection)) { |
|
1073 | + if (!Db::$db->select(Db::$db->name, Db::$db->connection)) |
|
1074 | + { |
|
942 | 1075 | $incontext['error'] = sprintf(Lang::$txt['error_db_database'], Db::$db->name); |
943 | 1076 | |
944 | 1077 | return false; |
@@ -960,12 +1093,14 @@ discard block |
||
960 | 1093 | $incontext['page_title'] = Lang::$txt['install_settings']; |
961 | 1094 | |
962 | 1095 | // Let's see if we got the database type correct. |
963 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
1096 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
1097 | + { |
|
964 | 1098 | Config::$db_type = $_POST['db_type']; |
965 | 1099 | } |
966 | 1100 | |
967 | 1101 | // Else we'd better be able to get the connection. |
968 | - else { |
|
1102 | + else |
|
1103 | + { |
|
969 | 1104 | load_database(); |
970 | 1105 | } |
971 | 1106 | |
@@ -976,9 +1111,12 @@ discard block |
||
976 | 1111 | |
977 | 1112 | $secure = false; |
978 | 1113 | |
979 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
1114 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
1115 | + { |
|
980 | 1116 | $secure = true; |
981 | - } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
1117 | + } |
|
1118 | + elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
1119 | + { |
|
982 | 1120 | $secure = true; |
983 | 1121 | } |
984 | 1122 | |
@@ -991,7 +1129,8 @@ discard block |
||
991 | 1129 | $incontext['continue'] = 1; |
992 | 1130 | |
993 | 1131 | // Check Postgres setting |
994 | - if (Config::$db_type === 'postgresql') { |
|
1132 | + if (Config::$db_type === 'postgresql') |
|
1133 | + { |
|
995 | 1134 | load_database(); |
996 | 1135 | $result = Db::$db->query( |
997 | 1136 | '', |
@@ -1001,10 +1140,12 @@ discard block |
||
1001 | 1140 | ], |
1002 | 1141 | ); |
1003 | 1142 | |
1004 | - if ($result !== false) { |
|
1143 | + if ($result !== false) |
|
1144 | + { |
|
1005 | 1145 | $row = Db::$db->fetch_assoc($result); |
1006 | 1146 | |
1007 | - if ($row['standard_conforming_strings'] !== 'on') { |
|
1147 | + if ($row['standard_conforming_strings'] !== 'on') |
|
1148 | + { |
|
1008 | 1149 | $incontext['continue'] = 0; |
1009 | 1150 | $incontext['error'] = Lang::$txt['error_pg_scs']; |
1010 | 1151 | } |
@@ -1019,39 +1160,50 @@ discard block |
||
1019 | 1160 | // If redirect in effect, force SSL ON. |
1020 | 1161 | $url = new Url($incontext['detected_url']); |
1021 | 1162 | |
1022 | - if ($url->redirectsToHttps()) { |
|
1163 | + if ($url->redirectsToHttps()) |
|
1164 | + { |
|
1023 | 1165 | $incontext['ssl_chkbx_protected'] = true; |
1024 | 1166 | $incontext['ssl_chkbx_checked'] = true; |
1025 | 1167 | $_POST['force_ssl'] = true; |
1026 | 1168 | } |
1027 | 1169 | |
1028 | 1170 | // If no cert, make sure SSL stays OFF. |
1029 | - if (!$url->hasSSL()) { |
|
1171 | + if (!$url->hasSSL()) |
|
1172 | + { |
|
1030 | 1173 | $incontext['ssl_chkbx_protected'] = true; |
1031 | 1174 | $incontext['ssl_chkbx_checked'] = false; |
1032 | 1175 | } |
1033 | 1176 | |
1034 | 1177 | // Submitting? |
1035 | - if (isset($_POST['boardurl'])) { |
|
1036 | - if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1178 | + if (isset($_POST['boardurl'])) |
|
1179 | + { |
|
1180 | + if (substr($_POST['boardurl'], -10) == '/index.php') |
|
1181 | + { |
|
1037 | 1182 | $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
1038 | - } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1183 | + } |
|
1184 | + elseif (substr($_POST['boardurl'], -1) == '/') |
|
1185 | + { |
|
1039 | 1186 | $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
1040 | 1187 | } |
1041 | 1188 | |
1042 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1189 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
1190 | + { |
|
1043 | 1191 | $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
1044 | 1192 | } |
1045 | 1193 | |
1046 | 1194 | // Make sure boardurl is aligned with ssl setting |
1047 | - if (empty($_POST['force_ssl'])) { |
|
1195 | + if (empty($_POST['force_ssl'])) |
|
1196 | + { |
|
1048 | 1197 | $_POST['boardurl'] = strtr($_POST['boardurl'], ['https://' => 'http://']); |
1049 | - } else { |
|
1198 | + } |
|
1199 | + else |
|
1200 | + { |
|
1050 | 1201 | $_POST['boardurl'] = strtr($_POST['boardurl'], ['http://' => 'https://']); |
1051 | 1202 | } |
1052 | 1203 | |
1053 | 1204 | // Make sure international domain names are normalized correctly. |
1054 | - if (Lang::$txt['lang_character_set'] == 'UTF-8') { |
|
1205 | + if (Lang::$txt['lang_character_set'] == 'UTF-8') |
|
1206 | + { |
|
1055 | 1207 | $_POST['boardurl'] = (string) new Url($_POST['boardurl'], true); |
1056 | 1208 | } |
1057 | 1209 | |
@@ -1074,7 +1226,8 @@ discard block |
||
1074 | 1226 | ]; |
1075 | 1227 | |
1076 | 1228 | // Must save! |
1077 | - if (!installer_updateSettingsFile($vars)) { |
|
1229 | + if (!installer_updateSettingsFile($vars)) |
|
1230 | + { |
|
1078 | 1231 | $incontext['error'] = Lang::$txt['settings_error']; |
1079 | 1232 | |
1080 | 1233 | return false; |
@@ -1084,13 +1237,15 @@ discard block |
||
1084 | 1237 | Config::load(); |
1085 | 1238 | |
1086 | 1239 | // UTF-8 requires a setting to override the language charset. |
1087 | - if (!$databases[Config::$db_type]['utf8_support']()) { |
|
1240 | + if (!$databases[Config::$db_type]['utf8_support']()) |
|
1241 | + { |
|
1088 | 1242 | $incontext['error'] = sprintf(Lang::$txt['error_utf8_support']); |
1089 | 1243 | |
1090 | 1244 | return false; |
1091 | 1245 | } |
1092 | 1246 | |
1093 | - if (!empty($databases[Config::$db_type]['utf8_version_check']) && version_compare($databases[Config::$db_type]['utf8_version'], preg_replace('~\-.+?$~', '', $databases[Config::$db_type]['utf8_version_check']()), '>')) { |
|
1247 | + if (!empty($databases[Config::$db_type]['utf8_version_check']) && version_compare($databases[Config::$db_type]['utf8_version'], preg_replace('~\-.+?$~', '', $databases[Config::$db_type]['utf8_version_check']()), '>')) |
|
1248 | + { |
|
1094 | 1249 | $incontext['error'] = sprintf(Lang::$txt['error_utf8_version'], $databases[Config::$db_type]['utf8_version']); |
1095 | 1250 | |
1096 | 1251 | return false; |
@@ -1116,7 +1271,8 @@ discard block |
||
1116 | 1271 | $incontext['continue'] = 1; |
1117 | 1272 | |
1118 | 1273 | // Already done? |
1119 | - if (isset($_POST['pop_done'])) { |
|
1274 | + if (isset($_POST['pop_done'])) |
|
1275 | + { |
|
1120 | 1276 | return true; |
1121 | 1277 | } |
1122 | 1278 | |
@@ -1135,15 +1291,18 @@ discard block |
||
1135 | 1291 | ); |
1136 | 1292 | $newSettings = []; |
1137 | 1293 | |
1138 | - if ($result !== false) { |
|
1139 | - while ($row = Db::$db->fetch_assoc($result)) { |
|
1294 | + if ($result !== false) |
|
1295 | + { |
|
1296 | + while ($row = Db::$db->fetch_assoc($result)) |
|
1297 | + { |
|
1140 | 1298 | Config::$modSettings[$row['variable']] = $row['value']; |
1141 | 1299 | } |
1142 | 1300 | |
1143 | 1301 | Db::$db->free_result($result); |
1144 | 1302 | |
1145 | 1303 | // Do they match? If so, this is just a refresh so charge on! |
1146 | - if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] != SMF_VERSION) { |
|
1304 | + if (!isset(Config::$modSettings['smfVersion']) || Config::$modSettings['smfVersion'] != SMF_VERSION) |
|
1305 | + { |
|
1147 | 1306 | $incontext['error'] = Lang::$txt['error_versions_do_not_match']; |
1148 | 1307 | |
1149 | 1308 | return false; |
@@ -1162,9 +1321,12 @@ discard block |
||
1162 | 1321 | ); |
1163 | 1322 | |
1164 | 1323 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1165 | - if (substr(__DIR__, -1) == '\\') { |
|
1324 | + if (substr(__DIR__, -1) == '\\') |
|
1325 | + { |
|
1166 | 1326 | $attachdir = __DIR__ . 'attachments'; |
1167 | - } else { |
|
1327 | + } |
|
1328 | + else |
|
1329 | + { |
|
1168 | 1330 | $attachdir = __DIR__ . '/attachments'; |
1169 | 1331 | } |
1170 | 1332 | |
@@ -1181,23 +1343,28 @@ discard block |
||
1181 | 1343 | '{$registration_method}' => $_POST['reg_mode'] ?? 0, |
1182 | 1344 | ]; |
1183 | 1345 | |
1184 | - foreach (Lang::$txt as $key => $value) { |
|
1185 | - if (substr($key, 0, 8) == 'default_') { |
|
1346 | + foreach (Lang::$txt as $key => $value) |
|
1347 | + { |
|
1348 | + if (substr($key, 0, 8) == 'default_') |
|
1349 | + { |
|
1186 | 1350 | $replaces['{$' . $key . '}'] = Db::$db->escape_string($value); |
1187 | 1351 | } |
1188 | 1352 | } |
1189 | 1353 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], ['\\\\n' => '\\n']); |
1190 | 1354 | |
1191 | 1355 | // MySQL-specific stuff - storage engine and UTF8 handling |
1192 | - if (substr(Config::$db_type, 0, 5) == 'mysql') { |
|
1356 | + if (substr(Config::$db_type, 0, 5) == 'mysql') |
|
1357 | + { |
|
1193 | 1358 | // Just in case the query fails for some reason... |
1194 | 1359 | $engines = []; |
1195 | 1360 | |
1196 | 1361 | // Figure out storage engines - what do we have, etc. |
1197 | 1362 | $get_engines = Db::$db->query('', 'SHOW ENGINES', []); |
1198 | 1363 | |
1199 | - while ($row = Db::$db->fetch_assoc($get_engines)) { |
|
1200 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1364 | + while ($row = Db::$db->fetch_assoc($get_engines)) |
|
1365 | + { |
|
1366 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1367 | + { |
|
1201 | 1368 | $engines[] = $row['Engine']; |
1202 | 1369 | } |
1203 | 1370 | } |
@@ -1215,11 +1382,14 @@ discard block |
||
1215 | 1382 | $replaces['{$memory}'] .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
1216 | 1383 | |
1217 | 1384 | // One last thing - if we don't have InnoDB, we can't do transactions... |
1218 | - if (!$has_innodb) { |
|
1385 | + if (!$has_innodb) |
|
1386 | + { |
|
1219 | 1387 | $replaces['START TRANSACTION;'] = ''; |
1220 | 1388 | $replaces['COMMIT;'] = ''; |
1221 | 1389 | } |
1222 | - } else { |
|
1390 | + } |
|
1391 | + else |
|
1392 | + { |
|
1223 | 1393 | $has_innodb = false; |
1224 | 1394 | } |
1225 | 1395 | |
@@ -1238,24 +1408,31 @@ discard block |
||
1238 | 1408 | 'insert_dups' => 0, |
1239 | 1409 | ]; |
1240 | 1410 | |
1241 | - foreach ($sql_lines as $count => $line) { |
|
1411 | + foreach ($sql_lines as $count => $line) |
|
1412 | + { |
|
1242 | 1413 | // No comments allowed! |
1243 | - if (substr(trim($line), 0, 1) != '#') { |
|
1414 | + if (substr(trim($line), 0, 1) != '#') |
|
1415 | + { |
|
1244 | 1416 | $current_statement .= "\n" . rtrim($line); |
1245 | 1417 | } |
1246 | 1418 | |
1247 | 1419 | // Is this the end of the query string? |
1248 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1420 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1421 | + { |
|
1249 | 1422 | continue; |
1250 | 1423 | } |
1251 | 1424 | |
1252 | 1425 | // Does this table already exist? If so, don't insert more data into it! |
1253 | - if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) { |
|
1426 | + if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
|
1427 | + { |
|
1254 | 1428 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1255 | 1429 | |
1256 | - if (!empty($matches[0])) { |
|
1430 | + if (!empty($matches[0])) |
|
1431 | + { |
|
1257 | 1432 | $incontext['sql_results']['insert_dups'] += count($matches[0]); |
1258 | - } else { |
|
1433 | + } |
|
1434 | + else |
|
1435 | + { |
|
1259 | 1436 | $incontext['sql_results']['insert_dups']++; |
1260 | 1437 | } |
1261 | 1438 | |
@@ -1264,27 +1441,38 @@ discard block |
||
1264 | 1441 | continue; |
1265 | 1442 | } |
1266 | 1443 | |
1267 | - if (Db::$db->query('', $current_statement, ['security_override' => true, 'db_error_skip' => true], Db::$db->connection) === false) { |
|
1444 | + if (Db::$db->query('', $current_statement, ['security_override' => true, 'db_error_skip' => true], Db::$db->connection) === false) |
|
1445 | + { |
|
1268 | 1446 | // Error 1050: Table already exists! |
1269 | 1447 | // @todo Needs to be made better! |
1270 | - if (((Config::$db_type != 'mysql' && Config::$db_type != 'mysqli') || mysqli_errno(Db::$db->connection) == 1050) && preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1448 | + if (((Config::$db_type != 'mysql' && Config::$db_type != 'mysqli') || mysqli_errno(Db::$db->connection) == 1050) && preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1449 | + { |
|
1271 | 1450 | $exists[] = $match[1]; |
1272 | 1451 | $incontext['sql_results']['table_dups']++; |
1273 | 1452 | } |
1274 | 1453 | // Don't error on duplicate indexes (or duplicate operators in PostgreSQL.) |
1275 | - elseif (!preg_match('~^\s*CREATE( UNIQUE)? INDEX ([^\n\r]+?)~', $current_statement, $match) && !(Config::$db_type == 'postgresql' && preg_match('~^\s*CREATE OPERATOR (^\n\r]+?)~', $current_statement, $match))) { |
|
1454 | + elseif (!preg_match('~^\s*CREATE( UNIQUE)? INDEX ([^\n\r]+?)~', $current_statement, $match) && !(Config::$db_type == 'postgresql' && preg_match('~^\s*CREATE OPERATOR (^\n\r]+?)~', $current_statement, $match))) |
|
1455 | + { |
|
1276 | 1456 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1277 | 1457 | $incontext['failures'][$count] = Db::$db->error(Db::$db->connection); |
1278 | 1458 | } |
1279 | - } else { |
|
1280 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1459 | + } |
|
1460 | + else |
|
1461 | + { |
|
1462 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1463 | + { |
|
1281 | 1464 | $incontext['sql_results']['tables']++; |
1282 | - } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1465 | + } |
|
1466 | + elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1467 | + { |
|
1283 | 1468 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1284 | 1469 | |
1285 | - if (!empty($matches[0])) { |
|
1470 | + if (!empty($matches[0])) |
|
1471 | + { |
|
1286 | 1472 | $incontext['sql_results']['inserts'] += count($matches[0]); |
1287 | - } else { |
|
1473 | + } |
|
1474 | + else |
|
1475 | + { |
|
1288 | 1476 | $incontext['sql_results']['inserts']++; |
1289 | 1477 | } |
1290 | 1478 | } |
@@ -1297,10 +1485,14 @@ discard block |
||
1297 | 1485 | } |
1298 | 1486 | |
1299 | 1487 | // Sort out the context for the SQL. |
1300 | - foreach ($incontext['sql_results'] as $key => $number) { |
|
1301 | - if ($number == 0) { |
|
1488 | + foreach ($incontext['sql_results'] as $key => $number) |
|
1489 | + { |
|
1490 | + if ($number == 0) |
|
1491 | + { |
|
1302 | 1492 | unset($incontext['sql_results'][$key]); |
1303 | - } else { |
|
1493 | + } |
|
1494 | + else |
|
1495 | + { |
|
1304 | 1496 | $incontext['sql_results'][$key] = sprintf(Lang::$txt['db_populate_' . $key], $number); |
1305 | 1497 | } |
1306 | 1498 | } |
@@ -1309,17 +1501,20 @@ discard block |
||
1309 | 1501 | $newSettings[] = ['global_character_set', 'UTF-8']; |
1310 | 1502 | |
1311 | 1503 | // Are we allowing stat collection? |
1312 | - if (!empty($_POST['stats']) && substr(Config::$boardurl, 0, 16) != 'http://localhost' && empty(Config::$modSettings['allow_sm_stats']) && empty(Config::$modSettings['enable_sm_stats'])) { |
|
1504 | + if (!empty($_POST['stats']) && substr(Config::$boardurl, 0, 16) != 'http://localhost' && empty(Config::$modSettings['allow_sm_stats']) && empty(Config::$modSettings['enable_sm_stats'])) |
|
1505 | + { |
|
1313 | 1506 | $incontext['allow_sm_stats'] = true; |
1314 | 1507 | |
1315 | 1508 | // Attempt to register the site etc. |
1316 | 1509 | $fp = @fsockopen('www.simplemachines.org', 443, $errno, $errstr); |
1317 | 1510 | |
1318 | - if (!$fp) { |
|
1511 | + if (!$fp) |
|
1512 | + { |
|
1319 | 1513 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
1320 | 1514 | } |
1321 | 1515 | |
1322 | - if ($fp) { |
|
1516 | + if ($fp) |
|
1517 | + { |
|
1323 | 1518 | $out = 'GET /smf/stats/register_stats.php?site=' . base64_encode(Config::$boardurl) . ' HTTP/1.1' . "\r\n"; |
1324 | 1519 | $out .= 'Host: www.simplemachines.org' . "\r\n"; |
1325 | 1520 | $out .= 'Connection: Close' . "\r\n\r\n"; |
@@ -1327,7 +1522,8 @@ discard block |
||
1327 | 1522 | |
1328 | 1523 | $return_data = ''; |
1329 | 1524 | |
1330 | - while (!feof($fp)) { |
|
1525 | + while (!feof($fp)) |
|
1526 | + { |
|
1331 | 1527 | $return_data .= fgets($fp, 128); |
1332 | 1528 | } |
1333 | 1529 | |
@@ -1336,7 +1532,8 @@ discard block |
||
1336 | 1532 | // Get the unique site ID. |
1337 | 1533 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1338 | 1534 | |
1339 | - if (!empty($ID[1])) { |
|
1535 | + if (!empty($ID[1])) |
|
1536 | + { |
|
1340 | 1537 | Db::$db->insert( |
1341 | 1538 | 'replace', |
1342 | 1539 | Db::$db->prefix . 'settings', |
@@ -1351,7 +1548,8 @@ discard block |
||
1351 | 1548 | } |
1352 | 1549 | } |
1353 | 1550 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1354 | - elseif (empty($_POST['stats']) && empty($incontext['allow_sm_stats'])) { |
|
1551 | + elseif (empty($_POST['stats']) && empty($incontext['allow_sm_stats'])) |
|
1552 | + { |
|
1355 | 1553 | Db::$db->query( |
1356 | 1554 | '', |
1357 | 1555 | 'DELETE FROM {db_prefix}settings |
@@ -1364,37 +1562,46 @@ discard block |
||
1364 | 1562 | } |
1365 | 1563 | |
1366 | 1564 | // Are we enabling SSL? |
1367 | - if (!empty($_POST['force_ssl'])) { |
|
1565 | + if (!empty($_POST['force_ssl'])) |
|
1566 | + { |
|
1368 | 1567 | $newSettings[] = ['force_ssl', 1]; |
1369 | 1568 | } |
1370 | 1569 | |
1371 | 1570 | // Setting a timezone is required. |
1372 | - if (!isset(Config::$modSettings['default_timezone']) && function_exists('date_default_timezone_set')) { |
|
1571 | + if (!isset(Config::$modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
|
1572 | + { |
|
1373 | 1573 | // Get PHP's default timezone, if set |
1374 | 1574 | $ini_tz = ini_get('date.timezone'); |
1375 | 1575 | |
1376 | - if (!empty($ini_tz)) { |
|
1576 | + if (!empty($ini_tz)) |
|
1577 | + { |
|
1377 | 1578 | $timezone_id = $ini_tz; |
1378 | - } else { |
|
1579 | + } |
|
1580 | + else |
|
1581 | + { |
|
1379 | 1582 | $timezone_id = ''; |
1380 | 1583 | } |
1381 | 1584 | |
1382 | 1585 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1383 | - if (!in_array($timezone_id, timezone_identifiers_list())) { |
|
1586 | + if (!in_array($timezone_id, timezone_identifiers_list())) |
|
1587 | + { |
|
1384 | 1588 | $server_offset = @mktime(0, 0, 0, 1, 1, 1970) * -1; |
1385 | 1589 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1386 | 1590 | |
1387 | - if (empty($timezone_id)) { |
|
1591 | + if (empty($timezone_id)) |
|
1592 | + { |
|
1388 | 1593 | $timezone_id = 'UTC'; |
1389 | 1594 | } |
1390 | 1595 | } |
1391 | 1596 | |
1392 | - if (date_default_timezone_set($timezone_id)) { |
|
1597 | + if (date_default_timezone_set($timezone_id)) |
|
1598 | + { |
|
1393 | 1599 | $newSettings[] = ['default_timezone', $timezone_id]; |
1394 | 1600 | } |
1395 | 1601 | } |
1396 | 1602 | |
1397 | - if (!empty($newSettings)) { |
|
1603 | + if (!empty($newSettings)) |
|
1604 | + { |
|
1398 | 1605 | Db::$db->insert( |
1399 | 1606 | 'replace', |
1400 | 1607 | '{db_prefix}settings', |
@@ -1440,8 +1647,10 @@ discard block |
||
1440 | 1647 | [], |
1441 | 1648 | ); |
1442 | 1649 | |
1443 | - while ($row = Db::$db->fetch_assoc($request)) { |
|
1444 | - foreach ($smiley_set_extensions as $set => $ext) { |
|
1650 | + while ($row = Db::$db->fetch_assoc($request)) |
|
1651 | + { |
|
1652 | + foreach ($smiley_set_extensions as $set => $ext) |
|
1653 | + { |
|
1445 | 1654 | $smiley_inserts[] = [$row['id_smiley'], $set, $smiley_filenames[$row['code']] . $ext]; |
1446 | 1655 | } |
1447 | 1656 | } |
@@ -1456,13 +1665,16 @@ discard block |
||
1456 | 1665 | ); |
1457 | 1666 | |
1458 | 1667 | // Let's optimize those new tables, but not on InnoDB, ok? |
1459 | - if (!$has_innodb) { |
|
1668 | + if (!$has_innodb) |
|
1669 | + { |
|
1460 | 1670 | $tables = Db::$db->list_tables(Db::$db->name, Db::$db->prefix . '%'); |
1461 | 1671 | |
1462 | - foreach ($tables as $table) { |
|
1672 | + foreach ($tables as $table) |
|
1673 | + { |
|
1463 | 1674 | Db::$db->optimize_table($table) != -1 or $db_messed = true; |
1464 | 1675 | |
1465 | - if (!empty($db_messed)) { |
|
1676 | + if (!empty($db_messed)) |
|
1677 | + { |
|
1466 | 1678 | $incontext['failures'][-1] = Db::$db->error(); |
1467 | 1679 | break; |
1468 | 1680 | } |
@@ -1470,7 +1682,8 @@ discard block |
||
1470 | 1682 | } |
1471 | 1683 | |
1472 | 1684 | // MySQL specific stuff |
1473 | - if (substr(Config::$db_type, 0, 5) != 'mysql') { |
|
1685 | + if (substr(Config::$db_type, 0, 5) != 'mysql') |
|
1686 | + { |
|
1474 | 1687 | return false; |
1475 | 1688 | } |
1476 | 1689 | |
@@ -1478,21 +1691,25 @@ discard block |
||
1478 | 1691 | $privs = []; |
1479 | 1692 | $get_privs = Db::$db->query('', 'SHOW PRIVILEGES', []); |
1480 | 1693 | |
1481 | - while ($row = Db::$db->fetch_assoc($get_privs)) { |
|
1482 | - if ($row['Privilege'] == 'Alter') { |
|
1694 | + while ($row = Db::$db->fetch_assoc($get_privs)) |
|
1695 | + { |
|
1696 | + if ($row['Privilege'] == 'Alter') |
|
1697 | + { |
|
1483 | 1698 | $privs[] = $row['Privilege']; |
1484 | 1699 | } |
1485 | 1700 | } |
1486 | 1701 | Db::$db->free_result($get_privs); |
1487 | 1702 | |
1488 | 1703 | // Check for the ALTER privilege. |
1489 | - if (!empty($databases[Config::$db_type]['alter_support']) && !in_array('Alter', $privs)) { |
|
1704 | + if (!empty($databases[Config::$db_type]['alter_support']) && !in_array('Alter', $privs)) |
|
1705 | + { |
|
1490 | 1706 | $incontext['error'] = Lang::$txt['error_db_alter_priv']; |
1491 | 1707 | |
1492 | 1708 | return false; |
1493 | 1709 | } |
1494 | 1710 | |
1495 | - if (!empty($exists)) { |
|
1711 | + if (!empty($exists)) |
|
1712 | + { |
|
1496 | 1713 | $incontext['page_title'] = Lang::$txt['user_refresh_install']; |
1497 | 1714 | $incontext['was_refresh'] = true; |
1498 | 1715 | } |
@@ -1510,7 +1727,8 @@ discard block |
||
1510 | 1727 | $incontext['continue'] = 1; |
1511 | 1728 | |
1512 | 1729 | // Skipping? |
1513 | - if (!empty($_POST['skip'])) { |
|
1730 | + if (!empty($_POST['skip'])) |
|
1731 | + { |
|
1514 | 1732 | return true; |
1515 | 1733 | } |
1516 | 1734 | |
@@ -1523,15 +1741,18 @@ discard block |
||
1523 | 1741 | // Reload $modSettings. |
1524 | 1742 | Config::reloadModSettings(); |
1525 | 1743 | |
1526 | - if (!isset($_POST['username'])) { |
|
1744 | + if (!isset($_POST['username'])) |
|
1745 | + { |
|
1527 | 1746 | $_POST['username'] = ''; |
1528 | 1747 | } |
1529 | 1748 | |
1530 | - if (!isset($_POST['email'])) { |
|
1749 | + if (!isset($_POST['email'])) |
|
1750 | + { |
|
1531 | 1751 | $_POST['email'] = ''; |
1532 | 1752 | } |
1533 | 1753 | |
1534 | - if (!isset($_POST['server_email'])) { |
|
1754 | + if (!isset($_POST['server_email'])) |
|
1755 | + { |
|
1535 | 1756 | $_POST['server_email'] = ''; |
1536 | 1757 | } |
1537 | 1758 | |
@@ -1554,42 +1775,49 @@ discard block |
||
1554 | 1775 | ], |
1555 | 1776 | ); |
1556 | 1777 | |
1557 | - if (Db::$db->num_rows($request) != 0) { |
|
1778 | + if (Db::$db->num_rows($request) != 0) |
|
1779 | + { |
|
1558 | 1780 | $incontext['skip'] = 1; |
1559 | 1781 | } |
1560 | 1782 | Db::$db->free_result($request); |
1561 | 1783 | |
1562 | 1784 | // Trying to create an account? |
1563 | - if (isset($_POST['password1']) && !empty($_POST['contbutt'])) { |
|
1785 | + if (isset($_POST['password1']) && !empty($_POST['contbutt'])) |
|
1786 | + { |
|
1564 | 1787 | // Wrong password? |
1565 | - if ($incontext['require_db_confirm'] && $_POST['password3'] != Config::$db_passwd) { |
|
1788 | + if ($incontext['require_db_confirm'] && $_POST['password3'] != Config::$db_passwd) |
|
1789 | + { |
|
1566 | 1790 | $incontext['error'] = Lang::$txt['error_db_connect']; |
1567 | 1791 | |
1568 | 1792 | return false; |
1569 | 1793 | } |
1570 | 1794 | |
1571 | 1795 | // Not matching passwords? |
1572 | - if ($_POST['password1'] != $_POST['password2']) { |
|
1796 | + if ($_POST['password1'] != $_POST['password2']) |
|
1797 | + { |
|
1573 | 1798 | $incontext['error'] = Lang::$txt['error_user_settings_again_match']; |
1574 | 1799 | |
1575 | 1800 | return false; |
1576 | 1801 | } |
1577 | 1802 | |
1578 | 1803 | // No password? |
1579 | - if (strlen($_POST['password1']) < 4) { |
|
1804 | + if (strlen($_POST['password1']) < 4) |
|
1805 | + { |
|
1580 | 1806 | $incontext['error'] = Lang::$txt['error_user_settings_no_password']; |
1581 | 1807 | |
1582 | 1808 | return false; |
1583 | 1809 | } |
1584 | 1810 | |
1585 | - if (!file_exists(Config::$sourcedir . '/Utils.php')) { |
|
1811 | + if (!file_exists(Config::$sourcedir . '/Utils.php')) |
|
1812 | + { |
|
1586 | 1813 | $incontext['error'] = sprintf(Lang::$txt['error_sourcefile_missing'], 'Utils.php'); |
1587 | 1814 | |
1588 | 1815 | return false; |
1589 | 1816 | } |
1590 | 1817 | |
1591 | 1818 | // Update the webmaster's email? |
1592 | - if (!empty($_POST['server_email']) && (empty(Config::$webmaster_email) || Config::$webmaster_email == $settingsDefs['webmaster_email']['default'])) { |
|
1819 | + if (!empty($_POST['server_email']) && (empty(Config::$webmaster_email) || Config::$webmaster_email == $settingsDefs['webmaster_email']['default'])) |
|
1820 | + { |
|
1593 | 1821 | installer_updateSettingsFile(['webmaster_email' => $_POST['server_email']]); |
1594 | 1822 | } |
1595 | 1823 | |
@@ -1610,32 +1838,43 @@ discard block |
||
1610 | 1838 | ], |
1611 | 1839 | ); |
1612 | 1840 | |
1613 | - if (Db::$db->num_rows($result) != 0) { |
|
1841 | + if (Db::$db->num_rows($result) != 0) |
|
1842 | + { |
|
1614 | 1843 | list($incontext['member_id'], $incontext['member_salt']) = Db::$db->fetch_row($result); |
1615 | 1844 | Db::$db->free_result($result); |
1616 | 1845 | |
1617 | 1846 | $incontext['account_existed'] = Lang::$txt['error_user_settings_taken']; |
1618 | - } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) { |
|
1847 | + } |
|
1848 | + elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1849 | + { |
|
1619 | 1850 | // Try the previous step again. |
1620 | 1851 | $incontext['error'] = $_POST['username'] == '' ? Lang::$txt['error_username_left_empty'] : Lang::$txt['error_username_too_long']; |
1621 | 1852 | |
1622 | 1853 | return false; |
1623 | - } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) { |
|
1854 | + } |
|
1855 | + elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1856 | + { |
|
1624 | 1857 | // Try the previous step again. |
1625 | 1858 | $incontext['error'] = Lang::$txt['error_invalid_characters_username']; |
1626 | 1859 | |
1627 | 1860 | return false; |
1628 | - } elseif (empty($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) || strlen($_POST['email']) > 255) { |
|
1861 | + } |
|
1862 | + elseif (empty($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) || strlen($_POST['email']) > 255) |
|
1863 | + { |
|
1629 | 1864 | // One step back, this time fill out a proper admin email address. |
1630 | 1865 | $incontext['error'] = sprintf(Lang::$txt['error_valid_admin_email_needed'], $_POST['username']); |
1631 | 1866 | |
1632 | 1867 | return false; |
1633 | - } elseif (empty($_POST['server_email']) || !filter_var($_POST['server_email'], FILTER_VALIDATE_EMAIL) || strlen($_POST['server_email']) > 255) { |
|
1868 | + } |
|
1869 | + elseif (empty($_POST['server_email']) || !filter_var($_POST['server_email'], FILTER_VALIDATE_EMAIL) || strlen($_POST['server_email']) > 255) |
|
1870 | + { |
|
1634 | 1871 | // One step back, this time fill out a proper admin email address. |
1635 | 1872 | $incontext['error'] = Lang::$txt['error_valid_server_email_needed']; |
1636 | 1873 | |
1637 | 1874 | return false; |
1638 | - } elseif ($_POST['username'] != '') { |
|
1875 | + } |
|
1876 | + elseif ($_POST['username'] != '') |
|
1877 | + { |
|
1639 | 1878 | $incontext['member_salt'] = bin2hex(random_bytes(16)); |
1640 | 1879 | |
1641 | 1880 | // Format the username properly. |
@@ -1726,7 +1965,8 @@ discard block |
||
1726 | 1965 | Config::reloadModSettings(); |
1727 | 1966 | |
1728 | 1967 | // Bring a warning over. |
1729 | - if (!empty($incontext['account_existed'])) { |
|
1968 | + if (!empty($incontext['account_existed'])) |
|
1969 | + { |
|
1730 | 1970 | $incontext['warning'] = $incontext['account_existed']; |
1731 | 1971 | } |
1732 | 1972 | |
@@ -1759,15 +1999,18 @@ discard block |
||
1759 | 1999 | ); |
1760 | 2000 | |
1761 | 2001 | // Only proceed if we can load the data. |
1762 | - if ($request) { |
|
1763 | - while ($row = Db::$db->fetch_row($request)) { |
|
2002 | + if ($request) |
|
2003 | + { |
|
2004 | + while ($row = Db::$db->fetch_row($request)) |
|
2005 | + { |
|
1764 | 2006 | Config::$modSettings[$row[0]] = $row[1]; |
1765 | 2007 | } |
1766 | 2008 | Db::$db->free_result($request); |
1767 | 2009 | } |
1768 | 2010 | |
1769 | 2011 | // Automatically log them in ;) |
1770 | - if (isset($incontext['member_id'], $incontext['member_salt'])) { |
|
2012 | + if (isset($incontext['member_id'], $incontext['member_salt'])) |
|
2013 | + { |
|
1771 | 2014 | Cookie::setLoginCookie(3153600 * 60, $incontext['member_id'], Cookie::encrypt($_POST['password1'], $incontext['member_salt'])); |
1772 | 2015 | } |
1773 | 2016 | |
@@ -1782,14 +2025,18 @@ discard block |
||
1782 | 2025 | ], |
1783 | 2026 | ); |
1784 | 2027 | |
1785 | - if (Db::$db->num_rows($result) != 0) { |
|
2028 | + if (Db::$db->num_rows($result) != 0) |
|
2029 | + { |
|
1786 | 2030 | list($db_sessions) = Db::$db->fetch_row($result); |
1787 | 2031 | } |
1788 | 2032 | Db::$db->free_result($result); |
1789 | 2033 | |
1790 | - if (empty($db_sessions)) { |
|
2034 | + if (empty($db_sessions)) |
|
2035 | + { |
|
1791 | 2036 | $_SESSION['admin_time'] = time(); |
1792 | - } else { |
|
2037 | + } |
|
2038 | + else |
|
2039 | + { |
|
1793 | 2040 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1794 | 2041 | |
1795 | 2042 | Db::$db->insert( |
@@ -1822,20 +2069,25 @@ discard block |
||
1822 | 2069 | ); |
1823 | 2070 | Utils::$context['utf8'] = true; |
1824 | 2071 | |
1825 | - if (Db::$db->num_rows($request) > 0) { |
|
2072 | + if (Db::$db->num_rows($request) > 0) |
|
2073 | + { |
|
1826 | 2074 | Logging::updateStats('subject', 1, htmlspecialchars(Lang::$txt['default_topic_subject'])); |
1827 | 2075 | } |
1828 | 2076 | Db::$db->free_result($request); |
1829 | 2077 | |
1830 | 2078 | // Now is the perfect time to fetch the SM files. |
1831 | 2079 | // Sanity check that they loaded earlier! |
1832 | - if (isset(Config::$modSettings['recycle_board'])) { |
|
2080 | + if (isset(Config::$modSettings['recycle_board'])) |
|
2081 | + { |
|
1833 | 2082 | (new TaskRunner())->runScheduledTasks(['fetchSMfiles']); // Now go get those files! |
1834 | 2083 | |
1835 | 2084 | // We've just installed! |
1836 | - if (isset($incontext['member_id'])) { |
|
2085 | + if (isset($incontext['member_id'])) |
|
2086 | + { |
|
1837 | 2087 | User::setMe($incontext['member_id']); |
1838 | - } else { |
|
2088 | + } |
|
2089 | + else |
|
2090 | + { |
|
1839 | 2091 | User::load(); |
1840 | 2092 | } |
1841 | 2093 | |
@@ -1863,10 +2115,12 @@ discard block |
||
1863 | 2115 | |
1864 | 2116 | function installer_updateSettingsFile($vars, $rebuild = false) |
1865 | 2117 | { |
1866 | - if (!is_writable(SMF_SETTINGS_FILE)) { |
|
2118 | + if (!is_writable(SMF_SETTINGS_FILE)) |
|
2119 | + { |
|
1867 | 2120 | @chmod(SMF_SETTINGS_FILE, 0777); |
1868 | 2121 | |
1869 | - if (!is_writable(SMF_SETTINGS_FILE)) { |
|
2122 | + if (!is_writable(SMF_SETTINGS_FILE)) |
|
2123 | + { |
|
1870 | 2124 | return false; |
1871 | 2125 | } |
1872 | 2126 | } |
@@ -1886,16 +2140,20 @@ discard block |
||
1886 | 2140 | SecFilterScanPOST Off |
1887 | 2141 | </IfModule>'; |
1888 | 2142 | |
1889 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
2143 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
2144 | + { |
|
1890 | 2145 | return true; |
1891 | 2146 | } |
1892 | 2147 | |
1893 | - if (file_exists(Config::$boarddir . '/.htaccess') && is_writable(Config::$boarddir . '/.htaccess')) { |
|
2148 | + if (file_exists(Config::$boarddir . '/.htaccess') && is_writable(Config::$boarddir . '/.htaccess')) |
|
2149 | + { |
|
1894 | 2150 | $current_htaccess = implode('', file(Config::$boarddir . '/.htaccess')); |
1895 | 2151 | |
1896 | 2152 | // Only change something if mod_security hasn't been addressed yet. |
1897 | - if (strpos($current_htaccess, '<IfModule mod_security.c>') === false) { |
|
1898 | - if ($ht_handle = fopen(Config::$boarddir . '/.htaccess', 'a')) { |
|
2153 | + if (strpos($current_htaccess, '<IfModule mod_security.c>') === false) |
|
2154 | + { |
|
2155 | + if ($ht_handle = fopen(Config::$boarddir . '/.htaccess', 'a')) |
|
2156 | + { |
|
1899 | 2157 | fwrite($ht_handle, $htaccess_addition); |
1900 | 2158 | fclose($ht_handle); |
1901 | 2159 | |
@@ -1906,10 +2164,15 @@ discard block |
||
1906 | 2164 | } |
1907 | 2165 | |
1908 | 2166 | return true; |
1909 | - } elseif (file_exists(Config::$boarddir . '/.htaccess')) { |
|
2167 | + } |
|
2168 | + elseif (file_exists(Config::$boarddir . '/.htaccess')) |
|
2169 | + { |
|
1910 | 2170 | return strpos(implode('', file(Config::$boarddir . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
1911 | - } elseif (is_writable(Config::$boarddir)) { |
|
1912 | - if ($ht_handle = fopen(Config::$boarddir . '/.htaccess', 'w')) { |
|
2171 | + } |
|
2172 | + elseif (is_writable(Config::$boarddir)) |
|
2173 | + { |
|
2174 | + if ($ht_handle = fopen(Config::$boarddir . '/.htaccess', 'w')) |
|
2175 | + { |
|
1913 | 2176 | fwrite($ht_handle, $htaccess_addition); |
1914 | 2177 | fclose($ht_handle); |
1915 | 2178 | |
@@ -1948,7 +2211,8 @@ discard block |
||
1948 | 2211 | <div id="wrapper">'; |
1949 | 2212 | |
1950 | 2213 | // Have we got a language drop down - if so do it on the first step only. |
1951 | - if (!empty($incontext['detected_languages']) && count($incontext['detected_languages']) > 1 && $incontext['current_step'] == 0) { |
|
2214 | + if (!empty($incontext['detected_languages']) && count($incontext['detected_languages']) > 1 && $incontext['current_step'] == 0) |
|
2215 | + { |
|
1952 | 2216 | echo ' |
1953 | 2217 | <div id="upper_section"> |
1954 | 2218 | <div id="inner_section"> |
@@ -1958,7 +2222,8 @@ discard block |
||
1958 | 2222 | <label for="installer_language">', Lang::$txt['installer_language'], ':</label> |
1959 | 2223 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1960 | 2224 | |
1961 | - foreach ($incontext['detected_languages'] as $lang => $name) { |
|
2225 | + foreach ($incontext['detected_languages'] as $lang => $name) |
|
2226 | + { |
|
1962 | 2227 | echo ' |
1963 | 2228 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
1964 | 2229 | } |
@@ -1981,7 +2246,8 @@ discard block |
||
1981 | 2246 | <h2>', Lang::$txt['upgrade_progress'], '</h2> |
1982 | 2247 | <ul class="steps_list">'; |
1983 | 2248 | |
1984 | - foreach ($incontext['steps'] as $num => $step) { |
|
2249 | + foreach ($incontext['steps'] as $num => $step) |
|
2250 | + { |
|
1985 | 2251 | echo ' |
1986 | 2252 | <li', $num == $incontext['current_step'] ? ' class="stepcurrent"' : '', '> |
1987 | 2253 | ', Lang::$txt['upgrade_step'], ' ', $step[0], ': ', $step[1], ' |
@@ -2007,16 +2273,19 @@ discard block |
||
2007 | 2273 | { |
2008 | 2274 | global $incontext; |
2009 | 2275 | |
2010 | - if (!empty($incontext['continue']) || !empty($incontext['skip'])) { |
|
2276 | + if (!empty($incontext['continue']) || !empty($incontext['skip'])) |
|
2277 | + { |
|
2011 | 2278 | echo ' |
2012 | 2279 | <div class="floatright">'; |
2013 | 2280 | |
2014 | - if (!empty($incontext['continue'])) { |
|
2281 | + if (!empty($incontext['continue'])) |
|
2282 | + { |
|
2015 | 2283 | echo ' |
2016 | 2284 | <input type="submit" id="contbutt" name="contbutt" value="', Lang::$txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button">'; |
2017 | 2285 | } |
2018 | 2286 | |
2019 | - if (!empty($incontext['skip'])) { |
|
2287 | + if (!empty($incontext['skip'])) |
|
2288 | + { |
|
2020 | 2289 | echo ' |
2021 | 2290 | <input type="submit" id="skip" name="skip" value="', Lang::$txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button">'; |
2022 | 2291 | } |
@@ -2025,7 +2294,8 @@ discard block |
||
2025 | 2294 | } |
2026 | 2295 | |
2027 | 2296 | // Show the closing form tag and other data only if not in the last step |
2028 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
2297 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
2298 | + { |
|
2029 | 2299 | echo ' |
2030 | 2300 | </form>'; |
2031 | 2301 | } |
@@ -2061,13 +2331,15 @@ discard block |
||
2061 | 2331 | </div>'; |
2062 | 2332 | |
2063 | 2333 | // Show the warnings, or not. |
2064 | - if (template_warning_divs()) { |
|
2334 | + if (template_warning_divs()) |
|
2335 | + { |
|
2065 | 2336 | echo ' |
2066 | 2337 | <h3>', Lang::$txt['install_all_lovely'], '</h3>'; |
2067 | 2338 | } |
2068 | 2339 | |
2069 | 2340 | // Say we want the continue button! |
2070 | - if (empty($incontext['error'])) { |
|
2341 | + if (empty($incontext['error'])) |
|
2342 | + { |
|
2071 | 2343 | $incontext['continue'] = 1; |
2072 | 2344 | } |
2073 | 2345 | |
@@ -2103,7 +2375,8 @@ discard block |
||
2103 | 2375 | global $incontext; |
2104 | 2376 | |
2105 | 2377 | // Errors are very serious.. |
2106 | - if (!empty($incontext['error'])) { |
|
2378 | + if (!empty($incontext['error'])) |
|
2379 | + { |
|
2107 | 2380 | echo ' |
2108 | 2381 | <div class="errorbox"> |
2109 | 2382 | <h3>', Lang::$txt['upgrade_critical_error'], '</h3> |
@@ -2111,7 +2384,8 @@ discard block |
||
2111 | 2384 | </div>'; |
2112 | 2385 | } |
2113 | 2386 | // A warning message? |
2114 | - elseif (!empty($incontext['warning'])) { |
|
2387 | + elseif (!empty($incontext['warning'])) |
|
2388 | + { |
|
2115 | 2389 | echo ' |
2116 | 2390 | <div class="errorbox"> |
2117 | 2391 | <h3>', Lang::$txt['upgrade_warning'], '</h3> |
@@ -2133,7 +2407,8 @@ discard block |
||
2133 | 2407 | <li>', $incontext['failed_files']), '</li> |
2134 | 2408 | </ul>'; |
2135 | 2409 | |
2136 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2410 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
2411 | + { |
|
2137 | 2412 | echo ' |
2138 | 2413 | <hr> |
2139 | 2414 | <p>', Lang::$txt['chmod_linux_info'], '</p> |
@@ -2141,7 +2416,8 @@ discard block |
||
2141 | 2416 | } |
2142 | 2417 | |
2143 | 2418 | // This is serious! |
2144 | - if (!template_warning_divs()) { |
|
2419 | + if (!template_warning_divs()) |
|
2420 | + { |
|
2145 | 2421 | return; |
2146 | 2422 | } |
2147 | 2423 | |
@@ -2149,7 +2425,8 @@ discard block |
||
2149 | 2425 | <hr> |
2150 | 2426 | <p>', Lang::$txt['ftp_setup_info'], '</p>'; |
2151 | 2427 | |
2152 | - if (!empty($incontext['ftp_errors'])) { |
|
2428 | + if (!empty($incontext['ftp_errors'])) |
|
2429 | + { |
|
2153 | 2430 | echo ' |
2154 | 2431 | <div class="error_message"> |
2155 | 2432 | ', Lang::$txt['error_ftp_no_connect'], '<br><br> |
@@ -2215,7 +2492,8 @@ discard block |
||
2215 | 2492 | <dl class="settings">'; |
2216 | 2493 | |
2217 | 2494 | // More than one database type? |
2218 | - if (count($incontext['supported_databases']) > 1) { |
|
2495 | + if (count($incontext['supported_databases']) > 1) |
|
2496 | + { |
|
2219 | 2497 | echo ' |
2220 | 2498 | <dt> |
2221 | 2499 | <label for="db_type_input">', Lang::$txt['db_settings_type'], ':</label> |
@@ -2223,7 +2501,8 @@ discard block |
||
2223 | 2501 | <dd> |
2224 | 2502 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2225 | 2503 | |
2226 | - foreach ($incontext['supported_databases'] as $key => $db) { |
|
2504 | + foreach ($incontext['supported_databases'] as $key => $db) |
|
2505 | + { |
|
2227 | 2506 | echo ' |
2228 | 2507 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2229 | 2508 | } |
@@ -2232,7 +2511,9 @@ discard block |
||
2232 | 2511 | </select> |
2233 | 2512 | <div class="smalltext">', Lang::$txt['db_settings_type_info'], '</div> |
2234 | 2513 | </dd>'; |
2235 | - } else { |
|
2514 | + } |
|
2515 | + else |
|
2516 | + { |
|
2236 | 2517 | echo ' |
2237 | 2518 | <dd> |
2238 | 2519 | <input type="hidden" name="db_type" value="', $incontext['db']['type'], '"> |
@@ -2379,19 +2660,22 @@ discard block |
||
2379 | 2660 | <form action="', $incontext['form_url'], '" method="post"> |
2380 | 2661 | <p>', !empty($incontext['was_refresh']) ? Lang::$txt['user_refresh_install_desc'] : Lang::$txt['db_populate_info'], '</p>'; |
2381 | 2662 | |
2382 | - if (!empty($incontext['sql_results'])) { |
|
2663 | + if (!empty($incontext['sql_results'])) |
|
2664 | + { |
|
2383 | 2665 | echo ' |
2384 | 2666 | <ul> |
2385 | 2667 | <li>', implode('</li><li>', $incontext['sql_results']), '</li> |
2386 | 2668 | </ul>'; |
2387 | 2669 | } |
2388 | 2670 | |
2389 | - if (!empty($incontext['failures'])) { |
|
2671 | + if (!empty($incontext['failures'])) |
|
2672 | + { |
|
2390 | 2673 | echo ' |
2391 | 2674 | <div class="red">', Lang::$txt['error_db_queries'], '</div> |
2392 | 2675 | <ul>'; |
2393 | 2676 | |
2394 | - foreach ($incontext['failures'] as $line => $fail) { |
|
2677 | + foreach ($incontext['failures'] as $line => $fail) |
|
2678 | + { |
|
2395 | 2679 | echo ' |
2396 | 2680 | <li><strong>', Lang::$txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2397 | 2681 | } |
@@ -2459,7 +2743,8 @@ discard block |
||
2459 | 2743 | </dd> |
2460 | 2744 | </dl>'; |
2461 | 2745 | |
2462 | - if ($incontext['require_db_confirm']) { |
|
2746 | + if ($incontext['require_db_confirm']) |
|
2747 | + { |
|
2463 | 2748 | echo ' |
2464 | 2749 | <h2>', Lang::$txt['user_settings_database'], '</h2> |
2465 | 2750 | <p>', Lang::$txt['user_settings_database_info'], '</p> |
@@ -2481,13 +2766,15 @@ discard block |
||
2481 | 2766 | template_warning_divs(); |
2482 | 2767 | |
2483 | 2768 | // Install directory still writable? |
2484 | - if ($incontext['dir_still_writable']) { |
|
2769 | + if ($incontext['dir_still_writable']) |
|
2770 | + { |
|
2485 | 2771 | echo ' |
2486 | 2772 | <p><em>', Lang::$txt['still_writable'], '</em></p>'; |
2487 | 2773 | } |
2488 | 2774 | |
2489 | 2775 | // Don't show the box if it's like 99% sure it won't work :P. |
2490 | - if ($incontext['probably_delete_install']) { |
|
2776 | + if ($incontext['probably_delete_install']) |
|
2777 | + { |
|
2491 | 2778 | echo ' |
2492 | 2779 | <label> |
2493 | 2780 | <input type="checkbox" id="delete_self" onclick="doTheDelete();"> |
@@ -29,7 +29,8 @@ discard block |
||
29 | 29 | // Start things rolling by getting SMF alive... |
30 | 30 | $ssi_guest_access = true; |
31 | 31 | |
32 | -if (!file_exists(__DIR__ . '/SSI.php')) { |
|
32 | +if (!file_exists(__DIR__ . '/SSI.php')) |
|
33 | +{ |
|
33 | 34 | die('Cannot find SSI.php'); |
34 | 35 | } |
35 | 36 | |
@@ -41,22 +42,26 @@ discard block |
||
41 | 42 | Lang::load('ManagePaid'); |
42 | 43 | |
43 | 44 | // If there's literally nothing coming in, let's take flight! |
44 | -if (empty($_POST)) { |
|
45 | +if (empty($_POST)) |
|
46 | +{ |
|
45 | 47 | header('content-type: text/html; charset=' . (empty(Config::$modSettings['global_character_set']) ? (empty(Lang::$txt['lang_character_set']) ? 'ISO-8859-1' : Lang::$txt['lang_character_set']) : Config::$modSettings['global_character_set'])); |
46 | 48 | |
47 | 49 | die(Lang::$txt['paid_no_data']); |
48 | 50 | } |
49 | 51 | |
50 | 52 | // I assume we're even active? |
51 | -if (empty(Config::$modSettings['paid_enabled'])) { |
|
53 | +if (empty(Config::$modSettings['paid_enabled'])) |
|
54 | +{ |
|
52 | 55 | exit; |
53 | 56 | } |
54 | 57 | |
55 | 58 | // If we have some custom people who find out about problems load them here. |
56 | 59 | $notify_users = []; |
57 | 60 | |
58 | -if (!empty(Config::$modSettings['paid_email_to'])) { |
|
59 | - foreach (explode(',', Config::$modSettings['paid_email_to']) as $email) { |
|
61 | +if (!empty(Config::$modSettings['paid_email_to'])) |
|
62 | +{ |
|
63 | + foreach (explode(',', Config::$modSettings['paid_email_to']) as $email) |
|
64 | + { |
|
60 | 65 | $notify_users[] = [ |
61 | 66 | 'email' => $email, |
62 | 67 | 'name' => Lang::$txt['who_member'], |
@@ -71,16 +76,19 @@ discard block |
||
71 | 76 | $txnType = ''; |
72 | 77 | $gatewayHandles = Subscriptions::loadPaymentGateways(); |
73 | 78 | |
74 | -foreach ($gatewayHandles as $gateway) { |
|
79 | +foreach ($gatewayHandles as $gateway) |
|
80 | +{ |
|
75 | 81 | $gatewayClass = new $gateway['payment_class'](); |
76 | 82 | |
77 | - if ($gatewayClass->isValid()) { |
|
83 | + if ($gatewayClass->isValid()) |
|
84 | + { |
|
78 | 85 | $txnType = $gateway['code']; |
79 | 86 | break; |
80 | 87 | } |
81 | 88 | } |
82 | 89 | |
83 | -if (empty($txnType)) { |
|
90 | +if (empty($txnType)) |
|
91 | +{ |
|
84 | 92 | generateSubscriptionError(Lang::$txt['paid_unknown_transaction_type']); |
85 | 93 | } |
86 | 94 | |
@@ -92,7 +100,8 @@ discard block |
||
92 | 100 | $member_id = (int) $member_id; |
93 | 101 | |
94 | 102 | // This would be bad... |
95 | -if (empty($member_id)) { |
|
103 | +if (empty($member_id)) |
|
104 | +{ |
|
96 | 105 | generateSubscriptionError(Lang::$txt['paid_empty_member']); |
97 | 106 | } |
98 | 107 | |
@@ -108,7 +117,8 @@ discard block |
||
108 | 117 | ); |
109 | 118 | |
110 | 119 | // Didn't find them? |
111 | -if (Db::$db->num_rows($request) === 0) { |
|
120 | +if (Db::$db->num_rows($request) === 0) |
|
121 | +{ |
|
112 | 122 | generateSubscriptionError(sprintf(Lang::$txt['paid_could_not_find_member'], $member_id)); |
113 | 123 | } |
114 | 124 | $member_info = Db::$db->fetch_assoc($request); |
@@ -126,7 +136,8 @@ discard block |
||
126 | 136 | ); |
127 | 137 | |
128 | 138 | // Didn't find it? |
129 | -if (Db::$db->num_rows($request) === 0) { |
|
139 | +if (Db::$db->num_rows($request) === 0) |
|
140 | +{ |
|
130 | 141 | generateSubscriptionError(sprintf(Lang::$txt['paid_count_not_find_subscription'], $member_id, $subscription_id)); |
131 | 142 | } |
132 | 143 | |
@@ -147,22 +158,27 @@ discard block |
||
147 | 158 | ], |
148 | 159 | ); |
149 | 160 | |
150 | -if (Db::$db->num_rows($request) === 0) { |
|
161 | +if (Db::$db->num_rows($request) === 0) |
|
162 | +{ |
|
151 | 163 | generateSubscriptionError(sprintf(Lang::$txt['paid_count_not_find_subscription_log'], $member_id, $subscription_id)); |
152 | 164 | } |
153 | 165 | $subscription_info += Db::$db->fetch_assoc($request); |
154 | 166 | Db::$db->free_result($request); |
155 | 167 | |
156 | 168 | // Is this a refund etc? |
157 | -if ($gatewayClass->isRefund()) { |
|
169 | +if ($gatewayClass->isRefund()) |
|
170 | +{ |
|
158 | 171 | // If the end time subtracted by current time, is not greater |
159 | 172 | // than the duration (ie length of subscription), then we close it. |
160 | - if ($subscription_info['end_time'] - time() < $subscription_info['length']) { |
|
173 | + if ($subscription_info['end_time'] - time() < $subscription_info['length']) |
|
174 | + { |
|
161 | 175 | // Delete user subscription. |
162 | 176 | Subscriptions::remove($subscription_id, $member_id); |
163 | 177 | $subscription_act = time(); |
164 | 178 | $status = 0; |
165 | - } else { |
|
179 | + } |
|
180 | + else |
|
181 | + { |
|
166 | 182 | Subscriptions::getAll(); |
167 | 183 | $subscription_act = $subscription_info['end_time'] - Subscriptions::$all[$subscription_id]['num_length']; |
168 | 184 | $status = 1; |
@@ -185,7 +201,8 @@ discard block |
||
185 | 201 | ); |
186 | 202 | |
187 | 203 | // Receipt? |
188 | - if (!empty(Config::$modSettings['paid_email']) && Config::$modSettings['paid_email'] == 2) { |
|
204 | + if (!empty(Config::$modSettings['paid_email']) && Config::$modSettings['paid_email'] == 2) |
|
205 | + { |
|
189 | 206 | $replacements = [ |
190 | 207 | 'NAME' => $subscription_info['name'], |
191 | 208 | 'REFUNDNAME' => $member_info['member_name'], |
@@ -199,25 +216,30 @@ discard block |
||
199 | 216 | |
200 | 217 | } |
201 | 218 | // Otherwise is it what we want, a purchase? |
202 | -elseif ($gatewayClass->isPayment() || $gatewayClass->isSubscription()) { |
|
219 | +elseif ($gatewayClass->isPayment() || $gatewayClass->isSubscription()) |
|
220 | +{ |
|
203 | 221 | $cost = Utils::jsonDecode($subscription_info['cost'], true); |
204 | 222 | $total_cost = $gatewayClass->getCost(); |
205 | 223 | $notify = false; |
206 | 224 | |
207 | 225 | // For one off's we want to only capture them once! |
208 | - if (!$gatewayClass->isSubscription()) { |
|
226 | + if (!$gatewayClass->isSubscription()) |
|
227 | + { |
|
209 | 228 | $real_details = Utils::jsonDecode($subscription_info['pending_details'], true); |
210 | 229 | |
211 | - if (empty($real_details)) { |
|
230 | + if (empty($real_details)) |
|
231 | + { |
|
212 | 232 | generateSubscriptionError(sprintf(Lang::$txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
213 | 233 | } |
214 | 234 | |
215 | 235 | // Now we just try to find anything pending. |
216 | 236 | // We don't really care which it is as security happens later. |
217 | - foreach ($real_details as $id => $detail) { |
|
237 | + foreach ($real_details as $id => $detail) |
|
238 | + { |
|
218 | 239 | unset($real_details[$id]); |
219 | 240 | |
220 | - if ($detail[3] == 'payback' && $subscription_info['payments_pending']) { |
|
241 | + if ($detail[3] == 'payback' && $subscription_info['payments_pending']) |
|
242 | + { |
|
221 | 243 | $subscription_info['payments_pending']--; |
222 | 244 | } |
223 | 245 | break; |
@@ -239,30 +261,38 @@ discard block |
||
239 | 261 | } |
240 | 262 | |
241 | 263 | // Is this flexible? |
242 | - if ($subscription_info['length'] == 'F') { |
|
264 | + if ($subscription_info['length'] == 'F') |
|
265 | + { |
|
243 | 266 | $found_duration = 0; |
244 | 267 | |
245 | 268 | // This is a little harder, can we find the right duration? |
246 | - foreach ($cost as $duration => $value) { |
|
247 | - if ($duration == 'fixed') { |
|
269 | + foreach ($cost as $duration => $value) |
|
270 | + { |
|
271 | + if ($duration == 'fixed') |
|
272 | + { |
|
248 | 273 | continue; |
249 | 274 | } |
250 | 275 | |
251 | - if ((float) $value == (float) $total_cost) { |
|
276 | + if ((float) $value == (float) $total_cost) |
|
277 | + { |
|
252 | 278 | $found_duration = strtoupper(substr($duration, 0, 1)); |
253 | 279 | } |
254 | 280 | } |
255 | 281 | |
256 | 282 | // If we have the duration then we're done. |
257 | - if ($found_duration !== 0) { |
|
283 | + if ($found_duration !== 0) |
|
284 | + { |
|
258 | 285 | $notify = true; |
259 | 286 | Subscriptions::add($subscription_id, $member_id, $found_duration); |
260 | 287 | } |
261 | - } else { |
|
288 | + } |
|
289 | + else |
|
290 | + { |
|
262 | 291 | $actual_cost = $cost['fixed']; |
263 | 292 | |
264 | 293 | // It must be at least the right amount. |
265 | - if ($total_cost != 0 && $total_cost >= $actual_cost) { |
|
294 | + if ($total_cost != 0 && $total_cost >= $actual_cost) |
|
295 | + { |
|
266 | 296 | // Add the subscription. |
267 | 297 | $notify = true; |
268 | 298 | Subscriptions::add($subscription_id, $member_id); |
@@ -270,7 +300,8 @@ discard block |
||
270 | 300 | } |
271 | 301 | |
272 | 302 | // Send a receipt? |
273 | - if (!empty(Config::$modSettings['paid_email']) && Config::$modSettings['paid_email'] == 2 && $notify) { |
|
303 | + if (!empty(Config::$modSettings['paid_email']) && Config::$modSettings['paid_email'] == 2 && $notify) |
|
304 | + { |
|
274 | 305 | $replacements = [ |
275 | 306 | 'NAME' => $subscription_info['name'], |
276 | 307 | 'SUBNAME' => $member_info['member_name'], |
@@ -285,8 +316,10 @@ discard block |
||
285 | 316 | } |
286 | 317 | } |
287 | 318 | // Maybe they're cancelling. Some subscriptions may require actively doing something, but PayPal doesn't, for example. |
288 | -elseif ($gatewayClass->isCancellation()) { |
|
289 | - if (method_exists($gatewayClass, 'performCancel')) { |
|
319 | +elseif ($gatewayClass->isCancellation()) |
|
320 | +{ |
|
321 | + if (method_exists($gatewayClass, 'performCancel')) |
|
322 | + { |
|
290 | 323 | $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
291 | 324 | } |
292 | 325 | } |
@@ -303,7 +336,8 @@ discard block |
||
303 | 336 | $gatewayClass->close(); |
304 | 337 | |
305 | 338 | // Hidden setting to log the IPN info for debugging purposes. |
306 | -if ($paid_debug === true) { |
|
339 | +if ($paid_debug === true) |
|
340 | +{ |
|
307 | 341 | generateSubscriptionError(Lang::$txt['subscription'], true); |
308 | 342 | } |
309 | 343 | |
@@ -318,7 +352,8 @@ discard block |
||
318 | 352 | global $notify_users; |
319 | 353 | |
320 | 354 | // Send an email? |
321 | - if (!empty(Config::$modSettings['paid_email']) && !$debug) { |
|
355 | + if (!empty(Config::$modSettings['paid_email']) && !$debug) |
|
356 | + { |
|
322 | 357 | $replacements = [ |
323 | 358 | 'ERROR' => $text, |
324 | 359 | ]; |
@@ -327,8 +362,10 @@ discard block |
||
327 | 362 | } |
328 | 363 | |
329 | 364 | // Maybe we can try to give them the post data? |
330 | - if (!empty($_POST)) { |
|
331 | - foreach ($_POST as $key => $val) { |
|
365 | + if (!empty($_POST)) |
|
366 | + { |
|
367 | + foreach ($_POST as $key => $val) |
|
368 | + { |
|
332 | 369 | $text .= '<br>' . Utils::htmlspecialchars($key) . ': ' . Utils::htmlspecialchars($val); |
333 | 370 | } |
334 | 371 | } |
@@ -1692,7 +1692,7 @@ discard block |
||
1692 | 1692 | { |
1693 | 1693 | // Avoid double separators and empty titled sections |
1694 | 1694 | $empty_section = true; |
1695 | - for ($j=$i+1; $j < count(Utils::$context['theme_options']); $j++) |
|
1695 | + for ($j = $i + 1; $j < count(Utils::$context['theme_options']); $j++) |
|
1696 | 1696 | { |
1697 | 1697 | // Found another separator, so we're done |
1698 | 1698 | if (!is_array(Utils::$context['theme_options'][$j])) |
@@ -2687,8 +2687,7 @@ discard block |
||
2687 | 2687 | foreach (Utils::$context['post_errors'] as $error) |
2688 | 2688 | { |
2689 | 2689 | $text_key_error = $error == 'password_short' ? |
2690 | - sprintf(Lang::$txt['profile_error_' . $error], (empty(Config::$modSettings['password_strength']) ? 4 : 8)) : |
|
2691 | - (isset(Lang::$txt['profile_error_' . $error]) ? Lang::$txt['profile_error_' . $error] : ''); |
|
2690 | + sprintf(Lang::$txt['profile_error_' . $error], (empty(Config::$modSettings['password_strength']) ? 4 : 8)) : (isset(Lang::$txt['profile_error_' . $error]) ? Lang::$txt['profile_error_' . $error] : ''); |
|
2692 | 2691 | |
2693 | 2692 | echo ' |
2694 | 2693 | <li>', isset(Lang::$txt['profile_error_' . $error]) ? $text_key_error : $error, '</li>'; |
@@ -456,7 +456,7 @@ |
||
456 | 456 | |
457 | 457 | elseif (Utils::$context['uninstalling']) |
458 | 458 | echo ' |
459 | - ', Lang::$txt['package_uninstall_done'] .' <br> |
|
459 | + ', Lang::$txt['package_uninstall_done'] . ' <br> |
|
460 | 460 | ', '<a href="', Utils::$context['keep_url'], '" class="button">', Lang::$txt['package_keep'], '</a>', '<a href="', Utils::$context['remove_url'], '" class="button">', Lang::$txt['package_delete2'], '</a>'; |
461 | 461 | |
462 | 462 | elseif (Utils::$context['install_finished']) |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | $report_buttons = array( |
198 | 198 | 'ignore' => array( |
199 | 199 | 'text' => !Utils::$context['report']['ignore'] ? 'mc_reportedp_ignore' : 'mc_reportedp_unignore', |
200 | - 'url' => Config::$scripturl.'?action=moderate;area=reportedposts;sa=handle;ignore='.(int) !Utils::$context['report']['ignore'].';rid='.Utils::$context['report']['id'].';'.Utils::$context['session_var'].'='.Utils::$context['session_id'].';'.Utils::$context['mod-report-ignore_token_var'].'='.Utils::$context['mod-report-ignore_token'], |
|
200 | + 'url' => Config::$scripturl . '?action=moderate;area=reportedposts;sa=handle;ignore=' . (int) !Utils::$context['report']['ignore'] . ';rid=' . Utils::$context['report']['id'] . ';' . Utils::$context['session_var'] . '=' . Utils::$context['session_id'] . ';' . Utils::$context['mod-report-ignore_token_var'] . '=' . Utils::$context['mod-report-ignore_token'], |
|
201 | 201 | 'class' => !Utils::$context['report']['ignore'] ? ' you_sure' : '', |
202 | 202 | 'custom' => !Utils::$context['report']['ignore'] ? ' data-confirm="' . Lang::$txt['mc_reportedp_ignore_confirm'] . '"' : '', |
203 | 203 | 'icon' => 'ignore' |
204 | 204 | ), |
205 | 205 | 'close' => array( |
206 | 206 | 'text' => Utils::$context['report']['closed'] ? 'mc_reportedp_open' : 'mc_reportedp_close', |
207 | - 'url' => Config::$scripturl.'?action=moderate;area=reportedposts;sa=handle;closed='.(int) !Utils::$context['report']['closed'].';rid='.Utils::$context['report']['id'].';'.Utils::$context['session_var'].'='.Utils::$context['session_id'].';'.Utils::$context['mod-report-closed_token_var'].'='.Utils::$context['mod-report-closed_token'], |
|
207 | + 'url' => Config::$scripturl . '?action=moderate;area=reportedposts;sa=handle;closed=' . (int) !Utils::$context['report']['closed'] . ';rid=' . Utils::$context['report']['id'] . ';' . Utils::$context['session_var'] . '=' . Utils::$context['session_id'] . ';' . Utils::$context['mod-report-closed_token_var'] . '=' . Utils::$context['mod-report-closed_token'], |
|
208 | 208 | 'icon' => 'close' |
209 | 209 | ) |
210 | 210 | ); |
@@ -479,14 +479,14 @@ discard block |
||
479 | 479 | $report_buttons = array( |
480 | 480 | 'ignore' => array( |
481 | 481 | 'text' => !Utils::$context['report']['ignore'] ? 'mc_reportedp_ignore' : 'mc_reportedp_unignore', |
482 | - 'url' => Config::$scripturl.'?action=moderate;area=reportedmembers;sa=handle;ignore='.(int)!Utils::$context['report']['ignore'].';rid='.Utils::$context['report']['id'].';'.Utils::$context['session_var'].'='.Utils::$context['session_id'].';'.Utils::$context['mod-report-ignore_token_var'].'='.Utils::$context['mod-report-ignore_token'], |
|
482 | + 'url' => Config::$scripturl . '?action=moderate;area=reportedmembers;sa=handle;ignore=' . (int) !Utils::$context['report']['ignore'] . ';rid=' . Utils::$context['report']['id'] . ';' . Utils::$context['session_var'] . '=' . Utils::$context['session_id'] . ';' . Utils::$context['mod-report-ignore_token_var'] . '=' . Utils::$context['mod-report-ignore_token'], |
|
483 | 483 | 'class' => !Utils::$context['report']['ignore'] ? ' you_sure' : '', |
484 | 484 | 'custom' => !Utils::$context['report']['ignore'] ? ' data-confirm="' . Lang::$txt['mc_reportedp_ignore_confirm'] . '"' : '', |
485 | 485 | 'icon' => 'ignore' |
486 | 486 | ), |
487 | 487 | 'close' => array( |
488 | 488 | 'text' => Utils::$context['report']['closed'] ? 'mc_reportedp_open' : 'mc_reportedp_close', |
489 | - 'url' => Config::$scripturl.'?action=moderate;area=reportedmembers;sa=handle;closed='.(int)!Utils::$context['report']['closed'].';rid='.Utils::$context['report']['id'].';'.Utils::$context['session_var'].'='.Utils::$context['session_id'].';'.Utils::$context['mod-report-closed_token_var'].'='.Utils::$context['mod-report-closed_token'], |
|
489 | + 'url' => Config::$scripturl . '?action=moderate;area=reportedmembers;sa=handle;closed=' . (int) !Utils::$context['report']['closed'] . ';rid=' . Utils::$context['report']['id'] . ';' . Utils::$context['session_var'] . '=' . Utils::$context['session_id'] . ';' . Utils::$context['mod-report-closed_token_var'] . '=' . Utils::$context['mod-report-closed_token'], |
|
490 | 490 | 'icon' => 'close' |
491 | 491 | ) |
492 | 492 | ); |
@@ -102,18 +102,22 @@ |
||
102 | 102 | $tempTab++; |
103 | 103 | Utils::$context['tabindex'] = $tempTab; |
104 | 104 | |
105 | - foreach (Utils::$context['richedit_buttons'] as $name => $button) { |
|
106 | - if ($name == 'spell_check') { |
|
105 | + foreach (Utils::$context['richedit_buttons'] as $name => $button) |
|
106 | + { |
|
107 | + if ($name == 'spell_check') |
|
108 | + { |
|
107 | 109 | $button['onclick'] = 'oEditorHandle_' . $editor_id . '.spellCheckStart();'; |
108 | 110 | } |
109 | 111 | |
110 | - if ($name == 'preview') { |
|
112 | + if ($name == 'preview') |
|
113 | + { |
|
111 | 114 | $button['value'] = isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $button['value']; |
112 | 115 | $button['onclick'] = $editor_context['preview_type'] == Editor::PREVIEW_XML ? '' : 'return submitThisOnce(this);'; |
113 | 116 | $button['show'] = $editor_context['preview_type']; |
114 | 117 | } |
115 | 118 | |
116 | - if ($button['show']) { |
|
119 | + if ($button['show']) |
|
120 | + { |
|
117 | 121 | echo ' |
118 | 122 | <input type="', $button['type'], '"', $button['type'] == 'hidden' ? ' id="' . $name . '"' : '', ' name="', $name, '" value="', $button['value'], '"', $button['type'] != 'hidden' ? ' tabindex="' . --$tempTab . '"' : '', !empty($button['onclick']) ? ' onclick="' . $button['onclick'] . '"' : '', !empty($button['accessKey']) ? ' accesskey="' . $button['accessKey'] . '"' : '', $button['type'] != 'hidden' ? ' class="button"' : '', '>'; |
119 | 123 | } |