@@ -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 | |
@@ -100,11 +101,14 @@ discard block |
||
| 100 | 101 | ini_set('default_socket_timeout', 900); |
| 101 | 102 | } |
| 102 | 103 | // Clean the upgrade path if this is from the client. |
| 103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 105 | + for ($i = 1; |
|
| 106 | +} |
|
| 107 | +$i < $_SERVER['argc']; $i++) |
|
| 105 | 108 | { |
| 106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 111 | + } |
|
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
| 112 | 116 | { |
| 113 | 117 | $command_line = true; |
| 114 | 118 | $disable_security = true; |
| 115 | -} |
|
| 116 | -else |
|
| 119 | +} else { |
|
| 117 | 120 | $command_line = false; |
| 121 | +} |
|
| 118 | 122 | |
| 119 | 123 | // Load this now just because we can. |
| 120 | 124 | require_once($upgrade_path . '/Settings.php'); |
| 121 | 125 | |
| 122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 123 | -if (isset($language)) |
|
| 127 | +if (isset($language)) { |
|
| 124 | 128 | $language = str_ireplace('-utf8', '', $language); |
| 129 | +} |
|
| 125 | 130 | |
| 126 | 131 | // Are we logged in? |
| 127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
| 129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 130 | 135 | |
| 131 | 136 | // Check for sensible values. |
| 132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 133 | - $upcontext['user']['started'] = time(); |
|
| 134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 135 | - $upcontext['user']['updated'] = 0; |
|
| 137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 138 | + $upcontext['user']['started'] = time(); |
|
| 139 | + } |
|
| 140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 141 | + $upcontext['user']['updated'] = 0; |
|
| 142 | + } |
|
| 136 | 143 | |
| 137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
| 138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -190,8 +197,9 @@ discard block |
||
| 190 | 197 | 'db_error_skip' => true, |
| 191 | 198 | ) |
| 192 | 199 | ); |
| 193 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 194 | - $modSettings[$row['variable']] = $row['value']; |
|
| 200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 201 | + $modSettings[$row['variable']] = $row['value']; |
|
| 202 | + } |
|
| 195 | 203 | $smcFunc['db_free_result']($request); |
| 196 | 204 | } |
| 197 | 205 | |
@@ -201,10 +209,12 @@ discard block |
||
| 201 | 209 | $modSettings['theme_url'] = 'Themes/default'; |
| 202 | 210 | $modSettings['images_url'] = 'Themes/default/images'; |
| 203 | 211 | } |
| 204 | -if (!isset($settings['default_theme_url'])) |
|
| 212 | +if (!isset($settings['default_theme_url'])) { |
|
| 205 | 213 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 206 | -if (!isset($settings['default_theme_dir'])) |
|
| 214 | +} |
|
| 215 | +if (!isset($settings['default_theme_dir'])) { |
|
| 207 | 216 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 217 | +} |
|
| 208 | 218 | |
| 209 | 219 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 210 | 220 | // Default title... |
@@ -222,13 +232,15 @@ discard block |
||
| 222 | 232 | $support_js = $upcontext['upgrade_status']['js']; |
| 223 | 233 | |
| 224 | 234 | // Only set this if the upgrader status says so. |
| 225 | - if (empty($is_debug)) |
|
| 226 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 235 | + if (empty($is_debug)) { |
|
| 236 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 237 | + } |
|
| 227 | 238 | |
| 228 | 239 | // Load the language. |
| 229 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 230 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 231 | -} |
|
| 240 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 241 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 242 | + } |
|
| 243 | + } |
|
| 232 | 244 | // Set the defaults. |
| 233 | 245 | else |
| 234 | 246 | { |
@@ -246,15 +258,18 @@ discard block |
||
| 246 | 258 | } |
| 247 | 259 | |
| 248 | 260 | // If this isn't the first stage see whether they are logging in and resuming. |
| 249 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 261 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 250 | 262 | checkLogin(); |
| 263 | +} |
|
| 251 | 264 | |
| 252 | -if ($command_line) |
|
| 265 | +if ($command_line) { |
|
| 253 | 266 | cmdStep0(); |
| 267 | +} |
|
| 254 | 268 | |
| 255 | 269 | // Don't error if we're using xml. |
| 256 | -if (isset($_GET['xml'])) |
|
| 270 | +if (isset($_GET['xml'])) { |
|
| 257 | 271 | $upcontext['return_error'] = true; |
| 272 | +} |
|
| 258 | 273 | |
| 259 | 274 | // Loop through all the steps doing each one as required. |
| 260 | 275 | $upcontext['overall_percent'] = 0; |
@@ -275,9 +290,9 @@ discard block |
||
| 275 | 290 | } |
| 276 | 291 | |
| 277 | 292 | // Call the step and if it returns false that means pause! |
| 278 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 279 | - break; |
|
| 280 | - elseif (function_exists($step[2])) { |
|
| 293 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 294 | + break; |
|
| 295 | + } elseif (function_exists($step[2])) { |
|
| 281 | 296 | //Start each new step with this unset, so the 'normal' template is called first |
| 282 | 297 | unset($_GET['xml']); |
| 283 | 298 | $_GET['substep'] = 0; |
@@ -321,17 +336,18 @@ discard block |
||
| 321 | 336 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 322 | 337 | if (!empty($command_line)) |
| 323 | 338 | { |
| 324 | - if (function_exists('debug_print_backtrace')) |
|
| 325 | - debug_print_backtrace(); |
|
| 339 | + if (function_exists('debug_print_backtrace')) { |
|
| 340 | + debug_print_backtrace(); |
|
| 341 | + } |
|
| 326 | 342 | |
| 327 | 343 | 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.'; |
| 328 | 344 | flush(); |
| 329 | 345 | die(); |
| 330 | 346 | } |
| 331 | 347 | |
| 332 | - if (!isset($_GET['xml'])) |
|
| 333 | - template_upgrade_above(); |
|
| 334 | - else |
|
| 348 | + if (!isset($_GET['xml'])) { |
|
| 349 | + template_upgrade_above(); |
|
| 350 | + } else |
|
| 335 | 351 | { |
| 336 | 352 | header('Content-Type: text/xml; charset=UTF-8'); |
| 337 | 353 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -353,25 +369,29 @@ discard block |
||
| 353 | 369 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 354 | 370 | |
| 355 | 371 | // Custom stuff to pass back? |
| 356 | - if (!empty($upcontext['query_string'])) |
|
| 357 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 372 | + if (!empty($upcontext['query_string'])) { |
|
| 373 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 374 | + } |
|
| 358 | 375 | |
| 359 | 376 | // Call the appropriate subtemplate |
| 360 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 361 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 362 | - else |
|
| 363 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 377 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 378 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 379 | + } else { |
|
| 380 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 381 | + } |
|
| 364 | 382 | } |
| 365 | 383 | |
| 366 | 384 | // Was there an error? |
| 367 | - if (!empty($upcontext['forced_error_message'])) |
|
| 368 | - echo $upcontext['forced_error_message']; |
|
| 385 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 386 | + echo $upcontext['forced_error_message']; |
|
| 387 | + } |
|
| 369 | 388 | |
| 370 | 389 | // Show the footer. |
| 371 | - if (!isset($_GET['xml'])) |
|
| 372 | - template_upgrade_below(); |
|
| 373 | - else |
|
| 374 | - template_xml_below(); |
|
| 390 | + if (!isset($_GET['xml'])) { |
|
| 391 | + template_upgrade_below(); |
|
| 392 | + } else { |
|
| 393 | + template_xml_below(); |
|
| 394 | + } |
|
| 375 | 395 | } |
| 376 | 396 | |
| 377 | 397 | |
@@ -383,15 +403,19 @@ discard block |
||
| 383 | 403 | $seconds = intval($active % 60); |
| 384 | 404 | |
| 385 | 405 | $totalTime = ''; |
| 386 | - if ($hours > 0) |
|
| 387 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 388 | - if ($minutes > 0) |
|
| 389 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 390 | - if ($seconds > 0) |
|
| 391 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 406 | + if ($hours > 0) { |
|
| 407 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 408 | + } |
|
| 409 | + if ($minutes > 0) { |
|
| 410 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 411 | + } |
|
| 412 | + if ($seconds > 0) { |
|
| 413 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 414 | + } |
|
| 392 | 415 | |
| 393 | - if (!empty($totalTime)) |
|
| 394 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 416 | + if (!empty($totalTime)) { |
|
| 417 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 418 | + } |
|
| 395 | 419 | } |
| 396 | 420 | |
| 397 | 421 | // Bang - gone! |
@@ -404,8 +428,9 @@ discard block |
||
| 404 | 428 | global $upgradeurl, $upcontext, $command_line; |
| 405 | 429 | |
| 406 | 430 | // Command line users can't be redirected. |
| 407 | - if ($command_line) |
|
| 408 | - upgradeExit(true); |
|
| 431 | + if ($command_line) { |
|
| 432 | + upgradeExit(true); |
|
| 433 | + } |
|
| 409 | 434 | |
| 410 | 435 | // Are we providing the core info? |
| 411 | 436 | if ($addForm) |
@@ -431,12 +456,14 @@ discard block |
||
| 431 | 456 | define('SMF', 1); |
| 432 | 457 | |
| 433 | 458 | // Start the session. |
| 434 | - if (@ini_get('session.save_handler') == 'user') |
|
| 435 | - @ini_set('session.save_handler', 'files'); |
|
| 459 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 460 | + @ini_set('session.save_handler', 'files'); |
|
| 461 | + } |
|
| 436 | 462 | @session_start(); |
| 437 | 463 | |
| 438 | - if (empty($smcFunc)) |
|
| 439 | - $smcFunc = array(); |
|
| 464 | + if (empty($smcFunc)) { |
|
| 465 | + $smcFunc = array(); |
|
| 466 | + } |
|
| 440 | 467 | |
| 441 | 468 | // We need this for authentication and some upgrade code |
| 442 | 469 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -448,32 +475,36 @@ discard block |
||
| 448 | 475 | initialize_inputs(); |
| 449 | 476 | |
| 450 | 477 | // Get the database going! |
| 451 | - if (empty($db_type) || $db_type == 'mysqli') |
|
| 452 | - $db_type = 'mysql'; |
|
| 478 | + if (empty($db_type) || $db_type == 'mysqli') { |
|
| 479 | + $db_type = 'mysql'; |
|
| 480 | + } |
|
| 453 | 481 | |
| 454 | 482 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
| 455 | 483 | { |
| 456 | 484 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 457 | 485 | |
| 458 | 486 | // Make the connection... |
| 459 | - if (empty($db_connection)) |
|
| 460 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 461 | - else |
|
| 462 | - // If we've returned here, ping/reconnect to be safe |
|
| 487 | + if (empty($db_connection)) { |
|
| 488 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 489 | + } else { |
|
| 490 | + // If we've returned here, ping/reconnect to be safe |
|
| 463 | 491 | $smcFunc['db_ping']($db_connection); |
| 492 | + } |
|
| 464 | 493 | |
| 465 | 494 | // Oh dear god!! |
| 466 | - if ($db_connection === null) |
|
| 467 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 495 | + if ($db_connection === null) { |
|
| 496 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 497 | + } |
|
| 468 | 498 | |
| 469 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 470 | - $smcFunc['db_query']('', ' |
|
| 499 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 500 | + $smcFunc['db_query']('', ' |
|
| 471 | 501 | SET NAMES {string:db_character_set}', |
| 472 | 502 | array( |
| 473 | 503 | 'db_error_skip' => true, |
| 474 | 504 | 'db_character_set' => $db_character_set, |
| 475 | 505 | ) |
| 476 | 506 | ); |
| 507 | + } |
|
| 477 | 508 | |
| 478 | 509 | // Load the modSettings data... |
| 479 | 510 | $request = $smcFunc['db_query']('', ' |
@@ -484,11 +515,11 @@ discard block |
||
| 484 | 515 | ) |
| 485 | 516 | ); |
| 486 | 517 | $modSettings = array(); |
| 487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 488 | - $modSettings[$row['variable']] = $row['value']; |
|
| 518 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 519 | + $modSettings[$row['variable']] = $row['value']; |
|
| 520 | + } |
|
| 489 | 521 | $smcFunc['db_free_result']($request); |
| 490 | - } |
|
| 491 | - else |
|
| 522 | + } else |
|
| 492 | 523 | { |
| 493 | 524 | 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.'); |
| 494 | 525 | } |
@@ -502,9 +533,10 @@ discard block |
||
| 502 | 533 | cleanRequest(); |
| 503 | 534 | } |
| 504 | 535 | |
| 505 | - if (!isset($_GET['substep'])) |
|
| 506 | - $_GET['substep'] = 0; |
|
| 507 | -} |
|
| 536 | + if (!isset($_GET['substep'])) { |
|
| 537 | + $_GET['substep'] = 0; |
|
| 538 | + } |
|
| 539 | + } |
|
| 508 | 540 | |
| 509 | 541 | function initialize_inputs() |
| 510 | 542 | { |
@@ -534,8 +566,9 @@ discard block |
||
| 534 | 566 | $dh = opendir(dirname(__FILE__)); |
| 535 | 567 | while ($file = readdir($dh)) |
| 536 | 568 | { |
| 537 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 538 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 569 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 570 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 571 | + } |
|
| 539 | 572 | } |
| 540 | 573 | closedir($dh); |
| 541 | 574 | |
@@ -564,8 +597,9 @@ discard block |
||
| 564 | 597 | $temp = 'upgrade_php?step'; |
| 565 | 598 | while (strlen($temp) > 4) |
| 566 | 599 | { |
| 567 | - if (isset($_GET[$temp])) |
|
| 568 | - unset($_GET[$temp]); |
|
| 600 | + if (isset($_GET[$temp])) { |
|
| 601 | + unset($_GET[$temp]); |
|
| 602 | + } |
|
| 569 | 603 | $temp = substr($temp, 1); |
| 570 | 604 | } |
| 571 | 605 | |
@@ -592,32 +626,39 @@ discard block |
||
| 592 | 626 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 593 | 627 | |
| 594 | 628 | // Need legacy scripts? |
| 595 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 596 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 597 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 598 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 599 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 600 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 629 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 630 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 631 | + } |
|
| 632 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 633 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 634 | + } |
|
| 635 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 636 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 637 | + } |
|
| 601 | 638 | |
| 602 | 639 | // We don't need "-utf8" files anymore... |
| 603 | 640 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 604 | 641 | |
| 605 | 642 | // This needs to exist! |
| 606 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 607 | - 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>]'); |
|
| 608 | - else |
|
| 609 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 643 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 644 | + 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>]'); |
|
| 645 | + } else { |
|
| 646 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 647 | + } |
|
| 610 | 648 | |
| 611 | - if (!$check) |
|
| 612 | - // 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. |
|
| 649 | + if (!$check) { |
|
| 650 | + // 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. |
|
| 613 | 651 | 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.'); |
| 652 | + } |
|
| 614 | 653 | |
| 615 | 654 | // Do they meet the install requirements? |
| 616 | - if (!php_version_check()) |
|
| 617 | - 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.'); |
|
| 655 | + if (!php_version_check()) { |
|
| 656 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 657 | + } |
|
| 618 | 658 | |
| 619 | - if (!db_version_check()) |
|
| 620 | - 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.'); |
|
| 659 | + if (!db_version_check()) { |
|
| 660 | + 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.'); |
|
| 661 | + } |
|
| 621 | 662 | |
| 622 | 663 | // Do some checks to make sure they have proper privileges |
| 623 | 664 | db_extend('packages'); |
@@ -632,14 +673,16 @@ discard block |
||
| 632 | 673 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 633 | 674 | |
| 634 | 675 | // Sorry... we need CREATE, ALTER and DROP |
| 635 | - if (!$create || !$alter || !$drop) |
|
| 636 | - 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.'); |
|
| 676 | + if (!$create || !$alter || !$drop) { |
|
| 677 | + 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.'); |
|
| 678 | + } |
|
| 637 | 679 | |
| 638 | 680 | // Do a quick version spot check. |
| 639 | 681 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 640 | 682 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 641 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 642 | - 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.'); |
|
| 683 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 684 | + 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.'); |
|
| 685 | + } |
|
| 643 | 686 | |
| 644 | 687 | // What absolutely needs to be writable? |
| 645 | 688 | $writable_files = array( |
@@ -661,12 +704,13 @@ discard block |
||
| 661 | 704 | quickFileWritable($custom_av_dir); |
| 662 | 705 | |
| 663 | 706 | // Are we good now? |
| 664 | - if (!is_writable($custom_av_dir)) |
|
| 665 | - 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)); |
|
| 666 | - elseif ($need_settings_update) |
|
| 707 | + if (!is_writable($custom_av_dir)) { |
|
| 708 | + 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)); |
|
| 709 | + } elseif ($need_settings_update) |
|
| 667 | 710 | { |
| 668 | - if (!function_exists('cache_put_data')) |
|
| 669 | - require_once($sourcedir . '/Load.php'); |
|
| 711 | + if (!function_exists('cache_put_data')) { |
|
| 712 | + require_once($sourcedir . '/Load.php'); |
|
| 713 | + } |
|
| 670 | 714 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 671 | 715 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 672 | 716 | } |
@@ -675,28 +719,33 @@ discard block |
||
| 675 | 719 | |
| 676 | 720 | // Check the cache directory. |
| 677 | 721 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 678 | - if (!file_exists($cachedir_temp)) |
|
| 679 | - @mkdir($cachedir_temp); |
|
| 680 | - if (!file_exists($cachedir_temp)) |
|
| 681 | - 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.'); |
|
| 682 | - |
|
| 683 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 684 | - 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>.'); |
|
| 685 | - elseif (!isset($_GET['skiplang'])) |
|
| 722 | + if (!file_exists($cachedir_temp)) { |
|
| 723 | + @mkdir($cachedir_temp); |
|
| 724 | + } |
|
| 725 | + if (!file_exists($cachedir_temp)) { |
|
| 726 | + 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.'); |
|
| 727 | + } |
|
| 728 | + |
|
| 729 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 730 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 731 | + } elseif (!isset($_GET['skiplang'])) |
|
| 686 | 732 | { |
| 687 | 733 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 688 | 734 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 689 | 735 | |
| 690 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 691 | - 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>]'); |
|
| 736 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 737 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 738 | + } |
|
| 692 | 739 | } |
| 693 | 740 | |
| 694 | - if (!makeFilesWritable($writable_files)) |
|
| 695 | - return false; |
|
| 741 | + if (!makeFilesWritable($writable_files)) { |
|
| 742 | + return false; |
|
| 743 | + } |
|
| 696 | 744 | |
| 697 | 745 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 698 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 699 | - 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.'); |
|
| 746 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 747 | + 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.'); |
|
| 748 | + } |
|
| 700 | 749 | |
| 701 | 750 | // Upgrade the agreement. |
| 702 | 751 | elseif (isset($modSettings['agreement'])) |
@@ -707,8 +756,8 @@ discard block |
||
| 707 | 756 | } |
| 708 | 757 | |
| 709 | 758 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 710 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 711 | - $upcontext['warning'] = ' |
|
| 759 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 760 | + $upcontext['warning'] = ' |
|
| 712 | 761 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
| 713 | 762 | <ul> |
| 714 | 763 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -716,10 +765,12 @@ discard block |
||
| 716 | 765 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 717 | 766 | </ul> |
| 718 | 767 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 768 | + } |
|
| 719 | 769 | |
| 720 | 770 | // Either we're logged in or we're going to present the login. |
| 721 | - if (checkLogin()) |
|
| 722 | - return true; |
|
| 771 | + if (checkLogin()) { |
|
| 772 | + return true; |
|
| 773 | + } |
|
| 723 | 774 | |
| 724 | 775 | $upcontext += createToken('login'); |
| 725 | 776 | |
@@ -733,15 +784,17 @@ discard block |
||
| 733 | 784 | global $smcFunc, $db_type, $support_js; |
| 734 | 785 | |
| 735 | 786 | // Don't bother if the security is disabled. |
| 736 | - if ($disable_security) |
|
| 737 | - return true; |
|
| 787 | + if ($disable_security) { |
|
| 788 | + return true; |
|
| 789 | + } |
|
| 738 | 790 | |
| 739 | 791 | // Are we trying to login? |
| 740 | 792 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 741 | 793 | { |
| 742 | 794 | // If we've disabled security pick a suitable name! |
| 743 | - if (empty($_POST['user'])) |
|
| 744 | - $_POST['user'] = 'Administrator'; |
|
| 795 | + if (empty($_POST['user'])) { |
|
| 796 | + $_POST['user'] = 'Administrator'; |
|
| 797 | + } |
|
| 745 | 798 | |
| 746 | 799 | // Before 2.0 these column names were different! |
| 747 | 800 | $oldDB = false; |
@@ -756,16 +809,17 @@ discard block |
||
| 756 | 809 | 'db_error_skip' => true, |
| 757 | 810 | ) |
| 758 | 811 | ); |
| 759 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 760 | - $oldDB = true; |
|
| 812 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 813 | + $oldDB = true; |
|
| 814 | + } |
|
| 761 | 815 | $smcFunc['db_free_result']($request); |
| 762 | 816 | } |
| 763 | 817 | |
| 764 | 818 | // Get what we believe to be their details. |
| 765 | 819 | if (!$disable_security) |
| 766 | 820 | { |
| 767 | - if ($oldDB) |
|
| 768 | - $request = $smcFunc['db_query']('', ' |
|
| 821 | + if ($oldDB) { |
|
| 822 | + $request = $smcFunc['db_query']('', ' |
|
| 769 | 823 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 770 | 824 | additionalGroups AS additional_groups, lngfile |
| 771 | 825 | FROM {db_prefix}members |
@@ -775,8 +829,8 @@ discard block |
||
| 775 | 829 | 'db_error_skip' => true, |
| 776 | 830 | ) |
| 777 | 831 | ); |
| 778 | - else |
|
| 779 | - $request = $smcFunc['db_query']('', ' |
|
| 832 | + } else { |
|
| 833 | + $request = $smcFunc['db_query']('', ' |
|
| 780 | 834 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 781 | 835 | FROM {db_prefix}members |
| 782 | 836 | WHERE member_name = {string:member_name}', |
@@ -785,6 +839,7 @@ discard block |
||
| 785 | 839 | 'db_error_skip' => true, |
| 786 | 840 | ) |
| 787 | 841 | ); |
| 842 | + } |
|
| 788 | 843 | if ($smcFunc['db_num_rows']($request) != 0) |
| 789 | 844 | { |
| 790 | 845 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -792,16 +847,17 @@ discard block |
||
| 792 | 847 | $groups = explode(',', $addGroups); |
| 793 | 848 | $groups[] = $id_group; |
| 794 | 849 | |
| 795 | - foreach ($groups as $k => $v) |
|
| 796 | - $groups[$k] = (int) $v; |
|
| 850 | + foreach ($groups as $k => $v) { |
|
| 851 | + $groups[$k] = (int) $v; |
|
| 852 | + } |
|
| 797 | 853 | |
| 798 | 854 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 799 | 855 | |
| 800 | 856 | // We don't use "-utf8" anymore... |
| 801 | 857 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 858 | + } else { |
|
| 859 | + $upcontext['username_incorrect'] = true; |
|
| 802 | 860 | } |
| 803 | - else |
|
| 804 | - $upcontext['username_incorrect'] = true; |
|
| 805 | 861 | $smcFunc['db_free_result']($request); |
| 806 | 862 | } |
| 807 | 863 | $upcontext['username'] = $_POST['user']; |
@@ -811,13 +867,14 @@ discard block |
||
| 811 | 867 | { |
| 812 | 868 | $upcontext['upgrade_status']['js'] = 1; |
| 813 | 869 | $support_js = 1; |
| 870 | + } else { |
|
| 871 | + $support_js = 0; |
|
| 814 | 872 | } |
| 815 | - else |
|
| 816 | - $support_js = 0; |
|
| 817 | 873 | |
| 818 | 874 | // Note down the version we are coming from. |
| 819 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 820 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 875 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 876 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 877 | + } |
|
| 821 | 878 | |
| 822 | 879 | // Didn't get anywhere? |
| 823 | 880 | 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'])) |
@@ -851,15 +908,15 @@ discard block |
||
| 851 | 908 | 'db_error_skip' => true, |
| 852 | 909 | ) |
| 853 | 910 | ); |
| 854 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 855 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 911 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 912 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 913 | + } |
|
| 856 | 914 | $smcFunc['db_free_result']($request); |
| 857 | 915 | } |
| 858 | 916 | |
| 859 | 917 | $upcontext['user']['id'] = $id_member; |
| 860 | 918 | $upcontext['user']['name'] = $name; |
| 861 | - } |
|
| 862 | - else |
|
| 919 | + } else |
|
| 863 | 920 | { |
| 864 | 921 | $upcontext['user']['id'] = 1; |
| 865 | 922 | $upcontext['user']['name'] = 'Administrator'; |
@@ -875,11 +932,11 @@ discard block |
||
| 875 | 932 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 876 | 933 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 877 | 934 | |
| 878 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 879 | - $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'] . '.'; |
|
| 880 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 881 | - $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'] . '.'; |
|
| 882 | - else |
|
| 935 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 936 | + $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'] . '.'; |
|
| 937 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 938 | + $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'] . '.'; |
|
| 939 | + } else |
|
| 883 | 940 | { |
| 884 | 941 | // Set this as the new language. |
| 885 | 942 | $upcontext['language'] = $user_language; |
@@ -923,8 +980,9 @@ discard block |
||
| 923 | 980 | unset($member_columns); |
| 924 | 981 | |
| 925 | 982 | // If we've not submitted then we're done. |
| 926 | - if (empty($_POST['upcont'])) |
|
| 927 | - return false; |
|
| 983 | + if (empty($_POST['upcont'])) { |
|
| 984 | + return false; |
|
| 985 | + } |
|
| 928 | 986 | |
| 929 | 987 | // Firstly, if they're enabling SM stat collection just do it. |
| 930 | 988 | if (!empty($_POST['stats']) && (substr($boardurl, 0, 16) != 'http://localhost' || substr($boardurl, 0, 16) != 'https://localhost') && empty($modSettings['allow_sm_stats'])) |
@@ -939,25 +997,26 @@ discard block |
||
| 939 | 997 | fwrite($fp, $out); |
| 940 | 998 | |
| 941 | 999 | $return_data = ''; |
| 942 | - while (!feof($fp)) |
|
| 943 | - $return_data .= fgets($fp, 128); |
|
| 1000 | + while (!feof($fp)) { |
|
| 1001 | + $return_data .= fgets($fp, 128); |
|
| 1002 | + } |
|
| 944 | 1003 | |
| 945 | 1004 | fclose($fp); |
| 946 | 1005 | |
| 947 | 1006 | // Get the unique site ID. |
| 948 | 1007 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 949 | 1008 | |
| 950 | - if (!empty($ID[1])) |
|
| 951 | - $smcFunc['db_insert']('replace', |
|
| 1009 | + if (!empty($ID[1])) { |
|
| 1010 | + $smcFunc['db_insert']('replace', |
|
| 952 | 1011 | $db_prefix . 'settings', |
| 953 | 1012 | array('variable' => 'string', 'value' => 'string'), |
| 954 | 1013 | array('allow_sm_stats', $ID[1]), |
| 955 | 1014 | array('variable') |
| 956 | 1015 | ); |
| 1016 | + } |
|
| 957 | 1017 | } |
| 958 | - } |
|
| 959 | - else |
|
| 960 | - $smcFunc['db_query']('', ' |
|
| 1018 | + } else { |
|
| 1019 | + $smcFunc['db_query']('', ' |
|
| 961 | 1020 | DELETE FROM {db_prefix}settings |
| 962 | 1021 | WHERE variable = {string:allow_sm_stats}', |
| 963 | 1022 | array( |
@@ -965,6 +1024,7 @@ discard block |
||
| 965 | 1024 | 'db_error_skip' => true, |
| 966 | 1025 | ) |
| 967 | 1026 | ); |
| 1027 | + } |
|
| 968 | 1028 | |
| 969 | 1029 | // Deleting old karma stuff? |
| 970 | 1030 | if (!empty($_POST['delete_karma'])) |
@@ -979,20 +1039,22 @@ discard block |
||
| 979 | 1039 | ); |
| 980 | 1040 | |
| 981 | 1041 | // Cleaning up old karma member settings. |
| 982 | - if ($upcontext['karma_installed']['good']) |
|
| 983 | - $smcFunc['db_query']('', ' |
|
| 1042 | + if ($upcontext['karma_installed']['good']) { |
|
| 1043 | + $smcFunc['db_query']('', ' |
|
| 984 | 1044 | ALTER TABLE {db_prefix}members |
| 985 | 1045 | DROP karma_good', |
| 986 | 1046 | array() |
| 987 | 1047 | ); |
| 1048 | + } |
|
| 988 | 1049 | |
| 989 | 1050 | // Does karma bad was enable? |
| 990 | - if ($upcontext['karma_installed']['bad']) |
|
| 991 | - $smcFunc['db_query']('', ' |
|
| 1051 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1052 | + $smcFunc['db_query']('', ' |
|
| 992 | 1053 | ALTER TABLE {db_prefix}members |
| 993 | 1054 | DROP karma_bad', |
| 994 | 1055 | array() |
| 995 | 1056 | ); |
| 1057 | + } |
|
| 996 | 1058 | |
| 997 | 1059 | // Cleaning up old karma permissions. |
| 998 | 1060 | $smcFunc['db_query']('', ' |
@@ -1005,26 +1067,29 @@ discard block |
||
| 1005 | 1067 | } |
| 1006 | 1068 | |
| 1007 | 1069 | // Emptying the error log? |
| 1008 | - if (!empty($_POST['empty_error'])) |
|
| 1009 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1070 | + if (!empty($_POST['empty_error'])) { |
|
| 1071 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1010 | 1072 | TRUNCATE {db_prefix}log_errors', |
| 1011 | 1073 | array( |
| 1012 | 1074 | ) |
| 1013 | 1075 | ); |
| 1076 | + } |
|
| 1014 | 1077 | |
| 1015 | 1078 | $changes = array(); |
| 1016 | 1079 | |
| 1017 | 1080 | // Add proxy settings. |
| 1018 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1019 | - $changes += array( |
|
| 1081 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1082 | + $changes += array( |
|
| 1020 | 1083 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1021 | 1084 | 'image_proxy_maxsize' => 5190, |
| 1022 | 1085 | 'image_proxy_enabled' => 0, |
| 1023 | 1086 | ); |
| 1087 | + } |
|
| 1024 | 1088 | |
| 1025 | 1089 | // If we're overriding the language follow it through. |
| 1026 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1027 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1090 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1091 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1092 | + } |
|
| 1028 | 1093 | |
| 1029 | 1094 | if (!empty($_POST['maint'])) |
| 1030 | 1095 | { |
@@ -1036,30 +1101,34 @@ discard block |
||
| 1036 | 1101 | { |
| 1037 | 1102 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1038 | 1103 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1039 | - } |
|
| 1040 | - else |
|
| 1104 | + } else |
|
| 1041 | 1105 | { |
| 1042 | 1106 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1043 | 1107 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1044 | 1108 | } |
| 1045 | 1109 | } |
| 1046 | 1110 | |
| 1047 | - if ($command_line) |
|
| 1048 | - echo ' * Updating Settings.php...'; |
|
| 1111 | + if ($command_line) { |
|
| 1112 | + echo ' * Updating Settings.php...'; |
|
| 1113 | + } |
|
| 1049 | 1114 | |
| 1050 | 1115 | // Fix some old paths. |
| 1051 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1052 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1116 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1117 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1118 | + } |
|
| 1053 | 1119 | |
| 1054 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1055 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1120 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1121 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1122 | + } |
|
| 1056 | 1123 | |
| 1057 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1058 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1124 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1125 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1126 | + } |
|
| 1059 | 1127 | |
| 1060 | 1128 | // Not had the database type added before? |
| 1061 | - if (empty($db_type)) |
|
| 1062 | - $changes['db_type'] = 'mysql'; |
|
| 1129 | + if (empty($db_type)) { |
|
| 1130 | + $changes['db_type'] = 'mysql'; |
|
| 1131 | + } |
|
| 1063 | 1132 | |
| 1064 | 1133 | // If they have a "host:port" setup for the host, split that into separate values |
| 1065 | 1134 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1070,32 +1139,36 @@ discard block |
||
| 1070 | 1139 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1071 | 1140 | |
| 1072 | 1141 | // Only set this if we're not using the default port |
| 1073 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1074 | - $changes['db_port'] = (int) $db_port; |
|
| 1075 | - } |
|
| 1076 | - elseif (!empty($db_port)) |
|
| 1142 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1143 | + $changes['db_port'] = (int) $db_port; |
|
| 1144 | + } |
|
| 1145 | + } elseif (!empty($db_port)) |
|
| 1077 | 1146 | { |
| 1078 | 1147 | // If db_port is set and is the same as the default, set it to '' |
| 1079 | 1148 | if ($db_type == 'mysql') |
| 1080 | 1149 | { |
| 1081 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1082 | - $changes['db_port'] = '\'\''; |
|
| 1083 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1084 | - $changes['db_port'] = '\'\''; |
|
| 1150 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1151 | + $changes['db_port'] = '\'\''; |
|
| 1152 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1153 | + $changes['db_port'] = '\'\''; |
|
| 1154 | + } |
|
| 1085 | 1155 | } |
| 1086 | 1156 | } |
| 1087 | 1157 | |
| 1088 | 1158 | // Maybe we haven't had this option yet? |
| 1089 | - if (empty($packagesdir)) |
|
| 1090 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1159 | + if (empty($packagesdir)) { |
|
| 1160 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1161 | + } |
|
| 1091 | 1162 | |
| 1092 | 1163 | // Add support for $tasksdir var. |
| 1093 | - if (empty($tasksdir)) |
|
| 1094 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1164 | + if (empty($tasksdir)) { |
|
| 1165 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1166 | + } |
|
| 1095 | 1167 | |
| 1096 | 1168 | // Make sure we fix the language as well. |
| 1097 | - if (stristr($language, '-utf8')) |
|
| 1098 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1169 | + if (stristr($language, '-utf8')) { |
|
| 1170 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1171 | + } |
|
| 1099 | 1172 | |
| 1100 | 1173 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1101 | 1174 | |
@@ -1103,8 +1176,9 @@ discard block |
||
| 1103 | 1176 | require_once($sourcedir . '/Subs-Admin.php'); |
| 1104 | 1177 | updateSettingsFile($changes); |
| 1105 | 1178 | |
| 1106 | - if ($command_line) |
|
| 1107 | - echo ' Successful.' . "\n"; |
|
| 1179 | + if ($command_line) { |
|
| 1180 | + echo ' Successful.' . "\n"; |
|
| 1181 | + } |
|
| 1108 | 1182 | |
| 1109 | 1183 | // Are we doing debug? |
| 1110 | 1184 | if (isset($_POST['debug'])) |
@@ -1114,8 +1188,9 @@ discard block |
||
| 1114 | 1188 | } |
| 1115 | 1189 | |
| 1116 | 1190 | // If we're not backing up then jump one. |
| 1117 | - if (empty($_POST['backup'])) |
|
| 1118 | - $upcontext['current_step']++; |
|
| 1191 | + if (empty($_POST['backup'])) { |
|
| 1192 | + $upcontext['current_step']++; |
|
| 1193 | + } |
|
| 1119 | 1194 | |
| 1120 | 1195 | // If we've got here then let's proceed to the next step! |
| 1121 | 1196 | return true; |
@@ -1130,8 +1205,9 @@ discard block |
||
| 1130 | 1205 | $upcontext['page_title'] = 'Backup Database'; |
| 1131 | 1206 | |
| 1132 | 1207 | // Done it already - js wise? |
| 1133 | - if (!empty($_POST['backup_done'])) |
|
| 1134 | - return true; |
|
| 1208 | + if (!empty($_POST['backup_done'])) { |
|
| 1209 | + return true; |
|
| 1210 | + } |
|
| 1135 | 1211 | |
| 1136 | 1212 | // Some useful stuff here. |
| 1137 | 1213 | db_extend(); |
@@ -1145,9 +1221,10 @@ discard block |
||
| 1145 | 1221 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1146 | 1222 | |
| 1147 | 1223 | $table_names = array(); |
| 1148 | - foreach ($tables as $table) |
|
| 1149 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1224 | + foreach ($tables as $table) { |
|
| 1225 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1150 | 1226 | $table_names[] = $table; |
| 1227 | + } |
|
| 1151 | 1228 | |
| 1152 | 1229 | $upcontext['table_count'] = count($table_names); |
| 1153 | 1230 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1157,12 +1234,14 @@ discard block |
||
| 1157 | 1234 | $file_steps = $upcontext['table_count']; |
| 1158 | 1235 | |
| 1159 | 1236 | // What ones have we already done? |
| 1160 | - foreach ($table_names as $id => $table) |
|
| 1161 | - if ($id < $_GET['substep']) |
|
| 1237 | + foreach ($table_names as $id => $table) { |
|
| 1238 | + if ($id < $_GET['substep']) |
|
| 1162 | 1239 | $upcontext['previous_tables'][] = $table; |
| 1240 | + } |
|
| 1163 | 1241 | |
| 1164 | - if ($command_line) |
|
| 1165 | - echo 'Backing Up Tables.'; |
|
| 1242 | + if ($command_line) { |
|
| 1243 | + echo 'Backing Up Tables.'; |
|
| 1244 | + } |
|
| 1166 | 1245 | |
| 1167 | 1246 | // If we don't support javascript we backup here. |
| 1168 | 1247 | if (!$support_js || isset($_GET['xml'])) |
@@ -1181,8 +1260,9 @@ discard block |
||
| 1181 | 1260 | backupTable($table_names[$substep]); |
| 1182 | 1261 | |
| 1183 | 1262 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1184 | - if (isset($_GET['xml'])) |
|
| 1185 | - return upgradeExit(); |
|
| 1263 | + if (isset($_GET['xml'])) { |
|
| 1264 | + return upgradeExit(); |
|
| 1265 | + } |
|
| 1186 | 1266 | } |
| 1187 | 1267 | |
| 1188 | 1268 | if ($command_line) |
@@ -1215,9 +1295,10 @@ discard block |
||
| 1215 | 1295 | |
| 1216 | 1296 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1217 | 1297 | |
| 1218 | - if ($command_line) |
|
| 1219 | - echo ' done.'; |
|
| 1220 | -} |
|
| 1298 | + if ($command_line) { |
|
| 1299 | + echo ' done.'; |
|
| 1300 | + } |
|
| 1301 | + } |
|
| 1221 | 1302 | |
| 1222 | 1303 | // Step 2: Everything. |
| 1223 | 1304 | function DatabaseChanges() |
@@ -1226,8 +1307,9 @@ discard block |
||
| 1226 | 1307 | global $upcontext, $support_js, $db_type; |
| 1227 | 1308 | |
| 1228 | 1309 | // Have we just completed this? |
| 1229 | - if (!empty($_POST['database_done'])) |
|
| 1230 | - return true; |
|
| 1310 | + if (!empty($_POST['database_done'])) { |
|
| 1311 | + return true; |
|
| 1312 | + } |
|
| 1231 | 1313 | |
| 1232 | 1314 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1233 | 1315 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1242,15 +1324,16 @@ discard block |
||
| 1242 | 1324 | ); |
| 1243 | 1325 | |
| 1244 | 1326 | // How many files are there in total? |
| 1245 | - if (isset($_GET['filecount'])) |
|
| 1246 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1247 | - else |
|
| 1327 | + if (isset($_GET['filecount'])) { |
|
| 1328 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1329 | + } else |
|
| 1248 | 1330 | { |
| 1249 | 1331 | $upcontext['file_count'] = 0; |
| 1250 | 1332 | foreach ($files as $file) |
| 1251 | 1333 | { |
| 1252 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1253 | - $upcontext['file_count']++; |
|
| 1334 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1335 | + $upcontext['file_count']++; |
|
| 1336 | + } |
|
| 1254 | 1337 | } |
| 1255 | 1338 | } |
| 1256 | 1339 | |
@@ -1260,9 +1343,9 @@ discard block |
||
| 1260 | 1343 | $upcontext['cur_file_num'] = 0; |
| 1261 | 1344 | foreach ($files as $file) |
| 1262 | 1345 | { |
| 1263 | - if ($did_not_do) |
|
| 1264 | - $did_not_do--; |
|
| 1265 | - else |
|
| 1346 | + if ($did_not_do) { |
|
| 1347 | + $did_not_do--; |
|
| 1348 | + } else |
|
| 1266 | 1349 | { |
| 1267 | 1350 | $upcontext['cur_file_num']++; |
| 1268 | 1351 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1289,12 +1372,13 @@ discard block |
||
| 1289 | 1372 | // Flag to move on to the next. |
| 1290 | 1373 | $upcontext['completed_step'] = true; |
| 1291 | 1374 | // Did we complete the whole file? |
| 1292 | - if ($nextFile) |
|
| 1293 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1375 | + if ($nextFile) { |
|
| 1376 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1377 | + } |
|
| 1294 | 1378 | return upgradeExit(); |
| 1379 | + } elseif ($support_js) { |
|
| 1380 | + break; |
|
| 1295 | 1381 | } |
| 1296 | - elseif ($support_js) |
|
| 1297 | - break; |
|
| 1298 | 1382 | } |
| 1299 | 1383 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1300 | 1384 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1319,8 +1403,9 @@ discard block |
||
| 1319 | 1403 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1320 | 1404 | |
| 1321 | 1405 | // Now it's nice to have some of the basic SMF source files. |
| 1322 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1323 | - redirectLocation('&ssi=1'); |
|
| 1406 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1407 | + redirectLocation('&ssi=1'); |
|
| 1408 | + } |
|
| 1324 | 1409 | |
| 1325 | 1410 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1326 | 1411 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1336,14 +1421,16 @@ discard block |
||
| 1336 | 1421 | // Are we in maintenance mode? |
| 1337 | 1422 | if (isset($upcontext['user']['main'])) |
| 1338 | 1423 | { |
| 1339 | - if ($command_line) |
|
| 1340 | - echo ' * '; |
|
| 1424 | + if ($command_line) { |
|
| 1425 | + echo ' * '; |
|
| 1426 | + } |
|
| 1341 | 1427 | $upcontext['removed_maintenance'] = true; |
| 1342 | 1428 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1343 | 1429 | } |
| 1344 | 1430 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1345 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1346 | - $changes['maintenance'] = 1; |
|
| 1431 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1432 | + $changes['maintenance'] = 1; |
|
| 1433 | + } |
|
| 1347 | 1434 | |
| 1348 | 1435 | // Wipe this out... |
| 1349 | 1436 | $upcontext['user'] = array(); |
@@ -1358,9 +1445,9 @@ discard block |
||
| 1358 | 1445 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1359 | 1446 | |
| 1360 | 1447 | // Now is the perfect time to fetch the SM files. |
| 1361 | - if ($command_line) |
|
| 1362 | - cli_scheduled_fetchSMfiles(); |
|
| 1363 | - else |
|
| 1448 | + if ($command_line) { |
|
| 1449 | + cli_scheduled_fetchSMfiles(); |
|
| 1450 | + } else |
|
| 1364 | 1451 | { |
| 1365 | 1452 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1366 | 1453 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1368,8 +1455,9 @@ discard block |
||
| 1368 | 1455 | } |
| 1369 | 1456 | |
| 1370 | 1457 | // Log what we've done. |
| 1371 | - if (empty($user_info['id'])) |
|
| 1372 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1458 | + if (empty($user_info['id'])) { |
|
| 1459 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1460 | + } |
|
| 1373 | 1461 | |
| 1374 | 1462 | // Log the action manually, so CLI still works. |
| 1375 | 1463 | $smcFunc['db_insert']('', |
@@ -1388,8 +1476,9 @@ discard block |
||
| 1388 | 1476 | |
| 1389 | 1477 | // Save the current database version. |
| 1390 | 1478 | $server_version = $smcFunc['db_server_info'](); |
| 1391 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1392 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1479 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1480 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1481 | + } |
|
| 1393 | 1482 | |
| 1394 | 1483 | if ($command_line) |
| 1395 | 1484 | { |
@@ -1401,8 +1490,9 @@ discard block |
||
| 1401 | 1490 | |
| 1402 | 1491 | // Make sure it says we're done. |
| 1403 | 1492 | $upcontext['overall_percent'] = 100; |
| 1404 | - if (isset($upcontext['step_progress'])) |
|
| 1405 | - unset($upcontext['step_progress']); |
|
| 1493 | + if (isset($upcontext['step_progress'])) { |
|
| 1494 | + unset($upcontext['step_progress']); |
|
| 1495 | + } |
|
| 1406 | 1496 | |
| 1407 | 1497 | $_GET['substep'] = 0; |
| 1408 | 1498 | return false; |
@@ -1413,8 +1503,9 @@ discard block |
||
| 1413 | 1503 | { |
| 1414 | 1504 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1415 | 1505 | |
| 1416 | - if (empty($modSettings['time_format'])) |
|
| 1417 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1506 | + if (empty($modSettings['time_format'])) { |
|
| 1507 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1508 | + } |
|
| 1418 | 1509 | |
| 1419 | 1510 | // What files do we want to get |
| 1420 | 1511 | $request = $smcFunc['db_query']('', ' |
@@ -1448,8 +1539,9 @@ discard block |
||
| 1448 | 1539 | $file_data = fetch_web_data($url); |
| 1449 | 1540 | |
| 1450 | 1541 | // If we got an error - give up - the site might be down. |
| 1451 | - if ($file_data === false) |
|
| 1452 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1542 | + if ($file_data === false) { |
|
| 1543 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1544 | + } |
|
| 1453 | 1545 | |
| 1454 | 1546 | // Save the file to the database. |
| 1455 | 1547 | $smcFunc['db_query']('substring', ' |
@@ -1491,8 +1583,9 @@ discard block |
||
| 1491 | 1583 | $themeData = array(); |
| 1492 | 1584 | foreach ($values as $variable => $value) |
| 1493 | 1585 | { |
| 1494 | - if (!isset($value) || $value === null) |
|
| 1495 | - $value = 0; |
|
| 1586 | + if (!isset($value) || $value === null) { |
|
| 1587 | + $value = 0; |
|
| 1588 | + } |
|
| 1496 | 1589 | |
| 1497 | 1590 | $themeData[] = array(0, 1, $variable, $value); |
| 1498 | 1591 | } |
@@ -1521,8 +1614,9 @@ discard block |
||
| 1521 | 1614 | |
| 1522 | 1615 | foreach ($values as $variable => $value) |
| 1523 | 1616 | { |
| 1524 | - if (empty($modSettings[$value[0]])) |
|
| 1525 | - continue; |
|
| 1617 | + if (empty($modSettings[$value[0]])) { |
|
| 1618 | + continue; |
|
| 1619 | + } |
|
| 1526 | 1620 | |
| 1527 | 1621 | $smcFunc['db_query']('', ' |
| 1528 | 1622 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1608,19 +1702,21 @@ discard block |
||
| 1608 | 1702 | set_error_handler( |
| 1609 | 1703 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1610 | 1704 | { |
| 1611 | - if ($support_js) |
|
| 1612 | - return true; |
|
| 1613 | - else |
|
| 1614 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1705 | + if ($support_js) { |
|
| 1706 | + return true; |
|
| 1707 | + } else { |
|
| 1708 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1709 | + } |
|
| 1615 | 1710 | } |
| 1616 | 1711 | ); |
| 1617 | 1712 | |
| 1618 | 1713 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1619 | 1714 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1620 | - if ($db_type == 'mysql') |
|
| 1621 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1622 | - else |
|
| 1623 | - $db_collation = ''; |
|
| 1715 | + if ($db_type == 'mysql') { |
|
| 1716 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1717 | + } else { |
|
| 1718 | + $db_collation = ''; |
|
| 1719 | + } |
|
| 1624 | 1720 | |
| 1625 | 1721 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1626 | 1722 | |
@@ -1632,8 +1728,9 @@ discard block |
||
| 1632 | 1728 | $last_step = ''; |
| 1633 | 1729 | |
| 1634 | 1730 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1635 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1636 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1731 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1732 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1733 | + } |
|
| 1637 | 1734 | |
| 1638 | 1735 | // Count the total number of steps within this file - for progress. |
| 1639 | 1736 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1653,15 +1750,18 @@ discard block |
||
| 1653 | 1750 | $do_current = $substep >= $_GET['substep']; |
| 1654 | 1751 | |
| 1655 | 1752 | // Get rid of any comments in the beginning of the line... |
| 1656 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1657 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1753 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1754 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1755 | + } |
|
| 1658 | 1756 | |
| 1659 | 1757 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1660 | - if ($is_debug && !$support_js && $command_line) |
|
| 1661 | - flush(); |
|
| 1758 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1759 | + flush(); |
|
| 1760 | + } |
|
| 1662 | 1761 | |
| 1663 | - if (trim($line) === '') |
|
| 1664 | - continue; |
|
| 1762 | + if (trim($line) === '') { |
|
| 1763 | + continue; |
|
| 1764 | + } |
|
| 1665 | 1765 | |
| 1666 | 1766 | if (trim(substr($line, 0, 3)) === '---') |
| 1667 | 1767 | { |
@@ -1671,8 +1771,9 @@ discard block |
||
| 1671 | 1771 | if (trim($current_data) != '' && $type !== '}') |
| 1672 | 1772 | { |
| 1673 | 1773 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1674 | - if ($command_line) |
|
| 1675 | - echo $upcontext['error_message']; |
|
| 1774 | + if ($command_line) { |
|
| 1775 | + echo $upcontext['error_message']; |
|
| 1776 | + } |
|
| 1676 | 1777 | } |
| 1677 | 1778 | |
| 1678 | 1779 | if ($type == ' ') |
@@ -1690,17 +1791,18 @@ discard block |
||
| 1690 | 1791 | if ($do_current) |
| 1691 | 1792 | { |
| 1692 | 1793 | $upcontext['actioned_items'][] = $last_step; |
| 1693 | - if ($command_line) |
|
| 1694 | - echo ' * '; |
|
| 1794 | + if ($command_line) { |
|
| 1795 | + echo ' * '; |
|
| 1796 | + } |
|
| 1695 | 1797 | } |
| 1696 | - } |
|
| 1697 | - elseif ($type == '#') |
|
| 1798 | + } elseif ($type == '#') |
|
| 1698 | 1799 | { |
| 1699 | 1800 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1700 | 1801 | |
| 1701 | 1802 | $upcontext['current_debug_item_num']++; |
| 1702 | - if (trim($line) != '---#') |
|
| 1703 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1803 | + if (trim($line) != '---#') { |
|
| 1804 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1805 | + } |
|
| 1704 | 1806 | |
| 1705 | 1807 | // Have we already done something? |
| 1706 | 1808 | if (isset($_GET['xml']) && $done_something) |
@@ -1711,34 +1813,36 @@ discard block |
||
| 1711 | 1813 | |
| 1712 | 1814 | if ($do_current) |
| 1713 | 1815 | { |
| 1714 | - if (trim($line) == '---#' && $command_line) |
|
| 1715 | - echo ' done.', $endl; |
|
| 1716 | - elseif ($command_line) |
|
| 1717 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1718 | - elseif (trim($line) != '---#') |
|
| 1816 | + if (trim($line) == '---#' && $command_line) { |
|
| 1817 | + echo ' done.', $endl; |
|
| 1818 | + } elseif ($command_line) { |
|
| 1819 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1820 | + } elseif (trim($line) != '---#') |
|
| 1719 | 1821 | { |
| 1720 | - if ($is_debug) |
|
| 1721 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1822 | + if ($is_debug) { |
|
| 1823 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1824 | + } |
|
| 1722 | 1825 | } |
| 1723 | 1826 | } |
| 1724 | 1827 | |
| 1725 | 1828 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1726 | 1829 | { |
| 1727 | - if ($command_line) |
|
| 1728 | - echo ' * '; |
|
| 1729 | - else |
|
| 1730 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1830 | + if ($command_line) { |
|
| 1831 | + echo ' * '; |
|
| 1832 | + } else { |
|
| 1833 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1834 | + } |
|
| 1731 | 1835 | } |
| 1732 | 1836 | |
| 1733 | 1837 | // Small step - only if we're actually doing stuff. |
| 1734 | - if ($do_current) |
|
| 1735 | - nextSubstep(++$substep); |
|
| 1736 | - else |
|
| 1737 | - $substep++; |
|
| 1738 | - } |
|
| 1739 | - elseif ($type == '{') |
|
| 1740 | - $current_type = 'code'; |
|
| 1741 | - elseif ($type == '}') |
|
| 1838 | + if ($do_current) { |
|
| 1839 | + nextSubstep(++$substep); |
|
| 1840 | + } else { |
|
| 1841 | + $substep++; |
|
| 1842 | + } |
|
| 1843 | + } elseif ($type == '{') { |
|
| 1844 | + $current_type = 'code'; |
|
| 1845 | + } elseif ($type == '}') |
|
| 1742 | 1846 | { |
| 1743 | 1847 | $current_type = 'sql'; |
| 1744 | 1848 | |
@@ -1751,8 +1855,9 @@ discard block |
||
| 1751 | 1855 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1752 | 1856 | { |
| 1753 | 1857 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1754 | - if ($command_line) |
|
| 1755 | - echo $upcontext['error_message']; |
|
| 1858 | + if ($command_line) { |
|
| 1859 | + echo $upcontext['error_message']; |
|
| 1860 | + } |
|
| 1756 | 1861 | } |
| 1757 | 1862 | |
| 1758 | 1863 | // Done with code! |
@@ -1832,8 +1937,9 @@ discard block |
||
| 1832 | 1937 | $db_unbuffered = false; |
| 1833 | 1938 | |
| 1834 | 1939 | // Failure?! |
| 1835 | - if ($result !== false) |
|
| 1836 | - return $result; |
|
| 1940 | + if ($result !== false) { |
|
| 1941 | + return $result; |
|
| 1942 | + } |
|
| 1837 | 1943 | |
| 1838 | 1944 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1839 | 1945 | // If MySQL we do something more clever. |
@@ -1861,54 +1967,61 @@ discard block |
||
| 1861 | 1967 | { |
| 1862 | 1968 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 1863 | 1969 | $result = mysqli_query($db_connection, $string); |
| 1864 | - if ($result !== false) |
|
| 1865 | - return $result; |
|
| 1970 | + if ($result !== false) { |
|
| 1971 | + return $result; |
|
| 1972 | + } |
|
| 1866 | 1973 | } |
| 1867 | - } |
|
| 1868 | - elseif ($mysqli_errno == 2013) |
|
| 1974 | + } elseif ($mysqli_errno == 2013) |
|
| 1869 | 1975 | { |
| 1870 | 1976 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 1871 | 1977 | mysqli_select_db($db_connection, $db_name); |
| 1872 | 1978 | if ($db_connection) |
| 1873 | 1979 | { |
| 1874 | 1980 | $result = mysqli_query($db_connection, $string); |
| 1875 | - if ($result !== false) |
|
| 1876 | - return $result; |
|
| 1981 | + if ($result !== false) { |
|
| 1982 | + return $result; |
|
| 1983 | + } |
|
| 1877 | 1984 | } |
| 1878 | 1985 | } |
| 1879 | 1986 | // Duplicate column name... should be okay ;). |
| 1880 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 1881 | - return false; |
|
| 1987 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 1988 | + return false; |
|
| 1989 | + } |
|
| 1882 | 1990 | // Duplicate insert... make sure it's the proper type of query ;). |
| 1883 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 1884 | - return false; |
|
| 1991 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 1992 | + return false; |
|
| 1993 | + } |
|
| 1885 | 1994 | // Creating an index on a non-existent column. |
| 1886 | - elseif ($mysqli_errno == 1072) |
|
| 1887 | - return false; |
|
| 1888 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 1889 | - return false; |
|
| 1995 | + elseif ($mysqli_errno == 1072) { |
|
| 1996 | + return false; |
|
| 1997 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 1998 | + return false; |
|
| 1999 | + } |
|
| 1890 | 2000 | } |
| 1891 | 2001 | // If a table already exists don't go potty. |
| 1892 | 2002 | else |
| 1893 | 2003 | { |
| 1894 | 2004 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 1895 | 2005 | { |
| 1896 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 1897 | - return true; |
|
| 1898 | - } |
|
| 1899 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2006 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2007 | + return true; |
|
| 2008 | + } |
|
| 2009 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 1900 | 2010 | { |
| 1901 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 1902 | - return true; |
|
| 2011 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2012 | + return true; |
|
| 2013 | + } |
|
| 1903 | 2014 | } |
| 1904 | 2015 | } |
| 1905 | 2016 | |
| 1906 | 2017 | // Get the query string so we pass everything. |
| 1907 | 2018 | $query_string = ''; |
| 1908 | - foreach ($_GET as $k => $v) |
|
| 1909 | - $query_string .= ';' . $k . '=' . $v; |
|
| 1910 | - if (strlen($query_string) != 0) |
|
| 1911 | - $query_string = '?' . substr($query_string, 1); |
|
| 2019 | + foreach ($_GET as $k => $v) { |
|
| 2020 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2021 | + } |
|
| 2022 | + if (strlen($query_string) != 0) { |
|
| 2023 | + $query_string = '?' . substr($query_string, 1); |
|
| 2024 | + } |
|
| 1912 | 2025 | |
| 1913 | 2026 | if ($command_line) |
| 1914 | 2027 | { |
@@ -1963,16 +2076,18 @@ discard block |
||
| 1963 | 2076 | { |
| 1964 | 2077 | $found |= 1; |
| 1965 | 2078 | // Do some checks on the data if we have it set. |
| 1966 | - if (isset($change['col_type'])) |
|
| 1967 | - $found &= $change['col_type'] === $column['type']; |
|
| 1968 | - if (isset($change['null_allowed'])) |
|
| 1969 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 1970 | - if (isset($change['default'])) |
|
| 1971 | - $found &= $change['default'] === $column['default']; |
|
| 2079 | + if (isset($change['col_type'])) { |
|
| 2080 | + $found &= $change['col_type'] === $column['type']; |
|
| 2081 | + } |
|
| 2082 | + if (isset($change['null_allowed'])) { |
|
| 2083 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2084 | + } |
|
| 2085 | + if (isset($change['default'])) { |
|
| 2086 | + $found &= $change['default'] === $column['default']; |
|
| 2087 | + } |
|
| 1972 | 2088 | } |
| 1973 | 2089 | } |
| 1974 | - } |
|
| 1975 | - elseif ($change['type'] === 'index') |
|
| 2090 | + } elseif ($change['type'] === 'index') |
|
| 1976 | 2091 | { |
| 1977 | 2092 | $request = upgrade_query(' |
| 1978 | 2093 | SHOW INDEX |
@@ -1981,9 +2096,10 @@ discard block |
||
| 1981 | 2096 | { |
| 1982 | 2097 | $cur_index = array(); |
| 1983 | 2098 | |
| 1984 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1985 | - if ($row['Key_name'] === $change['name']) |
|
| 2099 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2100 | + if ($row['Key_name'] === $change['name']) |
|
| 1986 | 2101 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2102 | + } |
|
| 1987 | 2103 | |
| 1988 | 2104 | ksort($cur_index, SORT_NUMERIC); |
| 1989 | 2105 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -1993,14 +2109,17 @@ discard block |
||
| 1993 | 2109 | } |
| 1994 | 2110 | |
| 1995 | 2111 | // If we're trying to add and it's added, we're done. |
| 1996 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 1997 | - return true; |
|
| 2112 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2113 | + return true; |
|
| 2114 | + } |
|
| 1998 | 2115 | // Otherwise if we're removing and it wasn't found we're also done. |
| 1999 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2000 | - return true; |
|
| 2116 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2117 | + return true; |
|
| 2118 | + } |
|
| 2001 | 2119 | // Otherwise is it just a test? |
| 2002 | - elseif ($is_test) |
|
| 2003 | - return false; |
|
| 2120 | + elseif ($is_test) { |
|
| 2121 | + return false; |
|
| 2122 | + } |
|
| 2004 | 2123 | |
| 2005 | 2124 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2006 | 2125 | $running = false; |
@@ -2011,8 +2130,9 @@ discard block |
||
| 2011 | 2130 | SHOW FULL PROCESSLIST'); |
| 2012 | 2131 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2013 | 2132 | { |
| 2014 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2015 | - $found = true; |
|
| 2133 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2134 | + $found = true; |
|
| 2135 | + } |
|
| 2016 | 2136 | } |
| 2017 | 2137 | |
| 2018 | 2138 | // Can't find it? Then we need to run it fools! |
@@ -2024,8 +2144,9 @@ discard block |
||
| 2024 | 2144 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2025 | 2145 | ' . $change['text'], true) !== false; |
| 2026 | 2146 | |
| 2027 | - if (!$success) |
|
| 2028 | - return false; |
|
| 2147 | + if (!$success) { |
|
| 2148 | + return false; |
|
| 2149 | + } |
|
| 2029 | 2150 | |
| 2030 | 2151 | // Return |
| 2031 | 2152 | $running = true; |
@@ -2067,8 +2188,9 @@ discard block |
||
| 2067 | 2188 | 'db_error_skip' => true, |
| 2068 | 2189 | ) |
| 2069 | 2190 | ); |
| 2070 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2071 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2191 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2192 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2193 | + } |
|
| 2072 | 2194 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2073 | 2195 | $smcFunc['db_free_result']($request); |
| 2074 | 2196 | |
@@ -2090,18 +2212,19 @@ discard block |
||
| 2090 | 2212 | ) |
| 2091 | 2213 | ); |
| 2092 | 2214 | // No results? Just forget it all together. |
| 2093 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2094 | - unset($table_row['Collation']); |
|
| 2095 | - else |
|
| 2096 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2215 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2216 | + unset($table_row['Collation']); |
|
| 2217 | + } else { |
|
| 2218 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2219 | + } |
|
| 2097 | 2220 | $smcFunc['db_free_result']($request); |
| 2098 | 2221 | } |
| 2099 | 2222 | |
| 2100 | 2223 | if ($column_fix) |
| 2101 | 2224 | { |
| 2102 | 2225 | // Make sure there are no NULL's left. |
| 2103 | - if ($null_fix) |
|
| 2104 | - $smcFunc['db_query']('', ' |
|
| 2226 | + if ($null_fix) { |
|
| 2227 | + $smcFunc['db_query']('', ' |
|
| 2105 | 2228 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2106 | 2229 | SET ' . $change['column'] . ' = {string:default} |
| 2107 | 2230 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2110,6 +2233,7 @@ discard block |
||
| 2110 | 2233 | 'db_error_skip' => true, |
| 2111 | 2234 | ) |
| 2112 | 2235 | ); |
| 2236 | + } |
|
| 2113 | 2237 | |
| 2114 | 2238 | // Do the actual alteration. |
| 2115 | 2239 | $smcFunc['db_query']('', ' |
@@ -2138,8 +2262,9 @@ discard block |
||
| 2138 | 2262 | } |
| 2139 | 2263 | |
| 2140 | 2264 | // Not a column we need to check on? |
| 2141 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2142 | - return; |
|
| 2265 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2266 | + return; |
|
| 2267 | + } |
|
| 2143 | 2268 | |
| 2144 | 2269 | // Break it up you (six|seven). |
| 2145 | 2270 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2158,13 +2283,13 @@ discard block |
||
| 2158 | 2283 | 'new_name' => $temp[2], |
| 2159 | 2284 | )); |
| 2160 | 2285 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2161 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2162 | - return; |
|
| 2286 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2287 | + return; |
|
| 2288 | + } |
|
| 2163 | 2289 | |
| 2164 | 2290 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2165 | 2291 | $smcFunc['db_free_result']($request); |
| 2166 | - } |
|
| 2167 | - else |
|
| 2292 | + } else |
|
| 2168 | 2293 | { |
| 2169 | 2294 | // Do this the old fashion, sure method way. |
| 2170 | 2295 | $request = $smcFunc['db_query']('', ' |
@@ -2175,21 +2300,24 @@ discard block |
||
| 2175 | 2300 | )); |
| 2176 | 2301 | // Mayday! |
| 2177 | 2302 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2178 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2179 | - return; |
|
| 2303 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2304 | + return; |
|
| 2305 | + } |
|
| 2180 | 2306 | |
| 2181 | 2307 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2182 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2183 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2308 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2309 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2184 | 2310 | { |
| 2185 | 2311 | $current_type = $row['Type']; |
| 2312 | + } |
|
| 2186 | 2313 | break; |
| 2187 | 2314 | } |
| 2188 | 2315 | } |
| 2189 | 2316 | |
| 2190 | 2317 | // If this doesn't match, the column may of been altered for a reason. |
| 2191 | - if (trim($current_type) != trim($temp[3])) |
|
| 2192 | - $temp[3] = $current_type; |
|
| 2318 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2319 | + $temp[3] = $current_type; |
|
| 2320 | + } |
|
| 2193 | 2321 | |
| 2194 | 2322 | // Piece this back together. |
| 2195 | 2323 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2201,8 +2329,9 @@ discard block |
||
| 2201 | 2329 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2202 | 2330 | global $step_progress, $is_debug, $upcontext; |
| 2203 | 2331 | |
| 2204 | - if ($_GET['substep'] < $substep) |
|
| 2205 | - $_GET['substep'] = $substep; |
|
| 2332 | + if ($_GET['substep'] < $substep) { |
|
| 2333 | + $_GET['substep'] = $substep; |
|
| 2334 | + } |
|
| 2206 | 2335 | |
| 2207 | 2336 | if ($command_line) |
| 2208 | 2337 | { |
@@ -2215,29 +2344,33 @@ discard block |
||
| 2215 | 2344 | } |
| 2216 | 2345 | |
| 2217 | 2346 | @set_time_limit(300); |
| 2218 | - if (function_exists('apache_reset_timeout')) |
|
| 2219 | - @apache_reset_timeout(); |
|
| 2347 | + if (function_exists('apache_reset_timeout')) { |
|
| 2348 | + @apache_reset_timeout(); |
|
| 2349 | + } |
|
| 2220 | 2350 | |
| 2221 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2222 | - return; |
|
| 2351 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2352 | + return; |
|
| 2353 | + } |
|
| 2223 | 2354 | |
| 2224 | 2355 | // Do we have some custom step progress stuff? |
| 2225 | 2356 | if (!empty($step_progress)) |
| 2226 | 2357 | { |
| 2227 | 2358 | $upcontext['substep_progress'] = 0; |
| 2228 | 2359 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2229 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2230 | - $upcontext['substep_progress'] = 99.9; |
|
| 2231 | - else |
|
| 2232 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2360 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2361 | + $upcontext['substep_progress'] = 99.9; |
|
| 2362 | + } else { |
|
| 2363 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2364 | + } |
|
| 2233 | 2365 | |
| 2234 | 2366 | // Make it nicely rounded. |
| 2235 | 2367 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2236 | 2368 | } |
| 2237 | 2369 | |
| 2238 | 2370 | // If this is XML we just exit right away! |
| 2239 | - if (isset($_GET['xml'])) |
|
| 2240 | - return upgradeExit(); |
|
| 2371 | + if (isset($_GET['xml'])) { |
|
| 2372 | + return upgradeExit(); |
|
| 2373 | + } |
|
| 2241 | 2374 | |
| 2242 | 2375 | // We're going to pause after this! |
| 2243 | 2376 | $upcontext['pause'] = true; |
@@ -2245,13 +2378,15 @@ discard block |
||
| 2245 | 2378 | $upcontext['query_string'] = ''; |
| 2246 | 2379 | foreach ($_GET as $k => $v) |
| 2247 | 2380 | { |
| 2248 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2249 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2381 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2382 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2383 | + } |
|
| 2250 | 2384 | } |
| 2251 | 2385 | |
| 2252 | 2386 | // Custom warning? |
| 2253 | - if (!empty($custom_warning)) |
|
| 2254 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2387 | + if (!empty($custom_warning)) { |
|
| 2388 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2389 | + } |
|
| 2255 | 2390 | |
| 2256 | 2391 | upgradeExit(); |
| 2257 | 2392 | } |
@@ -2266,25 +2401,26 @@ discard block |
||
| 2266 | 2401 | ob_implicit_flush(true); |
| 2267 | 2402 | @set_time_limit(600); |
| 2268 | 2403 | |
| 2269 | - if (!isset($_SERVER['argv'])) |
|
| 2270 | - $_SERVER['argv'] = array(); |
|
| 2404 | + if (!isset($_SERVER['argv'])) { |
|
| 2405 | + $_SERVER['argv'] = array(); |
|
| 2406 | + } |
|
| 2271 | 2407 | $_GET['maint'] = 1; |
| 2272 | 2408 | |
| 2273 | 2409 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2274 | 2410 | { |
| 2275 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2276 | - $_GET['lang'] = $match[1]; |
|
| 2277 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2278 | - continue; |
|
| 2279 | - elseif ($arg == '--no-maintenance') |
|
| 2280 | - $_GET['maint'] = 0; |
|
| 2281 | - elseif ($arg == '--debug') |
|
| 2282 | - $is_debug = true; |
|
| 2283 | - elseif ($arg == '--backup') |
|
| 2284 | - $_POST['backup'] = 1; |
|
| 2285 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2286 | - $_GET['conv'] = 1; |
|
| 2287 | - elseif ($i != 0) |
|
| 2411 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2412 | + $_GET['lang'] = $match[1]; |
|
| 2413 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2414 | + continue; |
|
| 2415 | + } elseif ($arg == '--no-maintenance') { |
|
| 2416 | + $_GET['maint'] = 0; |
|
| 2417 | + } elseif ($arg == '--debug') { |
|
| 2418 | + $is_debug = true; |
|
| 2419 | + } elseif ($arg == '--backup') { |
|
| 2420 | + $_POST['backup'] = 1; |
|
| 2421 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2422 | + $_GET['conv'] = 1; |
|
| 2423 | + } elseif ($i != 0) |
|
| 2288 | 2424 | { |
| 2289 | 2425 | echo 'SMF Command-line Upgrader |
| 2290 | 2426 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2298,10 +2434,12 @@ discard block |
||
| 2298 | 2434 | } |
| 2299 | 2435 | } |
| 2300 | 2436 | |
| 2301 | - if (!php_version_check()) |
|
| 2302 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2303 | - if (!db_version_check()) |
|
| 2304 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2437 | + if (!php_version_check()) { |
|
| 2438 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2439 | + } |
|
| 2440 | + if (!db_version_check()) { |
|
| 2441 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2442 | + } |
|
| 2305 | 2443 | |
| 2306 | 2444 | // Do some checks to make sure they have proper privileges |
| 2307 | 2445 | db_extend('packages'); |
@@ -2316,34 +2454,39 @@ discard block |
||
| 2316 | 2454 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2317 | 2455 | |
| 2318 | 2456 | // Sorry... we need CREATE, ALTER and DROP |
| 2319 | - if (!$create || !$alter || !$drop) |
|
| 2320 | - 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); |
|
| 2457 | + if (!$create || !$alter || !$drop) { |
|
| 2458 | + 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); |
|
| 2459 | + } |
|
| 2321 | 2460 | |
| 2322 | 2461 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2323 | 2462 | && @file_exists($sourcedir . '/QueryString.php') |
| 2324 | 2463 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2325 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2326 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2464 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2465 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2466 | + } |
|
| 2327 | 2467 | |
| 2328 | 2468 | // Do a quick version spot check. |
| 2329 | 2469 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2330 | 2470 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2331 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2332 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2471 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2472 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2473 | + } |
|
| 2333 | 2474 | |
| 2334 | 2475 | // Make sure Settings.php is writable. |
| 2335 | 2476 | quickFileWritable($boarddir . '/Settings.php'); |
| 2336 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2337 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2477 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2478 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2479 | + } |
|
| 2338 | 2480 | |
| 2339 | 2481 | // Make sure Settings_bak.php is writable. |
| 2340 | 2482 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2341 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2342 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2483 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2484 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2485 | + } |
|
| 2343 | 2486 | |
| 2344 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2345 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2346 | - elseif (isset($modSettings['agreement'])) |
|
| 2487 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2488 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2489 | + } elseif (isset($modSettings['agreement'])) |
|
| 2347 | 2490 | { |
| 2348 | 2491 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2349 | 2492 | fwrite($fp, $modSettings['agreement']); |
@@ -2353,31 +2496,36 @@ discard block |
||
| 2353 | 2496 | // Make sure Themes is writable. |
| 2354 | 2497 | quickFileWritable($modSettings['theme_dir']); |
| 2355 | 2498 | |
| 2356 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2357 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2499 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2500 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2501 | + } |
|
| 2358 | 2502 | |
| 2359 | 2503 | // Make sure cache directory exists and is writable! |
| 2360 | 2504 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2361 | - if (!file_exists($cachedir_temp)) |
|
| 2362 | - @mkdir($cachedir_temp); |
|
| 2505 | + if (!file_exists($cachedir_temp)) { |
|
| 2506 | + @mkdir($cachedir_temp); |
|
| 2507 | + } |
|
| 2363 | 2508 | |
| 2364 | 2509 | // Make sure the cache temp dir is writable. |
| 2365 | 2510 | quickFileWritable($cachedir_temp); |
| 2366 | 2511 | |
| 2367 | - if (!is_writable($cachedir_temp)) |
|
| 2368 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2512 | + if (!is_writable($cachedir_temp)) { |
|
| 2513 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2514 | + } |
|
| 2369 | 2515 | |
| 2370 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2371 | - print_error('Error: Unable to find language files!', true); |
|
| 2372 | - else |
|
| 2516 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2517 | + print_error('Error: Unable to find language files!', true); |
|
| 2518 | + } else |
|
| 2373 | 2519 | { |
| 2374 | 2520 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2375 | 2521 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2376 | 2522 | |
| 2377 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2378 | - print_error('Error: Language files out of date.', true); |
|
| 2379 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2380 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2523 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2524 | + print_error('Error: Language files out of date.', true); |
|
| 2525 | + } |
|
| 2526 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2527 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2528 | + } |
|
| 2381 | 2529 | |
| 2382 | 2530 | // Otherwise include it! |
| 2383 | 2531 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2396,8 +2544,9 @@ discard block |
||
| 2396 | 2544 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
| 2397 | 2545 | |
| 2398 | 2546 | // Done it already? |
| 2399 | - if (!empty($_POST['utf8_done'])) |
|
| 2400 | - return true; |
|
| 2547 | + if (!empty($_POST['utf8_done'])) { |
|
| 2548 | + return true; |
|
| 2549 | + } |
|
| 2401 | 2550 | |
| 2402 | 2551 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2403 | 2552 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2410,8 +2559,7 @@ discard block |
||
| 2410 | 2559 | ); |
| 2411 | 2560 | |
| 2412 | 2561 | return true; |
| 2413 | - } |
|
| 2414 | - else |
|
| 2562 | + } else |
|
| 2415 | 2563 | { |
| 2416 | 2564 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2417 | 2565 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2455,8 +2603,9 @@ discard block |
||
| 2455 | 2603 | ) |
| 2456 | 2604 | ); |
| 2457 | 2605 | $db_charsets = array(); |
| 2458 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2459 | - $db_charsets[] = $row['Charset']; |
|
| 2606 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2607 | + $db_charsets[] = $row['Charset']; |
|
| 2608 | + } |
|
| 2460 | 2609 | |
| 2461 | 2610 | $smcFunc['db_free_result']($request); |
| 2462 | 2611 | |
@@ -2492,13 +2641,15 @@ discard block |
||
| 2492 | 2641 | // If there's a fulltext index, we need to drop it first... |
| 2493 | 2642 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2494 | 2643 | { |
| 2495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2496 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2644 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2645 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2497 | 2646 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2647 | + } |
|
| 2498 | 2648 | $smcFunc['db_free_result']($request); |
| 2499 | 2649 | |
| 2500 | - if (isset($upcontext['fulltext_index'])) |
|
| 2501 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2650 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2651 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2652 | + } |
|
| 2502 | 2653 | } |
| 2503 | 2654 | |
| 2504 | 2655 | // Drop it and make a note... |
@@ -2688,8 +2839,9 @@ discard block |
||
| 2688 | 2839 | $replace = '%field%'; |
| 2689 | 2840 | |
| 2690 | 2841 | // Build a huge REPLACE statement... |
| 2691 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2692 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2842 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 2843 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2844 | + } |
|
| 2693 | 2845 | } |
| 2694 | 2846 | |
| 2695 | 2847 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2699,9 +2851,10 @@ discard block |
||
| 2699 | 2851 | $upcontext['table_count'] = count($queryTables); |
| 2700 | 2852 | |
| 2701 | 2853 | // What ones have we already done? |
| 2702 | - foreach ($queryTables as $id => $table) |
|
| 2703 | - if ($id < $_GET['substep']) |
|
| 2854 | + foreach ($queryTables as $id => $table) { |
|
| 2855 | + if ($id < $_GET['substep']) |
|
| 2704 | 2856 | $upcontext['previous_tables'][] = $table; |
| 2857 | + } |
|
| 2705 | 2858 | |
| 2706 | 2859 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2707 | 2860 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2738,8 +2891,9 @@ discard block |
||
| 2738 | 2891 | nextSubstep($substep); |
| 2739 | 2892 | |
| 2740 | 2893 | // Just to make sure it doesn't time out. |
| 2741 | - if (function_exists('apache_reset_timeout')) |
|
| 2742 | - @apache_reset_timeout(); |
|
| 2894 | + if (function_exists('apache_reset_timeout')) { |
|
| 2895 | + @apache_reset_timeout(); |
|
| 2896 | + } |
|
| 2743 | 2897 | |
| 2744 | 2898 | $table_charsets = array(); |
| 2745 | 2899 | |
@@ -2760,8 +2914,9 @@ discard block |
||
| 2760 | 2914 | { |
| 2761 | 2915 | list($charset) = explode('_', $collation); |
| 2762 | 2916 | |
| 2763 | - if (!isset($table_charsets[$charset])) |
|
| 2764 | - $table_charsets[$charset] = array(); |
|
| 2917 | + if (!isset($table_charsets[$charset])) { |
|
| 2918 | + $table_charsets[$charset] = array(); |
|
| 2919 | + } |
|
| 2765 | 2920 | |
| 2766 | 2921 | $table_charsets[$charset][] = $column_info; |
| 2767 | 2922 | } |
@@ -2801,10 +2956,11 @@ discard block |
||
| 2801 | 2956 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2802 | 2957 | { |
| 2803 | 2958 | $update = ''; |
| 2804 | - foreach ($table_charsets as $charset => $columns) |
|
| 2805 | - foreach ($columns as $column) |
|
| 2959 | + foreach ($table_charsets as $charset => $columns) { |
|
| 2960 | + foreach ($columns as $column) |
|
| 2806 | 2961 | $update .= ' |
| 2807 | 2962 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 2963 | + } |
|
| 2808 | 2964 | |
| 2809 | 2965 | $smcFunc['db_query']('', ' |
| 2810 | 2966 | UPDATE {raw:table_name} |
@@ -2829,8 +2985,9 @@ discard block |
||
| 2829 | 2985 | // Now do the actual conversion (if still needed). |
| 2830 | 2986 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2831 | 2987 | { |
| 2832 | - if ($command_line) |
|
| 2833 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 2988 | + if ($command_line) { |
|
| 2989 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 2990 | + } |
|
| 2834 | 2991 | |
| 2835 | 2992 | $smcFunc['db_query']('', ' |
| 2836 | 2993 | ALTER TABLE {raw:table_name} |
@@ -2840,12 +2997,14 @@ discard block |
||
| 2840 | 2997 | ) |
| 2841 | 2998 | ); |
| 2842 | 2999 | |
| 2843 | - if ($command_line) |
|
| 2844 | - echo " done.\n"; |
|
| 3000 | + if ($command_line) { |
|
| 3001 | + echo " done.\n"; |
|
| 3002 | + } |
|
| 2845 | 3003 | } |
| 2846 | 3004 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 2847 | - if (isset($_GET['xml'])) |
|
| 2848 | - return upgradeExit(); |
|
| 3005 | + if (isset($_GET['xml'])) { |
|
| 3006 | + return upgradeExit(); |
|
| 3007 | + } |
|
| 2849 | 3008 | } |
| 2850 | 3009 | |
| 2851 | 3010 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2874,8 +3033,8 @@ discard block |
||
| 2874 | 3033 | ); |
| 2875 | 3034 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2876 | 3035 | { |
| 2877 | - 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) |
|
| 2878 | - $smcFunc['db_query']('', ' |
|
| 3036 | + 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) { |
|
| 3037 | + $smcFunc['db_query']('', ' |
|
| 2879 | 3038 | UPDATE {db_prefix}log_actions |
| 2880 | 3039 | SET extra = {string:extra} |
| 2881 | 3040 | WHERE id_action = {int:current_action}', |
@@ -2884,6 +3043,7 @@ discard block |
||
| 2884 | 3043 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 2885 | 3044 | ) |
| 2886 | 3045 | ); |
| 3046 | + } |
|
| 2887 | 3047 | } |
| 2888 | 3048 | $smcFunc['db_free_result']($request); |
| 2889 | 3049 | |
@@ -2905,15 +3065,17 @@ discard block |
||
| 2905 | 3065 | // First thing's first - did we already do this? |
| 2906 | 3066 | if (!empty($modSettings['json_done'])) |
| 2907 | 3067 | { |
| 2908 | - if ($command_line) |
|
| 2909 | - return DeleteUpgrade(); |
|
| 2910 | - else |
|
| 2911 | - return true; |
|
| 3068 | + if ($command_line) { |
|
| 3069 | + return DeleteUpgrade(); |
|
| 3070 | + } else { |
|
| 3071 | + return true; |
|
| 3072 | + } |
|
| 2912 | 3073 | } |
| 2913 | 3074 | |
| 2914 | 3075 | // Done it already - js wise? |
| 2915 | - if (!empty($_POST['json_done'])) |
|
| 2916 | - return true; |
|
| 3076 | + if (!empty($_POST['json_done'])) { |
|
| 3077 | + return true; |
|
| 3078 | + } |
|
| 2917 | 3079 | |
| 2918 | 3080 | // List of tables affected by this function |
| 2919 | 3081 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2945,12 +3107,14 @@ discard block |
||
| 2945 | 3107 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 2946 | 3108 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 2947 | 3109 | |
| 2948 | - foreach ($keys as $id => $table) |
|
| 2949 | - if ($id < $_GET['substep']) |
|
| 3110 | + foreach ($keys as $id => $table) { |
|
| 3111 | + if ($id < $_GET['substep']) |
|
| 2950 | 3112 | $upcontext['previous_tables'][] = $table; |
| 3113 | + } |
|
| 2951 | 3114 | |
| 2952 | - if ($command_line) |
|
| 2953 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3115 | + if ($command_line) { |
|
| 3116 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3117 | + } |
|
| 2954 | 3118 | |
| 2955 | 3119 | if (!$support_js || isset($_GET['xml'])) |
| 2956 | 3120 | { |
@@ -2990,8 +3154,9 @@ discard block |
||
| 2990 | 3154 | |
| 2991 | 3155 | // Loop through and fix these... |
| 2992 | 3156 | $new_settings = array(); |
| 2993 | - if ($command_line) |
|
| 2994 | - echo "\n" . 'Fixing some settings...'; |
|
| 3157 | + if ($command_line) { |
|
| 3158 | + echo "\n" . 'Fixing some settings...'; |
|
| 3159 | + } |
|
| 2995 | 3160 | |
| 2996 | 3161 | foreach ($serialized_settings as $var) |
| 2997 | 3162 | { |
@@ -2999,22 +3164,24 @@ discard block |
||
| 2999 | 3164 | { |
| 3000 | 3165 | // Attempt to unserialize the setting |
| 3001 | 3166 | $temp = @safe_unserialize($modSettings[$var]); |
| 3002 | - if (!$temp && $command_line) |
|
| 3003 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3004 | - elseif ($temp !== false) |
|
| 3005 | - $new_settings[$var] = json_encode($temp); |
|
| 3167 | + if (!$temp && $command_line) { |
|
| 3168 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3169 | + } elseif ($temp !== false) { |
|
| 3170 | + $new_settings[$var] = json_encode($temp); |
|
| 3171 | + } |
|
| 3006 | 3172 | } |
| 3007 | 3173 | } |
| 3008 | 3174 | |
| 3009 | 3175 | // Update everything at once |
| 3010 | - if (!function_exists('cache_put_data')) |
|
| 3011 | - require_once($sourcedir . '/Load.php'); |
|
| 3176 | + if (!function_exists('cache_put_data')) { |
|
| 3177 | + require_once($sourcedir . '/Load.php'); |
|
| 3178 | + } |
|
| 3012 | 3179 | updateSettings($new_settings, true); |
| 3013 | 3180 | |
| 3014 | - if ($command_line) |
|
| 3015 | - echo ' done.'; |
|
| 3016 | - } |
|
| 3017 | - elseif ($table == 'themes') |
|
| 3181 | + if ($command_line) { |
|
| 3182 | + echo ' done.'; |
|
| 3183 | + } |
|
| 3184 | + } elseif ($table == 'themes') |
|
| 3018 | 3185 | { |
| 3019 | 3186 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3020 | 3187 | $query = $smcFunc['db_query']('', ' |
@@ -3033,10 +3200,11 @@ discard block |
||
| 3033 | 3200 | |
| 3034 | 3201 | if ($command_line) |
| 3035 | 3202 | { |
| 3036 | - if ($temp === false) |
|
| 3037 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3038 | - else |
|
| 3039 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3203 | + if ($temp === false) { |
|
| 3204 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3205 | + } else { |
|
| 3206 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3207 | + } |
|
| 3040 | 3208 | } |
| 3041 | 3209 | |
| 3042 | 3210 | if ($temp !== false) |
@@ -3058,15 +3226,15 @@ discard block |
||
| 3058 | 3226 | ) |
| 3059 | 3227 | ); |
| 3060 | 3228 | |
| 3061 | - if ($command_line) |
|
| 3062 | - echo ' done.'; |
|
| 3229 | + if ($command_line) { |
|
| 3230 | + echo ' done.'; |
|
| 3231 | + } |
|
| 3063 | 3232 | } |
| 3064 | 3233 | } |
| 3065 | 3234 | |
| 3066 | 3235 | $smcFunc['db_free_result']($query); |
| 3067 | 3236 | } |
| 3068 | - } |
|
| 3069 | - else |
|
| 3237 | + } else |
|
| 3070 | 3238 | { |
| 3071 | 3239 | // First item is always the key... |
| 3072 | 3240 | $key = $info[0]; |
@@ -3077,8 +3245,7 @@ discard block |
||
| 3077 | 3245 | { |
| 3078 | 3246 | $col_select = $info[1]; |
| 3079 | 3247 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3080 | - } |
|
| 3081 | - else |
|
| 3248 | + } else |
|
| 3082 | 3249 | { |
| 3083 | 3250 | $col_select = implode(', ', $info); |
| 3084 | 3251 | } |
@@ -3111,8 +3278,7 @@ discard block |
||
| 3111 | 3278 | if ($temp === false && $command_line) |
| 3112 | 3279 | { |
| 3113 | 3280 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3114 | - } |
|
| 3115 | - else |
|
| 3281 | + } else |
|
| 3116 | 3282 | { |
| 3117 | 3283 | $row[$col] = json_encode($temp); |
| 3118 | 3284 | |
@@ -3137,16 +3303,18 @@ discard block |
||
| 3137 | 3303 | } |
| 3138 | 3304 | } |
| 3139 | 3305 | |
| 3140 | - if ($command_line) |
|
| 3141 | - echo ' done.'; |
|
| 3306 | + if ($command_line) { |
|
| 3307 | + echo ' done.'; |
|
| 3308 | + } |
|
| 3142 | 3309 | |
| 3143 | 3310 | // Free up some memory... |
| 3144 | 3311 | $smcFunc['db_free_result']($query); |
| 3145 | 3312 | } |
| 3146 | 3313 | } |
| 3147 | 3314 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3148 | - if (isset($_GET['xml'])) |
|
| 3149 | - return upgradeExit(); |
|
| 3315 | + if (isset($_GET['xml'])) { |
|
| 3316 | + return upgradeExit(); |
|
| 3317 | + } |
|
| 3150 | 3318 | } |
| 3151 | 3319 | |
| 3152 | 3320 | if ($command_line) |
@@ -3161,8 +3329,9 @@ discard block |
||
| 3161 | 3329 | |
| 3162 | 3330 | $_GET['substep'] = 0; |
| 3163 | 3331 | // Make sure we move on! |
| 3164 | - if ($command_line) |
|
| 3165 | - return DeleteUpgrade(); |
|
| 3332 | + if ($command_line) { |
|
| 3333 | + return DeleteUpgrade(); |
|
| 3334 | + } |
|
| 3166 | 3335 | |
| 3167 | 3336 | return true; |
| 3168 | 3337 | } |
@@ -3182,14 +3351,16 @@ discard block |
||
| 3182 | 3351 | global $upcontext, $txt, $settings; |
| 3183 | 3352 | |
| 3184 | 3353 | // Don't call me twice! |
| 3185 | - if (!empty($upcontext['chmod_called'])) |
|
| 3186 | - return; |
|
| 3354 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3355 | + return; |
|
| 3356 | + } |
|
| 3187 | 3357 | |
| 3188 | 3358 | $upcontext['chmod_called'] = true; |
| 3189 | 3359 | |
| 3190 | 3360 | // Nothing? |
| 3191 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3192 | - return; |
|
| 3361 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3362 | + return; |
|
| 3363 | + } |
|
| 3193 | 3364 | |
| 3194 | 3365 | // Was it a problem with Windows? |
| 3195 | 3366 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3221,11 +3392,12 @@ discard block |
||
| 3221 | 3392 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
| 3222 | 3393 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3223 | 3394 | |
| 3224 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3225 | - echo ' |
|
| 3395 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3396 | + echo ' |
|
| 3226 | 3397 | content.write(\'<hr>\n\t\t\t\'); |
| 3227 | 3398 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
| 3228 | 3399 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3400 | + } |
|
| 3229 | 3401 | |
| 3230 | 3402 | echo ' |
| 3231 | 3403 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3233,17 +3405,19 @@ discard block |
||
| 3233 | 3405 | } |
| 3234 | 3406 | </script>'; |
| 3235 | 3407 | |
| 3236 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3237 | - echo ' |
|
| 3408 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3409 | + echo ' |
|
| 3238 | 3410 | <div class="error_message red"> |
| 3239 | 3411 | The following error was encountered when trying to connect:<br><br> |
| 3240 | 3412 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3241 | 3413 | </div> |
| 3242 | 3414 | <br>'; |
| 3415 | + } |
|
| 3243 | 3416 | |
| 3244 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3245 | - echo ' |
|
| 3417 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3418 | + echo ' |
|
| 3246 | 3419 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3420 | + } |
|
| 3247 | 3421 | |
| 3248 | 3422 | echo ' |
| 3249 | 3423 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3278,10 +3452,11 @@ discard block |
||
| 3278 | 3452 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
| 3279 | 3453 | </div>'; |
| 3280 | 3454 | |
| 3281 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3282 | - echo ' |
|
| 3455 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3456 | + echo ' |
|
| 3283 | 3457 | </form>'; |
| 3284 | -} |
|
| 3458 | + } |
|
| 3459 | + } |
|
| 3285 | 3460 | |
| 3286 | 3461 | function template_upgrade_above() |
| 3287 | 3462 | { |
@@ -3341,9 +3516,10 @@ discard block |
||
| 3341 | 3516 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3342 | 3517 | <ul>'; |
| 3343 | 3518 | |
| 3344 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3345 | - echo ' |
|
| 3519 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3520 | + echo ' |
|
| 3346 | 3521 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3522 | + } |
|
| 3347 | 3523 | |
| 3348 | 3524 | echo ' |
| 3349 | 3525 | </ul> |
@@ -3356,8 +3532,8 @@ discard block |
||
| 3356 | 3532 | </div> |
| 3357 | 3533 | </div>'; |
| 3358 | 3534 | |
| 3359 | - if (isset($upcontext['step_progress'])) |
|
| 3360 | - echo ' |
|
| 3535 | + if (isset($upcontext['step_progress'])) { |
|
| 3536 | + echo ' |
|
| 3361 | 3537 | <br> |
| 3362 | 3538 | <br> |
| 3363 | 3539 | <div id="progress_bar_step"> |
@@ -3366,6 +3542,7 @@ discard block |
||
| 3366 | 3542 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3367 | 3543 | </div> |
| 3368 | 3544 | </div>'; |
| 3545 | + } |
|
| 3369 | 3546 | |
| 3370 | 3547 | echo ' |
| 3371 | 3548 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3396,32 +3573,36 @@ discard block |
||
| 3396 | 3573 | { |
| 3397 | 3574 | global $upcontext, $txt; |
| 3398 | 3575 | |
| 3399 | - if (!empty($upcontext['pause'])) |
|
| 3400 | - echo ' |
|
| 3576 | + if (!empty($upcontext['pause'])) { |
|
| 3577 | + echo ' |
|
| 3401 | 3578 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3402 | 3579 | |
| 3403 | 3580 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3404 | 3581 | <h3> |
| 3405 | 3582 | ', $txt['upgrade_paused_overload'], ' |
| 3406 | 3583 | </h3>'; |
| 3584 | + } |
|
| 3407 | 3585 | |
| 3408 | - if (!empty($upcontext['custom_warning'])) |
|
| 3409 | - echo ' |
|
| 3586 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3587 | + echo ' |
|
| 3410 | 3588 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3411 | 3589 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3412 | 3590 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3413 | 3591 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3414 | 3592 | </div>'; |
| 3593 | + } |
|
| 3415 | 3594 | |
| 3416 | 3595 | echo ' |
| 3417 | 3596 | <div class="righttext" style="margin: 1ex;">'; |
| 3418 | 3597 | |
| 3419 | - if (!empty($upcontext['continue'])) |
|
| 3420 | - echo ' |
|
| 3598 | + if (!empty($upcontext['continue'])) { |
|
| 3599 | + echo ' |
|
| 3421 | 3600 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
| 3422 | - if (!empty($upcontext['skip'])) |
|
| 3423 | - echo ' |
|
| 3601 | + } |
|
| 3602 | + if (!empty($upcontext['skip'])) { |
|
| 3603 | + echo ' |
|
| 3424 | 3604 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
| 3605 | + } |
|
| 3425 | 3606 | |
| 3426 | 3607 | echo ' |
| 3427 | 3608 | </div> |
@@ -3471,11 +3652,12 @@ discard block |
||
| 3471 | 3652 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3472 | 3653 | <smf>'; |
| 3473 | 3654 | |
| 3474 | - if (!empty($upcontext['get_data'])) |
|
| 3475 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3655 | + if (!empty($upcontext['get_data'])) { |
|
| 3656 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3476 | 3657 | echo ' |
| 3477 | 3658 | <get key="', $k, '">', $v, '</get>'; |
| 3478 | -} |
|
| 3659 | + } |
|
| 3660 | + } |
|
| 3479 | 3661 | |
| 3480 | 3662 | function template_xml_below() |
| 3481 | 3663 | { |
@@ -3516,8 +3698,8 @@ discard block |
||
| 3516 | 3698 | template_chmod(); |
| 3517 | 3699 | |
| 3518 | 3700 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3519 | - if ($upcontext['is_large_forum']) |
|
| 3520 | - echo ' |
|
| 3701 | + if ($upcontext['is_large_forum']) { |
|
| 3702 | + echo ' |
|
| 3521 | 3703 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3522 | 3704 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3523 | 3705 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3525,10 +3707,11 @@ discard block |
||
| 3525 | 3707 | ', $txt['upgrade_warning_lots_data'], ' |
| 3526 | 3708 | </div> |
| 3527 | 3709 | </div>'; |
| 3710 | + } |
|
| 3528 | 3711 | |
| 3529 | 3712 | // A warning message? |
| 3530 | - if (!empty($upcontext['warning'])) |
|
| 3531 | - echo ' |
|
| 3713 | + if (!empty($upcontext['warning'])) { |
|
| 3714 | + echo ' |
|
| 3532 | 3715 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3533 | 3716 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3534 | 3717 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3536,6 +3719,7 @@ discard block |
||
| 3536 | 3719 | ', $upcontext['warning'], ' |
| 3537 | 3720 | </div> |
| 3538 | 3721 | </div>'; |
| 3722 | + } |
|
| 3539 | 3723 | |
| 3540 | 3724 | // Paths are incorrect? |
| 3541 | 3725 | echo ' |
@@ -3551,20 +3735,22 @@ discard block |
||
| 3551 | 3735 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3552 | 3736 | { |
| 3553 | 3737 | $ago = time() - $upcontext['started']; |
| 3554 | - if ($ago < 60) |
|
| 3555 | - $ago = $ago . ' seconds'; |
|
| 3556 | - elseif ($ago < 3600) |
|
| 3557 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3558 | - else |
|
| 3559 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3738 | + if ($ago < 60) { |
|
| 3739 | + $ago = $ago . ' seconds'; |
|
| 3740 | + } elseif ($ago < 3600) { |
|
| 3741 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3742 | + } else { |
|
| 3743 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3744 | + } |
|
| 3560 | 3745 | |
| 3561 | 3746 | $active = time() - $upcontext['updated']; |
| 3562 | - if ($active < 60) |
|
| 3563 | - $updated = $active . ' seconds'; |
|
| 3564 | - elseif ($active < 3600) |
|
| 3565 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3566 | - else |
|
| 3567 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3747 | + if ($active < 60) { |
|
| 3748 | + $updated = $active . ' seconds'; |
|
| 3749 | + } elseif ($active < 3600) { |
|
| 3750 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3751 | + } else { |
|
| 3752 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3753 | + } |
|
| 3568 | 3754 | |
| 3569 | 3755 | echo ' |
| 3570 | 3756 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3573,16 +3759,18 @@ discard block |
||
| 3573 | 3759 | <div style="padding-left: 6ex;"> |
| 3574 | 3760 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3575 | 3761 | |
| 3576 | - if ($active < 600) |
|
| 3577 | - echo ' |
|
| 3762 | + if ($active < 600) { |
|
| 3763 | + echo ' |
|
| 3578 | 3764 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3765 | + } |
|
| 3579 | 3766 | |
| 3580 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3581 | - echo ' |
|
| 3767 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3768 | + echo ' |
|
| 3582 | 3769 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
| 3583 | - else |
|
| 3584 | - echo ' |
|
| 3770 | + } else { |
|
| 3771 | + echo ' |
|
| 3585 | 3772 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
| 3773 | + } |
|
| 3586 | 3774 | |
| 3587 | 3775 | echo ' |
| 3588 | 3776 | </div> |
@@ -3598,9 +3786,10 @@ discard block |
||
| 3598 | 3786 | <td> |
| 3599 | 3787 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
| 3600 | 3788 | |
| 3601 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3602 | - echo ' |
|
| 3789 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3790 | + echo ' |
|
| 3603 | 3791 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3792 | + } |
|
| 3604 | 3793 | |
| 3605 | 3794 | echo ' |
| 3606 | 3795 | </td> |
@@ -3611,9 +3800,10 @@ discard block |
||
| 3611 | 3800 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
| 3612 | 3801 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3613 | 3802 | |
| 3614 | - if (!empty($upcontext['password_failed'])) |
|
| 3615 | - echo ' |
|
| 3803 | + if (!empty($upcontext['password_failed'])) { |
|
| 3804 | + echo ' |
|
| 3616 | 3805 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3806 | + } |
|
| 3617 | 3807 | |
| 3618 | 3808 | echo ' |
| 3619 | 3809 | </td> |
@@ -3684,8 +3874,8 @@ discard block |
||
| 3684 | 3874 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3685 | 3875 | |
| 3686 | 3876 | // Warning message? |
| 3687 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3688 | - echo ' |
|
| 3877 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 3878 | + echo ' |
|
| 3689 | 3879 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3690 | 3880 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3691 | 3881 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3693,6 +3883,7 @@ discard block |
||
| 3693 | 3883 | ', $upcontext['upgrade_options_warning'], ' |
| 3694 | 3884 | </div> |
| 3695 | 3885 | </div>'; |
| 3886 | + } |
|
| 3696 | 3887 | |
| 3697 | 3888 | echo ' |
| 3698 | 3889 | <table> |
@@ -3735,8 +3926,8 @@ discard block |
||
| 3735 | 3926 | </td> |
| 3736 | 3927 | </tr>'; |
| 3737 | 3928 | |
| 3738 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3739 | - echo ' |
|
| 3929 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 3930 | + echo ' |
|
| 3740 | 3931 | <tr valign="top"> |
| 3741 | 3932 | <td width="2%"> |
| 3742 | 3933 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3745,6 +3936,7 @@ discard block |
||
| 3745 | 3936 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3746 | 3937 | </td> |
| 3747 | 3938 | </tr>'; |
| 3939 | + } |
|
| 3748 | 3940 | |
| 3749 | 3941 | echo ' |
| 3750 | 3942 | <tr valign="top"> |
@@ -3782,10 +3974,11 @@ discard block |
||
| 3782 | 3974 | </div>'; |
| 3783 | 3975 | |
| 3784 | 3976 | // Dont any tables so far? |
| 3785 | - if (!empty($upcontext['previous_tables'])) |
|
| 3786 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 3977 | + if (!empty($upcontext['previous_tables'])) { |
|
| 3978 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3787 | 3979 | echo ' |
| 3788 | 3980 | <br>Completed Table: "', $table, '".'; |
| 3981 | + } |
|
| 3789 | 3982 | |
| 3790 | 3983 | echo ' |
| 3791 | 3984 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3822,12 +4015,13 @@ discard block |
||
| 3822 | 4015 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3823 | 4016 | |
| 3824 | 4017 | // If debug flood the screen. |
| 3825 | - if ($is_debug) |
|
| 3826 | - echo ' |
|
| 4018 | + if ($is_debug) { |
|
| 4019 | + echo ' |
|
| 3827 | 4020 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3828 | 4021 | |
| 3829 | 4022 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 3830 | 4023 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4024 | + } |
|
| 3831 | 4025 | |
| 3832 | 4026 | echo ' |
| 3833 | 4027 | // Get the next update... |
@@ -3860,8 +4054,9 @@ discard block |
||
| 3860 | 4054 | { |
| 3861 | 4055 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 3862 | 4056 | |
| 3863 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 3864 | - $is_debug = true; |
|
| 4057 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4058 | + $is_debug = true; |
|
| 4059 | + } |
|
| 3865 | 4060 | |
| 3866 | 4061 | echo ' |
| 3867 | 4062 | <h3>Executing database changes</h3> |
@@ -3876,8 +4071,9 @@ discard block |
||
| 3876 | 4071 | { |
| 3877 | 4072 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 3878 | 4073 | { |
| 3879 | - if ($num != 0) |
|
| 3880 | - echo ' Successful!'; |
|
| 4074 | + if ($num != 0) { |
|
| 4075 | + echo ' Successful!'; |
|
| 4076 | + } |
|
| 3881 | 4077 | echo '<br>' . $item; |
| 3882 | 4078 | } |
| 3883 | 4079 | if (!empty($upcontext['changes_complete'])) |
@@ -3890,28 +4086,32 @@ discard block |
||
| 3890 | 4086 | $seconds = intval($active % 60); |
| 3891 | 4087 | |
| 3892 | 4088 | $totalTime = ''; |
| 3893 | - if ($hours > 0) |
|
| 3894 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3895 | - if ($minutes > 0) |
|
| 3896 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3897 | - if ($seconds > 0) |
|
| 3898 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4089 | + if ($hours > 0) { |
|
| 4090 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4091 | + } |
|
| 4092 | + if ($minutes > 0) { |
|
| 4093 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4094 | + } |
|
| 4095 | + if ($seconds > 0) { |
|
| 4096 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4097 | + } |
|
| 3899 | 4098 | } |
| 3900 | 4099 | |
| 3901 | - if ($is_debug && !empty($totalTime)) |
|
| 3902 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 3903 | - else |
|
| 3904 | - echo ' Successful!<br><br>'; |
|
| 4100 | + if ($is_debug && !empty($totalTime)) { |
|
| 4101 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4102 | + } else { |
|
| 4103 | + echo ' Successful!<br><br>'; |
|
| 4104 | + } |
|
| 3905 | 4105 | |
| 3906 | 4106 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 3907 | 4107 | } |
| 3908 | - } |
|
| 3909 | - else |
|
| 4108 | + } else |
|
| 3910 | 4109 | { |
| 3911 | 4110 | // Tell them how many files we have in total. |
| 3912 | - if ($upcontext['file_count'] > 1) |
|
| 3913 | - echo ' |
|
| 4111 | + if ($upcontext['file_count'] > 1) { |
|
| 4112 | + echo ' |
|
| 3914 | 4113 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4114 | + } |
|
| 3915 | 4115 | |
| 3916 | 4116 | echo ' |
| 3917 | 4117 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3927,19 +4127,23 @@ discard block |
||
| 3927 | 4127 | $seconds = intval($active % 60); |
| 3928 | 4128 | |
| 3929 | 4129 | $totalTime = ''; |
| 3930 | - if ($hours > 0) |
|
| 3931 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3932 | - if ($minutes > 0) |
|
| 3933 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3934 | - if ($seconds > 0) |
|
| 3935 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4130 | + if ($hours > 0) { |
|
| 4131 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4132 | + } |
|
| 4133 | + if ($minutes > 0) { |
|
| 4134 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4135 | + } |
|
| 4136 | + if ($seconds > 0) { |
|
| 4137 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4138 | + } |
|
| 3936 | 4139 | } |
| 3937 | 4140 | |
| 3938 | 4141 | echo ' |
| 3939 | 4142 | <br><span id="upgradeCompleted">'; |
| 3940 | 4143 | |
| 3941 | - if (!empty($totalTime)) |
|
| 3942 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4144 | + if (!empty($totalTime)) { |
|
| 4145 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4146 | + } |
|
| 3943 | 4147 | |
| 3944 | 4148 | echo '</span> |
| 3945 | 4149 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -3976,9 +4180,10 @@ discard block |
||
| 3976 | 4180 | var getData = ""; |
| 3977 | 4181 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 3978 | 4182 | |
| 3979 | - if ($is_debug) |
|
| 3980 | - echo ' |
|
| 4183 | + if ($is_debug) { |
|
| 4184 | + echo ' |
|
| 3981 | 4185 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4186 | + } |
|
| 3982 | 4187 | |
| 3983 | 4188 | echo ' |
| 3984 | 4189 | function getNextItem() |
@@ -4018,9 +4223,10 @@ discard block |
||
| 4018 | 4223 | document.getElementById("error_block").style.display = ""; |
| 4019 | 4224 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4020 | 4225 | |
| 4021 | - if ($is_debug) |
|
| 4022 | - echo ' |
|
| 4226 | + if ($is_debug) { |
|
| 4227 | + echo ' |
|
| 4023 | 4228 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4229 | + } |
|
| 4024 | 4230 | |
| 4025 | 4231 | echo ' |
| 4026 | 4232 | } |
@@ -4041,9 +4247,10 @@ discard block |
||
| 4041 | 4247 | document.getElementById("error_block").style.display = ""; |
| 4042 | 4248 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4043 | 4249 | |
| 4044 | - if ($is_debug) |
|
| 4045 | - echo ' |
|
| 4250 | + if ($is_debug) { |
|
| 4251 | + echo ' |
|
| 4046 | 4252 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4253 | + } |
|
| 4047 | 4254 | |
| 4048 | 4255 | echo ' |
| 4049 | 4256 | } |
@@ -4102,8 +4309,8 @@ discard block |
||
| 4102 | 4309 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4103 | 4310 | {'; |
| 4104 | 4311 | |
| 4105 | - if ($is_debug) |
|
| 4106 | - echo ' |
|
| 4312 | + if ($is_debug) { |
|
| 4313 | + echo ' |
|
| 4107 | 4314 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4108 | 4315 | |
| 4109 | 4316 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4121,6 +4328,7 @@ discard block |
||
| 4121 | 4328 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4122 | 4329 | |
| 4123 | 4330 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4331 | + } |
|
| 4124 | 4332 | |
| 4125 | 4333 | echo ' |
| 4126 | 4334 | |
@@ -4128,9 +4336,10 @@ discard block |
||
| 4128 | 4336 | document.getElementById(\'contbutt\').disabled = 0; |
| 4129 | 4337 | document.getElementById(\'database_done\').value = 1;'; |
| 4130 | 4338 | |
| 4131 | - if ($upcontext['file_count'] > 1) |
|
| 4132 | - echo ' |
|
| 4339 | + if ($upcontext['file_count'] > 1) { |
|
| 4340 | + echo ' |
|
| 4133 | 4341 | document.getElementById(\'info1\').style.display = "none";'; |
| 4342 | + } |
|
| 4134 | 4343 | |
| 4135 | 4344 | echo ' |
| 4136 | 4345 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4143,9 +4352,10 @@ discard block |
||
| 4143 | 4352 | lastItem = 0; |
| 4144 | 4353 | prevFile = curFile;'; |
| 4145 | 4354 | |
| 4146 | - if ($is_debug) |
|
| 4147 | - echo ' |
|
| 4355 | + if ($is_debug) { |
|
| 4356 | + echo ' |
|
| 4148 | 4357 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4358 | + } |
|
| 4149 | 4359 | |
| 4150 | 4360 | echo ' |
| 4151 | 4361 | getNextItem(); |
@@ -4153,8 +4363,8 @@ discard block |
||
| 4153 | 4363 | }'; |
| 4154 | 4364 | |
| 4155 | 4365 | // If debug scroll the screen. |
| 4156 | - if ($is_debug) |
|
| 4157 | - echo ' |
|
| 4366 | + if ($is_debug) { |
|
| 4367 | + echo ' |
|
| 4158 | 4368 | if (iLastSubStepProgress == -1) |
| 4159 | 4369 | { |
| 4160 | 4370 | // Give it consistent dots. |
@@ -4173,6 +4383,7 @@ discard block |
||
| 4173 | 4383 | |
| 4174 | 4384 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4175 | 4385 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4386 | + } |
|
| 4176 | 4387 | |
| 4177 | 4388 | echo ' |
| 4178 | 4389 | // Update the page. |
@@ -4233,9 +4444,10 @@ discard block |
||
| 4233 | 4444 | }'; |
| 4234 | 4445 | |
| 4235 | 4446 | // Start things off assuming we've not errored. |
| 4236 | - if (empty($upcontext['error_message'])) |
|
| 4237 | - echo ' |
|
| 4447 | + if (empty($upcontext['error_message'])) { |
|
| 4448 | + echo ' |
|
| 4238 | 4449 | getNextItem();'; |
| 4450 | + } |
|
| 4239 | 4451 | |
| 4240 | 4452 | echo ' |
| 4241 | 4453 | //# sourceURL=dynamicScript-dbch.js |
@@ -4253,18 +4465,21 @@ discard block |
||
| 4253 | 4465 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4254 | 4466 | <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>'; |
| 4255 | 4467 | |
| 4256 | - if (!empty($upcontext['error_message'])) |
|
| 4257 | - echo ' |
|
| 4468 | + if (!empty($upcontext['error_message'])) { |
|
| 4469 | + echo ' |
|
| 4258 | 4470 | <error>', $upcontext['error_message'], '</error>'; |
| 4471 | + } |
|
| 4259 | 4472 | |
| 4260 | - if (!empty($upcontext['error_string'])) |
|
| 4261 | - echo ' |
|
| 4473 | + if (!empty($upcontext['error_string'])) { |
|
| 4474 | + echo ' |
|
| 4262 | 4475 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4476 | + } |
|
| 4263 | 4477 | |
| 4264 | - if ($is_debug) |
|
| 4265 | - echo ' |
|
| 4478 | + if ($is_debug) { |
|
| 4479 | + echo ' |
|
| 4266 | 4480 | <curtime>', time(), '</curtime>'; |
| 4267 | -} |
|
| 4481 | + } |
|
| 4482 | + } |
|
| 4268 | 4483 | |
| 4269 | 4484 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4270 | 4485 | function template_convert_utf8() |
@@ -4283,18 +4498,20 @@ discard block |
||
| 4283 | 4498 | </div>'; |
| 4284 | 4499 | |
| 4285 | 4500 | // Done any tables so far? |
| 4286 | - if (!empty($upcontext['previous_tables'])) |
|
| 4287 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4501 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4502 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4288 | 4503 | echo ' |
| 4289 | 4504 | <br>Completed Table: "', $table, '".'; |
| 4505 | + } |
|
| 4290 | 4506 | |
| 4291 | 4507 | echo ' |
| 4292 | 4508 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4293 | 4509 | |
| 4294 | 4510 | // If we dropped their index, let's let them know |
| 4295 | - if ($upcontext['dropping_index']) |
|
| 4296 | - echo ' |
|
| 4511 | + if ($upcontext['dropping_index']) { |
|
| 4512 | + echo ' |
|
| 4297 | 4513 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated in the admin area after the upgrade is complete.</span>'; |
| 4514 | + } |
|
| 4298 | 4515 | |
| 4299 | 4516 | // Completion notification |
| 4300 | 4517 | echo ' |
@@ -4331,12 +4548,13 @@ discard block |
||
| 4331 | 4548 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4332 | 4549 | |
| 4333 | 4550 | // If debug flood the screen. |
| 4334 | - if ($is_debug) |
|
| 4335 | - echo ' |
|
| 4551 | + if ($is_debug) { |
|
| 4552 | + echo ' |
|
| 4336 | 4553 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4337 | 4554 | |
| 4338 | 4555 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4339 | 4556 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4557 | + } |
|
| 4340 | 4558 | |
| 4341 | 4559 | echo ' |
| 4342 | 4560 | // Get the next update... |
@@ -4384,19 +4602,21 @@ discard block |
||
| 4384 | 4602 | </div>'; |
| 4385 | 4603 | |
| 4386 | 4604 | // Dont any tables so far? |
| 4387 | - if (!empty($upcontext['previous_tables'])) |
|
| 4388 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4605 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4606 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4389 | 4607 | echo ' |
| 4390 | 4608 | <br>Completed Table: "', $table, '".'; |
| 4609 | + } |
|
| 4391 | 4610 | |
| 4392 | 4611 | echo ' |
| 4393 | 4612 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4394 | 4613 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
| 4395 | 4614 | |
| 4396 | 4615 | // Try to make sure substep was reset. |
| 4397 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4398 | - echo ' |
|
| 4616 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4617 | + echo ' |
|
| 4399 | 4618 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4619 | + } |
|
| 4400 | 4620 | |
| 4401 | 4621 | // Continue please! |
| 4402 | 4622 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4429,12 +4649,13 @@ discard block |
||
| 4429 | 4649 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4430 | 4650 | |
| 4431 | 4651 | // If debug flood the screen. |
| 4432 | - if ($is_debug) |
|
| 4433 | - echo ' |
|
| 4652 | + if ($is_debug) { |
|
| 4653 | + echo ' |
|
| 4434 | 4654 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4435 | 4655 | |
| 4436 | 4656 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4437 | 4657 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4658 | + } |
|
| 4438 | 4659 | |
| 4439 | 4660 | echo ' |
| 4440 | 4661 | // Get the next update... |
@@ -4470,8 +4691,8 @@ discard block |
||
| 4470 | 4691 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
| 4471 | 4692 | <form action="', $boardurl, '/index.php">'; |
| 4472 | 4693 | |
| 4473 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4474 | - echo ' |
|
| 4694 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4695 | + echo ' |
|
| 4475 | 4696 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
| 4476 | 4697 | <script> |
| 4477 | 4698 | function doTheDelete(theCheck) |
@@ -4483,6 +4704,7 @@ discard block |
||
| 4483 | 4704 | } |
| 4484 | 4705 | </script> |
| 4485 | 4706 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4707 | + } |
|
| 4486 | 4708 | |
| 4487 | 4709 | $active = time() - $upcontext['started']; |
| 4488 | 4710 | $hours = floor($active / 3600); |
@@ -4492,16 +4714,20 @@ discard block |
||
| 4492 | 4714 | if ($is_debug) |
| 4493 | 4715 | { |
| 4494 | 4716 | $totalTime = ''; |
| 4495 | - if ($hours > 0) |
|
| 4496 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4497 | - if ($minutes > 0) |
|
| 4498 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4499 | - if ($seconds > 0) |
|
| 4500 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4717 | + if ($hours > 0) { |
|
| 4718 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4719 | + } |
|
| 4720 | + if ($minutes > 0) { |
|
| 4721 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4722 | + } |
|
| 4723 | + if ($seconds > 0) { |
|
| 4724 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4725 | + } |
|
| 4501 | 4726 | } |
| 4502 | 4727 | |
| 4503 | - if ($is_debug && !empty($totalTime)) |
|
| 4504 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4728 | + if ($is_debug && !empty($totalTime)) { |
|
| 4729 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4730 | + } |
|
| 4505 | 4731 | |
| 4506 | 4732 | echo '<br> |
| 4507 | 4733 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4528,8 +4754,9 @@ discard block |
||
| 4528 | 4754 | |
| 4529 | 4755 | $current_substep = $_GET['substep']; |
| 4530 | 4756 | |
| 4531 | - if (empty($_GET['a'])) |
|
| 4532 | - $_GET['a'] = 0; |
|
| 4757 | + if (empty($_GET['a'])) { |
|
| 4758 | + $_GET['a'] = 0; |
|
| 4759 | + } |
|
| 4533 | 4760 | $step_progress['name'] = 'Converting ips'; |
| 4534 | 4761 | $step_progress['current'] = $_GET['a']; |
| 4535 | 4762 | |
@@ -4572,16 +4799,19 @@ discard block |
||
| 4572 | 4799 | 'empty' => '', |
| 4573 | 4800 | 'limit' => $limit, |
| 4574 | 4801 | )); |
| 4575 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4576 | - $arIp[] = $row[$oldCol]; |
|
| 4802 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4803 | + $arIp[] = $row[$oldCol]; |
|
| 4804 | + } |
|
| 4577 | 4805 | $smcFunc['db_free_result']($request); |
| 4578 | 4806 | |
| 4579 | 4807 | // Special case, null ip could keep us in a loop. |
| 4580 | - if (is_null($arIp[0])) |
|
| 4581 | - unset($arIp[0]); |
|
| 4808 | + if (is_null($arIp[0])) { |
|
| 4809 | + unset($arIp[0]); |
|
| 4810 | + } |
|
| 4582 | 4811 | |
| 4583 | - if (empty($arIp)) |
|
| 4584 | - $is_done = true; |
|
| 4812 | + if (empty($arIp)) { |
|
| 4813 | + $is_done = true; |
|
| 4814 | + } |
|
| 4585 | 4815 | |
| 4586 | 4816 | $updates = array(); |
| 4587 | 4817 | $cases = array(); |
@@ -4590,16 +4820,18 @@ discard block |
||
| 4590 | 4820 | { |
| 4591 | 4821 | $arIp[$i] = trim($arIp[$i]); |
| 4592 | 4822 | |
| 4593 | - if (empty($arIp[$i])) |
|
| 4594 | - continue; |
|
| 4823 | + if (empty($arIp[$i])) { |
|
| 4824 | + continue; |
|
| 4825 | + } |
|
| 4595 | 4826 | |
| 4596 | 4827 | $updates['ip' . $i] = $arIp[$i]; |
| 4597 | 4828 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4598 | 4829 | |
| 4599 | 4830 | if ($setSize > 0 && $i % $setSize === 0) |
| 4600 | 4831 | { |
| 4601 | - if (count($updates) == 1) |
|
| 4602 | - continue; |
|
| 4832 | + if (count($updates) == 1) { |
|
| 4833 | + continue; |
|
| 4834 | + } |
|
| 4603 | 4835 | |
| 4604 | 4836 | $updates['whereSet'] = array_values($updates); |
| 4605 | 4837 | $smcFunc['db_query']('', ' |
@@ -4633,8 +4865,7 @@ discard block |
||
| 4633 | 4865 | 'ip' => $ip |
| 4634 | 4866 | )); |
| 4635 | 4867 | } |
| 4636 | - } |
|
| 4637 | - else |
|
| 4868 | + } else |
|
| 4638 | 4869 | { |
| 4639 | 4870 | $updates['whereSet'] = array_values($updates); |
| 4640 | 4871 | $smcFunc['db_query']('', ' |
@@ -4648,9 +4879,9 @@ discard block |
||
| 4648 | 4879 | $updates |
| 4649 | 4880 | ); |
| 4650 | 4881 | } |
| 4882 | + } else { |
|
| 4883 | + $is_done = true; |
|
| 4651 | 4884 | } |
| 4652 | - else |
|
| 4653 | - $is_done = true; |
|
| 4654 | 4885 | |
| 4655 | 4886 | $_GET['a'] += $limit; |
| 4656 | 4887 | $step_progress['current'] = $_GET['a']; |
@@ -4676,10 +4907,11 @@ discard block |
||
| 4676 | 4907 | |
| 4677 | 4908 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4678 | 4909 | |
| 4679 | - if (isset($columns[$column])) |
|
| 4680 | - return $columns[$column]; |
|
| 4681 | - else |
|
| 4682 | - return null; |
|
| 4683 | -} |
|
| 4910 | + if (isset($columns[$column])) { |
|
| 4911 | + return $columns[$column]; |
|
| 4912 | + } else { |
|
| 4913 | + return null; |
|
| 4914 | + } |
|
| 4915 | + } |
|
| 4684 | 4916 | |
| 4685 | 4917 | ?> |
| 4686 | 4918 | \ No newline at end of file |