@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $upcontext['inactive_timeout'] = 10; |
| 76 | 76 | |
| 77 | 77 | // The helper is crucial. Include it first thing. |
| 78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
| 80 | +} |
|
| 80 | 81 | |
| 81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 82 | 83 | |
@@ -107,11 +108,14 @@ discard block |
||
| 107 | 108 | ini_set('default_socket_timeout', 900); |
| 108 | 109 | } |
| 109 | 110 | // Clean the upgrade path if this is from the client. |
| 110 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 111 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 111 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 112 | + for ($i = 1; |
|
| 113 | +} |
|
| 114 | +$i < $_SERVER['argc']; $i++) |
|
| 112 | 115 | { |
| 113 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 114 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 116 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 117 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 118 | + } |
|
| 115 | 119 | } |
| 116 | 120 | |
| 117 | 121 | // Are we from the client? |
@@ -119,16 +123,17 @@ discard block |
||
| 119 | 123 | { |
| 120 | 124 | $command_line = true; |
| 121 | 125 | $disable_security = true; |
| 122 | -} |
|
| 123 | -else |
|
| 126 | +} else { |
|
| 124 | 127 | $command_line = false; |
| 128 | +} |
|
| 125 | 129 | |
| 126 | 130 | // Load this now just because we can. |
| 127 | 131 | require_once($upgrade_path . '/Settings.php'); |
| 128 | 132 | |
| 129 | 133 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 130 | -if (isset($language)) |
|
| 134 | +if (isset($language)) { |
|
| 131 | 135 | $language = str_ireplace('-utf8', '', $language); |
| 136 | +} |
|
| 132 | 137 | |
| 133 | 138 | // Are we logged in? |
| 134 | 139 | if (isset($upgradeData)) |
@@ -136,10 +141,12 @@ discard block |
||
| 136 | 141 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 137 | 142 | |
| 138 | 143 | // Check for sensible values. |
| 139 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 140 | - $upcontext['user']['started'] = time(); |
|
| 141 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 142 | - $upcontext['user']['updated'] = 0; |
|
| 144 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 145 | + $upcontext['user']['started'] = time(); |
|
| 146 | + } |
|
| 147 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 148 | + $upcontext['user']['updated'] = 0; |
|
| 149 | + } |
|
| 143 | 150 | |
| 144 | 151 | $upcontext['started'] = $upcontext['user']['started']; |
| 145 | 152 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -204,8 +211,9 @@ discard block |
||
| 204 | 211 | 'db_error_skip' => true, |
| 205 | 212 | ) |
| 206 | 213 | ); |
| 207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 208 | - $modSettings[$row['variable']] = $row['value']; |
|
| 214 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 215 | + $modSettings[$row['variable']] = $row['value']; |
|
| 216 | + } |
|
| 209 | 217 | $smcFunc['db_free_result']($request); |
| 210 | 218 | } |
| 211 | 219 | |
@@ -215,14 +223,17 @@ discard block |
||
| 215 | 223 | $modSettings['theme_url'] = 'Themes/default'; |
| 216 | 224 | $modSettings['images_url'] = 'Themes/default/images'; |
| 217 | 225 | } |
| 218 | -if (!isset($settings['default_theme_url'])) |
|
| 226 | +if (!isset($settings['default_theme_url'])) { |
|
| 219 | 227 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 220 | -if (!isset($settings['default_theme_dir'])) |
|
| 228 | +} |
|
| 229 | +if (!isset($settings['default_theme_dir'])) { |
|
| 221 | 230 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 231 | +} |
|
| 222 | 232 | |
| 223 | 233 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
| 224 | -if (httpsOn()) |
|
| 234 | +if (httpsOn()) { |
|
| 225 | 235 | $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
| 236 | +} |
|
| 226 | 237 | |
| 227 | 238 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 228 | 239 | // Default title... |
@@ -240,13 +251,15 @@ discard block |
||
| 240 | 251 | $support_js = $upcontext['upgrade_status']['js']; |
| 241 | 252 | |
| 242 | 253 | // Only set this if the upgrader status says so. |
| 243 | - if (empty($is_debug)) |
|
| 244 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 254 | + if (empty($is_debug)) { |
|
| 255 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 256 | + } |
|
| 245 | 257 | |
| 246 | 258 | // Load the language. |
| 247 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 248 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 249 | -} |
|
| 259 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 260 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 261 | + } |
|
| 262 | + } |
|
| 250 | 263 | // Set the defaults. |
| 251 | 264 | else |
| 252 | 265 | { |
@@ -264,15 +277,18 @@ discard block |
||
| 264 | 277 | } |
| 265 | 278 | |
| 266 | 279 | // If this isn't the first stage see whether they are logging in and resuming. |
| 267 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 280 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 268 | 281 | checkLogin(); |
| 282 | +} |
|
| 269 | 283 | |
| 270 | -if ($command_line) |
|
| 284 | +if ($command_line) { |
|
| 271 | 285 | cmdStep0(); |
| 286 | +} |
|
| 272 | 287 | |
| 273 | 288 | // Don't error if we're using xml. |
| 274 | -if (isset($_GET['xml'])) |
|
| 289 | +if (isset($_GET['xml'])) { |
|
| 275 | 290 | $upcontext['return_error'] = true; |
| 291 | +} |
|
| 276 | 292 | |
| 277 | 293 | // Loop through all the steps doing each one as required. |
| 278 | 294 | $upcontext['overall_percent'] = 0; |
@@ -293,9 +309,9 @@ discard block |
||
| 293 | 309 | } |
| 294 | 310 | |
| 295 | 311 | // Call the step and if it returns false that means pause! |
| 296 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 297 | - break; |
|
| 298 | - elseif (function_exists($step[2])) { |
|
| 312 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 313 | + break; |
|
| 314 | + } elseif (function_exists($step[2])) { |
|
| 299 | 315 | //Start each new step with this unset, so the 'normal' template is called first |
| 300 | 316 | unset($_GET['xml']); |
| 301 | 317 | //Clear out warnings at the start of each step |
@@ -341,17 +357,18 @@ discard block |
||
| 341 | 357 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 342 | 358 | if (!empty($command_line)) |
| 343 | 359 | { |
| 344 | - if (function_exists('debug_print_backtrace')) |
|
| 345 | - debug_print_backtrace(); |
|
| 360 | + if (function_exists('debug_print_backtrace')) { |
|
| 361 | + debug_print_backtrace(); |
|
| 362 | + } |
|
| 346 | 363 | |
| 347 | 364 | 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.'; |
| 348 | 365 | flush(); |
| 349 | 366 | die(); |
| 350 | 367 | } |
| 351 | 368 | |
| 352 | - if (!isset($_GET['xml'])) |
|
| 353 | - template_upgrade_above(); |
|
| 354 | - else |
|
| 369 | + if (!isset($_GET['xml'])) { |
|
| 370 | + template_upgrade_above(); |
|
| 371 | + } else |
|
| 355 | 372 | { |
| 356 | 373 | header('content-type: text/xml; charset=UTF-8'); |
| 357 | 374 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -373,25 +390,29 @@ discard block |
||
| 373 | 390 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 374 | 391 | |
| 375 | 392 | // Custom stuff to pass back? |
| 376 | - if (!empty($upcontext['query_string'])) |
|
| 377 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 393 | + if (!empty($upcontext['query_string'])) { |
|
| 394 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 395 | + } |
|
| 378 | 396 | |
| 379 | 397 | // Call the appropriate subtemplate |
| 380 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 381 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 382 | - else |
|
| 383 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 398 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 399 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 400 | + } else { |
|
| 401 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 402 | + } |
|
| 384 | 403 | } |
| 385 | 404 | |
| 386 | 405 | // Was there an error? |
| 387 | - if (!empty($upcontext['forced_error_message'])) |
|
| 388 | - echo $upcontext['forced_error_message']; |
|
| 406 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 407 | + echo $upcontext['forced_error_message']; |
|
| 408 | + } |
|
| 389 | 409 | |
| 390 | 410 | // Show the footer. |
| 391 | - if (!isset($_GET['xml'])) |
|
| 392 | - template_upgrade_below(); |
|
| 393 | - else |
|
| 394 | - template_xml_below(); |
|
| 411 | + if (!isset($_GET['xml'])) { |
|
| 412 | + template_upgrade_below(); |
|
| 413 | + } else { |
|
| 414 | + template_xml_below(); |
|
| 415 | + } |
|
| 395 | 416 | } |
| 396 | 417 | |
| 397 | 418 | |
@@ -403,15 +424,19 @@ discard block |
||
| 403 | 424 | $seconds = intval($active % 60); |
| 404 | 425 | |
| 405 | 426 | $totalTime = ''; |
| 406 | - if ($hours > 0) |
|
| 407 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 408 | - if ($minutes > 0) |
|
| 409 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 410 | - if ($seconds > 0) |
|
| 411 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 427 | + if ($hours > 0) { |
|
| 428 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 429 | + } |
|
| 430 | + if ($minutes > 0) { |
|
| 431 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 432 | + } |
|
| 433 | + if ($seconds > 0) { |
|
| 434 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 435 | + } |
|
| 412 | 436 | |
| 413 | - if (!empty($totalTime)) |
|
| 414 | - echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
| 437 | + if (!empty($totalTime)) { |
|
| 438 | + echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
| 439 | + } |
|
| 415 | 440 | } |
| 416 | 441 | |
| 417 | 442 | // Bang - gone! |
@@ -432,8 +457,9 @@ discard block |
||
| 432 | 457 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 433 | 458 | while ($entry = $dir->read()) |
| 434 | 459 | { |
| 435 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 436 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 460 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 461 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 462 | + } |
|
| 437 | 463 | } |
| 438 | 464 | $dir->close(); |
| 439 | 465 | } |
@@ -477,10 +503,11 @@ discard block |
||
| 477 | 503 | } |
| 478 | 504 | |
| 479 | 505 | // Override the language file? |
| 480 | - if (isset($_GET['lang_file'])) |
|
| 481 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 482 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 483 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 506 | + if (isset($_GET['lang_file'])) { |
|
| 507 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 508 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 509 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 510 | + } |
|
| 484 | 511 | |
| 485 | 512 | // Make sure it exists, if it doesn't reset it. |
| 486 | 513 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -489,12 +516,14 @@ discard block |
||
| 489 | 516 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 490 | 517 | |
| 491 | 518 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 492 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 493 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 519 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 520 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 521 | + } |
|
| 494 | 522 | |
| 495 | 523 | // For backup we load the english at first -> second language overwrite the english one |
| 496 | - if (count($incontext['detected_languages']) > 1) |
|
| 497 | - require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 524 | + if (count($incontext['detected_languages']) > 1) { |
|
| 525 | + require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 526 | + } |
|
| 498 | 527 | } |
| 499 | 528 | |
| 500 | 529 | // And now include the actual language file itself. |
@@ -502,11 +531,12 @@ discard block |
||
| 502 | 531 | |
| 503 | 532 | // Which language did we load? Assume that he likes his language. |
| 504 | 533 | preg_match('~^Install\.(.+[^-utf8])\.php$~', $_SESSION['installer_temp_lang'], $matches); |
| 505 | - if (empty($matches[1])) |
|
| 506 | - $matches = [ |
|
| 534 | + if (empty($matches[1])) { |
|
| 535 | + $matches = [ |
|
| 507 | 536 | 0 => 'nothing', |
| 508 | 537 | 1 => 'english', |
| 509 | 538 | ]; |
| 539 | + } |
|
| 510 | 540 | $user_info['language'] = $matches[1]; |
| 511 | 541 | } |
| 512 | 542 | |
@@ -516,8 +546,9 @@ discard block |
||
| 516 | 546 | global $upgradeurl, $upcontext, $command_line; |
| 517 | 547 | |
| 518 | 548 | // Command line users can't be redirected. |
| 519 | - if ($command_line) |
|
| 520 | - upgradeExit(true); |
|
| 549 | + if ($command_line) { |
|
| 550 | + upgradeExit(true); |
|
| 551 | + } |
|
| 521 | 552 | |
| 522 | 553 | // Are we providing the core info? |
| 523 | 554 | if ($addForm) |
@@ -543,12 +574,14 @@ discard block |
||
| 543 | 574 | define('SMF', 1); |
| 544 | 575 | |
| 545 | 576 | // Start the session. |
| 546 | - if (@ini_get('session.save_handler') == 'user') |
|
| 547 | - @ini_set('session.save_handler', 'files'); |
|
| 577 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 578 | + @ini_set('session.save_handler', 'files'); |
|
| 579 | + } |
|
| 548 | 580 | @session_start(); |
| 549 | 581 | |
| 550 | - if (empty($smcFunc)) |
|
| 551 | - $smcFunc = array(); |
|
| 582 | + if (empty($smcFunc)) { |
|
| 583 | + $smcFunc = array(); |
|
| 584 | + } |
|
| 552 | 585 | |
| 553 | 586 | // We need this for authentication and some upgrade code |
| 554 | 587 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -579,30 +612,34 @@ discard block |
||
| 579 | 612 | { |
| 580 | 613 | $options = array('non_fatal' => true); |
| 581 | 614 | // Add in the port if needed |
| 582 | - if (!empty($db_port)) |
|
| 583 | - $options['port'] = $db_port; |
|
| 615 | + if (!empty($db_port)) { |
|
| 616 | + $options['port'] = $db_port; |
|
| 617 | + } |
|
| 584 | 618 | |
| 585 | - if (!empty($db_mb4)) |
|
| 586 | - $options['db_mb4'] = $db_mb4; |
|
| 619 | + if (!empty($db_mb4)) { |
|
| 620 | + $options['db_mb4'] = $db_mb4; |
|
| 621 | + } |
|
| 587 | 622 | |
| 588 | 623 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options); |
| 589 | - } |
|
| 590 | - else |
|
| 591 | - // If we've returned here, ping/reconnect to be safe |
|
| 624 | + } else { |
|
| 625 | + // If we've returned here, ping/reconnect to be safe |
|
| 592 | 626 | $smcFunc['db_ping']($db_connection); |
| 627 | + } |
|
| 593 | 628 | |
| 594 | 629 | // Oh dear god!! |
| 595 | - if ($db_connection === null) |
|
| 596 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 630 | + if ($db_connection === null) { |
|
| 631 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 632 | + } |
|
| 597 | 633 | |
| 598 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 599 | - $smcFunc['db_query']('', ' |
|
| 634 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 635 | + $smcFunc['db_query']('', ' |
|
| 600 | 636 | SET NAMES {string:db_character_set}', |
| 601 | 637 | array( |
| 602 | 638 | 'db_error_skip' => true, |
| 603 | 639 | 'db_character_set' => $db_character_set, |
| 604 | 640 | ) |
| 605 | 641 | ); |
| 642 | + } |
|
| 606 | 643 | |
| 607 | 644 | // Load the modSettings data... |
| 608 | 645 | $request = $smcFunc['db_query']('', ' |
@@ -613,11 +650,11 @@ discard block |
||
| 613 | 650 | ) |
| 614 | 651 | ); |
| 615 | 652 | $modSettings = array(); |
| 616 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 617 | - $modSettings[$row['variable']] = $row['value']; |
|
| 653 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 654 | + $modSettings[$row['variable']] = $row['value']; |
|
| 655 | + } |
|
| 618 | 656 | $smcFunc['db_free_result']($request); |
| 619 | - } |
|
| 620 | - else |
|
| 657 | + } else |
|
| 621 | 658 | { |
| 622 | 659 | 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.'); |
| 623 | 660 | } |
@@ -631,9 +668,10 @@ discard block |
||
| 631 | 668 | cleanRequest(); |
| 632 | 669 | } |
| 633 | 670 | |
| 634 | - if (!isset($_GET['substep'])) |
|
| 635 | - $_GET['substep'] = 0; |
|
| 636 | -} |
|
| 671 | + if (!isset($_GET['substep'])) { |
|
| 672 | + $_GET['substep'] = 0; |
|
| 673 | + } |
|
| 674 | + } |
|
| 637 | 675 | |
| 638 | 676 | function initialize_inputs() |
| 639 | 677 | { |
@@ -663,8 +701,9 @@ discard block |
||
| 663 | 701 | $dh = opendir(dirname(__FILE__)); |
| 664 | 702 | while ($file = readdir($dh)) |
| 665 | 703 | { |
| 666 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 667 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 704 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 705 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 706 | + } |
|
| 668 | 707 | } |
| 669 | 708 | closedir($dh); |
| 670 | 709 | |
@@ -693,8 +732,9 @@ discard block |
||
| 693 | 732 | $temp = 'upgrade_php?step'; |
| 694 | 733 | while (strlen($temp) > 4) |
| 695 | 734 | { |
| 696 | - if (isset($_GET[$temp])) |
|
| 697 | - unset($_GET[$temp]); |
|
| 735 | + if (isset($_GET[$temp])) { |
|
| 736 | + unset($_GET[$temp]); |
|
| 737 | + } |
|
| 698 | 738 | $temp = substr($temp, 1); |
| 699 | 739 | } |
| 700 | 740 | |
@@ -721,32 +761,39 @@ discard block |
||
| 721 | 761 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 722 | 762 | |
| 723 | 763 | // Need legacy scripts? |
| 724 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 725 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 726 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 727 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 728 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 729 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 764 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 765 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 766 | + } |
|
| 767 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 768 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 769 | + } |
|
| 770 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 771 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 772 | + } |
|
| 730 | 773 | |
| 731 | 774 | // We don't need "-utf8" files anymore... |
| 732 | 775 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 733 | 776 | |
| 734 | 777 | // This needs to exist! |
| 735 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 736 | - 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>]'); |
|
| 737 | - else |
|
| 738 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 778 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 779 | + 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>]'); |
|
| 780 | + } else { |
|
| 781 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 782 | + } |
|
| 739 | 783 | |
| 740 | - if (!$check) |
|
| 741 | - // 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. |
|
| 784 | + if (!$check) { |
|
| 785 | + // 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. |
|
| 742 | 786 | 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.'); |
| 787 | + } |
|
| 743 | 788 | |
| 744 | 789 | // Do they meet the install requirements? |
| 745 | - if (!php_version_check()) |
|
| 746 | - 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.'); |
|
| 790 | + if (!php_version_check()) { |
|
| 791 | + 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.'); |
|
| 792 | + } |
|
| 747 | 793 | |
| 748 | - if (!db_version_check()) |
|
| 749 | - 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.'); |
|
| 794 | + if (!db_version_check()) { |
|
| 795 | + 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.'); |
|
| 796 | + } |
|
| 750 | 797 | |
| 751 | 798 | // Do some checks to make sure they have proper privileges |
| 752 | 799 | db_extend('packages'); |
@@ -761,14 +808,16 @@ discard block |
||
| 761 | 808 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 762 | 809 | |
| 763 | 810 | // Sorry... we need CREATE, ALTER and DROP |
| 764 | - if (!$create || !$alter || !$drop) |
|
| 765 | - 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.'); |
|
| 811 | + if (!$create || !$alter || !$drop) { |
|
| 812 | + 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.'); |
|
| 813 | + } |
|
| 766 | 814 | |
| 767 | 815 | // Do a quick version spot check. |
| 768 | 816 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 769 | 817 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 770 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 771 | - 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.'); |
|
| 818 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 819 | + 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.'); |
|
| 820 | + } |
|
| 772 | 821 | |
| 773 | 822 | // What absolutely needs to be writable? |
| 774 | 823 | $writable_files = array( |
@@ -777,12 +826,13 @@ discard block |
||
| 777 | 826 | ); |
| 778 | 827 | |
| 779 | 828 | // Only check for minified writable files if we have it enabled or not set. |
| 780 | - if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) |
|
| 781 | - $writable_files += array( |
|
| 829 | + if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) { |
|
| 830 | + $writable_files += array( |
|
| 782 | 831 | $modSettings['theme_dir'] . '/css/minified.css', |
| 783 | 832 | $modSettings['theme_dir'] . '/scripts/minified.js', |
| 784 | 833 | $modSettings['theme_dir'] . '/scripts/minified_deferred.js', |
| 785 | 834 | ); |
| 835 | + } |
|
| 786 | 836 | |
| 787 | 837 | // Do we need to add this setting? |
| 788 | 838 | $need_settings_update = empty($modSettings['custom_avatar_dir']); |
@@ -794,12 +844,13 @@ discard block |
||
| 794 | 844 | quickFileWritable($custom_av_dir); |
| 795 | 845 | |
| 796 | 846 | // Are we good now? |
| 797 | - if (!is_writable($custom_av_dir)) |
|
| 798 | - 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)); |
|
| 799 | - elseif ($need_settings_update) |
|
| 847 | + if (!is_writable($custom_av_dir)) { |
|
| 848 | + 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)); |
|
| 849 | + } elseif ($need_settings_update) |
|
| 800 | 850 | { |
| 801 | - if (!function_exists('cache_put_data')) |
|
| 802 | - require_once($sourcedir . '/Load.php'); |
|
| 851 | + if (!function_exists('cache_put_data')) { |
|
| 852 | + require_once($sourcedir . '/Load.php'); |
|
| 853 | + } |
|
| 803 | 854 | |
| 804 | 855 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 805 | 856 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
@@ -809,29 +860,34 @@ discard block |
||
| 809 | 860 | |
| 810 | 861 | // Check the cache directory. |
| 811 | 862 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 812 | - if (!file_exists($cachedir_temp)) |
|
| 813 | - @mkdir($cachedir_temp); |
|
| 863 | + if (!file_exists($cachedir_temp)) { |
|
| 864 | + @mkdir($cachedir_temp); |
|
| 865 | + } |
|
| 814 | 866 | |
| 815 | - if (!file_exists($cachedir_temp)) |
|
| 816 | - 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.'); |
|
| 867 | + if (!file_exists($cachedir_temp)) { |
|
| 868 | + 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.'); |
|
| 869 | + } |
|
| 817 | 870 | |
| 818 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 819 | - 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>.'); |
|
| 820 | - elseif (!isset($_GET['skiplang'])) |
|
| 871 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 872 | + 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>.'); |
|
| 873 | + } elseif (!isset($_GET['skiplang'])) |
|
| 821 | 874 | { |
| 822 | 875 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 823 | 876 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 824 | 877 | |
| 825 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 826 | - 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>]'); |
|
| 878 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 879 | + 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>]'); |
|
| 880 | + } |
|
| 827 | 881 | } |
| 828 | 882 | |
| 829 | - if (!makeFilesWritable($writable_files)) |
|
| 830 | - return false; |
|
| 883 | + if (!makeFilesWritable($writable_files)) { |
|
| 884 | + return false; |
|
| 885 | + } |
|
| 831 | 886 | |
| 832 | 887 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 833 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 834 | - 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.'); |
|
| 888 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 889 | + 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.'); |
|
| 890 | + } |
|
| 835 | 891 | |
| 836 | 892 | // Upgrade the agreement. |
| 837 | 893 | elseif (isset($modSettings['agreement'])) |
@@ -842,8 +898,8 @@ discard block |
||
| 842 | 898 | } |
| 843 | 899 | |
| 844 | 900 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 845 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 846 | - $upcontext['warning'] = ' |
|
| 901 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 902 | + $upcontext['warning'] = ' |
|
| 847 | 903 | '. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) .'<br> |
| 848 | 904 | <ul> |
| 849 | 905 | <li>'. $txt['upgrade_boarddir'] .' ' . $boarddir . '</li> |
@@ -851,19 +907,23 @@ discard block |
||
| 851 | 907 | <li>'. $txt['upgrade_cachedir'] .' ' . $cachedir_temp . '</li> |
| 852 | 908 | </ul> |
| 853 | 909 | '. $txt['upgrade_incorrect_settings'] .''; |
| 910 | + } |
|
| 854 | 911 | |
| 855 | 912 | // Confirm mbstring is loaded... |
| 856 | - if (!extension_loaded('mbstring')) |
|
| 857 | - return throw_error($txt['install_no_mbstring']); |
|
| 913 | + if (!extension_loaded('mbstring')) { |
|
| 914 | + return throw_error($txt['install_no_mbstring']); |
|
| 915 | + } |
|
| 858 | 916 | |
| 859 | 917 | // Check for https stream support. |
| 860 | 918 | $supported_streams = stream_get_wrappers(); |
| 861 | - if (!in_array('https', $supported_streams)) |
|
| 862 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 919 | + if (!in_array('https', $supported_streams)) { |
|
| 920 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 921 | + } |
|
| 863 | 922 | |
| 864 | 923 | // Either we're logged in or we're going to present the login. |
| 865 | - if (checkLogin()) |
|
| 866 | - return true; |
|
| 924 | + if (checkLogin()) { |
|
| 925 | + return true; |
|
| 926 | + } |
|
| 867 | 927 | |
| 868 | 928 | $upcontext += createToken('login'); |
| 869 | 929 | |
@@ -877,15 +937,17 @@ discard block |
||
| 877 | 937 | global $smcFunc, $db_type, $support_js; |
| 878 | 938 | |
| 879 | 939 | // Don't bother if the security is disabled. |
| 880 | - if ($disable_security) |
|
| 881 | - return true; |
|
| 940 | + if ($disable_security) { |
|
| 941 | + return true; |
|
| 942 | + } |
|
| 882 | 943 | |
| 883 | 944 | // Are we trying to login? |
| 884 | 945 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 885 | 946 | { |
| 886 | 947 | // If we've disabled security pick a suitable name! |
| 887 | - if (empty($_POST['user'])) |
|
| 888 | - $_POST['user'] = 'Administrator'; |
|
| 948 | + if (empty($_POST['user'])) { |
|
| 949 | + $_POST['user'] = 'Administrator'; |
|
| 950 | + } |
|
| 889 | 951 | |
| 890 | 952 | // Before 2.0 these column names were different! |
| 891 | 953 | $oldDB = false; |
@@ -900,16 +962,17 @@ discard block |
||
| 900 | 962 | 'db_error_skip' => true, |
| 901 | 963 | ) |
| 902 | 964 | ); |
| 903 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 904 | - $oldDB = true; |
|
| 965 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 966 | + $oldDB = true; |
|
| 967 | + } |
|
| 905 | 968 | $smcFunc['db_free_result']($request); |
| 906 | 969 | } |
| 907 | 970 | |
| 908 | 971 | // Get what we believe to be their details. |
| 909 | 972 | if (!$disable_security) |
| 910 | 973 | { |
| 911 | - if ($oldDB) |
|
| 912 | - $request = $smcFunc['db_query']('', ' |
|
| 974 | + if ($oldDB) { |
|
| 975 | + $request = $smcFunc['db_query']('', ' |
|
| 913 | 976 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 914 | 977 | additionalGroups AS additional_groups, lngfile |
| 915 | 978 | FROM {db_prefix}members |
@@ -919,8 +982,8 @@ discard block |
||
| 919 | 982 | 'db_error_skip' => true, |
| 920 | 983 | ) |
| 921 | 984 | ); |
| 922 | - else |
|
| 923 | - $request = $smcFunc['db_query']('', ' |
|
| 985 | + } else { |
|
| 986 | + $request = $smcFunc['db_query']('', ' |
|
| 924 | 987 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 925 | 988 | FROM {db_prefix}members |
| 926 | 989 | WHERE member_name = {string:member_name}', |
@@ -929,6 +992,7 @@ discard block |
||
| 929 | 992 | 'db_error_skip' => true, |
| 930 | 993 | ) |
| 931 | 994 | ); |
| 995 | + } |
|
| 932 | 996 | if ($smcFunc['db_num_rows']($request) != 0) |
| 933 | 997 | { |
| 934 | 998 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -936,16 +1000,17 @@ discard block |
||
| 936 | 1000 | $groups = explode(',', $addGroups); |
| 937 | 1001 | $groups[] = $id_group; |
| 938 | 1002 | |
| 939 | - foreach ($groups as $k => $v) |
|
| 940 | - $groups[$k] = (int) $v; |
|
| 1003 | + foreach ($groups as $k => $v) { |
|
| 1004 | + $groups[$k] = (int) $v; |
|
| 1005 | + } |
|
| 941 | 1006 | |
| 942 | 1007 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 943 | 1008 | |
| 944 | 1009 | // We don't use "-utf8" anymore... |
| 945 | 1010 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 1011 | + } else { |
|
| 1012 | + $upcontext['username_incorrect'] = true; |
|
| 946 | 1013 | } |
| 947 | - else |
|
| 948 | - $upcontext['username_incorrect'] = true; |
|
| 949 | 1014 | |
| 950 | 1015 | $smcFunc['db_free_result']($request); |
| 951 | 1016 | } |
@@ -956,13 +1021,14 @@ discard block |
||
| 956 | 1021 | { |
| 957 | 1022 | $upcontext['upgrade_status']['js'] = 1; |
| 958 | 1023 | $support_js = 1; |
| 1024 | + } else { |
|
| 1025 | + $support_js = 0; |
|
| 959 | 1026 | } |
| 960 | - else |
|
| 961 | - $support_js = 0; |
|
| 962 | 1027 | |
| 963 | 1028 | // Note down the version we are coming from. |
| 964 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 965 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1029 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 1030 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1031 | + } |
|
| 966 | 1032 | |
| 967 | 1033 | // Didn't get anywhere? |
| 968 | 1034 | 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'])) |
@@ -996,15 +1062,15 @@ discard block |
||
| 996 | 1062 | 'db_error_skip' => true, |
| 997 | 1063 | ) |
| 998 | 1064 | ); |
| 999 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1000 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1065 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1066 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1067 | + } |
|
| 1001 | 1068 | $smcFunc['db_free_result']($request); |
| 1002 | 1069 | } |
| 1003 | 1070 | |
| 1004 | 1071 | $upcontext['user']['id'] = $id_member; |
| 1005 | 1072 | $upcontext['user']['name'] = $name; |
| 1006 | - } |
|
| 1007 | - else |
|
| 1073 | + } else |
|
| 1008 | 1074 | { |
| 1009 | 1075 | $upcontext['user']['id'] = 1; |
| 1010 | 1076 | $upcontext['user']['name'] = 'Administrator'; |
@@ -1020,11 +1086,11 @@ discard block |
||
| 1020 | 1086 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 1021 | 1087 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 1022 | 1088 | |
| 1023 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 1024 | - $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'] . '.'; |
|
| 1025 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 1026 | - $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'] . '.'; |
|
| 1027 | - else |
|
| 1089 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 1090 | + $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'] . '.'; |
|
| 1091 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 1092 | + $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'] . '.'; |
|
| 1093 | + } else |
|
| 1028 | 1094 | { |
| 1029 | 1095 | // Set this as the new language. |
| 1030 | 1096 | $upcontext['language'] = $user_language; |
@@ -1068,8 +1134,9 @@ discard block |
||
| 1068 | 1134 | unset($member_columns); |
| 1069 | 1135 | |
| 1070 | 1136 | // If we've not submitted then we're done. |
| 1071 | - if (empty($_POST['upcont'])) |
|
| 1072 | - return false; |
|
| 1137 | + if (empty($_POST['upcont'])) { |
|
| 1138 | + return false; |
|
| 1139 | + } |
|
| 1073 | 1140 | |
| 1074 | 1141 | // Firstly, if they're enabling SM stat collection just do it. |
| 1075 | 1142 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -1089,16 +1156,17 @@ discard block |
||
| 1089 | 1156 | fwrite($fp, $out); |
| 1090 | 1157 | |
| 1091 | 1158 | $return_data = ''; |
| 1092 | - while (!feof($fp)) |
|
| 1093 | - $return_data .= fgets($fp, 128); |
|
| 1159 | + while (!feof($fp)) { |
|
| 1160 | + $return_data .= fgets($fp, 128); |
|
| 1161 | + } |
|
| 1094 | 1162 | |
| 1095 | 1163 | fclose($fp); |
| 1096 | 1164 | |
| 1097 | 1165 | // Get the unique site ID. |
| 1098 | 1166 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1099 | 1167 | |
| 1100 | - if (!empty($ID[1])) |
|
| 1101 | - $smcFunc['db_insert']('replace', |
|
| 1168 | + if (!empty($ID[1])) { |
|
| 1169 | + $smcFunc['db_insert']('replace', |
|
| 1102 | 1170 | $db_prefix . 'settings', |
| 1103 | 1171 | array('variable' => 'string', 'value' => 'string'), |
| 1104 | 1172 | array( |
@@ -1107,9 +1175,9 @@ discard block |
||
| 1107 | 1175 | ), |
| 1108 | 1176 | array('variable') |
| 1109 | 1177 | ); |
| 1178 | + } |
|
| 1110 | 1179 | } |
| 1111 | - } |
|
| 1112 | - else |
|
| 1180 | + } else |
|
| 1113 | 1181 | { |
| 1114 | 1182 | $smcFunc['db_insert']('replace', |
| 1115 | 1183 | $db_prefix . 'settings', |
@@ -1120,8 +1188,8 @@ discard block |
||
| 1120 | 1188 | } |
| 1121 | 1189 | } |
| 1122 | 1190 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1123 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1124 | - $smcFunc['db_query']('', ' |
|
| 1191 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1192 | + $smcFunc['db_query']('', ' |
|
| 1125 | 1193 | DELETE FROM {db_prefix}settings |
| 1126 | 1194 | WHERE variable = {string:enable_sm_stats}', |
| 1127 | 1195 | array( |
@@ -1129,6 +1197,7 @@ discard block |
||
| 1129 | 1197 | 'db_error_skip' => true, |
| 1130 | 1198 | ) |
| 1131 | 1199 | ); |
| 1200 | + } |
|
| 1132 | 1201 | |
| 1133 | 1202 | // Deleting old karma stuff? |
| 1134 | 1203 | if (!empty($_POST['delete_karma'])) |
@@ -1143,20 +1212,22 @@ discard block |
||
| 1143 | 1212 | ); |
| 1144 | 1213 | |
| 1145 | 1214 | // Cleaning up old karma member settings. |
| 1146 | - if ($upcontext['karma_installed']['good']) |
|
| 1147 | - $smcFunc['db_query']('', ' |
|
| 1215 | + if ($upcontext['karma_installed']['good']) { |
|
| 1216 | + $smcFunc['db_query']('', ' |
|
| 1148 | 1217 | ALTER TABLE {db_prefix}members |
| 1149 | 1218 | DROP karma_good', |
| 1150 | 1219 | array() |
| 1151 | 1220 | ); |
| 1221 | + } |
|
| 1152 | 1222 | |
| 1153 | 1223 | // Does karma bad was enable? |
| 1154 | - if ($upcontext['karma_installed']['bad']) |
|
| 1155 | - $smcFunc['db_query']('', ' |
|
| 1224 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1225 | + $smcFunc['db_query']('', ' |
|
| 1156 | 1226 | ALTER TABLE {db_prefix}members |
| 1157 | 1227 | DROP karma_bad', |
| 1158 | 1228 | array() |
| 1159 | 1229 | ); |
| 1230 | + } |
|
| 1160 | 1231 | |
| 1161 | 1232 | // Cleaning up old karma permissions. |
| 1162 | 1233 | $smcFunc['db_query']('', ' |
@@ -1174,32 +1245,37 @@ discard block |
||
| 1174 | 1245 | } |
| 1175 | 1246 | |
| 1176 | 1247 | // Emptying the error log? |
| 1177 | - if (!empty($_POST['empty_error'])) |
|
| 1178 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1248 | + if (!empty($_POST['empty_error'])) { |
|
| 1249 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1179 | 1250 | TRUNCATE {db_prefix}log_errors', |
| 1180 | 1251 | array( |
| 1181 | 1252 | ) |
| 1182 | 1253 | ); |
| 1254 | + } |
|
| 1183 | 1255 | |
| 1184 | 1256 | $changes = array(); |
| 1185 | 1257 | |
| 1186 | 1258 | // Add proxy settings. |
| 1187 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1188 | - $changes += array( |
|
| 1259 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1260 | + $changes += array( |
|
| 1189 | 1261 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1190 | 1262 | 'image_proxy_maxsize' => 5190, |
| 1191 | 1263 | 'image_proxy_enabled' => 0, |
| 1192 | 1264 | ); |
| 1265 | + } |
|
| 1193 | 1266 | |
| 1194 | 1267 | // If $boardurl reflects https, set force_ssl |
| 1195 | - if (!function_exists('cache_put_data')) |
|
| 1196 | - require_once($sourcedir . '/Load.php'); |
|
| 1197 | - if (stripos($boardurl, 'https://') !== false) |
|
| 1198 | - updateSettings(array('force_ssl' => '1')); |
|
| 1268 | + if (!function_exists('cache_put_data')) { |
|
| 1269 | + require_once($sourcedir . '/Load.php'); |
|
| 1270 | + } |
|
| 1271 | + if (stripos($boardurl, 'https://') !== false) { |
|
| 1272 | + updateSettings(array('force_ssl' => '1')); |
|
| 1273 | + } |
|
| 1199 | 1274 | |
| 1200 | 1275 | // If we're overriding the language follow it through. |
| 1201 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1202 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1276 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1277 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1278 | + } |
|
| 1203 | 1279 | |
| 1204 | 1280 | if (!empty($_POST['maint'])) |
| 1205 | 1281 | { |
@@ -1211,26 +1287,29 @@ discard block |
||
| 1211 | 1287 | { |
| 1212 | 1288 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1213 | 1289 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1214 | - } |
|
| 1215 | - else |
|
| 1290 | + } else |
|
| 1216 | 1291 | { |
| 1217 | 1292 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1218 | 1293 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1219 | 1294 | } |
| 1220 | 1295 | } |
| 1221 | 1296 | |
| 1222 | - if ($command_line) |
|
| 1223 | - echo ' * Updating Settings.php...'; |
|
| 1297 | + if ($command_line) { |
|
| 1298 | + echo ' * Updating Settings.php...'; |
|
| 1299 | + } |
|
| 1224 | 1300 | |
| 1225 | 1301 | // Fix some old paths. |
| 1226 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1227 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1302 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1303 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1304 | + } |
|
| 1228 | 1305 | |
| 1229 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1230 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1306 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1307 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1308 | + } |
|
| 1231 | 1309 | |
| 1232 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1233 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1310 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1311 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1312 | + } |
|
| 1234 | 1313 | |
| 1235 | 1314 | // If they have a "host:port" setup for the host, split that into separate values |
| 1236 | 1315 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1241,32 +1320,36 @@ discard block |
||
| 1241 | 1320 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1242 | 1321 | |
| 1243 | 1322 | // Only set this if we're not using the default port |
| 1244 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1245 | - $changes['db_port'] = (int) $db_port; |
|
| 1246 | - } |
|
| 1247 | - elseif (!empty($db_port)) |
|
| 1323 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1324 | + $changes['db_port'] = (int) $db_port; |
|
| 1325 | + } |
|
| 1326 | + } elseif (!empty($db_port)) |
|
| 1248 | 1327 | { |
| 1249 | 1328 | // If db_port is set and is the same as the default, set it to '' |
| 1250 | 1329 | if ($db_type == 'mysql') |
| 1251 | 1330 | { |
| 1252 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1253 | - $changes['db_port'] = '\'\''; |
|
| 1254 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1255 | - $changes['db_port'] = '\'\''; |
|
| 1331 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1332 | + $changes['db_port'] = '\'\''; |
|
| 1333 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1334 | + $changes['db_port'] = '\'\''; |
|
| 1335 | + } |
|
| 1256 | 1336 | } |
| 1257 | 1337 | } |
| 1258 | 1338 | |
| 1259 | 1339 | // Maybe we haven't had this option yet? |
| 1260 | - if (empty($packagesdir)) |
|
| 1261 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1340 | + if (empty($packagesdir)) { |
|
| 1341 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1342 | + } |
|
| 1262 | 1343 | |
| 1263 | 1344 | // Add support for $tasksdir var. |
| 1264 | - if (empty($tasksdir)) |
|
| 1265 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1345 | + if (empty($tasksdir)) { |
|
| 1346 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1347 | + } |
|
| 1266 | 1348 | |
| 1267 | 1349 | // Make sure we fix the language as well. |
| 1268 | - if (stristr($language, '-utf8')) |
|
| 1269 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1350 | + if (stristr($language, '-utf8')) { |
|
| 1351 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1352 | + } |
|
| 1270 | 1353 | |
| 1271 | 1354 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1272 | 1355 | |
@@ -1277,8 +1360,9 @@ discard block |
||
| 1277 | 1360 | // Tell Settings.php to store db_last_error.php in the cache |
| 1278 | 1361 | move_db_last_error_to_cachedir(); |
| 1279 | 1362 | |
| 1280 | - if ($command_line) |
|
| 1281 | - echo ' Successful.' . "\n"; |
|
| 1363 | + if ($command_line) { |
|
| 1364 | + echo ' Successful.' . "\n"; |
|
| 1365 | + } |
|
| 1282 | 1366 | |
| 1283 | 1367 | // Are we doing debug? |
| 1284 | 1368 | if (isset($_POST['debug'])) |
@@ -1288,8 +1372,9 @@ discard block |
||
| 1288 | 1372 | } |
| 1289 | 1373 | |
| 1290 | 1374 | // If we're not backing up then jump one. |
| 1291 | - if (empty($_POST['backup'])) |
|
| 1292 | - $upcontext['current_step']++; |
|
| 1375 | + if (empty($_POST['backup'])) { |
|
| 1376 | + $upcontext['current_step']++; |
|
| 1377 | + } |
|
| 1293 | 1378 | |
| 1294 | 1379 | // If we've got here then let's proceed to the next step! |
| 1295 | 1380 | return true; |
@@ -1304,8 +1389,9 @@ discard block |
||
| 1304 | 1389 | $upcontext['page_title'] = $txt['backup_database']; |
| 1305 | 1390 | |
| 1306 | 1391 | // Done it already - js wise? |
| 1307 | - if (!empty($_POST['backup_done'])) |
|
| 1308 | - return true; |
|
| 1392 | + if (!empty($_POST['backup_done'])) { |
|
| 1393 | + return true; |
|
| 1394 | + } |
|
| 1309 | 1395 | |
| 1310 | 1396 | // Some useful stuff here. |
| 1311 | 1397 | db_extend(); |
@@ -1319,9 +1405,10 @@ discard block |
||
| 1319 | 1405 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1320 | 1406 | |
| 1321 | 1407 | $table_names = array(); |
| 1322 | - foreach ($tables as $table) |
|
| 1323 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1408 | + foreach ($tables as $table) { |
|
| 1409 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1324 | 1410 | $table_names[] = $table; |
| 1411 | + } |
|
| 1325 | 1412 | |
| 1326 | 1413 | $upcontext['table_count'] = count($table_names); |
| 1327 | 1414 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1331,12 +1418,14 @@ discard block |
||
| 1331 | 1418 | $file_steps = $upcontext['table_count']; |
| 1332 | 1419 | |
| 1333 | 1420 | // What ones have we already done? |
| 1334 | - foreach ($table_names as $id => $table) |
|
| 1335 | - if ($id < $_GET['substep']) |
|
| 1421 | + foreach ($table_names as $id => $table) { |
|
| 1422 | + if ($id < $_GET['substep']) |
|
| 1336 | 1423 | $upcontext['previous_tables'][] = $table; |
| 1424 | + } |
|
| 1337 | 1425 | |
| 1338 | - if ($command_line) |
|
| 1339 | - echo 'Backing Up Tables.'; |
|
| 1426 | + if ($command_line) { |
|
| 1427 | + echo 'Backing Up Tables.'; |
|
| 1428 | + } |
|
| 1340 | 1429 | |
| 1341 | 1430 | // If we don't support javascript we backup here. |
| 1342 | 1431 | if (!$support_js || isset($_GET['xml'])) |
@@ -1355,8 +1444,9 @@ discard block |
||
| 1355 | 1444 | backupTable($table_names[$substep]); |
| 1356 | 1445 | |
| 1357 | 1446 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1358 | - if (isset($_GET['xml'])) |
|
| 1359 | - return upgradeExit(); |
|
| 1447 | + if (isset($_GET['xml'])) { |
|
| 1448 | + return upgradeExit(); |
|
| 1449 | + } |
|
| 1360 | 1450 | } |
| 1361 | 1451 | |
| 1362 | 1452 | if ($command_line) |
@@ -1389,9 +1479,10 @@ discard block |
||
| 1389 | 1479 | |
| 1390 | 1480 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1391 | 1481 | |
| 1392 | - if ($command_line) |
|
| 1393 | - echo ' done.'; |
|
| 1394 | -} |
|
| 1482 | + if ($command_line) { |
|
| 1483 | + echo ' done.'; |
|
| 1484 | + } |
|
| 1485 | + } |
|
| 1395 | 1486 | |
| 1396 | 1487 | // Step 2: Everything. |
| 1397 | 1488 | function DatabaseChanges() |
@@ -1400,8 +1491,9 @@ discard block |
||
| 1400 | 1491 | global $upcontext, $support_js, $db_type; |
| 1401 | 1492 | |
| 1402 | 1493 | // Have we just completed this? |
| 1403 | - if (!empty($_POST['database_done'])) |
|
| 1404 | - return true; |
|
| 1494 | + if (!empty($_POST['database_done'])) { |
|
| 1495 | + return true; |
|
| 1496 | + } |
|
| 1405 | 1497 | |
| 1406 | 1498 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1407 | 1499 | $upcontext['page_title'] = $txt['database_changes']; |
@@ -1416,15 +1508,16 @@ discard block |
||
| 1416 | 1508 | ); |
| 1417 | 1509 | |
| 1418 | 1510 | // How many files are there in total? |
| 1419 | - if (isset($_GET['filecount'])) |
|
| 1420 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1421 | - else |
|
| 1511 | + if (isset($_GET['filecount'])) { |
|
| 1512 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1513 | + } else |
|
| 1422 | 1514 | { |
| 1423 | 1515 | $upcontext['file_count'] = 0; |
| 1424 | 1516 | foreach ($files as $file) |
| 1425 | 1517 | { |
| 1426 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1427 | - $upcontext['file_count']++; |
|
| 1518 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1519 | + $upcontext['file_count']++; |
|
| 1520 | + } |
|
| 1428 | 1521 | } |
| 1429 | 1522 | } |
| 1430 | 1523 | |
@@ -1434,9 +1527,9 @@ discard block |
||
| 1434 | 1527 | $upcontext['cur_file_num'] = 0; |
| 1435 | 1528 | foreach ($files as $file) |
| 1436 | 1529 | { |
| 1437 | - if ($did_not_do) |
|
| 1438 | - $did_not_do--; |
|
| 1439 | - else |
|
| 1530 | + if ($did_not_do) { |
|
| 1531 | + $did_not_do--; |
|
| 1532 | + } else |
|
| 1440 | 1533 | { |
| 1441 | 1534 | $upcontext['cur_file_num']++; |
| 1442 | 1535 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1463,12 +1556,13 @@ discard block |
||
| 1463 | 1556 | // Flag to move on to the next. |
| 1464 | 1557 | $upcontext['completed_step'] = true; |
| 1465 | 1558 | // Did we complete the whole file? |
| 1466 | - if ($nextFile) |
|
| 1467 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1559 | + if ($nextFile) { |
|
| 1560 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1561 | + } |
|
| 1468 | 1562 | return upgradeExit(); |
| 1563 | + } elseif ($support_js) { |
|
| 1564 | + break; |
|
| 1469 | 1565 | } |
| 1470 | - elseif ($support_js) |
|
| 1471 | - break; |
|
| 1472 | 1566 | } |
| 1473 | 1567 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1474 | 1568 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1494,8 +1588,9 @@ discard block |
||
| 1494 | 1588 | global $user_info, $maintenance, $smcFunc, $db_type, $txt, $settings; |
| 1495 | 1589 | |
| 1496 | 1590 | // Now it's nice to have some of the basic SMF source files. |
| 1497 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1498 | - redirectLocation('&ssi=1'); |
|
| 1591 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1592 | + redirectLocation('&ssi=1'); |
|
| 1593 | + } |
|
| 1499 | 1594 | |
| 1500 | 1595 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1501 | 1596 | $upcontext['page_title'] = $txt['upgrade_complete']; |
@@ -1511,14 +1606,16 @@ discard block |
||
| 1511 | 1606 | // Are we in maintenance mode? |
| 1512 | 1607 | if (isset($upcontext['user']['main'])) |
| 1513 | 1608 | { |
| 1514 | - if ($command_line) |
|
| 1515 | - echo ' * '; |
|
| 1609 | + if ($command_line) { |
|
| 1610 | + echo ' * '; |
|
| 1611 | + } |
|
| 1516 | 1612 | $upcontext['removed_maintenance'] = true; |
| 1517 | 1613 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1518 | 1614 | } |
| 1519 | 1615 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1520 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1521 | - $changes['maintenance'] = 1; |
|
| 1616 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1617 | + $changes['maintenance'] = 1; |
|
| 1618 | + } |
|
| 1522 | 1619 | |
| 1523 | 1620 | // Wipe this out... |
| 1524 | 1621 | $upcontext['user'] = array(); |
@@ -1533,21 +1630,23 @@ discard block |
||
| 1533 | 1630 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1534 | 1631 | |
| 1535 | 1632 | // Now is the perfect time to fetch the SM files. |
| 1536 | - if ($command_line) |
|
| 1537 | - cli_scheduled_fetchSMfiles(); |
|
| 1538 | - else |
|
| 1633 | + if ($command_line) { |
|
| 1634 | + cli_scheduled_fetchSMfiles(); |
|
| 1635 | + } else |
|
| 1539 | 1636 | { |
| 1540 | 1637 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1541 | 1638 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
| 1542 | 1639 | scheduled_fetchSMfiles(); // Now go get those files! |
| 1543 | 1640 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
| 1544 | - if (httpsOn()) |
|
| 1545 | - $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
| 1641 | + if (httpsOn()) { |
|
| 1642 | + $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
| 1643 | + } |
|
| 1546 | 1644 | } |
| 1547 | 1645 | |
| 1548 | 1646 | // Log what we've done. |
| 1549 | - if (empty($user_info['id'])) |
|
| 1550 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1647 | + if (empty($user_info['id'])) { |
|
| 1648 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1649 | + } |
|
| 1551 | 1650 | |
| 1552 | 1651 | // Log the action manually, so CLI still works. |
| 1553 | 1652 | $smcFunc['db_insert']('', |
@@ -1566,8 +1665,9 @@ discard block |
||
| 1566 | 1665 | |
| 1567 | 1666 | // Save the current database version. |
| 1568 | 1667 | $server_version = $smcFunc['db_server_info'](); |
| 1569 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1570 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1668 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1669 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1670 | + } |
|
| 1571 | 1671 | |
| 1572 | 1672 | if ($command_line) |
| 1573 | 1673 | { |
@@ -1579,8 +1679,9 @@ discard block |
||
| 1579 | 1679 | |
| 1580 | 1680 | // Make sure it says we're done. |
| 1581 | 1681 | $upcontext['overall_percent'] = 100; |
| 1582 | - if (isset($upcontext['step_progress'])) |
|
| 1583 | - unset($upcontext['step_progress']); |
|
| 1682 | + if (isset($upcontext['step_progress'])) { |
|
| 1683 | + unset($upcontext['step_progress']); |
|
| 1684 | + } |
|
| 1584 | 1685 | |
| 1585 | 1686 | $_GET['substep'] = 0; |
| 1586 | 1687 | return false; |
@@ -1591,8 +1692,9 @@ discard block |
||
| 1591 | 1692 | { |
| 1592 | 1693 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1593 | 1694 | |
| 1594 | - if (empty($modSettings['time_format'])) |
|
| 1595 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1695 | + if (empty($modSettings['time_format'])) { |
|
| 1696 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1697 | + } |
|
| 1596 | 1698 | |
| 1597 | 1699 | // What files do we want to get |
| 1598 | 1700 | $request = $smcFunc['db_query']('', ' |
@@ -1626,8 +1728,9 @@ discard block |
||
| 1626 | 1728 | $file_data = fetch_web_data($url); |
| 1627 | 1729 | |
| 1628 | 1730 | // If we got an error - give up - the site might be down. |
| 1629 | - if ($file_data === false) |
|
| 1630 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1731 | + if ($file_data === false) { |
|
| 1732 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1733 | + } |
|
| 1631 | 1734 | |
| 1632 | 1735 | // Save the file to the database. |
| 1633 | 1736 | $smcFunc['db_query']('substring', ' |
@@ -1669,8 +1772,9 @@ discard block |
||
| 1669 | 1772 | $themeData = array(); |
| 1670 | 1773 | foreach ($values as $variable => $value) |
| 1671 | 1774 | { |
| 1672 | - if (!isset($value) || $value === null) |
|
| 1673 | - $value = 0; |
|
| 1775 | + if (!isset($value) || $value === null) { |
|
| 1776 | + $value = 0; |
|
| 1777 | + } |
|
| 1674 | 1778 | |
| 1675 | 1779 | $themeData[] = array(0, 1, $variable, $value); |
| 1676 | 1780 | } |
@@ -1699,8 +1803,9 @@ discard block |
||
| 1699 | 1803 | |
| 1700 | 1804 | foreach ($values as $variable => $value) |
| 1701 | 1805 | { |
| 1702 | - if (empty($modSettings[$value[0]])) |
|
| 1703 | - continue; |
|
| 1806 | + if (empty($modSettings[$value[0]])) { |
|
| 1807 | + continue; |
|
| 1808 | + } |
|
| 1704 | 1809 | |
| 1705 | 1810 | $smcFunc['db_query']('', ' |
| 1706 | 1811 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1786,19 +1891,21 @@ discard block |
||
| 1786 | 1891 | set_error_handler( |
| 1787 | 1892 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1788 | 1893 | { |
| 1789 | - if ($support_js) |
|
| 1790 | - return true; |
|
| 1791 | - else |
|
| 1792 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1894 | + if ($support_js) { |
|
| 1895 | + return true; |
|
| 1896 | + } else { |
|
| 1897 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1898 | + } |
|
| 1793 | 1899 | } |
| 1794 | 1900 | ); |
| 1795 | 1901 | |
| 1796 | 1902 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1797 | 1903 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1798 | - if ($db_type == 'mysql') |
|
| 1799 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1800 | - else |
|
| 1801 | - $db_collation = ''; |
|
| 1904 | + if ($db_type == 'mysql') { |
|
| 1905 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1906 | + } else { |
|
| 1907 | + $db_collation = ''; |
|
| 1908 | + } |
|
| 1802 | 1909 | |
| 1803 | 1910 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1804 | 1911 | |
@@ -1810,8 +1917,9 @@ discard block |
||
| 1810 | 1917 | $last_step = ''; |
| 1811 | 1918 | |
| 1812 | 1919 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1813 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1814 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1920 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1921 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1922 | + } |
|
| 1815 | 1923 | |
| 1816 | 1924 | // Count the total number of steps within this file - for progress. |
| 1817 | 1925 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1831,15 +1939,18 @@ discard block |
||
| 1831 | 1939 | $do_current = $substep >= $_GET['substep']; |
| 1832 | 1940 | |
| 1833 | 1941 | // Get rid of any comments in the beginning of the line... |
| 1834 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1835 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1942 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1943 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1944 | + } |
|
| 1836 | 1945 | |
| 1837 | 1946 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1838 | - if ($is_debug && !$support_js && $command_line) |
|
| 1839 | - flush(); |
|
| 1947 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1948 | + flush(); |
|
| 1949 | + } |
|
| 1840 | 1950 | |
| 1841 | - if (trim($line) === '') |
|
| 1842 | - continue; |
|
| 1951 | + if (trim($line) === '') { |
|
| 1952 | + continue; |
|
| 1953 | + } |
|
| 1843 | 1954 | |
| 1844 | 1955 | if (trim(substr($line, 0, 3)) === '---') |
| 1845 | 1956 | { |
@@ -1849,8 +1960,9 @@ discard block |
||
| 1849 | 1960 | if (trim($current_data) != '' && $type !== '}') |
| 1850 | 1961 | { |
| 1851 | 1962 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1852 | - if ($command_line) |
|
| 1853 | - echo $upcontext['error_message']; |
|
| 1963 | + if ($command_line) { |
|
| 1964 | + echo $upcontext['error_message']; |
|
| 1965 | + } |
|
| 1854 | 1966 | } |
| 1855 | 1967 | |
| 1856 | 1968 | if ($type == ' ') |
@@ -1868,17 +1980,18 @@ discard block |
||
| 1868 | 1980 | if ($do_current) |
| 1869 | 1981 | { |
| 1870 | 1982 | $upcontext['actioned_items'][] = $last_step; |
| 1871 | - if ($command_line) |
|
| 1872 | - echo ' * '; |
|
| 1983 | + if ($command_line) { |
|
| 1984 | + echo ' * '; |
|
| 1985 | + } |
|
| 1873 | 1986 | } |
| 1874 | - } |
|
| 1875 | - elseif ($type == '#') |
|
| 1987 | + } elseif ($type == '#') |
|
| 1876 | 1988 | { |
| 1877 | 1989 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1878 | 1990 | |
| 1879 | 1991 | $upcontext['current_debug_item_num']++; |
| 1880 | - if (trim($line) != '---#') |
|
| 1881 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1992 | + if (trim($line) != '---#') { |
|
| 1993 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1994 | + } |
|
| 1882 | 1995 | |
| 1883 | 1996 | // Have we already done something? |
| 1884 | 1997 | if (isset($_GET['xml']) && $done_something) |
@@ -1889,34 +2002,36 @@ discard block |
||
| 1889 | 2002 | |
| 1890 | 2003 | if ($do_current) |
| 1891 | 2004 | { |
| 1892 | - if (trim($line) == '---#' && $command_line) |
|
| 1893 | - echo ' done.', $endl; |
|
| 1894 | - elseif ($command_line) |
|
| 1895 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1896 | - elseif (trim($line) != '---#') |
|
| 2005 | + if (trim($line) == '---#' && $command_line) { |
|
| 2006 | + echo ' done.', $endl; |
|
| 2007 | + } elseif ($command_line) { |
|
| 2008 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 2009 | + } elseif (trim($line) != '---#') |
|
| 1897 | 2010 | { |
| 1898 | - if ($is_debug) |
|
| 1899 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2011 | + if ($is_debug) { |
|
| 2012 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2013 | + } |
|
| 1900 | 2014 | } |
| 1901 | 2015 | } |
| 1902 | 2016 | |
| 1903 | 2017 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1904 | 2018 | { |
| 1905 | - if ($command_line) |
|
| 1906 | - echo ' * '; |
|
| 1907 | - else |
|
| 1908 | - $upcontext['actioned_items'][] = $last_step; |
|
| 2019 | + if ($command_line) { |
|
| 2020 | + echo ' * '; |
|
| 2021 | + } else { |
|
| 2022 | + $upcontext['actioned_items'][] = $last_step; |
|
| 2023 | + } |
|
| 1909 | 2024 | } |
| 1910 | 2025 | |
| 1911 | 2026 | // Small step - only if we're actually doing stuff. |
| 1912 | - if ($do_current) |
|
| 1913 | - nextSubstep(++$substep); |
|
| 1914 | - else |
|
| 1915 | - $substep++; |
|
| 1916 | - } |
|
| 1917 | - elseif ($type == '{') |
|
| 1918 | - $current_type = 'code'; |
|
| 1919 | - elseif ($type == '}') |
|
| 2027 | + if ($do_current) { |
|
| 2028 | + nextSubstep(++$substep); |
|
| 2029 | + } else { |
|
| 2030 | + $substep++; |
|
| 2031 | + } |
|
| 2032 | + } elseif ($type == '{') { |
|
| 2033 | + $current_type = 'code'; |
|
| 2034 | + } elseif ($type == '}') |
|
| 1920 | 2035 | { |
| 1921 | 2036 | $current_type = 'sql'; |
| 1922 | 2037 | |
@@ -1929,8 +2044,9 @@ discard block |
||
| 1929 | 2044 | if (eval('global $db_prefix, $modSettings, $smcFunc, $txt; ' . $current_data) === false) |
| 1930 | 2045 | { |
| 1931 | 2046 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1932 | - if ($command_line) |
|
| 1933 | - echo $upcontext['error_message']; |
|
| 2047 | + if ($command_line) { |
|
| 2048 | + echo $upcontext['error_message']; |
|
| 2049 | + } |
|
| 1934 | 2050 | } |
| 1935 | 2051 | |
| 1936 | 2052 | // Done with code! |
@@ -2018,8 +2134,9 @@ discard block |
||
| 2018 | 2134 | $db_unbuffered = false; |
| 2019 | 2135 | |
| 2020 | 2136 | // Failure?! |
| 2021 | - if ($result !== false) |
|
| 2022 | - return $result; |
|
| 2137 | + if ($result !== false) { |
|
| 2138 | + return $result; |
|
| 2139 | + } |
|
| 2023 | 2140 | |
| 2024 | 2141 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 2025 | 2142 | // If MySQL we do something more clever. |
@@ -2047,54 +2164,61 @@ discard block |
||
| 2047 | 2164 | { |
| 2048 | 2165 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 2049 | 2166 | $result = mysqli_query($db_connection, $string); |
| 2050 | - if ($result !== false) |
|
| 2051 | - return $result; |
|
| 2167 | + if ($result !== false) { |
|
| 2168 | + return $result; |
|
| 2169 | + } |
|
| 2052 | 2170 | } |
| 2053 | - } |
|
| 2054 | - elseif ($mysqli_errno == 2013) |
|
| 2171 | + } elseif ($mysqli_errno == 2013) |
|
| 2055 | 2172 | { |
| 2056 | 2173 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 2057 | 2174 | mysqli_select_db($db_connection, $db_name); |
| 2058 | 2175 | if ($db_connection) |
| 2059 | 2176 | { |
| 2060 | 2177 | $result = mysqli_query($db_connection, $string); |
| 2061 | - if ($result !== false) |
|
| 2062 | - return $result; |
|
| 2178 | + if ($result !== false) { |
|
| 2179 | + return $result; |
|
| 2180 | + } |
|
| 2063 | 2181 | } |
| 2064 | 2182 | } |
| 2065 | 2183 | // Duplicate column name... should be okay ;). |
| 2066 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 2067 | - return false; |
|
| 2184 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2185 | + return false; |
|
| 2186 | + } |
|
| 2068 | 2187 | // Duplicate insert... make sure it's the proper type of query ;). |
| 2069 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 2070 | - return false; |
|
| 2188 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2189 | + return false; |
|
| 2190 | + } |
|
| 2071 | 2191 | // Creating an index on a non-existent column. |
| 2072 | - elseif ($mysqli_errno == 1072) |
|
| 2073 | - return false; |
|
| 2074 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 2075 | - return false; |
|
| 2192 | + elseif ($mysqli_errno == 1072) { |
|
| 2193 | + return false; |
|
| 2194 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2195 | + return false; |
|
| 2196 | + } |
|
| 2076 | 2197 | } |
| 2077 | 2198 | // If a table already exists don't go potty. |
| 2078 | 2199 | else |
| 2079 | 2200 | { |
| 2080 | 2201 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 2081 | 2202 | { |
| 2082 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 2083 | - return true; |
|
| 2084 | - } |
|
| 2085 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2203 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2204 | + return true; |
|
| 2205 | + } |
|
| 2206 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2086 | 2207 | { |
| 2087 | - if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) |
|
| 2088 | - return true; |
|
| 2208 | + if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) { |
|
| 2209 | + return true; |
|
| 2210 | + } |
|
| 2089 | 2211 | } |
| 2090 | 2212 | } |
| 2091 | 2213 | |
| 2092 | 2214 | // Get the query string so we pass everything. |
| 2093 | 2215 | $query_string = ''; |
| 2094 | - foreach ($_GET as $k => $v) |
|
| 2095 | - $query_string .= ';' . $k . '=' . $v; |
|
| 2096 | - if (strlen($query_string) != 0) |
|
| 2097 | - $query_string = '?' . substr($query_string, 1); |
|
| 2216 | + foreach ($_GET as $k => $v) { |
|
| 2217 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2218 | + } |
|
| 2219 | + if (strlen($query_string) != 0) { |
|
| 2220 | + $query_string = '?' . substr($query_string, 1); |
|
| 2221 | + } |
|
| 2098 | 2222 | |
| 2099 | 2223 | if ($command_line) |
| 2100 | 2224 | { |
@@ -2149,16 +2273,18 @@ discard block |
||
| 2149 | 2273 | { |
| 2150 | 2274 | $found |= 1; |
| 2151 | 2275 | // Do some checks on the data if we have it set. |
| 2152 | - if (isset($change['col_type'])) |
|
| 2153 | - $found &= $change['col_type'] === $column['type']; |
|
| 2154 | - if (isset($change['null_allowed'])) |
|
| 2155 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2156 | - if (isset($change['default'])) |
|
| 2157 | - $found &= $change['default'] === $column['default']; |
|
| 2276 | + if (isset($change['col_type'])) { |
|
| 2277 | + $found &= $change['col_type'] === $column['type']; |
|
| 2278 | + } |
|
| 2279 | + if (isset($change['null_allowed'])) { |
|
| 2280 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2281 | + } |
|
| 2282 | + if (isset($change['default'])) { |
|
| 2283 | + $found &= $change['default'] === $column['default']; |
|
| 2284 | + } |
|
| 2158 | 2285 | } |
| 2159 | 2286 | } |
| 2160 | - } |
|
| 2161 | - elseif ($change['type'] === 'index') |
|
| 2287 | + } elseif ($change['type'] === 'index') |
|
| 2162 | 2288 | { |
| 2163 | 2289 | $request = upgrade_query(' |
| 2164 | 2290 | SHOW INDEX |
@@ -2167,9 +2293,10 @@ discard block |
||
| 2167 | 2293 | { |
| 2168 | 2294 | $cur_index = array(); |
| 2169 | 2295 | |
| 2170 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2171 | - if ($row['Key_name'] === $change['name']) |
|
| 2296 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2297 | + if ($row['Key_name'] === $change['name']) |
|
| 2172 | 2298 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2299 | + } |
|
| 2173 | 2300 | |
| 2174 | 2301 | ksort($cur_index, SORT_NUMERIC); |
| 2175 | 2302 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2179,14 +2306,17 @@ discard block |
||
| 2179 | 2306 | } |
| 2180 | 2307 | |
| 2181 | 2308 | // If we're trying to add and it's added, we're done. |
| 2182 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2183 | - return true; |
|
| 2309 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2310 | + return true; |
|
| 2311 | + } |
|
| 2184 | 2312 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2185 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2186 | - return true; |
|
| 2313 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2314 | + return true; |
|
| 2315 | + } |
|
| 2187 | 2316 | // Otherwise is it just a test? |
| 2188 | - elseif ($is_test) |
|
| 2189 | - return false; |
|
| 2317 | + elseif ($is_test) { |
|
| 2318 | + return false; |
|
| 2319 | + } |
|
| 2190 | 2320 | |
| 2191 | 2321 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2192 | 2322 | $running = false; |
@@ -2197,8 +2327,9 @@ discard block |
||
| 2197 | 2327 | SHOW FULL PROCESSLIST'); |
| 2198 | 2328 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2199 | 2329 | { |
| 2200 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2201 | - $found = true; |
|
| 2330 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2331 | + $found = true; |
|
| 2332 | + } |
|
| 2202 | 2333 | } |
| 2203 | 2334 | |
| 2204 | 2335 | // Can't find it? Then we need to run it fools! |
@@ -2210,8 +2341,9 @@ discard block |
||
| 2210 | 2341 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2211 | 2342 | ' . $change['text'], true) !== false; |
| 2212 | 2343 | |
| 2213 | - if (!$success) |
|
| 2214 | - return false; |
|
| 2344 | + if (!$success) { |
|
| 2345 | + return false; |
|
| 2346 | + } |
|
| 2215 | 2347 | |
| 2216 | 2348 | // Return |
| 2217 | 2349 | $running = true; |
@@ -2253,8 +2385,9 @@ discard block |
||
| 2253 | 2385 | 'db_error_skip' => true, |
| 2254 | 2386 | ) |
| 2255 | 2387 | ); |
| 2256 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2257 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2388 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2389 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2390 | + } |
|
| 2258 | 2391 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2259 | 2392 | $smcFunc['db_free_result']($request); |
| 2260 | 2393 | |
@@ -2276,18 +2409,19 @@ discard block |
||
| 2276 | 2409 | ) |
| 2277 | 2410 | ); |
| 2278 | 2411 | // No results? Just forget it all together. |
| 2279 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2280 | - unset($table_row['Collation']); |
|
| 2281 | - else |
|
| 2282 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2412 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2413 | + unset($table_row['Collation']); |
|
| 2414 | + } else { |
|
| 2415 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2416 | + } |
|
| 2283 | 2417 | $smcFunc['db_free_result']($request); |
| 2284 | 2418 | } |
| 2285 | 2419 | |
| 2286 | 2420 | if ($column_fix) |
| 2287 | 2421 | { |
| 2288 | 2422 | // Make sure there are no NULL's left. |
| 2289 | - if ($null_fix) |
|
| 2290 | - $smcFunc['db_query']('', ' |
|
| 2423 | + if ($null_fix) { |
|
| 2424 | + $smcFunc['db_query']('', ' |
|
| 2291 | 2425 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2292 | 2426 | SET ' . $change['column'] . ' = {string:default} |
| 2293 | 2427 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2296,6 +2430,7 @@ discard block |
||
| 2296 | 2430 | 'db_error_skip' => true, |
| 2297 | 2431 | ) |
| 2298 | 2432 | ); |
| 2433 | + } |
|
| 2299 | 2434 | |
| 2300 | 2435 | // Do the actual alteration. |
| 2301 | 2436 | $smcFunc['db_query']('', ' |
@@ -2324,8 +2459,9 @@ discard block |
||
| 2324 | 2459 | } |
| 2325 | 2460 | |
| 2326 | 2461 | // Not a column we need to check on? |
| 2327 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2328 | - return; |
|
| 2462 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2463 | + return; |
|
| 2464 | + } |
|
| 2329 | 2465 | |
| 2330 | 2466 | // Break it up you (six|seven). |
| 2331 | 2467 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2344,13 +2480,13 @@ discard block |
||
| 2344 | 2480 | 'new_name' => $temp[2], |
| 2345 | 2481 | )); |
| 2346 | 2482 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2347 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2348 | - return; |
|
| 2483 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2484 | + return; |
|
| 2485 | + } |
|
| 2349 | 2486 | |
| 2350 | 2487 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2351 | 2488 | $smcFunc['db_free_result']($request); |
| 2352 | - } |
|
| 2353 | - else |
|
| 2489 | + } else |
|
| 2354 | 2490 | { |
| 2355 | 2491 | // Do this the old fashion, sure method way. |
| 2356 | 2492 | $request = $smcFunc['db_query']('', ' |
@@ -2361,21 +2497,24 @@ discard block |
||
| 2361 | 2497 | )); |
| 2362 | 2498 | // Mayday! |
| 2363 | 2499 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2364 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2365 | - return; |
|
| 2500 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2501 | + return; |
|
| 2502 | + } |
|
| 2366 | 2503 | |
| 2367 | 2504 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2368 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2369 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2505 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2506 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2370 | 2507 | { |
| 2371 | 2508 | $current_type = $row['Type']; |
| 2509 | + } |
|
| 2372 | 2510 | break; |
| 2373 | 2511 | } |
| 2374 | 2512 | } |
| 2375 | 2513 | |
| 2376 | 2514 | // If this doesn't match, the column may of been altered for a reason. |
| 2377 | - if (trim($current_type) != trim($temp[3])) |
|
| 2378 | - $temp[3] = $current_type; |
|
| 2515 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2516 | + $temp[3] = $current_type; |
|
| 2517 | + } |
|
| 2379 | 2518 | |
| 2380 | 2519 | // Piece this back together. |
| 2381 | 2520 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2387,8 +2526,9 @@ discard block |
||
| 2387 | 2526 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2388 | 2527 | global $step_progress, $is_debug, $upcontext; |
| 2389 | 2528 | |
| 2390 | - if ($_GET['substep'] < $substep) |
|
| 2391 | - $_GET['substep'] = $substep; |
|
| 2529 | + if ($_GET['substep'] < $substep) { |
|
| 2530 | + $_GET['substep'] = $substep; |
|
| 2531 | + } |
|
| 2392 | 2532 | |
| 2393 | 2533 | if ($command_line) |
| 2394 | 2534 | { |
@@ -2401,29 +2541,33 @@ discard block |
||
| 2401 | 2541 | } |
| 2402 | 2542 | |
| 2403 | 2543 | @set_time_limit(300); |
| 2404 | - if (function_exists('apache_reset_timeout')) |
|
| 2405 | - @apache_reset_timeout(); |
|
| 2544 | + if (function_exists('apache_reset_timeout')) { |
|
| 2545 | + @apache_reset_timeout(); |
|
| 2546 | + } |
|
| 2406 | 2547 | |
| 2407 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2408 | - return; |
|
| 2548 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2549 | + return; |
|
| 2550 | + } |
|
| 2409 | 2551 | |
| 2410 | 2552 | // Do we have some custom step progress stuff? |
| 2411 | 2553 | if (!empty($step_progress)) |
| 2412 | 2554 | { |
| 2413 | 2555 | $upcontext['substep_progress'] = 0; |
| 2414 | 2556 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2415 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2416 | - $upcontext['substep_progress'] = 99.9; |
|
| 2417 | - else |
|
| 2418 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2557 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2558 | + $upcontext['substep_progress'] = 99.9; |
|
| 2559 | + } else { |
|
| 2560 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2561 | + } |
|
| 2419 | 2562 | |
| 2420 | 2563 | // Make it nicely rounded. |
| 2421 | 2564 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2422 | 2565 | } |
| 2423 | 2566 | |
| 2424 | 2567 | // If this is XML we just exit right away! |
| 2425 | - if (isset($_GET['xml'])) |
|
| 2426 | - return upgradeExit(); |
|
| 2568 | + if (isset($_GET['xml'])) { |
|
| 2569 | + return upgradeExit(); |
|
| 2570 | + } |
|
| 2427 | 2571 | |
| 2428 | 2572 | // We're going to pause after this! |
| 2429 | 2573 | $upcontext['pause'] = true; |
@@ -2431,13 +2575,15 @@ discard block |
||
| 2431 | 2575 | $upcontext['query_string'] = ''; |
| 2432 | 2576 | foreach ($_GET as $k => $v) |
| 2433 | 2577 | { |
| 2434 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2435 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2578 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2579 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2580 | + } |
|
| 2436 | 2581 | } |
| 2437 | 2582 | |
| 2438 | 2583 | // Custom warning? |
| 2439 | - if (!empty($custom_warning)) |
|
| 2440 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2584 | + if (!empty($custom_warning)) { |
|
| 2585 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2586 | + } |
|
| 2441 | 2587 | |
| 2442 | 2588 | upgradeExit(); |
| 2443 | 2589 | } |
@@ -2452,25 +2598,26 @@ discard block |
||
| 2452 | 2598 | ob_implicit_flush(true); |
| 2453 | 2599 | @set_time_limit(600); |
| 2454 | 2600 | |
| 2455 | - if (!isset($_SERVER['argv'])) |
|
| 2456 | - $_SERVER['argv'] = array(); |
|
| 2601 | + if (!isset($_SERVER['argv'])) { |
|
| 2602 | + $_SERVER['argv'] = array(); |
|
| 2603 | + } |
|
| 2457 | 2604 | $_GET['maint'] = 1; |
| 2458 | 2605 | |
| 2459 | 2606 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2460 | 2607 | { |
| 2461 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2462 | - $_GET['lang'] = $match[1]; |
|
| 2463 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2464 | - continue; |
|
| 2465 | - elseif ($arg == '--no-maintenance') |
|
| 2466 | - $_GET['maint'] = 0; |
|
| 2467 | - elseif ($arg == '--debug') |
|
| 2468 | - $is_debug = true; |
|
| 2469 | - elseif ($arg == '--backup') |
|
| 2470 | - $_POST['backup'] = 1; |
|
| 2471 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2472 | - $_GET['conv'] = 1; |
|
| 2473 | - elseif ($i != 0) |
|
| 2608 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2609 | + $_GET['lang'] = $match[1]; |
|
| 2610 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2611 | + continue; |
|
| 2612 | + } elseif ($arg == '--no-maintenance') { |
|
| 2613 | + $_GET['maint'] = 0; |
|
| 2614 | + } elseif ($arg == '--debug') { |
|
| 2615 | + $is_debug = true; |
|
| 2616 | + } elseif ($arg == '--backup') { |
|
| 2617 | + $_POST['backup'] = 1; |
|
| 2618 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2619 | + $_GET['conv'] = 1; |
|
| 2620 | + } elseif ($i != 0) |
|
| 2474 | 2621 | { |
| 2475 | 2622 | echo 'SMF Command-line Upgrader |
| 2476 | 2623 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2484,10 +2631,12 @@ discard block |
||
| 2484 | 2631 | } |
| 2485 | 2632 | } |
| 2486 | 2633 | |
| 2487 | - if (!php_version_check()) |
|
| 2488 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2489 | - if (!db_version_check()) |
|
| 2490 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2634 | + if (!php_version_check()) { |
|
| 2635 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2636 | + } |
|
| 2637 | + if (!db_version_check()) { |
|
| 2638 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2639 | + } |
|
| 2491 | 2640 | |
| 2492 | 2641 | // Do some checks to make sure they have proper privileges |
| 2493 | 2642 | db_extend('packages'); |
@@ -2502,34 +2651,39 @@ discard block |
||
| 2502 | 2651 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2503 | 2652 | |
| 2504 | 2653 | // Sorry... we need CREATE, ALTER and DROP |
| 2505 | - if (!$create || !$alter || !$drop) |
|
| 2506 | - 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); |
|
| 2654 | + if (!$create || !$alter || !$drop) { |
|
| 2655 | + 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); |
|
| 2656 | + } |
|
| 2507 | 2657 | |
| 2508 | 2658 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2509 | 2659 | && @file_exists($sourcedir . '/QueryString.php') |
| 2510 | 2660 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2511 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2512 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2661 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2662 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2663 | + } |
|
| 2513 | 2664 | |
| 2514 | 2665 | // Do a quick version spot check. |
| 2515 | 2666 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2516 | 2667 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2517 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2518 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2668 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2669 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2670 | + } |
|
| 2519 | 2671 | |
| 2520 | 2672 | // Make sure Settings.php is writable. |
| 2521 | 2673 | quickFileWritable($boarddir . '/Settings.php'); |
| 2522 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2523 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2674 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2675 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2676 | + } |
|
| 2524 | 2677 | |
| 2525 | 2678 | // Make sure Settings_bak.php is writable. |
| 2526 | 2679 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2527 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2528 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2680 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2681 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2682 | + } |
|
| 2529 | 2683 | |
| 2530 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2531 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2532 | - elseif (isset($modSettings['agreement'])) |
|
| 2684 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2685 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2686 | + } elseif (isset($modSettings['agreement'])) |
|
| 2533 | 2687 | { |
| 2534 | 2688 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2535 | 2689 | fwrite($fp, $modSettings['agreement']); |
@@ -2539,36 +2693,42 @@ discard block |
||
| 2539 | 2693 | // Make sure Themes is writable. |
| 2540 | 2694 | quickFileWritable($modSettings['theme_dir']); |
| 2541 | 2695 | |
| 2542 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2543 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2696 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2697 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2698 | + } |
|
| 2544 | 2699 | |
| 2545 | 2700 | // Make sure cache directory exists and is writable! |
| 2546 | 2701 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2547 | - if (!file_exists($cachedir_temp)) |
|
| 2548 | - @mkdir($cachedir_temp); |
|
| 2702 | + if (!file_exists($cachedir_temp)) { |
|
| 2703 | + @mkdir($cachedir_temp); |
|
| 2704 | + } |
|
| 2549 | 2705 | |
| 2550 | 2706 | // Make sure the cache temp dir is writable. |
| 2551 | 2707 | quickFileWritable($cachedir_temp); |
| 2552 | 2708 | |
| 2553 | - if (!is_writable($cachedir_temp)) |
|
| 2554 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2709 | + if (!is_writable($cachedir_temp)) { |
|
| 2710 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2711 | + } |
|
| 2555 | 2712 | |
| 2556 | 2713 | // Make sure db_last_error.php is writable. |
| 2557 | 2714 | quickFileWritable($cachedir_temp . '/db_last_error.php'); |
| 2558 | - if (!is_writable($cachedir_temp . '/db_last_error.php')) |
|
| 2559 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2715 | + if (!is_writable($cachedir_temp . '/db_last_error.php')) { |
|
| 2716 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2717 | + } |
|
| 2560 | 2718 | |
| 2561 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2562 | - print_error('Error: Unable to find language files!', true); |
|
| 2563 | - else |
|
| 2719 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2720 | + print_error('Error: Unable to find language files!', true); |
|
| 2721 | + } else |
|
| 2564 | 2722 | { |
| 2565 | 2723 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2566 | 2724 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2567 | 2725 | |
| 2568 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2569 | - print_error('Error: Language files out of date.', true); |
|
| 2570 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2571 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2726 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2727 | + print_error('Error: Language files out of date.', true); |
|
| 2728 | + } |
|
| 2729 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2730 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2731 | + } |
|
| 2572 | 2732 | |
| 2573 | 2733 | // Otherwise include it! |
| 2574 | 2734 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2588,8 +2748,9 @@ discard block |
||
| 2588 | 2748 | global $db_prefix, $db_type, $command_line, $support_js, $txt; |
| 2589 | 2749 | |
| 2590 | 2750 | // Done it already? |
| 2591 | - if (!empty($_POST['utf8_done'])) |
|
| 2592 | - return true; |
|
| 2751 | + if (!empty($_POST['utf8_done'])) { |
|
| 2752 | + return true; |
|
| 2753 | + } |
|
| 2593 | 2754 | |
| 2594 | 2755 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2595 | 2756 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2602,8 +2763,7 @@ discard block |
||
| 2602 | 2763 | ); |
| 2603 | 2764 | |
| 2604 | 2765 | return true; |
| 2605 | - } |
|
| 2606 | - else |
|
| 2766 | + } else |
|
| 2607 | 2767 | { |
| 2608 | 2768 | $upcontext['page_title'] = $txt['converting_utf8']; |
| 2609 | 2769 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2647,8 +2807,9 @@ discard block |
||
| 2647 | 2807 | ) |
| 2648 | 2808 | ); |
| 2649 | 2809 | $db_charsets = array(); |
| 2650 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2651 | - $db_charsets[] = $row['Charset']; |
|
| 2810 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2811 | + $db_charsets[] = $row['Charset']; |
|
| 2812 | + } |
|
| 2652 | 2813 | |
| 2653 | 2814 | $smcFunc['db_free_result']($request); |
| 2654 | 2815 | |
@@ -2684,13 +2845,15 @@ discard block |
||
| 2684 | 2845 | // If there's a fulltext index, we need to drop it first... |
| 2685 | 2846 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2686 | 2847 | { |
| 2687 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2688 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2848 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2849 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2689 | 2850 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2851 | + } |
|
| 2690 | 2852 | $smcFunc['db_free_result']($request); |
| 2691 | 2853 | |
| 2692 | - if (isset($upcontext['fulltext_index'])) |
|
| 2693 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2854 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2855 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2856 | + } |
|
| 2694 | 2857 | } |
| 2695 | 2858 | |
| 2696 | 2859 | // Drop it and make a note... |
@@ -2880,8 +3043,9 @@ discard block |
||
| 2880 | 3043 | $replace = '%field%'; |
| 2881 | 3044 | |
| 2882 | 3045 | // Build a huge REPLACE statement... |
| 2883 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2884 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3046 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 3047 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3048 | + } |
|
| 2885 | 3049 | } |
| 2886 | 3050 | |
| 2887 | 3051 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2891,9 +3055,10 @@ discard block |
||
| 2891 | 3055 | $upcontext['table_count'] = count($queryTables); |
| 2892 | 3056 | |
| 2893 | 3057 | // What ones have we already done? |
| 2894 | - foreach ($queryTables as $id => $table) |
|
| 2895 | - if ($id < $_GET['substep']) |
|
| 3058 | + foreach ($queryTables as $id => $table) { |
|
| 3059 | + if ($id < $_GET['substep']) |
|
| 2896 | 3060 | $upcontext['previous_tables'][] = $table; |
| 3061 | + } |
|
| 2897 | 3062 | |
| 2898 | 3063 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2899 | 3064 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2930,8 +3095,9 @@ discard block |
||
| 2930 | 3095 | nextSubstep($substep); |
| 2931 | 3096 | |
| 2932 | 3097 | // Just to make sure it doesn't time out. |
| 2933 | - if (function_exists('apache_reset_timeout')) |
|
| 2934 | - @apache_reset_timeout(); |
|
| 3098 | + if (function_exists('apache_reset_timeout')) { |
|
| 3099 | + @apache_reset_timeout(); |
|
| 3100 | + } |
|
| 2935 | 3101 | |
| 2936 | 3102 | $table_charsets = array(); |
| 2937 | 3103 | |
@@ -2954,8 +3120,9 @@ discard block |
||
| 2954 | 3120 | |
| 2955 | 3121 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2956 | 3122 | if ($charset != 'utf8') { |
| 2957 | - if (!isset($table_charsets[$charset])) |
|
| 2958 | - $table_charsets[$charset] = array(); |
|
| 3123 | + if (!isset($table_charsets[$charset])) { |
|
| 3124 | + $table_charsets[$charset] = array(); |
|
| 3125 | + } |
|
| 2959 | 3126 | |
| 2960 | 3127 | $table_charsets[$charset][] = $column_info; |
| 2961 | 3128 | } |
@@ -2996,10 +3163,11 @@ discard block |
||
| 2996 | 3163 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2997 | 3164 | { |
| 2998 | 3165 | $update = ''; |
| 2999 | - foreach ($table_charsets as $charset => $columns) |
|
| 3000 | - foreach ($columns as $column) |
|
| 3166 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3167 | + foreach ($columns as $column) |
|
| 3001 | 3168 | $update .= ' |
| 3002 | 3169 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3170 | + } |
|
| 3003 | 3171 | |
| 3004 | 3172 | $smcFunc['db_query']('', ' |
| 3005 | 3173 | UPDATE {raw:table_name} |
@@ -3024,8 +3192,9 @@ discard block |
||
| 3024 | 3192 | // Now do the actual conversion (if still needed). |
| 3025 | 3193 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 3026 | 3194 | { |
| 3027 | - if ($command_line) |
|
| 3028 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3195 | + if ($command_line) { |
|
| 3196 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3197 | + } |
|
| 3029 | 3198 | |
| 3030 | 3199 | $smcFunc['db_query']('', ' |
| 3031 | 3200 | ALTER TABLE {raw:table_name} |
@@ -3035,12 +3204,14 @@ discard block |
||
| 3035 | 3204 | ) |
| 3036 | 3205 | ); |
| 3037 | 3206 | |
| 3038 | - if ($command_line) |
|
| 3039 | - echo " done.\n"; |
|
| 3207 | + if ($command_line) { |
|
| 3208 | + echo " done.\n"; |
|
| 3209 | + } |
|
| 3040 | 3210 | } |
| 3041 | 3211 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3042 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 3043 | - return upgradeExit(); |
|
| 3212 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3213 | + return upgradeExit(); |
|
| 3214 | + } |
|
| 3044 | 3215 | } |
| 3045 | 3216 | |
| 3046 | 3217 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -3069,8 +3240,8 @@ discard block |
||
| 3069 | 3240 | ); |
| 3070 | 3241 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3071 | 3242 | { |
| 3072 | - 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) |
|
| 3073 | - $smcFunc['db_query']('', ' |
|
| 3243 | + 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) { |
|
| 3244 | + $smcFunc['db_query']('', ' |
|
| 3074 | 3245 | UPDATE {db_prefix}log_actions |
| 3075 | 3246 | SET extra = {string:extra} |
| 3076 | 3247 | WHERE id_action = {int:current_action}', |
@@ -3079,6 +3250,7 @@ discard block |
||
| 3079 | 3250 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 3080 | 3251 | ) |
| 3081 | 3252 | ); |
| 3253 | + } |
|
| 3082 | 3254 | } |
| 3083 | 3255 | $smcFunc['db_free_result']($request); |
| 3084 | 3256 | |
@@ -3100,15 +3272,17 @@ discard block |
||
| 3100 | 3272 | // First thing's first - did we already do this? |
| 3101 | 3273 | if (!empty($modSettings['json_done'])) |
| 3102 | 3274 | { |
| 3103 | - if ($command_line) |
|
| 3104 | - return DeleteUpgrade(); |
|
| 3105 | - else |
|
| 3106 | - return true; |
|
| 3275 | + if ($command_line) { |
|
| 3276 | + return DeleteUpgrade(); |
|
| 3277 | + } else { |
|
| 3278 | + return true; |
|
| 3279 | + } |
|
| 3107 | 3280 | } |
| 3108 | 3281 | |
| 3109 | 3282 | // Done it already - js wise? |
| 3110 | - if (!empty($_POST['json_done'])) |
|
| 3111 | - return true; |
|
| 3283 | + if (!empty($_POST['json_done'])) { |
|
| 3284 | + return true; |
|
| 3285 | + } |
|
| 3112 | 3286 | |
| 3113 | 3287 | // List of tables affected by this function |
| 3114 | 3288 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3140,12 +3314,14 @@ discard block |
||
| 3140 | 3314 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3141 | 3315 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3142 | 3316 | |
| 3143 | - foreach ($keys as $id => $table) |
|
| 3144 | - if ($id < $_GET['substep']) |
|
| 3317 | + foreach ($keys as $id => $table) { |
|
| 3318 | + if ($id < $_GET['substep']) |
|
| 3145 | 3319 | $upcontext['previous_tables'][] = $table; |
| 3320 | + } |
|
| 3146 | 3321 | |
| 3147 | - if ($command_line) |
|
| 3148 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3322 | + if ($command_line) { |
|
| 3323 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3324 | + } |
|
| 3149 | 3325 | |
| 3150 | 3326 | if (!$support_js || isset($_GET['xml'])) |
| 3151 | 3327 | { |
@@ -3185,8 +3361,9 @@ discard block |
||
| 3185 | 3361 | |
| 3186 | 3362 | // Loop through and fix these... |
| 3187 | 3363 | $new_settings = array(); |
| 3188 | - if ($command_line) |
|
| 3189 | - echo "\n" . 'Fixing some settings...'; |
|
| 3364 | + if ($command_line) { |
|
| 3365 | + echo "\n" . 'Fixing some settings...'; |
|
| 3366 | + } |
|
| 3190 | 3367 | |
| 3191 | 3368 | foreach ($serialized_settings as $var) |
| 3192 | 3369 | { |
@@ -3194,22 +3371,24 @@ discard block |
||
| 3194 | 3371 | { |
| 3195 | 3372 | // Attempt to unserialize the setting |
| 3196 | 3373 | $temp = @safe_unserialize($modSettings[$var]); |
| 3197 | - if (!$temp && $command_line) |
|
| 3198 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3199 | - elseif ($temp !== false) |
|
| 3200 | - $new_settings[$var] = json_encode($temp); |
|
| 3374 | + if (!$temp && $command_line) { |
|
| 3375 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3376 | + } elseif ($temp !== false) { |
|
| 3377 | + $new_settings[$var] = json_encode($temp); |
|
| 3378 | + } |
|
| 3201 | 3379 | } |
| 3202 | 3380 | } |
| 3203 | 3381 | |
| 3204 | 3382 | // Update everything at once |
| 3205 | - if (!function_exists('cache_put_data')) |
|
| 3206 | - require_once($sourcedir . '/Load.php'); |
|
| 3383 | + if (!function_exists('cache_put_data')) { |
|
| 3384 | + require_once($sourcedir . '/Load.php'); |
|
| 3385 | + } |
|
| 3207 | 3386 | updateSettings($new_settings, true); |
| 3208 | 3387 | |
| 3209 | - if ($command_line) |
|
| 3210 | - echo ' done.'; |
|
| 3211 | - } |
|
| 3212 | - elseif ($table == 'themes') |
|
| 3388 | + if ($command_line) { |
|
| 3389 | + echo ' done.'; |
|
| 3390 | + } |
|
| 3391 | + } elseif ($table == 'themes') |
|
| 3213 | 3392 | { |
| 3214 | 3393 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3215 | 3394 | $query = $smcFunc['db_query']('', ' |
@@ -3228,10 +3407,11 @@ discard block |
||
| 3228 | 3407 | |
| 3229 | 3408 | if ($command_line) |
| 3230 | 3409 | { |
| 3231 | - if ($temp === false) |
|
| 3232 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3233 | - else |
|
| 3234 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3410 | + if ($temp === false) { |
|
| 3411 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3412 | + } else { |
|
| 3413 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3414 | + } |
|
| 3235 | 3415 | } |
| 3236 | 3416 | |
| 3237 | 3417 | if ($temp !== false) |
@@ -3253,15 +3433,15 @@ discard block |
||
| 3253 | 3433 | ) |
| 3254 | 3434 | ); |
| 3255 | 3435 | |
| 3256 | - if ($command_line) |
|
| 3257 | - echo ' done.'; |
|
| 3436 | + if ($command_line) { |
|
| 3437 | + echo ' done.'; |
|
| 3438 | + } |
|
| 3258 | 3439 | } |
| 3259 | 3440 | } |
| 3260 | 3441 | |
| 3261 | 3442 | $smcFunc['db_free_result']($query); |
| 3262 | 3443 | } |
| 3263 | - } |
|
| 3264 | - else |
|
| 3444 | + } else |
|
| 3265 | 3445 | { |
| 3266 | 3446 | // First item is always the key... |
| 3267 | 3447 | $key = $info[0]; |
@@ -3272,8 +3452,7 @@ discard block |
||
| 3272 | 3452 | { |
| 3273 | 3453 | $col_select = $info[1]; |
| 3274 | 3454 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3275 | - } |
|
| 3276 | - else |
|
| 3455 | + } else |
|
| 3277 | 3456 | { |
| 3278 | 3457 | $col_select = implode(', ', $info); |
| 3279 | 3458 | } |
@@ -3306,8 +3485,7 @@ discard block |
||
| 3306 | 3485 | if ($temp === false && $command_line) |
| 3307 | 3486 | { |
| 3308 | 3487 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3309 | - } |
|
| 3310 | - else |
|
| 3488 | + } else |
|
| 3311 | 3489 | { |
| 3312 | 3490 | $row[$col] = json_encode($temp); |
| 3313 | 3491 | |
@@ -3332,16 +3510,18 @@ discard block |
||
| 3332 | 3510 | } |
| 3333 | 3511 | } |
| 3334 | 3512 | |
| 3335 | - if ($command_line) |
|
| 3336 | - echo ' done.'; |
|
| 3513 | + if ($command_line) { |
|
| 3514 | + echo ' done.'; |
|
| 3515 | + } |
|
| 3337 | 3516 | |
| 3338 | 3517 | // Free up some memory... |
| 3339 | 3518 | $smcFunc['db_free_result']($query); |
| 3340 | 3519 | } |
| 3341 | 3520 | } |
| 3342 | 3521 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3343 | - if (isset($_GET['xml'])) |
|
| 3344 | - return upgradeExit(); |
|
| 3522 | + if (isset($_GET['xml'])) { |
|
| 3523 | + return upgradeExit(); |
|
| 3524 | + } |
|
| 3345 | 3525 | } |
| 3346 | 3526 | |
| 3347 | 3527 | if ($command_line) |
@@ -3356,8 +3536,9 @@ discard block |
||
| 3356 | 3536 | |
| 3357 | 3537 | $_GET['substep'] = 0; |
| 3358 | 3538 | // Make sure we move on! |
| 3359 | - if ($command_line) |
|
| 3360 | - return DeleteUpgrade(); |
|
| 3539 | + if ($command_line) { |
|
| 3540 | + return DeleteUpgrade(); |
|
| 3541 | + } |
|
| 3361 | 3542 | |
| 3362 | 3543 | return true; |
| 3363 | 3544 | } |
@@ -3414,14 +3595,16 @@ discard block |
||
| 3414 | 3595 | global $upcontext, $txt, $settings; |
| 3415 | 3596 | |
| 3416 | 3597 | // Don't call me twice! |
| 3417 | - if (!empty($upcontext['chmod_called'])) |
|
| 3418 | - return; |
|
| 3598 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3599 | + return; |
|
| 3600 | + } |
|
| 3419 | 3601 | |
| 3420 | 3602 | $upcontext['chmod_called'] = true; |
| 3421 | 3603 | |
| 3422 | 3604 | // Nothing? |
| 3423 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3424 | - return; |
|
| 3605 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3606 | + return; |
|
| 3607 | + } |
|
| 3425 | 3608 | |
| 3426 | 3609 | // Was it a problem with Windows? |
| 3427 | 3610 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3453,11 +3636,12 @@ discard block |
||
| 3453 | 3636 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\'); |
| 3454 | 3637 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3455 | 3638 | |
| 3456 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3457 | - echo ' |
|
| 3639 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3640 | + echo ' |
|
| 3458 | 3641 | content.write(\'<hr>\n\t\t\t\'); |
| 3459 | 3642 | content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\'); |
| 3460 | 3643 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3644 | + } |
|
| 3461 | 3645 | |
| 3462 | 3646 | echo ' |
| 3463 | 3647 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3465,16 +3649,18 @@ discard block |
||
| 3465 | 3649 | } |
| 3466 | 3650 | </script>'; |
| 3467 | 3651 | |
| 3468 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3469 | - echo ' |
|
| 3652 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3653 | + echo ' |
|
| 3470 | 3654 | <div class="error_message red"> |
| 3471 | 3655 | <p>', $txt['upgrade_ftp_error'], '<p> |
| 3472 | 3656 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3473 | 3657 | </div>'; |
| 3658 | + } |
|
| 3474 | 3659 | |
| 3475 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3476 | - echo ' |
|
| 3660 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3661 | + echo ' |
|
| 3477 | 3662 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3663 | + } |
|
| 3478 | 3664 | |
| 3479 | 3665 | echo ' |
| 3480 | 3666 | <dl class="settings"> |
@@ -3516,9 +3702,10 @@ discard block |
||
| 3516 | 3702 | <input type="submit" value="', $txt['ftp_connect'], '" class="button"> |
| 3517 | 3703 | </div>'; |
| 3518 | 3704 | |
| 3519 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3520 | - echo ' |
|
| 3705 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3706 | + echo ' |
|
| 3521 | 3707 | </form>'; |
| 3708 | + } |
|
| 3522 | 3709 | |
| 3523 | 3710 | echo ' |
| 3524 | 3711 | </div><!-- .panel -->'; |
@@ -3582,9 +3769,10 @@ discard block |
||
| 3582 | 3769 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3583 | 3770 | <ul>'; |
| 3584 | 3771 | |
| 3585 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3586 | - echo ' |
|
| 3772 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3773 | + echo ' |
|
| 3587 | 3774 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3775 | + } |
|
| 3588 | 3776 | |
| 3589 | 3777 | echo ' |
| 3590 | 3778 | </ul> |
@@ -3597,13 +3785,14 @@ discard block |
||
| 3597 | 3785 | <span id="overall_text">', $upcontext['overall_percent'], '%</span> |
| 3598 | 3786 | </div>'; |
| 3599 | 3787 | |
| 3600 | - if (isset($upcontext['step_progress'])) |
|
| 3601 | - echo ' |
|
| 3788 | + if (isset($upcontext['step_progress'])) { |
|
| 3789 | + echo ' |
|
| 3602 | 3790 | <div id="progress_bar_step" class="progress_bar progress_yellow"> |
| 3603 | 3791 | <h3>', $txt['upgrade_step_progress'], '</h3> |
| 3604 | 3792 | <div id="step_progress" class="bar" style="width: ', $upcontext['step_progress'], '%;"></div> |
| 3605 | 3793 | <span id="step_text">', $upcontext['step_progress'], '%</span> |
| 3606 | 3794 | </div>'; |
| 3795 | + } |
|
| 3607 | 3796 | |
| 3608 | 3797 | echo ' |
| 3609 | 3798 | <h3>', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', '</h3> |
@@ -3634,31 +3823,35 @@ discard block |
||
| 3634 | 3823 | { |
| 3635 | 3824 | global $upcontext, $txt; |
| 3636 | 3825 | |
| 3637 | - if (!empty($upcontext['pause'])) |
|
| 3638 | - echo ' |
|
| 3826 | + if (!empty($upcontext['pause'])) { |
|
| 3827 | + echo ' |
|
| 3639 | 3828 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3640 | 3829 | |
| 3641 | 3830 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3642 | 3831 | <h3> |
| 3643 | 3832 | ', $txt['upgrade_paused_overload'], ' |
| 3644 | 3833 | </h3>'; |
| 3834 | + } |
|
| 3645 | 3835 | |
| 3646 | - if (!empty($upcontext['custom_warning'])) |
|
| 3647 | - echo ' |
|
| 3836 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3837 | + echo ' |
|
| 3648 | 3838 | <div class="errorbox"> |
| 3649 | 3839 | <h3>', $txt['upgrade_note'], '</h3> |
| 3650 | 3840 | ', $upcontext['custom_warning'], ' |
| 3651 | 3841 | </div>'; |
| 3842 | + } |
|
| 3652 | 3843 | |
| 3653 | 3844 | echo ' |
| 3654 | 3845 | <div class="righttext" style="margin: 1ex;">'; |
| 3655 | 3846 | |
| 3656 | - if (!empty($upcontext['continue'])) |
|
| 3657 | - echo ' |
|
| 3847 | + if (!empty($upcontext['continue'])) { |
|
| 3848 | + echo ' |
|
| 3658 | 3849 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
| 3659 | - if (!empty($upcontext['skip'])) |
|
| 3660 | - echo ' |
|
| 3850 | + } |
|
| 3851 | + if (!empty($upcontext['skip'])) { |
|
| 3852 | + echo ' |
|
| 3661 | 3853 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
| 3854 | + } |
|
| 3662 | 3855 | |
| 3663 | 3856 | echo ' |
| 3664 | 3857 | </div> |
@@ -3709,11 +3902,12 @@ discard block |
||
| 3709 | 3902 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3710 | 3903 | <smf>'; |
| 3711 | 3904 | |
| 3712 | - if (!empty($upcontext['get_data'])) |
|
| 3713 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3905 | + if (!empty($upcontext['get_data'])) { |
|
| 3906 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3714 | 3907 | echo ' |
| 3715 | 3908 | <get key="', $k, '">', $v, '</get>'; |
| 3716 | -} |
|
| 3909 | + } |
|
| 3910 | + } |
|
| 3717 | 3911 | |
| 3718 | 3912 | function template_xml_below() |
| 3719 | 3913 | { |
@@ -3753,20 +3947,22 @@ discard block |
||
| 3753 | 3947 | template_chmod(); |
| 3754 | 3948 | |
| 3755 | 3949 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3756 | - if ($upcontext['is_large_forum']) |
|
| 3757 | - echo ' |
|
| 3950 | + if ($upcontext['is_large_forum']) { |
|
| 3951 | + echo ' |
|
| 3758 | 3952 | <div class="errorbox"> |
| 3759 | 3953 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3760 | 3954 | ', $txt['upgrade_warning_lots_data'], ' |
| 3761 | 3955 | </div>'; |
| 3956 | + } |
|
| 3762 | 3957 | |
| 3763 | 3958 | // A warning message? |
| 3764 | - if (!empty($upcontext['warning'])) |
|
| 3765 | - echo ' |
|
| 3959 | + if (!empty($upcontext['warning'])) { |
|
| 3960 | + echo ' |
|
| 3766 | 3961 | <div class="errorbox"> |
| 3767 | 3962 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3768 | 3963 | ', $upcontext['warning'], ' |
| 3769 | 3964 | </div>'; |
| 3965 | + } |
|
| 3770 | 3966 | |
| 3771 | 3967 | // Paths are incorrect? |
| 3772 | 3968 | echo ' |
@@ -3779,35 +3975,39 @@ discard block |
||
| 3779 | 3975 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3780 | 3976 | { |
| 3781 | 3977 | $ago = time() - $upcontext['started']; |
| 3782 | - if ($ago < 60) |
|
| 3783 | - $ago = $ago . ' seconds'; |
|
| 3784 | - elseif ($ago < 3600) |
|
| 3785 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3786 | - else |
|
| 3787 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3978 | + if ($ago < 60) { |
|
| 3979 | + $ago = $ago . ' seconds'; |
|
| 3980 | + } elseif ($ago < 3600) { |
|
| 3981 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3982 | + } else { |
|
| 3983 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3984 | + } |
|
| 3788 | 3985 | |
| 3789 | 3986 | $active = time() - $upcontext['updated']; |
| 3790 | - if ($active < 60) |
|
| 3791 | - $updated = $active . ' seconds'; |
|
| 3792 | - elseif ($active < 3600) |
|
| 3793 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3794 | - else |
|
| 3795 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3987 | + if ($active < 60) { |
|
| 3988 | + $updated = $active . ' seconds'; |
|
| 3989 | + } elseif ($active < 3600) { |
|
| 3990 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3991 | + } else { |
|
| 3992 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3993 | + } |
|
| 3796 | 3994 | |
| 3797 | 3995 | echo ' |
| 3798 | 3996 | <div class="errorbox"> |
| 3799 | 3997 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3800 | 3998 | <p>', sprintf($txt['upgrade_time'], $upcontext['user']['name'], $ago, $updated), '</p>'; |
| 3801 | - if ($active < 600) |
|
| 3802 | - echo ' |
|
| 3999 | + if ($active < 600) { |
|
| 4000 | + echo ' |
|
| 3803 | 4001 | <p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>'; |
| 4002 | + } |
|
| 3804 | 4003 | |
| 3805 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3806 | - echo ' |
|
| 4004 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 4005 | + echo ' |
|
| 3807 | 4006 | <p>',$txt['upgrade_run'], '</p>'; |
| 3808 | - else |
|
| 3809 | - echo ' |
|
| 4007 | + } else { |
|
| 4008 | + echo ' |
|
| 3810 | 4009 | <p>', $txt['upgrade_script_timeout'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_script_timeout2'], ' ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'), '</p>'; |
| 4010 | + } |
|
| 3811 | 4011 | |
| 3812 | 4012 | echo ' |
| 3813 | 4013 | </div>'; |
@@ -3823,9 +4023,10 @@ discard block |
||
| 3823 | 4023 | <dd> |
| 3824 | 4024 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
| 3825 | 4025 | |
| 3826 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3827 | - echo ' |
|
| 4026 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 4027 | + echo ' |
|
| 3828 | 4028 | <div class="smalltext red">', $txt['upgrade_wrong_username'], '</div>'; |
| 4029 | + } |
|
| 3829 | 4030 | |
| 3830 | 4031 | echo ' |
| 3831 | 4032 | </dd> |
@@ -3836,9 +4037,10 @@ discard block |
||
| 3836 | 4037 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
| 3837 | 4038 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3838 | 4039 | |
| 3839 | - if (!empty($upcontext['password_failed'])) |
|
| 3840 | - echo ' |
|
| 4040 | + if (!empty($upcontext['password_failed'])) { |
|
| 4041 | + echo ' |
|
| 3841 | 4042 | <div class="smalltext red">', $txt['upgrade_wrong_password'], '</div>'; |
| 4043 | + } |
|
| 3842 | 4044 | |
| 3843 | 4045 | echo ' |
| 3844 | 4046 | </dd>'; |
@@ -3906,12 +4108,13 @@ discard block |
||
| 3906 | 4108 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3907 | 4109 | |
| 3908 | 4110 | // Warning message? |
| 3909 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3910 | - echo ' |
|
| 4111 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 4112 | + echo ' |
|
| 3911 | 4113 | <div class="errorbox"> |
| 3912 | 4114 | <h3>', $txt['upgrade_warning'] ,'</h3> |
| 3913 | 4115 | ', $upcontext['upgrade_options_warning'], ' |
| 3914 | 4116 | </div>'; |
| 4117 | + } |
|
| 3915 | 4118 | |
| 3916 | 4119 | echo ' |
| 3917 | 4120 | <ul class="upgrade_settings"> |
@@ -3940,12 +4143,13 @@ discard block |
||
| 3940 | 4143 | <label for="empty_error">', $txt['upgrade_empty_errlog'], '</label> |
| 3941 | 4144 | </li>'; |
| 3942 | 4145 | |
| 3943 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3944 | - echo ' |
|
| 4146 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 4147 | + echo ' |
|
| 3945 | 4148 | <li> |
| 3946 | 4149 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
| 3947 | 4150 | <label for="delete_karma">', $txt['upgrade_delete_karma'], '</label> |
| 3948 | 4151 | </li>'; |
| 4152 | + } |
|
| 3949 | 4153 | |
| 3950 | 4154 | echo ' |
| 3951 | 4155 | <li> |
@@ -3979,10 +4183,11 @@ discard block |
||
| 3979 | 4183 | </div>'; |
| 3980 | 4184 | |
| 3981 | 4185 | // Dont any tables so far? |
| 3982 | - if (!empty($upcontext['previous_tables'])) |
|
| 3983 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4186 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4187 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3984 | 4188 | echo ' |
| 3985 | 4189 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4190 | + } |
|
| 3986 | 4191 | |
| 3987 | 4192 | echo ' |
| 3988 | 4193 | <h3 id="current_tab"> |
@@ -4021,12 +4226,13 @@ discard block |
||
| 4021 | 4226 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4022 | 4227 | |
| 4023 | 4228 | // If debug flood the screen. |
| 4024 | - if ($is_debug) |
|
| 4025 | - echo ' |
|
| 4229 | + if ($is_debug) { |
|
| 4230 | + echo ' |
|
| 4026 | 4231 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4027 | 4232 | |
| 4028 | 4233 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4029 | 4234 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4235 | + } |
|
| 4030 | 4236 | |
| 4031 | 4237 | echo ' |
| 4032 | 4238 | // Get the next update... |
@@ -4059,8 +4265,9 @@ discard block |
||
| 4059 | 4265 | { |
| 4060 | 4266 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt; |
| 4061 | 4267 | |
| 4062 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 4063 | - $is_debug = true; |
|
| 4268 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4269 | + $is_debug = true; |
|
| 4270 | + } |
|
| 4064 | 4271 | |
| 4065 | 4272 | echo ' |
| 4066 | 4273 | <h3>', $txt['upgrade_db_changes'], '</h3> |
@@ -4075,8 +4282,9 @@ discard block |
||
| 4075 | 4282 | { |
| 4076 | 4283 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 4077 | 4284 | { |
| 4078 | - if ($num != 0) |
|
| 4079 | - echo ' Successful!'; |
|
| 4285 | + if ($num != 0) { |
|
| 4286 | + echo ' Successful!'; |
|
| 4287 | + } |
|
| 4080 | 4288 | echo '<br>' . $item; |
| 4081 | 4289 | } |
| 4082 | 4290 | if (!empty($upcontext['changes_complete'])) |
@@ -4089,29 +4297,33 @@ discard block |
||
| 4089 | 4297 | $seconds = intval($active % 60); |
| 4090 | 4298 | |
| 4091 | 4299 | $totalTime = ''; |
| 4092 | - if ($hours > 0) |
|
| 4093 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4094 | - if ($minutes > 0) |
|
| 4095 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4096 | - if ($seconds > 0) |
|
| 4097 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4300 | + if ($hours > 0) { |
|
| 4301 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4302 | + } |
|
| 4303 | + if ($minutes > 0) { |
|
| 4304 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4305 | + } |
|
| 4306 | + if ($seconds > 0) { |
|
| 4307 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4308 | + } |
|
| 4098 | 4309 | } |
| 4099 | 4310 | |
| 4100 | - if ($is_debug && !empty($totalTime)) |
|
| 4101 | - echo '', sprintf($txt['upgrade_success_time'], $totalTime), '<br>'; |
|
| 4102 | - else |
|
| 4103 | - echo '', $txt['upgrade_success'], '<br>'; |
|
| 4311 | + if ($is_debug && !empty($totalTime)) { |
|
| 4312 | + echo '', sprintf($txt['upgrade_success_time'], $totalTime), '<br>'; |
|
| 4313 | + } else { |
|
| 4314 | + echo '', $txt['upgrade_success'], '<br>'; |
|
| 4315 | + } |
|
| 4104 | 4316 | |
| 4105 | 4317 | echo ' |
| 4106 | 4318 | <p id="commess">', $txt['upgrade_db_complete'], '</p>'; |
| 4107 | 4319 | } |
| 4108 | - } |
|
| 4109 | - else |
|
| 4320 | + } else |
|
| 4110 | 4321 | { |
| 4111 | 4322 | // Tell them how many files we have in total. |
| 4112 | - if ($upcontext['file_count'] > 1) |
|
| 4113 | - echo ' |
|
| 4323 | + if ($upcontext['file_count'] > 1) { |
|
| 4324 | + echo ' |
|
| 4114 | 4325 | <strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4326 | + } |
|
| 4115 | 4327 | |
| 4116 | 4328 | echo ' |
| 4117 | 4329 | <h3 id="info2"> |
@@ -4129,19 +4341,23 @@ discard block |
||
| 4129 | 4341 | $seconds = intval($active % 60); |
| 4130 | 4342 | |
| 4131 | 4343 | $totalTime = ''; |
| 4132 | - if ($hours > 0) |
|
| 4133 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4134 | - if ($minutes > 0) |
|
| 4135 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4136 | - if ($seconds > 0) |
|
| 4137 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4344 | + if ($hours > 0) { |
|
| 4345 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4346 | + } |
|
| 4347 | + if ($minutes > 0) { |
|
| 4348 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4349 | + } |
|
| 4350 | + if ($seconds > 0) { |
|
| 4351 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4352 | + } |
|
| 4138 | 4353 | } |
| 4139 | 4354 | |
| 4140 | 4355 | echo ' |
| 4141 | 4356 | <p id="upgradeCompleted">'; |
| 4142 | 4357 | |
| 4143 | - if (!empty($totalTime)) |
|
| 4144 | - echo '', sprintf($txt['upgrade_completed_time2'], $totalTime), ''; |
|
| 4358 | + if (!empty($totalTime)) { |
|
| 4359 | + echo '', sprintf($txt['upgrade_completed_time2'], $totalTime), ''; |
|
| 4360 | + } |
|
| 4145 | 4361 | |
| 4146 | 4362 | echo ' |
| 4147 | 4363 | </p> |
@@ -4178,9 +4394,10 @@ discard block |
||
| 4178 | 4394 | var getData = ""; |
| 4179 | 4395 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4180 | 4396 | |
| 4181 | - if ($is_debug) |
|
| 4182 | - echo ' |
|
| 4397 | + if ($is_debug) { |
|
| 4398 | + echo ' |
|
| 4183 | 4399 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4400 | + } |
|
| 4184 | 4401 | |
| 4185 | 4402 | echo ' |
| 4186 | 4403 | function getNextItem() |
@@ -4220,9 +4437,10 @@ discard block |
||
| 4220 | 4437 | document.getElementById("error_block").style.display = ""; |
| 4221 | 4438 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4222 | 4439 | |
| 4223 | - if ($is_debug) |
|
| 4224 | - echo ' |
|
| 4440 | + if ($is_debug) { |
|
| 4441 | + echo ' |
|
| 4225 | 4442 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4443 | + } |
|
| 4226 | 4444 | |
| 4227 | 4445 | echo ' |
| 4228 | 4446 | } |
@@ -4243,9 +4461,10 @@ discard block |
||
| 4243 | 4461 | document.getElementById("error_block").style.display = ""; |
| 4244 | 4462 | setInnerHTML(document.getElementById("error_message"), "', $txt['upgrade_loop'], '" + sDebugName);'; |
| 4245 | 4463 | |
| 4246 | - if ($is_debug) |
|
| 4247 | - echo ' |
|
| 4464 | + if ($is_debug) { |
|
| 4465 | + echo ' |
|
| 4248 | 4466 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4467 | + } |
|
| 4249 | 4468 | |
| 4250 | 4469 | echo ' |
| 4251 | 4470 | } |
@@ -4302,8 +4521,8 @@ discard block |
||
| 4302 | 4521 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4303 | 4522 | {'; |
| 4304 | 4523 | |
| 4305 | - if ($is_debug) |
|
| 4306 | - echo ' |
|
| 4524 | + if ($is_debug) { |
|
| 4525 | + echo ' |
|
| 4307 | 4526 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4308 | 4527 | |
| 4309 | 4528 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4321,6 +4540,7 @@ discard block |
||
| 4321 | 4540 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4322 | 4541 | |
| 4323 | 4542 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4543 | + } |
|
| 4324 | 4544 | |
| 4325 | 4545 | echo ' |
| 4326 | 4546 | |
@@ -4328,9 +4548,10 @@ discard block |
||
| 4328 | 4548 | document.getElementById(\'contbutt\').disabled = 0; |
| 4329 | 4549 | document.getElementById(\'database_done\').value = 1;'; |
| 4330 | 4550 | |
| 4331 | - if ($upcontext['file_count'] > 1) |
|
| 4332 | - echo ' |
|
| 4551 | + if ($upcontext['file_count'] > 1) { |
|
| 4552 | + echo ' |
|
| 4333 | 4553 | document.getElementById(\'info1\').style.display = "none";'; |
| 4554 | + } |
|
| 4334 | 4555 | |
| 4335 | 4556 | echo ' |
| 4336 | 4557 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4343,9 +4564,10 @@ discard block |
||
| 4343 | 4564 | lastItem = 0; |
| 4344 | 4565 | prevFile = curFile;'; |
| 4345 | 4566 | |
| 4346 | - if ($is_debug) |
|
| 4347 | - echo ' |
|
| 4567 | + if ($is_debug) { |
|
| 4568 | + echo ' |
|
| 4348 | 4569 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4570 | + } |
|
| 4349 | 4571 | |
| 4350 | 4572 | echo ' |
| 4351 | 4573 | getNextItem(); |
@@ -4353,8 +4575,8 @@ discard block |
||
| 4353 | 4575 | }'; |
| 4354 | 4576 | |
| 4355 | 4577 | // If debug scroll the screen. |
| 4356 | - if ($is_debug) |
|
| 4357 | - echo ' |
|
| 4578 | + if ($is_debug) { |
|
| 4579 | + echo ' |
|
| 4358 | 4580 | if (iLastSubStepProgress == -1) |
| 4359 | 4581 | { |
| 4360 | 4582 | // Give it consistent dots. |
@@ -4373,6 +4595,7 @@ discard block |
||
| 4373 | 4595 | |
| 4374 | 4596 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4375 | 4597 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4598 | + } |
|
| 4376 | 4599 | |
| 4377 | 4600 | echo ' |
| 4378 | 4601 | // Update the page. |
@@ -4433,9 +4656,10 @@ discard block |
||
| 4433 | 4656 | }'; |
| 4434 | 4657 | |
| 4435 | 4658 | // Start things off assuming we've not errored. |
| 4436 | - if (empty($upcontext['error_message'])) |
|
| 4437 | - echo ' |
|
| 4659 | + if (empty($upcontext['error_message'])) { |
|
| 4660 | + echo ' |
|
| 4438 | 4661 | getNextItem();'; |
| 4662 | + } |
|
| 4439 | 4663 | |
| 4440 | 4664 | echo ' |
| 4441 | 4665 | //# sourceURL=dynamicScript-dbch.js |
@@ -4453,18 +4677,21 @@ discard block |
||
| 4453 | 4677 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4454 | 4678 | <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>'; |
| 4455 | 4679 | |
| 4456 | - if (!empty($upcontext['error_message'])) |
|
| 4457 | - echo ' |
|
| 4680 | + if (!empty($upcontext['error_message'])) { |
|
| 4681 | + echo ' |
|
| 4458 | 4682 | <error>', $upcontext['error_message'], '</error>'; |
| 4683 | + } |
|
| 4459 | 4684 | |
| 4460 | - if (!empty($upcontext['error_string'])) |
|
| 4461 | - echo ' |
|
| 4685 | + if (!empty($upcontext['error_string'])) { |
|
| 4686 | + echo ' |
|
| 4462 | 4687 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4688 | + } |
|
| 4463 | 4689 | |
| 4464 | - if ($is_debug) |
|
| 4465 | - echo ' |
|
| 4690 | + if ($is_debug) { |
|
| 4691 | + echo ' |
|
| 4466 | 4692 | <curtime>', time(), '</curtime>'; |
| 4467 | -} |
|
| 4693 | + } |
|
| 4694 | + } |
|
| 4468 | 4695 | |
| 4469 | 4696 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4470 | 4697 | function template_convert_utf8() |
@@ -4481,10 +4708,11 @@ discard block |
||
| 4481 | 4708 | </div>'; |
| 4482 | 4709 | |
| 4483 | 4710 | // Done any tables so far? |
| 4484 | - if (!empty($upcontext['previous_tables'])) |
|
| 4485 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4711 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4712 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4486 | 4713 | echo ' |
| 4487 | 4714 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4715 | + } |
|
| 4488 | 4716 | |
| 4489 | 4717 | echo ' |
| 4490 | 4718 | <h3 id="current_tab"> |
@@ -4492,9 +4720,10 @@ discard block |
||
| 4492 | 4720 | </h3>'; |
| 4493 | 4721 | |
| 4494 | 4722 | // If we dropped their index, let's let them know |
| 4495 | - if ($upcontext['dropping_index']) |
|
| 4496 | - echo ' |
|
| 4723 | + if ($upcontext['dropping_index']) { |
|
| 4724 | + echo ' |
|
| 4497 | 4725 | <p id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</p>'; |
| 4726 | + } |
|
| 4498 | 4727 | |
| 4499 | 4728 | // Completion notification |
| 4500 | 4729 | echo ' |
@@ -4531,12 +4760,13 @@ discard block |
||
| 4531 | 4760 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4532 | 4761 | |
| 4533 | 4762 | // If debug flood the screen. |
| 4534 | - if ($is_debug) |
|
| 4535 | - echo ' |
|
| 4763 | + if ($is_debug) { |
|
| 4764 | + echo ' |
|
| 4536 | 4765 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4537 | 4766 | |
| 4538 | 4767 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4539 | 4768 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4769 | + } |
|
| 4540 | 4770 | |
| 4541 | 4771 | echo ' |
| 4542 | 4772 | // Get the next update... |
@@ -4582,10 +4812,11 @@ discard block |
||
| 4582 | 4812 | </div>'; |
| 4583 | 4813 | |
| 4584 | 4814 | // Dont any tables so far? |
| 4585 | - if (!empty($upcontext['previous_tables'])) |
|
| 4586 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4815 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4816 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4587 | 4817 | echo ' |
| 4588 | 4818 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4819 | + } |
|
| 4589 | 4820 | |
| 4590 | 4821 | echo ' |
| 4591 | 4822 | <h3 id="current_tab"> |
@@ -4594,9 +4825,10 @@ discard block |
||
| 4594 | 4825 | <p id="commess" style="display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</p>'; |
| 4595 | 4826 | |
| 4596 | 4827 | // Try to make sure substep was reset. |
| 4597 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4598 | - echo ' |
|
| 4828 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4829 | + echo ' |
|
| 4599 | 4830 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4831 | + } |
|
| 4600 | 4832 | |
| 4601 | 4833 | // Continue please! |
| 4602 | 4834 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4629,12 +4861,13 @@ discard block |
||
| 4629 | 4861 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4630 | 4862 | |
| 4631 | 4863 | // If debug flood the screen. |
| 4632 | - if ($is_debug) |
|
| 4633 | - echo ' |
|
| 4864 | + if ($is_debug) { |
|
| 4865 | + echo ' |
|
| 4634 | 4866 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4635 | 4867 | |
| 4636 | 4868 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4637 | 4869 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4870 | + } |
|
| 4638 | 4871 | |
| 4639 | 4872 | echo ' |
| 4640 | 4873 | // Get the next update... |
@@ -4670,8 +4903,8 @@ discard block |
||
| 4670 | 4903 | <h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>. ', $txt['upgrade_done3'], '</h3> |
| 4671 | 4904 | <form action="', $boardurl, '/index.php">'; |
| 4672 | 4905 | |
| 4673 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4674 | - echo ' |
|
| 4906 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4907 | + echo ' |
|
| 4675 | 4908 | <label> |
| 4676 | 4909 | <input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], ' |
| 4677 | 4910 | </label> |
@@ -4685,6 +4918,7 @@ discard block |
||
| 4685 | 4918 | } |
| 4686 | 4919 | </script> |
| 4687 | 4920 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4921 | + } |
|
| 4688 | 4922 | |
| 4689 | 4923 | $active = time() - $upcontext['started']; |
| 4690 | 4924 | $hours = floor($active / 3600); |
@@ -4694,17 +4928,21 @@ discard block |
||
| 4694 | 4928 | if ($is_debug) |
| 4695 | 4929 | { |
| 4696 | 4930 | $totalTime = ''; |
| 4697 | - if ($hours > 0) |
|
| 4698 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4699 | - if ($minutes > 0) |
|
| 4700 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4701 | - if ($seconds > 0) |
|
| 4702 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4931 | + if ($hours > 0) { |
|
| 4932 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4933 | + } |
|
| 4934 | + if ($minutes > 0) { |
|
| 4935 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4936 | + } |
|
| 4937 | + if ($seconds > 0) { |
|
| 4938 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4939 | + } |
|
| 4703 | 4940 | } |
| 4704 | 4941 | |
| 4705 | - if ($is_debug && !empty($totalTime)) |
|
| 4706 | - echo ' |
|
| 4942 | + if ($is_debug && !empty($totalTime)) { |
|
| 4943 | + echo ' |
|
| 4707 | 4944 | <p> ', $txt['upgrade_completed_time'], ' ', $totalTime, '</p>'; |
| 4945 | + } |
|
| 4708 | 4946 | |
| 4709 | 4947 | echo ' |
| 4710 | 4948 | <p> |
@@ -4733,8 +4971,9 @@ discard block |
||
| 4733 | 4971 | |
| 4734 | 4972 | $current_substep = $_GET['substep']; |
| 4735 | 4973 | |
| 4736 | - if (empty($_GET['a'])) |
|
| 4737 | - $_GET['a'] = 0; |
|
| 4974 | + if (empty($_GET['a'])) { |
|
| 4975 | + $_GET['a'] = 0; |
|
| 4976 | + } |
|
| 4738 | 4977 | $step_progress['name'] = 'Converting ips'; |
| 4739 | 4978 | $step_progress['current'] = $_GET['a']; |
| 4740 | 4979 | |
@@ -4777,16 +5016,19 @@ discard block |
||
| 4777 | 5016 | 'empty' => '', |
| 4778 | 5017 | 'limit' => $limit, |
| 4779 | 5018 | )); |
| 4780 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4781 | - $arIp[] = $row[$oldCol]; |
|
| 5019 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 5020 | + $arIp[] = $row[$oldCol]; |
|
| 5021 | + } |
|
| 4782 | 5022 | $smcFunc['db_free_result']($request); |
| 4783 | 5023 | |
| 4784 | 5024 | // Special case, null ip could keep us in a loop. |
| 4785 | - if (is_null($arIp[0])) |
|
| 4786 | - unset($arIp[0]); |
|
| 5025 | + if (is_null($arIp[0])) { |
|
| 5026 | + unset($arIp[0]); |
|
| 5027 | + } |
|
| 4787 | 5028 | |
| 4788 | - if (empty($arIp)) |
|
| 4789 | - $is_done = true; |
|
| 5029 | + if (empty($arIp)) { |
|
| 5030 | + $is_done = true; |
|
| 5031 | + } |
|
| 4790 | 5032 | |
| 4791 | 5033 | $updates = array(); |
| 4792 | 5034 | $cases = array(); |
@@ -4795,16 +5037,18 @@ discard block |
||
| 4795 | 5037 | { |
| 4796 | 5038 | $arIp[$i] = trim($arIp[$i]); |
| 4797 | 5039 | |
| 4798 | - if (empty($arIp[$i])) |
|
| 4799 | - continue; |
|
| 5040 | + if (empty($arIp[$i])) { |
|
| 5041 | + continue; |
|
| 5042 | + } |
|
| 4800 | 5043 | |
| 4801 | 5044 | $updates['ip' . $i] = $arIp[$i]; |
| 4802 | 5045 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4803 | 5046 | |
| 4804 | 5047 | if ($setSize > 0 && $i % $setSize === 0) |
| 4805 | 5048 | { |
| 4806 | - if (count($updates) == 1) |
|
| 4807 | - continue; |
|
| 5049 | + if (count($updates) == 1) { |
|
| 5050 | + continue; |
|
| 5051 | + } |
|
| 4808 | 5052 | |
| 4809 | 5053 | $updates['whereSet'] = array_values($updates); |
| 4810 | 5054 | $smcFunc['db_query']('', ' |
@@ -4838,8 +5082,7 @@ discard block |
||
| 4838 | 5082 | 'ip' => $ip |
| 4839 | 5083 | )); |
| 4840 | 5084 | } |
| 4841 | - } |
|
| 4842 | - else |
|
| 5085 | + } else |
|
| 4843 | 5086 | { |
| 4844 | 5087 | $updates['whereSet'] = array_values($updates); |
| 4845 | 5088 | $smcFunc['db_query']('', ' |
@@ -4853,9 +5096,9 @@ discard block |
||
| 4853 | 5096 | $updates |
| 4854 | 5097 | ); |
| 4855 | 5098 | } |
| 5099 | + } else { |
|
| 5100 | + $is_done = true; |
|
| 4856 | 5101 | } |
| 4857 | - else |
|
| 4858 | - $is_done = true; |
|
| 4859 | 5102 | |
| 4860 | 5103 | $_GET['a'] += $limit; |
| 4861 | 5104 | $step_progress['current'] = $_GET['a']; |
@@ -4881,10 +5124,11 @@ discard block |
||
| 4881 | 5124 | |
| 4882 | 5125 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4883 | 5126 | |
| 4884 | - if (isset($columns[$column])) |
|
| 4885 | - return $columns[$column]; |
|
| 4886 | - else |
|
| 4887 | - return null; |
|
| 4888 | -} |
|
| 5127 | + if (isset($columns[$column])) { |
|
| 5128 | + return $columns[$column]; |
|
| 5129 | + } else { |
|
| 5130 | + return null; |
|
| 5131 | + } |
|
| 5132 | + } |
|
| 4889 | 5133 | |
| 4890 | 5134 | ?> |
| 4891 | 5135 | \ No newline at end of file |