@@ -81,8 +81,9 @@ discard block |
||
| 81 | 81 | $upcontext['inactive_timeout'] = 10; |
| 82 | 82 | |
| 83 | 83 | // The helper is crucial. Include it first thing. |
| 84 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 84 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 85 | 85 | 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.'); |
| 86 | +} |
|
| 86 | 87 | |
| 87 | 88 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 88 | 89 | |
@@ -106,11 +107,14 @@ discard block |
||
| 106 | 107 | ini_set('default_socket_timeout', 900); |
| 107 | 108 | } |
| 108 | 109 | // Clean the upgrade path if this is from the client. |
| 109 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 110 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 110 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 111 | + for ($i = 1; |
|
| 112 | +} |
|
| 113 | +$i < $_SERVER['argc']; $i++) |
|
| 111 | 114 | { |
| 112 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 113 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 115 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 116 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 117 | + } |
|
| 114 | 118 | } |
| 115 | 119 | |
| 116 | 120 | // Are we from the client? |
@@ -118,9 +122,9 @@ discard block |
||
| 118 | 122 | { |
| 119 | 123 | $command_line = true; |
| 120 | 124 | $disable_security = true; |
| 121 | -} |
|
| 122 | -else |
|
| 125 | +} else { |
|
| 123 | 126 | $command_line = false; |
| 127 | +} |
|
| 124 | 128 | |
| 125 | 129 | // Load this now just because we can. |
| 126 | 130 | require_once($upgrade_path . '/Settings.php'); |
@@ -131,10 +135,12 @@ discard block |
||
| 131 | 135 | $upcontext['user'] = unserialize(base64_decode($upgradeData)); |
| 132 | 136 | |
| 133 | 137 | // Check for sensible values. |
| 134 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 135 | - $upcontext['user']['started'] = time(); |
|
| 136 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 137 | - $upcontext['user']['updated'] = 0; |
|
| 138 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 139 | + $upcontext['user']['started'] = time(); |
|
| 140 | + } |
|
| 141 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 142 | + $upcontext['user']['updated'] = 0; |
|
| 143 | + } |
|
| 138 | 144 | |
| 139 | 145 | $upcontext['started'] = $upcontext['user']['started']; |
| 140 | 146 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -192,8 +198,9 @@ discard block |
||
| 192 | 198 | 'db_error_skip' => true, |
| 193 | 199 | ) |
| 194 | 200 | ); |
| 195 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 196 | - $modSettings[$row['variable']] = $row['value']; |
|
| 201 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 202 | + $modSettings[$row['variable']] = $row['value']; |
|
| 203 | + } |
|
| 197 | 204 | $smcFunc['db_free_result']($request); |
| 198 | 205 | } |
| 199 | 206 | |
@@ -203,10 +210,12 @@ discard block |
||
| 203 | 210 | $modSettings['theme_url'] = 'Themes/default'; |
| 204 | 211 | $modSettings['images_url'] = 'Themes/default/images'; |
| 205 | 212 | } |
| 206 | -if (!isset($settings['default_theme_url'])) |
|
| 213 | +if (!isset($settings['default_theme_url'])) { |
|
| 207 | 214 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 208 | -if (!isset($settings['default_theme_dir'])) |
|
| 215 | +} |
|
| 216 | +if (!isset($settings['default_theme_dir'])) { |
|
| 209 | 217 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 218 | +} |
|
| 210 | 219 | |
| 211 | 220 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 212 | 221 | // Default title... |
@@ -224,13 +233,15 @@ discard block |
||
| 224 | 233 | $support_js = $upcontext['upgrade_status']['js']; |
| 225 | 234 | |
| 226 | 235 | // Only set this if the upgrader status says so. |
| 227 | - if (empty($is_debug)) |
|
| 228 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 236 | + if (empty($is_debug)) { |
|
| 237 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 238 | + } |
|
| 229 | 239 | |
| 230 | 240 | // Load the language. |
| 231 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 232 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 233 | -} |
|
| 241 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 242 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 243 | + } |
|
| 244 | + } |
|
| 234 | 245 | // Set the defaults. |
| 235 | 246 | else |
| 236 | 247 | { |
@@ -248,15 +259,18 @@ discard block |
||
| 248 | 259 | } |
| 249 | 260 | |
| 250 | 261 | // If this isn't the first stage see whether they are logging in and resuming. |
| 251 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 262 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 252 | 263 | checkLogin(); |
| 264 | +} |
|
| 253 | 265 | |
| 254 | -if ($command_line) |
|
| 266 | +if ($command_line) { |
|
| 255 | 267 | cmdStep0(); |
| 268 | +} |
|
| 256 | 269 | |
| 257 | 270 | // Don't error if we're using xml. |
| 258 | -if (isset($_GET['xml'])) |
|
| 271 | +if (isset($_GET['xml'])) { |
|
| 259 | 272 | $upcontext['return_error'] = true; |
| 273 | +} |
|
| 260 | 274 | |
| 261 | 275 | // Loop through all the steps doing each one as required. |
| 262 | 276 | $upcontext['overall_percent'] = 0; |
@@ -277,10 +291,11 @@ discard block |
||
| 277 | 291 | } |
| 278 | 292 | |
| 279 | 293 | // Call the step and if it returns false that means pause! |
| 280 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 281 | - break; |
|
| 282 | - elseif (function_exists($step[2])) |
|
| 283 | - $upcontext['current_step']++; |
|
| 294 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 295 | + break; |
|
| 296 | + } elseif (function_exists($step[2])) { |
|
| 297 | + $upcontext['current_step']++; |
|
| 298 | + } |
|
| 284 | 299 | } |
| 285 | 300 | $upcontext['overall_percent'] += $step[3]; |
| 286 | 301 | } |
@@ -319,17 +334,18 @@ discard block |
||
| 319 | 334 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 320 | 335 | if (!empty($command_line)) |
| 321 | 336 | { |
| 322 | - if (function_exists('debug_print_backtrace')) |
|
| 323 | - debug_print_backtrace(); |
|
| 337 | + if (function_exists('debug_print_backtrace')) { |
|
| 338 | + debug_print_backtrace(); |
|
| 339 | + } |
|
| 324 | 340 | |
| 325 | 341 | 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.'; |
| 326 | 342 | flush(); |
| 327 | 343 | die(); |
| 328 | 344 | } |
| 329 | 345 | |
| 330 | - if (!isset($_GET['xml'])) |
|
| 331 | - template_upgrade_above(); |
|
| 332 | - else |
|
| 346 | + if (!isset($_GET['xml'])) { |
|
| 347 | + template_upgrade_above(); |
|
| 348 | + } else |
|
| 333 | 349 | { |
| 334 | 350 | header('Content-Type: text/xml; charset=UTF-8'); |
| 335 | 351 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -351,21 +367,24 @@ discard block |
||
| 351 | 367 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(safe_serialize($upcontext['upgrade_status'])); |
| 352 | 368 | |
| 353 | 369 | // Custom stuff to pass back? |
| 354 | - if (!empty($upcontext['query_string'])) |
|
| 355 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 370 | + if (!empty($upcontext['query_string'])) { |
|
| 371 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 372 | + } |
|
| 356 | 373 | |
| 357 | 374 | call_user_func('template_' . $upcontext['sub_template']); |
| 358 | 375 | } |
| 359 | 376 | |
| 360 | 377 | // Was there an error? |
| 361 | - if (!empty($upcontext['forced_error_message'])) |
|
| 362 | - echo $upcontext['forced_error_message']; |
|
| 378 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 379 | + echo $upcontext['forced_error_message']; |
|
| 380 | + } |
|
| 363 | 381 | |
| 364 | 382 | // Show the footer. |
| 365 | - if (!isset($_GET['xml'])) |
|
| 366 | - template_upgrade_below(); |
|
| 367 | - else |
|
| 368 | - template_xml_below(); |
|
| 383 | + if (!isset($_GET['xml'])) { |
|
| 384 | + template_upgrade_below(); |
|
| 385 | + } else { |
|
| 386 | + template_xml_below(); |
|
| 387 | + } |
|
| 369 | 388 | } |
| 370 | 389 | |
| 371 | 390 | |
@@ -377,15 +396,19 @@ discard block |
||
| 377 | 396 | $seconds = intval($active % 60); |
| 378 | 397 | |
| 379 | 398 | $totalTime = ''; |
| 380 | - if ($hours > 0) |
|
| 381 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 382 | - if ($minutes > 0) |
|
| 383 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 384 | - if ($seconds > 0) |
|
| 385 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 399 | + if ($hours > 0) { |
|
| 400 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 401 | + } |
|
| 402 | + if ($minutes > 0) { |
|
| 403 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 404 | + } |
|
| 405 | + if ($seconds > 0) { |
|
| 406 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 407 | + } |
|
| 386 | 408 | |
| 387 | - if (!empty($totalTime)) |
|
| 388 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 409 | + if (!empty($totalTime)) { |
|
| 410 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 411 | + } |
|
| 389 | 412 | } |
| 390 | 413 | |
| 391 | 414 | // Bang - gone! |
@@ -398,8 +421,9 @@ discard block |
||
| 398 | 421 | global $upgradeurl, $upcontext, $command_line; |
| 399 | 422 | |
| 400 | 423 | // Command line users can't be redirected. |
| 401 | - if ($command_line) |
|
| 402 | - upgradeExit(true); |
|
| 424 | + if ($command_line) { |
|
| 425 | + upgradeExit(true); |
|
| 426 | + } |
|
| 403 | 427 | |
| 404 | 428 | // Are we providing the core info? |
| 405 | 429 | if ($addForm) |
@@ -422,19 +446,22 @@ discard block |
||
| 422 | 446 | global $modSettings, $sourcedir, $smcFunc; |
| 423 | 447 | |
| 424 | 448 | // Do the non-SSI stuff... |
| 425 | - if (function_exists('set_magic_quotes_runtime')) |
|
| 426 | - @set_magic_quotes_runtime(0); |
|
| 449 | + if (function_exists('set_magic_quotes_runtime')) { |
|
| 450 | + @set_magic_quotes_runtime(0); |
|
| 451 | + } |
|
| 427 | 452 | |
| 428 | 453 | error_reporting(E_ALL); |
| 429 | 454 | define('SMF', 1); |
| 430 | 455 | |
| 431 | 456 | // Start the session. |
| 432 | - if (@ini_get('session.save_handler') == 'user') |
|
| 433 | - @ini_set('session.save_handler', 'files'); |
|
| 457 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 458 | + @ini_set('session.save_handler', 'files'); |
|
| 459 | + } |
|
| 434 | 460 | @session_start(); |
| 435 | 461 | |
| 436 | - if (empty($smcFunc)) |
|
| 437 | - $smcFunc = array(); |
|
| 462 | + if (empty($smcFunc)) { |
|
| 463 | + $smcFunc = array(); |
|
| 464 | + } |
|
| 438 | 465 | |
| 439 | 466 | // We need this for authentication and some upgrade code |
| 440 | 467 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -446,8 +473,9 @@ discard block |
||
| 446 | 473 | initialize_inputs(); |
| 447 | 474 | |
| 448 | 475 | // Get the database going! |
| 449 | - if (empty($db_type) || $db_type == 'mysqli') |
|
| 450 | - $db_type = 'mysql'; |
|
| 476 | + if (empty($db_type) || $db_type == 'mysqli') { |
|
| 477 | + $db_type = 'mysql'; |
|
| 478 | + } |
|
| 451 | 479 | |
| 452 | 480 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
| 453 | 481 | { |
@@ -457,17 +485,19 @@ discard block |
||
| 457 | 485 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
| 458 | 486 | |
| 459 | 487 | // Oh dear god!! |
| 460 | - if ($db_connection === null) |
|
| 461 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 488 | + if ($db_connection === null) { |
|
| 489 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 490 | + } |
|
| 462 | 491 | |
| 463 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 464 | - $smcFunc['db_query']('', ' |
|
| 492 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 493 | + $smcFunc['db_query']('', ' |
|
| 465 | 494 | SET NAMES {string:db_character_set}', |
| 466 | 495 | array( |
| 467 | 496 | 'db_error_skip' => true, |
| 468 | 497 | 'db_character_set' => $db_character_set, |
| 469 | 498 | ) |
| 470 | 499 | ); |
| 500 | + } |
|
| 471 | 501 | |
| 472 | 502 | // Load the modSettings data... |
| 473 | 503 | $request = $smcFunc['db_query']('', ' |
@@ -478,11 +508,11 @@ discard block |
||
| 478 | 508 | ) |
| 479 | 509 | ); |
| 480 | 510 | $modSettings = array(); |
| 481 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 482 | - $modSettings[$row['variable']] = $row['value']; |
|
| 511 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 512 | + $modSettings[$row['variable']] = $row['value']; |
|
| 513 | + } |
|
| 483 | 514 | $smcFunc['db_free_result']($request); |
| 484 | - } |
|
| 485 | - else |
|
| 515 | + } else |
|
| 486 | 516 | { |
| 487 | 517 | 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.'); |
| 488 | 518 | } |
@@ -496,9 +526,10 @@ discard block |
||
| 496 | 526 | cleanRequest(); |
| 497 | 527 | } |
| 498 | 528 | |
| 499 | - if (!isset($_GET['substep'])) |
|
| 500 | - $_GET['substep'] = 0; |
|
| 501 | -} |
|
| 529 | + if (!isset($_GET['substep'])) { |
|
| 530 | + $_GET['substep'] = 0; |
|
| 531 | + } |
|
| 532 | + } |
|
| 502 | 533 | |
| 503 | 534 | function initialize_inputs() |
| 504 | 535 | { |
@@ -528,8 +559,9 @@ discard block |
||
| 528 | 559 | $dh = opendir(dirname(__FILE__)); |
| 529 | 560 | while ($file = readdir($dh)) |
| 530 | 561 | { |
| 531 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 532 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 562 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 563 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 564 | + } |
|
| 533 | 565 | } |
| 534 | 566 | closedir($dh); |
| 535 | 567 | |
@@ -559,8 +591,9 @@ discard block |
||
| 559 | 591 | { |
| 560 | 592 | $upcontext['remote_files_available'] = false; |
| 561 | 593 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
| 562 | - if ($test) |
|
| 563 | - $upcontext['remote_files_available'] = true; |
|
| 594 | + if ($test) { |
|
| 595 | + $upcontext['remote_files_available'] = true; |
|
| 596 | + } |
|
| 564 | 597 | @fclose($test); |
| 565 | 598 | } |
| 566 | 599 | |
@@ -568,8 +601,9 @@ discard block |
||
| 568 | 601 | $temp = 'upgrade_php?step'; |
| 569 | 602 | while (strlen($temp) > 4) |
| 570 | 603 | { |
| 571 | - if (isset($_GET[$temp])) |
|
| 572 | - unset($_GET[$temp]); |
|
| 604 | + if (isset($_GET[$temp])) { |
|
| 605 | + unset($_GET[$temp]); |
|
| 606 | + } |
|
| 573 | 607 | $temp = substr($temp, 1); |
| 574 | 608 | } |
| 575 | 609 | |
@@ -596,29 +630,36 @@ discard block |
||
| 596 | 630 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 597 | 631 | |
| 598 | 632 | // Need legacy scripts? |
| 599 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 600 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 601 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 602 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 603 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 604 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 633 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 634 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 635 | + } |
|
| 636 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 637 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 638 | + } |
|
| 639 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 640 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 641 | + } |
|
| 605 | 642 | |
| 606 | 643 | // This needs to exist! |
| 607 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 608 | - 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>]'); |
|
| 609 | - else |
|
| 610 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 644 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 645 | + 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>]'); |
|
| 646 | + } else { |
|
| 647 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 648 | + } |
|
| 611 | 649 | |
| 612 | - if (!$check) |
|
| 613 | - // 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. |
|
| 650 | + if (!$check) { |
|
| 651 | + // 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. |
|
| 614 | 652 | 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.'); |
| 653 | + } |
|
| 615 | 654 | |
| 616 | 655 | // Do they meet the install requirements? |
| 617 | - if (!php_version_check()) |
|
| 618 | - 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.'); |
|
| 656 | + if (!php_version_check()) { |
|
| 657 | + 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.'); |
|
| 658 | + } |
|
| 619 | 659 | |
| 620 | - if (!db_version_check()) |
|
| 621 | - 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.'); |
|
| 660 | + if (!db_version_check()) { |
|
| 661 | + 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.'); |
|
| 662 | + } |
|
| 622 | 663 | |
| 623 | 664 | // Do some checks to make sure they have proper privileges |
| 624 | 665 | db_extend('packages'); |
@@ -633,14 +674,16 @@ discard block |
||
| 633 | 674 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 634 | 675 | |
| 635 | 676 | // Sorry... we need CREATE, ALTER and DROP |
| 636 | - if (!$create || !$alter || !$drop) |
|
| 637 | - 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.'); |
|
| 677 | + if (!$create || !$alter || !$drop) { |
|
| 678 | + 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.'); |
|
| 679 | + } |
|
| 638 | 680 | |
| 639 | 681 | // Do a quick version spot check. |
| 640 | 682 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 641 | 683 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 642 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 643 | - 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.'); |
|
| 684 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 685 | + 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.'); |
|
| 686 | + } |
|
| 644 | 687 | |
| 645 | 688 | // What absolutely needs to be writable? |
| 646 | 689 | $writable_files = array( |
@@ -662,12 +705,13 @@ discard block |
||
| 662 | 705 | quickFileWritable($custom_av_dir); |
| 663 | 706 | |
| 664 | 707 | // Are we good now? |
| 665 | - if (!is_writable($custom_av_dir)) |
|
| 666 | - 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)); |
|
| 667 | - elseif ($need_settings_update) |
|
| 708 | + if (!is_writable($custom_av_dir)) { |
|
| 709 | + 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)); |
|
| 710 | + } elseif ($need_settings_update) |
|
| 668 | 711 | { |
| 669 | - if (!function_exists('cache_put_data')) |
|
| 670 | - require_once($sourcedir . '/Load.php'); |
|
| 712 | + if (!function_exists('cache_put_data')) { |
|
| 713 | + require_once($sourcedir . '/Load.php'); |
|
| 714 | + } |
|
| 671 | 715 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 672 | 716 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 673 | 717 | } |
@@ -676,28 +720,33 @@ discard block |
||
| 676 | 720 | |
| 677 | 721 | // Check the cache directory. |
| 678 | 722 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 679 | - if (!file_exists($cachedir_temp)) |
|
| 680 | - @mkdir($cachedir_temp); |
|
| 681 | - if (!file_exists($cachedir_temp)) |
|
| 682 | - 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.'); |
|
| 683 | - |
|
| 684 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 685 | - 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>.'); |
|
| 686 | - elseif (!isset($_GET['skiplang'])) |
|
| 723 | + if (!file_exists($cachedir_temp)) { |
|
| 724 | + @mkdir($cachedir_temp); |
|
| 725 | + } |
|
| 726 | + if (!file_exists($cachedir_temp)) { |
|
| 727 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 731 | + 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>.'); |
|
| 732 | + } elseif (!isset($_GET['skiplang'])) |
|
| 687 | 733 | { |
| 688 | 734 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 689 | 735 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 690 | 736 | |
| 691 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 692 | - 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>]'); |
|
| 737 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 738 | + 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>]'); |
|
| 739 | + } |
|
| 693 | 740 | } |
| 694 | 741 | |
| 695 | - if (!makeFilesWritable($writable_files)) |
|
| 696 | - return false; |
|
| 742 | + if (!makeFilesWritable($writable_files)) { |
|
| 743 | + return false; |
|
| 744 | + } |
|
| 697 | 745 | |
| 698 | 746 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 699 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 700 | - 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.'); |
|
| 747 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 748 | + 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.'); |
|
| 749 | + } |
|
| 701 | 750 | |
| 702 | 751 | // Upgrade the agreement. |
| 703 | 752 | elseif (isset($modSettings['agreement'])) |
@@ -708,8 +757,8 @@ discard block |
||
| 708 | 757 | } |
| 709 | 758 | |
| 710 | 759 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 711 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 712 | - $upcontext['warning'] = ' |
|
| 760 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 761 | + $upcontext['warning'] = ' |
|
| 713 | 762 | 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> |
| 714 | 763 | <ul> |
| 715 | 764 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -717,10 +766,12 @@ discard block |
||
| 717 | 766 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 718 | 767 | </ul> |
| 719 | 768 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="http://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 769 | + } |
|
| 720 | 770 | |
| 721 | 771 | // Either we're logged in or we're going to present the login. |
| 722 | - if (checkLogin()) |
|
| 723 | - return true; |
|
| 772 | + if (checkLogin()) { |
|
| 773 | + return true; |
|
| 774 | + } |
|
| 724 | 775 | |
| 725 | 776 | $upcontext += createToken('login'); |
| 726 | 777 | |
@@ -734,15 +785,17 @@ discard block |
||
| 734 | 785 | global $smcFunc, $db_type, $support_js; |
| 735 | 786 | |
| 736 | 787 | // Don't bother if the security is disabled. |
| 737 | - if ($disable_security) |
|
| 738 | - return true; |
|
| 788 | + if ($disable_security) { |
|
| 789 | + return true; |
|
| 790 | + } |
|
| 739 | 791 | |
| 740 | 792 | // Are we trying to login? |
| 741 | 793 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 742 | 794 | { |
| 743 | 795 | // If we've disabled security pick a suitable name! |
| 744 | - if (empty($_POST['user'])) |
|
| 745 | - $_POST['user'] = 'Administrator'; |
|
| 796 | + if (empty($_POST['user'])) { |
|
| 797 | + $_POST['user'] = 'Administrator'; |
|
| 798 | + } |
|
| 746 | 799 | |
| 747 | 800 | // Before 2.0 these column names were different! |
| 748 | 801 | $oldDB = false; |
@@ -757,16 +810,17 @@ discard block |
||
| 757 | 810 | 'db_error_skip' => true, |
| 758 | 811 | ) |
| 759 | 812 | ); |
| 760 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 761 | - $oldDB = true; |
|
| 813 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 814 | + $oldDB = true; |
|
| 815 | + } |
|
| 762 | 816 | $smcFunc['db_free_result']($request); |
| 763 | 817 | } |
| 764 | 818 | |
| 765 | 819 | // Get what we believe to be their details. |
| 766 | 820 | if (!$disable_security) |
| 767 | 821 | { |
| 768 | - if ($oldDB) |
|
| 769 | - $request = $smcFunc['db_query']('', ' |
|
| 822 | + if ($oldDB) { |
|
| 823 | + $request = $smcFunc['db_query']('', ' |
|
| 770 | 824 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 771 | 825 | additionalGroups AS additional_groups, lngfile |
| 772 | 826 | FROM {db_prefix}members |
@@ -776,8 +830,8 @@ discard block |
||
| 776 | 830 | 'db_error_skip' => true, |
| 777 | 831 | ) |
| 778 | 832 | ); |
| 779 | - else |
|
| 780 | - $request = $smcFunc['db_query']('', ' |
|
| 833 | + } else { |
|
| 834 | + $request = $smcFunc['db_query']('', ' |
|
| 781 | 835 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 782 | 836 | FROM {db_prefix}members |
| 783 | 837 | WHERE member_name = {string:member_name}', |
@@ -786,6 +840,7 @@ discard block |
||
| 786 | 840 | 'db_error_skip' => true, |
| 787 | 841 | ) |
| 788 | 842 | ); |
| 843 | + } |
|
| 789 | 844 | if ($smcFunc['db_num_rows']($request) != 0) |
| 790 | 845 | { |
| 791 | 846 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -793,13 +848,14 @@ discard block |
||
| 793 | 848 | $groups = explode(',', $addGroups); |
| 794 | 849 | $groups[] = $id_group; |
| 795 | 850 | |
| 796 | - foreach ($groups as $k => $v) |
|
| 797 | - $groups[$k] = (int) $v; |
|
| 851 | + foreach ($groups as $k => $v) { |
|
| 852 | + $groups[$k] = (int) $v; |
|
| 853 | + } |
|
| 798 | 854 | |
| 799 | 855 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 856 | + } else { |
|
| 857 | + $upcontext['username_incorrect'] = true; |
|
| 800 | 858 | } |
| 801 | - else |
|
| 802 | - $upcontext['username_incorrect'] = true; |
|
| 803 | 859 | $smcFunc['db_free_result']($request); |
| 804 | 860 | } |
| 805 | 861 | $upcontext['username'] = $_POST['user']; |
@@ -809,13 +865,14 @@ discard block |
||
| 809 | 865 | { |
| 810 | 866 | $upcontext['upgrade_status']['js'] = 1; |
| 811 | 867 | $support_js = 1; |
| 868 | + } else { |
|
| 869 | + $support_js = 0; |
|
| 812 | 870 | } |
| 813 | - else |
|
| 814 | - $support_js = 0; |
|
| 815 | 871 | |
| 816 | 872 | // Note down the version we are coming from. |
| 817 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 818 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 873 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 874 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 875 | + } |
|
| 819 | 876 | |
| 820 | 877 | // Didn't get anywhere? |
| 821 | 878 | 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'])) |
@@ -849,15 +906,15 @@ discard block |
||
| 849 | 906 | 'db_error_skip' => true, |
| 850 | 907 | ) |
| 851 | 908 | ); |
| 852 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 853 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 909 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 910 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 911 | + } |
|
| 854 | 912 | $smcFunc['db_free_result']($request); |
| 855 | 913 | } |
| 856 | 914 | |
| 857 | 915 | $upcontext['user']['id'] = $id_member; |
| 858 | 916 | $upcontext['user']['name'] = $name; |
| 859 | - } |
|
| 860 | - else |
|
| 917 | + } else |
|
| 861 | 918 | { |
| 862 | 919 | $upcontext['user']['id'] = 1; |
| 863 | 920 | $upcontext['user']['name'] = 'Administrator'; |
@@ -873,11 +930,11 @@ discard block |
||
| 873 | 930 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 874 | 931 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 875 | 932 | |
| 876 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 877 | - $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'] . '.'; |
|
| 878 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 879 | - $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'] . '.'; |
|
| 880 | - else |
|
| 933 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 934 | + $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'] . '.'; |
|
| 935 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 936 | + $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'] . '.'; |
|
| 937 | + } else |
|
| 881 | 938 | { |
| 882 | 939 | // Set this as the new language. |
| 883 | 940 | $upcontext['language'] = $user_language; |
@@ -921,8 +978,9 @@ discard block |
||
| 921 | 978 | unset($member_columns); |
| 922 | 979 | |
| 923 | 980 | // If we've not submitted then we're done. |
| 924 | - if (empty($_POST['upcont'])) |
|
| 925 | - return false; |
|
| 981 | + if (empty($_POST['upcont'])) { |
|
| 982 | + return false; |
|
| 983 | + } |
|
| 926 | 984 | |
| 927 | 985 | // Firstly, if they're enabling SM stat collection just do it. |
| 928 | 986 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats'])) |
@@ -937,25 +995,26 @@ discard block |
||
| 937 | 995 | fwrite($fp, $out); |
| 938 | 996 | |
| 939 | 997 | $return_data = ''; |
| 940 | - while (!feof($fp)) |
|
| 941 | - $return_data .= fgets($fp, 128); |
|
| 998 | + while (!feof($fp)) { |
|
| 999 | + $return_data .= fgets($fp, 128); |
|
| 1000 | + } |
|
| 942 | 1001 | |
| 943 | 1002 | fclose($fp); |
| 944 | 1003 | |
| 945 | 1004 | // Get the unique site ID. |
| 946 | 1005 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 947 | 1006 | |
| 948 | - if (!empty($ID[1])) |
|
| 949 | - $smcFunc['db_insert']('replace', |
|
| 1007 | + if (!empty($ID[1])) { |
|
| 1008 | + $smcFunc['db_insert']('replace', |
|
| 950 | 1009 | $db_prefix . 'settings', |
| 951 | 1010 | array('variable' => 'string', 'value' => 'string'), |
| 952 | 1011 | array('allow_sm_stats', $ID[1]), |
| 953 | 1012 | array('variable') |
| 954 | 1013 | ); |
| 1014 | + } |
|
| 955 | 1015 | } |
| 956 | - } |
|
| 957 | - else |
|
| 958 | - $smcFunc['db_query']('', ' |
|
| 1016 | + } else { |
|
| 1017 | + $smcFunc['db_query']('', ' |
|
| 959 | 1018 | DELETE FROM {db_prefix}settings |
| 960 | 1019 | WHERE variable = {string:allow_sm_stats}', |
| 961 | 1020 | array( |
@@ -963,6 +1022,7 @@ discard block |
||
| 963 | 1022 | 'db_error_skip' => true, |
| 964 | 1023 | ) |
| 965 | 1024 | ); |
| 1025 | + } |
|
| 966 | 1026 | |
| 967 | 1027 | // Deleting old karma stuff? |
| 968 | 1028 | if (!empty($_POST['delete_karma'])) |
@@ -977,20 +1037,22 @@ discard block |
||
| 977 | 1037 | ); |
| 978 | 1038 | |
| 979 | 1039 | // Cleaning up old karma member settings. |
| 980 | - if ($upcontext['karma_installed']['good']) |
|
| 981 | - $smcFunc['db_query']('', ' |
|
| 1040 | + if ($upcontext['karma_installed']['good']) { |
|
| 1041 | + $smcFunc['db_query']('', ' |
|
| 982 | 1042 | ALTER TABLE {db_prefix}members |
| 983 | 1043 | DROP karma_good', |
| 984 | 1044 | array() |
| 985 | 1045 | ); |
| 1046 | + } |
|
| 986 | 1047 | |
| 987 | 1048 | // Does karma bad was enable? |
| 988 | - if ($upcontext['karma_installed']['bad']) |
|
| 989 | - $smcFunc['db_query']('', ' |
|
| 1049 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1050 | + $smcFunc['db_query']('', ' |
|
| 990 | 1051 | ALTER TABLE {db_prefix}members |
| 991 | 1052 | DROP karma_bad', |
| 992 | 1053 | array() |
| 993 | 1054 | ); |
| 1055 | + } |
|
| 994 | 1056 | |
| 995 | 1057 | // Cleaning up old karma permissions. |
| 996 | 1058 | $smcFunc['db_query']('', ' |
@@ -1003,26 +1065,29 @@ discard block |
||
| 1003 | 1065 | } |
| 1004 | 1066 | |
| 1005 | 1067 | // Emptying the error log? |
| 1006 | - if (!empty($_POST['empty_error'])) |
|
| 1007 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1068 | + if (!empty($_POST['empty_error'])) { |
|
| 1069 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1008 | 1070 | TRUNCATE {db_prefix}log_errors', |
| 1009 | 1071 | array( |
| 1010 | 1072 | ) |
| 1011 | 1073 | ); |
| 1074 | + } |
|
| 1012 | 1075 | |
| 1013 | 1076 | $changes = array(); |
| 1014 | 1077 | |
| 1015 | 1078 | // Add proxy settings. |
| 1016 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1017 | - $changes += array( |
|
| 1079 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1080 | + $changes += array( |
|
| 1018 | 1081 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1019 | 1082 | 'image_proxy_maxsize' => 5190, |
| 1020 | 1083 | 'image_proxy_enabled' => 0, |
| 1021 | 1084 | ); |
| 1085 | + } |
|
| 1022 | 1086 | |
| 1023 | 1087 | // If we're overriding the language follow it through. |
| 1024 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1025 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1088 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1089 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1090 | + } |
|
| 1026 | 1091 | |
| 1027 | 1092 | if (!empty($_POST['maint'])) |
| 1028 | 1093 | { |
@@ -1034,30 +1099,34 @@ discard block |
||
| 1034 | 1099 | { |
| 1035 | 1100 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1036 | 1101 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1037 | - } |
|
| 1038 | - else |
|
| 1102 | + } else |
|
| 1039 | 1103 | { |
| 1040 | 1104 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1041 | 1105 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1042 | 1106 | } |
| 1043 | 1107 | } |
| 1044 | 1108 | |
| 1045 | - if ($command_line) |
|
| 1046 | - echo ' * Updating Settings.php...'; |
|
| 1109 | + if ($command_line) { |
|
| 1110 | + echo ' * Updating Settings.php...'; |
|
| 1111 | + } |
|
| 1047 | 1112 | |
| 1048 | 1113 | // Fix some old paths. |
| 1049 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1050 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1114 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1115 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1116 | + } |
|
| 1051 | 1117 | |
| 1052 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1053 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1118 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1119 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1120 | + } |
|
| 1054 | 1121 | |
| 1055 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1056 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1122 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1123 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1124 | + } |
|
| 1057 | 1125 | |
| 1058 | 1126 | // Not had the database type added before? |
| 1059 | - if (empty($db_type)) |
|
| 1060 | - $changes['db_type'] = 'mysql'; |
|
| 1127 | + if (empty($db_type)) { |
|
| 1128 | + $changes['db_type'] = 'mysql'; |
|
| 1129 | + } |
|
| 1061 | 1130 | |
| 1062 | 1131 | // If they have a "host:port" setup for the host, split that into separate values |
| 1063 | 1132 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1068,28 +1137,31 @@ discard block |
||
| 1068 | 1137 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1069 | 1138 | |
| 1070 | 1139 | // Only set this if we're not using the default port |
| 1071 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1072 | - $changes['db_port'] = (int) $db_port; |
|
| 1073 | - } |
|
| 1074 | - elseif (!empty($db_port)) |
|
| 1140 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1141 | + $changes['db_port'] = (int) $db_port; |
|
| 1142 | + } |
|
| 1143 | + } elseif (!empty($db_port)) |
|
| 1075 | 1144 | { |
| 1076 | 1145 | // If db_port is set and is the same as the default, set it to '' |
| 1077 | 1146 | if ($db_type == 'mysql') |
| 1078 | 1147 | { |
| 1079 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1080 | - $changes['db_port'] = '\'\''; |
|
| 1081 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1082 | - $changes['db_port'] = '\'\''; |
|
| 1148 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1149 | + $changes['db_port'] = '\'\''; |
|
| 1150 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1151 | + $changes['db_port'] = '\'\''; |
|
| 1152 | + } |
|
| 1083 | 1153 | } |
| 1084 | 1154 | } |
| 1085 | 1155 | |
| 1086 | 1156 | // Maybe we haven't had this option yet? |
| 1087 | - if (empty($packagesdir)) |
|
| 1088 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1157 | + if (empty($packagesdir)) { |
|
| 1158 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1159 | + } |
|
| 1089 | 1160 | |
| 1090 | 1161 | // Add support for $tasksdir var. |
| 1091 | - if (empty($tasksdir)) |
|
| 1092 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1162 | + if (empty($tasksdir)) { |
|
| 1163 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1164 | + } |
|
| 1093 | 1165 | |
| 1094 | 1166 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1095 | 1167 | |
@@ -1097,8 +1169,9 @@ discard block |
||
| 1097 | 1169 | require_once($sourcedir . '/Subs-Admin.php'); |
| 1098 | 1170 | updateSettingsFile($changes); |
| 1099 | 1171 | |
| 1100 | - if ($command_line) |
|
| 1101 | - echo ' Successful.' . "\n"; |
|
| 1172 | + if ($command_line) { |
|
| 1173 | + echo ' Successful.' . "\n"; |
|
| 1174 | + } |
|
| 1102 | 1175 | |
| 1103 | 1176 | // Are we doing debug? |
| 1104 | 1177 | if (isset($_POST['debug'])) |
@@ -1108,8 +1181,9 @@ discard block |
||
| 1108 | 1181 | } |
| 1109 | 1182 | |
| 1110 | 1183 | // If we're not backing up then jump one. |
| 1111 | - if (empty($_POST['backup'])) |
|
| 1112 | - $upcontext['current_step']++; |
|
| 1184 | + if (empty($_POST['backup'])) { |
|
| 1185 | + $upcontext['current_step']++; |
|
| 1186 | + } |
|
| 1113 | 1187 | |
| 1114 | 1188 | // If we've got here then let's proceed to the next step! |
| 1115 | 1189 | return true; |
@@ -1124,8 +1198,9 @@ discard block |
||
| 1124 | 1198 | $upcontext['page_title'] = 'Backup Database'; |
| 1125 | 1199 | |
| 1126 | 1200 | // Done it already - js wise? |
| 1127 | - if (!empty($_POST['backup_done'])) |
|
| 1128 | - return true; |
|
| 1201 | + if (!empty($_POST['backup_done'])) { |
|
| 1202 | + return true; |
|
| 1203 | + } |
|
| 1129 | 1204 | |
| 1130 | 1205 | // Some useful stuff here. |
| 1131 | 1206 | db_extend(); |
@@ -1139,9 +1214,10 @@ discard block |
||
| 1139 | 1214 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1140 | 1215 | |
| 1141 | 1216 | $table_names = array(); |
| 1142 | - foreach ($tables as $table) |
|
| 1143 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1217 | + foreach ($tables as $table) { |
|
| 1218 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1144 | 1219 | $table_names[] = $table; |
| 1220 | + } |
|
| 1145 | 1221 | |
| 1146 | 1222 | $upcontext['table_count'] = count($table_names); |
| 1147 | 1223 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1151,12 +1227,14 @@ discard block |
||
| 1151 | 1227 | $file_steps = $upcontext['table_count']; |
| 1152 | 1228 | |
| 1153 | 1229 | // What ones have we already done? |
| 1154 | - foreach ($table_names as $id => $table) |
|
| 1155 | - if ($id < $_GET['substep']) |
|
| 1230 | + foreach ($table_names as $id => $table) { |
|
| 1231 | + if ($id < $_GET['substep']) |
|
| 1156 | 1232 | $upcontext['previous_tables'][] = $table; |
| 1233 | + } |
|
| 1157 | 1234 | |
| 1158 | - if ($command_line) |
|
| 1159 | - echo 'Backing Up Tables.'; |
|
| 1235 | + if ($command_line) { |
|
| 1236 | + echo 'Backing Up Tables.'; |
|
| 1237 | + } |
|
| 1160 | 1238 | |
| 1161 | 1239 | // If we don't support javascript we backup here. |
| 1162 | 1240 | if (!$support_js || isset($_GET['xml'])) |
@@ -1175,8 +1253,9 @@ discard block |
||
| 1175 | 1253 | backupTable($table_names[$substep]); |
| 1176 | 1254 | |
| 1177 | 1255 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1178 | - if (isset($_GET['xml'])) |
|
| 1179 | - return upgradeExit(); |
|
| 1256 | + if (isset($_GET['xml'])) { |
|
| 1257 | + return upgradeExit(); |
|
| 1258 | + } |
|
| 1180 | 1259 | } |
| 1181 | 1260 | |
| 1182 | 1261 | if ($command_line) |
@@ -1209,9 +1288,10 @@ discard block |
||
| 1209 | 1288 | |
| 1210 | 1289 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1211 | 1290 | |
| 1212 | - if ($command_line) |
|
| 1213 | - echo ' done.'; |
|
| 1214 | -} |
|
| 1291 | + if ($command_line) { |
|
| 1292 | + echo ' done.'; |
|
| 1293 | + } |
|
| 1294 | + } |
|
| 1215 | 1295 | |
| 1216 | 1296 | // Step 2: Everything. |
| 1217 | 1297 | function DatabaseChanges() |
@@ -1220,8 +1300,9 @@ discard block |
||
| 1220 | 1300 | global $upcontext, $support_js, $db_type; |
| 1221 | 1301 | |
| 1222 | 1302 | // Have we just completed this? |
| 1223 | - if (!empty($_POST['database_done'])) |
|
| 1224 | - return true; |
|
| 1303 | + if (!empty($_POST['database_done'])) { |
|
| 1304 | + return true; |
|
| 1305 | + } |
|
| 1225 | 1306 | |
| 1226 | 1307 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1227 | 1308 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1236,15 +1317,16 @@ discard block |
||
| 1236 | 1317 | ); |
| 1237 | 1318 | |
| 1238 | 1319 | // How many files are there in total? |
| 1239 | - if (isset($_GET['filecount'])) |
|
| 1240 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1241 | - else |
|
| 1320 | + if (isset($_GET['filecount'])) { |
|
| 1321 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1322 | + } else |
|
| 1242 | 1323 | { |
| 1243 | 1324 | $upcontext['file_count'] = 0; |
| 1244 | 1325 | foreach ($files as $file) |
| 1245 | 1326 | { |
| 1246 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1247 | - $upcontext['file_count']++; |
|
| 1327 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1328 | + $upcontext['file_count']++; |
|
| 1329 | + } |
|
| 1248 | 1330 | } |
| 1249 | 1331 | } |
| 1250 | 1332 | |
@@ -1254,9 +1336,9 @@ discard block |
||
| 1254 | 1336 | $upcontext['cur_file_num'] = 0; |
| 1255 | 1337 | foreach ($files as $file) |
| 1256 | 1338 | { |
| 1257 | - if ($did_not_do) |
|
| 1258 | - $did_not_do--; |
|
| 1259 | - else |
|
| 1339 | + if ($did_not_do) { |
|
| 1340 | + $did_not_do--; |
|
| 1341 | + } else |
|
| 1260 | 1342 | { |
| 1261 | 1343 | $upcontext['cur_file_num']++; |
| 1262 | 1344 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1283,12 +1365,13 @@ discard block |
||
| 1283 | 1365 | // Flag to move on to the next. |
| 1284 | 1366 | $upcontext['completed_step'] = true; |
| 1285 | 1367 | // Did we complete the whole file? |
| 1286 | - if ($nextFile) |
|
| 1287 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1368 | + if ($nextFile) { |
|
| 1369 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1370 | + } |
|
| 1288 | 1371 | return upgradeExit(); |
| 1372 | + } elseif ($support_js) { |
|
| 1373 | + break; |
|
| 1289 | 1374 | } |
| 1290 | - elseif ($support_js) |
|
| 1291 | - break; |
|
| 1292 | 1375 | } |
| 1293 | 1376 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1294 | 1377 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1313,8 +1396,9 @@ discard block |
||
| 1313 | 1396 | global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1314 | 1397 | |
| 1315 | 1398 | // Now it's nice to have some of the basic SMF source files. |
| 1316 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1317 | - redirectLocation('&ssi=1'); |
|
| 1399 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1400 | + redirectLocation('&ssi=1'); |
|
| 1401 | + } |
|
| 1318 | 1402 | |
| 1319 | 1403 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1320 | 1404 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1330,14 +1414,16 @@ discard block |
||
| 1330 | 1414 | // Are we in maintenance mode? |
| 1331 | 1415 | if (isset($upcontext['user']['main'])) |
| 1332 | 1416 | { |
| 1333 | - if ($command_line) |
|
| 1334 | - echo ' * '; |
|
| 1417 | + if ($command_line) { |
|
| 1418 | + echo ' * '; |
|
| 1419 | + } |
|
| 1335 | 1420 | $upcontext['removed_maintenance'] = true; |
| 1336 | 1421 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1337 | 1422 | } |
| 1338 | 1423 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1339 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1340 | - $changes['maintenance'] = 1; |
|
| 1424 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1425 | + $changes['maintenance'] = 1; |
|
| 1426 | + } |
|
| 1341 | 1427 | |
| 1342 | 1428 | // Wipe this out... |
| 1343 | 1429 | $upcontext['user'] = array(); |
@@ -1352,9 +1438,9 @@ discard block |
||
| 1352 | 1438 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1353 | 1439 | |
| 1354 | 1440 | // Now is the perfect time to fetch the SM files. |
| 1355 | - if ($command_line) |
|
| 1356 | - cli_scheduled_fetchSMfiles(); |
|
| 1357 | - else |
|
| 1441 | + if ($command_line) { |
|
| 1442 | + cli_scheduled_fetchSMfiles(); |
|
| 1443 | + } else |
|
| 1358 | 1444 | { |
| 1359 | 1445 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1360 | 1446 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1362,8 +1448,9 @@ discard block |
||
| 1362 | 1448 | } |
| 1363 | 1449 | |
| 1364 | 1450 | // Log what we've done. |
| 1365 | - if (empty($user_info['id'])) |
|
| 1366 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1451 | + if (empty($user_info['id'])) { |
|
| 1452 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1453 | + } |
|
| 1367 | 1454 | |
| 1368 | 1455 | // Log the action manually, so CLI still works. |
| 1369 | 1456 | $smcFunc['db_insert']('', |
@@ -1382,8 +1469,9 @@ discard block |
||
| 1382 | 1469 | |
| 1383 | 1470 | // Save the current database version. |
| 1384 | 1471 | $server_version = $smcFunc['db_server_info'](); |
| 1385 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1386 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1472 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1473 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1474 | + } |
|
| 1387 | 1475 | |
| 1388 | 1476 | if ($command_line) |
| 1389 | 1477 | { |
@@ -1395,8 +1483,9 @@ discard block |
||
| 1395 | 1483 | |
| 1396 | 1484 | // Make sure it says we're done. |
| 1397 | 1485 | $upcontext['overall_percent'] = 100; |
| 1398 | - if (isset($upcontext['step_progress'])) |
|
| 1399 | - unset($upcontext['step_progress']); |
|
| 1486 | + if (isset($upcontext['step_progress'])) { |
|
| 1487 | + unset($upcontext['step_progress']); |
|
| 1488 | + } |
|
| 1400 | 1489 | |
| 1401 | 1490 | $_GET['substep'] = 0; |
| 1402 | 1491 | return false; |
@@ -1407,8 +1496,9 @@ discard block |
||
| 1407 | 1496 | { |
| 1408 | 1497 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1409 | 1498 | |
| 1410 | - if (empty($modSettings['time_format'])) |
|
| 1411 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1499 | + if (empty($modSettings['time_format'])) { |
|
| 1500 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1501 | + } |
|
| 1412 | 1502 | |
| 1413 | 1503 | // What files do we want to get |
| 1414 | 1504 | $request = $smcFunc['db_query']('', ' |
@@ -1442,8 +1532,9 @@ discard block |
||
| 1442 | 1532 | $file_data = fetch_web_data($url); |
| 1443 | 1533 | |
| 1444 | 1534 | // If we got an error - give up - the site might be down. |
| 1445 | - if ($file_data === false) |
|
| 1446 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1535 | + if ($file_data === false) { |
|
| 1536 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1537 | + } |
|
| 1447 | 1538 | |
| 1448 | 1539 | // Save the file to the database. |
| 1449 | 1540 | $smcFunc['db_query']('substring', ' |
@@ -1485,8 +1576,9 @@ discard block |
||
| 1485 | 1576 | $themeData = array(); |
| 1486 | 1577 | foreach ($values as $variable => $value) |
| 1487 | 1578 | { |
| 1488 | - if (!isset($value) || $value === null) |
|
| 1489 | - $value = 0; |
|
| 1579 | + if (!isset($value) || $value === null) { |
|
| 1580 | + $value = 0; |
|
| 1581 | + } |
|
| 1490 | 1582 | |
| 1491 | 1583 | $themeData[] = array(0, 1, $variable, $value); |
| 1492 | 1584 | } |
@@ -1515,8 +1607,9 @@ discard block |
||
| 1515 | 1607 | |
| 1516 | 1608 | foreach ($values as $variable => $value) |
| 1517 | 1609 | { |
| 1518 | - if (empty($modSettings[$value[0]])) |
|
| 1519 | - continue; |
|
| 1610 | + if (empty($modSettings[$value[0]])) { |
|
| 1611 | + continue; |
|
| 1612 | + } |
|
| 1520 | 1613 | |
| 1521 | 1614 | $smcFunc['db_query']('', ' |
| 1522 | 1615 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1602,10 +1695,11 @@ discard block |
||
| 1602 | 1695 | set_error_handler( |
| 1603 | 1696 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1604 | 1697 | { |
| 1605 | - if ($support_js) |
|
| 1606 | - return true; |
|
| 1607 | - else |
|
| 1608 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1698 | + if ($support_js) { |
|
| 1699 | + return true; |
|
| 1700 | + } else { |
|
| 1701 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1702 | + } |
|
| 1609 | 1703 | } |
| 1610 | 1704 | ); |
| 1611 | 1705 | |
@@ -1620,8 +1714,9 @@ discard block |
||
| 1620 | 1714 | 'db_error_skip' => true, |
| 1621 | 1715 | ) |
| 1622 | 1716 | ); |
| 1623 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 1624 | - die('Unable to find members table!'); |
|
| 1717 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1718 | + die('Unable to find members table!'); |
|
| 1719 | + } |
|
| 1625 | 1720 | $table_status = $smcFunc['db_fetch_assoc']($request); |
| 1626 | 1721 | $smcFunc['db_free_result']($request); |
| 1627 | 1722 | |
@@ -1636,17 +1731,20 @@ discard block |
||
| 1636 | 1731 | ) |
| 1637 | 1732 | ); |
| 1638 | 1733 | // Got something? |
| 1639 | - if ($smcFunc['db_num_rows']($request) !== 0) |
|
| 1640 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 1734 | + if ($smcFunc['db_num_rows']($request) !== 0) { |
|
| 1735 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 1736 | + } |
|
| 1641 | 1737 | $smcFunc['db_free_result']($request); |
| 1642 | 1738 | |
| 1643 | 1739 | // Excellent! |
| 1644 | - if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) |
|
| 1645 | - $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
| 1740 | + if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) { |
|
| 1741 | + $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
| 1742 | + } |
|
| 1646 | 1743 | } |
| 1647 | 1744 | } |
| 1648 | - if (empty($db_collation)) |
|
| 1649 | - $db_collation = ''; |
|
| 1745 | + if (empty($db_collation)) { |
|
| 1746 | + $db_collation = ''; |
|
| 1747 | + } |
|
| 1650 | 1748 | |
| 1651 | 1749 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1652 | 1750 | |
@@ -1658,8 +1756,9 @@ discard block |
||
| 1658 | 1756 | $last_step = ''; |
| 1659 | 1757 | |
| 1660 | 1758 | // Make sure all newly created tables will have the proper characters set. |
| 1661 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1662 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1759 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1760 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1761 | + } |
|
| 1663 | 1762 | |
| 1664 | 1763 | // Count the total number of steps within this file - for progress. |
| 1665 | 1764 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1679,15 +1778,18 @@ discard block |
||
| 1679 | 1778 | $do_current = $substep >= $_GET['substep']; |
| 1680 | 1779 | |
| 1681 | 1780 | // Get rid of any comments in the beginning of the line... |
| 1682 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1683 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1781 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1782 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1783 | + } |
|
| 1684 | 1784 | |
| 1685 | 1785 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1686 | - if ($is_debug && !$support_js && $command_line) |
|
| 1687 | - flush(); |
|
| 1786 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1787 | + flush(); |
|
| 1788 | + } |
|
| 1688 | 1789 | |
| 1689 | - if (trim($line) === '') |
|
| 1690 | - continue; |
|
| 1790 | + if (trim($line) === '') { |
|
| 1791 | + continue; |
|
| 1792 | + } |
|
| 1691 | 1793 | |
| 1692 | 1794 | if (trim(substr($line, 0, 3)) === '---') |
| 1693 | 1795 | { |
@@ -1697,8 +1799,9 @@ discard block |
||
| 1697 | 1799 | if (trim($current_data) != '' && $type !== '}') |
| 1698 | 1800 | { |
| 1699 | 1801 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1700 | - if ($command_line) |
|
| 1701 | - echo $upcontext['error_message']; |
|
| 1802 | + if ($command_line) { |
|
| 1803 | + echo $upcontext['error_message']; |
|
| 1804 | + } |
|
| 1702 | 1805 | } |
| 1703 | 1806 | |
| 1704 | 1807 | if ($type == ' ') |
@@ -1716,17 +1819,18 @@ discard block |
||
| 1716 | 1819 | if ($do_current) |
| 1717 | 1820 | { |
| 1718 | 1821 | $upcontext['actioned_items'][] = $last_step; |
| 1719 | - if ($command_line) |
|
| 1720 | - echo ' * '; |
|
| 1822 | + if ($command_line) { |
|
| 1823 | + echo ' * '; |
|
| 1824 | + } |
|
| 1721 | 1825 | } |
| 1722 | - } |
|
| 1723 | - elseif ($type == '#') |
|
| 1826 | + } elseif ($type == '#') |
|
| 1724 | 1827 | { |
| 1725 | 1828 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1726 | 1829 | |
| 1727 | 1830 | $upcontext['current_debug_item_num']++; |
| 1728 | - if (trim($line) != '---#') |
|
| 1729 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1831 | + if (trim($line) != '---#') { |
|
| 1832 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1833 | + } |
|
| 1730 | 1834 | |
| 1731 | 1835 | // Have we already done something? |
| 1732 | 1836 | if (isset($_GET['xml']) && $done_something) |
@@ -1737,34 +1841,36 @@ discard block |
||
| 1737 | 1841 | |
| 1738 | 1842 | if ($do_current) |
| 1739 | 1843 | { |
| 1740 | - if (trim($line) == '---#' && $command_line) |
|
| 1741 | - echo ' done.', $endl; |
|
| 1742 | - elseif ($command_line) |
|
| 1743 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1744 | - elseif (trim($line) != '---#') |
|
| 1844 | + if (trim($line) == '---#' && $command_line) { |
|
| 1845 | + echo ' done.', $endl; |
|
| 1846 | + } elseif ($command_line) { |
|
| 1847 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1848 | + } elseif (trim($line) != '---#') |
|
| 1745 | 1849 | { |
| 1746 | - if ($is_debug) |
|
| 1747 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1850 | + if ($is_debug) { |
|
| 1851 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1852 | + } |
|
| 1748 | 1853 | } |
| 1749 | 1854 | } |
| 1750 | 1855 | |
| 1751 | 1856 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1752 | 1857 | { |
| 1753 | - if ($command_line) |
|
| 1754 | - echo ' * '; |
|
| 1755 | - else |
|
| 1756 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1858 | + if ($command_line) { |
|
| 1859 | + echo ' * '; |
|
| 1860 | + } else { |
|
| 1861 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1862 | + } |
|
| 1757 | 1863 | } |
| 1758 | 1864 | |
| 1759 | 1865 | // Small step - only if we're actually doing stuff. |
| 1760 | - if ($do_current) |
|
| 1761 | - nextSubstep(++$substep); |
|
| 1762 | - else |
|
| 1763 | - $substep++; |
|
| 1764 | - } |
|
| 1765 | - elseif ($type == '{') |
|
| 1766 | - $current_type = 'code'; |
|
| 1767 | - elseif ($type == '}') |
|
| 1866 | + if ($do_current) { |
|
| 1867 | + nextSubstep(++$substep); |
|
| 1868 | + } else { |
|
| 1869 | + $substep++; |
|
| 1870 | + } |
|
| 1871 | + } elseif ($type == '{') { |
|
| 1872 | + $current_type = 'code'; |
|
| 1873 | + } elseif ($type == '}') |
|
| 1768 | 1874 | { |
| 1769 | 1875 | $current_type = 'sql'; |
| 1770 | 1876 | |
@@ -1777,8 +1883,9 @@ discard block |
||
| 1777 | 1883 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1778 | 1884 | { |
| 1779 | 1885 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1780 | - if ($command_line) |
|
| 1781 | - echo $upcontext['error_message']; |
|
| 1886 | + if ($command_line) { |
|
| 1887 | + echo $upcontext['error_message']; |
|
| 1888 | + } |
|
| 1782 | 1889 | } |
| 1783 | 1890 | |
| 1784 | 1891 | // Done with code! |
@@ -1858,8 +1965,9 @@ discard block |
||
| 1858 | 1965 | $db_unbuffered = false; |
| 1859 | 1966 | |
| 1860 | 1967 | // Failure?! |
| 1861 | - if ($result !== false) |
|
| 1862 | - return $result; |
|
| 1968 | + if ($result !== false) { |
|
| 1969 | + return $result; |
|
| 1970 | + } |
|
| 1863 | 1971 | |
| 1864 | 1972 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1865 | 1973 | // If MySQL we do something more clever. |
@@ -1887,54 +1995,61 @@ discard block |
||
| 1887 | 1995 | { |
| 1888 | 1996 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 1889 | 1997 | $result = mysqli_query($db_connection, $string); |
| 1890 | - if ($result !== false) |
|
| 1891 | - return $result; |
|
| 1998 | + if ($result !== false) { |
|
| 1999 | + return $result; |
|
| 2000 | + } |
|
| 1892 | 2001 | } |
| 1893 | - } |
|
| 1894 | - elseif ($mysqli_errno == 2013) |
|
| 2002 | + } elseif ($mysqli_errno == 2013) |
|
| 1895 | 2003 | { |
| 1896 | 2004 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 1897 | 2005 | mysqli_select_db($db_connection, $db_name); |
| 1898 | 2006 | if ($db_connection) |
| 1899 | 2007 | { |
| 1900 | 2008 | $result = mysqli_query($db_connection, $string); |
| 1901 | - if ($result !== false) |
|
| 1902 | - return $result; |
|
| 2009 | + if ($result !== false) { |
|
| 2010 | + return $result; |
|
| 2011 | + } |
|
| 1903 | 2012 | } |
| 1904 | 2013 | } |
| 1905 | 2014 | // Duplicate column name... should be okay ;). |
| 1906 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 1907 | - return false; |
|
| 2015 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2016 | + return false; |
|
| 2017 | + } |
|
| 1908 | 2018 | // Duplicate insert... make sure it's the proper type of query ;). |
| 1909 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 1910 | - return false; |
|
| 2019 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2020 | + return false; |
|
| 2021 | + } |
|
| 1911 | 2022 | // Creating an index on a non-existent column. |
| 1912 | - elseif ($mysqli_errno == 1072) |
|
| 1913 | - return false; |
|
| 1914 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 1915 | - return false; |
|
| 2023 | + elseif ($mysqli_errno == 1072) { |
|
| 2024 | + return false; |
|
| 2025 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2026 | + return false; |
|
| 2027 | + } |
|
| 1916 | 2028 | } |
| 1917 | 2029 | // If a table already exists don't go potty. |
| 1918 | 2030 | else |
| 1919 | 2031 | { |
| 1920 | 2032 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 1921 | 2033 | { |
| 1922 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 1923 | - return true; |
|
| 1924 | - } |
|
| 1925 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2034 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2035 | + return true; |
|
| 2036 | + } |
|
| 2037 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 1926 | 2038 | { |
| 1927 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 1928 | - return true; |
|
| 2039 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2040 | + return true; |
|
| 2041 | + } |
|
| 1929 | 2042 | } |
| 1930 | 2043 | } |
| 1931 | 2044 | |
| 1932 | 2045 | // Get the query string so we pass everything. |
| 1933 | 2046 | $query_string = ''; |
| 1934 | - foreach ($_GET as $k => $v) |
|
| 1935 | - $query_string .= ';' . $k . '=' . $v; |
|
| 1936 | - if (strlen($query_string) != 0) |
|
| 1937 | - $query_string = '?' . substr($query_string, 1); |
|
| 2047 | + foreach ($_GET as $k => $v) { |
|
| 2048 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2049 | + } |
|
| 2050 | + if (strlen($query_string) != 0) { |
|
| 2051 | + $query_string = '?' . substr($query_string, 1); |
|
| 2052 | + } |
|
| 1938 | 2053 | |
| 1939 | 2054 | if ($command_line) |
| 1940 | 2055 | { |
@@ -1989,16 +2104,18 @@ discard block |
||
| 1989 | 2104 | { |
| 1990 | 2105 | $found |= 1; |
| 1991 | 2106 | // Do some checks on the data if we have it set. |
| 1992 | - if (isset($change['col_type'])) |
|
| 1993 | - $found &= $change['col_type'] === $column['type']; |
|
| 1994 | - if (isset($change['null_allowed'])) |
|
| 1995 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 1996 | - if (isset($change['default'])) |
|
| 1997 | - $found &= $change['default'] === $column['default']; |
|
| 2107 | + if (isset($change['col_type'])) { |
|
| 2108 | + $found &= $change['col_type'] === $column['type']; |
|
| 2109 | + } |
|
| 2110 | + if (isset($change['null_allowed'])) { |
|
| 2111 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2112 | + } |
|
| 2113 | + if (isset($change['default'])) { |
|
| 2114 | + $found &= $change['default'] === $column['default']; |
|
| 2115 | + } |
|
| 1998 | 2116 | } |
| 1999 | 2117 | } |
| 2000 | - } |
|
| 2001 | - elseif ($change['type'] === 'index') |
|
| 2118 | + } elseif ($change['type'] === 'index') |
|
| 2002 | 2119 | { |
| 2003 | 2120 | $request = upgrade_query(' |
| 2004 | 2121 | SHOW INDEX |
@@ -2007,9 +2124,10 @@ discard block |
||
| 2007 | 2124 | { |
| 2008 | 2125 | $cur_index = array(); |
| 2009 | 2126 | |
| 2010 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2011 | - if ($row['Key_name'] === $change['name']) |
|
| 2127 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2128 | + if ($row['Key_name'] === $change['name']) |
|
| 2012 | 2129 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2130 | + } |
|
| 2013 | 2131 | |
| 2014 | 2132 | ksort($cur_index, SORT_NUMERIC); |
| 2015 | 2133 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2019,14 +2137,17 @@ discard block |
||
| 2019 | 2137 | } |
| 2020 | 2138 | |
| 2021 | 2139 | // If we're trying to add and it's added, we're done. |
| 2022 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2023 | - return true; |
|
| 2140 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2141 | + return true; |
|
| 2142 | + } |
|
| 2024 | 2143 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2025 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2026 | - return true; |
|
| 2144 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2145 | + return true; |
|
| 2146 | + } |
|
| 2027 | 2147 | // Otherwise is it just a test? |
| 2028 | - elseif ($is_test) |
|
| 2029 | - return false; |
|
| 2148 | + elseif ($is_test) { |
|
| 2149 | + return false; |
|
| 2150 | + } |
|
| 2030 | 2151 | |
| 2031 | 2152 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2032 | 2153 | $running = false; |
@@ -2037,8 +2158,9 @@ discard block |
||
| 2037 | 2158 | SHOW FULL PROCESSLIST'); |
| 2038 | 2159 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2039 | 2160 | { |
| 2040 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2041 | - $found = true; |
|
| 2161 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2162 | + $found = true; |
|
| 2163 | + } |
|
| 2042 | 2164 | } |
| 2043 | 2165 | |
| 2044 | 2166 | // Can't find it? Then we need to run it fools! |
@@ -2050,8 +2172,9 @@ discard block |
||
| 2050 | 2172 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2051 | 2173 | ' . $change['text'], true) !== false; |
| 2052 | 2174 | |
| 2053 | - if (!$success) |
|
| 2054 | - return false; |
|
| 2175 | + if (!$success) { |
|
| 2176 | + return false; |
|
| 2177 | + } |
|
| 2055 | 2178 | |
| 2056 | 2179 | // Return |
| 2057 | 2180 | $running = true; |
@@ -2093,8 +2216,9 @@ discard block |
||
| 2093 | 2216 | 'db_error_skip' => true, |
| 2094 | 2217 | ) |
| 2095 | 2218 | ); |
| 2096 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2097 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2219 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2220 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2221 | + } |
|
| 2098 | 2222 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2099 | 2223 | $smcFunc['db_free_result']($request); |
| 2100 | 2224 | |
@@ -2116,18 +2240,19 @@ discard block |
||
| 2116 | 2240 | ) |
| 2117 | 2241 | ); |
| 2118 | 2242 | // No results? Just forget it all together. |
| 2119 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2120 | - unset($table_row['Collation']); |
|
| 2121 | - else |
|
| 2122 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2243 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2244 | + unset($table_row['Collation']); |
|
| 2245 | + } else { |
|
| 2246 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2247 | + } |
|
| 2123 | 2248 | $smcFunc['db_free_result']($request); |
| 2124 | 2249 | } |
| 2125 | 2250 | |
| 2126 | 2251 | if ($column_fix) |
| 2127 | 2252 | { |
| 2128 | 2253 | // Make sure there are no NULL's left. |
| 2129 | - if ($null_fix) |
|
| 2130 | - $smcFunc['db_query']('', ' |
|
| 2254 | + if ($null_fix) { |
|
| 2255 | + $smcFunc['db_query']('', ' |
|
| 2131 | 2256 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2132 | 2257 | SET ' . $change['column'] . ' = {string:default} |
| 2133 | 2258 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2136,6 +2261,7 @@ discard block |
||
| 2136 | 2261 | 'db_error_skip' => true, |
| 2137 | 2262 | ) |
| 2138 | 2263 | ); |
| 2264 | + } |
|
| 2139 | 2265 | |
| 2140 | 2266 | // Do the actual alteration. |
| 2141 | 2267 | $smcFunc['db_query']('', ' |
@@ -2164,8 +2290,9 @@ discard block |
||
| 2164 | 2290 | } |
| 2165 | 2291 | |
| 2166 | 2292 | // Not a column we need to check on? |
| 2167 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2168 | - return; |
|
| 2293 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2294 | + return; |
|
| 2295 | + } |
|
| 2169 | 2296 | |
| 2170 | 2297 | // Break it up you (six|seven). |
| 2171 | 2298 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2184,13 +2311,13 @@ discard block |
||
| 2184 | 2311 | 'new_name' => $temp[2], |
| 2185 | 2312 | )); |
| 2186 | 2313 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2187 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2188 | - return; |
|
| 2314 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2315 | + return; |
|
| 2316 | + } |
|
| 2189 | 2317 | |
| 2190 | 2318 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2191 | 2319 | $smcFunc['db_free_result']($request); |
| 2192 | - } |
|
| 2193 | - else |
|
| 2320 | + } else |
|
| 2194 | 2321 | { |
| 2195 | 2322 | // Do this the old fashion, sure method way. |
| 2196 | 2323 | $request = $smcFunc['db_query']('', ' |
@@ -2201,21 +2328,24 @@ discard block |
||
| 2201 | 2328 | )); |
| 2202 | 2329 | // Mayday! |
| 2203 | 2330 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2204 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2205 | - return; |
|
| 2331 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2332 | + return; |
|
| 2333 | + } |
|
| 2206 | 2334 | |
| 2207 | 2335 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2208 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2209 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2336 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2337 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2210 | 2338 | { |
| 2211 | 2339 | $current_type = $row['Type']; |
| 2340 | + } |
|
| 2212 | 2341 | break; |
| 2213 | 2342 | } |
| 2214 | 2343 | } |
| 2215 | 2344 | |
| 2216 | 2345 | // If this doesn't match, the column may of been altered for a reason. |
| 2217 | - if (trim($current_type) != trim($temp[3])) |
|
| 2218 | - $temp[3] = $current_type; |
|
| 2346 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2347 | + $temp[3] = $current_type; |
|
| 2348 | + } |
|
| 2219 | 2349 | |
| 2220 | 2350 | // Piece this back together. |
| 2221 | 2351 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2227,8 +2357,9 @@ discard block |
||
| 2227 | 2357 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2228 | 2358 | global $step_progress, $is_debug, $upcontext; |
| 2229 | 2359 | |
| 2230 | - if ($_GET['substep'] < $substep) |
|
| 2231 | - $_GET['substep'] = $substep; |
|
| 2360 | + if ($_GET['substep'] < $substep) { |
|
| 2361 | + $_GET['substep'] = $substep; |
|
| 2362 | + } |
|
| 2232 | 2363 | |
| 2233 | 2364 | if ($command_line) |
| 2234 | 2365 | { |
@@ -2241,29 +2372,33 @@ discard block |
||
| 2241 | 2372 | } |
| 2242 | 2373 | |
| 2243 | 2374 | @set_time_limit(300); |
| 2244 | - if (function_exists('apache_reset_timeout')) |
|
| 2245 | - @apache_reset_timeout(); |
|
| 2375 | + if (function_exists('apache_reset_timeout')) { |
|
| 2376 | + @apache_reset_timeout(); |
|
| 2377 | + } |
|
| 2246 | 2378 | |
| 2247 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2248 | - return; |
|
| 2379 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2380 | + return; |
|
| 2381 | + } |
|
| 2249 | 2382 | |
| 2250 | 2383 | // Do we have some custom step progress stuff? |
| 2251 | 2384 | if (!empty($step_progress)) |
| 2252 | 2385 | { |
| 2253 | 2386 | $upcontext['substep_progress'] = 0; |
| 2254 | 2387 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2255 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2256 | - $upcontext['substep_progress'] = 99.9; |
|
| 2257 | - else |
|
| 2258 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2388 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2389 | + $upcontext['substep_progress'] = 99.9; |
|
| 2390 | + } else { |
|
| 2391 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2392 | + } |
|
| 2259 | 2393 | |
| 2260 | 2394 | // Make it nicely rounded. |
| 2261 | 2395 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2262 | 2396 | } |
| 2263 | 2397 | |
| 2264 | 2398 | // If this is XML we just exit right away! |
| 2265 | - if (isset($_GET['xml'])) |
|
| 2266 | - return upgradeExit(); |
|
| 2399 | + if (isset($_GET['xml'])) { |
|
| 2400 | + return upgradeExit(); |
|
| 2401 | + } |
|
| 2267 | 2402 | |
| 2268 | 2403 | // We're going to pause after this! |
| 2269 | 2404 | $upcontext['pause'] = true; |
@@ -2271,13 +2406,15 @@ discard block |
||
| 2271 | 2406 | $upcontext['query_string'] = ''; |
| 2272 | 2407 | foreach ($_GET as $k => $v) |
| 2273 | 2408 | { |
| 2274 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2275 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2409 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2410 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2411 | + } |
|
| 2276 | 2412 | } |
| 2277 | 2413 | |
| 2278 | 2414 | // Custom warning? |
| 2279 | - if (!empty($custom_warning)) |
|
| 2280 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2415 | + if (!empty($custom_warning)) { |
|
| 2416 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2417 | + } |
|
| 2281 | 2418 | |
| 2282 | 2419 | upgradeExit(); |
| 2283 | 2420 | } |
@@ -2292,25 +2429,26 @@ discard block |
||
| 2292 | 2429 | ob_implicit_flush(true); |
| 2293 | 2430 | @set_time_limit(600); |
| 2294 | 2431 | |
| 2295 | - if (!isset($_SERVER['argv'])) |
|
| 2296 | - $_SERVER['argv'] = array(); |
|
| 2432 | + if (!isset($_SERVER['argv'])) { |
|
| 2433 | + $_SERVER['argv'] = array(); |
|
| 2434 | + } |
|
| 2297 | 2435 | $_GET['maint'] = 1; |
| 2298 | 2436 | |
| 2299 | 2437 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2300 | 2438 | { |
| 2301 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2302 | - $_GET['lang'] = $match[1]; |
|
| 2303 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2304 | - continue; |
|
| 2305 | - elseif ($arg == '--no-maintenance') |
|
| 2306 | - $_GET['maint'] = 0; |
|
| 2307 | - elseif ($arg == '--debug') |
|
| 2308 | - $is_debug = true; |
|
| 2309 | - elseif ($arg == '--backup') |
|
| 2310 | - $_POST['backup'] = 1; |
|
| 2311 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2312 | - $_GET['conv'] = 1; |
|
| 2313 | - elseif ($i != 0) |
|
| 2439 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2440 | + $_GET['lang'] = $match[1]; |
|
| 2441 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2442 | + continue; |
|
| 2443 | + } elseif ($arg == '--no-maintenance') { |
|
| 2444 | + $_GET['maint'] = 0; |
|
| 2445 | + } elseif ($arg == '--debug') { |
|
| 2446 | + $is_debug = true; |
|
| 2447 | + } elseif ($arg == '--backup') { |
|
| 2448 | + $_POST['backup'] = 1; |
|
| 2449 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2450 | + $_GET['conv'] = 1; |
|
| 2451 | + } elseif ($i != 0) |
|
| 2314 | 2452 | { |
| 2315 | 2453 | echo 'SMF Command-line Upgrader |
| 2316 | 2454 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2324,10 +2462,12 @@ discard block |
||
| 2324 | 2462 | } |
| 2325 | 2463 | } |
| 2326 | 2464 | |
| 2327 | - if (!php_version_check()) |
|
| 2328 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2329 | - if (!db_version_check()) |
|
| 2330 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2465 | + if (!php_version_check()) { |
|
| 2466 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2467 | + } |
|
| 2468 | + if (!db_version_check()) { |
|
| 2469 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2470 | + } |
|
| 2331 | 2471 | |
| 2332 | 2472 | // Do some checks to make sure they have proper privileges |
| 2333 | 2473 | db_extend('packages'); |
@@ -2342,34 +2482,39 @@ discard block |
||
| 2342 | 2482 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2343 | 2483 | |
| 2344 | 2484 | // Sorry... we need CREATE, ALTER and DROP |
| 2345 | - if (!$create || !$alter || !$drop) |
|
| 2346 | - 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); |
|
| 2485 | + if (!$create || !$alter || !$drop) { |
|
| 2486 | + 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); |
|
| 2487 | + } |
|
| 2347 | 2488 | |
| 2348 | 2489 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2349 | 2490 | && @file_exists($sourcedir . '/QueryString.php') |
| 2350 | 2491 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2351 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2352 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2492 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2493 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2494 | + } |
|
| 2353 | 2495 | |
| 2354 | 2496 | // Do a quick version spot check. |
| 2355 | 2497 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2356 | 2498 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2357 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2358 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2499 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2500 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2501 | + } |
|
| 2359 | 2502 | |
| 2360 | 2503 | // Make sure Settings.php is writable. |
| 2361 | 2504 | quickFileWritable($boarddir . '/Settings.php'); |
| 2362 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2363 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2505 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2506 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2507 | + } |
|
| 2364 | 2508 | |
| 2365 | 2509 | // Make sure Settings_bak.php is writable. |
| 2366 | 2510 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2367 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2368 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2511 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2512 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2513 | + } |
|
| 2369 | 2514 | |
| 2370 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2371 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2372 | - elseif (isset($modSettings['agreement'])) |
|
| 2515 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2516 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2517 | + } elseif (isset($modSettings['agreement'])) |
|
| 2373 | 2518 | { |
| 2374 | 2519 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2375 | 2520 | fwrite($fp, $modSettings['agreement']); |
@@ -2379,31 +2524,36 @@ discard block |
||
| 2379 | 2524 | // Make sure Themes is writable. |
| 2380 | 2525 | quickFileWritable($modSettings['theme_dir']); |
| 2381 | 2526 | |
| 2382 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2383 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2527 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2528 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2529 | + } |
|
| 2384 | 2530 | |
| 2385 | 2531 | // Make sure cache directory exists and is writable! |
| 2386 | 2532 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2387 | - if (!file_exists($cachedir_temp)) |
|
| 2388 | - @mkdir($cachedir_temp); |
|
| 2533 | + if (!file_exists($cachedir_temp)) { |
|
| 2534 | + @mkdir($cachedir_temp); |
|
| 2535 | + } |
|
| 2389 | 2536 | |
| 2390 | 2537 | // Make sure the cache temp dir is writable. |
| 2391 | 2538 | quickFileWritable($cachedir_temp); |
| 2392 | 2539 | |
| 2393 | - if (!is_writable($cachedir_temp)) |
|
| 2394 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2540 | + if (!is_writable($cachedir_temp)) { |
|
| 2541 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2542 | + } |
|
| 2395 | 2543 | |
| 2396 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2397 | - print_error('Error: Unable to find language files!', true); |
|
| 2398 | - else |
|
| 2544 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2545 | + print_error('Error: Unable to find language files!', true); |
|
| 2546 | + } else |
|
| 2399 | 2547 | { |
| 2400 | 2548 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2401 | 2549 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2402 | 2550 | |
| 2403 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2404 | - print_error('Error: Language files out of date.', true); |
|
| 2405 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2406 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2551 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2552 | + print_error('Error: Language files out of date.', true); |
|
| 2553 | + } |
|
| 2554 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2555 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2556 | + } |
|
| 2407 | 2557 | |
| 2408 | 2558 | // Otherwise include it! |
| 2409 | 2559 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2432,8 +2582,7 @@ discard block |
||
| 2432 | 2582 | ); |
| 2433 | 2583 | |
| 2434 | 2584 | return true; |
| 2435 | - } |
|
| 2436 | - else |
|
| 2585 | + } else |
|
| 2437 | 2586 | { |
| 2438 | 2587 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2439 | 2588 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2477,8 +2626,9 @@ discard block |
||
| 2477 | 2626 | ) |
| 2478 | 2627 | ); |
| 2479 | 2628 | $db_charsets = array(); |
| 2480 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2481 | - $db_charsets[] = $row['Charset']; |
|
| 2629 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2630 | + $db_charsets[] = $row['Charset']; |
|
| 2631 | + } |
|
| 2482 | 2632 | |
| 2483 | 2633 | $smcFunc['db_free_result']($request); |
| 2484 | 2634 | |
@@ -2514,13 +2664,15 @@ discard block |
||
| 2514 | 2664 | // If there's a fulltext index, we need to drop it first... |
| 2515 | 2665 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2516 | 2666 | { |
| 2517 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2518 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2667 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2668 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2519 | 2669 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2670 | + } |
|
| 2520 | 2671 | $smcFunc['db_free_result']($request); |
| 2521 | 2672 | |
| 2522 | - if (isset($upcontext['fulltext_index'])) |
|
| 2523 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2673 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2674 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2675 | + } |
|
| 2524 | 2676 | } |
| 2525 | 2677 | |
| 2526 | 2678 | // Drop it and make a note... |
@@ -2710,8 +2862,9 @@ discard block |
||
| 2710 | 2862 | $replace = '%field%'; |
| 2711 | 2863 | |
| 2712 | 2864 | // Build a huge REPLACE statement... |
| 2713 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2714 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2865 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 2866 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2867 | + } |
|
| 2715 | 2868 | } |
| 2716 | 2869 | |
| 2717 | 2870 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2745,8 +2898,9 @@ discard block |
||
| 2745 | 2898 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 2746 | 2899 | |
| 2747 | 2900 | // Just to make sure it doesn't time out. |
| 2748 | - if (function_exists('apache_reset_timeout')) |
|
| 2749 | - @apache_reset_timeout(); |
|
| 2901 | + if (function_exists('apache_reset_timeout')) { |
|
| 2902 | + @apache_reset_timeout(); |
|
| 2903 | + } |
|
| 2750 | 2904 | |
| 2751 | 2905 | $table_charsets = array(); |
| 2752 | 2906 | |
@@ -2767,8 +2921,9 @@ discard block |
||
| 2767 | 2921 | { |
| 2768 | 2922 | list($charset) = explode('_', $collation); |
| 2769 | 2923 | |
| 2770 | - if (!isset($table_charsets[$charset])) |
|
| 2771 | - $table_charsets[$charset] = array(); |
|
| 2924 | + if (!isset($table_charsets[$charset])) { |
|
| 2925 | + $table_charsets[$charset] = array(); |
|
| 2926 | + } |
|
| 2772 | 2927 | |
| 2773 | 2928 | $table_charsets[$charset][] = $column_info; |
| 2774 | 2929 | } |
@@ -2808,10 +2963,11 @@ discard block |
||
| 2808 | 2963 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2809 | 2964 | { |
| 2810 | 2965 | $update = ''; |
| 2811 | - foreach ($table_charsets as $charset => $columns) |
|
| 2812 | - foreach ($columns as $column) |
|
| 2966 | + foreach ($table_charsets as $charset => $columns) { |
|
| 2967 | + foreach ($columns as $column) |
|
| 2813 | 2968 | $update .= ' |
| 2814 | 2969 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 2970 | + } |
|
| 2815 | 2971 | |
| 2816 | 2972 | $smcFunc['db_query']('', ' |
| 2817 | 2973 | UPDATE {raw:table_name} |
@@ -2836,8 +2992,9 @@ discard block |
||
| 2836 | 2992 | // Now do the actual conversion (if still needed). |
| 2837 | 2993 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2838 | 2994 | { |
| 2839 | - if ($command_line) |
|
| 2840 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 2995 | + if ($command_line) { |
|
| 2996 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 2997 | + } |
|
| 2841 | 2998 | |
| 2842 | 2999 | $smcFunc['db_query']('', ' |
| 2843 | 3000 | ALTER TABLE {raw:table_name} |
@@ -2847,8 +3004,9 @@ discard block |
||
| 2847 | 3004 | ) |
| 2848 | 3005 | ); |
| 2849 | 3006 | |
| 2850 | - if ($command_line) |
|
| 2851 | - echo " done.\n"; |
|
| 3007 | + if ($command_line) { |
|
| 3008 | + echo " done.\n"; |
|
| 3009 | + } |
|
| 2852 | 3010 | } |
| 2853 | 3011 | } |
| 2854 | 3012 | |
@@ -2878,8 +3036,8 @@ discard block |
||
| 2878 | 3036 | ); |
| 2879 | 3037 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2880 | 3038 | { |
| 2881 | - 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) |
|
| 2882 | - $smcFunc['db_query']('', ' |
|
| 3039 | + 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) { |
|
| 3040 | + $smcFunc['db_query']('', ' |
|
| 2883 | 3041 | UPDATE {db_prefix}log_actions |
| 2884 | 3042 | SET extra = {string:extra} |
| 2885 | 3043 | WHERE id_action = {int:current_action}', |
@@ -2888,6 +3046,7 @@ discard block |
||
| 2888 | 3046 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 2889 | 3047 | ) |
| 2890 | 3048 | ); |
| 3049 | + } |
|
| 2891 | 3050 | } |
| 2892 | 3051 | $smcFunc['db_free_result']($request); |
| 2893 | 3052 | |
@@ -2909,15 +3068,17 @@ discard block |
||
| 2909 | 3068 | // First thing's first - did we already do this? |
| 2910 | 3069 | if (!empty($modSettings['json_done'])) |
| 2911 | 3070 | { |
| 2912 | - if ($command_line) |
|
| 2913 | - return DeleteUpgrade(); |
|
| 2914 | - else |
|
| 2915 | - return true; |
|
| 3071 | + if ($command_line) { |
|
| 3072 | + return DeleteUpgrade(); |
|
| 3073 | + } else { |
|
| 3074 | + return true; |
|
| 3075 | + } |
|
| 2916 | 3076 | } |
| 2917 | 3077 | |
| 2918 | 3078 | // Done it already - js wise? |
| 2919 | - if (!empty($_POST['json_done'])) |
|
| 2920 | - return true; |
|
| 3079 | + if (!empty($_POST['json_done'])) { |
|
| 3080 | + return true; |
|
| 3081 | + } |
|
| 2921 | 3082 | |
| 2922 | 3083 | // List of tables affected by this function |
| 2923 | 3084 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2948,12 +3109,14 @@ discard block |
||
| 2948 | 3109 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 2949 | 3110 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 2950 | 3111 | |
| 2951 | - foreach ($keys as $id => $table) |
|
| 2952 | - if ($id < $_GET['substep']) |
|
| 3112 | + foreach ($keys as $id => $table) { |
|
| 3113 | + if ($id < $_GET['substep']) |
|
| 2953 | 3114 | $upcontext['previous_tables'][] = $table; |
| 3115 | + } |
|
| 2954 | 3116 | |
| 2955 | - if ($command_line) |
|
| 2956 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3117 | + if ($command_line) { |
|
| 3118 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3119 | + } |
|
| 2957 | 3120 | |
| 2958 | 3121 | if (!$support_js || isset($_GET['xml'])) |
| 2959 | 3122 | { |
@@ -2993,8 +3156,9 @@ discard block |
||
| 2993 | 3156 | |
| 2994 | 3157 | // Loop through and fix these... |
| 2995 | 3158 | $new_settings = array(); |
| 2996 | - if ($command_line) |
|
| 2997 | - echo "\n" . 'Fixing some settings...'; |
|
| 3159 | + if ($command_line) { |
|
| 3160 | + echo "\n" . 'Fixing some settings...'; |
|
| 3161 | + } |
|
| 2998 | 3162 | |
| 2999 | 3163 | foreach ($serialized_settings as $var) |
| 3000 | 3164 | { |
@@ -3002,22 +3166,24 @@ discard block |
||
| 3002 | 3166 | { |
| 3003 | 3167 | // Attempt to unserialize the setting |
| 3004 | 3168 | $temp = @safe_unserialize($modSettings[$var]); |
| 3005 | - if (!$temp && $command_line) |
|
| 3006 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3007 | - elseif ($temp !== false) |
|
| 3008 | - $new_settings[$var] = json_encode($temp); |
|
| 3169 | + if (!$temp && $command_line) { |
|
| 3170 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3171 | + } elseif ($temp !== false) { |
|
| 3172 | + $new_settings[$var] = json_encode($temp); |
|
| 3173 | + } |
|
| 3009 | 3174 | } |
| 3010 | 3175 | } |
| 3011 | 3176 | |
| 3012 | 3177 | // Update everything at once |
| 3013 | - if (!function_exists('cache_put_data')) |
|
| 3014 | - require_once($sourcedir . '/Load.php'); |
|
| 3178 | + if (!function_exists('cache_put_data')) { |
|
| 3179 | + require_once($sourcedir . '/Load.php'); |
|
| 3180 | + } |
|
| 3015 | 3181 | updateSettings($new_settings, true); |
| 3016 | 3182 | |
| 3017 | - if ($command_line) |
|
| 3018 | - echo ' done.'; |
|
| 3019 | - } |
|
| 3020 | - elseif ($table == 'themes') |
|
| 3183 | + if ($command_line) { |
|
| 3184 | + echo ' done.'; |
|
| 3185 | + } |
|
| 3186 | + } elseif ($table == 'themes') |
|
| 3021 | 3187 | { |
| 3022 | 3188 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3023 | 3189 | $query = $smcFunc['db_query']('', ' |
@@ -3036,10 +3202,11 @@ discard block |
||
| 3036 | 3202 | |
| 3037 | 3203 | if ($command_line) |
| 3038 | 3204 | { |
| 3039 | - if ($temp === false) |
|
| 3040 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3041 | - else |
|
| 3042 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3205 | + if ($temp === false) { |
|
| 3206 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3207 | + } else { |
|
| 3208 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3209 | + } |
|
| 3043 | 3210 | } |
| 3044 | 3211 | |
| 3045 | 3212 | if ($temp !== false) |
@@ -3061,15 +3228,15 @@ discard block |
||
| 3061 | 3228 | ) |
| 3062 | 3229 | ); |
| 3063 | 3230 | |
| 3064 | - if ($command_line) |
|
| 3065 | - echo ' done.'; |
|
| 3231 | + if ($command_line) { |
|
| 3232 | + echo ' done.'; |
|
| 3233 | + } |
|
| 3066 | 3234 | } |
| 3067 | 3235 | } |
| 3068 | 3236 | |
| 3069 | 3237 | $smcFunc['db_free_result']($query); |
| 3070 | 3238 | } |
| 3071 | - } |
|
| 3072 | - else |
|
| 3239 | + } else |
|
| 3073 | 3240 | { |
| 3074 | 3241 | // First item is always the key... |
| 3075 | 3242 | $key = $info[0]; |
@@ -3080,8 +3247,7 @@ discard block |
||
| 3080 | 3247 | { |
| 3081 | 3248 | $col_select = $info[1]; |
| 3082 | 3249 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3083 | - } |
|
| 3084 | - else |
|
| 3250 | + } else |
|
| 3085 | 3251 | { |
| 3086 | 3252 | $col_select = implode(', ', $info); |
| 3087 | 3253 | } |
@@ -3114,8 +3280,7 @@ discard block |
||
| 3114 | 3280 | if ($temp === false && $command_line) |
| 3115 | 3281 | { |
| 3116 | 3282 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3117 | - } |
|
| 3118 | - else |
|
| 3283 | + } else |
|
| 3119 | 3284 | { |
| 3120 | 3285 | $row[$col] = json_encode($temp); |
| 3121 | 3286 | |
@@ -3140,16 +3305,18 @@ discard block |
||
| 3140 | 3305 | } |
| 3141 | 3306 | } |
| 3142 | 3307 | |
| 3143 | - if ($command_line) |
|
| 3144 | - echo ' done.'; |
|
| 3308 | + if ($command_line) { |
|
| 3309 | + echo ' done.'; |
|
| 3310 | + } |
|
| 3145 | 3311 | |
| 3146 | 3312 | // Free up some memory... |
| 3147 | 3313 | $smcFunc['db_free_result']($query); |
| 3148 | 3314 | } |
| 3149 | 3315 | } |
| 3150 | 3316 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3151 | - if (isset($_GET['xml'])) |
|
| 3152 | - return upgradeExit(); |
|
| 3317 | + if (isset($_GET['xml'])) { |
|
| 3318 | + return upgradeExit(); |
|
| 3319 | + } |
|
| 3153 | 3320 | } |
| 3154 | 3321 | |
| 3155 | 3322 | if ($command_line) |
@@ -3164,8 +3331,9 @@ discard block |
||
| 3164 | 3331 | |
| 3165 | 3332 | $_GET['substep'] = 0; |
| 3166 | 3333 | // Make sure we move on! |
| 3167 | - if ($command_line) |
|
| 3168 | - return DeleteUpgrade(); |
|
| 3334 | + if ($command_line) { |
|
| 3335 | + return DeleteUpgrade(); |
|
| 3336 | + } |
|
| 3169 | 3337 | |
| 3170 | 3338 | return true; |
| 3171 | 3339 | } |
@@ -3185,14 +3353,16 @@ discard block |
||
| 3185 | 3353 | global $upcontext, $txt, $settings; |
| 3186 | 3354 | |
| 3187 | 3355 | // Don't call me twice! |
| 3188 | - if (!empty($upcontext['chmod_called'])) |
|
| 3189 | - return; |
|
| 3356 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3357 | + return; |
|
| 3358 | + } |
|
| 3190 | 3359 | |
| 3191 | 3360 | $upcontext['chmod_called'] = true; |
| 3192 | 3361 | |
| 3193 | 3362 | // Nothing? |
| 3194 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3195 | - return; |
|
| 3363 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3364 | + return; |
|
| 3365 | + } |
|
| 3196 | 3366 | |
| 3197 | 3367 | // Was it a problem with Windows? |
| 3198 | 3368 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3224,11 +3394,12 @@ discard block |
||
| 3224 | 3394 | 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\'); |
| 3225 | 3395 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3226 | 3396 | |
| 3227 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3228 | - echo ' |
|
| 3397 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3398 | + echo ' |
|
| 3229 | 3399 | content.write(\'<hr>\n\t\t\t\'); |
| 3230 | 3400 | 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\'); |
| 3231 | 3401 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3402 | + } |
|
| 3232 | 3403 | |
| 3233 | 3404 | echo ' |
| 3234 | 3405 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3236,17 +3407,19 @@ discard block |
||
| 3236 | 3407 | } |
| 3237 | 3408 | </script>'; |
| 3238 | 3409 | |
| 3239 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3240 | - echo ' |
|
| 3410 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3411 | + echo ' |
|
| 3241 | 3412 | <div class="error_message red"> |
| 3242 | 3413 | The following error was encountered when trying to connect:<br><br> |
| 3243 | 3414 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3244 | 3415 | </div> |
| 3245 | 3416 | <br>'; |
| 3417 | + } |
|
| 3246 | 3418 | |
| 3247 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3248 | - echo ' |
|
| 3419 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3420 | + echo ' |
|
| 3249 | 3421 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3422 | + } |
|
| 3250 | 3423 | |
| 3251 | 3424 | echo ' |
| 3252 | 3425 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3281,10 +3454,11 @@ discard block |
||
| 3281 | 3454 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
| 3282 | 3455 | </div>'; |
| 3283 | 3456 | |
| 3284 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3285 | - echo ' |
|
| 3457 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3458 | + echo ' |
|
| 3286 | 3459 | </form>'; |
| 3287 | -} |
|
| 3460 | + } |
|
| 3461 | + } |
|
| 3288 | 3462 | |
| 3289 | 3463 | function template_upgrade_above() |
| 3290 | 3464 | { |
@@ -3344,9 +3518,10 @@ discard block |
||
| 3344 | 3518 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3345 | 3519 | <ul>'; |
| 3346 | 3520 | |
| 3347 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3348 | - echo ' |
|
| 3521 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3522 | + echo ' |
|
| 3349 | 3523 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3524 | + } |
|
| 3350 | 3525 | |
| 3351 | 3526 | echo ' |
| 3352 | 3527 | </ul> |
@@ -3359,8 +3534,8 @@ discard block |
||
| 3359 | 3534 | </div> |
| 3360 | 3535 | </div>'; |
| 3361 | 3536 | |
| 3362 | - if (isset($upcontext['step_progress'])) |
|
| 3363 | - echo ' |
|
| 3537 | + if (isset($upcontext['step_progress'])) { |
|
| 3538 | + echo ' |
|
| 3364 | 3539 | <br> |
| 3365 | 3540 | <br> |
| 3366 | 3541 | <div id="progress_bar_step"> |
@@ -3369,6 +3544,7 @@ discard block |
||
| 3369 | 3544 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3370 | 3545 | </div> |
| 3371 | 3546 | </div>'; |
| 3547 | + } |
|
| 3372 | 3548 | |
| 3373 | 3549 | echo ' |
| 3374 | 3550 | <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> |
@@ -3399,32 +3575,36 @@ discard block |
||
| 3399 | 3575 | { |
| 3400 | 3576 | global $upcontext, $txt; |
| 3401 | 3577 | |
| 3402 | - if (!empty($upcontext['pause'])) |
|
| 3403 | - echo ' |
|
| 3578 | + if (!empty($upcontext['pause'])) { |
|
| 3579 | + echo ' |
|
| 3404 | 3580 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3405 | 3581 | |
| 3406 | 3582 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3407 | 3583 | <h3> |
| 3408 | 3584 | ', $txt['upgrade_paused_overload'], ' |
| 3409 | 3585 | </h3>'; |
| 3586 | + } |
|
| 3410 | 3587 | |
| 3411 | - if (!empty($upcontext['custom_warning'])) |
|
| 3412 | - echo ' |
|
| 3588 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3589 | + echo ' |
|
| 3413 | 3590 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3414 | 3591 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3415 | 3592 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3416 | 3593 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3417 | 3594 | </div>'; |
| 3595 | + } |
|
| 3418 | 3596 | |
| 3419 | 3597 | echo ' |
| 3420 | 3598 | <div class="righttext" style="margin: 1ex;">'; |
| 3421 | 3599 | |
| 3422 | - if (!empty($upcontext['continue'])) |
|
| 3423 | - echo ' |
|
| 3600 | + if (!empty($upcontext['continue'])) { |
|
| 3601 | + echo ' |
|
| 3424 | 3602 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
| 3425 | - if (!empty($upcontext['skip'])) |
|
| 3426 | - echo ' |
|
| 3603 | + } |
|
| 3604 | + if (!empty($upcontext['skip'])) { |
|
| 3605 | + echo ' |
|
| 3427 | 3606 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
| 3607 | + } |
|
| 3428 | 3608 | |
| 3429 | 3609 | echo ' |
| 3430 | 3610 | </div> |
@@ -3474,11 +3654,12 @@ discard block |
||
| 3474 | 3654 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3475 | 3655 | <smf>'; |
| 3476 | 3656 | |
| 3477 | - if (!empty($upcontext['get_data'])) |
|
| 3478 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3657 | + if (!empty($upcontext['get_data'])) { |
|
| 3658 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3479 | 3659 | echo ' |
| 3480 | 3660 | <get key="', $k, '">', $v, '</get>'; |
| 3481 | -} |
|
| 3661 | + } |
|
| 3662 | + } |
|
| 3482 | 3663 | |
| 3483 | 3664 | function template_xml_below() |
| 3484 | 3665 | { |
@@ -3519,8 +3700,8 @@ discard block |
||
| 3519 | 3700 | template_chmod(); |
| 3520 | 3701 | |
| 3521 | 3702 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3522 | - if ($upcontext['is_large_forum']) |
|
| 3523 | - echo ' |
|
| 3703 | + if ($upcontext['is_large_forum']) { |
|
| 3704 | + echo ' |
|
| 3524 | 3705 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3525 | 3706 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3526 | 3707 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3528,10 +3709,11 @@ discard block |
||
| 3528 | 3709 | ', $txt['upgrade_warning_lots_data'], ' |
| 3529 | 3710 | </div> |
| 3530 | 3711 | </div>'; |
| 3712 | + } |
|
| 3531 | 3713 | |
| 3532 | 3714 | // A warning message? |
| 3533 | - if (!empty($upcontext['warning'])) |
|
| 3534 | - echo ' |
|
| 3715 | + if (!empty($upcontext['warning'])) { |
|
| 3716 | + echo ' |
|
| 3535 | 3717 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3536 | 3718 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3537 | 3719 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3539,6 +3721,7 @@ discard block |
||
| 3539 | 3721 | ', $upcontext['warning'], ' |
| 3540 | 3722 | </div> |
| 3541 | 3723 | </div>'; |
| 3724 | + } |
|
| 3542 | 3725 | |
| 3543 | 3726 | // Paths are incorrect? |
| 3544 | 3727 | echo ' |
@@ -3554,20 +3737,22 @@ discard block |
||
| 3554 | 3737 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3555 | 3738 | { |
| 3556 | 3739 | $ago = time() - $upcontext['started']; |
| 3557 | - if ($ago < 60) |
|
| 3558 | - $ago = $ago . ' seconds'; |
|
| 3559 | - elseif ($ago < 3600) |
|
| 3560 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3561 | - else |
|
| 3562 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3740 | + if ($ago < 60) { |
|
| 3741 | + $ago = $ago . ' seconds'; |
|
| 3742 | + } elseif ($ago < 3600) { |
|
| 3743 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3744 | + } else { |
|
| 3745 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3746 | + } |
|
| 3563 | 3747 | |
| 3564 | 3748 | $active = time() - $upcontext['updated']; |
| 3565 | - if ($active < 60) |
|
| 3566 | - $updated = $active . ' seconds'; |
|
| 3567 | - elseif ($active < 3600) |
|
| 3568 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3569 | - else |
|
| 3570 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3749 | + if ($active < 60) { |
|
| 3750 | + $updated = $active . ' seconds'; |
|
| 3751 | + } elseif ($active < 3600) { |
|
| 3752 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3753 | + } else { |
|
| 3754 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3755 | + } |
|
| 3571 | 3756 | |
| 3572 | 3757 | echo ' |
| 3573 | 3758 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3576,16 +3761,18 @@ discard block |
||
| 3576 | 3761 | <div style="padding-left: 6ex;"> |
| 3577 | 3762 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3578 | 3763 | |
| 3579 | - if ($active < 600) |
|
| 3580 | - echo ' |
|
| 3764 | + if ($active < 600) { |
|
| 3765 | + echo ' |
|
| 3581 | 3766 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3767 | + } |
|
| 3582 | 3768 | |
| 3583 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3584 | - echo ' |
|
| 3769 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3770 | + echo ' |
|
| 3585 | 3771 | <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.'; |
| 3586 | - else |
|
| 3587 | - echo ' |
|
| 3772 | + } else { |
|
| 3773 | + echo ' |
|
| 3588 | 3774 | <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!'); |
| 3775 | + } |
|
| 3589 | 3776 | |
| 3590 | 3777 | echo ' |
| 3591 | 3778 | </div> |
@@ -3601,9 +3788,10 @@ discard block |
||
| 3601 | 3788 | <td> |
| 3602 | 3789 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
| 3603 | 3790 | |
| 3604 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3605 | - echo ' |
|
| 3791 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3792 | + echo ' |
|
| 3606 | 3793 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3794 | + } |
|
| 3607 | 3795 | |
| 3608 | 3796 | echo ' |
| 3609 | 3797 | </td> |
@@ -3614,9 +3802,10 @@ discard block |
||
| 3614 | 3802 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
| 3615 | 3803 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3616 | 3804 | |
| 3617 | - if (!empty($upcontext['password_failed'])) |
|
| 3618 | - echo ' |
|
| 3805 | + if (!empty($upcontext['password_failed'])) { |
|
| 3806 | + echo ' |
|
| 3619 | 3807 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3808 | + } |
|
| 3620 | 3809 | |
| 3621 | 3810 | echo ' |
| 3622 | 3811 | </td> |
@@ -3687,8 +3876,8 @@ discard block |
||
| 3687 | 3876 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3688 | 3877 | |
| 3689 | 3878 | // Warning message? |
| 3690 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3691 | - echo ' |
|
| 3879 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 3880 | + echo ' |
|
| 3692 | 3881 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3693 | 3882 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3694 | 3883 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3696,6 +3885,7 @@ discard block |
||
| 3696 | 3885 | ', $upcontext['upgrade_options_warning'], ' |
| 3697 | 3886 | </div> |
| 3698 | 3887 | </div>'; |
| 3888 | + } |
|
| 3699 | 3889 | |
| 3700 | 3890 | echo ' |
| 3701 | 3891 | <table> |
@@ -3738,8 +3928,8 @@ discard block |
||
| 3738 | 3928 | </td> |
| 3739 | 3929 | </tr>'; |
| 3740 | 3930 | |
| 3741 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3742 | - echo ' |
|
| 3931 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 3932 | + echo ' |
|
| 3743 | 3933 | <tr valign="top"> |
| 3744 | 3934 | <td width="2%"> |
| 3745 | 3935 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3748,6 +3938,7 @@ discard block |
||
| 3748 | 3938 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3749 | 3939 | </td> |
| 3750 | 3940 | </tr>'; |
| 3941 | + } |
|
| 3751 | 3942 | |
| 3752 | 3943 | echo ' |
| 3753 | 3944 | <tr valign="top"> |
@@ -3785,10 +3976,11 @@ discard block |
||
| 3785 | 3976 | </div>'; |
| 3786 | 3977 | |
| 3787 | 3978 | // Dont any tables so far? |
| 3788 | - if (!empty($upcontext['previous_tables'])) |
|
| 3789 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 3979 | + if (!empty($upcontext['previous_tables'])) { |
|
| 3980 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3790 | 3981 | echo ' |
| 3791 | 3982 | <br>Completed Table: "', $table, '".'; |
| 3983 | + } |
|
| 3792 | 3984 | |
| 3793 | 3985 | echo ' |
| 3794 | 3986 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3825,12 +4017,13 @@ discard block |
||
| 3825 | 4017 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3826 | 4018 | |
| 3827 | 4019 | // If debug flood the screen. |
| 3828 | - if ($is_debug) |
|
| 3829 | - echo ' |
|
| 4020 | + if ($is_debug) { |
|
| 4021 | + echo ' |
|
| 3830 | 4022 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3831 | 4023 | |
| 3832 | 4024 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 3833 | 4025 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4026 | + } |
|
| 3834 | 4027 | |
| 3835 | 4028 | echo ' |
| 3836 | 4029 | // Get the next update... |
@@ -3862,8 +4055,9 @@ discard block |
||
| 3862 | 4055 | { |
| 3863 | 4056 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 3864 | 4057 | |
| 3865 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 3866 | - $is_debug = true; |
|
| 4058 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4059 | + $is_debug = true; |
|
| 4060 | + } |
|
| 3867 | 4061 | |
| 3868 | 4062 | echo ' |
| 3869 | 4063 | <h3>Executing database changes</h3> |
@@ -3878,8 +4072,9 @@ discard block |
||
| 3878 | 4072 | { |
| 3879 | 4073 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 3880 | 4074 | { |
| 3881 | - if ($num != 0) |
|
| 3882 | - echo ' Successful!'; |
|
| 4075 | + if ($num != 0) { |
|
| 4076 | + echo ' Successful!'; |
|
| 4077 | + } |
|
| 3883 | 4078 | echo '<br>' . $item; |
| 3884 | 4079 | } |
| 3885 | 4080 | if (!empty($upcontext['changes_complete'])) |
@@ -3892,28 +4087,32 @@ discard block |
||
| 3892 | 4087 | $seconds = intval($active % 60); |
| 3893 | 4088 | |
| 3894 | 4089 | $totalTime = ''; |
| 3895 | - if ($hours > 0) |
|
| 3896 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3897 | - if ($minutes > 0) |
|
| 3898 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3899 | - if ($seconds > 0) |
|
| 3900 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4090 | + if ($hours > 0) { |
|
| 4091 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4092 | + } |
|
| 4093 | + if ($minutes > 0) { |
|
| 4094 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4095 | + } |
|
| 4096 | + if ($seconds > 0) { |
|
| 4097 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4098 | + } |
|
| 3901 | 4099 | } |
| 3902 | 4100 | |
| 3903 | - if ($is_debug && !empty($totalTime)) |
|
| 3904 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 3905 | - else |
|
| 3906 | - echo ' Successful!<br><br>'; |
|
| 4101 | + if ($is_debug && !empty($totalTime)) { |
|
| 4102 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4103 | + } else { |
|
| 4104 | + echo ' Successful!<br><br>'; |
|
| 4105 | + } |
|
| 3907 | 4106 | |
| 3908 | 4107 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 3909 | 4108 | } |
| 3910 | - } |
|
| 3911 | - else |
|
| 4109 | + } else |
|
| 3912 | 4110 | { |
| 3913 | 4111 | // Tell them how many files we have in total. |
| 3914 | - if ($upcontext['file_count'] > 1) |
|
| 3915 | - echo ' |
|
| 4112 | + if ($upcontext['file_count'] > 1) { |
|
| 4113 | + echo ' |
|
| 3916 | 4114 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4115 | + } |
|
| 3917 | 4116 | |
| 3918 | 4117 | echo ' |
| 3919 | 4118 | <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> |
@@ -3929,19 +4128,23 @@ discard block |
||
| 3929 | 4128 | $seconds = intval($active % 60); |
| 3930 | 4129 | |
| 3931 | 4130 | $totalTime = ''; |
| 3932 | - if ($hours > 0) |
|
| 3933 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3934 | - if ($minutes > 0) |
|
| 3935 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3936 | - if ($seconds > 0) |
|
| 3937 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4131 | + if ($hours > 0) { |
|
| 4132 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4133 | + } |
|
| 4134 | + if ($minutes > 0) { |
|
| 4135 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4136 | + } |
|
| 4137 | + if ($seconds > 0) { |
|
| 4138 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4139 | + } |
|
| 3938 | 4140 | } |
| 3939 | 4141 | |
| 3940 | 4142 | echo ' |
| 3941 | 4143 | <br><span id="upgradeCompleted">'; |
| 3942 | 4144 | |
| 3943 | - if (!empty($totalTime)) |
|
| 3944 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4145 | + if (!empty($totalTime)) { |
|
| 4146 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4147 | + } |
|
| 3945 | 4148 | |
| 3946 | 4149 | echo '</span> |
| 3947 | 4150 | <div id="debug_section" style="height: 200px; overflow: auto;"> |
@@ -3978,9 +4181,10 @@ discard block |
||
| 3978 | 4181 | var getData = ""; |
| 3979 | 4182 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 3980 | 4183 | |
| 3981 | - if ($is_debug) |
|
| 3982 | - echo ' |
|
| 4184 | + if ($is_debug) { |
|
| 4185 | + echo ' |
|
| 3983 | 4186 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4187 | + } |
|
| 3984 | 4188 | |
| 3985 | 4189 | echo ' |
| 3986 | 4190 | function getNextItem() |
@@ -4020,9 +4224,10 @@ discard block |
||
| 4020 | 4224 | document.getElementById("error_block").style.display = ""; |
| 4021 | 4225 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4022 | 4226 | |
| 4023 | - if ($is_debug) |
|
| 4024 | - echo ' |
|
| 4227 | + if ($is_debug) { |
|
| 4228 | + echo ' |
|
| 4025 | 4229 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4230 | + } |
|
| 4026 | 4231 | |
| 4027 | 4232 | echo ' |
| 4028 | 4233 | } |
@@ -4043,9 +4248,10 @@ discard block |
||
| 4043 | 4248 | document.getElementById("error_block").style.display = ""; |
| 4044 | 4249 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4045 | 4250 | |
| 4046 | - if ($is_debug) |
|
| 4047 | - echo ' |
|
| 4251 | + if ($is_debug) { |
|
| 4252 | + echo ' |
|
| 4048 | 4253 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4254 | + } |
|
| 4049 | 4255 | |
| 4050 | 4256 | echo ' |
| 4051 | 4257 | } |
@@ -4104,8 +4310,8 @@ discard block |
||
| 4104 | 4310 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4105 | 4311 | {'; |
| 4106 | 4312 | |
| 4107 | - if ($is_debug) |
|
| 4108 | - echo ' |
|
| 4313 | + if ($is_debug) { |
|
| 4314 | + echo ' |
|
| 4109 | 4315 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4110 | 4316 | |
| 4111 | 4317 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4123,6 +4329,7 @@ discard block |
||
| 4123 | 4329 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4124 | 4330 | |
| 4125 | 4331 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4332 | + } |
|
| 4126 | 4333 | |
| 4127 | 4334 | echo ' |
| 4128 | 4335 | |
@@ -4130,9 +4337,10 @@ discard block |
||
| 4130 | 4337 | document.getElementById(\'contbutt\').disabled = 0; |
| 4131 | 4338 | document.getElementById(\'database_done\').value = 1;'; |
| 4132 | 4339 | |
| 4133 | - if ($upcontext['file_count'] > 1) |
|
| 4134 | - echo ' |
|
| 4340 | + if ($upcontext['file_count'] > 1) { |
|
| 4341 | + echo ' |
|
| 4135 | 4342 | document.getElementById(\'info1\').style.display = "none";'; |
| 4343 | + } |
|
| 4136 | 4344 | |
| 4137 | 4345 | echo ' |
| 4138 | 4346 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4145,9 +4353,10 @@ discard block |
||
| 4145 | 4353 | lastItem = 0; |
| 4146 | 4354 | prevFile = curFile;'; |
| 4147 | 4355 | |
| 4148 | - if ($is_debug) |
|
| 4149 | - echo ' |
|
| 4356 | + if ($is_debug) { |
|
| 4357 | + echo ' |
|
| 4150 | 4358 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4359 | + } |
|
| 4151 | 4360 | |
| 4152 | 4361 | echo ' |
| 4153 | 4362 | getNextItem(); |
@@ -4155,8 +4364,8 @@ discard block |
||
| 4155 | 4364 | }'; |
| 4156 | 4365 | |
| 4157 | 4366 | // If debug scroll the screen. |
| 4158 | - if ($is_debug) |
|
| 4159 | - echo ' |
|
| 4367 | + if ($is_debug) { |
|
| 4368 | + echo ' |
|
| 4160 | 4369 | if (iLastSubStepProgress == -1) |
| 4161 | 4370 | { |
| 4162 | 4371 | // Give it consistent dots. |
@@ -4175,6 +4384,7 @@ discard block |
||
| 4175 | 4384 | |
| 4176 | 4385 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4177 | 4386 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4387 | + } |
|
| 4178 | 4388 | |
| 4179 | 4389 | echo ' |
| 4180 | 4390 | // Update the page. |
@@ -4235,9 +4445,10 @@ discard block |
||
| 4235 | 4445 | }'; |
| 4236 | 4446 | |
| 4237 | 4447 | // Start things off assuming we've not errored. |
| 4238 | - if (empty($upcontext['error_message'])) |
|
| 4239 | - echo ' |
|
| 4448 | + if (empty($upcontext['error_message'])) { |
|
| 4449 | + echo ' |
|
| 4240 | 4450 | getNextItem();'; |
| 4451 | + } |
|
| 4241 | 4452 | |
| 4242 | 4453 | echo ' |
| 4243 | 4454 | </script>'; |
@@ -4254,18 +4465,21 @@ discard block |
||
| 4254 | 4465 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4255 | 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>'; |
| 4256 | 4467 | |
| 4257 | - if (!empty($upcontext['error_message'])) |
|
| 4258 | - echo ' |
|
| 4468 | + if (!empty($upcontext['error_message'])) { |
|
| 4469 | + echo ' |
|
| 4259 | 4470 | <error>', $upcontext['error_message'], '</error>'; |
| 4471 | + } |
|
| 4260 | 4472 | |
| 4261 | - if (!empty($upcontext['error_string'])) |
|
| 4262 | - echo ' |
|
| 4473 | + if (!empty($upcontext['error_string'])) { |
|
| 4474 | + echo ' |
|
| 4263 | 4475 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4476 | + } |
|
| 4264 | 4477 | |
| 4265 | - if ($is_debug) |
|
| 4266 | - echo ' |
|
| 4478 | + if ($is_debug) { |
|
| 4479 | + echo ' |
|
| 4267 | 4480 | <curtime>', time(), '</curtime>'; |
| 4268 | -} |
|
| 4481 | + } |
|
| 4482 | + } |
|
| 4269 | 4483 | |
| 4270 | 4484 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4271 | 4485 | function template_convert_utf8() |
@@ -4282,18 +4496,20 @@ discard block |
||
| 4282 | 4496 | <span id="debuginfo"></span>'; |
| 4283 | 4497 | |
| 4284 | 4498 | // Done any tables so far? |
| 4285 | - if (!empty($upcontext['previous_tables'])) |
|
| 4286 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4499 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4500 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4287 | 4501 | echo ' |
| 4288 | 4502 | <br>Completed Table: "', $table, '".'; |
| 4503 | + } |
|
| 4289 | 4504 | |
| 4290 | 4505 | echo ' |
| 4291 | 4506 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4292 | 4507 | |
| 4293 | 4508 | // If we dropped their index, let's let them know |
| 4294 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
| 4295 | - echo ' |
|
| 4509 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
| 4510 | + echo ' |
|
| 4296 | 4511 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
| 4512 | + } |
|
| 4297 | 4513 | |
| 4298 | 4514 | echo ' |
| 4299 | 4515 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>'; |
@@ -4329,9 +4545,10 @@ discard block |
||
| 4329 | 4545 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4330 | 4546 | |
| 4331 | 4547 | // If debug flood the screen. |
| 4332 | - if ($is_debug) |
|
| 4333 | - echo ' |
|
| 4548 | + if ($is_debug) { |
|
| 4549 | + echo ' |
|
| 4334 | 4550 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
| 4551 | + } |
|
| 4335 | 4552 | |
| 4336 | 4553 | echo ' |
| 4337 | 4554 | // Get the next update... |
@@ -4373,19 +4590,21 @@ discard block |
||
| 4373 | 4590 | <span id="debuginfo"></span>'; |
| 4374 | 4591 | |
| 4375 | 4592 | // Dont any tables so far? |
| 4376 | - if (!empty($upcontext['previous_tables'])) |
|
| 4377 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4593 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4594 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4378 | 4595 | echo ' |
| 4379 | 4596 | <br>Completed Table: "', $table, '".'; |
| 4597 | + } |
|
| 4380 | 4598 | |
| 4381 | 4599 | echo ' |
| 4382 | 4600 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4383 | 4601 | <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>'; |
| 4384 | 4602 | |
| 4385 | 4603 | // Try to make sure substep was reset. |
| 4386 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4387 | - echo ' |
|
| 4604 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4605 | + echo ' |
|
| 4388 | 4606 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4607 | + } |
|
| 4389 | 4608 | |
| 4390 | 4609 | // Continue please! |
| 4391 | 4610 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4418,9 +4637,10 @@ discard block |
||
| 4418 | 4637 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4419 | 4638 | |
| 4420 | 4639 | // If debug flood the screen. |
| 4421 | - if ($is_debug) |
|
| 4422 | - echo ' |
|
| 4640 | + if ($is_debug) { |
|
| 4641 | + echo ' |
|
| 4423 | 4642 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
| 4643 | + } |
|
| 4424 | 4644 | |
| 4425 | 4645 | echo ' |
| 4426 | 4646 | // Get the next update... |
@@ -4455,8 +4675,8 @@ discard block |
||
| 4455 | 4675 | <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> |
| 4456 | 4676 | <form action="', $boardurl, '/index.php">'; |
| 4457 | 4677 | |
| 4458 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4459 | - echo ' |
|
| 4678 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4679 | + echo ' |
|
| 4460 | 4680 | <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> |
| 4461 | 4681 | <script> |
| 4462 | 4682 | function doTheDelete(theCheck) |
@@ -4468,6 +4688,7 @@ discard block |
||
| 4468 | 4688 | } |
| 4469 | 4689 | </script> |
| 4470 | 4690 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4691 | + } |
|
| 4471 | 4692 | |
| 4472 | 4693 | $active = time() - $upcontext['started']; |
| 4473 | 4694 | $hours = floor($active / 3600); |
@@ -4477,16 +4698,20 @@ discard block |
||
| 4477 | 4698 | if ($is_debug) |
| 4478 | 4699 | { |
| 4479 | 4700 | $totalTime = ''; |
| 4480 | - if ($hours > 0) |
|
| 4481 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4482 | - if ($minutes > 0) |
|
| 4483 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4484 | - if ($seconds > 0) |
|
| 4485 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4701 | + if ($hours > 0) { |
|
| 4702 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4703 | + } |
|
| 4704 | + if ($minutes > 0) { |
|
| 4705 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4706 | + } |
|
| 4707 | + if ($seconds > 0) { |
|
| 4708 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4709 | + } |
|
| 4486 | 4710 | } |
| 4487 | 4711 | |
| 4488 | - if ($is_debug && !empty($totalTime)) |
|
| 4489 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4712 | + if ($is_debug && !empty($totalTime)) { |
|
| 4713 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4714 | + } |
|
| 4490 | 4715 | |
| 4491 | 4716 | echo '<br> |
| 4492 | 4717 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="http://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4553,16 +4778,19 @@ discard block |
||
| 4553 | 4778 | 'empty' => '', |
| 4554 | 4779 | 'limit' => $limit, |
| 4555 | 4780 | )); |
| 4556 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4557 | - $arIp[] = $row[$oldCol]; |
|
| 4781 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4782 | + $arIp[] = $row[$oldCol]; |
|
| 4783 | + } |
|
| 4558 | 4784 | $smcFunc['db_free_result']($request); |
| 4559 | 4785 | |
| 4560 | 4786 | // Special case, null ip could keep us in a loop. |
| 4561 | - if (is_null($arIp[0])) |
|
| 4562 | - unset($arIp[0]); |
|
| 4787 | + if (is_null($arIp[0])) { |
|
| 4788 | + unset($arIp[0]); |
|
| 4789 | + } |
|
| 4563 | 4790 | |
| 4564 | - if (empty($arIp)) |
|
| 4565 | - $is_done = true; |
|
| 4791 | + if (empty($arIp)) { |
|
| 4792 | + $is_done = true; |
|
| 4793 | + } |
|
| 4566 | 4794 | |
| 4567 | 4795 | $updates = array(); |
| 4568 | 4796 | $cases = array(); |
@@ -4571,16 +4799,18 @@ discard block |
||
| 4571 | 4799 | { |
| 4572 | 4800 | $arIp[$i] = trim($arIp[$i]); |
| 4573 | 4801 | |
| 4574 | - if (empty($arIp[$i])) |
|
| 4575 | - continue; |
|
| 4802 | + if (empty($arIp[$i])) { |
|
| 4803 | + continue; |
|
| 4804 | + } |
|
| 4576 | 4805 | |
| 4577 | 4806 | $updates['ip' . $i] = $arIp[$i]; |
| 4578 | 4807 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4579 | 4808 | |
| 4580 | 4809 | if ($setSize > 0 && $i % $setSize === 0) |
| 4581 | 4810 | { |
| 4582 | - if (count($updates) == 1) |
|
| 4583 | - continue; |
|
| 4811 | + if (count($updates) == 1) { |
|
| 4812 | + continue; |
|
| 4813 | + } |
|
| 4584 | 4814 | |
| 4585 | 4815 | $updates['whereSet'] = array_values($updates); |
| 4586 | 4816 | $smcFunc['db_query']('', ' |
@@ -4614,8 +4844,7 @@ discard block |
||
| 4614 | 4844 | 'ip' => $ip |
| 4615 | 4845 | )); |
| 4616 | 4846 | } |
| 4617 | - } |
|
| 4618 | - else |
|
| 4847 | + } else |
|
| 4619 | 4848 | { |
| 4620 | 4849 | $updates['whereSet'] = array_values($updates); |
| 4621 | 4850 | $smcFunc['db_query']('', ' |
@@ -4629,9 +4858,9 @@ discard block |
||
| 4629 | 4858 | $updates |
| 4630 | 4859 | ); |
| 4631 | 4860 | } |
| 4861 | + } else { |
|
| 4862 | + $is_done = true; |
|
| 4632 | 4863 | } |
| 4633 | - else |
|
| 4634 | - $is_done = true; |
|
| 4635 | 4864 | |
| 4636 | 4865 | $_GET['a'] += $limit; |
| 4637 | 4866 | $step_progress['current'] = $_GET['a']; |