@@ -68,11 +68,14 @@ discard block |
||
68 | 68 | ini_set('default_socket_timeout', 900); |
69 | 69 | } |
70 | 70 | // Clean the upgrade path if this is from the client. |
71 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
72 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
71 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
72 | + for ($i = 1; |
|
73 | +} |
|
74 | +$i < $_SERVER['argc']; $i++) |
|
73 | 75 | { |
74 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
75 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
76 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
77 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
78 | + } |
|
76 | 79 | } |
77 | 80 | |
78 | 81 | // Are we from the client? |
@@ -80,9 +83,9 @@ discard block |
||
80 | 83 | { |
81 | 84 | $command_line = true; |
82 | 85 | $disable_security = 1; |
83 | -} |
|
84 | -else |
|
86 | +} else { |
|
85 | 87 | $command_line = false; |
88 | +} |
|
86 | 89 | |
87 | 90 | // Load this now just because we can. |
88 | 91 | require_once($upgrade_path . '/Settings.php'); |
@@ -93,10 +96,12 @@ discard block |
||
93 | 96 | $upcontext['user'] = unserialize(base64_decode($upgradeData)); |
94 | 97 | |
95 | 98 | // Check for sensible values. |
96 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
97 | - $upcontext['user']['started'] = time(); |
|
98 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
99 | - $upcontext['user']['updated'] = 0; |
|
99 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
100 | + $upcontext['user']['started'] = time(); |
|
101 | + } |
|
102 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
103 | + $upcontext['user']['updated'] = 0; |
|
104 | + } |
|
100 | 105 | |
101 | 106 | $upcontext['started'] = $upcontext['user']['started']; |
102 | 107 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -159,8 +164,9 @@ discard block |
||
159 | 164 | { |
160 | 165 | $word = trim($word, '-_\''); |
161 | 166 | |
162 | - if ($word != '') |
|
163 | - $returned_words[] = substr($word, 0, 20); |
|
167 | + if ($word != '') { |
|
168 | + $returned_words[] = substr($word, 0, 20); |
|
169 | + } |
|
164 | 170 | } |
165 | 171 | |
166 | 172 | return array_unique($returned_words); |
@@ -175,15 +181,17 @@ discard block |
||
175 | 181 | global $cachedir, $sourcedir; |
176 | 182 | |
177 | 183 | // No directory = no game. |
178 | - if (!is_dir($cachedir)) |
|
179 | - return; |
|
184 | + if (!is_dir($cachedir)) { |
|
185 | + return; |
|
186 | + } |
|
180 | 187 | |
181 | 188 | // Remove the files in SMF's own disk cache, if any |
182 | 189 | $dh = opendir($cachedir); |
183 | 190 | while ($file = readdir($dh)) |
184 | 191 | { |
185 | - if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) |
|
186 | - @unlink($cachedir . '/' . $file); |
|
192 | + if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) { |
|
193 | + @unlink($cachedir . '/' . $file); |
|
194 | + } |
|
187 | 195 | } |
188 | 196 | closedir($dh); |
189 | 197 | |
@@ -199,8 +207,9 @@ discard block |
||
199 | 207 | { |
200 | 208 | function md5_hmac($data, $key) |
201 | 209 | { |
202 | - if (strlen($key) > 64) |
|
203 | - $key = pack('H*', md5($key)); |
|
210 | + if (strlen($key) > 64) { |
|
211 | + $key = pack('H*', md5($key)); |
|
212 | + } |
|
204 | 213 | $key = str_pad($key, 64, chr(0x00)); |
205 | 214 | |
206 | 215 | $k_ipad = $key ^ str_repeat(chr(0x36), 64); |
@@ -211,8 +220,9 @@ discard block |
||
211 | 220 | } |
212 | 221 | |
213 | 222 | // Don't do security check if on Yabbse |
214 | -if (!isset($modSettings['smfVersion'])) |
|
223 | +if (!isset($modSettings['smfVersion'])) { |
|
215 | 224 | $disable_security = true; |
225 | +} |
|
216 | 226 | |
217 | 227 | // This only exists if we're on SMF ;) |
218 | 228 | if (isset($modSettings['smfVersion'])) |
@@ -230,8 +240,9 @@ discard block |
||
230 | 240 | 'db_error_skip' => true, |
231 | 241 | ) |
232 | 242 | ); |
233 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
234 | - $modSettings[$row['variable']] = $row['value']; |
|
243 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
244 | + $modSettings[$row['variable']] = $row['value']; |
|
245 | + } |
|
235 | 246 | $smcFunc['db_free_result']($request); |
236 | 247 | } |
237 | 248 | |
@@ -241,10 +252,12 @@ discard block |
||
241 | 252 | $modSettings['theme_url'] = 'Themes/default'; |
242 | 253 | $modSettings['images_url'] = 'Themes/default/images'; |
243 | 254 | } |
244 | -if (!isset($settings['default_theme_url'])) |
|
255 | +if (!isset($settings['default_theme_url'])) { |
|
245 | 256 | $settings['default_theme_url'] = $modSettings['theme_url']; |
246 | -if (!isset($settings['default_theme_dir'])) |
|
257 | +} |
|
258 | +if (!isset($settings['default_theme_dir'])) { |
|
247 | 259 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
260 | +} |
|
248 | 261 | |
249 | 262 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
250 | 263 | // Default title... |
@@ -262,13 +275,15 @@ discard block |
||
262 | 275 | $support_js = $upcontext['upgrade_status']['js']; |
263 | 276 | |
264 | 277 | // Only set this if the upgrader status says so. |
265 | - if (empty($is_debug)) |
|
266 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
278 | + if (empty($is_debug)) { |
|
279 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
280 | + } |
|
267 | 281 | |
268 | 282 | // Load the language. |
269 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
270 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
271 | -} |
|
283 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
284 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
285 | + } |
|
286 | + } |
|
272 | 287 | // Set the defaults. |
273 | 288 | else |
274 | 289 | { |
@@ -286,15 +301,18 @@ discard block |
||
286 | 301 | } |
287 | 302 | |
288 | 303 | // If this isn't the first stage see whether they are logging in and resuming. |
289 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
304 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
290 | 305 | checkLogin(); |
306 | +} |
|
291 | 307 | |
292 | -if ($command_line) |
|
308 | +if ($command_line) { |
|
293 | 309 | cmdStep0(); |
310 | +} |
|
294 | 311 | |
295 | 312 | // Don't error if we're using xml. |
296 | -if (isset($_GET['xml'])) |
|
313 | +if (isset($_GET['xml'])) { |
|
297 | 314 | $upcontext['return_error'] = true; |
315 | +} |
|
298 | 316 | |
299 | 317 | // Loop through all the steps doing each one as required. |
300 | 318 | $upcontext['overall_percent'] = 0; |
@@ -315,10 +333,11 @@ discard block |
||
315 | 333 | } |
316 | 334 | |
317 | 335 | // Call the step and if it returns false that means pause! |
318 | - if (function_exists($step[2]) && $step[2]() === false) |
|
319 | - break; |
|
320 | - elseif (function_exists($step[2])) |
|
321 | - $upcontext['current_step']++; |
|
336 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
337 | + break; |
|
338 | + } elseif (function_exists($step[2])) { |
|
339 | + $upcontext['current_step']++; |
|
340 | + } |
|
322 | 341 | } |
323 | 342 | $upcontext['overall_percent'] += $step[3]; |
324 | 343 | } |
@@ -357,17 +376,18 @@ discard block |
||
357 | 376 | // This should not happen my dear... HELP ME DEVELOPERS!! |
358 | 377 | if (!empty($command_line)) |
359 | 378 | { |
360 | - if (function_exists('debug_print_backtrace')) |
|
361 | - debug_print_backtrace(); |
|
379 | + if (function_exists('debug_print_backtrace')) { |
|
380 | + debug_print_backtrace(); |
|
381 | + } |
|
362 | 382 | |
363 | 383 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
364 | 384 | flush(); |
365 | 385 | die(); |
366 | 386 | } |
367 | 387 | |
368 | - if (!isset($_GET['xml'])) |
|
369 | - template_upgrade_above(); |
|
370 | - else |
|
388 | + if (!isset($_GET['xml'])) { |
|
389 | + template_upgrade_above(); |
|
390 | + } else |
|
371 | 391 | { |
372 | 392 | header('Content-Type: text/xml; charset=UTF-8'); |
373 | 393 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -389,21 +409,24 @@ discard block |
||
389 | 409 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(safe_serialize($upcontext['upgrade_status'])); |
390 | 410 | |
391 | 411 | // Custom stuff to pass back? |
392 | - if (!empty($upcontext['query_string'])) |
|
393 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
412 | + if (!empty($upcontext['query_string'])) { |
|
413 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
414 | + } |
|
394 | 415 | |
395 | 416 | call_user_func('template_' . $upcontext['sub_template']); |
396 | 417 | } |
397 | 418 | |
398 | 419 | // Was there an error? |
399 | - if (!empty($upcontext['forced_error_message'])) |
|
400 | - echo $upcontext['forced_error_message']; |
|
420 | + if (!empty($upcontext['forced_error_message'])) { |
|
421 | + echo $upcontext['forced_error_message']; |
|
422 | + } |
|
401 | 423 | |
402 | 424 | // Show the footer. |
403 | - if (!isset($_GET['xml'])) |
|
404 | - template_upgrade_below(); |
|
405 | - else |
|
406 | - template_xml_below(); |
|
425 | + if (!isset($_GET['xml'])) { |
|
426 | + template_upgrade_below(); |
|
427 | + } else { |
|
428 | + template_xml_below(); |
|
429 | + } |
|
407 | 430 | } |
408 | 431 | |
409 | 432 | |
@@ -415,15 +438,19 @@ discard block |
||
415 | 438 | $seconds = intval($active % 60); |
416 | 439 | |
417 | 440 | $totalTime = ''; |
418 | - if ($hours > 0) |
|
419 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
420 | - if ($minutes > 0) |
|
421 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
422 | - if ($seconds > 0) |
|
423 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
441 | + if ($hours > 0) { |
|
442 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
443 | + } |
|
444 | + if ($minutes > 0) { |
|
445 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
446 | + } |
|
447 | + if ($seconds > 0) { |
|
448 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
449 | + } |
|
424 | 450 | |
425 | - if (!empty($totalTime)) |
|
426 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
451 | + if (!empty($totalTime)) { |
|
452 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
453 | + } |
|
427 | 454 | } |
428 | 455 | |
429 | 456 | // Bang - gone! |
@@ -436,8 +463,9 @@ discard block |
||
436 | 463 | global $upgradeurl, $upcontext, $command_line; |
437 | 464 | |
438 | 465 | // Command line users can't be redirected. |
439 | - if ($command_line) |
|
440 | - upgradeExit(true); |
|
466 | + if ($command_line) { |
|
467 | + upgradeExit(true); |
|
468 | + } |
|
441 | 469 | |
442 | 470 | // Are we providing the core info? |
443 | 471 | if ($addForm) |
@@ -460,19 +488,22 @@ discard block |
||
460 | 488 | global $modSettings, $sourcedir, $smcFunc; |
461 | 489 | |
462 | 490 | // Do the non-SSI stuff... |
463 | - if (function_exists('set_magic_quotes_runtime')) |
|
464 | - @set_magic_quotes_runtime(0); |
|
491 | + if (function_exists('set_magic_quotes_runtime')) { |
|
492 | + @set_magic_quotes_runtime(0); |
|
493 | + } |
|
465 | 494 | |
466 | 495 | error_reporting(E_ALL); |
467 | 496 | define('SMF', 1); |
468 | 497 | |
469 | 498 | // Start the session. |
470 | - if (@ini_get('session.save_handler') == 'user') |
|
471 | - @ini_set('session.save_handler', 'files'); |
|
499 | + if (@ini_get('session.save_handler') == 'user') { |
|
500 | + @ini_set('session.save_handler', 'files'); |
|
501 | + } |
|
472 | 502 | @session_start(); |
473 | 503 | |
474 | - if (empty($smcFunc)) |
|
475 | - $smcFunc = array(); |
|
504 | + if (empty($smcFunc)) { |
|
505 | + $smcFunc = array(); |
|
506 | + } |
|
476 | 507 | |
477 | 508 | // We need this for authentication and some upgrade code |
478 | 509 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -485,8 +516,9 @@ discard block |
||
485 | 516 | initialize_inputs(); |
486 | 517 | |
487 | 518 | // Get the database going! |
488 | - if (empty($db_type)) |
|
489 | - $db_type = 'mysql'; |
|
519 | + if (empty($db_type)) { |
|
520 | + $db_type = 'mysql'; |
|
521 | + } |
|
490 | 522 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
491 | 523 | { |
492 | 524 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -495,17 +527,19 @@ discard block |
||
495 | 527 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
496 | 528 | |
497 | 529 | // Oh dear god!! |
498 | - if ($db_connection === null) |
|
499 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
530 | + if ($db_connection === null) { |
|
531 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
532 | + } |
|
500 | 533 | |
501 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
502 | - $smcFunc['db_query']('', ' |
|
534 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
535 | + $smcFunc['db_query']('', ' |
|
503 | 536 | SET NAMES {string:db_character_set}', |
504 | 537 | array( |
505 | 538 | 'db_error_skip' => true, |
506 | 539 | 'db_character_set' => $db_character_set, |
507 | 540 | ) |
508 | 541 | ); |
542 | + } |
|
509 | 543 | |
510 | 544 | // Load the modSettings data... |
511 | 545 | $request = $smcFunc['db_query']('', ' |
@@ -516,11 +550,11 @@ discard block |
||
516 | 550 | ) |
517 | 551 | ); |
518 | 552 | $modSettings = array(); |
519 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
520 | - $modSettings[$row['variable']] = $row['value']; |
|
553 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
554 | + $modSettings[$row['variable']] = $row['value']; |
|
555 | + } |
|
521 | 556 | $smcFunc['db_free_result']($request); |
522 | - } |
|
523 | - else |
|
557 | + } else |
|
524 | 558 | { |
525 | 559 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
526 | 560 | } |
@@ -534,9 +568,10 @@ discard block |
||
534 | 568 | cleanRequest(); |
535 | 569 | } |
536 | 570 | |
537 | - if (!isset($_GET['substep'])) |
|
538 | - $_GET['substep'] = 0; |
|
539 | -} |
|
571 | + if (!isset($_GET['substep'])) { |
|
572 | + $_GET['substep'] = 0; |
|
573 | + } |
|
574 | + } |
|
540 | 575 | |
541 | 576 | function initialize_inputs() |
542 | 577 | { |
@@ -574,8 +609,9 @@ discard block |
||
574 | 609 | $dh = opendir(dirname(__FILE__)); |
575 | 610 | while ($file = readdir($dh)) |
576 | 611 | { |
577 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
578 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
612 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
613 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
614 | + } |
|
579 | 615 | } |
580 | 616 | closedir($dh); |
581 | 617 | |
@@ -605,8 +641,9 @@ discard block |
||
605 | 641 | { |
606 | 642 | $upcontext['remote_files_available'] = false; |
607 | 643 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
608 | - if ($test) |
|
609 | - $upcontext['remote_files_available'] = true; |
|
644 | + if ($test) { |
|
645 | + $upcontext['remote_files_available'] = true; |
|
646 | + } |
|
610 | 647 | @fclose($test); |
611 | 648 | } |
612 | 649 | |
@@ -614,8 +651,9 @@ discard block |
||
614 | 651 | $temp = 'upgrade_php?step'; |
615 | 652 | while (strlen($temp) > 4) |
616 | 653 | { |
617 | - if (isset($_GET[$temp])) |
|
618 | - unset($_GET[$temp]); |
|
654 | + if (isset($_GET[$temp])) { |
|
655 | + unset($_GET[$temp]); |
|
656 | + } |
|
619 | 657 | $temp = substr($temp, 1); |
620 | 658 | } |
621 | 659 | |
@@ -641,29 +679,36 @@ discard block |
||
641 | 679 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $type . '.sql'); |
642 | 680 | |
643 | 681 | // Need legacy scripts? |
644 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
645 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
646 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
647 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
648 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
649 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
682 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
683 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
684 | + } |
|
685 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
686 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
687 | + } |
|
688 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
689 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
690 | + } |
|
650 | 691 | |
651 | 692 | // This needs to exist! |
652 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
653 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
654 | - else |
|
655 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
693 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
694 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
695 | + } else { |
|
696 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
697 | + } |
|
656 | 698 | |
657 | - if (!$check) |
|
658 | - // 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. |
|
699 | + if (!$check) { |
|
700 | + // 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. |
|
659 | 701 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
702 | + } |
|
660 | 703 | |
661 | 704 | // Do they meet the install requirements? |
662 | - if (!php_version_check()) |
|
663 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
705 | + if (!php_version_check()) { |
|
706 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
707 | + } |
|
664 | 708 | |
665 | - if (!db_version_check()) |
|
666 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
709 | + if (!db_version_check()) { |
|
710 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
711 | + } |
|
667 | 712 | |
668 | 713 | // Do some checks to make sure they have proper privileges |
669 | 714 | db_extend('packages'); |
@@ -678,14 +723,16 @@ discard block |
||
678 | 723 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
679 | 724 | |
680 | 725 | // Sorry... we need CREATE, ALTER and DROP |
681 | - if (!$create || !$alter || !$drop) |
|
682 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
726 | + if (!$create || !$alter || !$drop) { |
|
727 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
728 | + } |
|
683 | 729 | |
684 | 730 | // Do a quick version spot check. |
685 | 731 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
686 | 732 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
687 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
688 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
733 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
734 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
735 | + } |
|
689 | 736 | |
690 | 737 | // What absolutely needs to be writable? |
691 | 738 | $writable_files = array( |
@@ -707,12 +754,13 @@ discard block |
||
707 | 754 | quickFileWritable($custom_av_dir); |
708 | 755 | |
709 | 756 | // Are we good now? |
710 | - if (!is_writable($custom_av_dir)) |
|
711 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
712 | - elseif ($need_settings_update) |
|
757 | + if (!is_writable($custom_av_dir)) { |
|
758 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
759 | + } elseif ($need_settings_update) |
|
713 | 760 | { |
714 | - if (!function_exists('cache_put_data')) |
|
715 | - require_once($sourcedir . '/Load.php'); |
|
761 | + if (!function_exists('cache_put_data')) { |
|
762 | + require_once($sourcedir . '/Load.php'); |
|
763 | + } |
|
716 | 764 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
717 | 765 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
718 | 766 | } |
@@ -721,28 +769,33 @@ discard block |
||
721 | 769 | |
722 | 770 | // Check the cache directory. |
723 | 771 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
724 | - if (!file_exists($cachedir_temp)) |
|
725 | - @mkdir($cachedir_temp); |
|
726 | - if (!file_exists($cachedir_temp)) |
|
727 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
728 | - |
|
729 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
730 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
731 | - elseif (!isset($_GET['skiplang'])) |
|
772 | + if (!file_exists($cachedir_temp)) { |
|
773 | + @mkdir($cachedir_temp); |
|
774 | + } |
|
775 | + if (!file_exists($cachedir_temp)) { |
|
776 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
777 | + } |
|
778 | + |
|
779 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
780 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
781 | + } elseif (!isset($_GET['skiplang'])) |
|
732 | 782 | { |
733 | 783 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
734 | 784 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
735 | 785 | |
736 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
737 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
786 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
787 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
788 | + } |
|
738 | 789 | } |
739 | 790 | |
740 | - if (!makeFilesWritable($writable_files)) |
|
741 | - return false; |
|
791 | + if (!makeFilesWritable($writable_files)) { |
|
792 | + return false; |
|
793 | + } |
|
742 | 794 | |
743 | 795 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
744 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
745 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
796 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
797 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
798 | + } |
|
746 | 799 | |
747 | 800 | // Upgrade the agreement. |
748 | 801 | elseif (isset($modSettings['agreement'])) |
@@ -753,8 +806,8 @@ discard block |
||
753 | 806 | } |
754 | 807 | |
755 | 808 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
756 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
757 | - $upcontext['warning'] = ' |
|
809 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
810 | + $upcontext['warning'] = ' |
|
758 | 811 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
759 | 812 | <ul> |
760 | 813 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -762,10 +815,12 @@ discard block |
||
762 | 815 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
763 | 816 | </ul> |
764 | 817 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="http://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
818 | + } |
|
765 | 819 | |
766 | 820 | // Either we're logged in or we're going to present the login. |
767 | - if (checkLogin()) |
|
768 | - return true; |
|
821 | + if (checkLogin()) { |
|
822 | + return true; |
|
823 | + } |
|
769 | 824 | |
770 | 825 | $upcontext += createToken('login'); |
771 | 826 | |
@@ -782,8 +837,9 @@ discard block |
||
782 | 837 | if (isset($_POST['contbutt']) && (!empty($_POST['user']) || $disable_security)) |
783 | 838 | { |
784 | 839 | // If we've disabled security pick a suitable name! |
785 | - if (empty($_POST['user'])) |
|
786 | - $_POST['user'] = 'Administrator'; |
|
840 | + if (empty($_POST['user'])) { |
|
841 | + $_POST['user'] = 'Administrator'; |
|
842 | + } |
|
787 | 843 | |
788 | 844 | // Before 2.0 these column names were different! |
789 | 845 | $oldDB = false; |
@@ -798,16 +854,17 @@ discard block |
||
798 | 854 | 'db_error_skip' => true, |
799 | 855 | ) |
800 | 856 | ); |
801 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
802 | - $oldDB = true; |
|
857 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
858 | + $oldDB = true; |
|
859 | + } |
|
803 | 860 | $smcFunc['db_free_result']($request); |
804 | 861 | } |
805 | 862 | |
806 | 863 | // Get what we believe to be their details. |
807 | 864 | if (!$disable_security) |
808 | 865 | { |
809 | - if ($oldDB) |
|
810 | - $request = $smcFunc['db_query']('', ' |
|
866 | + if ($oldDB) { |
|
867 | + $request = $smcFunc['db_query']('', ' |
|
811 | 868 | SELECT id_member, memberName AS member_name, passwd, id_group, |
812 | 869 | additionalGroups AS additional_groups, lngfile |
813 | 870 | FROM {db_prefix}members |
@@ -817,8 +874,8 @@ discard block |
||
817 | 874 | 'db_error_skip' => true, |
818 | 875 | ) |
819 | 876 | ); |
820 | - else |
|
821 | - $request = $smcFunc['db_query']('', ' |
|
877 | + } else { |
|
878 | + $request = $smcFunc['db_query']('', ' |
|
822 | 879 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
823 | 880 | FROM {db_prefix}members |
824 | 881 | WHERE member_name = {string:member_name}', |
@@ -827,6 +884,7 @@ discard block |
||
827 | 884 | 'db_error_skip' => true, |
828 | 885 | ) |
829 | 886 | ); |
887 | + } |
|
830 | 888 | if ($smcFunc['db_num_rows']($request) != 0) |
831 | 889 | { |
832 | 890 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -834,13 +892,14 @@ discard block |
||
834 | 892 | $groups = explode(',', $addGroups); |
835 | 893 | $groups[] = $id_group; |
836 | 894 | |
837 | - foreach ($groups as $k => $v) |
|
838 | - $groups[$k] = (int) $v; |
|
895 | + foreach ($groups as $k => $v) { |
|
896 | + $groups[$k] = (int) $v; |
|
897 | + } |
|
839 | 898 | |
840 | 899 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
900 | + } else { |
|
901 | + $upcontext['username_incorrect'] = true; |
|
841 | 902 | } |
842 | - else |
|
843 | - $upcontext['username_incorrect'] = true; |
|
844 | 903 | $smcFunc['db_free_result']($request); |
845 | 904 | } |
846 | 905 | $upcontext['username'] = $_POST['user']; |
@@ -850,13 +909,14 @@ discard block |
||
850 | 909 | { |
851 | 910 | $upcontext['upgrade_status']['js'] = 1; |
852 | 911 | $support_js = 1; |
912 | + } else { |
|
913 | + $support_js = 0; |
|
853 | 914 | } |
854 | - else |
|
855 | - $support_js = 0; |
|
856 | 915 | |
857 | 916 | // Note down the version we are coming from. |
858 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
859 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
917 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
918 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
919 | + } |
|
860 | 920 | |
861 | 921 | // Didn't get anywhere? |
862 | 922 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -890,15 +950,15 @@ discard block |
||
890 | 950 | 'db_error_skip' => true, |
891 | 951 | ) |
892 | 952 | ); |
893 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
894 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
953 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
954 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
955 | + } |
|
895 | 956 | $smcFunc['db_free_result']($request); |
896 | 957 | } |
897 | 958 | |
898 | 959 | $upcontext['user']['id'] = $id_member; |
899 | 960 | $upcontext['user']['name'] = $name; |
900 | - } |
|
901 | - else |
|
961 | + } else |
|
902 | 962 | { |
903 | 963 | $upcontext['user']['id'] = 1; |
904 | 964 | $upcontext['user']['name'] = 'Administrator'; |
@@ -914,11 +974,11 @@ discard block |
||
914 | 974 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
915 | 975 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
916 | 976 | |
917 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
918 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
919 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
920 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
921 | - else |
|
977 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
978 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
979 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
980 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
981 | + } else |
|
922 | 982 | { |
923 | 983 | // Set this as the new language. |
924 | 984 | $upcontext['language'] = $user_language; |
@@ -962,8 +1022,9 @@ discard block |
||
962 | 1022 | unset($member_columns); |
963 | 1023 | |
964 | 1024 | // If we've not submitted then we're done. |
965 | - if (empty($_POST['upcont'])) |
|
966 | - return false; |
|
1025 | + if (empty($_POST['upcont'])) { |
|
1026 | + return false; |
|
1027 | + } |
|
967 | 1028 | |
968 | 1029 | require_once($sourcedir . '/Subs-Admin.php'); |
969 | 1030 | updateSettingsFile(array('image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'')); |
@@ -981,25 +1042,26 @@ discard block |
||
981 | 1042 | fwrite($fp, $out); |
982 | 1043 | |
983 | 1044 | $return_data = ''; |
984 | - while (!feof($fp)) |
|
985 | - $return_data .= fgets($fp, 128); |
|
1045 | + while (!feof($fp)) { |
|
1046 | + $return_data .= fgets($fp, 128); |
|
1047 | + } |
|
986 | 1048 | |
987 | 1049 | fclose($fp); |
988 | 1050 | |
989 | 1051 | // Get the unique site ID. |
990 | 1052 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
991 | 1053 | |
992 | - if (!empty($ID[1])) |
|
993 | - $smcFunc['db_insert']('replace', |
|
1054 | + if (!empty($ID[1])) { |
|
1055 | + $smcFunc['db_insert']('replace', |
|
994 | 1056 | $db_prefix . 'settings', |
995 | 1057 | array('variable' => 'string', 'value' => 'string'), |
996 | 1058 | array('allow_sm_stats', $ID[1]), |
997 | 1059 | array('variable') |
998 | 1060 | ); |
1061 | + } |
|
999 | 1062 | } |
1000 | - } |
|
1001 | - else |
|
1002 | - $smcFunc['db_query']('', ' |
|
1063 | + } else { |
|
1064 | + $smcFunc['db_query']('', ' |
|
1003 | 1065 | DELETE FROM {db_prefix}settings |
1004 | 1066 | WHERE variable = {string:allow_sm_stats}', |
1005 | 1067 | array( |
@@ -1007,6 +1069,7 @@ discard block |
||
1007 | 1069 | 'db_error_skip' => true, |
1008 | 1070 | ) |
1009 | 1071 | ); |
1072 | + } |
|
1010 | 1073 | |
1011 | 1074 | // Deleting old karma stuff? |
1012 | 1075 | if (!empty($_POST['delete_karma'])) |
@@ -1021,20 +1084,22 @@ discard block |
||
1021 | 1084 | ); |
1022 | 1085 | |
1023 | 1086 | // Cleaning up old karma member settings. |
1024 | - if ($upcontext['karma_installed']['good']) |
|
1025 | - $smcFunc['db_query']('', ' |
|
1087 | + if ($upcontext['karma_installed']['good']) { |
|
1088 | + $smcFunc['db_query']('', ' |
|
1026 | 1089 | ALTER TABLE {db_prefix}members |
1027 | 1090 | DROP karma_good', |
1028 | 1091 | array() |
1029 | 1092 | ); |
1093 | + } |
|
1030 | 1094 | |
1031 | 1095 | // Does karma bad was enable? |
1032 | - if ($upcontext['karma_installed']['bad']) |
|
1033 | - $smcFunc['db_query']('', ' |
|
1096 | + if ($upcontext['karma_installed']['bad']) { |
|
1097 | + $smcFunc['db_query']('', ' |
|
1034 | 1098 | ALTER TABLE {db_prefix}members |
1035 | 1099 | DROP karma_bad', |
1036 | 1100 | array() |
1037 | 1101 | ); |
1102 | + } |
|
1038 | 1103 | |
1039 | 1104 | // Cleaning up old karma permissions. |
1040 | 1105 | $smcFunc['db_query']('', ' |
@@ -1047,18 +1112,20 @@ discard block |
||
1047 | 1112 | } |
1048 | 1113 | |
1049 | 1114 | // Emptying the error log? |
1050 | - if (!empty($_POST['empty_error'])) |
|
1051 | - $smcFunc['db_query']('truncate_table', ' |
|
1115 | + if (!empty($_POST['empty_error'])) { |
|
1116 | + $smcFunc['db_query']('truncate_table', ' |
|
1052 | 1117 | TRUNCATE {db_prefix}log_errors', |
1053 | 1118 | array( |
1054 | 1119 | ) |
1055 | 1120 | ); |
1121 | + } |
|
1056 | 1122 | |
1057 | 1123 | $changes = array(); |
1058 | 1124 | |
1059 | 1125 | // If we're overriding the language follow it through. |
1060 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
1061 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1126 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
1127 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1128 | + } |
|
1062 | 1129 | |
1063 | 1130 | if (!empty($_POST['maint'])) |
1064 | 1131 | { |
@@ -1070,37 +1137,42 @@ discard block |
||
1070 | 1137 | { |
1071 | 1138 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
1072 | 1139 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
1073 | - } |
|
1074 | - else |
|
1140 | + } else |
|
1075 | 1141 | { |
1076 | 1142 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
1077 | 1143 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
1078 | 1144 | } |
1079 | 1145 | } |
1080 | 1146 | |
1081 | - if ($command_line) |
|
1082 | - echo ' * Updating Settings.php...'; |
|
1147 | + if ($command_line) { |
|
1148 | + echo ' * Updating Settings.php...'; |
|
1149 | + } |
|
1083 | 1150 | |
1084 | 1151 | // Backup the current one first. |
1085 | 1152 | copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
1086 | 1153 | |
1087 | 1154 | // Fix some old paths. |
1088 | - if (substr($boarddir, 0, 1) == '.') |
|
1089 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1155 | + if (substr($boarddir, 0, 1) == '.') { |
|
1156 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1157 | + } |
|
1090 | 1158 | |
1091 | - if (substr($sourcedir, 0, 1) == '.') |
|
1092 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1159 | + if (substr($sourcedir, 0, 1) == '.') { |
|
1160 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1161 | + } |
|
1093 | 1162 | |
1094 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
1095 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1163 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
1164 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1165 | + } |
|
1096 | 1166 | |
1097 | 1167 | // Not had the database type added before? |
1098 | - if (empty($db_type)) |
|
1099 | - $changes['db_type'] = 'mysql'; |
|
1168 | + if (empty($db_type)) { |
|
1169 | + $changes['db_type'] = 'mysql'; |
|
1170 | + } |
|
1100 | 1171 | |
1101 | 1172 | // For now we offer a option, this may change in future versions when mysql is completely removed. |
1102 | - if (!empty($_POST['convertMysql']) && $db_type == 'mysql') |
|
1103 | - $changes['db_type'] = '\'mysqli\''; |
|
1173 | + if (!empty($_POST['convertMysql']) && $db_type == 'mysql') { |
|
1174 | + $changes['db_type'] = '\'mysqli\''; |
|
1175 | + } |
|
1104 | 1176 | |
1105 | 1177 | // If they have a "host:port" setup for the host, split that into separate values |
1106 | 1178 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1111,28 +1183,31 @@ discard block |
||
1111 | 1183 | $changes['db_server'] = '\'' . $db_server . '\''; |
1112 | 1184 | |
1113 | 1185 | // Only set this if we're not using the default port |
1114 | - if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) |
|
1115 | - $changes['db_port'] = (int) $db_port; |
|
1116 | - } |
|
1117 | - elseif (!empty($db_port)) |
|
1186 | + if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) { |
|
1187 | + $changes['db_port'] = (int) $db_port; |
|
1188 | + } |
|
1189 | + } elseif (!empty($db_port)) |
|
1118 | 1190 | { |
1119 | 1191 | // If db_port is set and is the same as the default, set it to '' |
1120 | 1192 | if ($db_type == 'mysql' || $db_type == 'mysqli') |
1121 | 1193 | { |
1122 | - if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) |
|
1123 | - $changes['db_port'] = '\'\''; |
|
1124 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
1125 | - $changes['db_port'] = '\'\''; |
|
1194 | + if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) { |
|
1195 | + $changes['db_port'] = '\'\''; |
|
1196 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
1197 | + $changes['db_port'] = '\'\''; |
|
1198 | + } |
|
1126 | 1199 | } |
1127 | 1200 | } |
1128 | 1201 | |
1129 | 1202 | // Maybe we haven't had this option yet? |
1130 | - if (empty($packagesdir)) |
|
1131 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1203 | + if (empty($packagesdir)) { |
|
1204 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1205 | + } |
|
1132 | 1206 | |
1133 | 1207 | // Add support for $tasksdir var. |
1134 | - if (empty($tasksdir)) |
|
1135 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1208 | + if (empty($tasksdir)) { |
|
1209 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1210 | + } |
|
1136 | 1211 | |
1137 | 1212 | // @todo Maybe change the cookie name if going to 1.1, too? |
1138 | 1213 | |
@@ -1177,8 +1252,7 @@ discard block |
||
1177 | 1252 | $found_old = true; |
1178 | 1253 | // Replace the old line with the new code |
1179 | 1254 | $settings_file = str_replace('$db_last_error = ' . $db_last_error . ';', $error_catching_header . $error_catching, $settings_file); |
1180 | - } |
|
1181 | - else |
|
1255 | + } else |
|
1182 | 1256 | { |
1183 | 1257 | $found_old = false; |
1184 | 1258 | // We want the comments as well as the code... |
@@ -1209,8 +1283,9 @@ discard block |
||
1209 | 1283 | fclose($file); |
1210 | 1284 | } |
1211 | 1285 | |
1212 | - if ($command_line) |
|
1213 | - echo ' Successful.' . "\n"; |
|
1286 | + if ($command_line) { |
|
1287 | + echo ' Successful.' . "\n"; |
|
1288 | + } |
|
1214 | 1289 | |
1215 | 1290 | // Are we doing debug? |
1216 | 1291 | if (isset($_POST['debug'])) |
@@ -1220,8 +1295,9 @@ discard block |
||
1220 | 1295 | } |
1221 | 1296 | |
1222 | 1297 | // If we're not backing up then jump one. |
1223 | - if (empty($_POST['backup'])) |
|
1224 | - $upcontext['current_step']++; |
|
1298 | + if (empty($_POST['backup'])) { |
|
1299 | + $upcontext['current_step']++; |
|
1300 | + } |
|
1225 | 1301 | |
1226 | 1302 | // If we've got here then let's proceed to the next step! |
1227 | 1303 | return true; |
@@ -1236,8 +1312,9 @@ discard block |
||
1236 | 1312 | $upcontext['page_title'] = 'Backup Database'; |
1237 | 1313 | |
1238 | 1314 | // Done it already - js wise? |
1239 | - if (!empty($_POST['backup_done'])) |
|
1240 | - return true; |
|
1315 | + if (!empty($_POST['backup_done'])) { |
|
1316 | + return true; |
|
1317 | + } |
|
1241 | 1318 | |
1242 | 1319 | // Some useful stuff here. |
1243 | 1320 | db_extend(); |
@@ -1251,9 +1328,10 @@ discard block |
||
1251 | 1328 | $tables = $smcFunc['db_list_tables']($db, $filter); |
1252 | 1329 | |
1253 | 1330 | $table_names = array(); |
1254 | - foreach ($tables as $table) |
|
1255 | - if (substr($table, 0, 7) !== 'backup_') |
|
1331 | + foreach ($tables as $table) { |
|
1332 | + if (substr($table, 0, 7) !== 'backup_') |
|
1256 | 1333 | $table_names[] = $table; |
1334 | + } |
|
1257 | 1335 | |
1258 | 1336 | $upcontext['table_count'] = count($table_names); |
1259 | 1337 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1263,12 +1341,14 @@ discard block |
||
1263 | 1341 | $file_steps = $upcontext['table_count']; |
1264 | 1342 | |
1265 | 1343 | // What ones have we already done? |
1266 | - foreach ($table_names as $id => $table) |
|
1267 | - if ($id < $_GET['substep']) |
|
1344 | + foreach ($table_names as $id => $table) { |
|
1345 | + if ($id < $_GET['substep']) |
|
1268 | 1346 | $upcontext['previous_tables'][] = $table; |
1347 | + } |
|
1269 | 1348 | |
1270 | - if ($command_line) |
|
1271 | - echo 'Backing Up Tables.'; |
|
1349 | + if ($command_line) { |
|
1350 | + echo 'Backing Up Tables.'; |
|
1351 | + } |
|
1272 | 1352 | |
1273 | 1353 | // If we don't support javascript we backup here. |
1274 | 1354 | if (!$support_js || isset($_GET['xml'])) |
@@ -1287,8 +1367,9 @@ discard block |
||
1287 | 1367 | backupTable($table_names[$substep]); |
1288 | 1368 | |
1289 | 1369 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1290 | - if (isset($_GET['xml'])) |
|
1291 | - return upgradeExit(); |
|
1370 | + if (isset($_GET['xml'])) { |
|
1371 | + return upgradeExit(); |
|
1372 | + } |
|
1292 | 1373 | } |
1293 | 1374 | |
1294 | 1375 | if ($command_line) |
@@ -1321,9 +1402,10 @@ discard block |
||
1321 | 1402 | |
1322 | 1403 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
1323 | 1404 | |
1324 | - if ($command_line) |
|
1325 | - echo ' done.'; |
|
1326 | -} |
|
1405 | + if ($command_line) { |
|
1406 | + echo ' done.'; |
|
1407 | + } |
|
1408 | + } |
|
1327 | 1409 | |
1328 | 1410 | // Step 2: Everything. |
1329 | 1411 | function DatabaseChanges() |
@@ -1332,8 +1414,9 @@ discard block |
||
1332 | 1414 | global $upcontext, $support_js, $db_type; |
1333 | 1415 | |
1334 | 1416 | // Have we just completed this? |
1335 | - if (!empty($_POST['database_done'])) |
|
1336 | - return true; |
|
1417 | + if (!empty($_POST['database_done'])) { |
|
1418 | + return true; |
|
1419 | + } |
|
1337 | 1420 | |
1338 | 1421 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
1339 | 1422 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1350,15 +1433,16 @@ discard block |
||
1350 | 1433 | ); |
1351 | 1434 | |
1352 | 1435 | // How many files are there in total? |
1353 | - if (isset($_GET['filecount'])) |
|
1354 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1355 | - else |
|
1436 | + if (isset($_GET['filecount'])) { |
|
1437 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1438 | + } else |
|
1356 | 1439 | { |
1357 | 1440 | $upcontext['file_count'] = 0; |
1358 | 1441 | foreach ($files as $file) |
1359 | 1442 | { |
1360 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
1361 | - $upcontext['file_count']++; |
|
1443 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
1444 | + $upcontext['file_count']++; |
|
1445 | + } |
|
1362 | 1446 | } |
1363 | 1447 | } |
1364 | 1448 | |
@@ -1368,9 +1452,9 @@ discard block |
||
1368 | 1452 | $upcontext['cur_file_num'] = 0; |
1369 | 1453 | foreach ($files as $file) |
1370 | 1454 | { |
1371 | - if ($did_not_do) |
|
1372 | - $did_not_do--; |
|
1373 | - else |
|
1455 | + if ($did_not_do) { |
|
1456 | + $did_not_do--; |
|
1457 | + } else |
|
1374 | 1458 | { |
1375 | 1459 | $upcontext['cur_file_num']++; |
1376 | 1460 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1397,12 +1481,13 @@ discard block |
||
1397 | 1481 | // Flag to move on to the next. |
1398 | 1482 | $upcontext['completed_step'] = true; |
1399 | 1483 | // Did we complete the whole file? |
1400 | - if ($nextFile) |
|
1401 | - $upcontext['current_debug_item_num'] = -1; |
|
1484 | + if ($nextFile) { |
|
1485 | + $upcontext['current_debug_item_num'] = -1; |
|
1486 | + } |
|
1402 | 1487 | return upgradeExit(); |
1488 | + } elseif ($support_js) { |
|
1489 | + break; |
|
1403 | 1490 | } |
1404 | - elseif ($support_js) |
|
1405 | - break; |
|
1406 | 1491 | } |
1407 | 1492 | // Set the progress bar to be right as if we had - even if we hadn't... |
1408 | 1493 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1426,8 +1511,9 @@ discard block |
||
1426 | 1511 | global $db_prefix, $upcontext, $boarddir, $packagesdir, $settings, $smcFunc, $command_line; |
1427 | 1512 | |
1428 | 1513 | // Sorry. Not supported for command line users. |
1429 | - if ($command_line) |
|
1430 | - return true; |
|
1514 | + if ($command_line) { |
|
1515 | + return true; |
|
1516 | + } |
|
1431 | 1517 | |
1432 | 1518 | // Skipping first? |
1433 | 1519 | if (!empty($_POST['skip'])) |
@@ -1437,8 +1523,9 @@ discard block |
||
1437 | 1523 | } |
1438 | 1524 | |
1439 | 1525 | // If we get here withOUT SSI we need to redirect to ensure we get it! |
1440 | - if (!isset($_GET['ssi']) || !function_exists('mktree')) |
|
1441 | - redirectLocation('&ssi=1'); |
|
1526 | + if (!isset($_GET['ssi']) || !function_exists('mktree')) { |
|
1527 | + redirectLocation('&ssi=1'); |
|
1528 | + } |
|
1442 | 1529 | |
1443 | 1530 | $upcontext['sub_template'] = 'clean_mods'; |
1444 | 1531 | $upcontext['page_title'] = 'Cleanup Modifications'; |
@@ -1447,8 +1534,9 @@ discard block |
||
1447 | 1534 | $upcontext['skip'] = true; |
1448 | 1535 | |
1449 | 1536 | // If we're on the second redirect continue... |
1450 | - if (isset($_POST['cleandone2'])) |
|
1451 | - return true; |
|
1537 | + if (isset($_POST['cleandone2'])) { |
|
1538 | + return true; |
|
1539 | + } |
|
1452 | 1540 | |
1453 | 1541 | // Do we already know about some writable files? |
1454 | 1542 | if (isset($_POST['writable_files'])) |
@@ -1463,8 +1551,9 @@ discard block |
||
1463 | 1551 | } |
1464 | 1552 | |
1465 | 1553 | // Make sure we have some sort of packages directory. |
1466 | - if (!isset($packagesdir)) |
|
1467 | - $packagesdir = $boarddir . '/Packages'; |
|
1554 | + if (!isset($packagesdir)) { |
|
1555 | + $packagesdir = $boarddir . '/Packages'; |
|
1556 | + } |
|
1468 | 1557 | |
1469 | 1558 | // Load all theme paths.... |
1470 | 1559 | $request = $smcFunc['db_query']('', ' |
@@ -1482,10 +1571,11 @@ discard block |
||
1482 | 1571 | $theme_paths = array(); |
1483 | 1572 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1484 | 1573 | { |
1485 | - if ($row['id_theme'] == 1) |
|
1486 | - $settings['default_' . $row['variable']] = $row['value']; |
|
1487 | - elseif ($row['variable'] == 'theme_dir') |
|
1488 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
1574 | + if ($row['id_theme'] == 1) { |
|
1575 | + $settings['default_' . $row['variable']] = $row['value']; |
|
1576 | + } elseif ($row['variable'] == 'theme_dir') { |
|
1577 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
1578 | + } |
|
1489 | 1579 | } |
1490 | 1580 | $smcFunc['db_free_result']($request); |
1491 | 1581 | |
@@ -1509,8 +1599,7 @@ discard block |
||
1509 | 1599 | $status = 'Missing'; |
1510 | 1600 | $status_color = 'red'; |
1511 | 1601 | $result = 'Removed'; |
1512 | - } |
|
1513 | - else |
|
1602 | + } else |
|
1514 | 1603 | { |
1515 | 1604 | $status = 'Installed'; |
1516 | 1605 | $status_color = 'green'; |
@@ -1535,12 +1624,14 @@ discard block |
||
1535 | 1624 | $smcFunc['db_free_result']($request); |
1536 | 1625 | |
1537 | 1626 | // Don't carry on if there are none. |
1538 | - if (empty($upcontext['packages'])) |
|
1539 | - return true; |
|
1627 | + if (empty($upcontext['packages'])) { |
|
1628 | + return true; |
|
1629 | + } |
|
1540 | 1630 | |
1541 | 1631 | // Setup some basics. |
1542 | - if (!empty($upcontext['user']['version'])) |
|
1543 | - $_SESSION['version_emulate'] = $upcontext['user']['version']; |
|
1632 | + if (!empty($upcontext['user']['version'])) { |
|
1633 | + $_SESSION['version_emulate'] = $upcontext['user']['version']; |
|
1634 | + } |
|
1544 | 1635 | |
1545 | 1636 | // Before we get started, don't report notice errors. |
1546 | 1637 | $oldErrorReporting = error_reporting(E_ALL ^ E_NOTICE); |
@@ -1563,34 +1654,40 @@ discard block |
||
1563 | 1654 | foreach ($upcontext['packages'] as $id => $package) |
1564 | 1655 | { |
1565 | 1656 | // Can't do anything about this.... |
1566 | - if ($package['missing_file']) |
|
1567 | - continue; |
|
1657 | + if ($package['missing_file']) { |
|
1658 | + continue; |
|
1659 | + } |
|
1568 | 1660 | |
1569 | 1661 | // Not testing *and* this wasn't checked? |
1570 | - if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id]))) |
|
1571 | - continue; |
|
1662 | + if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id]))) { |
|
1663 | + continue; |
|
1664 | + } |
|
1572 | 1665 | |
1573 | 1666 | // What are the themes this was installed into? |
1574 | 1667 | $cur_theme_paths = array(); |
1575 | - foreach ($theme_paths as $tid => $data) |
|
1576 | - if ($tid != 1 && in_array($tid, $package['themes'])) |
|
1668 | + foreach ($theme_paths as $tid => $data) { |
|
1669 | + if ($tid != 1 && in_array($tid, $package['themes'])) |
|
1577 | 1670 | $cur_theme_paths[$tid] = $data; |
1671 | + } |
|
1578 | 1672 | |
1579 | 1673 | // Get the modifications data if applicable. |
1580 | 1674 | $filename = $package['filename']; |
1581 | 1675 | $packageInfo = getPackageInfo($filename); |
1582 | - if (!is_array($packageInfo)) |
|
1583 | - continue; |
|
1676 | + if (!is_array($packageInfo)) { |
|
1677 | + continue; |
|
1678 | + } |
|
1584 | 1679 | |
1585 | 1680 | $info = parsePackageInfo($packageInfo['xml'], $test, 'uninstall'); |
1586 | 1681 | // Also get the reinstall details... |
1587 | - if (isset($_POST['remove'])) |
|
1588 | - $infoInstall = parsePackageInfo($packageInfo['xml'], true); |
|
1682 | + if (isset($_POST['remove'])) { |
|
1683 | + $infoInstall = parsePackageInfo($packageInfo['xml'], true); |
|
1684 | + } |
|
1589 | 1685 | |
1590 | - if (is_file($packagesdir . '/' . $filename)) |
|
1591 | - read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1592 | - else |
|
1593 | - copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1686 | + if (is_file($packagesdir . '/' . $filename)) { |
|
1687 | + read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1688 | + } else { |
|
1689 | + copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1690 | + } |
|
1594 | 1691 | |
1595 | 1692 | // Work out how we uninstall... |
1596 | 1693 | $files = array(); |
@@ -1602,16 +1699,18 @@ discard block |
||
1602 | 1699 | if ($change['type'] == 'modification') |
1603 | 1700 | { |
1604 | 1701 | $contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']); |
1605 | - if ($change['boardmod']) |
|
1606 | - $results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths); |
|
1607 | - else |
|
1608 | - $results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths); |
|
1702 | + if ($change['boardmod']) { |
|
1703 | + $results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths); |
|
1704 | + } else { |
|
1705 | + $results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths); |
|
1706 | + } |
|
1609 | 1707 | |
1610 | 1708 | foreach ($results as $action) |
1611 | 1709 | { |
1612 | 1710 | // Something we can remove? Probably means it existed! |
1613 | - if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files)) |
|
1614 | - $files[] = $action['filename']; |
|
1711 | + if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files)) { |
|
1712 | + $files[] = $action['filename']; |
|
1713 | + } |
|
1615 | 1714 | if ($action['type'] == 'failure') |
1616 | 1715 | { |
1617 | 1716 | $upcontext['packages'][$id]['needs_removing'] = true; |
@@ -1627,17 +1726,19 @@ discard block |
||
1627 | 1726 | $upcontext['packages'][$id]['file_count'] = count($files); |
1628 | 1727 | |
1629 | 1728 | // If we've done something save the changes! |
1630 | - if (!$test) |
|
1631 | - package_flush_cache(); |
|
1729 | + if (!$test) { |
|
1730 | + package_flush_cache(); |
|
1731 | + } |
|
1632 | 1732 | |
1633 | 1733 | // Are we attempting to reinstall this thing? |
1634 | 1734 | if (isset($_POST['remove']) && !$test && isset($infoInstall)) |
1635 | 1735 | { |
1636 | 1736 | // Need to extract again I'm afraid. |
1637 | - if (is_file($packagesdir . '/' . $filename)) |
|
1638 | - read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1639 | - else |
|
1640 | - copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1737 | + if (is_file($packagesdir . '/' . $filename)) { |
|
1738 | + read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1739 | + } else { |
|
1740 | + copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1741 | + } |
|
1641 | 1742 | |
1642 | 1743 | $errors = false; |
1643 | 1744 | $upcontext['packages'][$id]['result'] = 'Removed'; |
@@ -1646,15 +1747,17 @@ discard block |
||
1646 | 1747 | if ($change['type'] == 'modification') |
1647 | 1748 | { |
1648 | 1749 | $contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']); |
1649 | - if ($change['boardmod']) |
|
1650 | - $results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths); |
|
1651 | - else |
|
1652 | - $results = parseModification($contents, true, $change['reverse'], $cur_theme_paths); |
|
1750 | + if ($change['boardmod']) { |
|
1751 | + $results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths); |
|
1752 | + } else { |
|
1753 | + $results = parseModification($contents, true, $change['reverse'], $cur_theme_paths); |
|
1754 | + } |
|
1653 | 1755 | |
1654 | 1756 | // Are there any errors? |
1655 | - foreach ($results as $action) |
|
1656 | - if ($action['type'] == 'failure') |
|
1757 | + foreach ($results as $action) { |
|
1758 | + if ($action['type'] == 'failure') |
|
1657 | 1759 | $errors = true; |
1760 | + } |
|
1658 | 1761 | } |
1659 | 1762 | } |
1660 | 1763 | if (!$errors) |
@@ -1667,10 +1770,11 @@ discard block |
||
1667 | 1770 | if ($change['type'] == 'modification') |
1668 | 1771 | { |
1669 | 1772 | $contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']); |
1670 | - if ($change['boardmod']) |
|
1671 | - $results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths); |
|
1672 | - else |
|
1673 | - $results = parseModification($contents, false, $change['reverse'], $cur_theme_paths); |
|
1773 | + if ($change['boardmod']) { |
|
1774 | + $results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths); |
|
1775 | + } else { |
|
1776 | + $results = parseModification($contents, false, $change['reverse'], $cur_theme_paths); |
|
1777 | + } |
|
1674 | 1778 | } |
1675 | 1779 | } |
1676 | 1780 | |
@@ -1689,9 +1793,10 @@ discard block |
||
1689 | 1793 | $writable_files = array(); |
1690 | 1794 | foreach ($upcontext['packages'] as $package) |
1691 | 1795 | { |
1692 | - if (!empty($package['files'])) |
|
1693 | - foreach ($package['files'] as $file) |
|
1796 | + if (!empty($package['files'])) { |
|
1797 | + foreach ($package['files'] as $file) |
|
1694 | 1798 | $writable_files[] = $file; |
1799 | + } |
|
1695 | 1800 | } |
1696 | 1801 | |
1697 | 1802 | if (!empty($writable_files)) |
@@ -1699,13 +1804,15 @@ discard block |
||
1699 | 1804 | $writable_files = array_unique($writable_files); |
1700 | 1805 | $upcontext['writable_files'] = $writable_files; |
1701 | 1806 | |
1702 | - if (!makeFilesWritable($writable_files)) |
|
1703 | - return false; |
|
1807 | + if (!makeFilesWritable($writable_files)) { |
|
1808 | + return false; |
|
1809 | + } |
|
1704 | 1810 | } |
1705 | 1811 | } |
1706 | 1812 | |
1707 | - if (file_exists($packagesdir . '/temp')) |
|
1708 | - deltree($packagesdir . '/temp'); |
|
1813 | + if (file_exists($packagesdir . '/temp')) { |
|
1814 | + deltree($packagesdir . '/temp'); |
|
1815 | + } |
|
1709 | 1816 | |
1710 | 1817 | // Removing/Reinstalling any packages? |
1711 | 1818 | if (isset($_POST['remove'])) |
@@ -1713,32 +1820,35 @@ discard block |
||
1713 | 1820 | $deletes = array(); |
1714 | 1821 | foreach ($_POST['remove'] as $id => $dummy) |
1715 | 1822 | { |
1716 | - if (!in_array((int) $id, $reinstall_worked)) |
|
1717 | - $deletes[] = (int) $id; |
|
1823 | + if (!in_array((int) $id, $reinstall_worked)) { |
|
1824 | + $deletes[] = (int) $id; |
|
1825 | + } |
|
1718 | 1826 | } |
1719 | 1827 | |
1720 | - if (!empty($deletes)) |
|
1721 | - upgrade_query(' |
|
1828 | + if (!empty($deletes)) { |
|
1829 | + upgrade_query(' |
|
1722 | 1830 | UPDATE ' . $db_prefix . 'log_packages |
1723 | 1831 | SET install_state = 0 |
1724 | 1832 | WHERE id_install IN (' . implode(',', $deletes) . ')'); |
1833 | + } |
|
1725 | 1834 | |
1726 | 1835 | // Ensure we don't lose our changes! |
1727 | 1836 | package_put_contents($packagesdir . '/installed.list', time()); |
1728 | 1837 | |
1729 | 1838 | $upcontext['sub_template'] = 'cleanup_done'; |
1730 | 1839 | return false; |
1731 | - } |
|
1732 | - else |
|
1840 | + } else |
|
1733 | 1841 | { |
1734 | 1842 | $allgood = true; |
1735 | 1843 | // Is there actually anything that needs our attention? |
1736 | - foreach ($upcontext['packages'] as $package) |
|
1737 | - if ($package['color'] != 'green') |
|
1844 | + foreach ($upcontext['packages'] as $package) { |
|
1845 | + if ($package['color'] != 'green') |
|
1738 | 1846 | $allgood = false; |
1847 | + } |
|
1739 | 1848 | |
1740 | - if ($allgood) |
|
1741 | - return true; |
|
1849 | + if ($allgood) { |
|
1850 | + return true; |
|
1851 | + } |
|
1742 | 1852 | } |
1743 | 1853 | |
1744 | 1854 | $_GET['substep'] = 0; |
@@ -1752,8 +1862,9 @@ discard block |
||
1752 | 1862 | global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
1753 | 1863 | |
1754 | 1864 | // Now it's nice to have some of the basic SMF source files. |
1755 | - if (!isset($_GET['ssi']) && !$command_line) |
|
1756 | - redirectLocation('&ssi=1'); |
|
1865 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
1866 | + redirectLocation('&ssi=1'); |
|
1867 | + } |
|
1757 | 1868 | |
1758 | 1869 | $upcontext['sub_template'] = 'upgrade_complete'; |
1759 | 1870 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1769,14 +1880,16 @@ discard block |
||
1769 | 1880 | // Are we in maintenance mode? |
1770 | 1881 | if (isset($upcontext['user']['main'])) |
1771 | 1882 | { |
1772 | - if ($command_line) |
|
1773 | - echo ' * '; |
|
1883 | + if ($command_line) { |
|
1884 | + echo ' * '; |
|
1885 | + } |
|
1774 | 1886 | $upcontext['removed_maintenance'] = true; |
1775 | 1887 | $changes['maintenance'] = $upcontext['user']['main']; |
1776 | 1888 | } |
1777 | 1889 | // Otherwise if somehow we are in 2 let's go to 1. |
1778 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
1779 | - $changes['maintenance'] = 1; |
|
1890 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
1891 | + $changes['maintenance'] = 1; |
|
1892 | + } |
|
1780 | 1893 | |
1781 | 1894 | // Wipe this out... |
1782 | 1895 | $upcontext['user'] = array(); |
@@ -1792,9 +1905,9 @@ discard block |
||
1792 | 1905 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1793 | 1906 | |
1794 | 1907 | // Now is the perfect time to fetch the SM files. |
1795 | - if ($command_line) |
|
1796 | - cli_scheduled_fetchSMfiles(); |
|
1797 | - else |
|
1908 | + if ($command_line) { |
|
1909 | + cli_scheduled_fetchSMfiles(); |
|
1910 | + } else |
|
1798 | 1911 | { |
1799 | 1912 | require_once($sourcedir . '/ScheduledTasks.php'); |
1800 | 1913 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1802,8 +1915,9 @@ discard block |
||
1802 | 1915 | } |
1803 | 1916 | |
1804 | 1917 | // Log what we've done. |
1805 | - if (empty($user_info['id'])) |
|
1806 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1918 | + if (empty($user_info['id'])) { |
|
1919 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1920 | + } |
|
1807 | 1921 | |
1808 | 1922 | // Log the action manually, so CLI still works. |
1809 | 1923 | $smcFunc['db_insert']('', |
@@ -1822,8 +1936,9 @@ discard block |
||
1822 | 1936 | |
1823 | 1937 | // Save the current database version. |
1824 | 1938 | $server_version = $smcFunc['db_server_info'](); |
1825 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1826 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1939 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1940 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1941 | + } |
|
1827 | 1942 | |
1828 | 1943 | if ($command_line) |
1829 | 1944 | { |
@@ -1835,8 +1950,9 @@ discard block |
||
1835 | 1950 | |
1836 | 1951 | // Make sure it says we're done. |
1837 | 1952 | $upcontext['overall_percent'] = 100; |
1838 | - if (isset($upcontext['step_progress'])) |
|
1839 | - unset($upcontext['step_progress']); |
|
1953 | + if (isset($upcontext['step_progress'])) { |
|
1954 | + unset($upcontext['step_progress']); |
|
1955 | + } |
|
1840 | 1956 | |
1841 | 1957 | $_GET['substep'] = 0; |
1842 | 1958 | return false; |
@@ -1847,8 +1963,9 @@ discard block |
||
1847 | 1963 | { |
1848 | 1964 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
1849 | 1965 | |
1850 | - if (empty($modSettings['time_format'])) |
|
1851 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1966 | + if (empty($modSettings['time_format'])) { |
|
1967 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1968 | + } |
|
1852 | 1969 | |
1853 | 1970 | // What files do we want to get |
1854 | 1971 | $request = $smcFunc['db_query']('', ' |
@@ -1882,8 +1999,9 @@ discard block |
||
1882 | 1999 | $file_data = fetch_web_data($url); |
1883 | 2000 | |
1884 | 2001 | // If we got an error - give up - the site might be down. |
1885 | - if ($file_data === false) |
|
1886 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
2002 | + if ($file_data === false) { |
|
2003 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
2004 | + } |
|
1887 | 2005 | |
1888 | 2006 | // Save the file to the database. |
1889 | 2007 | $smcFunc['db_query']('substring', ' |
@@ -1925,8 +2043,9 @@ discard block |
||
1925 | 2043 | $themeData = array(); |
1926 | 2044 | foreach ($values as $variable => $value) |
1927 | 2045 | { |
1928 | - if (!isset($value) || $value === null) |
|
1929 | - $value = 0; |
|
2046 | + if (!isset($value) || $value === null) { |
|
2047 | + $value = 0; |
|
2048 | + } |
|
1930 | 2049 | |
1931 | 2050 | $themeData[] = array(0, 1, $variable, $value); |
1932 | 2051 | } |
@@ -1955,8 +2074,9 @@ discard block |
||
1955 | 2074 | |
1956 | 2075 | foreach ($values as $variable => $value) |
1957 | 2076 | { |
1958 | - if (empty($modSettings[$value[0]])) |
|
1959 | - continue; |
|
2077 | + if (empty($modSettings[$value[0]])) { |
|
2078 | + continue; |
|
2079 | + } |
|
1960 | 2080 | |
1961 | 2081 | $smcFunc['db_query']('', ' |
1962 | 2082 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1989,8 +2109,9 @@ discard block |
||
1989 | 2109 | |
1990 | 2110 | $settingsArray = file($boarddir . '/Settings_bak.php'); |
1991 | 2111 | |
1992 | - if (count($settingsArray) == 1) |
|
1993 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
2112 | + if (count($settingsArray) == 1) { |
|
2113 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
2114 | + } |
|
1994 | 2115 | |
1995 | 2116 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1996 | 2117 | { |
@@ -2003,9 +2124,9 @@ discard block |
||
2003 | 2124 | { |
2004 | 2125 | if (isset($settingsArray[$i]) && strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
2005 | 2126 | { |
2006 | - if ($val == '#remove#') |
|
2007 | - unset($settingsArray[$i]); |
|
2008 | - else |
|
2127 | + if ($val == '#remove#') { |
|
2128 | + unset($settingsArray[$i]); |
|
2129 | + } else |
|
2009 | 2130 | { |
2010 | 2131 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
2011 | 2132 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
@@ -2017,22 +2138,25 @@ discard block |
||
2017 | 2138 | } |
2018 | 2139 | if (isset($settingsArray[$i])) |
2019 | 2140 | { |
2020 | - if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') |
|
2021 | - $end = $i; |
|
2141 | + if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') { |
|
2142 | + $end = $i; |
|
2143 | + } |
|
2022 | 2144 | } |
2023 | 2145 | } |
2024 | 2146 | |
2025 | 2147 | // Assume end-of-file if the end wasn't found. |
2026 | - if (empty($end) || $end < 10) |
|
2027 | - $end = count($settingsArray); |
|
2148 | + if (empty($end) || $end < 10) { |
|
2149 | + $end = count($settingsArray); |
|
2150 | + } |
|
2028 | 2151 | |
2029 | 2152 | if (!empty($config_vars)) |
2030 | 2153 | { |
2031 | 2154 | $settingsArray[$end++] = ''; |
2032 | 2155 | foreach ($config_vars as $var => $val) |
2033 | 2156 | { |
2034 | - if ($val != '#remove#') |
|
2035 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
2157 | + if ($val != '#remove#') { |
|
2158 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
2159 | + } |
|
2036 | 2160 | } |
2037 | 2161 | } |
2038 | 2162 | // This should be the last line and even last bytes of the file. |
@@ -2045,8 +2169,9 @@ discard block |
||
2045 | 2169 | $fp = fopen($boarddir . '/Settings.php', 'r+'); |
2046 | 2170 | for ($i = 0; $i < $end; $i++) |
2047 | 2171 | { |
2048 | - if (isset($settingsArray[$i])) |
|
2049 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
2172 | + if (isset($settingsArray[$i])) { |
|
2173 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
2174 | + } |
|
2050 | 2175 | } |
2051 | 2176 | fwrite($fp, rtrim($settingsArray[$i])); |
2052 | 2177 | fclose($fp); |
@@ -2077,8 +2202,9 @@ discard block |
||
2077 | 2202 | global $smcFunc; |
2078 | 2203 | static $member_groups = array(); |
2079 | 2204 | |
2080 | - if (!empty($member_groups)) |
|
2081 | - return $member_groups; |
|
2205 | + if (!empty($member_groups)) { |
|
2206 | + return $member_groups; |
|
2207 | + } |
|
2082 | 2208 | |
2083 | 2209 | $request = $smcFunc['db_query']('', ' |
2084 | 2210 | SELECT group_name, id_group |
@@ -2103,8 +2229,9 @@ discard block |
||
2103 | 2229 | ) |
2104 | 2230 | ); |
2105 | 2231 | } |
2106 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
2107 | - $member_groups[trim($row[0])] = $row[1]; |
|
2232 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
2233 | + $member_groups[trim($row[0])] = $row[1]; |
|
2234 | + } |
|
2108 | 2235 | $smcFunc['db_free_result']($request); |
2109 | 2236 | |
2110 | 2237 | return $member_groups; |
@@ -2157,10 +2284,11 @@ discard block |
||
2157 | 2284 | { |
2158 | 2285 | global $support_js; |
2159 | 2286 | |
2160 | - if ($support_js) |
|
2161 | - return true; |
|
2162 | - else |
|
2163 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
2287 | + if ($support_js) { |
|
2288 | + return true; |
|
2289 | + } else { |
|
2290 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
2291 | + } |
|
2164 | 2292 | } |
2165 | 2293 | } |
2166 | 2294 | |
@@ -2178,8 +2306,9 @@ discard block |
||
2178 | 2306 | 'db_error_skip' => true, |
2179 | 2307 | ) |
2180 | 2308 | ); |
2181 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2182 | - die('Unable to find members table!'); |
|
2309 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2310 | + die('Unable to find members table!'); |
|
2311 | + } |
|
2183 | 2312 | $table_status = $smcFunc['db_fetch_assoc']($request); |
2184 | 2313 | $smcFunc['db_free_result']($request); |
2185 | 2314 | |
@@ -2194,17 +2323,20 @@ discard block |
||
2194 | 2323 | ) |
2195 | 2324 | ); |
2196 | 2325 | // Got something? |
2197 | - if ($smcFunc['db_num_rows']($request) !== 0) |
|
2198 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2326 | + if ($smcFunc['db_num_rows']($request) !== 0) { |
|
2327 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2328 | + } |
|
2199 | 2329 | $smcFunc['db_free_result']($request); |
2200 | 2330 | |
2201 | 2331 | // Excellent! |
2202 | - if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) |
|
2203 | - $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
2332 | + if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) { |
|
2333 | + $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
2334 | + } |
|
2204 | 2335 | } |
2205 | 2336 | } |
2206 | - if (empty($db_collation)) |
|
2207 | - $db_collation = ''; |
|
2337 | + if (empty($db_collation)) { |
|
2338 | + $db_collation = ''; |
|
2339 | + } |
|
2208 | 2340 | |
2209 | 2341 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
2210 | 2342 | |
@@ -2216,8 +2348,9 @@ discard block |
||
2216 | 2348 | $last_step = ''; |
2217 | 2349 | |
2218 | 2350 | // Make sure all newly created tables will have the proper characters set. |
2219 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
2220 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
2351 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
2352 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
2353 | + } |
|
2221 | 2354 | |
2222 | 2355 | // Count the total number of steps within this file - for progress. |
2223 | 2356 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -2237,15 +2370,18 @@ discard block |
||
2237 | 2370 | $do_current = $substep >= $_GET['substep']; |
2238 | 2371 | |
2239 | 2372 | // Get rid of any comments in the beginning of the line... |
2240 | - if (substr(trim($line), 0, 2) === '/*') |
|
2241 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
2373 | + if (substr(trim($line), 0, 2) === '/*') { |
|
2374 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
2375 | + } |
|
2242 | 2376 | |
2243 | 2377 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
2244 | - if ($is_debug && !$support_js && $command_line) |
|
2245 | - flush(); |
|
2378 | + if ($is_debug && !$support_js && $command_line) { |
|
2379 | + flush(); |
|
2380 | + } |
|
2246 | 2381 | |
2247 | - if (trim($line) === '') |
|
2248 | - continue; |
|
2382 | + if (trim($line) === '') { |
|
2383 | + continue; |
|
2384 | + } |
|
2249 | 2385 | |
2250 | 2386 | if (trim(substr($line, 0, 3)) === '---') |
2251 | 2387 | { |
@@ -2255,8 +2391,9 @@ discard block |
||
2255 | 2391 | if (trim($current_data) != '' && $type !== '}') |
2256 | 2392 | { |
2257 | 2393 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
2258 | - if ($command_line) |
|
2259 | - echo $upcontext['error_message']; |
|
2394 | + if ($command_line) { |
|
2395 | + echo $upcontext['error_message']; |
|
2396 | + } |
|
2260 | 2397 | } |
2261 | 2398 | |
2262 | 2399 | if ($type == ' ') |
@@ -2274,17 +2411,18 @@ discard block |
||
2274 | 2411 | if ($do_current) |
2275 | 2412 | { |
2276 | 2413 | $upcontext['actioned_items'][] = $last_step; |
2277 | - if ($command_line) |
|
2278 | - echo ' * '; |
|
2414 | + if ($command_line) { |
|
2415 | + echo ' * '; |
|
2416 | + } |
|
2279 | 2417 | } |
2280 | - } |
|
2281 | - elseif ($type == '#') |
|
2418 | + } elseif ($type == '#') |
|
2282 | 2419 | { |
2283 | 2420 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
2284 | 2421 | |
2285 | 2422 | $upcontext['current_debug_item_num']++; |
2286 | - if (trim($line) != '---#') |
|
2287 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
2423 | + if (trim($line) != '---#') { |
|
2424 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
2425 | + } |
|
2288 | 2426 | |
2289 | 2427 | // Have we already done something? |
2290 | 2428 | if (isset($_GET['xml']) && $done_something) |
@@ -2295,34 +2433,36 @@ discard block |
||
2295 | 2433 | |
2296 | 2434 | if ($do_current) |
2297 | 2435 | { |
2298 | - if (trim($line) == '---#' && $command_line) |
|
2299 | - echo ' done.', $endl; |
|
2300 | - elseif ($command_line) |
|
2301 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
2302 | - elseif (trim($line) != '---#') |
|
2436 | + if (trim($line) == '---#' && $command_line) { |
|
2437 | + echo ' done.', $endl; |
|
2438 | + } elseif ($command_line) { |
|
2439 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
2440 | + } elseif (trim($line) != '---#') |
|
2303 | 2441 | { |
2304 | - if ($is_debug) |
|
2305 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
2442 | + if ($is_debug) { |
|
2443 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
2444 | + } |
|
2306 | 2445 | } |
2307 | 2446 | } |
2308 | 2447 | |
2309 | 2448 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
2310 | 2449 | { |
2311 | - if ($command_line) |
|
2312 | - echo ' * '; |
|
2313 | - else |
|
2314 | - $upcontext['actioned_items'][] = $last_step; |
|
2450 | + if ($command_line) { |
|
2451 | + echo ' * '; |
|
2452 | + } else { |
|
2453 | + $upcontext['actioned_items'][] = $last_step; |
|
2454 | + } |
|
2315 | 2455 | } |
2316 | 2456 | |
2317 | 2457 | // Small step - only if we're actually doing stuff. |
2318 | - if ($do_current) |
|
2319 | - nextSubstep(++$substep); |
|
2320 | - else |
|
2321 | - $substep++; |
|
2322 | - } |
|
2323 | - elseif ($type == '{') |
|
2324 | - $current_type = 'code'; |
|
2325 | - elseif ($type == '}') |
|
2458 | + if ($do_current) { |
|
2459 | + nextSubstep(++$substep); |
|
2460 | + } else { |
|
2461 | + $substep++; |
|
2462 | + } |
|
2463 | + } elseif ($type == '{') { |
|
2464 | + $current_type = 'code'; |
|
2465 | + } elseif ($type == '}') |
|
2326 | 2466 | { |
2327 | 2467 | $current_type = 'sql'; |
2328 | 2468 | |
@@ -2335,8 +2475,9 @@ discard block |
||
2335 | 2475 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
2336 | 2476 | { |
2337 | 2477 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
2338 | - if ($command_line) |
|
2339 | - echo $upcontext['error_message']; |
|
2478 | + if ($command_line) { |
|
2479 | + echo $upcontext['error_message']; |
|
2480 | + } |
|
2340 | 2481 | } |
2341 | 2482 | |
2342 | 2483 | // Done with code! |
@@ -2416,8 +2557,9 @@ discard block |
||
2416 | 2557 | $db_unbuffered = false; |
2417 | 2558 | |
2418 | 2559 | // Failure?! |
2419 | - if ($result !== false) |
|
2420 | - return $result; |
|
2560 | + if ($result !== false) { |
|
2561 | + return $result; |
|
2562 | + } |
|
2421 | 2563 | |
2422 | 2564 | $db_error_message = $smcFunc['db_error']($db_connection); |
2423 | 2565 | // If MySQL we do something more clever. |
@@ -2445,54 +2587,61 @@ discard block |
||
2445 | 2587 | { |
2446 | 2588 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
2447 | 2589 | $result = mysqli_query($db_connection, $string); |
2448 | - if ($result !== false) |
|
2449 | - return $result; |
|
2590 | + if ($result !== false) { |
|
2591 | + return $result; |
|
2592 | + } |
|
2450 | 2593 | } |
2451 | - } |
|
2452 | - elseif ($mysqli_errno == 2013) |
|
2594 | + } elseif ($mysqli_errno == 2013) |
|
2453 | 2595 | { |
2454 | 2596 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
2455 | 2597 | mysqli_select_db($db_connection, $db_name); |
2456 | 2598 | if ($db_connection) |
2457 | 2599 | { |
2458 | 2600 | $result = mysqli_query($db_connection, $string); |
2459 | - if ($result !== false) |
|
2460 | - return $result; |
|
2601 | + if ($result !== false) { |
|
2602 | + return $result; |
|
2603 | + } |
|
2461 | 2604 | } |
2462 | 2605 | } |
2463 | 2606 | // Duplicate column name... should be okay ;). |
2464 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
2465 | - return false; |
|
2607 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
2608 | + return false; |
|
2609 | + } |
|
2466 | 2610 | // Duplicate insert... make sure it's the proper type of query ;). |
2467 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
2468 | - return false; |
|
2611 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
2612 | + return false; |
|
2613 | + } |
|
2469 | 2614 | // Creating an index on a non-existent column. |
2470 | - elseif ($mysqli_errno == 1072) |
|
2471 | - return false; |
|
2472 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
2473 | - return false; |
|
2615 | + elseif ($mysqli_errno == 1072) { |
|
2616 | + return false; |
|
2617 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
2618 | + return false; |
|
2619 | + } |
|
2474 | 2620 | } |
2475 | 2621 | // If a table already exists don't go potty. |
2476 | 2622 | else |
2477 | 2623 | { |
2478 | 2624 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
2479 | 2625 | { |
2480 | - if (strpos($db_error_message, 'exist') !== false) |
|
2481 | - return true; |
|
2482 | - } |
|
2483 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2626 | + if (strpos($db_error_message, 'exist') !== false) { |
|
2627 | + return true; |
|
2628 | + } |
|
2629 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2484 | 2630 | { |
2485 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
2486 | - return true; |
|
2631 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
2632 | + return true; |
|
2633 | + } |
|
2487 | 2634 | } |
2488 | 2635 | } |
2489 | 2636 | |
2490 | 2637 | // Get the query string so we pass everything. |
2491 | 2638 | $query_string = ''; |
2492 | - foreach ($_GET as $k => $v) |
|
2493 | - $query_string .= ';' . $k . '=' . $v; |
|
2494 | - if (strlen($query_string) != 0) |
|
2495 | - $query_string = '?' . substr($query_string, 1); |
|
2639 | + foreach ($_GET as $k => $v) { |
|
2640 | + $query_string .= ';' . $k . '=' . $v; |
|
2641 | + } |
|
2642 | + if (strlen($query_string) != 0) { |
|
2643 | + $query_string = '?' . substr($query_string, 1); |
|
2644 | + } |
|
2496 | 2645 | |
2497 | 2646 | if ($command_line) |
2498 | 2647 | { |
@@ -2578,16 +2727,18 @@ discard block |
||
2578 | 2727 | { |
2579 | 2728 | $found |= 1; |
2580 | 2729 | // Do some checks on the data if we have it set. |
2581 | - if (isset($change['col_type'])) |
|
2582 | - $found &= $change['col_type'] === $column['type']; |
|
2583 | - if (isset($change['null_allowed'])) |
|
2584 | - $found &= $column['null'] == $change['null_allowed']; |
|
2585 | - if (isset($change['default'])) |
|
2586 | - $found &= $change['default'] === $column['default']; |
|
2730 | + if (isset($change['col_type'])) { |
|
2731 | + $found &= $change['col_type'] === $column['type']; |
|
2732 | + } |
|
2733 | + if (isset($change['null_allowed'])) { |
|
2734 | + $found &= $column['null'] == $change['null_allowed']; |
|
2735 | + } |
|
2736 | + if (isset($change['default'])) { |
|
2737 | + $found &= $change['default'] === $column['default']; |
|
2738 | + } |
|
2587 | 2739 | } |
2588 | 2740 | } |
2589 | - } |
|
2590 | - elseif ($change['type'] === 'index') |
|
2741 | + } elseif ($change['type'] === 'index') |
|
2591 | 2742 | { |
2592 | 2743 | $request = upgrade_query(' |
2593 | 2744 | SHOW INDEX |
@@ -2596,9 +2747,10 @@ discard block |
||
2596 | 2747 | { |
2597 | 2748 | $cur_index = array(); |
2598 | 2749 | |
2599 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2600 | - if ($row['Key_name'] === $change['name']) |
|
2750 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2751 | + if ($row['Key_name'] === $change['name']) |
|
2601 | 2752 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2753 | + } |
|
2602 | 2754 | |
2603 | 2755 | ksort($cur_index, SORT_NUMERIC); |
2604 | 2756 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2608,14 +2760,17 @@ discard block |
||
2608 | 2760 | } |
2609 | 2761 | |
2610 | 2762 | // If we're trying to add and it's added, we're done. |
2611 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
2612 | - return true; |
|
2763 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
2764 | + return true; |
|
2765 | + } |
|
2613 | 2766 | // Otherwise if we're removing and it wasn't found we're also done. |
2614 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
2615 | - return true; |
|
2767 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
2768 | + return true; |
|
2769 | + } |
|
2616 | 2770 | // Otherwise is it just a test? |
2617 | - elseif ($is_test) |
|
2618 | - return false; |
|
2771 | + elseif ($is_test) { |
|
2772 | + return false; |
|
2773 | + } |
|
2619 | 2774 | |
2620 | 2775 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
2621 | 2776 | $running = false; |
@@ -2626,8 +2781,9 @@ discard block |
||
2626 | 2781 | SHOW FULL PROCESSLIST'); |
2627 | 2782 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2628 | 2783 | { |
2629 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
2630 | - $found = true; |
|
2784 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
2785 | + $found = true; |
|
2786 | + } |
|
2631 | 2787 | } |
2632 | 2788 | |
2633 | 2789 | // Can't find it? Then we need to run it fools! |
@@ -2639,8 +2795,9 @@ discard block |
||
2639 | 2795 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
2640 | 2796 | ' . $change['text'], true) !== false; |
2641 | 2797 | |
2642 | - if (!$success) |
|
2643 | - return false; |
|
2798 | + if (!$success) { |
|
2799 | + return false; |
|
2800 | + } |
|
2644 | 2801 | |
2645 | 2802 | // Return |
2646 | 2803 | $running = true; |
@@ -2673,8 +2830,7 @@ discard block |
||
2673 | 2830 | { |
2674 | 2831 | $column_fix = true; |
2675 | 2832 | $null_fix = !$change['null_allowed']; |
2676 | - } |
|
2677 | - else |
|
2833 | + } else |
|
2678 | 2834 | { |
2679 | 2835 | $request = $smcFunc['db_query']('', ' |
2680 | 2836 | SHOW FULL COLUMNS |
@@ -2685,8 +2841,9 @@ discard block |
||
2685 | 2841 | 'db_error_skip' => true, |
2686 | 2842 | ) |
2687 | 2843 | ); |
2688 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2689 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2844 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2845 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2846 | + } |
|
2690 | 2847 | $table_row = $smcFunc['db_fetch_assoc']($request); |
2691 | 2848 | $smcFunc['db_free_result']($request); |
2692 | 2849 | |
@@ -2708,10 +2865,11 @@ discard block |
||
2708 | 2865 | ) |
2709 | 2866 | ); |
2710 | 2867 | // No results? Just forget it all together. |
2711 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2712 | - unset($table_row['Collation']); |
|
2713 | - else |
|
2714 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2868 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2869 | + unset($table_row['Collation']); |
|
2870 | + } else { |
|
2871 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2872 | + } |
|
2715 | 2873 | $smcFunc['db_free_result']($request); |
2716 | 2874 | } |
2717 | 2875 | } |
@@ -2719,8 +2877,8 @@ discard block |
||
2719 | 2877 | if ($column_fix) |
2720 | 2878 | { |
2721 | 2879 | // Make sure there are no NULL's left. |
2722 | - if ($null_fix) |
|
2723 | - $smcFunc['db_query']('', ' |
|
2880 | + if ($null_fix) { |
|
2881 | + $smcFunc['db_query']('', ' |
|
2724 | 2882 | UPDATE {db_prefix}' . $change['table'] . ' |
2725 | 2883 | SET ' . $change['column'] . ' = {string:default} |
2726 | 2884 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2729,6 +2887,7 @@ discard block |
||
2729 | 2887 | 'db_error_skip' => true, |
2730 | 2888 | ) |
2731 | 2889 | ); |
2890 | + } |
|
2732 | 2891 | |
2733 | 2892 | // Do the actual alteration. |
2734 | 2893 | $smcFunc['db_query']('', ' |
@@ -2757,8 +2916,9 @@ discard block |
||
2757 | 2916 | } |
2758 | 2917 | |
2759 | 2918 | // Not a column we need to check on? |
2760 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
2761 | - return; |
|
2919 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
2920 | + return; |
|
2921 | + } |
|
2762 | 2922 | |
2763 | 2923 | // Break it up you (six|seven). |
2764 | 2924 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2777,13 +2937,13 @@ discard block |
||
2777 | 2937 | 'new_name' => $temp[2], |
2778 | 2938 | )); |
2779 | 2939 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2780 | - if ($smcFunc['db_num_rows'] != 1) |
|
2781 | - return; |
|
2940 | + if ($smcFunc['db_num_rows'] != 1) { |
|
2941 | + return; |
|
2942 | + } |
|
2782 | 2943 | |
2783 | 2944 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
2784 | 2945 | $smcFunc['db_free_result']($request); |
2785 | - } |
|
2786 | - else |
|
2946 | + } else |
|
2787 | 2947 | { |
2788 | 2948 | // Do this the old fashion, sure method way. |
2789 | 2949 | $request = $smcFunc['db_query']('', ' |
@@ -2794,21 +2954,24 @@ discard block |
||
2794 | 2954 | )); |
2795 | 2955 | // Mayday! |
2796 | 2956 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2797 | - if ($smcFunc['db_num_rows'] == 0) |
|
2798 | - return; |
|
2957 | + if ($smcFunc['db_num_rows'] == 0) { |
|
2958 | + return; |
|
2959 | + } |
|
2799 | 2960 | |
2800 | 2961 | // Oh where, oh where has my little field gone. Oh where can it be... |
2801 | - while ($row = $smcFunc['db_query']($request)) |
|
2802 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2962 | + while ($row = $smcFunc['db_query']($request)) { |
|
2963 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2803 | 2964 | { |
2804 | 2965 | $current_type = $row['Type']; |
2966 | + } |
|
2805 | 2967 | break; |
2806 | 2968 | } |
2807 | 2969 | } |
2808 | 2970 | |
2809 | 2971 | // If this doesn't match, the column may of been altered for a reason. |
2810 | - if (trim($current_type) != trim($temp[3])) |
|
2811 | - $temp[3] = $current_type; |
|
2972 | + if (trim($current_type) != trim($temp[3])) { |
|
2973 | + $temp[3] = $current_type; |
|
2974 | + } |
|
2812 | 2975 | |
2813 | 2976 | // Piece this back together. |
2814 | 2977 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2820,8 +2983,9 @@ discard block |
||
2820 | 2983 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2821 | 2984 | global $step_progress, $is_debug, $upcontext; |
2822 | 2985 | |
2823 | - if ($_GET['substep'] < $substep) |
|
2824 | - $_GET['substep'] = $substep; |
|
2986 | + if ($_GET['substep'] < $substep) { |
|
2987 | + $_GET['substep'] = $substep; |
|
2988 | + } |
|
2825 | 2989 | |
2826 | 2990 | if ($command_line) |
2827 | 2991 | { |
@@ -2834,29 +2998,33 @@ discard block |
||
2834 | 2998 | } |
2835 | 2999 | |
2836 | 3000 | @set_time_limit(300); |
2837 | - if (function_exists('apache_reset_timeout')) |
|
2838 | - @apache_reset_timeout(); |
|
3001 | + if (function_exists('apache_reset_timeout')) { |
|
3002 | + @apache_reset_timeout(); |
|
3003 | + } |
|
2839 | 3004 | |
2840 | - if (time() - $start_time <= $timeLimitThreshold) |
|
2841 | - return; |
|
3005 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
3006 | + return; |
|
3007 | + } |
|
2842 | 3008 | |
2843 | 3009 | // Do we have some custom step progress stuff? |
2844 | 3010 | if (!empty($step_progress)) |
2845 | 3011 | { |
2846 | 3012 | $upcontext['substep_progress'] = 0; |
2847 | 3013 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2848 | - if ($step_progress['current'] > $step_progress['total']) |
|
2849 | - $upcontext['substep_progress'] = 99.9; |
|
2850 | - else |
|
2851 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
3014 | + if ($step_progress['current'] > $step_progress['total']) { |
|
3015 | + $upcontext['substep_progress'] = 99.9; |
|
3016 | + } else { |
|
3017 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
3018 | + } |
|
2852 | 3019 | |
2853 | 3020 | // Make it nicely rounded. |
2854 | 3021 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
2855 | 3022 | } |
2856 | 3023 | |
2857 | 3024 | // If this is XML we just exit right away! |
2858 | - if (isset($_GET['xml'])) |
|
2859 | - return upgradeExit(); |
|
3025 | + if (isset($_GET['xml'])) { |
|
3026 | + return upgradeExit(); |
|
3027 | + } |
|
2860 | 3028 | |
2861 | 3029 | // We're going to pause after this! |
2862 | 3030 | $upcontext['pause'] = true; |
@@ -2864,13 +3032,15 @@ discard block |
||
2864 | 3032 | $upcontext['query_string'] = ''; |
2865 | 3033 | foreach ($_GET as $k => $v) |
2866 | 3034 | { |
2867 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
2868 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
3035 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
3036 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
3037 | + } |
|
2869 | 3038 | } |
2870 | 3039 | |
2871 | 3040 | // Custom warning? |
2872 | - if (!empty($custom_warning)) |
|
2873 | - $upcontext['custom_warning'] = $custom_warning; |
|
3041 | + if (!empty($custom_warning)) { |
|
3042 | + $upcontext['custom_warning'] = $custom_warning; |
|
3043 | + } |
|
2874 | 3044 | |
2875 | 3045 | upgradeExit(); |
2876 | 3046 | } |
@@ -2885,25 +3055,26 @@ discard block |
||
2885 | 3055 | ob_implicit_flush(true); |
2886 | 3056 | @set_time_limit(600); |
2887 | 3057 | |
2888 | - if (!isset($_SERVER['argv'])) |
|
2889 | - $_SERVER['argv'] = array(); |
|
3058 | + if (!isset($_SERVER['argv'])) { |
|
3059 | + $_SERVER['argv'] = array(); |
|
3060 | + } |
|
2890 | 3061 | $_GET['maint'] = 1; |
2891 | 3062 | |
2892 | 3063 | foreach ($_SERVER['argv'] as $i => $arg) |
2893 | 3064 | { |
2894 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
2895 | - $_GET['lang'] = $match[1]; |
|
2896 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
2897 | - continue; |
|
2898 | - elseif ($arg == '--no-maintenance') |
|
2899 | - $_GET['maint'] = 0; |
|
2900 | - elseif ($arg == '--debug') |
|
2901 | - $is_debug = true; |
|
2902 | - elseif ($arg == '--backup') |
|
2903 | - $_POST['backup'] = 1; |
|
2904 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
2905 | - $_GET['conv'] = 1; |
|
2906 | - elseif ($i != 0) |
|
3065 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
3066 | + $_GET['lang'] = $match[1]; |
|
3067 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
3068 | + continue; |
|
3069 | + } elseif ($arg == '--no-maintenance') { |
|
3070 | + $_GET['maint'] = 0; |
|
3071 | + } elseif ($arg == '--debug') { |
|
3072 | + $is_debug = true; |
|
3073 | + } elseif ($arg == '--backup') { |
|
3074 | + $_POST['backup'] = 1; |
|
3075 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
3076 | + $_GET['conv'] = 1; |
|
3077 | + } elseif ($i != 0) |
|
2907 | 3078 | { |
2908 | 3079 | echo 'SMF Command-line Upgrader |
2909 | 3080 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2917,10 +3088,12 @@ discard block |
||
2917 | 3088 | } |
2918 | 3089 | } |
2919 | 3090 | |
2920 | - if (!php_version_check()) |
|
2921 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2922 | - if (!db_version_check()) |
|
2923 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
3091 | + if (!php_version_check()) { |
|
3092 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
3093 | + } |
|
3094 | + if (!db_version_check()) { |
|
3095 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
3096 | + } |
|
2924 | 3097 | |
2925 | 3098 | // Do some checks to make sure they have proper privileges |
2926 | 3099 | db_extend('packages'); |
@@ -2935,34 +3108,39 @@ discard block |
||
2935 | 3108 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
2936 | 3109 | |
2937 | 3110 | // Sorry... we need CREATE, ALTER and DROP |
2938 | - if (!$create || !$alter || !$drop) |
|
2939 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
3111 | + if (!$create || !$alter || !$drop) { |
|
3112 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
3113 | + } |
|
2940 | 3114 | |
2941 | 3115 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
2942 | 3116 | && @file_exists($sourcedir . '/QueryString.php') |
2943 | 3117 | && @file_exists($sourcedir . '/ManageBoards.php'); |
2944 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
2945 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
3118 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
3119 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
3120 | + } |
|
2946 | 3121 | |
2947 | 3122 | // Do a quick version spot check. |
2948 | 3123 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
2949 | 3124 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2950 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
2951 | - print_error('Error: Some files have not yet been updated properly.'); |
|
3125 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
3126 | + print_error('Error: Some files have not yet been updated properly.'); |
|
3127 | + } |
|
2952 | 3128 | |
2953 | 3129 | // Make sure Settings.php is writable. |
2954 | 3130 | quickFileWritable($boarddir . '/Settings.php'); |
2955 | - if (!is_writable($boarddir . '/Settings.php')) |
|
2956 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
3131 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
3132 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
3133 | + } |
|
2957 | 3134 | |
2958 | 3135 | // Make sure Settings_bak.php is writable. |
2959 | 3136 | quickFileWritable($boarddir . '/Settings_bak.php'); |
2960 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
2961 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
3137 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
3138 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
3139 | + } |
|
2962 | 3140 | |
2963 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
2964 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2965 | - elseif (isset($modSettings['agreement'])) |
|
3141 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
3142 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
3143 | + } elseif (isset($modSettings['agreement'])) |
|
2966 | 3144 | { |
2967 | 3145 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
2968 | 3146 | fwrite($fp, $modSettings['agreement']); |
@@ -2972,31 +3150,36 @@ discard block |
||
2972 | 3150 | // Make sure Themes is writable. |
2973 | 3151 | quickFileWritable($modSettings['theme_dir']); |
2974 | 3152 | |
2975 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
2976 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
3153 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
3154 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
3155 | + } |
|
2977 | 3156 | |
2978 | 3157 | // Make sure cache directory exists and is writable! |
2979 | 3158 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
2980 | - if (!file_exists($cachedir_temp)) |
|
2981 | - @mkdir($cachedir_temp); |
|
3159 | + if (!file_exists($cachedir_temp)) { |
|
3160 | + @mkdir($cachedir_temp); |
|
3161 | + } |
|
2982 | 3162 | |
2983 | 3163 | // Make sure the cache temp dir is writable. |
2984 | 3164 | quickFileWritable($cachedir_temp); |
2985 | 3165 | |
2986 | - if (!is_writable($cachedir_temp)) |
|
2987 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
3166 | + if (!is_writable($cachedir_temp)) { |
|
3167 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
3168 | + } |
|
2988 | 3169 | |
2989 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
2990 | - print_error('Error: Unable to find language files!', true); |
|
2991 | - else |
|
3170 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
3171 | + print_error('Error: Unable to find language files!', true); |
|
3172 | + } else |
|
2992 | 3173 | { |
2993 | 3174 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
2994 | 3175 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
2995 | 3176 | |
2996 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
2997 | - print_error('Error: Language files out of date.', true); |
|
2998 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
2999 | - print_error('Error: Install language is missing for selected language.', true); |
|
3177 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
3178 | + print_error('Error: Language files out of date.', true); |
|
3179 | + } |
|
3180 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
3181 | + print_error('Error: Install language is missing for selected language.', true); |
|
3182 | + } |
|
3000 | 3183 | |
3001 | 3184 | // Otherwise include it! |
3002 | 3185 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -3011,14 +3194,16 @@ discard block |
||
3011 | 3194 | { |
3012 | 3195 | static $fp = null; |
3013 | 3196 | |
3014 | - if ($fp === null) |
|
3015 | - $fp = fopen('php://stderr', 'wb'); |
|
3197 | + if ($fp === null) { |
|
3198 | + $fp = fopen('php://stderr', 'wb'); |
|
3199 | + } |
|
3016 | 3200 | |
3017 | 3201 | fwrite($fp, $message . "\n"); |
3018 | 3202 | |
3019 | - if ($fatal) |
|
3020 | - exit; |
|
3021 | -} |
|
3203 | + if ($fatal) { |
|
3204 | + exit; |
|
3205 | + } |
|
3206 | + } |
|
3022 | 3207 | |
3023 | 3208 | function throw_error($message) |
3024 | 3209 | { |
@@ -3035,8 +3220,9 @@ discard block |
||
3035 | 3220 | { |
3036 | 3221 | global $upcontext, $boarddir; |
3037 | 3222 | |
3038 | - if (empty($files)) |
|
3039 | - return true; |
|
3223 | + if (empty($files)) { |
|
3224 | + return true; |
|
3225 | + } |
|
3040 | 3226 | |
3041 | 3227 | $failure = false; |
3042 | 3228 | // On linux, it's easy - just use is_writable! |
@@ -3051,14 +3237,16 @@ discard block |
||
3051 | 3237 | @chmod($file, 0755); |
3052 | 3238 | |
3053 | 3239 | // Well, 755 hopefully worked... if not, try 777. |
3054 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
3055 | - $failure = true; |
|
3240 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
3241 | + $failure = true; |
|
3242 | + } |
|
3056 | 3243 | // Otherwise remove it as it's good! |
3057 | - else |
|
3058 | - unset($files[$k]); |
|
3244 | + else { |
|
3245 | + unset($files[$k]); |
|
3246 | + } |
|
3247 | + } else { |
|
3248 | + unset($files[$k]); |
|
3059 | 3249 | } |
3060 | - else |
|
3061 | - unset($files[$k]); |
|
3062 | 3250 | } |
3063 | 3251 | } |
3064 | 3252 | // Windows is trickier. Let's try opening for r+... |
@@ -3069,30 +3257,35 @@ discard block |
||
3069 | 3257 | foreach ($files as $k => $file) |
3070 | 3258 | { |
3071 | 3259 | // Folders can't be opened for write... but the index.php in them can ;). |
3072 | - if (is_dir($file)) |
|
3073 | - $file .= '/index.php'; |
|
3260 | + if (is_dir($file)) { |
|
3261 | + $file .= '/index.php'; |
|
3262 | + } |
|
3074 | 3263 | |
3075 | 3264 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
3076 | 3265 | @chmod($file, 0777); |
3077 | 3266 | $fp = @fopen($file, 'r+'); |
3078 | 3267 | |
3079 | 3268 | // Hmm, okay, try just for write in that case... |
3080 | - if (!$fp) |
|
3081 | - $fp = @fopen($file, 'w'); |
|
3269 | + if (!$fp) { |
|
3270 | + $fp = @fopen($file, 'w'); |
|
3271 | + } |
|
3082 | 3272 | |
3083 | - if (!$fp) |
|
3084 | - $failure = true; |
|
3085 | - else |
|
3086 | - unset($files[$k]); |
|
3273 | + if (!$fp) { |
|
3274 | + $failure = true; |
|
3275 | + } else { |
|
3276 | + unset($files[$k]); |
|
3277 | + } |
|
3087 | 3278 | @fclose($fp); |
3088 | 3279 | } |
3089 | 3280 | } |
3090 | 3281 | |
3091 | - if (empty($files)) |
|
3092 | - return true; |
|
3282 | + if (empty($files)) { |
|
3283 | + return true; |
|
3284 | + } |
|
3093 | 3285 | |
3094 | - if (!isset($_SERVER)) |
|
3095 | - return !$failure; |
|
3286 | + if (!isset($_SERVER)) { |
|
3287 | + return !$failure; |
|
3288 | + } |
|
3096 | 3289 | |
3097 | 3290 | // What still needs to be done? |
3098 | 3291 | $upcontext['chmod']['files'] = $files; |
@@ -3143,36 +3336,40 @@ discard block |
||
3143 | 3336 | |
3144 | 3337 | if (!isset($ftp) || $ftp->error !== false) |
3145 | 3338 | { |
3146 | - if (!isset($ftp)) |
|
3147 | - $ftp = new ftp_connection(null); |
|
3339 | + if (!isset($ftp)) { |
|
3340 | + $ftp = new ftp_connection(null); |
|
3341 | + } |
|
3148 | 3342 | // Save the error so we can mess with listing... |
3149 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
3150 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
3343 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
3344 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
3345 | + } |
|
3151 | 3346 | |
3152 | 3347 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
3153 | 3348 | |
3154 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
3155 | - $upcontext['chmod']['path'] = $detect_path; |
|
3349 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
3350 | + $upcontext['chmod']['path'] = $detect_path; |
|
3351 | + } |
|
3156 | 3352 | |
3157 | - if (!isset($upcontext['chmod']['username'])) |
|
3158 | - $upcontext['chmod']['username'] = $username; |
|
3353 | + if (!isset($upcontext['chmod']['username'])) { |
|
3354 | + $upcontext['chmod']['username'] = $username; |
|
3355 | + } |
|
3159 | 3356 | |
3160 | 3357 | // Don't forget the login token. |
3161 | 3358 | $upcontext += createToken('login'); |
3162 | 3359 | |
3163 | 3360 | return false; |
3164 | - } |
|
3165 | - else |
|
3361 | + } else |
|
3166 | 3362 | { |
3167 | 3363 | // We want to do a relative path for FTP. |
3168 | 3364 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
3169 | 3365 | { |
3170 | 3366 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
3171 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
3172 | - $ftp_root = substr($ftp_root, 0, -1); |
|
3367 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
3368 | + $ftp_root = substr($ftp_root, 0, -1); |
|
3369 | + } |
|
3370 | + } else { |
|
3371 | + $ftp_root = $boarddir; |
|
3173 | 3372 | } |
3174 | - else |
|
3175 | - $ftp_root = $boarddir; |
|
3176 | 3373 | |
3177 | 3374 | // Save the info for next time! |
3178 | 3375 | $_SESSION['installer_temp_ftp'] = array( |
@@ -3186,10 +3383,12 @@ discard block |
||
3186 | 3383 | |
3187 | 3384 | foreach ($files as $k => $file) |
3188 | 3385 | { |
3189 | - if (!is_writable($file)) |
|
3190 | - $ftp->chmod($file, 0755); |
|
3191 | - if (!is_writable($file)) |
|
3192 | - $ftp->chmod($file, 0777); |
|
3386 | + if (!is_writable($file)) { |
|
3387 | + $ftp->chmod($file, 0755); |
|
3388 | + } |
|
3389 | + if (!is_writable($file)) { |
|
3390 | + $ftp->chmod($file, 0777); |
|
3391 | + } |
|
3193 | 3392 | |
3194 | 3393 | // Assuming that didn't work calculate the path without the boarddir. |
3195 | 3394 | if (!is_writable($file)) |
@@ -3198,19 +3397,23 @@ discard block |
||
3198 | 3397 | { |
3199 | 3398 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
3200 | 3399 | $ftp->chmod($ftp_file, 0755); |
3201 | - if (!is_writable($file)) |
|
3202 | - $ftp->chmod($ftp_file, 0777); |
|
3400 | + if (!is_writable($file)) { |
|
3401 | + $ftp->chmod($ftp_file, 0777); |
|
3402 | + } |
|
3203 | 3403 | // Sometimes an extra slash can help... |
3204 | 3404 | $ftp_file = '/' . $ftp_file; |
3205 | - if (!is_writable($file)) |
|
3206 | - $ftp->chmod($ftp_file, 0755); |
|
3207 | - if (!is_writable($file)) |
|
3208 | - $ftp->chmod($ftp_file, 0777); |
|
3405 | + if (!is_writable($file)) { |
|
3406 | + $ftp->chmod($ftp_file, 0755); |
|
3407 | + } |
|
3408 | + if (!is_writable($file)) { |
|
3409 | + $ftp->chmod($ftp_file, 0777); |
|
3410 | + } |
|
3209 | 3411 | } |
3210 | 3412 | } |
3211 | 3413 | |
3212 | - if (is_writable($file)) |
|
3213 | - unset($files[$k]); |
|
3414 | + if (is_writable($file)) { |
|
3415 | + unset($files[$k]); |
|
3416 | + } |
|
3214 | 3417 | } |
3215 | 3418 | |
3216 | 3419 | $ftp->close(); |
@@ -3220,16 +3423,18 @@ discard block |
||
3220 | 3423 | // What remains? |
3221 | 3424 | $upcontext['chmod']['files'] = $files; |
3222 | 3425 | |
3223 | - if (empty($files)) |
|
3224 | - return true; |
|
3426 | + if (empty($files)) { |
|
3427 | + return true; |
|
3428 | + } |
|
3225 | 3429 | |
3226 | 3430 | return false; |
3227 | 3431 | } |
3228 | 3432 | |
3229 | 3433 | function quickFileWritable($file) |
3230 | 3434 | { |
3231 | - if (is_writable($file)) |
|
3232 | - return true; |
|
3435 | + if (is_writable($file)) { |
|
3436 | + return true; |
|
3437 | + } |
|
3233 | 3438 | |
3234 | 3439 | @chmod($file, 0755); |
3235 | 3440 | |
@@ -3239,17 +3444,19 @@ discard block |
||
3239 | 3444 | foreach ($chmod_values as $val) |
3240 | 3445 | { |
3241 | 3446 | // If it's writable, break out of the loop |
3242 | - if (is_writable($file)) |
|
3243 | - break; |
|
3244 | - else |
|
3245 | - @chmod($file, $val); |
|
3447 | + if (is_writable($file)) { |
|
3448 | + break; |
|
3449 | + } else { |
|
3450 | + @chmod($file, $val); |
|
3451 | + } |
|
3246 | 3452 | } |
3247 | 3453 | } |
3248 | 3454 | function smf_strtolower($string) |
3249 | 3455 | { |
3250 | 3456 | global $sourcedir; |
3251 | - if (function_exists('mb_strtolower')) |
|
3252 | - return mb_strtolower($string, 'UTF-8'); |
|
3457 | + if (function_exists('mb_strtolower')) { |
|
3458 | + return mb_strtolower($string, 'UTF-8'); |
|
3459 | + } |
|
3253 | 3460 | require_once($sourcedir . '/Subs-Charset.php'); |
3254 | 3461 | return utf8_strtolower($string); |
3255 | 3462 | } |
@@ -3272,8 +3479,7 @@ discard block |
||
3272 | 3479 | ); |
3273 | 3480 | |
3274 | 3481 | return true; |
3275 | - } |
|
3276 | - else |
|
3482 | + } else |
|
3277 | 3483 | { |
3278 | 3484 | $upcontext['page_title'] = 'Converting to UTF8'; |
3279 | 3485 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -3317,8 +3523,9 @@ discard block |
||
3317 | 3523 | ) |
3318 | 3524 | ); |
3319 | 3525 | $db_charsets = array(); |
3320 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3321 | - $db_charsets[] = $row['Charset']; |
|
3526 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3527 | + $db_charsets[] = $row['Charset']; |
|
3528 | + } |
|
3322 | 3529 | |
3323 | 3530 | $smcFunc['db_free_result']($request); |
3324 | 3531 | |
@@ -3354,13 +3561,15 @@ discard block |
||
3354 | 3561 | // If there's a fulltext index, we need to drop it first... |
3355 | 3562 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
3356 | 3563 | { |
3357 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3358 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
3564 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3565 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
3359 | 3566 | $upcontext['fulltext_index'][] = $row['Key_name']; |
3567 | + } |
|
3360 | 3568 | $smcFunc['db_free_result']($request); |
3361 | 3569 | |
3362 | - if (isset($upcontext['fulltext_index'])) |
|
3363 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
3570 | + if (isset($upcontext['fulltext_index'])) { |
|
3571 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
3572 | + } |
|
3364 | 3573 | } |
3365 | 3574 | |
3366 | 3575 | // Drop it and make a note... |
@@ -3552,8 +3761,9 @@ discard block |
||
3552 | 3761 | $replace = '%field%'; |
3553 | 3762 | |
3554 | 3763 | // Build a huge REPLACE statement... |
3555 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
3556 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
3764 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
3765 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
3766 | + } |
|
3557 | 3767 | } |
3558 | 3768 | |
3559 | 3769 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -3587,8 +3797,9 @@ discard block |
||
3587 | 3797 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
3588 | 3798 | |
3589 | 3799 | // Just to make sure it doesn't time out. |
3590 | - if (function_exists('apache_reset_timeout')) |
|
3591 | - @apache_reset_timeout(); |
|
3800 | + if (function_exists('apache_reset_timeout')) { |
|
3801 | + @apache_reset_timeout(); |
|
3802 | + } |
|
3592 | 3803 | |
3593 | 3804 | $table_charsets = array(); |
3594 | 3805 | |
@@ -3609,8 +3820,9 @@ discard block |
||
3609 | 3820 | { |
3610 | 3821 | list($charset) = explode('_', $collation); |
3611 | 3822 | |
3612 | - if (!isset($table_charsets[$charset])) |
|
3613 | - $table_charsets[$charset] = array(); |
|
3823 | + if (!isset($table_charsets[$charset])) { |
|
3824 | + $table_charsets[$charset] = array(); |
|
3825 | + } |
|
3614 | 3826 | |
3615 | 3827 | $table_charsets[$charset][] = $column_info; |
3616 | 3828 | } |
@@ -3650,10 +3862,11 @@ discard block |
||
3650 | 3862 | if (isset($translation_tables[$upcontext['charset_detected']])) |
3651 | 3863 | { |
3652 | 3864 | $update = ''; |
3653 | - foreach ($table_charsets as $charset => $columns) |
|
3654 | - foreach ($columns as $column) |
|
3865 | + foreach ($table_charsets as $charset => $columns) { |
|
3866 | + foreach ($columns as $column) |
|
3655 | 3867 | $update .= ' |
3656 | 3868 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
3869 | + } |
|
3657 | 3870 | |
3658 | 3871 | $smcFunc['db_query']('', ' |
3659 | 3872 | UPDATE {raw:table_name} |
@@ -3678,8 +3891,9 @@ discard block |
||
3678 | 3891 | // Now do the actual conversion (if still needed). |
3679 | 3892 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
3680 | 3893 | { |
3681 | - if ($command_line) |
|
3682 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3894 | + if ($command_line) { |
|
3895 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3896 | + } |
|
3683 | 3897 | |
3684 | 3898 | $smcFunc['db_query']('', ' |
3685 | 3899 | ALTER TABLE {raw:table_name} |
@@ -3689,8 +3903,9 @@ discard block |
||
3689 | 3903 | ) |
3690 | 3904 | ); |
3691 | 3905 | |
3692 | - if ($command_line) |
|
3693 | - echo " done.\n"; |
|
3906 | + if ($command_line) { |
|
3907 | + echo " done.\n"; |
|
3908 | + } |
|
3694 | 3909 | } |
3695 | 3910 | } |
3696 | 3911 | |
@@ -3720,8 +3935,8 @@ discard block |
||
3720 | 3935 | ); |
3721 | 3936 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3722 | 3937 | { |
3723 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
3724 | - $smcFunc['db_query']('', ' |
|
3938 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
3939 | + $smcFunc['db_query']('', ' |
|
3725 | 3940 | UPDATE {db_prefix}log_actions |
3726 | 3941 | SET extra = {string:extra} |
3727 | 3942 | WHERE id_action = {int:current_action}', |
@@ -3730,6 +3945,7 @@ discard block |
||
3730 | 3945 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
3731 | 3946 | ) |
3732 | 3947 | ); |
3948 | + } |
|
3733 | 3949 | } |
3734 | 3950 | $smcFunc['db_free_result']($request); |
3735 | 3951 | |
@@ -3751,15 +3967,17 @@ discard block |
||
3751 | 3967 | // First thing's first - did we already do this? |
3752 | 3968 | if (!empty($modSettings['json_done'])) |
3753 | 3969 | { |
3754 | - if ($command_line) |
|
3755 | - return DeleteUpgrade(); |
|
3756 | - else |
|
3757 | - return true; |
|
3970 | + if ($command_line) { |
|
3971 | + return DeleteUpgrade(); |
|
3972 | + } else { |
|
3973 | + return true; |
|
3974 | + } |
|
3758 | 3975 | } |
3759 | 3976 | |
3760 | 3977 | // Done it already - js wise? |
3761 | - if (!empty($_POST['json_done'])) |
|
3762 | - return true; |
|
3978 | + if (!empty($_POST['json_done'])) { |
|
3979 | + return true; |
|
3980 | + } |
|
3763 | 3981 | |
3764 | 3982 | // List of tables affected by this function |
3765 | 3983 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3791,12 +4009,14 @@ discard block |
||
3791 | 4009 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
3792 | 4010 | $file_steps = $upcontext['table_count']; |
3793 | 4011 | |
3794 | - foreach ($keys as $id => $table) |
|
3795 | - if ($id < $_GET['substep']) |
|
4012 | + foreach ($keys as $id => $table) { |
|
4013 | + if ($id < $_GET['substep']) |
|
3796 | 4014 | $upcontext['previous_tables'][] = $table; |
4015 | + } |
|
3797 | 4016 | |
3798 | - if ($command_line) |
|
3799 | - echo 'Converting data from serialize() to json_encode().'; |
|
4017 | + if ($command_line) { |
|
4018 | + echo 'Converting data from serialize() to json_encode().'; |
|
4019 | + } |
|
3800 | 4020 | |
3801 | 4021 | if (!$support_js || isset($_GET['xml'])) |
3802 | 4022 | { |
@@ -3836,8 +4056,9 @@ discard block |
||
3836 | 4056 | |
3837 | 4057 | // Loop through and fix these... |
3838 | 4058 | $new_settings = array(); |
3839 | - if ($command_line) |
|
3840 | - echo "\n" . 'Fixing some settings...'; |
|
4059 | + if ($command_line) { |
|
4060 | + echo "\n" . 'Fixing some settings...'; |
|
4061 | + } |
|
3841 | 4062 | |
3842 | 4063 | foreach ($serialized_settings as $var) |
3843 | 4064 | { |
@@ -3845,22 +4066,24 @@ discard block |
||
3845 | 4066 | { |
3846 | 4067 | // Attempt to unserialize the setting |
3847 | 4068 | $temp = @safe_unserialize($modSettings[$var]); |
3848 | - if (!$temp && $command_line) |
|
3849 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3850 | - elseif ($temp !== false) |
|
3851 | - $new_settings[$var] = json_encode($temp); |
|
4069 | + if (!$temp && $command_line) { |
|
4070 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
4071 | + } elseif ($temp !== false) { |
|
4072 | + $new_settings[$var] = json_encode($temp); |
|
4073 | + } |
|
3852 | 4074 | } |
3853 | 4075 | } |
3854 | 4076 | |
3855 | 4077 | // Update everything at once |
3856 | - if (!function_exists('cache_put_data')) |
|
3857 | - require_once($sourcedir . '/Load.php'); |
|
4078 | + if (!function_exists('cache_put_data')) { |
|
4079 | + require_once($sourcedir . '/Load.php'); |
|
4080 | + } |
|
3858 | 4081 | updateSettings($new_settings, true); |
3859 | 4082 | |
3860 | - if ($command_line) |
|
3861 | - echo ' done.'; |
|
3862 | - } |
|
3863 | - elseif ($table == 'themes') |
|
4083 | + if ($command_line) { |
|
4084 | + echo ' done.'; |
|
4085 | + } |
|
4086 | + } elseif ($table == 'themes') |
|
3864 | 4087 | { |
3865 | 4088 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3866 | 4089 | $query = $smcFunc['db_query']('', ' |
@@ -3879,10 +4102,11 @@ discard block |
||
3879 | 4102 | |
3880 | 4103 | if ($command_line) |
3881 | 4104 | { |
3882 | - if ($temp === false) |
|
3883 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3884 | - else |
|
3885 | - echo "\n" . 'Fixing admin preferences...'; |
|
4105 | + if ($temp === false) { |
|
4106 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
4107 | + } else { |
|
4108 | + echo "\n" . 'Fixing admin preferences...'; |
|
4109 | + } |
|
3886 | 4110 | } |
3887 | 4111 | |
3888 | 4112 | if ($temp !== false) |
@@ -3902,15 +4126,15 @@ discard block |
||
3902 | 4126 | ) |
3903 | 4127 | ); |
3904 | 4128 | |
3905 | - if ($command_line) |
|
3906 | - echo ' done.'; |
|
4129 | + if ($command_line) { |
|
4130 | + echo ' done.'; |
|
4131 | + } |
|
3907 | 4132 | } |
3908 | 4133 | } |
3909 | 4134 | |
3910 | 4135 | $smcFunc['db_free_result']($query); |
3911 | 4136 | } |
3912 | - } |
|
3913 | - else |
|
4137 | + } else |
|
3914 | 4138 | { |
3915 | 4139 | // First item is always the key... |
3916 | 4140 | $key = $info[0]; |
@@ -3921,8 +4145,7 @@ discard block |
||
3921 | 4145 | { |
3922 | 4146 | $col_select = $info[1]; |
3923 | 4147 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3924 | - } |
|
3925 | - else |
|
4148 | + } else |
|
3926 | 4149 | { |
3927 | 4150 | $col_select = implode(', ', $info); |
3928 | 4151 | } |
@@ -3955,8 +4178,7 @@ discard block |
||
3955 | 4178 | if ($temp === false && $command_line) |
3956 | 4179 | { |
3957 | 4180 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
3958 | - } |
|
3959 | - else |
|
4181 | + } else |
|
3960 | 4182 | { |
3961 | 4183 | $row[$col] = json_encode($temp); |
3962 | 4184 | |
@@ -3981,16 +4203,18 @@ discard block |
||
3981 | 4203 | } |
3982 | 4204 | } |
3983 | 4205 | |
3984 | - if ($command_line) |
|
3985 | - echo ' done.'; |
|
4206 | + if ($command_line) { |
|
4207 | + echo ' done.'; |
|
4208 | + } |
|
3986 | 4209 | |
3987 | 4210 | // Free up some memory... |
3988 | 4211 | $smcFunc['db_free_result']($query); |
3989 | 4212 | } |
3990 | 4213 | } |
3991 | 4214 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3992 | - if (isset($_GET['xml'])) |
|
3993 | - return upgradeExit(); |
|
4215 | + if (isset($_GET['xml'])) { |
|
4216 | + return upgradeExit(); |
|
4217 | + } |
|
3994 | 4218 | } |
3995 | 4219 | |
3996 | 4220 | if ($command_line) |
@@ -4005,8 +4229,9 @@ discard block |
||
4005 | 4229 | |
4006 | 4230 | $_GET['substep'] = 0; |
4007 | 4231 | // Make sure we move on! |
4008 | - if ($command_line) |
|
4009 | - return DeleteUpgrade(); |
|
4232 | + if ($command_line) { |
|
4233 | + return DeleteUpgrade(); |
|
4234 | + } |
|
4010 | 4235 | |
4011 | 4236 | return true; |
4012 | 4237 | } |
@@ -4026,14 +4251,16 @@ discard block |
||
4026 | 4251 | global $upcontext, $txt, $settings; |
4027 | 4252 | |
4028 | 4253 | // Don't call me twice! |
4029 | - if (!empty($upcontext['chmod_called'])) |
|
4030 | - return; |
|
4254 | + if (!empty($upcontext['chmod_called'])) { |
|
4255 | + return; |
|
4256 | + } |
|
4031 | 4257 | |
4032 | 4258 | $upcontext['chmod_called'] = true; |
4033 | 4259 | |
4034 | 4260 | // Nothing? |
4035 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
4036 | - return; |
|
4261 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
4262 | + return; |
|
4263 | + } |
|
4037 | 4264 | |
4038 | 4265 | // Was it a problem with Windows? |
4039 | 4266 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -4065,11 +4292,12 @@ discard block |
||
4065 | 4292 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
4066 | 4293 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
4067 | 4294 | |
4068 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
4069 | - echo ' |
|
4295 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
4296 | + echo ' |
|
4070 | 4297 | content.write(\'<hr>\n\t\t\t\'); |
4071 | 4298 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
4072 | 4299 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
4300 | + } |
|
4073 | 4301 | |
4074 | 4302 | echo ' |
4075 | 4303 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -4077,17 +4305,19 @@ discard block |
||
4077 | 4305 | } |
4078 | 4306 | </script>'; |
4079 | 4307 | |
4080 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
4081 | - echo ' |
|
4308 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
4309 | + echo ' |
|
4082 | 4310 | <div class="error_message red"> |
4083 | 4311 | The following error was encountered when trying to connect:<br><br> |
4084 | 4312 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
4085 | 4313 | </div> |
4086 | 4314 | <br>'; |
4315 | + } |
|
4087 | 4316 | |
4088 | - if (empty($upcontext['chmod_in_form'])) |
|
4089 | - echo ' |
|
4317 | + if (empty($upcontext['chmod_in_form'])) { |
|
4318 | + echo ' |
|
4090 | 4319 | <form action="', $upcontext['form_url'], '" method="post">'; |
4320 | + } |
|
4091 | 4321 | |
4092 | 4322 | echo ' |
4093 | 4323 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -4122,10 +4352,11 @@ discard block |
||
4122 | 4352 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
4123 | 4353 | </div>'; |
4124 | 4354 | |
4125 | - if (empty($upcontext['chmod_in_form'])) |
|
4126 | - echo ' |
|
4355 | + if (empty($upcontext['chmod_in_form'])) { |
|
4356 | + echo ' |
|
4127 | 4357 | </form>'; |
4128 | -} |
|
4358 | + } |
|
4359 | + } |
|
4129 | 4360 | |
4130 | 4361 | function template_upgrade_above() |
4131 | 4362 | { |
@@ -4185,9 +4416,10 @@ discard block |
||
4185 | 4416 | <h2>', $txt['upgrade_progress'], '</h2> |
4186 | 4417 | <ul>'; |
4187 | 4418 | |
4188 | - foreach ($upcontext['steps'] as $num => $step) |
|
4189 | - echo ' |
|
4419 | + foreach ($upcontext['steps'] as $num => $step) { |
|
4420 | + echo ' |
|
4190 | 4421 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
4422 | + } |
|
4191 | 4423 | |
4192 | 4424 | echo ' |
4193 | 4425 | </ul> |
@@ -4200,8 +4432,8 @@ discard block |
||
4200 | 4432 | </div> |
4201 | 4433 | </div>'; |
4202 | 4434 | |
4203 | - if (isset($upcontext['step_progress'])) |
|
4204 | - echo ' |
|
4435 | + if (isset($upcontext['step_progress'])) { |
|
4436 | + echo ' |
|
4205 | 4437 | <br> |
4206 | 4438 | <br> |
4207 | 4439 | <div id="progress_bar_step"> |
@@ -4210,6 +4442,7 @@ discard block |
||
4210 | 4442 | <span>', $txt['upgrade_step_progress'], '</span> |
4211 | 4443 | </div> |
4212 | 4444 | </div>'; |
4445 | + } |
|
4213 | 4446 | |
4214 | 4447 | echo ' |
4215 | 4448 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -4240,32 +4473,36 @@ discard block |
||
4240 | 4473 | { |
4241 | 4474 | global $upcontext, $txt; |
4242 | 4475 | |
4243 | - if (!empty($upcontext['pause'])) |
|
4244 | - echo ' |
|
4476 | + if (!empty($upcontext['pause'])) { |
|
4477 | + echo ' |
|
4245 | 4478 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
4246 | 4479 | |
4247 | 4480 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
4248 | 4481 | <h3> |
4249 | 4482 | ', $txt['upgrade_paused_overload'], ' |
4250 | 4483 | </h3>'; |
4484 | + } |
|
4251 | 4485 | |
4252 | - if (!empty($upcontext['custom_warning'])) |
|
4253 | - echo ' |
|
4486 | + if (!empty($upcontext['custom_warning'])) { |
|
4487 | + echo ' |
|
4254 | 4488 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
4255 | 4489 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
4256 | 4490 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
4257 | 4491 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
4258 | 4492 | </div>'; |
4493 | + } |
|
4259 | 4494 | |
4260 | 4495 | echo ' |
4261 | 4496 | <div class="righttext" style="margin: 1ex;">'; |
4262 | 4497 | |
4263 | - if (!empty($upcontext['continue'])) |
|
4264 | - echo ' |
|
4498 | + if (!empty($upcontext['continue'])) { |
|
4499 | + echo ' |
|
4265 | 4500 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
4266 | - if (!empty($upcontext['skip'])) |
|
4267 | - echo ' |
|
4501 | + } |
|
4502 | + if (!empty($upcontext['skip'])) { |
|
4503 | + echo ' |
|
4268 | 4504 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
4505 | + } |
|
4269 | 4506 | |
4270 | 4507 | echo ' |
4271 | 4508 | </div> |
@@ -4315,11 +4552,12 @@ discard block |
||
4315 | 4552 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
4316 | 4553 | <smf>'; |
4317 | 4554 | |
4318 | - if (!empty($upcontext['get_data'])) |
|
4319 | - foreach ($upcontext['get_data'] as $k => $v) |
|
4555 | + if (!empty($upcontext['get_data'])) { |
|
4556 | + foreach ($upcontext['get_data'] as $k => $v) |
|
4320 | 4557 | echo ' |
4321 | 4558 | <get key="', $k, '">', $v, '</get>'; |
4322 | -} |
|
4559 | + } |
|
4560 | + } |
|
4323 | 4561 | |
4324 | 4562 | function template_xml_below() |
4325 | 4563 | { |
@@ -4360,8 +4598,8 @@ discard block |
||
4360 | 4598 | template_chmod(); |
4361 | 4599 | |
4362 | 4600 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
4363 | - if ($upcontext['is_large_forum']) |
|
4364 | - echo ' |
|
4601 | + if ($upcontext['is_large_forum']) { |
|
4602 | + echo ' |
|
4365 | 4603 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
4366 | 4604 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
4367 | 4605 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -4369,10 +4607,11 @@ discard block |
||
4369 | 4607 | ', $txt['upgrade_warning_lots_data'], ' |
4370 | 4608 | </div> |
4371 | 4609 | </div>'; |
4610 | + } |
|
4372 | 4611 | |
4373 | 4612 | // A warning message? |
4374 | - if (!empty($upcontext['warning'])) |
|
4375 | - echo ' |
|
4613 | + if (!empty($upcontext['warning'])) { |
|
4614 | + echo ' |
|
4376 | 4615 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
4377 | 4616 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
4378 | 4617 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -4380,6 +4619,7 @@ discard block |
||
4380 | 4619 | ', $upcontext['warning'], ' |
4381 | 4620 | </div> |
4382 | 4621 | </div>'; |
4622 | + } |
|
4383 | 4623 | |
4384 | 4624 | // Paths are incorrect? |
4385 | 4625 | echo ' |
@@ -4395,20 +4635,22 @@ discard block |
||
4395 | 4635 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
4396 | 4636 | { |
4397 | 4637 | $ago = time() - $upcontext['started']; |
4398 | - if ($ago < 60) |
|
4399 | - $ago = $ago . ' seconds'; |
|
4400 | - elseif ($ago < 3600) |
|
4401 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
4402 | - else |
|
4403 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
4638 | + if ($ago < 60) { |
|
4639 | + $ago = $ago . ' seconds'; |
|
4640 | + } elseif ($ago < 3600) { |
|
4641 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
4642 | + } else { |
|
4643 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
4644 | + } |
|
4404 | 4645 | |
4405 | 4646 | $active = time() - $upcontext['updated']; |
4406 | - if ($active < 60) |
|
4407 | - $updated = $active . ' seconds'; |
|
4408 | - elseif ($active < 3600) |
|
4409 | - $updated = (int) ($active / 60) . ' minutes'; |
|
4410 | - else |
|
4411 | - $updated = (int) ($active / 3600) . ' hours'; |
|
4647 | + if ($active < 60) { |
|
4648 | + $updated = $active . ' seconds'; |
|
4649 | + } elseif ($active < 3600) { |
|
4650 | + $updated = (int) ($active / 60) . ' minutes'; |
|
4651 | + } else { |
|
4652 | + $updated = (int) ($active / 3600) . ' hours'; |
|
4653 | + } |
|
4412 | 4654 | |
4413 | 4655 | echo ' |
4414 | 4656 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -4417,16 +4659,18 @@ discard block |
||
4417 | 4659 | <div style="padding-left: 6ex;"> |
4418 | 4660 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
4419 | 4661 | |
4420 | - if ($active < 600) |
|
4421 | - echo ' |
|
4662 | + if ($active < 600) { |
|
4663 | + echo ' |
|
4422 | 4664 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
4665 | + } |
|
4423 | 4666 | |
4424 | - if ($active > $upcontext['inactive_timeout']) |
|
4425 | - echo ' |
|
4667 | + if ($active > $upcontext['inactive_timeout']) { |
|
4668 | + echo ' |
|
4426 | 4669 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
4427 | - else |
|
4428 | - echo ' |
|
4670 | + } else { |
|
4671 | + echo ' |
|
4429 | 4672 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
4673 | + } |
|
4430 | 4674 | |
4431 | 4675 | echo ' |
4432 | 4676 | </div> |
@@ -4442,9 +4686,10 @@ discard block |
||
4442 | 4686 | <td> |
4443 | 4687 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
4444 | 4688 | |
4445 | - if (!empty($upcontext['username_incorrect'])) |
|
4446 | - echo ' |
|
4689 | + if (!empty($upcontext['username_incorrect'])) { |
|
4690 | + echo ' |
|
4447 | 4691 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
4692 | + } |
|
4448 | 4693 | |
4449 | 4694 | echo ' |
4450 | 4695 | </td> |
@@ -4455,9 +4700,10 @@ discard block |
||
4455 | 4700 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
4456 | 4701 | <input type="hidden" name="hash_passwrd" value="">'; |
4457 | 4702 | |
4458 | - if (!empty($upcontext['password_failed'])) |
|
4459 | - echo ' |
|
4703 | + if (!empty($upcontext['password_failed'])) { |
|
4704 | + echo ' |
|
4460 | 4705 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
4706 | + } |
|
4461 | 4707 | |
4462 | 4708 | echo ' |
4463 | 4709 | </td> |
@@ -4528,8 +4774,8 @@ discard block |
||
4528 | 4774 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
4529 | 4775 | |
4530 | 4776 | // Warning message? |
4531 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
4532 | - echo ' |
|
4777 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
4778 | + echo ' |
|
4533 | 4779 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
4534 | 4780 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
4535 | 4781 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -4537,6 +4783,7 @@ discard block |
||
4537 | 4783 | ', $upcontext['upgrade_options_warning'], ' |
4538 | 4784 | </div> |
4539 | 4785 | </div>'; |
4786 | + } |
|
4540 | 4787 | |
4541 | 4788 | echo ' |
4542 | 4789 | <table> |
@@ -4564,8 +4811,8 @@ discard block |
||
4564 | 4811 | </tr>'; |
4565 | 4812 | |
4566 | 4813 | // Offer mysql users to switch to mysqli |
4567 | - if ($db_type == 'mysql' && function_exists('mysqli_query')) |
|
4568 | - echo ' |
|
4814 | + if ($db_type == 'mysql' && function_exists('mysqli_query')) { |
|
4815 | + echo ' |
|
4569 | 4816 | <tr valign="top"> |
4570 | 4817 | <td width="2%"> |
4571 | 4818 | <input type="checkbox" name="convertMysql" id="convertMysql" value="1" checked class="input_check"> |
@@ -4575,6 +4822,7 @@ discard block |
||
4575 | 4822 | <strong class="smalltext"><a href="http://wiki.simplemachines.org/smf/Upgrading-MySQLi-Functionality" target="_blank">More information about MySQLi</a></strong><br> |
4576 | 4823 | </td> |
4577 | 4824 | </tr>'; |
4825 | + } |
|
4578 | 4826 | |
4579 | 4827 | echo ' |
4580 | 4828 | <tr valign="top"> |
@@ -4594,8 +4842,8 @@ discard block |
||
4594 | 4842 | </td> |
4595 | 4843 | </tr>'; |
4596 | 4844 | |
4597 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
4598 | - echo ' |
|
4845 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
4846 | + echo ' |
|
4599 | 4847 | <tr valign="top"> |
4600 | 4848 | <td width="2%"> |
4601 | 4849 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -4604,6 +4852,7 @@ discard block |
||
4604 | 4852 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
4605 | 4853 | </td> |
4606 | 4854 | </tr>'; |
4855 | + } |
|
4607 | 4856 | |
4608 | 4857 | echo ' |
4609 | 4858 | <tr valign="top"> |
@@ -4639,10 +4888,11 @@ discard block |
||
4639 | 4888 | <span id="debuginfo"></span>'; |
4640 | 4889 | |
4641 | 4890 | // Dont any tables so far? |
4642 | - if (!empty($upcontext['previous_tables'])) |
|
4643 | - foreach ($upcontext['previous_tables'] as $table) |
|
4891 | + if (!empty($upcontext['previous_tables'])) { |
|
4892 | + foreach ($upcontext['previous_tables'] as $table) |
|
4644 | 4893 | echo ' |
4645 | 4894 | <br>Completed Table: "', $table, '".'; |
4895 | + } |
|
4646 | 4896 | |
4647 | 4897 | echo ' |
4648 | 4898 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -4679,12 +4929,13 @@ discard block |
||
4679 | 4929 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4680 | 4930 | |
4681 | 4931 | // If debug flood the screen. |
4682 | - if ($is_debug) |
|
4683 | - echo ' |
|
4932 | + if ($is_debug) { |
|
4933 | + echo ' |
|
4684 | 4934 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4685 | 4935 | |
4686 | 4936 | if (document.getElementById(\'debuginfo\').scrollHeight) |
4687 | 4937 | document.getElementById(\'debuginfo\').scrollTop = document.getElementById(\'debuginfo\').scrollHeight;'; |
4938 | + } |
|
4688 | 4939 | |
4689 | 4940 | echo ' |
4690 | 4941 | // Get the next update... |
@@ -4716,8 +4967,9 @@ discard block |
||
4716 | 4967 | { |
4717 | 4968 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
4718 | 4969 | |
4719 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
4720 | - $is_debug = true; |
|
4970 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
4971 | + $is_debug = true; |
|
4972 | + } |
|
4721 | 4973 | |
4722 | 4974 | echo ' |
4723 | 4975 | <h3>Executing database changes</h3> |
@@ -4732,8 +4984,9 @@ discard block |
||
4732 | 4984 | { |
4733 | 4985 | foreach ($upcontext['actioned_items'] as $num => $item) |
4734 | 4986 | { |
4735 | - if ($num != 0) |
|
4736 | - echo ' Successful!'; |
|
4987 | + if ($num != 0) { |
|
4988 | + echo ' Successful!'; |
|
4989 | + } |
|
4737 | 4990 | echo '<br>' . $item; |
4738 | 4991 | } |
4739 | 4992 | if (!empty($upcontext['changes_complete'])) |
@@ -4746,28 +4999,32 @@ discard block |
||
4746 | 4999 | $seconds = intval($active % 60); |
4747 | 5000 | |
4748 | 5001 | $totalTime = ''; |
4749 | - if ($hours > 0) |
|
4750 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4751 | - if ($minutes > 0) |
|
4752 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4753 | - if ($seconds > 0) |
|
4754 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
5002 | + if ($hours > 0) { |
|
5003 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
5004 | + } |
|
5005 | + if ($minutes > 0) { |
|
5006 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
5007 | + } |
|
5008 | + if ($seconds > 0) { |
|
5009 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
5010 | + } |
|
4755 | 5011 | } |
4756 | 5012 | |
4757 | - if ($is_debug && !empty($totalTime)) |
|
4758 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4759 | - else |
|
4760 | - echo ' Successful!<br><br>'; |
|
5013 | + if ($is_debug && !empty($totalTime)) { |
|
5014 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
5015 | + } else { |
|
5016 | + echo ' Successful!<br><br>'; |
|
5017 | + } |
|
4761 | 5018 | |
4762 | 5019 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
4763 | 5020 | } |
4764 | - } |
|
4765 | - else |
|
5021 | + } else |
|
4766 | 5022 | { |
4767 | 5023 | // Tell them how many files we have in total. |
4768 | - if ($upcontext['file_count'] > 1) |
|
4769 | - echo ' |
|
5024 | + if ($upcontext['file_count'] > 1) { |
|
5025 | + echo ' |
|
4770 | 5026 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
5027 | + } |
|
4771 | 5028 | |
4772 | 5029 | echo ' |
4773 | 5030 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -4783,19 +5040,23 @@ discard block |
||
4783 | 5040 | $seconds = intval($active % 60); |
4784 | 5041 | |
4785 | 5042 | $totalTime = ''; |
4786 | - if ($hours > 0) |
|
4787 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4788 | - if ($minutes > 0) |
|
4789 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4790 | - if ($seconds > 0) |
|
4791 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
5043 | + if ($hours > 0) { |
|
5044 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
5045 | + } |
|
5046 | + if ($minutes > 0) { |
|
5047 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
5048 | + } |
|
5049 | + if ($seconds > 0) { |
|
5050 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
5051 | + } |
|
4792 | 5052 | } |
4793 | 5053 | |
4794 | 5054 | echo ' |
4795 | 5055 | <br><span id="upgradeCompleted">'; |
4796 | 5056 | |
4797 | - if (!empty($totalTime)) |
|
4798 | - echo 'Completed in ', $totalTime, '<br>'; |
|
5057 | + if (!empty($totalTime)) { |
|
5058 | + echo 'Completed in ', $totalTime, '<br>'; |
|
5059 | + } |
|
4799 | 5060 | |
4800 | 5061 | echo '</span> |
4801 | 5062 | <div id="debug_section" style="height: 200px; overflow: auto;"> |
@@ -4832,9 +5093,10 @@ discard block |
||
4832 | 5093 | var getData = ""; |
4833 | 5094 | var debugItems = ', $upcontext['debug_items'], ';'; |
4834 | 5095 | |
4835 | - if ($is_debug) |
|
4836 | - echo ' |
|
5096 | + if ($is_debug) { |
|
5097 | + echo ' |
|
4837 | 5098 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
5099 | + } |
|
4838 | 5100 | |
4839 | 5101 | echo ' |
4840 | 5102 | function getNextItem() |
@@ -4874,9 +5136,10 @@ discard block |
||
4874 | 5136 | document.getElementById("error_block").style.display = ""; |
4875 | 5137 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4876 | 5138 | |
4877 | - if ($is_debug) |
|
4878 | - echo ' |
|
5139 | + if ($is_debug) { |
|
5140 | + echo ' |
|
4879 | 5141 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
5142 | + } |
|
4880 | 5143 | |
4881 | 5144 | echo ' |
4882 | 5145 | } |
@@ -4897,9 +5160,10 @@ discard block |
||
4897 | 5160 | document.getElementById("error_block").style.display = ""; |
4898 | 5161 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
4899 | 5162 | |
4900 | - if ($is_debug) |
|
4901 | - echo ' |
|
5163 | + if ($is_debug) { |
|
5164 | + echo ' |
|
4902 | 5165 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
5166 | + } |
|
4903 | 5167 | |
4904 | 5168 | echo ' |
4905 | 5169 | } |
@@ -4958,8 +5222,8 @@ discard block |
||
4958 | 5222 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
4959 | 5223 | {'; |
4960 | 5224 | |
4961 | - if ($is_debug) |
|
4962 | - echo ' |
|
5225 | + if ($is_debug) { |
|
5226 | + echo ' |
|
4963 | 5227 | document.getElementById(\'debug_section\').style.display = "none"; |
4964 | 5228 | |
4965 | 5229 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4977,6 +5241,7 @@ discard block |
||
4977 | 5241 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
4978 | 5242 | |
4979 | 5243 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
5244 | + } |
|
4980 | 5245 | |
4981 | 5246 | echo ' |
4982 | 5247 | |
@@ -4984,9 +5249,10 @@ discard block |
||
4984 | 5249 | document.getElementById(\'contbutt\').disabled = 0; |
4985 | 5250 | document.getElementById(\'database_done\').value = 1;'; |
4986 | 5251 | |
4987 | - if ($upcontext['file_count'] > 1) |
|
4988 | - echo ' |
|
5252 | + if ($upcontext['file_count'] > 1) { |
|
5253 | + echo ' |
|
4989 | 5254 | document.getElementById(\'info1\').style.display = "none";'; |
5255 | + } |
|
4990 | 5256 | |
4991 | 5257 | echo ' |
4992 | 5258 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4999,9 +5265,10 @@ discard block |
||
4999 | 5265 | lastItem = 0; |
5000 | 5266 | prevFile = curFile;'; |
5001 | 5267 | |
5002 | - if ($is_debug) |
|
5003 | - echo ' |
|
5268 | + if ($is_debug) { |
|
5269 | + echo ' |
|
5004 | 5270 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
5271 | + } |
|
5005 | 5272 | |
5006 | 5273 | echo ' |
5007 | 5274 | getNextItem(); |
@@ -5009,8 +5276,8 @@ discard block |
||
5009 | 5276 | }'; |
5010 | 5277 | |
5011 | 5278 | // If debug scroll the screen. |
5012 | - if ($is_debug) |
|
5013 | - echo ' |
|
5279 | + if ($is_debug) { |
|
5280 | + echo ' |
|
5014 | 5281 | if (iLastSubStepProgress == -1) |
5015 | 5282 | { |
5016 | 5283 | // Give it consistent dots. |
@@ -5029,6 +5296,7 @@ discard block |
||
5029 | 5296 | |
5030 | 5297 | if (document.getElementById(\'debug_section\').scrollHeight) |
5031 | 5298 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
5299 | + } |
|
5032 | 5300 | |
5033 | 5301 | echo ' |
5034 | 5302 | // Update the page. |
@@ -5089,9 +5357,10 @@ discard block |
||
5089 | 5357 | }'; |
5090 | 5358 | |
5091 | 5359 | // Start things off assuming we've not errored. |
5092 | - if (empty($upcontext['error_message'])) |
|
5093 | - echo ' |
|
5360 | + if (empty($upcontext['error_message'])) { |
|
5361 | + echo ' |
|
5094 | 5362 | getNextItem();'; |
5363 | + } |
|
5095 | 5364 | |
5096 | 5365 | echo ' |
5097 | 5366 | </script>'; |
@@ -5108,18 +5377,21 @@ discard block |
||
5108 | 5377 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
5109 | 5378 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
5110 | 5379 | |
5111 | - if (!empty($upcontext['error_message'])) |
|
5112 | - echo ' |
|
5380 | + if (!empty($upcontext['error_message'])) { |
|
5381 | + echo ' |
|
5113 | 5382 | <error>', $upcontext['error_message'], '</error>'; |
5383 | + } |
|
5114 | 5384 | |
5115 | - if (!empty($upcontext['error_string'])) |
|
5116 | - echo ' |
|
5385 | + if (!empty($upcontext['error_string'])) { |
|
5386 | + echo ' |
|
5117 | 5387 | <sql>', $upcontext['error_string'], '</sql>'; |
5388 | + } |
|
5118 | 5389 | |
5119 | - if ($is_debug) |
|
5120 | - echo ' |
|
5390 | + if ($is_debug) { |
|
5391 | + echo ' |
|
5121 | 5392 | <curtime>', time(), '</curtime>'; |
5122 | -} |
|
5393 | + } |
|
5394 | + } |
|
5123 | 5395 | |
5124 | 5396 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
5125 | 5397 | function template_convert_utf8() |
@@ -5136,18 +5408,20 @@ discard block |
||
5136 | 5408 | <span id="debuginfo"></span>'; |
5137 | 5409 | |
5138 | 5410 | // Done any tables so far? |
5139 | - if (!empty($upcontext['previous_tables'])) |
|
5140 | - foreach ($upcontext['previous_tables'] as $table) |
|
5411 | + if (!empty($upcontext['previous_tables'])) { |
|
5412 | + foreach ($upcontext['previous_tables'] as $table) |
|
5141 | 5413 | echo ' |
5142 | 5414 | <br>Completed Table: "', $table, '".'; |
5415 | + } |
|
5143 | 5416 | |
5144 | 5417 | echo ' |
5145 | 5418 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
5146 | 5419 | |
5147 | 5420 | // If we dropped their index, let's let them know |
5148 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
5149 | - echo ' |
|
5421 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
5422 | + echo ' |
|
5150 | 5423 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
5424 | + } |
|
5151 | 5425 | |
5152 | 5426 | echo ' |
5153 | 5427 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>'; |
@@ -5183,9 +5457,10 @@ discard block |
||
5183 | 5457 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
5184 | 5458 | |
5185 | 5459 | // If debug flood the screen. |
5186 | - if ($is_debug) |
|
5187 | - echo ' |
|
5460 | + if ($is_debug) { |
|
5461 | + echo ' |
|
5188 | 5462 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
5463 | + } |
|
5189 | 5464 | |
5190 | 5465 | echo ' |
5191 | 5466 | // Get the next update... |
@@ -5254,14 +5529,16 @@ discard block |
||
5254 | 5529 | <input type="hidden" name="cleandone" value="1">'; |
5255 | 5530 | |
5256 | 5531 | // Files to make writable? |
5257 | - if (!empty($upcontext['writable_files'])) |
|
5258 | - echo ' |
|
5532 | + if (!empty($upcontext['writable_files'])) { |
|
5533 | + echo ' |
|
5259 | 5534 | <input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">'; |
5535 | + } |
|
5260 | 5536 | |
5261 | 5537 | // We'll want a continue button... |
5262 | - if (empty($upcontext['chmod']['files'])) |
|
5263 | - $upcontext['continue'] = 1; |
|
5264 | -} |
|
5538 | + if (empty($upcontext['chmod']['files'])) { |
|
5539 | + $upcontext['continue'] = 1; |
|
5540 | + } |
|
5541 | + } |
|
5265 | 5542 | |
5266 | 5543 | // Finished with the mods - let them know what we've done. |
5267 | 5544 | function template_cleanup_done() |
@@ -5323,8 +5600,9 @@ discard block |
||
5323 | 5600 | "', $language['name'], '" Language Pack |
5324 | 5601 | <div class="smalltext">('; |
5325 | 5602 | |
5326 | - foreach ($language['files'] as $k => $file) |
|
5327 | - echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')'; |
|
5603 | + foreach ($language['files'] as $k => $file) { |
|
5604 | + echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')'; |
|
5605 | + } |
|
5328 | 5606 | |
5329 | 5607 | echo ' |
5330 | 5608 | </div> |
@@ -5341,8 +5619,9 @@ discard block |
||
5341 | 5619 | "', $theme['name'], '" Theme |
5342 | 5620 | <div class="smalltext">('; |
5343 | 5621 | |
5344 | - foreach ($theme['files'] as $k => $file) |
|
5345 | - echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')'; |
|
5622 | + foreach ($theme['files'] as $k => $file) { |
|
5623 | + echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')'; |
|
5624 | + } |
|
5346 | 5625 | |
5347 | 5626 | echo ' |
5348 | 5627 | </div> |
@@ -5353,47 +5632,54 @@ discard block |
||
5353 | 5632 | |
5354 | 5633 | echo ' |
5355 | 5634 | </table>'; |
5356 | - } |
|
5357 | - else |
|
5635 | + } else |
|
5358 | 5636 | { |
5359 | 5637 | $langFiles = 0; |
5360 | 5638 | $themeFiles = 0; |
5361 | - if (!empty($upcontext['languages'])) |
|
5362 | - foreach ($upcontext['languages'] as $lang) |
|
5639 | + if (!empty($upcontext['languages'])) { |
|
5640 | + foreach ($upcontext['languages'] as $lang) |
|
5363 | 5641 | $langFiles += count($lang['files']); |
5364 | - if (!empty($upcontext['themes'])) |
|
5365 | - foreach ($upcontext['themes'] as $theme) |
|
5642 | + } |
|
5643 | + if (!empty($upcontext['themes'])) { |
|
5644 | + foreach ($upcontext['themes'] as $theme) |
|
5366 | 5645 | $themeFiles += count($theme['files']); |
5646 | + } |
|
5367 | 5647 | echo sprintf('Found <strong>%d</strong> language files and <strong>%d</strong> templates requiring an update so far.', $langFiles, $themeFiles) . '<br>'; |
5368 | 5648 | |
5369 | 5649 | // What we're currently doing? |
5370 | - if (!empty($upcontext['current_message'])) |
|
5371 | - echo ' |
|
5650 | + if (!empty($upcontext['current_message'])) { |
|
5651 | + echo ' |
|
5372 | 5652 | ', $upcontext['current_message']; |
5653 | + } |
|
5373 | 5654 | } |
5374 | 5655 | |
5375 | 5656 | echo ' |
5376 | 5657 | <input type="hidden" name="uptempdone" value="1">'; |
5377 | 5658 | |
5378 | - if (!empty($upcontext['languages'])) |
|
5379 | - echo ' |
|
5659 | + if (!empty($upcontext['languages'])) { |
|
5660 | + echo ' |
|
5380 | 5661 | <input type="hidden" name="languages" value="', base64_encode(safe_serialize($upcontext['languages'])), '">'; |
5381 | - if (!empty($upcontext['themes'])) |
|
5382 | - echo ' |
|
5662 | + } |
|
5663 | + if (!empty($upcontext['themes'])) { |
|
5664 | + echo ' |
|
5383 | 5665 | <input type="hidden" name="themes" value="', base64_encode(safe_serialize($upcontext['themes'])), '">'; |
5384 | - if (!empty($upcontext['writable_files'])) |
|
5385 | - echo ' |
|
5666 | + } |
|
5667 | + if (!empty($upcontext['writable_files'])) { |
|
5668 | + echo ' |
|
5386 | 5669 | <input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">'; |
5670 | + } |
|
5387 | 5671 | |
5388 | 5672 | // Offer them the option to upgrade from YaBB SE? |
5389 | - if (!empty($upcontext['can_upgrade_yabbse'])) |
|
5390 | - echo ' |
|
5673 | + if (!empty($upcontext['can_upgrade_yabbse'])) { |
|
5674 | + echo ' |
|
5391 | 5675 | <br><label for="conv"><input type="checkbox" name="conv" id="conv" value="1" class="input_check"> Convert the existing YaBB SE template and set it as default.</label><br>'; |
5676 | + } |
|
5392 | 5677 | |
5393 | 5678 | // We'll want a continue button... assuming chmod is OK (Otherwise let them use connect!) |
5394 | - if (empty($upcontext['chmod']['files']) || $upcontext['is_test']) |
|
5395 | - $upcontext['continue'] = 1; |
|
5396 | -} |
|
5679 | + if (empty($upcontext['chmod']['files']) || $upcontext['is_test']) { |
|
5680 | + $upcontext['continue'] = 1; |
|
5681 | + } |
|
5682 | + } |
|
5397 | 5683 | |
5398 | 5684 | // Template for the database backup tool/ |
5399 | 5685 | function template_serialize_json() |
@@ -5410,19 +5696,21 @@ discard block |
||
5410 | 5696 | <span id="debuginfo"></span>'; |
5411 | 5697 | |
5412 | 5698 | // Dont any tables so far? |
5413 | - if (!empty($upcontext['previous_tables'])) |
|
5414 | - foreach ($upcontext['previous_tables'] as $table) |
|
5699 | + if (!empty($upcontext['previous_tables'])) { |
|
5700 | + foreach ($upcontext['previous_tables'] as $table) |
|
5415 | 5701 | echo ' |
5416 | 5702 | <br>Completed Table: "', $table, '".'; |
5703 | + } |
|
5417 | 5704 | |
5418 | 5705 | echo ' |
5419 | 5706 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
5420 | 5707 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
5421 | 5708 | |
5422 | 5709 | // Try to make sure substep was reset. |
5423 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
5424 | - echo ' |
|
5710 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
5711 | + echo ' |
|
5425 | 5712 | <input type="hidden" name="substep" id="substep" value="0">'; |
5713 | + } |
|
5426 | 5714 | |
5427 | 5715 | // Continue please! |
5428 | 5716 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -5455,9 +5743,10 @@ discard block |
||
5455 | 5743 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
5456 | 5744 | |
5457 | 5745 | // If debug flood the screen. |
5458 | - if ($is_debug) |
|
5459 | - echo ' |
|
5746 | + if ($is_debug) { |
|
5747 | + echo ' |
|
5460 | 5748 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
5749 | + } |
|
5461 | 5750 | |
5462 | 5751 | echo ' |
5463 | 5752 | // Get the next update... |
@@ -5492,8 +5781,8 @@ discard block |
||
5492 | 5781 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
5493 | 5782 | <form action="', $boardurl, '/index.php">'; |
5494 | 5783 | |
5495 | - if (!empty($upcontext['can_delete_script'])) |
|
5496 | - echo ' |
|
5784 | + if (!empty($upcontext['can_delete_script'])) { |
|
5785 | + echo ' |
|
5497 | 5786 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
5498 | 5787 | <script> |
5499 | 5788 | function doTheDelete(theCheck) |
@@ -5505,6 +5794,7 @@ discard block |
||
5505 | 5794 | } |
5506 | 5795 | </script> |
5507 | 5796 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
5797 | + } |
|
5508 | 5798 | |
5509 | 5799 | $active = time() - $upcontext['started']; |
5510 | 5800 | $hours = floor($active / 3600); |
@@ -5514,16 +5804,20 @@ discard block |
||
5514 | 5804 | if ($is_debug) |
5515 | 5805 | { |
5516 | 5806 | $totalTime = ''; |
5517 | - if ($hours > 0) |
|
5518 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
5519 | - if ($minutes > 0) |
|
5520 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
5521 | - if ($seconds > 0) |
|
5522 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
5807 | + if ($hours > 0) { |
|
5808 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
5809 | + } |
|
5810 | + if ($minutes > 0) { |
|
5811 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
5812 | + } |
|
5813 | + if ($seconds > 0) { |
|
5814 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
5815 | + } |
|
5523 | 5816 | } |
5524 | 5817 | |
5525 | - if ($is_debug && !empty($totalTime)) |
|
5526 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
5818 | + if ($is_debug && !empty($totalTime)) { |
|
5819 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
5820 | + } |
|
5527 | 5821 | |
5528 | 5822 | echo '<br> |
5529 | 5823 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="http://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -5583,16 +5877,19 @@ discard block |
||
5583 | 5877 | 'empty' => '', |
5584 | 5878 | 'limit' => $limit, |
5585 | 5879 | )); |
5586 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
5587 | - $arIp[] = $row[$oldCol]; |
|
5880 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
5881 | + $arIp[] = $row[$oldCol]; |
|
5882 | + } |
|
5588 | 5883 | $smcFunc['db_free_result']($request); |
5589 | 5884 | |
5590 | 5885 | // Special case, null ip could keep us in a loop. |
5591 | - if (is_null($arIp[0])) |
|
5592 | - unset($arIp[0]); |
|
5886 | + if (is_null($arIp[0])) { |
|
5887 | + unset($arIp[0]); |
|
5888 | + } |
|
5593 | 5889 | |
5594 | - if (empty($arIp)) |
|
5595 | - $is_done = true; |
|
5890 | + if (empty($arIp)) { |
|
5891 | + $is_done = true; |
|
5892 | + } |
|
5596 | 5893 | |
5597 | 5894 | $updates = array(); |
5598 | 5895 | $cases = array(); |
@@ -5601,16 +5898,18 @@ discard block |
||
5601 | 5898 | { |
5602 | 5899 | $arIp[$i] = trim($arIp[$i]); |
5603 | 5900 | |
5604 | - if (empty($arIp[$i])) |
|
5605 | - continue; |
|
5901 | + if (empty($arIp[$i])) { |
|
5902 | + continue; |
|
5903 | + } |
|
5606 | 5904 | |
5607 | 5905 | $updates['ip' . $i] = $arIp[$i]; |
5608 | 5906 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
5609 | 5907 | |
5610 | 5908 | if ($setSize > 0 && $i % $setSize === 0) |
5611 | 5909 | { |
5612 | - if (count($updates) == 1) |
|
5613 | - continue; |
|
5910 | + if (count($updates) == 1) { |
|
5911 | + continue; |
|
5912 | + } |
|
5614 | 5913 | |
5615 | 5914 | $updates['whereSet'] = array_values($updates); |
5616 | 5915 | $smcFunc['db_query']('', ' |
@@ -5644,8 +5943,7 @@ discard block |
||
5644 | 5943 | 'ip' => $ip |
5645 | 5944 | )); |
5646 | 5945 | } |
5647 | - } |
|
5648 | - else |
|
5946 | + } else |
|
5649 | 5947 | { |
5650 | 5948 | $updates['whereSet'] = array_values($updates); |
5651 | 5949 | $request = $smcFunc['db_query']('', ' |
@@ -5659,9 +5957,9 @@ discard block |
||
5659 | 5957 | $updates |
5660 | 5958 | ); |
5661 | 5959 | } |
5960 | + } else { |
|
5961 | + $is_done = true; |
|
5662 | 5962 | } |
5663 | - else |
|
5664 | - $is_done = true; |
|
5665 | 5963 | |
5666 | 5964 | $_GET['a'] += $limit; |
5667 | 5965 | $step_progress['current'] = $_GET['a']; |