@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $upcontext['inactive_timeout'] = 10; |
| 76 | 76 | |
| 77 | 77 | // The helper is crucial. Include it first thing. |
| 78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
| 80 | +} |
|
| 80 | 81 | |
| 81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 82 | 83 | |
@@ -100,11 +101,14 @@ discard block |
||
| 100 | 101 | ini_set('default_socket_timeout', 900); |
| 101 | 102 | } |
| 102 | 103 | // Clean the upgrade path if this is from the client. |
| 103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 105 | + for ($i = 1; |
|
| 106 | +} |
|
| 107 | +$i < $_SERVER['argc']; $i++) |
|
| 105 | 108 | { |
| 106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 111 | + } |
|
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
| 112 | 116 | { |
| 113 | 117 | $command_line = true; |
| 114 | 118 | $disable_security = true; |
| 115 | -} |
|
| 116 | -else |
|
| 119 | +} else { |
|
| 117 | 120 | $command_line = false; |
| 121 | +} |
|
| 118 | 122 | |
| 119 | 123 | // Load this now just because we can. |
| 120 | 124 | require_once($upgrade_path . '/Settings.php'); |
| 121 | 125 | |
| 122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 123 | -if (isset($language)) |
|
| 127 | +if (isset($language)) { |
|
| 124 | 128 | $language = str_ireplace('-utf8', '', $language); |
| 129 | +} |
|
| 125 | 130 | |
| 126 | 131 | // Are we logged in? |
| 127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
| 129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 130 | 135 | |
| 131 | 136 | // Check for sensible values. |
| 132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 133 | - $upcontext['user']['started'] = time(); |
|
| 134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 135 | - $upcontext['user']['updated'] = 0; |
|
| 137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 138 | + $upcontext['user']['started'] = time(); |
|
| 139 | + } |
|
| 140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 141 | + $upcontext['user']['updated'] = 0; |
|
| 142 | + } |
|
| 136 | 143 | |
| 137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
| 138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -190,8 +197,9 @@ discard block |
||
| 190 | 197 | 'db_error_skip' => true, |
| 191 | 198 | ) |
| 192 | 199 | ); |
| 193 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 194 | - $modSettings[$row['variable']] = $row['value']; |
|
| 200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 201 | + $modSettings[$row['variable']] = $row['value']; |
|
| 202 | + } |
|
| 195 | 203 | $smcFunc['db_free_result']($request); |
| 196 | 204 | } |
| 197 | 205 | |
@@ -201,10 +209,12 @@ discard block |
||
| 201 | 209 | $modSettings['theme_url'] = 'Themes/default'; |
| 202 | 210 | $modSettings['images_url'] = 'Themes/default/images'; |
| 203 | 211 | } |
| 204 | -if (!isset($settings['default_theme_url'])) |
|
| 212 | +if (!isset($settings['default_theme_url'])) { |
|
| 205 | 213 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 206 | -if (!isset($settings['default_theme_dir'])) |
|
| 214 | +} |
|
| 215 | +if (!isset($settings['default_theme_dir'])) { |
|
| 207 | 216 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 217 | +} |
|
| 208 | 218 | |
| 209 | 219 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 210 | 220 | // Default title... |
@@ -222,13 +232,15 @@ discard block |
||
| 222 | 232 | $support_js = $upcontext['upgrade_status']['js']; |
| 223 | 233 | |
| 224 | 234 | // Only set this if the upgrader status says so. |
| 225 | - if (empty($is_debug)) |
|
| 226 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 235 | + if (empty($is_debug)) { |
|
| 236 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 237 | + } |
|
| 227 | 238 | |
| 228 | 239 | // Load the language. |
| 229 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 230 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 231 | -} |
|
| 240 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 241 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 242 | + } |
|
| 243 | + } |
|
| 232 | 244 | // Set the defaults. |
| 233 | 245 | else |
| 234 | 246 | { |
@@ -246,15 +258,18 @@ discard block |
||
| 246 | 258 | } |
| 247 | 259 | |
| 248 | 260 | // If this isn't the first stage see whether they are logging in and resuming. |
| 249 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 261 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 250 | 262 | checkLogin(); |
| 263 | +} |
|
| 251 | 264 | |
| 252 | -if ($command_line) |
|
| 265 | +if ($command_line) { |
|
| 253 | 266 | cmdStep0(); |
| 267 | +} |
|
| 254 | 268 | |
| 255 | 269 | // Don't error if we're using xml. |
| 256 | -if (isset($_GET['xml'])) |
|
| 270 | +if (isset($_GET['xml'])) { |
|
| 257 | 271 | $upcontext['return_error'] = true; |
| 272 | +} |
|
| 258 | 273 | |
| 259 | 274 | // Loop through all the steps doing each one as required. |
| 260 | 275 | $upcontext['overall_percent'] = 0; |
@@ -275,9 +290,9 @@ discard block |
||
| 275 | 290 | } |
| 276 | 291 | |
| 277 | 292 | // Call the step and if it returns false that means pause! |
| 278 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 279 | - break; |
|
| 280 | - elseif (function_exists($step[2])) { |
|
| 293 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 294 | + break; |
|
| 295 | + } elseif (function_exists($step[2])) { |
|
| 281 | 296 | //Start each new step with this unset, so the 'normal' template is called first |
| 282 | 297 | unset($_GET['xml']); |
| 283 | 298 | $_GET['substep'] = 0; |
@@ -321,17 +336,18 @@ discard block |
||
| 321 | 336 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 322 | 337 | if (!empty($command_line)) |
| 323 | 338 | { |
| 324 | - if (function_exists('debug_print_backtrace')) |
|
| 325 | - debug_print_backtrace(); |
|
| 339 | + if (function_exists('debug_print_backtrace')) { |
|
| 340 | + debug_print_backtrace(); |
|
| 341 | + } |
|
| 326 | 342 | |
| 327 | 343 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
| 328 | 344 | flush(); |
| 329 | 345 | die(); |
| 330 | 346 | } |
| 331 | 347 | |
| 332 | - if (!isset($_GET['xml'])) |
|
| 333 | - template_upgrade_above(); |
|
| 334 | - else |
|
| 348 | + if (!isset($_GET['xml'])) { |
|
| 349 | + template_upgrade_above(); |
|
| 350 | + } else |
|
| 335 | 351 | { |
| 336 | 352 | header('Content-Type: text/xml; charset=UTF-8'); |
| 337 | 353 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -353,25 +369,29 @@ discard block |
||
| 353 | 369 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 354 | 370 | |
| 355 | 371 | // Custom stuff to pass back? |
| 356 | - if (!empty($upcontext['query_string'])) |
|
| 357 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 372 | + if (!empty($upcontext['query_string'])) { |
|
| 373 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 374 | + } |
|
| 358 | 375 | |
| 359 | 376 | // Call the appropriate subtemplate |
| 360 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 361 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 362 | - else |
|
| 363 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 377 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 378 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 379 | + } else { |
|
| 380 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 381 | + } |
|
| 364 | 382 | } |
| 365 | 383 | |
| 366 | 384 | // Was there an error? |
| 367 | - if (!empty($upcontext['forced_error_message'])) |
|
| 368 | - echo $upcontext['forced_error_message']; |
|
| 385 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 386 | + echo $upcontext['forced_error_message']; |
|
| 387 | + } |
|
| 369 | 388 | |
| 370 | 389 | // Show the footer. |
| 371 | - if (!isset($_GET['xml'])) |
|
| 372 | - template_upgrade_below(); |
|
| 373 | - else |
|
| 374 | - template_xml_below(); |
|
| 390 | + if (!isset($_GET['xml'])) { |
|
| 391 | + template_upgrade_below(); |
|
| 392 | + } else { |
|
| 393 | + template_xml_below(); |
|
| 394 | + } |
|
| 375 | 395 | } |
| 376 | 396 | |
| 377 | 397 | |
@@ -383,15 +403,19 @@ discard block |
||
| 383 | 403 | $seconds = intval($active % 60); |
| 384 | 404 | |
| 385 | 405 | $totalTime = ''; |
| 386 | - if ($hours > 0) |
|
| 387 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 388 | - if ($minutes > 0) |
|
| 389 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 390 | - if ($seconds > 0) |
|
| 391 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 406 | + if ($hours > 0) { |
|
| 407 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 408 | + } |
|
| 409 | + if ($minutes > 0) { |
|
| 410 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 411 | + } |
|
| 412 | + if ($seconds > 0) { |
|
| 413 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 414 | + } |
|
| 392 | 415 | |
| 393 | - if (!empty($totalTime)) |
|
| 394 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 416 | + if (!empty($totalTime)) { |
|
| 417 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 418 | + } |
|
| 395 | 419 | } |
| 396 | 420 | |
| 397 | 421 | // Bang - gone! |
@@ -404,8 +428,9 @@ discard block |
||
| 404 | 428 | global $upgradeurl, $upcontext, $command_line; |
| 405 | 429 | |
| 406 | 430 | // Command line users can't be redirected. |
| 407 | - if ($command_line) |
|
| 408 | - upgradeExit(true); |
|
| 431 | + if ($command_line) { |
|
| 432 | + upgradeExit(true); |
|
| 433 | + } |
|
| 409 | 434 | |
| 410 | 435 | // Are we providing the core info? |
| 411 | 436 | if ($addForm) |
@@ -428,19 +453,22 @@ discard block |
||
| 428 | 453 | global $modSettings, $sourcedir, $smcFunc; |
| 429 | 454 | |
| 430 | 455 | // Do the non-SSI stuff... |
| 431 | - if (function_exists('set_magic_quotes_runtime')) |
|
| 432 | - @set_magic_quotes_runtime(0); |
|
| 456 | + if (function_exists('set_magic_quotes_runtime')) { |
|
| 457 | + @set_magic_quotes_runtime(0); |
|
| 458 | + } |
|
| 433 | 459 | |
| 434 | 460 | error_reporting(E_ALL); |
| 435 | 461 | define('SMF', 1); |
| 436 | 462 | |
| 437 | 463 | // Start the session. |
| 438 | - if (@ini_get('session.save_handler') == 'user') |
|
| 439 | - @ini_set('session.save_handler', 'files'); |
|
| 464 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 465 | + @ini_set('session.save_handler', 'files'); |
|
| 466 | + } |
|
| 440 | 467 | @session_start(); |
| 441 | 468 | |
| 442 | - if (empty($smcFunc)) |
|
| 443 | - $smcFunc = array(); |
|
| 469 | + if (empty($smcFunc)) { |
|
| 470 | + $smcFunc = array(); |
|
| 471 | + } |
|
| 444 | 472 | |
| 445 | 473 | // We need this for authentication and some upgrade code |
| 446 | 474 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -452,32 +480,36 @@ discard block |
||
| 452 | 480 | initialize_inputs(); |
| 453 | 481 | |
| 454 | 482 | // Get the database going! |
| 455 | - if (empty($db_type) || $db_type == 'mysqli') |
|
| 456 | - $db_type = 'mysql'; |
|
| 483 | + if (empty($db_type) || $db_type == 'mysqli') { |
|
| 484 | + $db_type = 'mysql'; |
|
| 485 | + } |
|
| 457 | 486 | |
| 458 | 487 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
| 459 | 488 | { |
| 460 | 489 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 461 | 490 | |
| 462 | 491 | // Make the connection... |
| 463 | - if (empty($db_connection)) |
|
| 464 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 465 | - else |
|
| 466 | - // If we've returned here, ping/reconnect to be safe |
|
| 492 | + if (empty($db_connection)) { |
|
| 493 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 494 | + } else { |
|
| 495 | + // If we've returned here, ping/reconnect to be safe |
|
| 467 | 496 | $smcFunc['db_ping']($db_connection); |
| 497 | + } |
|
| 468 | 498 | |
| 469 | 499 | // Oh dear god!! |
| 470 | - if ($db_connection === null) |
|
| 471 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 500 | + if ($db_connection === null) { |
|
| 501 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 502 | + } |
|
| 472 | 503 | |
| 473 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 474 | - $smcFunc['db_query']('', ' |
|
| 504 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 505 | + $smcFunc['db_query']('', ' |
|
| 475 | 506 | SET NAMES {string:db_character_set}', |
| 476 | 507 | array( |
| 477 | 508 | 'db_error_skip' => true, |
| 478 | 509 | 'db_character_set' => $db_character_set, |
| 479 | 510 | ) |
| 480 | 511 | ); |
| 512 | + } |
|
| 481 | 513 | |
| 482 | 514 | // Load the modSettings data... |
| 483 | 515 | $request = $smcFunc['db_query']('', ' |
@@ -488,11 +520,11 @@ discard block |
||
| 488 | 520 | ) |
| 489 | 521 | ); |
| 490 | 522 | $modSettings = array(); |
| 491 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 492 | - $modSettings[$row['variable']] = $row['value']; |
|
| 523 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 524 | + $modSettings[$row['variable']] = $row['value']; |
|
| 525 | + } |
|
| 493 | 526 | $smcFunc['db_free_result']($request); |
| 494 | - } |
|
| 495 | - else |
|
| 527 | + } else |
|
| 496 | 528 | { |
| 497 | 529 | 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.'); |
| 498 | 530 | } |
@@ -506,9 +538,10 @@ discard block |
||
| 506 | 538 | cleanRequest(); |
| 507 | 539 | } |
| 508 | 540 | |
| 509 | - if (!isset($_GET['substep'])) |
|
| 510 | - $_GET['substep'] = 0; |
|
| 511 | -} |
|
| 541 | + if (!isset($_GET['substep'])) { |
|
| 542 | + $_GET['substep'] = 0; |
|
| 543 | + } |
|
| 544 | + } |
|
| 512 | 545 | |
| 513 | 546 | function initialize_inputs() |
| 514 | 547 | { |
@@ -538,8 +571,9 @@ discard block |
||
| 538 | 571 | $dh = opendir(dirname(__FILE__)); |
| 539 | 572 | while ($file = readdir($dh)) |
| 540 | 573 | { |
| 541 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 542 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 574 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 575 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 576 | + } |
|
| 543 | 577 | } |
| 544 | 578 | closedir($dh); |
| 545 | 579 | |
@@ -568,8 +602,9 @@ discard block |
||
| 568 | 602 | $temp = 'upgrade_php?step'; |
| 569 | 603 | while (strlen($temp) > 4) |
| 570 | 604 | { |
| 571 | - if (isset($_GET[$temp])) |
|
| 572 | - unset($_GET[$temp]); |
|
| 605 | + if (isset($_GET[$temp])) { |
|
| 606 | + unset($_GET[$temp]); |
|
| 607 | + } |
|
| 573 | 608 | $temp = substr($temp, 1); |
| 574 | 609 | } |
| 575 | 610 | |
@@ -596,32 +631,39 @@ discard block |
||
| 596 | 631 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 597 | 632 | |
| 598 | 633 | // 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'); |
|
| 634 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 635 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 636 | + } |
|
| 637 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 638 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 639 | + } |
|
| 640 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 641 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 642 | + } |
|
| 605 | 643 | |
| 606 | 644 | // We don't need "-utf8" files anymore... |
| 607 | 645 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 608 | 646 | |
| 609 | 647 | // This needs to exist! |
| 610 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 611 | - 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>]'); |
|
| 612 | - else |
|
| 613 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 648 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 649 | + 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>]'); |
|
| 650 | + } else { |
|
| 651 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 652 | + } |
|
| 614 | 653 | |
| 615 | - if (!$check) |
|
| 616 | - // 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. |
|
| 654 | + if (!$check) { |
|
| 655 | + // 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. |
|
| 617 | 656 | 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.'); |
| 657 | + } |
|
| 618 | 658 | |
| 619 | 659 | // Do they meet the install requirements? |
| 620 | - if (!php_version_check()) |
|
| 621 | - 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.'); |
|
| 660 | + if (!php_version_check()) { |
|
| 661 | + 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.'); |
|
| 662 | + } |
|
| 622 | 663 | |
| 623 | - if (!db_version_check()) |
|
| 624 | - 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.'); |
|
| 664 | + if (!db_version_check()) { |
|
| 665 | + 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.'); |
|
| 666 | + } |
|
| 625 | 667 | |
| 626 | 668 | // Do some checks to make sure they have proper privileges |
| 627 | 669 | db_extend('packages'); |
@@ -636,14 +678,16 @@ discard block |
||
| 636 | 678 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 637 | 679 | |
| 638 | 680 | // Sorry... we need CREATE, ALTER and DROP |
| 639 | - if (!$create || !$alter || !$drop) |
|
| 640 | - 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.'); |
|
| 681 | + if (!$create || !$alter || !$drop) { |
|
| 682 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 683 | + } |
|
| 641 | 684 | |
| 642 | 685 | // Do a quick version spot check. |
| 643 | 686 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 644 | 687 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 645 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 646 | - 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.'); |
|
| 688 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 689 | + 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.'); |
|
| 690 | + } |
|
| 647 | 691 | |
| 648 | 692 | // What absolutely needs to be writable? |
| 649 | 693 | $writable_files = array( |
@@ -665,12 +709,13 @@ discard block |
||
| 665 | 709 | quickFileWritable($custom_av_dir); |
| 666 | 710 | |
| 667 | 711 | // Are we good now? |
| 668 | - if (!is_writable($custom_av_dir)) |
|
| 669 | - 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)); |
|
| 670 | - elseif ($need_settings_update) |
|
| 712 | + if (!is_writable($custom_av_dir)) { |
|
| 713 | + 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)); |
|
| 714 | + } elseif ($need_settings_update) |
|
| 671 | 715 | { |
| 672 | - if (!function_exists('cache_put_data')) |
|
| 673 | - require_once($sourcedir . '/Load.php'); |
|
| 716 | + if (!function_exists('cache_put_data')) { |
|
| 717 | + require_once($sourcedir . '/Load.php'); |
|
| 718 | + } |
|
| 674 | 719 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 675 | 720 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 676 | 721 | } |
@@ -679,28 +724,33 @@ discard block |
||
| 679 | 724 | |
| 680 | 725 | // Check the cache directory. |
| 681 | 726 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 682 | - if (!file_exists($cachedir_temp)) |
|
| 683 | - @mkdir($cachedir_temp); |
|
| 684 | - if (!file_exists($cachedir_temp)) |
|
| 685 | - 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.'); |
|
| 686 | - |
|
| 687 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 688 | - 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>.'); |
|
| 689 | - elseif (!isset($_GET['skiplang'])) |
|
| 727 | + if (!file_exists($cachedir_temp)) { |
|
| 728 | + @mkdir($cachedir_temp); |
|
| 729 | + } |
|
| 730 | + if (!file_exists($cachedir_temp)) { |
|
| 731 | + 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.'); |
|
| 732 | + } |
|
| 733 | + |
|
| 734 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 735 | + 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>.'); |
|
| 736 | + } elseif (!isset($_GET['skiplang'])) |
|
| 690 | 737 | { |
| 691 | 738 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 692 | 739 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 693 | 740 | |
| 694 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 695 | - 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>]'); |
|
| 741 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 742 | + 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>]'); |
|
| 743 | + } |
|
| 696 | 744 | } |
| 697 | 745 | |
| 698 | - if (!makeFilesWritable($writable_files)) |
|
| 699 | - return false; |
|
| 746 | + if (!makeFilesWritable($writable_files)) { |
|
| 747 | + return false; |
|
| 748 | + } |
|
| 700 | 749 | |
| 701 | 750 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 702 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 703 | - 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.'); |
|
| 751 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 752 | + 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.'); |
|
| 753 | + } |
|
| 704 | 754 | |
| 705 | 755 | // Upgrade the agreement. |
| 706 | 756 | elseif (isset($modSettings['agreement'])) |
@@ -711,8 +761,8 @@ discard block |
||
| 711 | 761 | } |
| 712 | 762 | |
| 713 | 763 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 714 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 715 | - $upcontext['warning'] = ' |
|
| 764 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 765 | + $upcontext['warning'] = ' |
|
| 716 | 766 | 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> |
| 717 | 767 | <ul> |
| 718 | 768 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -720,10 +770,12 @@ discard block |
||
| 720 | 770 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 721 | 771 | </ul> |
| 722 | 772 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 773 | + } |
|
| 723 | 774 | |
| 724 | 775 | // Either we're logged in or we're going to present the login. |
| 725 | - if (checkLogin()) |
|
| 726 | - return true; |
|
| 776 | + if (checkLogin()) { |
|
| 777 | + return true; |
|
| 778 | + } |
|
| 727 | 779 | |
| 728 | 780 | $upcontext += createToken('login'); |
| 729 | 781 | |
@@ -737,15 +789,17 @@ discard block |
||
| 737 | 789 | global $smcFunc, $db_type, $support_js; |
| 738 | 790 | |
| 739 | 791 | // Don't bother if the security is disabled. |
| 740 | - if ($disable_security) |
|
| 741 | - return true; |
|
| 792 | + if ($disable_security) { |
|
| 793 | + return true; |
|
| 794 | + } |
|
| 742 | 795 | |
| 743 | 796 | // Are we trying to login? |
| 744 | 797 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 745 | 798 | { |
| 746 | 799 | // If we've disabled security pick a suitable name! |
| 747 | - if (empty($_POST['user'])) |
|
| 748 | - $_POST['user'] = 'Administrator'; |
|
| 800 | + if (empty($_POST['user'])) { |
|
| 801 | + $_POST['user'] = 'Administrator'; |
|
| 802 | + } |
|
| 749 | 803 | |
| 750 | 804 | // Before 2.0 these column names were different! |
| 751 | 805 | $oldDB = false; |
@@ -760,16 +814,17 @@ discard block |
||
| 760 | 814 | 'db_error_skip' => true, |
| 761 | 815 | ) |
| 762 | 816 | ); |
| 763 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 764 | - $oldDB = true; |
|
| 817 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 818 | + $oldDB = true; |
|
| 819 | + } |
|
| 765 | 820 | $smcFunc['db_free_result']($request); |
| 766 | 821 | } |
| 767 | 822 | |
| 768 | 823 | // Get what we believe to be their details. |
| 769 | 824 | if (!$disable_security) |
| 770 | 825 | { |
| 771 | - if ($oldDB) |
|
| 772 | - $request = $smcFunc['db_query']('', ' |
|
| 826 | + if ($oldDB) { |
|
| 827 | + $request = $smcFunc['db_query']('', ' |
|
| 773 | 828 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 774 | 829 | additionalGroups AS additional_groups, lngfile |
| 775 | 830 | FROM {db_prefix}members |
@@ -779,8 +834,8 @@ discard block |
||
| 779 | 834 | 'db_error_skip' => true, |
| 780 | 835 | ) |
| 781 | 836 | ); |
| 782 | - else |
|
| 783 | - $request = $smcFunc['db_query']('', ' |
|
| 837 | + } else { |
|
| 838 | + $request = $smcFunc['db_query']('', ' |
|
| 784 | 839 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 785 | 840 | FROM {db_prefix}members |
| 786 | 841 | WHERE member_name = {string:member_name}', |
@@ -789,6 +844,7 @@ discard block |
||
| 789 | 844 | 'db_error_skip' => true, |
| 790 | 845 | ) |
| 791 | 846 | ); |
| 847 | + } |
|
| 792 | 848 | if ($smcFunc['db_num_rows']($request) != 0) |
| 793 | 849 | { |
| 794 | 850 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -796,16 +852,17 @@ discard block |
||
| 796 | 852 | $groups = explode(',', $addGroups); |
| 797 | 853 | $groups[] = $id_group; |
| 798 | 854 | |
| 799 | - foreach ($groups as $k => $v) |
|
| 800 | - $groups[$k] = (int) $v; |
|
| 855 | + foreach ($groups as $k => $v) { |
|
| 856 | + $groups[$k] = (int) $v; |
|
| 857 | + } |
|
| 801 | 858 | |
| 802 | 859 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 803 | 860 | |
| 804 | 861 | // We don't use "-utf8" anymore... |
| 805 | 862 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 863 | + } else { |
|
| 864 | + $upcontext['username_incorrect'] = true; |
|
| 806 | 865 | } |
| 807 | - else |
|
| 808 | - $upcontext['username_incorrect'] = true; |
|
| 809 | 866 | $smcFunc['db_free_result']($request); |
| 810 | 867 | } |
| 811 | 868 | $upcontext['username'] = $_POST['user']; |
@@ -815,13 +872,14 @@ discard block |
||
| 815 | 872 | { |
| 816 | 873 | $upcontext['upgrade_status']['js'] = 1; |
| 817 | 874 | $support_js = 1; |
| 875 | + } else { |
|
| 876 | + $support_js = 0; |
|
| 818 | 877 | } |
| 819 | - else |
|
| 820 | - $support_js = 0; |
|
| 821 | 878 | |
| 822 | 879 | // Note down the version we are coming from. |
| 823 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 824 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 880 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 881 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 882 | + } |
|
| 825 | 883 | |
| 826 | 884 | // Didn't get anywhere? |
| 827 | 885 | 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'])) |
@@ -855,15 +913,15 @@ discard block |
||
| 855 | 913 | 'db_error_skip' => true, |
| 856 | 914 | ) |
| 857 | 915 | ); |
| 858 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 859 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 916 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 917 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 918 | + } |
|
| 860 | 919 | $smcFunc['db_free_result']($request); |
| 861 | 920 | } |
| 862 | 921 | |
| 863 | 922 | $upcontext['user']['id'] = $id_member; |
| 864 | 923 | $upcontext['user']['name'] = $name; |
| 865 | - } |
|
| 866 | - else |
|
| 924 | + } else |
|
| 867 | 925 | { |
| 868 | 926 | $upcontext['user']['id'] = 1; |
| 869 | 927 | $upcontext['user']['name'] = 'Administrator'; |
@@ -879,11 +937,11 @@ discard block |
||
| 879 | 937 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 880 | 938 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 881 | 939 | |
| 882 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 883 | - $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'] . '.'; |
|
| 884 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 885 | - $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'] . '.'; |
|
| 886 | - else |
|
| 940 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 941 | + $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'] . '.'; |
|
| 942 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 943 | + $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'] . '.'; |
|
| 944 | + } else |
|
| 887 | 945 | { |
| 888 | 946 | // Set this as the new language. |
| 889 | 947 | $upcontext['language'] = $user_language; |
@@ -927,8 +985,9 @@ discard block |
||
| 927 | 985 | unset($member_columns); |
| 928 | 986 | |
| 929 | 987 | // If we've not submitted then we're done. |
| 930 | - if (empty($_POST['upcont'])) |
|
| 931 | - return false; |
|
| 988 | + if (empty($_POST['upcont'])) { |
|
| 989 | + return false; |
|
| 990 | + } |
|
| 932 | 991 | |
| 933 | 992 | // Firstly, if they're enabling SM stat collection just do it. |
| 934 | 993 | if (!empty($_POST['stats']) && (substr($boardurl, 0, 16) != 'http://localhost' || substr($boardurl, 0, 16) != 'https://localhost') && empty($modSettings['allow_sm_stats'])) |
@@ -945,26 +1004,28 @@ discard block |
||
| 945 | 1004 | fwrite($fp, $out); |
| 946 | 1005 | |
| 947 | 1006 | $return_data = ''; |
| 948 | - while (!feof($fp)) |
|
| 949 | - $return_data .= fgets($fp, 128); |
|
| 1007 | + while (!feof($fp)) { |
|
| 1008 | + $return_data .= fgets($fp, 128); |
|
| 1009 | + } |
|
| 950 | 1010 | |
| 951 | 1011 | fclose($fp); |
| 952 | 1012 | |
| 953 | 1013 | // Get the unique site ID. |
| 954 | 1014 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 955 | 1015 | |
| 956 | - if (!empty($ID[1])) |
|
| 957 | - $smcFunc['db_insert']('replace', |
|
| 1016 | + if (!empty($ID[1])) { |
|
| 1017 | + $smcFunc['db_insert']('replace', |
|
| 958 | 1018 | $db_prefix . 'settings', |
| 959 | 1019 | array('variable' => 'string', 'value' => 'string'), |
| 960 | 1020 | array('allow_sm_stats', $ID[1]), |
| 961 | 1021 | array('variable') |
| 962 | 1022 | ); |
| 1023 | + } |
|
| 963 | 1024 | } |
| 964 | 1025 | } |
| 965 | 1026 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 966 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 967 | - $smcFunc['db_query']('', ' |
|
| 1027 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1028 | + $smcFunc['db_query']('', ' |
|
| 968 | 1029 | DELETE FROM {db_prefix}settings |
| 969 | 1030 | WHERE variable = {string:allow_sm_stats}', |
| 970 | 1031 | array( |
@@ -972,6 +1033,7 @@ discard block |
||
| 972 | 1033 | 'db_error_skip' => true, |
| 973 | 1034 | ) |
| 974 | 1035 | ); |
| 1036 | + } |
|
| 975 | 1037 | |
| 976 | 1038 | // Deleting old karma stuff? |
| 977 | 1039 | if (!empty($_POST['delete_karma'])) |
@@ -986,20 +1048,22 @@ discard block |
||
| 986 | 1048 | ); |
| 987 | 1049 | |
| 988 | 1050 | // Cleaning up old karma member settings. |
| 989 | - if ($upcontext['karma_installed']['good']) |
|
| 990 | - $smcFunc['db_query']('', ' |
|
| 1051 | + if ($upcontext['karma_installed']['good']) { |
|
| 1052 | + $smcFunc['db_query']('', ' |
|
| 991 | 1053 | ALTER TABLE {db_prefix}members |
| 992 | 1054 | DROP karma_good', |
| 993 | 1055 | array() |
| 994 | 1056 | ); |
| 1057 | + } |
|
| 995 | 1058 | |
| 996 | 1059 | // Does karma bad was enable? |
| 997 | - if ($upcontext['karma_installed']['bad']) |
|
| 998 | - $smcFunc['db_query']('', ' |
|
| 1060 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1061 | + $smcFunc['db_query']('', ' |
|
| 999 | 1062 | ALTER TABLE {db_prefix}members |
| 1000 | 1063 | DROP karma_bad', |
| 1001 | 1064 | array() |
| 1002 | 1065 | ); |
| 1066 | + } |
|
| 1003 | 1067 | |
| 1004 | 1068 | // Cleaning up old karma permissions. |
| 1005 | 1069 | $smcFunc['db_query']('', ' |
@@ -1012,26 +1076,29 @@ discard block |
||
| 1012 | 1076 | } |
| 1013 | 1077 | |
| 1014 | 1078 | // Emptying the error log? |
| 1015 | - if (!empty($_POST['empty_error'])) |
|
| 1016 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1079 | + if (!empty($_POST['empty_error'])) { |
|
| 1080 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1017 | 1081 | TRUNCATE {db_prefix}log_errors', |
| 1018 | 1082 | array( |
| 1019 | 1083 | ) |
| 1020 | 1084 | ); |
| 1085 | + } |
|
| 1021 | 1086 | |
| 1022 | 1087 | $changes = array(); |
| 1023 | 1088 | |
| 1024 | 1089 | // Add proxy settings. |
| 1025 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1026 | - $changes += array( |
|
| 1090 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1091 | + $changes += array( |
|
| 1027 | 1092 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1028 | 1093 | 'image_proxy_maxsize' => 5190, |
| 1029 | 1094 | 'image_proxy_enabled' => 0, |
| 1030 | 1095 | ); |
| 1096 | + } |
|
| 1031 | 1097 | |
| 1032 | 1098 | // If we're overriding the language follow it through. |
| 1033 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1034 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1099 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1100 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1101 | + } |
|
| 1035 | 1102 | |
| 1036 | 1103 | if (!empty($_POST['maint'])) |
| 1037 | 1104 | { |
@@ -1043,30 +1110,34 @@ discard block |
||
| 1043 | 1110 | { |
| 1044 | 1111 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1045 | 1112 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1046 | - } |
|
| 1047 | - else |
|
| 1113 | + } else |
|
| 1048 | 1114 | { |
| 1049 | 1115 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1050 | 1116 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1051 | 1117 | } |
| 1052 | 1118 | } |
| 1053 | 1119 | |
| 1054 | - if ($command_line) |
|
| 1055 | - echo ' * Updating Settings.php...'; |
|
| 1120 | + if ($command_line) { |
|
| 1121 | + echo ' * Updating Settings.php...'; |
|
| 1122 | + } |
|
| 1056 | 1123 | |
| 1057 | 1124 | // Fix some old paths. |
| 1058 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1059 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1125 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1126 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1127 | + } |
|
| 1060 | 1128 | |
| 1061 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1062 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1129 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1130 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1131 | + } |
|
| 1063 | 1132 | |
| 1064 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1065 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1133 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1134 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1135 | + } |
|
| 1066 | 1136 | |
| 1067 | 1137 | // Not had the database type added before? |
| 1068 | - if (empty($db_type)) |
|
| 1069 | - $changes['db_type'] = 'mysql'; |
|
| 1138 | + if (empty($db_type)) { |
|
| 1139 | + $changes['db_type'] = 'mysql'; |
|
| 1140 | + } |
|
| 1070 | 1141 | |
| 1071 | 1142 | // If they have a "host:port" setup for the host, split that into separate values |
| 1072 | 1143 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1077,32 +1148,36 @@ discard block |
||
| 1077 | 1148 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1078 | 1149 | |
| 1079 | 1150 | // Only set this if we're not using the default port |
| 1080 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1081 | - $changes['db_port'] = (int) $db_port; |
|
| 1082 | - } |
|
| 1083 | - elseif (!empty($db_port)) |
|
| 1151 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1152 | + $changes['db_port'] = (int) $db_port; |
|
| 1153 | + } |
|
| 1154 | + } elseif (!empty($db_port)) |
|
| 1084 | 1155 | { |
| 1085 | 1156 | // If db_port is set and is the same as the default, set it to '' |
| 1086 | 1157 | if ($db_type == 'mysql') |
| 1087 | 1158 | { |
| 1088 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1089 | - $changes['db_port'] = '\'\''; |
|
| 1090 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1091 | - $changes['db_port'] = '\'\''; |
|
| 1159 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1160 | + $changes['db_port'] = '\'\''; |
|
| 1161 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1162 | + $changes['db_port'] = '\'\''; |
|
| 1163 | + } |
|
| 1092 | 1164 | } |
| 1093 | 1165 | } |
| 1094 | 1166 | |
| 1095 | 1167 | // Maybe we haven't had this option yet? |
| 1096 | - if (empty($packagesdir)) |
|
| 1097 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1168 | + if (empty($packagesdir)) { |
|
| 1169 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1170 | + } |
|
| 1098 | 1171 | |
| 1099 | 1172 | // Add support for $tasksdir var. |
| 1100 | - if (empty($tasksdir)) |
|
| 1101 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1173 | + if (empty($tasksdir)) { |
|
| 1174 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1175 | + } |
|
| 1102 | 1176 | |
| 1103 | 1177 | // Make sure we fix the language as well. |
| 1104 | - if (stristr($language, '-utf8')) |
|
| 1105 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1178 | + if (stristr($language, '-utf8')) { |
|
| 1179 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1180 | + } |
|
| 1106 | 1181 | |
| 1107 | 1182 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1108 | 1183 | |
@@ -1110,8 +1185,9 @@ discard block |
||
| 1110 | 1185 | require_once($sourcedir . '/Subs-Admin.php'); |
| 1111 | 1186 | updateSettingsFile($changes); |
| 1112 | 1187 | |
| 1113 | - if ($command_line) |
|
| 1114 | - echo ' Successful.' . "\n"; |
|
| 1188 | + if ($command_line) { |
|
| 1189 | + echo ' Successful.' . "\n"; |
|
| 1190 | + } |
|
| 1115 | 1191 | |
| 1116 | 1192 | // Are we doing debug? |
| 1117 | 1193 | if (isset($_POST['debug'])) |
@@ -1121,8 +1197,9 @@ discard block |
||
| 1121 | 1197 | } |
| 1122 | 1198 | |
| 1123 | 1199 | // If we're not backing up then jump one. |
| 1124 | - if (empty($_POST['backup'])) |
|
| 1125 | - $upcontext['current_step']++; |
|
| 1200 | + if (empty($_POST['backup'])) { |
|
| 1201 | + $upcontext['current_step']++; |
|
| 1202 | + } |
|
| 1126 | 1203 | |
| 1127 | 1204 | // If we've got here then let's proceed to the next step! |
| 1128 | 1205 | return true; |
@@ -1137,8 +1214,9 @@ discard block |
||
| 1137 | 1214 | $upcontext['page_title'] = 'Backup Database'; |
| 1138 | 1215 | |
| 1139 | 1216 | // Done it already - js wise? |
| 1140 | - if (!empty($_POST['backup_done'])) |
|
| 1141 | - return true; |
|
| 1217 | + if (!empty($_POST['backup_done'])) { |
|
| 1218 | + return true; |
|
| 1219 | + } |
|
| 1142 | 1220 | |
| 1143 | 1221 | // Some useful stuff here. |
| 1144 | 1222 | db_extend(); |
@@ -1152,9 +1230,10 @@ discard block |
||
| 1152 | 1230 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1153 | 1231 | |
| 1154 | 1232 | $table_names = array(); |
| 1155 | - foreach ($tables as $table) |
|
| 1156 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1233 | + foreach ($tables as $table) { |
|
| 1234 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1157 | 1235 | $table_names[] = $table; |
| 1236 | + } |
|
| 1158 | 1237 | |
| 1159 | 1238 | $upcontext['table_count'] = count($table_names); |
| 1160 | 1239 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1164,12 +1243,14 @@ discard block |
||
| 1164 | 1243 | $file_steps = $upcontext['table_count']; |
| 1165 | 1244 | |
| 1166 | 1245 | // What ones have we already done? |
| 1167 | - foreach ($table_names as $id => $table) |
|
| 1168 | - if ($id < $_GET['substep']) |
|
| 1246 | + foreach ($table_names as $id => $table) { |
|
| 1247 | + if ($id < $_GET['substep']) |
|
| 1169 | 1248 | $upcontext['previous_tables'][] = $table; |
| 1249 | + } |
|
| 1170 | 1250 | |
| 1171 | - if ($command_line) |
|
| 1172 | - echo 'Backing Up Tables.'; |
|
| 1251 | + if ($command_line) { |
|
| 1252 | + echo 'Backing Up Tables.'; |
|
| 1253 | + } |
|
| 1173 | 1254 | |
| 1174 | 1255 | // If we don't support javascript we backup here. |
| 1175 | 1256 | if (!$support_js || isset($_GET['xml'])) |
@@ -1188,8 +1269,9 @@ discard block |
||
| 1188 | 1269 | backupTable($table_names[$substep]); |
| 1189 | 1270 | |
| 1190 | 1271 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1191 | - if (isset($_GET['xml'])) |
|
| 1192 | - return upgradeExit(); |
|
| 1272 | + if (isset($_GET['xml'])) { |
|
| 1273 | + return upgradeExit(); |
|
| 1274 | + } |
|
| 1193 | 1275 | } |
| 1194 | 1276 | |
| 1195 | 1277 | if ($command_line) |
@@ -1222,9 +1304,10 @@ discard block |
||
| 1222 | 1304 | |
| 1223 | 1305 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1224 | 1306 | |
| 1225 | - if ($command_line) |
|
| 1226 | - echo ' done.'; |
|
| 1227 | -} |
|
| 1307 | + if ($command_line) { |
|
| 1308 | + echo ' done.'; |
|
| 1309 | + } |
|
| 1310 | + } |
|
| 1228 | 1311 | |
| 1229 | 1312 | // Step 2: Everything. |
| 1230 | 1313 | function DatabaseChanges() |
@@ -1233,8 +1316,9 @@ discard block |
||
| 1233 | 1316 | global $upcontext, $support_js, $db_type; |
| 1234 | 1317 | |
| 1235 | 1318 | // Have we just completed this? |
| 1236 | - if (!empty($_POST['database_done'])) |
|
| 1237 | - return true; |
|
| 1319 | + if (!empty($_POST['database_done'])) { |
|
| 1320 | + return true; |
|
| 1321 | + } |
|
| 1238 | 1322 | |
| 1239 | 1323 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1240 | 1324 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1249,15 +1333,16 @@ discard block |
||
| 1249 | 1333 | ); |
| 1250 | 1334 | |
| 1251 | 1335 | // How many files are there in total? |
| 1252 | - if (isset($_GET['filecount'])) |
|
| 1253 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1254 | - else |
|
| 1336 | + if (isset($_GET['filecount'])) { |
|
| 1337 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1338 | + } else |
|
| 1255 | 1339 | { |
| 1256 | 1340 | $upcontext['file_count'] = 0; |
| 1257 | 1341 | foreach ($files as $file) |
| 1258 | 1342 | { |
| 1259 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1260 | - $upcontext['file_count']++; |
|
| 1343 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1344 | + $upcontext['file_count']++; |
|
| 1345 | + } |
|
| 1261 | 1346 | } |
| 1262 | 1347 | } |
| 1263 | 1348 | |
@@ -1267,9 +1352,9 @@ discard block |
||
| 1267 | 1352 | $upcontext['cur_file_num'] = 0; |
| 1268 | 1353 | foreach ($files as $file) |
| 1269 | 1354 | { |
| 1270 | - if ($did_not_do) |
|
| 1271 | - $did_not_do--; |
|
| 1272 | - else |
|
| 1355 | + if ($did_not_do) { |
|
| 1356 | + $did_not_do--; |
|
| 1357 | + } else |
|
| 1273 | 1358 | { |
| 1274 | 1359 | $upcontext['cur_file_num']++; |
| 1275 | 1360 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1296,12 +1381,13 @@ discard block |
||
| 1296 | 1381 | // Flag to move on to the next. |
| 1297 | 1382 | $upcontext['completed_step'] = true; |
| 1298 | 1383 | // Did we complete the whole file? |
| 1299 | - if ($nextFile) |
|
| 1300 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1384 | + if ($nextFile) { |
|
| 1385 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1386 | + } |
|
| 1301 | 1387 | return upgradeExit(); |
| 1388 | + } elseif ($support_js) { |
|
| 1389 | + break; |
|
| 1302 | 1390 | } |
| 1303 | - elseif ($support_js) |
|
| 1304 | - break; |
|
| 1305 | 1391 | } |
| 1306 | 1392 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1307 | 1393 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1326,8 +1412,9 @@ discard block |
||
| 1326 | 1412 | global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1327 | 1413 | |
| 1328 | 1414 | // Now it's nice to have some of the basic SMF source files. |
| 1329 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1330 | - redirectLocation('&ssi=1'); |
|
| 1415 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1416 | + redirectLocation('&ssi=1'); |
|
| 1417 | + } |
|
| 1331 | 1418 | |
| 1332 | 1419 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1333 | 1420 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1343,14 +1430,16 @@ discard block |
||
| 1343 | 1430 | // Are we in maintenance mode? |
| 1344 | 1431 | if (isset($upcontext['user']['main'])) |
| 1345 | 1432 | { |
| 1346 | - if ($command_line) |
|
| 1347 | - echo ' * '; |
|
| 1433 | + if ($command_line) { |
|
| 1434 | + echo ' * '; |
|
| 1435 | + } |
|
| 1348 | 1436 | $upcontext['removed_maintenance'] = true; |
| 1349 | 1437 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1350 | 1438 | } |
| 1351 | 1439 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1352 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1353 | - $changes['maintenance'] = 1; |
|
| 1440 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1441 | + $changes['maintenance'] = 1; |
|
| 1442 | + } |
|
| 1354 | 1443 | |
| 1355 | 1444 | // Wipe this out... |
| 1356 | 1445 | $upcontext['user'] = array(); |
@@ -1365,9 +1454,9 @@ discard block |
||
| 1365 | 1454 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1366 | 1455 | |
| 1367 | 1456 | // Now is the perfect time to fetch the SM files. |
| 1368 | - if ($command_line) |
|
| 1369 | - cli_scheduled_fetchSMfiles(); |
|
| 1370 | - else |
|
| 1457 | + if ($command_line) { |
|
| 1458 | + cli_scheduled_fetchSMfiles(); |
|
| 1459 | + } else |
|
| 1371 | 1460 | { |
| 1372 | 1461 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1373 | 1462 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1375,8 +1464,9 @@ discard block |
||
| 1375 | 1464 | } |
| 1376 | 1465 | |
| 1377 | 1466 | // Log what we've done. |
| 1378 | - if (empty($user_info['id'])) |
|
| 1379 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1467 | + if (empty($user_info['id'])) { |
|
| 1468 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1469 | + } |
|
| 1380 | 1470 | |
| 1381 | 1471 | // Log the action manually, so CLI still works. |
| 1382 | 1472 | $smcFunc['db_insert']('', |
@@ -1395,8 +1485,9 @@ discard block |
||
| 1395 | 1485 | |
| 1396 | 1486 | // Save the current database version. |
| 1397 | 1487 | $server_version = $smcFunc['db_server_info'](); |
| 1398 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1399 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1488 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1489 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1490 | + } |
|
| 1400 | 1491 | |
| 1401 | 1492 | if ($command_line) |
| 1402 | 1493 | { |
@@ -1408,8 +1499,9 @@ discard block |
||
| 1408 | 1499 | |
| 1409 | 1500 | // Make sure it says we're done. |
| 1410 | 1501 | $upcontext['overall_percent'] = 100; |
| 1411 | - if (isset($upcontext['step_progress'])) |
|
| 1412 | - unset($upcontext['step_progress']); |
|
| 1502 | + if (isset($upcontext['step_progress'])) { |
|
| 1503 | + unset($upcontext['step_progress']); |
|
| 1504 | + } |
|
| 1413 | 1505 | |
| 1414 | 1506 | $_GET['substep'] = 0; |
| 1415 | 1507 | return false; |
@@ -1420,8 +1512,9 @@ discard block |
||
| 1420 | 1512 | { |
| 1421 | 1513 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1422 | 1514 | |
| 1423 | - if (empty($modSettings['time_format'])) |
|
| 1424 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1515 | + if (empty($modSettings['time_format'])) { |
|
| 1516 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1517 | + } |
|
| 1425 | 1518 | |
| 1426 | 1519 | // What files do we want to get |
| 1427 | 1520 | $request = $smcFunc['db_query']('', ' |
@@ -1455,8 +1548,9 @@ discard block |
||
| 1455 | 1548 | $file_data = fetch_web_data($url); |
| 1456 | 1549 | |
| 1457 | 1550 | // If we got an error - give up - the site might be down. |
| 1458 | - if ($file_data === false) |
|
| 1459 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1551 | + if ($file_data === false) { |
|
| 1552 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1553 | + } |
|
| 1460 | 1554 | |
| 1461 | 1555 | // Save the file to the database. |
| 1462 | 1556 | $smcFunc['db_query']('substring', ' |
@@ -1498,8 +1592,9 @@ discard block |
||
| 1498 | 1592 | $themeData = array(); |
| 1499 | 1593 | foreach ($values as $variable => $value) |
| 1500 | 1594 | { |
| 1501 | - if (!isset($value) || $value === null) |
|
| 1502 | - $value = 0; |
|
| 1595 | + if (!isset($value) || $value === null) { |
|
| 1596 | + $value = 0; |
|
| 1597 | + } |
|
| 1503 | 1598 | |
| 1504 | 1599 | $themeData[] = array(0, 1, $variable, $value); |
| 1505 | 1600 | } |
@@ -1528,8 +1623,9 @@ discard block |
||
| 1528 | 1623 | |
| 1529 | 1624 | foreach ($values as $variable => $value) |
| 1530 | 1625 | { |
| 1531 | - if (empty($modSettings[$value[0]])) |
|
| 1532 | - continue; |
|
| 1626 | + if (empty($modSettings[$value[0]])) { |
|
| 1627 | + continue; |
|
| 1628 | + } |
|
| 1533 | 1629 | |
| 1534 | 1630 | $smcFunc['db_query']('', ' |
| 1535 | 1631 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1615,19 +1711,21 @@ discard block |
||
| 1615 | 1711 | set_error_handler( |
| 1616 | 1712 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1617 | 1713 | { |
| 1618 | - if ($support_js) |
|
| 1619 | - return true; |
|
| 1620 | - else |
|
| 1621 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1714 | + if ($support_js) { |
|
| 1715 | + return true; |
|
| 1716 | + } else { |
|
| 1717 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1718 | + } |
|
| 1622 | 1719 | } |
| 1623 | 1720 | ); |
| 1624 | 1721 | |
| 1625 | 1722 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1626 | 1723 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1627 | - if ($db_type == 'mysql') |
|
| 1628 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1629 | - else |
|
| 1630 | - $db_collation = ''; |
|
| 1724 | + if ($db_type == 'mysql') { |
|
| 1725 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1726 | + } else { |
|
| 1727 | + $db_collation = ''; |
|
| 1728 | + } |
|
| 1631 | 1729 | |
| 1632 | 1730 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1633 | 1731 | |
@@ -1639,8 +1737,9 @@ discard block |
||
| 1639 | 1737 | $last_step = ''; |
| 1640 | 1738 | |
| 1641 | 1739 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1642 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1643 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1740 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1741 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1742 | + } |
|
| 1644 | 1743 | |
| 1645 | 1744 | // Count the total number of steps within this file - for progress. |
| 1646 | 1745 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1660,15 +1759,18 @@ discard block |
||
| 1660 | 1759 | $do_current = $substep >= $_GET['substep']; |
| 1661 | 1760 | |
| 1662 | 1761 | // Get rid of any comments in the beginning of the line... |
| 1663 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1664 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1762 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1763 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1764 | + } |
|
| 1665 | 1765 | |
| 1666 | 1766 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1667 | - if ($is_debug && !$support_js && $command_line) |
|
| 1668 | - flush(); |
|
| 1767 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1768 | + flush(); |
|
| 1769 | + } |
|
| 1669 | 1770 | |
| 1670 | - if (trim($line) === '') |
|
| 1671 | - continue; |
|
| 1771 | + if (trim($line) === '') { |
|
| 1772 | + continue; |
|
| 1773 | + } |
|
| 1672 | 1774 | |
| 1673 | 1775 | if (trim(substr($line, 0, 3)) === '---') |
| 1674 | 1776 | { |
@@ -1678,8 +1780,9 @@ discard block |
||
| 1678 | 1780 | if (trim($current_data) != '' && $type !== '}') |
| 1679 | 1781 | { |
| 1680 | 1782 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1681 | - if ($command_line) |
|
| 1682 | - echo $upcontext['error_message']; |
|
| 1783 | + if ($command_line) { |
|
| 1784 | + echo $upcontext['error_message']; |
|
| 1785 | + } |
|
| 1683 | 1786 | } |
| 1684 | 1787 | |
| 1685 | 1788 | if ($type == ' ') |
@@ -1697,17 +1800,18 @@ discard block |
||
| 1697 | 1800 | if ($do_current) |
| 1698 | 1801 | { |
| 1699 | 1802 | $upcontext['actioned_items'][] = $last_step; |
| 1700 | - if ($command_line) |
|
| 1701 | - echo ' * '; |
|
| 1803 | + if ($command_line) { |
|
| 1804 | + echo ' * '; |
|
| 1805 | + } |
|
| 1702 | 1806 | } |
| 1703 | - } |
|
| 1704 | - elseif ($type == '#') |
|
| 1807 | + } elseif ($type == '#') |
|
| 1705 | 1808 | { |
| 1706 | 1809 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1707 | 1810 | |
| 1708 | 1811 | $upcontext['current_debug_item_num']++; |
| 1709 | - if (trim($line) != '---#') |
|
| 1710 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1812 | + if (trim($line) != '---#') { |
|
| 1813 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1814 | + } |
|
| 1711 | 1815 | |
| 1712 | 1816 | // Have we already done something? |
| 1713 | 1817 | if (isset($_GET['xml']) && $done_something) |
@@ -1718,34 +1822,36 @@ discard block |
||
| 1718 | 1822 | |
| 1719 | 1823 | if ($do_current) |
| 1720 | 1824 | { |
| 1721 | - if (trim($line) == '---#' && $command_line) |
|
| 1722 | - echo ' done.', $endl; |
|
| 1723 | - elseif ($command_line) |
|
| 1724 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1725 | - elseif (trim($line) != '---#') |
|
| 1825 | + if (trim($line) == '---#' && $command_line) { |
|
| 1826 | + echo ' done.', $endl; |
|
| 1827 | + } elseif ($command_line) { |
|
| 1828 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1829 | + } elseif (trim($line) != '---#') |
|
| 1726 | 1830 | { |
| 1727 | - if ($is_debug) |
|
| 1728 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1831 | + if ($is_debug) { |
|
| 1832 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1833 | + } |
|
| 1729 | 1834 | } |
| 1730 | 1835 | } |
| 1731 | 1836 | |
| 1732 | 1837 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1733 | 1838 | { |
| 1734 | - if ($command_line) |
|
| 1735 | - echo ' * '; |
|
| 1736 | - else |
|
| 1737 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1839 | + if ($command_line) { |
|
| 1840 | + echo ' * '; |
|
| 1841 | + } else { |
|
| 1842 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1843 | + } |
|
| 1738 | 1844 | } |
| 1739 | 1845 | |
| 1740 | 1846 | // Small step - only if we're actually doing stuff. |
| 1741 | - if ($do_current) |
|
| 1742 | - nextSubstep(++$substep); |
|
| 1743 | - else |
|
| 1744 | - $substep++; |
|
| 1745 | - } |
|
| 1746 | - elseif ($type == '{') |
|
| 1747 | - $current_type = 'code'; |
|
| 1748 | - elseif ($type == '}') |
|
| 1847 | + if ($do_current) { |
|
| 1848 | + nextSubstep(++$substep); |
|
| 1849 | + } else { |
|
| 1850 | + $substep++; |
|
| 1851 | + } |
|
| 1852 | + } elseif ($type == '{') { |
|
| 1853 | + $current_type = 'code'; |
|
| 1854 | + } elseif ($type == '}') |
|
| 1749 | 1855 | { |
| 1750 | 1856 | $current_type = 'sql'; |
| 1751 | 1857 | |
@@ -1758,8 +1864,9 @@ discard block |
||
| 1758 | 1864 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1759 | 1865 | { |
| 1760 | 1866 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1761 | - if ($command_line) |
|
| 1762 | - echo $upcontext['error_message']; |
|
| 1867 | + if ($command_line) { |
|
| 1868 | + echo $upcontext['error_message']; |
|
| 1869 | + } |
|
| 1763 | 1870 | } |
| 1764 | 1871 | |
| 1765 | 1872 | // Done with code! |
@@ -1839,8 +1946,9 @@ discard block |
||
| 1839 | 1946 | $db_unbuffered = false; |
| 1840 | 1947 | |
| 1841 | 1948 | // Failure?! |
| 1842 | - if ($result !== false) |
|
| 1843 | - return $result; |
|
| 1949 | + if ($result !== false) { |
|
| 1950 | + return $result; |
|
| 1951 | + } |
|
| 1844 | 1952 | |
| 1845 | 1953 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1846 | 1954 | // If MySQL we do something more clever. |
@@ -1868,54 +1976,61 @@ discard block |
||
| 1868 | 1976 | { |
| 1869 | 1977 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 1870 | 1978 | $result = mysqli_query($db_connection, $string); |
| 1871 | - if ($result !== false) |
|
| 1872 | - return $result; |
|
| 1979 | + if ($result !== false) { |
|
| 1980 | + return $result; |
|
| 1981 | + } |
|
| 1873 | 1982 | } |
| 1874 | - } |
|
| 1875 | - elseif ($mysqli_errno == 2013) |
|
| 1983 | + } elseif ($mysqli_errno == 2013) |
|
| 1876 | 1984 | { |
| 1877 | 1985 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 1878 | 1986 | mysqli_select_db($db_connection, $db_name); |
| 1879 | 1987 | if ($db_connection) |
| 1880 | 1988 | { |
| 1881 | 1989 | $result = mysqli_query($db_connection, $string); |
| 1882 | - if ($result !== false) |
|
| 1883 | - return $result; |
|
| 1990 | + if ($result !== false) { |
|
| 1991 | + return $result; |
|
| 1992 | + } |
|
| 1884 | 1993 | } |
| 1885 | 1994 | } |
| 1886 | 1995 | // Duplicate column name... should be okay ;). |
| 1887 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 1888 | - return false; |
|
| 1996 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 1997 | + return false; |
|
| 1998 | + } |
|
| 1889 | 1999 | // Duplicate insert... make sure it's the proper type of query ;). |
| 1890 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 1891 | - return false; |
|
| 2000 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2001 | + return false; |
|
| 2002 | + } |
|
| 1892 | 2003 | // Creating an index on a non-existent column. |
| 1893 | - elseif ($mysqli_errno == 1072) |
|
| 1894 | - return false; |
|
| 1895 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 1896 | - return false; |
|
| 2004 | + elseif ($mysqli_errno == 1072) { |
|
| 2005 | + return false; |
|
| 2006 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2007 | + return false; |
|
| 2008 | + } |
|
| 1897 | 2009 | } |
| 1898 | 2010 | // If a table already exists don't go potty. |
| 1899 | 2011 | else |
| 1900 | 2012 | { |
| 1901 | 2013 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 1902 | 2014 | { |
| 1903 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 1904 | - return true; |
|
| 1905 | - } |
|
| 1906 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2015 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2016 | + return true; |
|
| 2017 | + } |
|
| 2018 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 1907 | 2019 | { |
| 1908 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 1909 | - return true; |
|
| 2020 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2021 | + return true; |
|
| 2022 | + } |
|
| 1910 | 2023 | } |
| 1911 | 2024 | } |
| 1912 | 2025 | |
| 1913 | 2026 | // Get the query string so we pass everything. |
| 1914 | 2027 | $query_string = ''; |
| 1915 | - foreach ($_GET as $k => $v) |
|
| 1916 | - $query_string .= ';' . $k . '=' . $v; |
|
| 1917 | - if (strlen($query_string) != 0) |
|
| 1918 | - $query_string = '?' . substr($query_string, 1); |
|
| 2028 | + foreach ($_GET as $k => $v) { |
|
| 2029 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2030 | + } |
|
| 2031 | + if (strlen($query_string) != 0) { |
|
| 2032 | + $query_string = '?' . substr($query_string, 1); |
|
| 2033 | + } |
|
| 1919 | 2034 | |
| 1920 | 2035 | if ($command_line) |
| 1921 | 2036 | { |
@@ -1970,16 +2085,18 @@ discard block |
||
| 1970 | 2085 | { |
| 1971 | 2086 | $found |= 1; |
| 1972 | 2087 | // Do some checks on the data if we have it set. |
| 1973 | - if (isset($change['col_type'])) |
|
| 1974 | - $found &= $change['col_type'] === $column['type']; |
|
| 1975 | - if (isset($change['null_allowed'])) |
|
| 1976 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 1977 | - if (isset($change['default'])) |
|
| 1978 | - $found &= $change['default'] === $column['default']; |
|
| 2088 | + if (isset($change['col_type'])) { |
|
| 2089 | + $found &= $change['col_type'] === $column['type']; |
|
| 2090 | + } |
|
| 2091 | + if (isset($change['null_allowed'])) { |
|
| 2092 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2093 | + } |
|
| 2094 | + if (isset($change['default'])) { |
|
| 2095 | + $found &= $change['default'] === $column['default']; |
|
| 2096 | + } |
|
| 1979 | 2097 | } |
| 1980 | 2098 | } |
| 1981 | - } |
|
| 1982 | - elseif ($change['type'] === 'index') |
|
| 2099 | + } elseif ($change['type'] === 'index') |
|
| 1983 | 2100 | { |
| 1984 | 2101 | $request = upgrade_query(' |
| 1985 | 2102 | SHOW INDEX |
@@ -1988,9 +2105,10 @@ discard block |
||
| 1988 | 2105 | { |
| 1989 | 2106 | $cur_index = array(); |
| 1990 | 2107 | |
| 1991 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1992 | - if ($row['Key_name'] === $change['name']) |
|
| 2108 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2109 | + if ($row['Key_name'] === $change['name']) |
|
| 1993 | 2110 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2111 | + } |
|
| 1994 | 2112 | |
| 1995 | 2113 | ksort($cur_index, SORT_NUMERIC); |
| 1996 | 2114 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2000,14 +2118,17 @@ discard block |
||
| 2000 | 2118 | } |
| 2001 | 2119 | |
| 2002 | 2120 | // If we're trying to add and it's added, we're done. |
| 2003 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2004 | - return true; |
|
| 2121 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2122 | + return true; |
|
| 2123 | + } |
|
| 2005 | 2124 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2006 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2007 | - return true; |
|
| 2125 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2126 | + return true; |
|
| 2127 | + } |
|
| 2008 | 2128 | // Otherwise is it just a test? |
| 2009 | - elseif ($is_test) |
|
| 2010 | - return false; |
|
| 2129 | + elseif ($is_test) { |
|
| 2130 | + return false; |
|
| 2131 | + } |
|
| 2011 | 2132 | |
| 2012 | 2133 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2013 | 2134 | $running = false; |
@@ -2018,8 +2139,9 @@ discard block |
||
| 2018 | 2139 | SHOW FULL PROCESSLIST'); |
| 2019 | 2140 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2020 | 2141 | { |
| 2021 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2022 | - $found = true; |
|
| 2142 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2143 | + $found = true; |
|
| 2144 | + } |
|
| 2023 | 2145 | } |
| 2024 | 2146 | |
| 2025 | 2147 | // Can't find it? Then we need to run it fools! |
@@ -2031,8 +2153,9 @@ discard block |
||
| 2031 | 2153 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2032 | 2154 | ' . $change['text'], true) !== false; |
| 2033 | 2155 | |
| 2034 | - if (!$success) |
|
| 2035 | - return false; |
|
| 2156 | + if (!$success) { |
|
| 2157 | + return false; |
|
| 2158 | + } |
|
| 2036 | 2159 | |
| 2037 | 2160 | // Return |
| 2038 | 2161 | $running = true; |
@@ -2074,8 +2197,9 @@ discard block |
||
| 2074 | 2197 | 'db_error_skip' => true, |
| 2075 | 2198 | ) |
| 2076 | 2199 | ); |
| 2077 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2078 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2200 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2201 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2202 | + } |
|
| 2079 | 2203 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2080 | 2204 | $smcFunc['db_free_result']($request); |
| 2081 | 2205 | |
@@ -2097,18 +2221,19 @@ discard block |
||
| 2097 | 2221 | ) |
| 2098 | 2222 | ); |
| 2099 | 2223 | // No results? Just forget it all together. |
| 2100 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2101 | - unset($table_row['Collation']); |
|
| 2102 | - else |
|
| 2103 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2224 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2225 | + unset($table_row['Collation']); |
|
| 2226 | + } else { |
|
| 2227 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2228 | + } |
|
| 2104 | 2229 | $smcFunc['db_free_result']($request); |
| 2105 | 2230 | } |
| 2106 | 2231 | |
| 2107 | 2232 | if ($column_fix) |
| 2108 | 2233 | { |
| 2109 | 2234 | // Make sure there are no NULL's left. |
| 2110 | - if ($null_fix) |
|
| 2111 | - $smcFunc['db_query']('', ' |
|
| 2235 | + if ($null_fix) { |
|
| 2236 | + $smcFunc['db_query']('', ' |
|
| 2112 | 2237 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2113 | 2238 | SET ' . $change['column'] . ' = {string:default} |
| 2114 | 2239 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2117,6 +2242,7 @@ discard block |
||
| 2117 | 2242 | 'db_error_skip' => true, |
| 2118 | 2243 | ) |
| 2119 | 2244 | ); |
| 2245 | + } |
|
| 2120 | 2246 | |
| 2121 | 2247 | // Do the actual alteration. |
| 2122 | 2248 | $smcFunc['db_query']('', ' |
@@ -2145,8 +2271,9 @@ discard block |
||
| 2145 | 2271 | } |
| 2146 | 2272 | |
| 2147 | 2273 | // Not a column we need to check on? |
| 2148 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2149 | - return; |
|
| 2274 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2275 | + return; |
|
| 2276 | + } |
|
| 2150 | 2277 | |
| 2151 | 2278 | // Break it up you (six|seven). |
| 2152 | 2279 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2165,13 +2292,13 @@ discard block |
||
| 2165 | 2292 | 'new_name' => $temp[2], |
| 2166 | 2293 | )); |
| 2167 | 2294 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2168 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2169 | - return; |
|
| 2295 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2296 | + return; |
|
| 2297 | + } |
|
| 2170 | 2298 | |
| 2171 | 2299 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2172 | 2300 | $smcFunc['db_free_result']($request); |
| 2173 | - } |
|
| 2174 | - else |
|
| 2301 | + } else |
|
| 2175 | 2302 | { |
| 2176 | 2303 | // Do this the old fashion, sure method way. |
| 2177 | 2304 | $request = $smcFunc['db_query']('', ' |
@@ -2182,21 +2309,24 @@ discard block |
||
| 2182 | 2309 | )); |
| 2183 | 2310 | // Mayday! |
| 2184 | 2311 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2185 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2186 | - return; |
|
| 2312 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2313 | + return; |
|
| 2314 | + } |
|
| 2187 | 2315 | |
| 2188 | 2316 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2189 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2190 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2317 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2318 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2191 | 2319 | { |
| 2192 | 2320 | $current_type = $row['Type']; |
| 2321 | + } |
|
| 2193 | 2322 | break; |
| 2194 | 2323 | } |
| 2195 | 2324 | } |
| 2196 | 2325 | |
| 2197 | 2326 | // If this doesn't match, the column may of been altered for a reason. |
| 2198 | - if (trim($current_type) != trim($temp[3])) |
|
| 2199 | - $temp[3] = $current_type; |
|
| 2327 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2328 | + $temp[3] = $current_type; |
|
| 2329 | + } |
|
| 2200 | 2330 | |
| 2201 | 2331 | // Piece this back together. |
| 2202 | 2332 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2208,8 +2338,9 @@ discard block |
||
| 2208 | 2338 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2209 | 2339 | global $step_progress, $is_debug, $upcontext; |
| 2210 | 2340 | |
| 2211 | - if ($_GET['substep'] < $substep) |
|
| 2212 | - $_GET['substep'] = $substep; |
|
| 2341 | + if ($_GET['substep'] < $substep) { |
|
| 2342 | + $_GET['substep'] = $substep; |
|
| 2343 | + } |
|
| 2213 | 2344 | |
| 2214 | 2345 | if ($command_line) |
| 2215 | 2346 | { |
@@ -2222,29 +2353,33 @@ discard block |
||
| 2222 | 2353 | } |
| 2223 | 2354 | |
| 2224 | 2355 | @set_time_limit(300); |
| 2225 | - if (function_exists('apache_reset_timeout')) |
|
| 2226 | - @apache_reset_timeout(); |
|
| 2356 | + if (function_exists('apache_reset_timeout')) { |
|
| 2357 | + @apache_reset_timeout(); |
|
| 2358 | + } |
|
| 2227 | 2359 | |
| 2228 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2229 | - return; |
|
| 2360 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2361 | + return; |
|
| 2362 | + } |
|
| 2230 | 2363 | |
| 2231 | 2364 | // Do we have some custom step progress stuff? |
| 2232 | 2365 | if (!empty($step_progress)) |
| 2233 | 2366 | { |
| 2234 | 2367 | $upcontext['substep_progress'] = 0; |
| 2235 | 2368 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2236 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2237 | - $upcontext['substep_progress'] = 99.9; |
|
| 2238 | - else |
|
| 2239 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2369 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2370 | + $upcontext['substep_progress'] = 99.9; |
|
| 2371 | + } else { |
|
| 2372 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2373 | + } |
|
| 2240 | 2374 | |
| 2241 | 2375 | // Make it nicely rounded. |
| 2242 | 2376 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2243 | 2377 | } |
| 2244 | 2378 | |
| 2245 | 2379 | // If this is XML we just exit right away! |
| 2246 | - if (isset($_GET['xml'])) |
|
| 2247 | - return upgradeExit(); |
|
| 2380 | + if (isset($_GET['xml'])) { |
|
| 2381 | + return upgradeExit(); |
|
| 2382 | + } |
|
| 2248 | 2383 | |
| 2249 | 2384 | // We're going to pause after this! |
| 2250 | 2385 | $upcontext['pause'] = true; |
@@ -2252,13 +2387,15 @@ discard block |
||
| 2252 | 2387 | $upcontext['query_string'] = ''; |
| 2253 | 2388 | foreach ($_GET as $k => $v) |
| 2254 | 2389 | { |
| 2255 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2256 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2390 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2391 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2392 | + } |
|
| 2257 | 2393 | } |
| 2258 | 2394 | |
| 2259 | 2395 | // Custom warning? |
| 2260 | - if (!empty($custom_warning)) |
|
| 2261 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2396 | + if (!empty($custom_warning)) { |
|
| 2397 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2398 | + } |
|
| 2262 | 2399 | |
| 2263 | 2400 | upgradeExit(); |
| 2264 | 2401 | } |
@@ -2273,25 +2410,26 @@ discard block |
||
| 2273 | 2410 | ob_implicit_flush(true); |
| 2274 | 2411 | @set_time_limit(600); |
| 2275 | 2412 | |
| 2276 | - if (!isset($_SERVER['argv'])) |
|
| 2277 | - $_SERVER['argv'] = array(); |
|
| 2413 | + if (!isset($_SERVER['argv'])) { |
|
| 2414 | + $_SERVER['argv'] = array(); |
|
| 2415 | + } |
|
| 2278 | 2416 | $_GET['maint'] = 1; |
| 2279 | 2417 | |
| 2280 | 2418 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2281 | 2419 | { |
| 2282 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2283 | - $_GET['lang'] = $match[1]; |
|
| 2284 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2285 | - continue; |
|
| 2286 | - elseif ($arg == '--no-maintenance') |
|
| 2287 | - $_GET['maint'] = 0; |
|
| 2288 | - elseif ($arg == '--debug') |
|
| 2289 | - $is_debug = true; |
|
| 2290 | - elseif ($arg == '--backup') |
|
| 2291 | - $_POST['backup'] = 1; |
|
| 2292 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2293 | - $_GET['conv'] = 1; |
|
| 2294 | - elseif ($i != 0) |
|
| 2420 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2421 | + $_GET['lang'] = $match[1]; |
|
| 2422 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2423 | + continue; |
|
| 2424 | + } elseif ($arg == '--no-maintenance') { |
|
| 2425 | + $_GET['maint'] = 0; |
|
| 2426 | + } elseif ($arg == '--debug') { |
|
| 2427 | + $is_debug = true; |
|
| 2428 | + } elseif ($arg == '--backup') { |
|
| 2429 | + $_POST['backup'] = 1; |
|
| 2430 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2431 | + $_GET['conv'] = 1; |
|
| 2432 | + } elseif ($i != 0) |
|
| 2295 | 2433 | { |
| 2296 | 2434 | echo 'SMF Command-line Upgrader |
| 2297 | 2435 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2305,10 +2443,12 @@ discard block |
||
| 2305 | 2443 | } |
| 2306 | 2444 | } |
| 2307 | 2445 | |
| 2308 | - if (!php_version_check()) |
|
| 2309 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2310 | - if (!db_version_check()) |
|
| 2311 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2446 | + if (!php_version_check()) { |
|
| 2447 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2448 | + } |
|
| 2449 | + if (!db_version_check()) { |
|
| 2450 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2451 | + } |
|
| 2312 | 2452 | |
| 2313 | 2453 | // Do some checks to make sure they have proper privileges |
| 2314 | 2454 | db_extend('packages'); |
@@ -2323,34 +2463,39 @@ discard block |
||
| 2323 | 2463 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2324 | 2464 | |
| 2325 | 2465 | // Sorry... we need CREATE, ALTER and DROP |
| 2326 | - if (!$create || !$alter || !$drop) |
|
| 2327 | - 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); |
|
| 2466 | + if (!$create || !$alter || !$drop) { |
|
| 2467 | + 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); |
|
| 2468 | + } |
|
| 2328 | 2469 | |
| 2329 | 2470 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2330 | 2471 | && @file_exists($sourcedir . '/QueryString.php') |
| 2331 | 2472 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2332 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2333 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2473 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2474 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2475 | + } |
|
| 2334 | 2476 | |
| 2335 | 2477 | // Do a quick version spot check. |
| 2336 | 2478 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2337 | 2479 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2338 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2339 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2480 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2481 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2482 | + } |
|
| 2340 | 2483 | |
| 2341 | 2484 | // Make sure Settings.php is writable. |
| 2342 | 2485 | quickFileWritable($boarddir . '/Settings.php'); |
| 2343 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2344 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2486 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2487 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2488 | + } |
|
| 2345 | 2489 | |
| 2346 | 2490 | // Make sure Settings_bak.php is writable. |
| 2347 | 2491 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2348 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2349 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2492 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2493 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2494 | + } |
|
| 2350 | 2495 | |
| 2351 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2352 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2353 | - elseif (isset($modSettings['agreement'])) |
|
| 2496 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2497 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2498 | + } elseif (isset($modSettings['agreement'])) |
|
| 2354 | 2499 | { |
| 2355 | 2500 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2356 | 2501 | fwrite($fp, $modSettings['agreement']); |
@@ -2360,31 +2505,36 @@ discard block |
||
| 2360 | 2505 | // Make sure Themes is writable. |
| 2361 | 2506 | quickFileWritable($modSettings['theme_dir']); |
| 2362 | 2507 | |
| 2363 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2364 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2508 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2509 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2510 | + } |
|
| 2365 | 2511 | |
| 2366 | 2512 | // Make sure cache directory exists and is writable! |
| 2367 | 2513 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2368 | - if (!file_exists($cachedir_temp)) |
|
| 2369 | - @mkdir($cachedir_temp); |
|
| 2514 | + if (!file_exists($cachedir_temp)) { |
|
| 2515 | + @mkdir($cachedir_temp); |
|
| 2516 | + } |
|
| 2370 | 2517 | |
| 2371 | 2518 | // Make sure the cache temp dir is writable. |
| 2372 | 2519 | quickFileWritable($cachedir_temp); |
| 2373 | 2520 | |
| 2374 | - if (!is_writable($cachedir_temp)) |
|
| 2375 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2521 | + if (!is_writable($cachedir_temp)) { |
|
| 2522 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2523 | + } |
|
| 2376 | 2524 | |
| 2377 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2378 | - print_error('Error: Unable to find language files!', true); |
|
| 2379 | - else |
|
| 2525 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2526 | + print_error('Error: Unable to find language files!', true); |
|
| 2527 | + } else |
|
| 2380 | 2528 | { |
| 2381 | 2529 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2382 | 2530 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2383 | 2531 | |
| 2384 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2385 | - print_error('Error: Language files out of date.', true); |
|
| 2386 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2387 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2532 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2533 | + print_error('Error: Language files out of date.', true); |
|
| 2534 | + } |
|
| 2535 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2536 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2537 | + } |
|
| 2388 | 2538 | |
| 2389 | 2539 | // Otherwise include it! |
| 2390 | 2540 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2403,8 +2553,9 @@ discard block |
||
| 2403 | 2553 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
| 2404 | 2554 | |
| 2405 | 2555 | // Done it already? |
| 2406 | - if (!empty($_POST['utf8_done'])) |
|
| 2407 | - return true; |
|
| 2556 | + if (!empty($_POST['utf8_done'])) { |
|
| 2557 | + return true; |
|
| 2558 | + } |
|
| 2408 | 2559 | |
| 2409 | 2560 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2410 | 2561 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2417,8 +2568,7 @@ discard block |
||
| 2417 | 2568 | ); |
| 2418 | 2569 | |
| 2419 | 2570 | return true; |
| 2420 | - } |
|
| 2421 | - else |
|
| 2571 | + } else |
|
| 2422 | 2572 | { |
| 2423 | 2573 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2424 | 2574 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2462,8 +2612,9 @@ discard block |
||
| 2462 | 2612 | ) |
| 2463 | 2613 | ); |
| 2464 | 2614 | $db_charsets = array(); |
| 2465 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2466 | - $db_charsets[] = $row['Charset']; |
|
| 2615 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2616 | + $db_charsets[] = $row['Charset']; |
|
| 2617 | + } |
|
| 2467 | 2618 | |
| 2468 | 2619 | $smcFunc['db_free_result']($request); |
| 2469 | 2620 | |
@@ -2499,13 +2650,15 @@ discard block |
||
| 2499 | 2650 | // If there's a fulltext index, we need to drop it first... |
| 2500 | 2651 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2501 | 2652 | { |
| 2502 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2503 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2653 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2654 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2504 | 2655 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2656 | + } |
|
| 2505 | 2657 | $smcFunc['db_free_result']($request); |
| 2506 | 2658 | |
| 2507 | - if (isset($upcontext['fulltext_index'])) |
|
| 2508 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2659 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2660 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2661 | + } |
|
| 2509 | 2662 | } |
| 2510 | 2663 | |
| 2511 | 2664 | // Drop it and make a note... |
@@ -2695,8 +2848,9 @@ discard block |
||
| 2695 | 2848 | $replace = '%field%'; |
| 2696 | 2849 | |
| 2697 | 2850 | // Build a huge REPLACE statement... |
| 2698 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2699 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2851 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 2852 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2853 | + } |
|
| 2700 | 2854 | } |
| 2701 | 2855 | |
| 2702 | 2856 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2706,9 +2860,10 @@ discard block |
||
| 2706 | 2860 | $upcontext['table_count'] = count($queryTables); |
| 2707 | 2861 | |
| 2708 | 2862 | // What ones have we already done? |
| 2709 | - foreach ($queryTables as $id => $table) |
|
| 2710 | - if ($id < $_GET['substep']) |
|
| 2863 | + foreach ($queryTables as $id => $table) { |
|
| 2864 | + if ($id < $_GET['substep']) |
|
| 2711 | 2865 | $upcontext['previous_tables'][] = $table; |
| 2866 | + } |
|
| 2712 | 2867 | |
| 2713 | 2868 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2714 | 2869 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2745,8 +2900,9 @@ discard block |
||
| 2745 | 2900 | nextSubstep($substep); |
| 2746 | 2901 | |
| 2747 | 2902 | // Just to make sure it doesn't time out. |
| 2748 | - if (function_exists('apache_reset_timeout')) |
|
| 2749 | - @apache_reset_timeout(); |
|
| 2903 | + if (function_exists('apache_reset_timeout')) { |
|
| 2904 | + @apache_reset_timeout(); |
|
| 2905 | + } |
|
| 2750 | 2906 | |
| 2751 | 2907 | $table_charsets = array(); |
| 2752 | 2908 | |
@@ -2767,8 +2923,9 @@ discard block |
||
| 2767 | 2923 | { |
| 2768 | 2924 | list($charset) = explode('_', $collation); |
| 2769 | 2925 | |
| 2770 | - if (!isset($table_charsets[$charset])) |
|
| 2771 | - $table_charsets[$charset] = array(); |
|
| 2926 | + if (!isset($table_charsets[$charset])) { |
|
| 2927 | + $table_charsets[$charset] = array(); |
|
| 2928 | + } |
|
| 2772 | 2929 | |
| 2773 | 2930 | $table_charsets[$charset][] = $column_info; |
| 2774 | 2931 | } |
@@ -2808,10 +2965,11 @@ discard block |
||
| 2808 | 2965 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2809 | 2966 | { |
| 2810 | 2967 | $update = ''; |
| 2811 | - foreach ($table_charsets as $charset => $columns) |
|
| 2812 | - foreach ($columns as $column) |
|
| 2968 | + foreach ($table_charsets as $charset => $columns) { |
|
| 2969 | + foreach ($columns as $column) |
|
| 2813 | 2970 | $update .= ' |
| 2814 | 2971 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 2972 | + } |
|
| 2815 | 2973 | |
| 2816 | 2974 | $smcFunc['db_query']('', ' |
| 2817 | 2975 | UPDATE {raw:table_name} |
@@ -2836,8 +2994,9 @@ discard block |
||
| 2836 | 2994 | // Now do the actual conversion (if still needed). |
| 2837 | 2995 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2838 | 2996 | { |
| 2839 | - if ($command_line) |
|
| 2840 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 2997 | + if ($command_line) { |
|
| 2998 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 2999 | + } |
|
| 2841 | 3000 | |
| 2842 | 3001 | $smcFunc['db_query']('', ' |
| 2843 | 3002 | ALTER TABLE {raw:table_name} |
@@ -2847,12 +3006,14 @@ discard block |
||
| 2847 | 3006 | ) |
| 2848 | 3007 | ); |
| 2849 | 3008 | |
| 2850 | - if ($command_line) |
|
| 2851 | - echo " done.\n"; |
|
| 3009 | + if ($command_line) { |
|
| 3010 | + echo " done.\n"; |
|
| 3011 | + } |
|
| 2852 | 3012 | } |
| 2853 | 3013 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 2854 | - if (isset($_GET['xml'])) |
|
| 2855 | - return upgradeExit(); |
|
| 3014 | + if (isset($_GET['xml'])) { |
|
| 3015 | + return upgradeExit(); |
|
| 3016 | + } |
|
| 2856 | 3017 | } |
| 2857 | 3018 | |
| 2858 | 3019 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2881,8 +3042,8 @@ discard block |
||
| 2881 | 3042 | ); |
| 2882 | 3043 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2883 | 3044 | { |
| 2884 | - 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) |
|
| 2885 | - $smcFunc['db_query']('', ' |
|
| 3045 | + 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) { |
|
| 3046 | + $smcFunc['db_query']('', ' |
|
| 2886 | 3047 | UPDATE {db_prefix}log_actions |
| 2887 | 3048 | SET extra = {string:extra} |
| 2888 | 3049 | WHERE id_action = {int:current_action}', |
@@ -2891,6 +3052,7 @@ discard block |
||
| 2891 | 3052 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 2892 | 3053 | ) |
| 2893 | 3054 | ); |
| 3055 | + } |
|
| 2894 | 3056 | } |
| 2895 | 3057 | $smcFunc['db_free_result']($request); |
| 2896 | 3058 | |
@@ -2912,15 +3074,17 @@ discard block |
||
| 2912 | 3074 | // First thing's first - did we already do this? |
| 2913 | 3075 | if (!empty($modSettings['json_done'])) |
| 2914 | 3076 | { |
| 2915 | - if ($command_line) |
|
| 2916 | - return DeleteUpgrade(); |
|
| 2917 | - else |
|
| 2918 | - return true; |
|
| 3077 | + if ($command_line) { |
|
| 3078 | + return DeleteUpgrade(); |
|
| 3079 | + } else { |
|
| 3080 | + return true; |
|
| 3081 | + } |
|
| 2919 | 3082 | } |
| 2920 | 3083 | |
| 2921 | 3084 | // Done it already - js wise? |
| 2922 | - if (!empty($_POST['json_done'])) |
|
| 2923 | - return true; |
|
| 3085 | + if (!empty($_POST['json_done'])) { |
|
| 3086 | + return true; |
|
| 3087 | + } |
|
| 2924 | 3088 | |
| 2925 | 3089 | // List of tables affected by this function |
| 2926 | 3090 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2952,12 +3116,14 @@ discard block |
||
| 2952 | 3116 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 2953 | 3117 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 2954 | 3118 | |
| 2955 | - foreach ($keys as $id => $table) |
|
| 2956 | - if ($id < $_GET['substep']) |
|
| 3119 | + foreach ($keys as $id => $table) { |
|
| 3120 | + if ($id < $_GET['substep']) |
|
| 2957 | 3121 | $upcontext['previous_tables'][] = $table; |
| 3122 | + } |
|
| 2958 | 3123 | |
| 2959 | - if ($command_line) |
|
| 2960 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3124 | + if ($command_line) { |
|
| 3125 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3126 | + } |
|
| 2961 | 3127 | |
| 2962 | 3128 | if (!$support_js || isset($_GET['xml'])) |
| 2963 | 3129 | { |
@@ -2997,8 +3163,9 @@ discard block |
||
| 2997 | 3163 | |
| 2998 | 3164 | // Loop through and fix these... |
| 2999 | 3165 | $new_settings = array(); |
| 3000 | - if ($command_line) |
|
| 3001 | - echo "\n" . 'Fixing some settings...'; |
|
| 3166 | + if ($command_line) { |
|
| 3167 | + echo "\n" . 'Fixing some settings...'; |
|
| 3168 | + } |
|
| 3002 | 3169 | |
| 3003 | 3170 | foreach ($serialized_settings as $var) |
| 3004 | 3171 | { |
@@ -3006,22 +3173,24 @@ discard block |
||
| 3006 | 3173 | { |
| 3007 | 3174 | // Attempt to unserialize the setting |
| 3008 | 3175 | $temp = @safe_unserialize($modSettings[$var]); |
| 3009 | - if (!$temp && $command_line) |
|
| 3010 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3011 | - elseif ($temp !== false) |
|
| 3012 | - $new_settings[$var] = json_encode($temp); |
|
| 3176 | + if (!$temp && $command_line) { |
|
| 3177 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3178 | + } elseif ($temp !== false) { |
|
| 3179 | + $new_settings[$var] = json_encode($temp); |
|
| 3180 | + } |
|
| 3013 | 3181 | } |
| 3014 | 3182 | } |
| 3015 | 3183 | |
| 3016 | 3184 | // Update everything at once |
| 3017 | - if (!function_exists('cache_put_data')) |
|
| 3018 | - require_once($sourcedir . '/Load.php'); |
|
| 3185 | + if (!function_exists('cache_put_data')) { |
|
| 3186 | + require_once($sourcedir . '/Load.php'); |
|
| 3187 | + } |
|
| 3019 | 3188 | updateSettings($new_settings, true); |
| 3020 | 3189 | |
| 3021 | - if ($command_line) |
|
| 3022 | - echo ' done.'; |
|
| 3023 | - } |
|
| 3024 | - elseif ($table == 'themes') |
|
| 3190 | + if ($command_line) { |
|
| 3191 | + echo ' done.'; |
|
| 3192 | + } |
|
| 3193 | + } elseif ($table == 'themes') |
|
| 3025 | 3194 | { |
| 3026 | 3195 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3027 | 3196 | $query = $smcFunc['db_query']('', ' |
@@ -3040,10 +3209,11 @@ discard block |
||
| 3040 | 3209 | |
| 3041 | 3210 | if ($command_line) |
| 3042 | 3211 | { |
| 3043 | - if ($temp === false) |
|
| 3044 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3045 | - else |
|
| 3046 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3212 | + if ($temp === false) { |
|
| 3213 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3214 | + } else { |
|
| 3215 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3216 | + } |
|
| 3047 | 3217 | } |
| 3048 | 3218 | |
| 3049 | 3219 | if ($temp !== false) |
@@ -3065,15 +3235,15 @@ discard block |
||
| 3065 | 3235 | ) |
| 3066 | 3236 | ); |
| 3067 | 3237 | |
| 3068 | - if ($command_line) |
|
| 3069 | - echo ' done.'; |
|
| 3238 | + if ($command_line) { |
|
| 3239 | + echo ' done.'; |
|
| 3240 | + } |
|
| 3070 | 3241 | } |
| 3071 | 3242 | } |
| 3072 | 3243 | |
| 3073 | 3244 | $smcFunc['db_free_result']($query); |
| 3074 | 3245 | } |
| 3075 | - } |
|
| 3076 | - else |
|
| 3246 | + } else |
|
| 3077 | 3247 | { |
| 3078 | 3248 | // First item is always the key... |
| 3079 | 3249 | $key = $info[0]; |
@@ -3084,8 +3254,7 @@ discard block |
||
| 3084 | 3254 | { |
| 3085 | 3255 | $col_select = $info[1]; |
| 3086 | 3256 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3087 | - } |
|
| 3088 | - else |
|
| 3257 | + } else |
|
| 3089 | 3258 | { |
| 3090 | 3259 | $col_select = implode(', ', $info); |
| 3091 | 3260 | } |
@@ -3118,8 +3287,7 @@ discard block |
||
| 3118 | 3287 | if ($temp === false && $command_line) |
| 3119 | 3288 | { |
| 3120 | 3289 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3121 | - } |
|
| 3122 | - else |
|
| 3290 | + } else |
|
| 3123 | 3291 | { |
| 3124 | 3292 | $row[$col] = json_encode($temp); |
| 3125 | 3293 | |
@@ -3144,16 +3312,18 @@ discard block |
||
| 3144 | 3312 | } |
| 3145 | 3313 | } |
| 3146 | 3314 | |
| 3147 | - if ($command_line) |
|
| 3148 | - echo ' done.'; |
|
| 3315 | + if ($command_line) { |
|
| 3316 | + echo ' done.'; |
|
| 3317 | + } |
|
| 3149 | 3318 | |
| 3150 | 3319 | // Free up some memory... |
| 3151 | 3320 | $smcFunc['db_free_result']($query); |
| 3152 | 3321 | } |
| 3153 | 3322 | } |
| 3154 | 3323 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3155 | - if (isset($_GET['xml'])) |
|
| 3156 | - return upgradeExit(); |
|
| 3324 | + if (isset($_GET['xml'])) { |
|
| 3325 | + return upgradeExit(); |
|
| 3326 | + } |
|
| 3157 | 3327 | } |
| 3158 | 3328 | |
| 3159 | 3329 | if ($command_line) |
@@ -3168,8 +3338,9 @@ discard block |
||
| 3168 | 3338 | |
| 3169 | 3339 | $_GET['substep'] = 0; |
| 3170 | 3340 | // Make sure we move on! |
| 3171 | - if ($command_line) |
|
| 3172 | - return DeleteUpgrade(); |
|
| 3341 | + if ($command_line) { |
|
| 3342 | + return DeleteUpgrade(); |
|
| 3343 | + } |
|
| 3173 | 3344 | |
| 3174 | 3345 | return true; |
| 3175 | 3346 | } |
@@ -3189,14 +3360,16 @@ discard block |
||
| 3189 | 3360 | global $upcontext, $txt, $settings; |
| 3190 | 3361 | |
| 3191 | 3362 | // Don't call me twice! |
| 3192 | - if (!empty($upcontext['chmod_called'])) |
|
| 3193 | - return; |
|
| 3363 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3364 | + return; |
|
| 3365 | + } |
|
| 3194 | 3366 | |
| 3195 | 3367 | $upcontext['chmod_called'] = true; |
| 3196 | 3368 | |
| 3197 | 3369 | // Nothing? |
| 3198 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3199 | - return; |
|
| 3370 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3371 | + return; |
|
| 3372 | + } |
|
| 3200 | 3373 | |
| 3201 | 3374 | // Was it a problem with Windows? |
| 3202 | 3375 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3228,11 +3401,12 @@ discard block |
||
| 3228 | 3401 | 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\'); |
| 3229 | 3402 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3230 | 3403 | |
| 3231 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3232 | - echo ' |
|
| 3404 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3405 | + echo ' |
|
| 3233 | 3406 | content.write(\'<hr>\n\t\t\t\'); |
| 3234 | 3407 | 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\'); |
| 3235 | 3408 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3409 | + } |
|
| 3236 | 3410 | |
| 3237 | 3411 | echo ' |
| 3238 | 3412 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3240,17 +3414,19 @@ discard block |
||
| 3240 | 3414 | } |
| 3241 | 3415 | </script>'; |
| 3242 | 3416 | |
| 3243 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3244 | - echo ' |
|
| 3417 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3418 | + echo ' |
|
| 3245 | 3419 | <div class="error_message red"> |
| 3246 | 3420 | The following error was encountered when trying to connect:<br><br> |
| 3247 | 3421 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3248 | 3422 | </div> |
| 3249 | 3423 | <br>'; |
| 3424 | + } |
|
| 3250 | 3425 | |
| 3251 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3252 | - echo ' |
|
| 3426 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3427 | + echo ' |
|
| 3253 | 3428 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3429 | + } |
|
| 3254 | 3430 | |
| 3255 | 3431 | echo ' |
| 3256 | 3432 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3285,10 +3461,11 @@ discard block |
||
| 3285 | 3461 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
| 3286 | 3462 | </div>'; |
| 3287 | 3463 | |
| 3288 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3289 | - echo ' |
|
| 3464 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3465 | + echo ' |
|
| 3290 | 3466 | </form>'; |
| 3291 | -} |
|
| 3467 | + } |
|
| 3468 | + } |
|
| 3292 | 3469 | |
| 3293 | 3470 | function template_upgrade_above() |
| 3294 | 3471 | { |
@@ -3348,9 +3525,10 @@ discard block |
||
| 3348 | 3525 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3349 | 3526 | <ul>'; |
| 3350 | 3527 | |
| 3351 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3352 | - echo ' |
|
| 3528 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3529 | + echo ' |
|
| 3353 | 3530 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3531 | + } |
|
| 3354 | 3532 | |
| 3355 | 3533 | echo ' |
| 3356 | 3534 | </ul> |
@@ -3363,8 +3541,8 @@ discard block |
||
| 3363 | 3541 | </div> |
| 3364 | 3542 | </div>'; |
| 3365 | 3543 | |
| 3366 | - if (isset($upcontext['step_progress'])) |
|
| 3367 | - echo ' |
|
| 3544 | + if (isset($upcontext['step_progress'])) { |
|
| 3545 | + echo ' |
|
| 3368 | 3546 | <br> |
| 3369 | 3547 | <br> |
| 3370 | 3548 | <div id="progress_bar_step"> |
@@ -3373,6 +3551,7 @@ discard block |
||
| 3373 | 3551 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3374 | 3552 | </div> |
| 3375 | 3553 | </div>'; |
| 3554 | + } |
|
| 3376 | 3555 | |
| 3377 | 3556 | echo ' |
| 3378 | 3557 | <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> |
@@ -3403,32 +3582,36 @@ discard block |
||
| 3403 | 3582 | { |
| 3404 | 3583 | global $upcontext, $txt; |
| 3405 | 3584 | |
| 3406 | - if (!empty($upcontext['pause'])) |
|
| 3407 | - echo ' |
|
| 3585 | + if (!empty($upcontext['pause'])) { |
|
| 3586 | + echo ' |
|
| 3408 | 3587 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3409 | 3588 | |
| 3410 | 3589 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3411 | 3590 | <h3> |
| 3412 | 3591 | ', $txt['upgrade_paused_overload'], ' |
| 3413 | 3592 | </h3>'; |
| 3593 | + } |
|
| 3414 | 3594 | |
| 3415 | - if (!empty($upcontext['custom_warning'])) |
|
| 3416 | - echo ' |
|
| 3595 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3596 | + echo ' |
|
| 3417 | 3597 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3418 | 3598 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3419 | 3599 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3420 | 3600 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3421 | 3601 | </div>'; |
| 3602 | + } |
|
| 3422 | 3603 | |
| 3423 | 3604 | echo ' |
| 3424 | 3605 | <div class="righttext" style="margin: 1ex;">'; |
| 3425 | 3606 | |
| 3426 | - if (!empty($upcontext['continue'])) |
|
| 3427 | - echo ' |
|
| 3607 | + if (!empty($upcontext['continue'])) { |
|
| 3608 | + echo ' |
|
| 3428 | 3609 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
| 3429 | - if (!empty($upcontext['skip'])) |
|
| 3430 | - echo ' |
|
| 3610 | + } |
|
| 3611 | + if (!empty($upcontext['skip'])) { |
|
| 3612 | + echo ' |
|
| 3431 | 3613 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
| 3614 | + } |
|
| 3432 | 3615 | |
| 3433 | 3616 | echo ' |
| 3434 | 3617 | </div> |
@@ -3478,11 +3661,12 @@ discard block |
||
| 3478 | 3661 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3479 | 3662 | <smf>'; |
| 3480 | 3663 | |
| 3481 | - if (!empty($upcontext['get_data'])) |
|
| 3482 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3664 | + if (!empty($upcontext['get_data'])) { |
|
| 3665 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3483 | 3666 | echo ' |
| 3484 | 3667 | <get key="', $k, '">', $v, '</get>'; |
| 3485 | -} |
|
| 3668 | + } |
|
| 3669 | + } |
|
| 3486 | 3670 | |
| 3487 | 3671 | function template_xml_below() |
| 3488 | 3672 | { |
@@ -3523,8 +3707,8 @@ discard block |
||
| 3523 | 3707 | template_chmod(); |
| 3524 | 3708 | |
| 3525 | 3709 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3526 | - if ($upcontext['is_large_forum']) |
|
| 3527 | - echo ' |
|
| 3710 | + if ($upcontext['is_large_forum']) { |
|
| 3711 | + echo ' |
|
| 3528 | 3712 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3529 | 3713 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3530 | 3714 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3532,10 +3716,11 @@ discard block |
||
| 3532 | 3716 | ', $txt['upgrade_warning_lots_data'], ' |
| 3533 | 3717 | </div> |
| 3534 | 3718 | </div>'; |
| 3719 | + } |
|
| 3535 | 3720 | |
| 3536 | 3721 | // A warning message? |
| 3537 | - if (!empty($upcontext['warning'])) |
|
| 3538 | - echo ' |
|
| 3722 | + if (!empty($upcontext['warning'])) { |
|
| 3723 | + echo ' |
|
| 3539 | 3724 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3540 | 3725 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3541 | 3726 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3543,6 +3728,7 @@ discard block |
||
| 3543 | 3728 | ', $upcontext['warning'], ' |
| 3544 | 3729 | </div> |
| 3545 | 3730 | </div>'; |
| 3731 | + } |
|
| 3546 | 3732 | |
| 3547 | 3733 | // Paths are incorrect? |
| 3548 | 3734 | echo ' |
@@ -3558,20 +3744,22 @@ discard block |
||
| 3558 | 3744 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3559 | 3745 | { |
| 3560 | 3746 | $ago = time() - $upcontext['started']; |
| 3561 | - if ($ago < 60) |
|
| 3562 | - $ago = $ago . ' seconds'; |
|
| 3563 | - elseif ($ago < 3600) |
|
| 3564 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3565 | - else |
|
| 3566 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3747 | + if ($ago < 60) { |
|
| 3748 | + $ago = $ago . ' seconds'; |
|
| 3749 | + } elseif ($ago < 3600) { |
|
| 3750 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3751 | + } else { |
|
| 3752 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3753 | + } |
|
| 3567 | 3754 | |
| 3568 | 3755 | $active = time() - $upcontext['updated']; |
| 3569 | - if ($active < 60) |
|
| 3570 | - $updated = $active . ' seconds'; |
|
| 3571 | - elseif ($active < 3600) |
|
| 3572 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3573 | - else |
|
| 3574 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3756 | + if ($active < 60) { |
|
| 3757 | + $updated = $active . ' seconds'; |
|
| 3758 | + } elseif ($active < 3600) { |
|
| 3759 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3760 | + } else { |
|
| 3761 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3762 | + } |
|
| 3575 | 3763 | |
| 3576 | 3764 | echo ' |
| 3577 | 3765 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3580,16 +3768,18 @@ discard block |
||
| 3580 | 3768 | <div style="padding-left: 6ex;"> |
| 3581 | 3769 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3582 | 3770 | |
| 3583 | - if ($active < 600) |
|
| 3584 | - echo ' |
|
| 3771 | + if ($active < 600) { |
|
| 3772 | + echo ' |
|
| 3585 | 3773 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3774 | + } |
|
| 3586 | 3775 | |
| 3587 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3588 | - echo ' |
|
| 3776 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3777 | + echo ' |
|
| 3589 | 3778 | <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.'; |
| 3590 | - else |
|
| 3591 | - echo ' |
|
| 3779 | + } else { |
|
| 3780 | + echo ' |
|
| 3592 | 3781 | <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!'); |
| 3782 | + } |
|
| 3593 | 3783 | |
| 3594 | 3784 | echo ' |
| 3595 | 3785 | </div> |
@@ -3605,9 +3795,10 @@ discard block |
||
| 3605 | 3795 | <td> |
| 3606 | 3796 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
| 3607 | 3797 | |
| 3608 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3609 | - echo ' |
|
| 3798 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3799 | + echo ' |
|
| 3610 | 3800 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3801 | + } |
|
| 3611 | 3802 | |
| 3612 | 3803 | echo ' |
| 3613 | 3804 | </td> |
@@ -3618,9 +3809,10 @@ discard block |
||
| 3618 | 3809 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
| 3619 | 3810 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3620 | 3811 | |
| 3621 | - if (!empty($upcontext['password_failed'])) |
|
| 3622 | - echo ' |
|
| 3812 | + if (!empty($upcontext['password_failed'])) { |
|
| 3813 | + echo ' |
|
| 3623 | 3814 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3815 | + } |
|
| 3624 | 3816 | |
| 3625 | 3817 | echo ' |
| 3626 | 3818 | </td> |
@@ -3691,8 +3883,8 @@ discard block |
||
| 3691 | 3883 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3692 | 3884 | |
| 3693 | 3885 | // Warning message? |
| 3694 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3695 | - echo ' |
|
| 3886 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 3887 | + echo ' |
|
| 3696 | 3888 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3697 | 3889 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3698 | 3890 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3700,6 +3892,7 @@ discard block |
||
| 3700 | 3892 | ', $upcontext['upgrade_options_warning'], ' |
| 3701 | 3893 | </div> |
| 3702 | 3894 | </div>'; |
| 3895 | + } |
|
| 3703 | 3896 | |
| 3704 | 3897 | echo ' |
| 3705 | 3898 | <table> |
@@ -3742,8 +3935,8 @@ discard block |
||
| 3742 | 3935 | </td> |
| 3743 | 3936 | </tr>'; |
| 3744 | 3937 | |
| 3745 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3746 | - echo ' |
|
| 3938 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 3939 | + echo ' |
|
| 3747 | 3940 | <tr valign="top"> |
| 3748 | 3941 | <td width="2%"> |
| 3749 | 3942 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3752,6 +3945,7 @@ discard block |
||
| 3752 | 3945 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3753 | 3946 | </td> |
| 3754 | 3947 | </tr>'; |
| 3948 | + } |
|
| 3755 | 3949 | |
| 3756 | 3950 | echo ' |
| 3757 | 3951 | <tr valign="top"> |
@@ -3789,10 +3983,11 @@ discard block |
||
| 3789 | 3983 | </div>'; |
| 3790 | 3984 | |
| 3791 | 3985 | // Dont any tables so far? |
| 3792 | - if (!empty($upcontext['previous_tables'])) |
|
| 3793 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 3986 | + if (!empty($upcontext['previous_tables'])) { |
|
| 3987 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3794 | 3988 | echo ' |
| 3795 | 3989 | <br>Completed Table: "', $table, '".'; |
| 3990 | + } |
|
| 3796 | 3991 | |
| 3797 | 3992 | echo ' |
| 3798 | 3993 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3829,12 +4024,13 @@ discard block |
||
| 3829 | 4024 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3830 | 4025 | |
| 3831 | 4026 | // If debug flood the screen. |
| 3832 | - if ($is_debug) |
|
| 3833 | - echo ' |
|
| 4027 | + if ($is_debug) { |
|
| 4028 | + echo ' |
|
| 3834 | 4029 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3835 | 4030 | |
| 3836 | 4031 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 3837 | 4032 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4033 | + } |
|
| 3838 | 4034 | |
| 3839 | 4035 | echo ' |
| 3840 | 4036 | // Get the next update... |
@@ -3867,8 +4063,9 @@ discard block |
||
| 3867 | 4063 | { |
| 3868 | 4064 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 3869 | 4065 | |
| 3870 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 3871 | - $is_debug = true; |
|
| 4066 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4067 | + $is_debug = true; |
|
| 4068 | + } |
|
| 3872 | 4069 | |
| 3873 | 4070 | echo ' |
| 3874 | 4071 | <h3>Executing database changes</h3> |
@@ -3883,8 +4080,9 @@ discard block |
||
| 3883 | 4080 | { |
| 3884 | 4081 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 3885 | 4082 | { |
| 3886 | - if ($num != 0) |
|
| 3887 | - echo ' Successful!'; |
|
| 4083 | + if ($num != 0) { |
|
| 4084 | + echo ' Successful!'; |
|
| 4085 | + } |
|
| 3888 | 4086 | echo '<br>' . $item; |
| 3889 | 4087 | } |
| 3890 | 4088 | if (!empty($upcontext['changes_complete'])) |
@@ -3897,28 +4095,32 @@ discard block |
||
| 3897 | 4095 | $seconds = intval($active % 60); |
| 3898 | 4096 | |
| 3899 | 4097 | $totalTime = ''; |
| 3900 | - if ($hours > 0) |
|
| 3901 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3902 | - if ($minutes > 0) |
|
| 3903 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3904 | - if ($seconds > 0) |
|
| 3905 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4098 | + if ($hours > 0) { |
|
| 4099 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4100 | + } |
|
| 4101 | + if ($minutes > 0) { |
|
| 4102 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4103 | + } |
|
| 4104 | + if ($seconds > 0) { |
|
| 4105 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4106 | + } |
|
| 3906 | 4107 | } |
| 3907 | 4108 | |
| 3908 | - if ($is_debug && !empty($totalTime)) |
|
| 3909 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 3910 | - else |
|
| 3911 | - echo ' Successful!<br><br>'; |
|
| 4109 | + if ($is_debug && !empty($totalTime)) { |
|
| 4110 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4111 | + } else { |
|
| 4112 | + echo ' Successful!<br><br>'; |
|
| 4113 | + } |
|
| 3912 | 4114 | |
| 3913 | 4115 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 3914 | 4116 | } |
| 3915 | - } |
|
| 3916 | - else |
|
| 4117 | + } else |
|
| 3917 | 4118 | { |
| 3918 | 4119 | // Tell them how many files we have in total. |
| 3919 | - if ($upcontext['file_count'] > 1) |
|
| 3920 | - echo ' |
|
| 4120 | + if ($upcontext['file_count'] > 1) { |
|
| 4121 | + echo ' |
|
| 3921 | 4122 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4123 | + } |
|
| 3922 | 4124 | |
| 3923 | 4125 | echo ' |
| 3924 | 4126 | <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> |
@@ -3934,19 +4136,23 @@ discard block |
||
| 3934 | 4136 | $seconds = intval($active % 60); |
| 3935 | 4137 | |
| 3936 | 4138 | $totalTime = ''; |
| 3937 | - if ($hours > 0) |
|
| 3938 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3939 | - if ($minutes > 0) |
|
| 3940 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3941 | - if ($seconds > 0) |
|
| 3942 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4139 | + if ($hours > 0) { |
|
| 4140 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4141 | + } |
|
| 4142 | + if ($minutes > 0) { |
|
| 4143 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4144 | + } |
|
| 4145 | + if ($seconds > 0) { |
|
| 4146 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4147 | + } |
|
| 3943 | 4148 | } |
| 3944 | 4149 | |
| 3945 | 4150 | echo ' |
| 3946 | 4151 | <br><span id="upgradeCompleted">'; |
| 3947 | 4152 | |
| 3948 | - if (!empty($totalTime)) |
|
| 3949 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4153 | + if (!empty($totalTime)) { |
|
| 4154 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4155 | + } |
|
| 3950 | 4156 | |
| 3951 | 4157 | echo '</span> |
| 3952 | 4158 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -3983,9 +4189,10 @@ discard block |
||
| 3983 | 4189 | var getData = ""; |
| 3984 | 4190 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 3985 | 4191 | |
| 3986 | - if ($is_debug) |
|
| 3987 | - echo ' |
|
| 4192 | + if ($is_debug) { |
|
| 4193 | + echo ' |
|
| 3988 | 4194 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4195 | + } |
|
| 3989 | 4196 | |
| 3990 | 4197 | echo ' |
| 3991 | 4198 | function getNextItem() |
@@ -4025,9 +4232,10 @@ discard block |
||
| 4025 | 4232 | document.getElementById("error_block").style.display = ""; |
| 4026 | 4233 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4027 | 4234 | |
| 4028 | - if ($is_debug) |
|
| 4029 | - echo ' |
|
| 4235 | + if ($is_debug) { |
|
| 4236 | + echo ' |
|
| 4030 | 4237 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4238 | + } |
|
| 4031 | 4239 | |
| 4032 | 4240 | echo ' |
| 4033 | 4241 | } |
@@ -4048,9 +4256,10 @@ discard block |
||
| 4048 | 4256 | document.getElementById("error_block").style.display = ""; |
| 4049 | 4257 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4050 | 4258 | |
| 4051 | - if ($is_debug) |
|
| 4052 | - echo ' |
|
| 4259 | + if ($is_debug) { |
|
| 4260 | + echo ' |
|
| 4053 | 4261 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4262 | + } |
|
| 4054 | 4263 | |
| 4055 | 4264 | echo ' |
| 4056 | 4265 | } |
@@ -4109,8 +4318,8 @@ discard block |
||
| 4109 | 4318 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4110 | 4319 | {'; |
| 4111 | 4320 | |
| 4112 | - if ($is_debug) |
|
| 4113 | - echo ' |
|
| 4321 | + if ($is_debug) { |
|
| 4322 | + echo ' |
|
| 4114 | 4323 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4115 | 4324 | |
| 4116 | 4325 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4128,6 +4337,7 @@ discard block |
||
| 4128 | 4337 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4129 | 4338 | |
| 4130 | 4339 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4340 | + } |
|
| 4131 | 4341 | |
| 4132 | 4342 | echo ' |
| 4133 | 4343 | |
@@ -4135,9 +4345,10 @@ discard block |
||
| 4135 | 4345 | document.getElementById(\'contbutt\').disabled = 0; |
| 4136 | 4346 | document.getElementById(\'database_done\').value = 1;'; |
| 4137 | 4347 | |
| 4138 | - if ($upcontext['file_count'] > 1) |
|
| 4139 | - echo ' |
|
| 4348 | + if ($upcontext['file_count'] > 1) { |
|
| 4349 | + echo ' |
|
| 4140 | 4350 | document.getElementById(\'info1\').style.display = "none";'; |
| 4351 | + } |
|
| 4141 | 4352 | |
| 4142 | 4353 | echo ' |
| 4143 | 4354 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4150,9 +4361,10 @@ discard block |
||
| 4150 | 4361 | lastItem = 0; |
| 4151 | 4362 | prevFile = curFile;'; |
| 4152 | 4363 | |
| 4153 | - if ($is_debug) |
|
| 4154 | - echo ' |
|
| 4364 | + if ($is_debug) { |
|
| 4365 | + echo ' |
|
| 4155 | 4366 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4367 | + } |
|
| 4156 | 4368 | |
| 4157 | 4369 | echo ' |
| 4158 | 4370 | getNextItem(); |
@@ -4160,8 +4372,8 @@ discard block |
||
| 4160 | 4372 | }'; |
| 4161 | 4373 | |
| 4162 | 4374 | // If debug scroll the screen. |
| 4163 | - if ($is_debug) |
|
| 4164 | - echo ' |
|
| 4375 | + if ($is_debug) { |
|
| 4376 | + echo ' |
|
| 4165 | 4377 | if (iLastSubStepProgress == -1) |
| 4166 | 4378 | { |
| 4167 | 4379 | // Give it consistent dots. |
@@ -4180,6 +4392,7 @@ discard block |
||
| 4180 | 4392 | |
| 4181 | 4393 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4182 | 4394 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4395 | + } |
|
| 4183 | 4396 | |
| 4184 | 4397 | echo ' |
| 4185 | 4398 | // Update the page. |
@@ -4240,9 +4453,10 @@ discard block |
||
| 4240 | 4453 | }'; |
| 4241 | 4454 | |
| 4242 | 4455 | // Start things off assuming we've not errored. |
| 4243 | - if (empty($upcontext['error_message'])) |
|
| 4244 | - echo ' |
|
| 4456 | + if (empty($upcontext['error_message'])) { |
|
| 4457 | + echo ' |
|
| 4245 | 4458 | getNextItem();'; |
| 4459 | + } |
|
| 4246 | 4460 | |
| 4247 | 4461 | echo ' |
| 4248 | 4462 | //# sourceURL=dynamicScript-dbch.js |
@@ -4260,18 +4474,21 @@ discard block |
||
| 4260 | 4474 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4261 | 4475 | <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>'; |
| 4262 | 4476 | |
| 4263 | - if (!empty($upcontext['error_message'])) |
|
| 4264 | - echo ' |
|
| 4477 | + if (!empty($upcontext['error_message'])) { |
|
| 4478 | + echo ' |
|
| 4265 | 4479 | <error>', $upcontext['error_message'], '</error>'; |
| 4480 | + } |
|
| 4266 | 4481 | |
| 4267 | - if (!empty($upcontext['error_string'])) |
|
| 4268 | - echo ' |
|
| 4482 | + if (!empty($upcontext['error_string'])) { |
|
| 4483 | + echo ' |
|
| 4269 | 4484 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4485 | + } |
|
| 4270 | 4486 | |
| 4271 | - if ($is_debug) |
|
| 4272 | - echo ' |
|
| 4487 | + if ($is_debug) { |
|
| 4488 | + echo ' |
|
| 4273 | 4489 | <curtime>', time(), '</curtime>'; |
| 4274 | -} |
|
| 4490 | + } |
|
| 4491 | + } |
|
| 4275 | 4492 | |
| 4276 | 4493 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4277 | 4494 | function template_convert_utf8() |
@@ -4290,18 +4507,20 @@ discard block |
||
| 4290 | 4507 | </div>'; |
| 4291 | 4508 | |
| 4292 | 4509 | // Done any tables so far? |
| 4293 | - if (!empty($upcontext['previous_tables'])) |
|
| 4294 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4510 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4511 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4295 | 4512 | echo ' |
| 4296 | 4513 | <br>Completed Table: "', $table, '".'; |
| 4514 | + } |
|
| 4297 | 4515 | |
| 4298 | 4516 | echo ' |
| 4299 | 4517 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4300 | 4518 | |
| 4301 | 4519 | // If we dropped their index, let's let them know |
| 4302 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
| 4303 | - echo ' |
|
| 4520 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
| 4521 | + echo ' |
|
| 4304 | 4522 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
| 4523 | + } |
|
| 4305 | 4524 | |
| 4306 | 4525 | echo ' |
| 4307 | 4526 | <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>'; |
@@ -4337,12 +4556,13 @@ discard block |
||
| 4337 | 4556 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4338 | 4557 | |
| 4339 | 4558 | // If debug flood the screen. |
| 4340 | - if ($is_debug) |
|
| 4341 | - echo ' |
|
| 4559 | + if ($is_debug) { |
|
| 4560 | + echo ' |
|
| 4342 | 4561 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4343 | 4562 | |
| 4344 | 4563 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4345 | 4564 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4565 | + } |
|
| 4346 | 4566 | |
| 4347 | 4567 | echo ' |
| 4348 | 4568 | // Get the next update... |
@@ -4387,19 +4607,21 @@ discard block |
||
| 4387 | 4607 | </div>'; |
| 4388 | 4608 | |
| 4389 | 4609 | // Dont any tables so far? |
| 4390 | - if (!empty($upcontext['previous_tables'])) |
|
| 4391 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4610 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4611 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4392 | 4612 | echo ' |
| 4393 | 4613 | <br>Completed Table: "', $table, '".'; |
| 4614 | + } |
|
| 4394 | 4615 | |
| 4395 | 4616 | echo ' |
| 4396 | 4617 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4397 | 4618 | <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>'; |
| 4398 | 4619 | |
| 4399 | 4620 | // Try to make sure substep was reset. |
| 4400 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4401 | - echo ' |
|
| 4621 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4622 | + echo ' |
|
| 4402 | 4623 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4624 | + } |
|
| 4403 | 4625 | |
| 4404 | 4626 | // Continue please! |
| 4405 | 4627 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4432,12 +4654,13 @@ discard block |
||
| 4432 | 4654 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4433 | 4655 | |
| 4434 | 4656 | // If debug flood the screen. |
| 4435 | - if ($is_debug) |
|
| 4436 | - echo ' |
|
| 4657 | + if ($is_debug) { |
|
| 4658 | + echo ' |
|
| 4437 | 4659 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4438 | 4660 | |
| 4439 | 4661 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4440 | 4662 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4663 | + } |
|
| 4441 | 4664 | |
| 4442 | 4665 | echo ' |
| 4443 | 4666 | // Get the next update... |
@@ -4473,8 +4696,8 @@ discard block |
||
| 4473 | 4696 | <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> |
| 4474 | 4697 | <form action="', $boardurl, '/index.php">'; |
| 4475 | 4698 | |
| 4476 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4477 | - echo ' |
|
| 4699 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4700 | + echo ' |
|
| 4478 | 4701 | <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> |
| 4479 | 4702 | <script> |
| 4480 | 4703 | function doTheDelete(theCheck) |
@@ -4486,6 +4709,7 @@ discard block |
||
| 4486 | 4709 | } |
| 4487 | 4710 | </script> |
| 4488 | 4711 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4712 | + } |
|
| 4489 | 4713 | |
| 4490 | 4714 | $active = time() - $upcontext['started']; |
| 4491 | 4715 | $hours = floor($active / 3600); |
@@ -4495,16 +4719,20 @@ discard block |
||
| 4495 | 4719 | if ($is_debug) |
| 4496 | 4720 | { |
| 4497 | 4721 | $totalTime = ''; |
| 4498 | - if ($hours > 0) |
|
| 4499 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4500 | - if ($minutes > 0) |
|
| 4501 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4502 | - if ($seconds > 0) |
|
| 4503 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4722 | + if ($hours > 0) { |
|
| 4723 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4724 | + } |
|
| 4725 | + if ($minutes > 0) { |
|
| 4726 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4727 | + } |
|
| 4728 | + if ($seconds > 0) { |
|
| 4729 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4730 | + } |
|
| 4504 | 4731 | } |
| 4505 | 4732 | |
| 4506 | - if ($is_debug && !empty($totalTime)) |
|
| 4507 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4733 | + if ($is_debug && !empty($totalTime)) { |
|
| 4734 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4735 | + } |
|
| 4508 | 4736 | |
| 4509 | 4737 | echo '<br> |
| 4510 | 4738 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4531,8 +4759,9 @@ discard block |
||
| 4531 | 4759 | |
| 4532 | 4760 | $current_substep = $_GET['substep']; |
| 4533 | 4761 | |
| 4534 | - if (empty($_GET['a'])) |
|
| 4535 | - $_GET['a'] = 0; |
|
| 4762 | + if (empty($_GET['a'])) { |
|
| 4763 | + $_GET['a'] = 0; |
|
| 4764 | + } |
|
| 4536 | 4765 | $step_progress['name'] = 'Converting ips'; |
| 4537 | 4766 | $step_progress['current'] = $_GET['a']; |
| 4538 | 4767 | |
@@ -4575,16 +4804,19 @@ discard block |
||
| 4575 | 4804 | 'empty' => '', |
| 4576 | 4805 | 'limit' => $limit, |
| 4577 | 4806 | )); |
| 4578 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4579 | - $arIp[] = $row[$oldCol]; |
|
| 4807 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4808 | + $arIp[] = $row[$oldCol]; |
|
| 4809 | + } |
|
| 4580 | 4810 | $smcFunc['db_free_result']($request); |
| 4581 | 4811 | |
| 4582 | 4812 | // Special case, null ip could keep us in a loop. |
| 4583 | - if (is_null($arIp[0])) |
|
| 4584 | - unset($arIp[0]); |
|
| 4813 | + if (is_null($arIp[0])) { |
|
| 4814 | + unset($arIp[0]); |
|
| 4815 | + } |
|
| 4585 | 4816 | |
| 4586 | - if (empty($arIp)) |
|
| 4587 | - $is_done = true; |
|
| 4817 | + if (empty($arIp)) { |
|
| 4818 | + $is_done = true; |
|
| 4819 | + } |
|
| 4588 | 4820 | |
| 4589 | 4821 | $updates = array(); |
| 4590 | 4822 | $cases = array(); |
@@ -4593,16 +4825,18 @@ discard block |
||
| 4593 | 4825 | { |
| 4594 | 4826 | $arIp[$i] = trim($arIp[$i]); |
| 4595 | 4827 | |
| 4596 | - if (empty($arIp[$i])) |
|
| 4597 | - continue; |
|
| 4828 | + if (empty($arIp[$i])) { |
|
| 4829 | + continue; |
|
| 4830 | + } |
|
| 4598 | 4831 | |
| 4599 | 4832 | $updates['ip' . $i] = $arIp[$i]; |
| 4600 | 4833 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4601 | 4834 | |
| 4602 | 4835 | if ($setSize > 0 && $i % $setSize === 0) |
| 4603 | 4836 | { |
| 4604 | - if (count($updates) == 1) |
|
| 4605 | - continue; |
|
| 4837 | + if (count($updates) == 1) { |
|
| 4838 | + continue; |
|
| 4839 | + } |
|
| 4606 | 4840 | |
| 4607 | 4841 | $updates['whereSet'] = array_values($updates); |
| 4608 | 4842 | $smcFunc['db_query']('', ' |
@@ -4636,8 +4870,7 @@ discard block |
||
| 4636 | 4870 | 'ip' => $ip |
| 4637 | 4871 | )); |
| 4638 | 4872 | } |
| 4639 | - } |
|
| 4640 | - else |
|
| 4873 | + } else |
|
| 4641 | 4874 | { |
| 4642 | 4875 | $updates['whereSet'] = array_values($updates); |
| 4643 | 4876 | $smcFunc['db_query']('', ' |
@@ -4651,9 +4884,9 @@ discard block |
||
| 4651 | 4884 | $updates |
| 4652 | 4885 | ); |
| 4653 | 4886 | } |
| 4887 | + } else { |
|
| 4888 | + $is_done = true; |
|
| 4654 | 4889 | } |
| 4655 | - else |
|
| 4656 | - $is_done = true; |
|
| 4657 | 4890 | |
| 4658 | 4891 | $_GET['a'] += $limit; |
| 4659 | 4892 | $step_progress['current'] = $_GET['a']; |
@@ -4679,10 +4912,11 @@ discard block |
||
| 4679 | 4912 | |
| 4680 | 4913 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4681 | 4914 | |
| 4682 | - if (isset($columns[$column])) |
|
| 4683 | - return $columns[$column]; |
|
| 4684 | - else |
|
| 4685 | - return null; |
|
| 4686 | -} |
|
| 4915 | + if (isset($columns[$column])) { |
|
| 4916 | + return $columns[$column]; |
|
| 4917 | + } else { |
|
| 4918 | + return null; |
|
| 4919 | + } |
|
| 4920 | + } |
|
| 4687 | 4921 | |
| 4688 | 4922 | ?> |
| 4689 | 4923 | \ No newline at end of file |