@@ -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 | //Clear out warnings at the start of each step |
@@ -323,17 +338,18 @@ discard block |
||
| 323 | 338 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 324 | 339 | if (!empty($command_line)) |
| 325 | 340 | { |
| 326 | - if (function_exists('debug_print_backtrace')) |
|
| 327 | - debug_print_backtrace(); |
|
| 341 | + if (function_exists('debug_print_backtrace')) { |
|
| 342 | + debug_print_backtrace(); |
|
| 343 | + } |
|
| 328 | 344 | |
| 329 | 345 | 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.'; |
| 330 | 346 | flush(); |
| 331 | 347 | die(); |
| 332 | 348 | } |
| 333 | 349 | |
| 334 | - if (!isset($_GET['xml'])) |
|
| 335 | - template_upgrade_above(); |
|
| 336 | - else |
|
| 350 | + if (!isset($_GET['xml'])) { |
|
| 351 | + template_upgrade_above(); |
|
| 352 | + } else |
|
| 337 | 353 | { |
| 338 | 354 | header('Content-Type: text/xml; charset=UTF-8'); |
| 339 | 355 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -355,25 +371,29 @@ discard block |
||
| 355 | 371 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 356 | 372 | |
| 357 | 373 | // Custom stuff to pass back? |
| 358 | - if (!empty($upcontext['query_string'])) |
|
| 359 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 374 | + if (!empty($upcontext['query_string'])) { |
|
| 375 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 376 | + } |
|
| 360 | 377 | |
| 361 | 378 | // Call the appropriate subtemplate |
| 362 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 363 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 364 | - else |
|
| 365 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 379 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 380 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 381 | + } else { |
|
| 382 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 383 | + } |
|
| 366 | 384 | } |
| 367 | 385 | |
| 368 | 386 | // Was there an error? |
| 369 | - if (!empty($upcontext['forced_error_message'])) |
|
| 370 | - echo $upcontext['forced_error_message']; |
|
| 387 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 388 | + echo $upcontext['forced_error_message']; |
|
| 389 | + } |
|
| 371 | 390 | |
| 372 | 391 | // Show the footer. |
| 373 | - if (!isset($_GET['xml'])) |
|
| 374 | - template_upgrade_below(); |
|
| 375 | - else |
|
| 376 | - template_xml_below(); |
|
| 392 | + if (!isset($_GET['xml'])) { |
|
| 393 | + template_upgrade_below(); |
|
| 394 | + } else { |
|
| 395 | + template_xml_below(); |
|
| 396 | + } |
|
| 377 | 397 | } |
| 378 | 398 | |
| 379 | 399 | |
@@ -385,15 +405,19 @@ discard block |
||
| 385 | 405 | $seconds = intval($active % 60); |
| 386 | 406 | |
| 387 | 407 | $totalTime = ''; |
| 388 | - if ($hours > 0) |
|
| 389 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 390 | - if ($minutes > 0) |
|
| 391 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 392 | - if ($seconds > 0) |
|
| 393 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 408 | + if ($hours > 0) { |
|
| 409 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 410 | + } |
|
| 411 | + if ($minutes > 0) { |
|
| 412 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 413 | + } |
|
| 414 | + if ($seconds > 0) { |
|
| 415 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 416 | + } |
|
| 394 | 417 | |
| 395 | - if (!empty($totalTime)) |
|
| 396 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 418 | + if (!empty($totalTime)) { |
|
| 419 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 420 | + } |
|
| 397 | 421 | } |
| 398 | 422 | |
| 399 | 423 | // Bang - gone! |
@@ -406,8 +430,9 @@ discard block |
||
| 406 | 430 | global $upgradeurl, $upcontext, $command_line; |
| 407 | 431 | |
| 408 | 432 | // Command line users can't be redirected. |
| 409 | - if ($command_line) |
|
| 410 | - upgradeExit(true); |
|
| 433 | + if ($command_line) { |
|
| 434 | + upgradeExit(true); |
|
| 435 | + } |
|
| 411 | 436 | |
| 412 | 437 | // Are we providing the core info? |
| 413 | 438 | if ($addForm) |
@@ -433,12 +458,14 @@ discard block |
||
| 433 | 458 | define('SMF', 1); |
| 434 | 459 | |
| 435 | 460 | // Start the session. |
| 436 | - if (@ini_get('session.save_handler') == 'user') |
|
| 437 | - @ini_set('session.save_handler', 'files'); |
|
| 461 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 462 | + @ini_set('session.save_handler', 'files'); |
|
| 463 | + } |
|
| 438 | 464 | @session_start(); |
| 439 | 465 | |
| 440 | - if (empty($smcFunc)) |
|
| 441 | - $smcFunc = array(); |
|
| 466 | + if (empty($smcFunc)) { |
|
| 467 | + $smcFunc = array(); |
|
| 468 | + } |
|
| 442 | 469 | |
| 443 | 470 | // We need this for authentication and some upgrade code |
| 444 | 471 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -450,32 +477,36 @@ discard block |
||
| 450 | 477 | initialize_inputs(); |
| 451 | 478 | |
| 452 | 479 | // Get the database going! |
| 453 | - if (empty($db_type) || $db_type == 'mysqli') |
|
| 454 | - $db_type = 'mysql'; |
|
| 480 | + if (empty($db_type) || $db_type == 'mysqli') { |
|
| 481 | + $db_type = 'mysql'; |
|
| 482 | + } |
|
| 455 | 483 | |
| 456 | 484 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
| 457 | 485 | { |
| 458 | 486 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 459 | 487 | |
| 460 | 488 | // Make the connection... |
| 461 | - if (empty($db_connection)) |
|
| 462 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 463 | - else |
|
| 464 | - // If we've returned here, ping/reconnect to be safe |
|
| 489 | + if (empty($db_connection)) { |
|
| 490 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 491 | + } else { |
|
| 492 | + // If we've returned here, ping/reconnect to be safe |
|
| 465 | 493 | $smcFunc['db_ping']($db_connection); |
| 494 | + } |
|
| 466 | 495 | |
| 467 | 496 | // Oh dear god!! |
| 468 | - if ($db_connection === null) |
|
| 469 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 497 | + if ($db_connection === null) { |
|
| 498 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 499 | + } |
|
| 470 | 500 | |
| 471 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 472 | - $smcFunc['db_query']('', ' |
|
| 501 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 502 | + $smcFunc['db_query']('', ' |
|
| 473 | 503 | SET NAMES {string:db_character_set}', |
| 474 | 504 | array( |
| 475 | 505 | 'db_error_skip' => true, |
| 476 | 506 | 'db_character_set' => $db_character_set, |
| 477 | 507 | ) |
| 478 | 508 | ); |
| 509 | + } |
|
| 479 | 510 | |
| 480 | 511 | // Load the modSettings data... |
| 481 | 512 | $request = $smcFunc['db_query']('', ' |
@@ -486,11 +517,11 @@ discard block |
||
| 486 | 517 | ) |
| 487 | 518 | ); |
| 488 | 519 | $modSettings = array(); |
| 489 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 490 | - $modSettings[$row['variable']] = $row['value']; |
|
| 520 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 521 | + $modSettings[$row['variable']] = $row['value']; |
|
| 522 | + } |
|
| 491 | 523 | $smcFunc['db_free_result']($request); |
| 492 | - } |
|
| 493 | - else |
|
| 524 | + } else |
|
| 494 | 525 | { |
| 495 | 526 | 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.'); |
| 496 | 527 | } |
@@ -504,9 +535,10 @@ discard block |
||
| 504 | 535 | cleanRequest(); |
| 505 | 536 | } |
| 506 | 537 | |
| 507 | - if (!isset($_GET['substep'])) |
|
| 508 | - $_GET['substep'] = 0; |
|
| 509 | -} |
|
| 538 | + if (!isset($_GET['substep'])) { |
|
| 539 | + $_GET['substep'] = 0; |
|
| 540 | + } |
|
| 541 | + } |
|
| 510 | 542 | |
| 511 | 543 | function initialize_inputs() |
| 512 | 544 | { |
@@ -536,8 +568,9 @@ discard block |
||
| 536 | 568 | $dh = opendir(dirname(__FILE__)); |
| 537 | 569 | while ($file = readdir($dh)) |
| 538 | 570 | { |
| 539 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 540 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 571 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 572 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 573 | + } |
|
| 541 | 574 | } |
| 542 | 575 | closedir($dh); |
| 543 | 576 | |
@@ -566,8 +599,9 @@ discard block |
||
| 566 | 599 | $temp = 'upgrade_php?step'; |
| 567 | 600 | while (strlen($temp) > 4) |
| 568 | 601 | { |
| 569 | - if (isset($_GET[$temp])) |
|
| 570 | - unset($_GET[$temp]); |
|
| 602 | + if (isset($_GET[$temp])) { |
|
| 603 | + unset($_GET[$temp]); |
|
| 604 | + } |
|
| 571 | 605 | $temp = substr($temp, 1); |
| 572 | 606 | } |
| 573 | 607 | |
@@ -594,32 +628,39 @@ discard block |
||
| 594 | 628 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 595 | 629 | |
| 596 | 630 | // Need legacy scripts? |
| 597 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 598 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 599 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 600 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 601 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 602 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 631 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 632 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 633 | + } |
|
| 634 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 635 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 636 | + } |
|
| 637 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 638 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 639 | + } |
|
| 603 | 640 | |
| 604 | 641 | // We don't need "-utf8" files anymore... |
| 605 | 642 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 606 | 643 | |
| 607 | 644 | // This needs to exist! |
| 608 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 609 | - 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>]'); |
|
| 610 | - else |
|
| 611 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 645 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 646 | + 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>]'); |
|
| 647 | + } else { |
|
| 648 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 649 | + } |
|
| 612 | 650 | |
| 613 | - if (!$check) |
|
| 614 | - // 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. |
|
| 651 | + if (!$check) { |
|
| 652 | + // 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. |
|
| 615 | 653 | 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.'); |
| 654 | + } |
|
| 616 | 655 | |
| 617 | 656 | // Do they meet the install requirements? |
| 618 | - if (!php_version_check()) |
|
| 619 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 657 | + if (!php_version_check()) { |
|
| 658 | + 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.'); |
|
| 659 | + } |
|
| 620 | 660 | |
| 621 | - if (!db_version_check()) |
|
| 622 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 661 | + if (!db_version_check()) { |
|
| 662 | + 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.'); |
|
| 663 | + } |
|
| 623 | 664 | |
| 624 | 665 | // Do some checks to make sure they have proper privileges |
| 625 | 666 | db_extend('packages'); |
@@ -634,14 +675,16 @@ discard block |
||
| 634 | 675 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 635 | 676 | |
| 636 | 677 | // Sorry... we need CREATE, ALTER and DROP |
| 637 | - if (!$create || !$alter || !$drop) |
|
| 638 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 678 | + if (!$create || !$alter || !$drop) { |
|
| 679 | + 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.'); |
|
| 680 | + } |
|
| 639 | 681 | |
| 640 | 682 | // Do a quick version spot check. |
| 641 | 683 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 642 | 684 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 643 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 644 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 685 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 686 | + 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.'); |
|
| 687 | + } |
|
| 645 | 688 | |
| 646 | 689 | // What absolutely needs to be writable? |
| 647 | 690 | $writable_files = array( |
@@ -663,12 +706,13 @@ discard block |
||
| 663 | 706 | quickFileWritable($custom_av_dir); |
| 664 | 707 | |
| 665 | 708 | // Are we good now? |
| 666 | - if (!is_writable($custom_av_dir)) |
|
| 667 | - 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)); |
|
| 668 | - elseif ($need_settings_update) |
|
| 709 | + if (!is_writable($custom_av_dir)) { |
|
| 710 | + 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)); |
|
| 711 | + } elseif ($need_settings_update) |
|
| 669 | 712 | { |
| 670 | - if (!function_exists('cache_put_data')) |
|
| 671 | - require_once($sourcedir . '/Load.php'); |
|
| 713 | + if (!function_exists('cache_put_data')) { |
|
| 714 | + require_once($sourcedir . '/Load.php'); |
|
| 715 | + } |
|
| 672 | 716 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 673 | 717 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 674 | 718 | } |
@@ -677,28 +721,33 @@ discard block |
||
| 677 | 721 | |
| 678 | 722 | // Check the cache directory. |
| 679 | 723 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 680 | - if (!file_exists($cachedir_temp)) |
|
| 681 | - @mkdir($cachedir_temp); |
|
| 682 | - if (!file_exists($cachedir_temp)) |
|
| 683 | - 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.'); |
|
| 684 | - |
|
| 685 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 686 | - 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>.'); |
|
| 687 | - elseif (!isset($_GET['skiplang'])) |
|
| 724 | + if (!file_exists($cachedir_temp)) { |
|
| 725 | + @mkdir($cachedir_temp); |
|
| 726 | + } |
|
| 727 | + if (!file_exists($cachedir_temp)) { |
|
| 728 | + 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.'); |
|
| 729 | + } |
|
| 730 | + |
|
| 731 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 732 | + 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>.'); |
|
| 733 | + } elseif (!isset($_GET['skiplang'])) |
|
| 688 | 734 | { |
| 689 | 735 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 690 | 736 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 691 | 737 | |
| 692 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 693 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 738 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 739 | + 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>]'); |
|
| 740 | + } |
|
| 694 | 741 | } |
| 695 | 742 | |
| 696 | - if (!makeFilesWritable($writable_files)) |
|
| 697 | - return false; |
|
| 743 | + if (!makeFilesWritable($writable_files)) { |
|
| 744 | + return false; |
|
| 745 | + } |
|
| 698 | 746 | |
| 699 | 747 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 700 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 701 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 748 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 749 | + 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.'); |
|
| 750 | + } |
|
| 702 | 751 | |
| 703 | 752 | // Upgrade the agreement. |
| 704 | 753 | elseif (isset($modSettings['agreement'])) |
@@ -709,8 +758,8 @@ discard block |
||
| 709 | 758 | } |
| 710 | 759 | |
| 711 | 760 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 712 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 713 | - $upcontext['warning'] = ' |
|
| 761 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 762 | + $upcontext['warning'] = ' |
|
| 714 | 763 | 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> |
| 715 | 764 | <ul> |
| 716 | 765 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -718,19 +767,23 @@ discard block |
||
| 718 | 767 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 719 | 768 | </ul> |
| 720 | 769 | 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.'; |
| 770 | + } |
|
| 721 | 771 | |
| 722 | 772 | // Confirm mbstring is loaded... |
| 723 | - if (!extension_loaded('mbstring')) |
|
| 724 | - return throw_error($txt['install_no_mbstring']); |
|
| 773 | + if (!extension_loaded('mbstring')) { |
|
| 774 | + return throw_error($txt['install_no_mbstring']); |
|
| 775 | + } |
|
| 725 | 776 | |
| 726 | 777 | // Check for https stream support. |
| 727 | 778 | $supported_streams = stream_get_wrappers(); |
| 728 | - if (!in_array('https', $supported_streams)) |
|
| 729 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 779 | + if (!in_array('https', $supported_streams)) { |
|
| 780 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 781 | + } |
|
| 730 | 782 | |
| 731 | 783 | // Either we're logged in or we're going to present the login. |
| 732 | - if (checkLogin()) |
|
| 733 | - return true; |
|
| 784 | + if (checkLogin()) { |
|
| 785 | + return true; |
|
| 786 | + } |
|
| 734 | 787 | |
| 735 | 788 | $upcontext += createToken('login'); |
| 736 | 789 | |
@@ -744,15 +797,17 @@ discard block |
||
| 744 | 797 | global $smcFunc, $db_type, $support_js; |
| 745 | 798 | |
| 746 | 799 | // Don't bother if the security is disabled. |
| 747 | - if ($disable_security) |
|
| 748 | - return true; |
|
| 800 | + if ($disable_security) { |
|
| 801 | + return true; |
|
| 802 | + } |
|
| 749 | 803 | |
| 750 | 804 | // Are we trying to login? |
| 751 | 805 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 752 | 806 | { |
| 753 | 807 | // If we've disabled security pick a suitable name! |
| 754 | - if (empty($_POST['user'])) |
|
| 755 | - $_POST['user'] = 'Administrator'; |
|
| 808 | + if (empty($_POST['user'])) { |
|
| 809 | + $_POST['user'] = 'Administrator'; |
|
| 810 | + } |
|
| 756 | 811 | |
| 757 | 812 | // Before 2.0 these column names were different! |
| 758 | 813 | $oldDB = false; |
@@ -767,16 +822,17 @@ discard block |
||
| 767 | 822 | 'db_error_skip' => true, |
| 768 | 823 | ) |
| 769 | 824 | ); |
| 770 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 771 | - $oldDB = true; |
|
| 825 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 826 | + $oldDB = true; |
|
| 827 | + } |
|
| 772 | 828 | $smcFunc['db_free_result']($request); |
| 773 | 829 | } |
| 774 | 830 | |
| 775 | 831 | // Get what we believe to be their details. |
| 776 | 832 | if (!$disable_security) |
| 777 | 833 | { |
| 778 | - if ($oldDB) |
|
| 779 | - $request = $smcFunc['db_query']('', ' |
|
| 834 | + if ($oldDB) { |
|
| 835 | + $request = $smcFunc['db_query']('', ' |
|
| 780 | 836 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 781 | 837 | additionalGroups AS additional_groups, lngfile |
| 782 | 838 | FROM {db_prefix}members |
@@ -786,8 +842,8 @@ discard block |
||
| 786 | 842 | 'db_error_skip' => true, |
| 787 | 843 | ) |
| 788 | 844 | ); |
| 789 | - else |
|
| 790 | - $request = $smcFunc['db_query']('', ' |
|
| 845 | + } else { |
|
| 846 | + $request = $smcFunc['db_query']('', ' |
|
| 791 | 847 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 792 | 848 | FROM {db_prefix}members |
| 793 | 849 | WHERE member_name = {string:member_name}', |
@@ -796,6 +852,7 @@ discard block |
||
| 796 | 852 | 'db_error_skip' => true, |
| 797 | 853 | ) |
| 798 | 854 | ); |
| 855 | + } |
|
| 799 | 856 | if ($smcFunc['db_num_rows']($request) != 0) |
| 800 | 857 | { |
| 801 | 858 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -803,16 +860,17 @@ discard block |
||
| 803 | 860 | $groups = explode(',', $addGroups); |
| 804 | 861 | $groups[] = $id_group; |
| 805 | 862 | |
| 806 | - foreach ($groups as $k => $v) |
|
| 807 | - $groups[$k] = (int) $v; |
|
| 863 | + foreach ($groups as $k => $v) { |
|
| 864 | + $groups[$k] = (int) $v; |
|
| 865 | + } |
|
| 808 | 866 | |
| 809 | 867 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 810 | 868 | |
| 811 | 869 | // We don't use "-utf8" anymore... |
| 812 | 870 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 871 | + } else { |
|
| 872 | + $upcontext['username_incorrect'] = true; |
|
| 813 | 873 | } |
| 814 | - else |
|
| 815 | - $upcontext['username_incorrect'] = true; |
|
| 816 | 874 | $smcFunc['db_free_result']($request); |
| 817 | 875 | } |
| 818 | 876 | $upcontext['username'] = $_POST['user']; |
@@ -822,13 +880,14 @@ discard block |
||
| 822 | 880 | { |
| 823 | 881 | $upcontext['upgrade_status']['js'] = 1; |
| 824 | 882 | $support_js = 1; |
| 883 | + } else { |
|
| 884 | + $support_js = 0; |
|
| 825 | 885 | } |
| 826 | - else |
|
| 827 | - $support_js = 0; |
|
| 828 | 886 | |
| 829 | 887 | // Note down the version we are coming from. |
| 830 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 831 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 888 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 889 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 890 | + } |
|
| 832 | 891 | |
| 833 | 892 | // Didn't get anywhere? |
| 834 | 893 | 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'])) |
@@ -862,15 +921,15 @@ discard block |
||
| 862 | 921 | 'db_error_skip' => true, |
| 863 | 922 | ) |
| 864 | 923 | ); |
| 865 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 866 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 924 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 925 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 926 | + } |
|
| 867 | 927 | $smcFunc['db_free_result']($request); |
| 868 | 928 | } |
| 869 | 929 | |
| 870 | 930 | $upcontext['user']['id'] = $id_member; |
| 871 | 931 | $upcontext['user']['name'] = $name; |
| 872 | - } |
|
| 873 | - else |
|
| 932 | + } else |
|
| 874 | 933 | { |
| 875 | 934 | $upcontext['user']['id'] = 1; |
| 876 | 935 | $upcontext['user']['name'] = 'Administrator'; |
@@ -886,11 +945,11 @@ discard block |
||
| 886 | 945 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 887 | 946 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 888 | 947 | |
| 889 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 890 | - $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'] . '.'; |
|
| 891 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 892 | - $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'] . '.'; |
|
| 893 | - else |
|
| 948 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 949 | + $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'] . '.'; |
|
| 950 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 951 | + $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'] . '.'; |
|
| 952 | + } else |
|
| 894 | 953 | { |
| 895 | 954 | // Set this as the new language. |
| 896 | 955 | $upcontext['language'] = $user_language; |
@@ -934,8 +993,9 @@ discard block |
||
| 934 | 993 | unset($member_columns); |
| 935 | 994 | |
| 936 | 995 | // If we've not submitted then we're done. |
| 937 | - if (empty($_POST['upcont'])) |
|
| 938 | - return false; |
|
| 996 | + if (empty($_POST['upcont'])) { |
|
| 997 | + return false; |
|
| 998 | + } |
|
| 939 | 999 | |
| 940 | 1000 | // Firstly, if they're enabling SM stat collection just do it. |
| 941 | 1001 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -955,16 +1015,17 @@ discard block |
||
| 955 | 1015 | fwrite($fp, $out); |
| 956 | 1016 | |
| 957 | 1017 | $return_data = ''; |
| 958 | - while (!feof($fp)) |
|
| 959 | - $return_data .= fgets($fp, 128); |
|
| 1018 | + while (!feof($fp)) { |
|
| 1019 | + $return_data .= fgets($fp, 128); |
|
| 1020 | + } |
|
| 960 | 1021 | |
| 961 | 1022 | fclose($fp); |
| 962 | 1023 | |
| 963 | 1024 | // Get the unique site ID. |
| 964 | 1025 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 965 | 1026 | |
| 966 | - if (!empty($ID[1])) |
|
| 967 | - $smcFunc['db_insert']('replace', |
|
| 1027 | + if (!empty($ID[1])) { |
|
| 1028 | + $smcFunc['db_insert']('replace', |
|
| 968 | 1029 | $db_prefix . 'settings', |
| 969 | 1030 | array('variable' => 'string', 'value' => 'string'), |
| 970 | 1031 | array( |
@@ -973,9 +1034,9 @@ discard block |
||
| 973 | 1034 | ), |
| 974 | 1035 | array('variable') |
| 975 | 1036 | ); |
| 1037 | + } |
|
| 976 | 1038 | } |
| 977 | - } |
|
| 978 | - else |
|
| 1039 | + } else |
|
| 979 | 1040 | { |
| 980 | 1041 | $smcFunc['db_insert']('replace', |
| 981 | 1042 | $db_prefix . 'settings', |
@@ -986,8 +1047,8 @@ discard block |
||
| 986 | 1047 | } |
| 987 | 1048 | } |
| 988 | 1049 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 989 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 990 | - $smcFunc['db_query']('', ' |
|
| 1050 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1051 | + $smcFunc['db_query']('', ' |
|
| 991 | 1052 | DELETE FROM {db_prefix}settings |
| 992 | 1053 | WHERE variable = {string:enable_sm_stats}', |
| 993 | 1054 | array( |
@@ -995,6 +1056,7 @@ discard block |
||
| 995 | 1056 | 'db_error_skip' => true, |
| 996 | 1057 | ) |
| 997 | 1058 | ); |
| 1059 | + } |
|
| 998 | 1060 | |
| 999 | 1061 | // Deleting old karma stuff? |
| 1000 | 1062 | if (!empty($_POST['delete_karma'])) |
@@ -1009,20 +1071,22 @@ discard block |
||
| 1009 | 1071 | ); |
| 1010 | 1072 | |
| 1011 | 1073 | // Cleaning up old karma member settings. |
| 1012 | - if ($upcontext['karma_installed']['good']) |
|
| 1013 | - $smcFunc['db_query']('', ' |
|
| 1074 | + if ($upcontext['karma_installed']['good']) { |
|
| 1075 | + $smcFunc['db_query']('', ' |
|
| 1014 | 1076 | ALTER TABLE {db_prefix}members |
| 1015 | 1077 | DROP karma_good', |
| 1016 | 1078 | array() |
| 1017 | 1079 | ); |
| 1080 | + } |
|
| 1018 | 1081 | |
| 1019 | 1082 | // Does karma bad was enable? |
| 1020 | - if ($upcontext['karma_installed']['bad']) |
|
| 1021 | - $smcFunc['db_query']('', ' |
|
| 1083 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1084 | + $smcFunc['db_query']('', ' |
|
| 1022 | 1085 | ALTER TABLE {db_prefix}members |
| 1023 | 1086 | DROP karma_bad', |
| 1024 | 1087 | array() |
| 1025 | 1088 | ); |
| 1089 | + } |
|
| 1026 | 1090 | |
| 1027 | 1091 | // Cleaning up old karma permissions. |
| 1028 | 1092 | $smcFunc['db_query']('', ' |
@@ -1035,26 +1099,29 @@ discard block |
||
| 1035 | 1099 | } |
| 1036 | 1100 | |
| 1037 | 1101 | // Emptying the error log? |
| 1038 | - if (!empty($_POST['empty_error'])) |
|
| 1039 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1102 | + if (!empty($_POST['empty_error'])) { |
|
| 1103 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1040 | 1104 | TRUNCATE {db_prefix}log_errors', |
| 1041 | 1105 | array( |
| 1042 | 1106 | ) |
| 1043 | 1107 | ); |
| 1108 | + } |
|
| 1044 | 1109 | |
| 1045 | 1110 | $changes = array(); |
| 1046 | 1111 | |
| 1047 | 1112 | // Add proxy settings. |
| 1048 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1049 | - $changes += array( |
|
| 1113 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1114 | + $changes += array( |
|
| 1050 | 1115 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1051 | 1116 | 'image_proxy_maxsize' => 5190, |
| 1052 | 1117 | 'image_proxy_enabled' => 0, |
| 1053 | 1118 | ); |
| 1119 | + } |
|
| 1054 | 1120 | |
| 1055 | 1121 | // If we're overriding the language follow it through. |
| 1056 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1057 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1122 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1123 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1124 | + } |
|
| 1058 | 1125 | |
| 1059 | 1126 | if (!empty($_POST['maint'])) |
| 1060 | 1127 | { |
@@ -1066,30 +1133,34 @@ discard block |
||
| 1066 | 1133 | { |
| 1067 | 1134 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1068 | 1135 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1069 | - } |
|
| 1070 | - else |
|
| 1136 | + } else |
|
| 1071 | 1137 | { |
| 1072 | 1138 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1073 | 1139 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1074 | 1140 | } |
| 1075 | 1141 | } |
| 1076 | 1142 | |
| 1077 | - if ($command_line) |
|
| 1078 | - echo ' * Updating Settings.php...'; |
|
| 1143 | + if ($command_line) { |
|
| 1144 | + echo ' * Updating Settings.php...'; |
|
| 1145 | + } |
|
| 1079 | 1146 | |
| 1080 | 1147 | // Fix some old paths. |
| 1081 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1082 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1148 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1149 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1150 | + } |
|
| 1083 | 1151 | |
| 1084 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1085 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1152 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1153 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1154 | + } |
|
| 1086 | 1155 | |
| 1087 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1088 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1156 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1157 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1158 | + } |
|
| 1089 | 1159 | |
| 1090 | 1160 | // Not had the database type added before? |
| 1091 | - if (empty($db_type)) |
|
| 1092 | - $changes['db_type'] = 'mysql'; |
|
| 1161 | + if (empty($db_type)) { |
|
| 1162 | + $changes['db_type'] = 'mysql'; |
|
| 1163 | + } |
|
| 1093 | 1164 | |
| 1094 | 1165 | // If they have a "host:port" setup for the host, split that into separate values |
| 1095 | 1166 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1100,32 +1171,36 @@ discard block |
||
| 1100 | 1171 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1101 | 1172 | |
| 1102 | 1173 | // Only set this if we're not using the default port |
| 1103 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1104 | - $changes['db_port'] = (int) $db_port; |
|
| 1105 | - } |
|
| 1106 | - elseif (!empty($db_port)) |
|
| 1174 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1175 | + $changes['db_port'] = (int) $db_port; |
|
| 1176 | + } |
|
| 1177 | + } elseif (!empty($db_port)) |
|
| 1107 | 1178 | { |
| 1108 | 1179 | // If db_port is set and is the same as the default, set it to '' |
| 1109 | 1180 | if ($db_type == 'mysql') |
| 1110 | 1181 | { |
| 1111 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1112 | - $changes['db_port'] = '\'\''; |
|
| 1113 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1114 | - $changes['db_port'] = '\'\''; |
|
| 1182 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1183 | + $changes['db_port'] = '\'\''; |
|
| 1184 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1185 | + $changes['db_port'] = '\'\''; |
|
| 1186 | + } |
|
| 1115 | 1187 | } |
| 1116 | 1188 | } |
| 1117 | 1189 | |
| 1118 | 1190 | // Maybe we haven't had this option yet? |
| 1119 | - if (empty($packagesdir)) |
|
| 1120 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1191 | + if (empty($packagesdir)) { |
|
| 1192 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1193 | + } |
|
| 1121 | 1194 | |
| 1122 | 1195 | // Add support for $tasksdir var. |
| 1123 | - if (empty($tasksdir)) |
|
| 1124 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1196 | + if (empty($tasksdir)) { |
|
| 1197 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1198 | + } |
|
| 1125 | 1199 | |
| 1126 | 1200 | // Make sure we fix the language as well. |
| 1127 | - if (stristr($language, '-utf8')) |
|
| 1128 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1201 | + if (stristr($language, '-utf8')) { |
|
| 1202 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1203 | + } |
|
| 1129 | 1204 | |
| 1130 | 1205 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1131 | 1206 | |
@@ -1133,8 +1208,9 @@ discard block |
||
| 1133 | 1208 | require_once($sourcedir . '/Subs-Admin.php'); |
| 1134 | 1209 | updateSettingsFile($changes); |
| 1135 | 1210 | |
| 1136 | - if ($command_line) |
|
| 1137 | - echo ' Successful.' . "\n"; |
|
| 1211 | + if ($command_line) { |
|
| 1212 | + echo ' Successful.' . "\n"; |
|
| 1213 | + } |
|
| 1138 | 1214 | |
| 1139 | 1215 | // Are we doing debug? |
| 1140 | 1216 | if (isset($_POST['debug'])) |
@@ -1144,8 +1220,9 @@ discard block |
||
| 1144 | 1220 | } |
| 1145 | 1221 | |
| 1146 | 1222 | // If we're not backing up then jump one. |
| 1147 | - if (empty($_POST['backup'])) |
|
| 1148 | - $upcontext['current_step']++; |
|
| 1223 | + if (empty($_POST['backup'])) { |
|
| 1224 | + $upcontext['current_step']++; |
|
| 1225 | + } |
|
| 1149 | 1226 | |
| 1150 | 1227 | // If we've got here then let's proceed to the next step! |
| 1151 | 1228 | return true; |
@@ -1160,8 +1237,9 @@ discard block |
||
| 1160 | 1237 | $upcontext['page_title'] = 'Backup Database'; |
| 1161 | 1238 | |
| 1162 | 1239 | // Done it already - js wise? |
| 1163 | - if (!empty($_POST['backup_done'])) |
|
| 1164 | - return true; |
|
| 1240 | + if (!empty($_POST['backup_done'])) { |
|
| 1241 | + return true; |
|
| 1242 | + } |
|
| 1165 | 1243 | |
| 1166 | 1244 | // Some useful stuff here. |
| 1167 | 1245 | db_extend(); |
@@ -1175,9 +1253,10 @@ discard block |
||
| 1175 | 1253 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1176 | 1254 | |
| 1177 | 1255 | $table_names = array(); |
| 1178 | - foreach ($tables as $table) |
|
| 1179 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1256 | + foreach ($tables as $table) { |
|
| 1257 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1180 | 1258 | $table_names[] = $table; |
| 1259 | + } |
|
| 1181 | 1260 | |
| 1182 | 1261 | $upcontext['table_count'] = count($table_names); |
| 1183 | 1262 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1187,12 +1266,14 @@ discard block |
||
| 1187 | 1266 | $file_steps = $upcontext['table_count']; |
| 1188 | 1267 | |
| 1189 | 1268 | // What ones have we already done? |
| 1190 | - foreach ($table_names as $id => $table) |
|
| 1191 | - if ($id < $_GET['substep']) |
|
| 1269 | + foreach ($table_names as $id => $table) { |
|
| 1270 | + if ($id < $_GET['substep']) |
|
| 1192 | 1271 | $upcontext['previous_tables'][] = $table; |
| 1272 | + } |
|
| 1193 | 1273 | |
| 1194 | - if ($command_line) |
|
| 1195 | - echo 'Backing Up Tables.'; |
|
| 1274 | + if ($command_line) { |
|
| 1275 | + echo 'Backing Up Tables.'; |
|
| 1276 | + } |
|
| 1196 | 1277 | |
| 1197 | 1278 | // If we don't support javascript we backup here. |
| 1198 | 1279 | if (!$support_js || isset($_GET['xml'])) |
@@ -1211,8 +1292,9 @@ discard block |
||
| 1211 | 1292 | backupTable($table_names[$substep]); |
| 1212 | 1293 | |
| 1213 | 1294 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1214 | - if (isset($_GET['xml'])) |
|
| 1215 | - return upgradeExit(); |
|
| 1295 | + if (isset($_GET['xml'])) { |
|
| 1296 | + return upgradeExit(); |
|
| 1297 | + } |
|
| 1216 | 1298 | } |
| 1217 | 1299 | |
| 1218 | 1300 | if ($command_line) |
@@ -1245,9 +1327,10 @@ discard block |
||
| 1245 | 1327 | |
| 1246 | 1328 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1247 | 1329 | |
| 1248 | - if ($command_line) |
|
| 1249 | - echo ' done.'; |
|
| 1250 | -} |
|
| 1330 | + if ($command_line) { |
|
| 1331 | + echo ' done.'; |
|
| 1332 | + } |
|
| 1333 | + } |
|
| 1251 | 1334 | |
| 1252 | 1335 | // Step 2: Everything. |
| 1253 | 1336 | function DatabaseChanges() |
@@ -1256,8 +1339,9 @@ discard block |
||
| 1256 | 1339 | global $upcontext, $support_js, $db_type; |
| 1257 | 1340 | |
| 1258 | 1341 | // Have we just completed this? |
| 1259 | - if (!empty($_POST['database_done'])) |
|
| 1260 | - return true; |
|
| 1342 | + if (!empty($_POST['database_done'])) { |
|
| 1343 | + return true; |
|
| 1344 | + } |
|
| 1261 | 1345 | |
| 1262 | 1346 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1263 | 1347 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1272,15 +1356,16 @@ discard block |
||
| 1272 | 1356 | ); |
| 1273 | 1357 | |
| 1274 | 1358 | // How many files are there in total? |
| 1275 | - if (isset($_GET['filecount'])) |
|
| 1276 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1277 | - else |
|
| 1359 | + if (isset($_GET['filecount'])) { |
|
| 1360 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1361 | + } else |
|
| 1278 | 1362 | { |
| 1279 | 1363 | $upcontext['file_count'] = 0; |
| 1280 | 1364 | foreach ($files as $file) |
| 1281 | 1365 | { |
| 1282 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1283 | - $upcontext['file_count']++; |
|
| 1366 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1367 | + $upcontext['file_count']++; |
|
| 1368 | + } |
|
| 1284 | 1369 | } |
| 1285 | 1370 | } |
| 1286 | 1371 | |
@@ -1290,9 +1375,9 @@ discard block |
||
| 1290 | 1375 | $upcontext['cur_file_num'] = 0; |
| 1291 | 1376 | foreach ($files as $file) |
| 1292 | 1377 | { |
| 1293 | - if ($did_not_do) |
|
| 1294 | - $did_not_do--; |
|
| 1295 | - else |
|
| 1378 | + if ($did_not_do) { |
|
| 1379 | + $did_not_do--; |
|
| 1380 | + } else |
|
| 1296 | 1381 | { |
| 1297 | 1382 | $upcontext['cur_file_num']++; |
| 1298 | 1383 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1319,12 +1404,13 @@ discard block |
||
| 1319 | 1404 | // Flag to move on to the next. |
| 1320 | 1405 | $upcontext['completed_step'] = true; |
| 1321 | 1406 | // Did we complete the whole file? |
| 1322 | - if ($nextFile) |
|
| 1323 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1407 | + if ($nextFile) { |
|
| 1408 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1409 | + } |
|
| 1324 | 1410 | return upgradeExit(); |
| 1411 | + } elseif ($support_js) { |
|
| 1412 | + break; |
|
| 1325 | 1413 | } |
| 1326 | - elseif ($support_js) |
|
| 1327 | - break; |
|
| 1328 | 1414 | } |
| 1329 | 1415 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1330 | 1416 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1349,8 +1435,9 @@ discard block |
||
| 1349 | 1435 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1350 | 1436 | |
| 1351 | 1437 | // Now it's nice to have some of the basic SMF source files. |
| 1352 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1353 | - redirectLocation('&ssi=1'); |
|
| 1438 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1439 | + redirectLocation('&ssi=1'); |
|
| 1440 | + } |
|
| 1354 | 1441 | |
| 1355 | 1442 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1356 | 1443 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1366,14 +1453,16 @@ discard block |
||
| 1366 | 1453 | // Are we in maintenance mode? |
| 1367 | 1454 | if (isset($upcontext['user']['main'])) |
| 1368 | 1455 | { |
| 1369 | - if ($command_line) |
|
| 1370 | - echo ' * '; |
|
| 1456 | + if ($command_line) { |
|
| 1457 | + echo ' * '; |
|
| 1458 | + } |
|
| 1371 | 1459 | $upcontext['removed_maintenance'] = true; |
| 1372 | 1460 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1373 | 1461 | } |
| 1374 | 1462 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1375 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1376 | - $changes['maintenance'] = 1; |
|
| 1463 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1464 | + $changes['maintenance'] = 1; |
|
| 1465 | + } |
|
| 1377 | 1466 | |
| 1378 | 1467 | // Wipe this out... |
| 1379 | 1468 | $upcontext['user'] = array(); |
@@ -1388,9 +1477,9 @@ discard block |
||
| 1388 | 1477 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1389 | 1478 | |
| 1390 | 1479 | // Now is the perfect time to fetch the SM files. |
| 1391 | - if ($command_line) |
|
| 1392 | - cli_scheduled_fetchSMfiles(); |
|
| 1393 | - else |
|
| 1480 | + if ($command_line) { |
|
| 1481 | + cli_scheduled_fetchSMfiles(); |
|
| 1482 | + } else |
|
| 1394 | 1483 | { |
| 1395 | 1484 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1396 | 1485 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1398,8 +1487,9 @@ discard block |
||
| 1398 | 1487 | } |
| 1399 | 1488 | |
| 1400 | 1489 | // Log what we've done. |
| 1401 | - if (empty($user_info['id'])) |
|
| 1402 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1490 | + if (empty($user_info['id'])) { |
|
| 1491 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1492 | + } |
|
| 1403 | 1493 | |
| 1404 | 1494 | // Log the action manually, so CLI still works. |
| 1405 | 1495 | $smcFunc['db_insert']('', |
@@ -1418,8 +1508,9 @@ discard block |
||
| 1418 | 1508 | |
| 1419 | 1509 | // Save the current database version. |
| 1420 | 1510 | $server_version = $smcFunc['db_server_info'](); |
| 1421 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1422 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1511 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1512 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1513 | + } |
|
| 1423 | 1514 | |
| 1424 | 1515 | if ($command_line) |
| 1425 | 1516 | { |
@@ -1431,8 +1522,9 @@ discard block |
||
| 1431 | 1522 | |
| 1432 | 1523 | // Make sure it says we're done. |
| 1433 | 1524 | $upcontext['overall_percent'] = 100; |
| 1434 | - if (isset($upcontext['step_progress'])) |
|
| 1435 | - unset($upcontext['step_progress']); |
|
| 1525 | + if (isset($upcontext['step_progress'])) { |
|
| 1526 | + unset($upcontext['step_progress']); |
|
| 1527 | + } |
|
| 1436 | 1528 | |
| 1437 | 1529 | $_GET['substep'] = 0; |
| 1438 | 1530 | return false; |
@@ -1443,8 +1535,9 @@ discard block |
||
| 1443 | 1535 | { |
| 1444 | 1536 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1445 | 1537 | |
| 1446 | - if (empty($modSettings['time_format'])) |
|
| 1447 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1538 | + if (empty($modSettings['time_format'])) { |
|
| 1539 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1540 | + } |
|
| 1448 | 1541 | |
| 1449 | 1542 | // What files do we want to get |
| 1450 | 1543 | $request = $smcFunc['db_query']('', ' |
@@ -1478,8 +1571,9 @@ discard block |
||
| 1478 | 1571 | $file_data = fetch_web_data($url); |
| 1479 | 1572 | |
| 1480 | 1573 | // If we got an error - give up - the site might be down. |
| 1481 | - if ($file_data === false) |
|
| 1482 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1574 | + if ($file_data === false) { |
|
| 1575 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1576 | + } |
|
| 1483 | 1577 | |
| 1484 | 1578 | // Save the file to the database. |
| 1485 | 1579 | $smcFunc['db_query']('substring', ' |
@@ -1521,8 +1615,9 @@ discard block |
||
| 1521 | 1615 | $themeData = array(); |
| 1522 | 1616 | foreach ($values as $variable => $value) |
| 1523 | 1617 | { |
| 1524 | - if (!isset($value) || $value === null) |
|
| 1525 | - $value = 0; |
|
| 1618 | + if (!isset($value) || $value === null) { |
|
| 1619 | + $value = 0; |
|
| 1620 | + } |
|
| 1526 | 1621 | |
| 1527 | 1622 | $themeData[] = array(0, 1, $variable, $value); |
| 1528 | 1623 | } |
@@ -1551,8 +1646,9 @@ discard block |
||
| 1551 | 1646 | |
| 1552 | 1647 | foreach ($values as $variable => $value) |
| 1553 | 1648 | { |
| 1554 | - if (empty($modSettings[$value[0]])) |
|
| 1555 | - continue; |
|
| 1649 | + if (empty($modSettings[$value[0]])) { |
|
| 1650 | + continue; |
|
| 1651 | + } |
|
| 1556 | 1652 | |
| 1557 | 1653 | $smcFunc['db_query']('', ' |
| 1558 | 1654 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1638,19 +1734,21 @@ discard block |
||
| 1638 | 1734 | set_error_handler( |
| 1639 | 1735 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1640 | 1736 | { |
| 1641 | - if ($support_js) |
|
| 1642 | - return true; |
|
| 1643 | - else |
|
| 1644 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1737 | + if ($support_js) { |
|
| 1738 | + return true; |
|
| 1739 | + } else { |
|
| 1740 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1741 | + } |
|
| 1645 | 1742 | } |
| 1646 | 1743 | ); |
| 1647 | 1744 | |
| 1648 | 1745 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1649 | 1746 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1650 | - if ($db_type == 'mysql') |
|
| 1651 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1652 | - else |
|
| 1653 | - $db_collation = ''; |
|
| 1747 | + if ($db_type == 'mysql') { |
|
| 1748 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1749 | + } else { |
|
| 1750 | + $db_collation = ''; |
|
| 1751 | + } |
|
| 1654 | 1752 | |
| 1655 | 1753 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1656 | 1754 | |
@@ -1662,8 +1760,9 @@ discard block |
||
| 1662 | 1760 | $last_step = ''; |
| 1663 | 1761 | |
| 1664 | 1762 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1665 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1666 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1763 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1764 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1765 | + } |
|
| 1667 | 1766 | |
| 1668 | 1767 | // Count the total number of steps within this file - for progress. |
| 1669 | 1768 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1683,15 +1782,18 @@ discard block |
||
| 1683 | 1782 | $do_current = $substep >= $_GET['substep']; |
| 1684 | 1783 | |
| 1685 | 1784 | // Get rid of any comments in the beginning of the line... |
| 1686 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1687 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1785 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1786 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1787 | + } |
|
| 1688 | 1788 | |
| 1689 | 1789 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1690 | - if ($is_debug && !$support_js && $command_line) |
|
| 1691 | - flush(); |
|
| 1790 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1791 | + flush(); |
|
| 1792 | + } |
|
| 1692 | 1793 | |
| 1693 | - if (trim($line) === '') |
|
| 1694 | - continue; |
|
| 1794 | + if (trim($line) === '') { |
|
| 1795 | + continue; |
|
| 1796 | + } |
|
| 1695 | 1797 | |
| 1696 | 1798 | if (trim(substr($line, 0, 3)) === '---') |
| 1697 | 1799 | { |
@@ -1701,8 +1803,9 @@ discard block |
||
| 1701 | 1803 | if (trim($current_data) != '' && $type !== '}') |
| 1702 | 1804 | { |
| 1703 | 1805 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1704 | - if ($command_line) |
|
| 1705 | - echo $upcontext['error_message']; |
|
| 1806 | + if ($command_line) { |
|
| 1807 | + echo $upcontext['error_message']; |
|
| 1808 | + } |
|
| 1706 | 1809 | } |
| 1707 | 1810 | |
| 1708 | 1811 | if ($type == ' ') |
@@ -1720,17 +1823,18 @@ discard block |
||
| 1720 | 1823 | if ($do_current) |
| 1721 | 1824 | { |
| 1722 | 1825 | $upcontext['actioned_items'][] = $last_step; |
| 1723 | - if ($command_line) |
|
| 1724 | - echo ' * '; |
|
| 1826 | + if ($command_line) { |
|
| 1827 | + echo ' * '; |
|
| 1828 | + } |
|
| 1725 | 1829 | } |
| 1726 | - } |
|
| 1727 | - elseif ($type == '#') |
|
| 1830 | + } elseif ($type == '#') |
|
| 1728 | 1831 | { |
| 1729 | 1832 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1730 | 1833 | |
| 1731 | 1834 | $upcontext['current_debug_item_num']++; |
| 1732 | - if (trim($line) != '---#') |
|
| 1733 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1835 | + if (trim($line) != '---#') { |
|
| 1836 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1837 | + } |
|
| 1734 | 1838 | |
| 1735 | 1839 | // Have we already done something? |
| 1736 | 1840 | if (isset($_GET['xml']) && $done_something) |
@@ -1741,34 +1845,36 @@ discard block |
||
| 1741 | 1845 | |
| 1742 | 1846 | if ($do_current) |
| 1743 | 1847 | { |
| 1744 | - if (trim($line) == '---#' && $command_line) |
|
| 1745 | - echo ' done.', $endl; |
|
| 1746 | - elseif ($command_line) |
|
| 1747 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1748 | - elseif (trim($line) != '---#') |
|
| 1848 | + if (trim($line) == '---#' && $command_line) { |
|
| 1849 | + echo ' done.', $endl; |
|
| 1850 | + } elseif ($command_line) { |
|
| 1851 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1852 | + } elseif (trim($line) != '---#') |
|
| 1749 | 1853 | { |
| 1750 | - if ($is_debug) |
|
| 1751 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1854 | + if ($is_debug) { |
|
| 1855 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1856 | + } |
|
| 1752 | 1857 | } |
| 1753 | 1858 | } |
| 1754 | 1859 | |
| 1755 | 1860 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1756 | 1861 | { |
| 1757 | - if ($command_line) |
|
| 1758 | - echo ' * '; |
|
| 1759 | - else |
|
| 1760 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1862 | + if ($command_line) { |
|
| 1863 | + echo ' * '; |
|
| 1864 | + } else { |
|
| 1865 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1866 | + } |
|
| 1761 | 1867 | } |
| 1762 | 1868 | |
| 1763 | 1869 | // Small step - only if we're actually doing stuff. |
| 1764 | - if ($do_current) |
|
| 1765 | - nextSubstep(++$substep); |
|
| 1766 | - else |
|
| 1767 | - $substep++; |
|
| 1768 | - } |
|
| 1769 | - elseif ($type == '{') |
|
| 1770 | - $current_type = 'code'; |
|
| 1771 | - elseif ($type == '}') |
|
| 1870 | + if ($do_current) { |
|
| 1871 | + nextSubstep(++$substep); |
|
| 1872 | + } else { |
|
| 1873 | + $substep++; |
|
| 1874 | + } |
|
| 1875 | + } elseif ($type == '{') { |
|
| 1876 | + $current_type = 'code'; |
|
| 1877 | + } elseif ($type == '}') |
|
| 1772 | 1878 | { |
| 1773 | 1879 | $current_type = 'sql'; |
| 1774 | 1880 | |
@@ -1781,8 +1887,9 @@ discard block |
||
| 1781 | 1887 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1782 | 1888 | { |
| 1783 | 1889 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1784 | - if ($command_line) |
|
| 1785 | - echo $upcontext['error_message']; |
|
| 1890 | + if ($command_line) { |
|
| 1891 | + echo $upcontext['error_message']; |
|
| 1892 | + } |
|
| 1786 | 1893 | } |
| 1787 | 1894 | |
| 1788 | 1895 | // Done with code! |
@@ -1862,8 +1969,9 @@ discard block |
||
| 1862 | 1969 | $db_unbuffered = false; |
| 1863 | 1970 | |
| 1864 | 1971 | // Failure?! |
| 1865 | - if ($result !== false) |
|
| 1866 | - return $result; |
|
| 1972 | + if ($result !== false) { |
|
| 1973 | + return $result; |
|
| 1974 | + } |
|
| 1867 | 1975 | |
| 1868 | 1976 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1869 | 1977 | // If MySQL we do something more clever. |
@@ -1891,54 +1999,61 @@ discard block |
||
| 1891 | 1999 | { |
| 1892 | 2000 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 1893 | 2001 | $result = mysqli_query($db_connection, $string); |
| 1894 | - if ($result !== false) |
|
| 1895 | - return $result; |
|
| 2002 | + if ($result !== false) { |
|
| 2003 | + return $result; |
|
| 2004 | + } |
|
| 1896 | 2005 | } |
| 1897 | - } |
|
| 1898 | - elseif ($mysqli_errno == 2013) |
|
| 2006 | + } elseif ($mysqli_errno == 2013) |
|
| 1899 | 2007 | { |
| 1900 | 2008 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 1901 | 2009 | mysqli_select_db($db_connection, $db_name); |
| 1902 | 2010 | if ($db_connection) |
| 1903 | 2011 | { |
| 1904 | 2012 | $result = mysqli_query($db_connection, $string); |
| 1905 | - if ($result !== false) |
|
| 1906 | - return $result; |
|
| 2013 | + if ($result !== false) { |
|
| 2014 | + return $result; |
|
| 2015 | + } |
|
| 1907 | 2016 | } |
| 1908 | 2017 | } |
| 1909 | 2018 | // Duplicate column name... should be okay ;). |
| 1910 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 1911 | - return false; |
|
| 2019 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2020 | + return false; |
|
| 2021 | + } |
|
| 1912 | 2022 | // Duplicate insert... make sure it's the proper type of query ;). |
| 1913 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 1914 | - return false; |
|
| 2023 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2024 | + return false; |
|
| 2025 | + } |
|
| 1915 | 2026 | // Creating an index on a non-existent column. |
| 1916 | - elseif ($mysqli_errno == 1072) |
|
| 1917 | - return false; |
|
| 1918 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 1919 | - return false; |
|
| 2027 | + elseif ($mysqli_errno == 1072) { |
|
| 2028 | + return false; |
|
| 2029 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2030 | + return false; |
|
| 2031 | + } |
|
| 1920 | 2032 | } |
| 1921 | 2033 | // If a table already exists don't go potty. |
| 1922 | 2034 | else |
| 1923 | 2035 | { |
| 1924 | 2036 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 1925 | 2037 | { |
| 1926 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 1927 | - return true; |
|
| 1928 | - } |
|
| 1929 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2038 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2039 | + return true; |
|
| 2040 | + } |
|
| 2041 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 1930 | 2042 | { |
| 1931 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 1932 | - return true; |
|
| 2043 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2044 | + return true; |
|
| 2045 | + } |
|
| 1933 | 2046 | } |
| 1934 | 2047 | } |
| 1935 | 2048 | |
| 1936 | 2049 | // Get the query string so we pass everything. |
| 1937 | 2050 | $query_string = ''; |
| 1938 | - foreach ($_GET as $k => $v) |
|
| 1939 | - $query_string .= ';' . $k . '=' . $v; |
|
| 1940 | - if (strlen($query_string) != 0) |
|
| 1941 | - $query_string = '?' . substr($query_string, 1); |
|
| 2051 | + foreach ($_GET as $k => $v) { |
|
| 2052 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2053 | + } |
|
| 2054 | + if (strlen($query_string) != 0) { |
|
| 2055 | + $query_string = '?' . substr($query_string, 1); |
|
| 2056 | + } |
|
| 1942 | 2057 | |
| 1943 | 2058 | if ($command_line) |
| 1944 | 2059 | { |
@@ -1993,16 +2108,18 @@ discard block |
||
| 1993 | 2108 | { |
| 1994 | 2109 | $found |= 1; |
| 1995 | 2110 | // Do some checks on the data if we have it set. |
| 1996 | - if (isset($change['col_type'])) |
|
| 1997 | - $found &= $change['col_type'] === $column['type']; |
|
| 1998 | - if (isset($change['null_allowed'])) |
|
| 1999 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2000 | - if (isset($change['default'])) |
|
| 2001 | - $found &= $change['default'] === $column['default']; |
|
| 2111 | + if (isset($change['col_type'])) { |
|
| 2112 | + $found &= $change['col_type'] === $column['type']; |
|
| 2113 | + } |
|
| 2114 | + if (isset($change['null_allowed'])) { |
|
| 2115 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2116 | + } |
|
| 2117 | + if (isset($change['default'])) { |
|
| 2118 | + $found &= $change['default'] === $column['default']; |
|
| 2119 | + } |
|
| 2002 | 2120 | } |
| 2003 | 2121 | } |
| 2004 | - } |
|
| 2005 | - elseif ($change['type'] === 'index') |
|
| 2122 | + } elseif ($change['type'] === 'index') |
|
| 2006 | 2123 | { |
| 2007 | 2124 | $request = upgrade_query(' |
| 2008 | 2125 | SHOW INDEX |
@@ -2011,9 +2128,10 @@ discard block |
||
| 2011 | 2128 | { |
| 2012 | 2129 | $cur_index = array(); |
| 2013 | 2130 | |
| 2014 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2015 | - if ($row['Key_name'] === $change['name']) |
|
| 2131 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2132 | + if ($row['Key_name'] === $change['name']) |
|
| 2016 | 2133 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2134 | + } |
|
| 2017 | 2135 | |
| 2018 | 2136 | ksort($cur_index, SORT_NUMERIC); |
| 2019 | 2137 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2023,14 +2141,17 @@ discard block |
||
| 2023 | 2141 | } |
| 2024 | 2142 | |
| 2025 | 2143 | // If we're trying to add and it's added, we're done. |
| 2026 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2027 | - return true; |
|
| 2144 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2145 | + return true; |
|
| 2146 | + } |
|
| 2028 | 2147 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2029 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2030 | - return true; |
|
| 2148 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2149 | + return true; |
|
| 2150 | + } |
|
| 2031 | 2151 | // Otherwise is it just a test? |
| 2032 | - elseif ($is_test) |
|
| 2033 | - return false; |
|
| 2152 | + elseif ($is_test) { |
|
| 2153 | + return false; |
|
| 2154 | + } |
|
| 2034 | 2155 | |
| 2035 | 2156 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2036 | 2157 | $running = false; |
@@ -2041,8 +2162,9 @@ discard block |
||
| 2041 | 2162 | SHOW FULL PROCESSLIST'); |
| 2042 | 2163 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2043 | 2164 | { |
| 2044 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2045 | - $found = true; |
|
| 2165 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2166 | + $found = true; |
|
| 2167 | + } |
|
| 2046 | 2168 | } |
| 2047 | 2169 | |
| 2048 | 2170 | // Can't find it? Then we need to run it fools! |
@@ -2054,8 +2176,9 @@ discard block |
||
| 2054 | 2176 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2055 | 2177 | ' . $change['text'], true) !== false; |
| 2056 | 2178 | |
| 2057 | - if (!$success) |
|
| 2058 | - return false; |
|
| 2179 | + if (!$success) { |
|
| 2180 | + return false; |
|
| 2181 | + } |
|
| 2059 | 2182 | |
| 2060 | 2183 | // Return |
| 2061 | 2184 | $running = true; |
@@ -2097,8 +2220,9 @@ discard block |
||
| 2097 | 2220 | 'db_error_skip' => true, |
| 2098 | 2221 | ) |
| 2099 | 2222 | ); |
| 2100 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2101 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2223 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2224 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2225 | + } |
|
| 2102 | 2226 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2103 | 2227 | $smcFunc['db_free_result']($request); |
| 2104 | 2228 | |
@@ -2120,18 +2244,19 @@ discard block |
||
| 2120 | 2244 | ) |
| 2121 | 2245 | ); |
| 2122 | 2246 | // No results? Just forget it all together. |
| 2123 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2124 | - unset($table_row['Collation']); |
|
| 2125 | - else |
|
| 2126 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2247 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2248 | + unset($table_row['Collation']); |
|
| 2249 | + } else { |
|
| 2250 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2251 | + } |
|
| 2127 | 2252 | $smcFunc['db_free_result']($request); |
| 2128 | 2253 | } |
| 2129 | 2254 | |
| 2130 | 2255 | if ($column_fix) |
| 2131 | 2256 | { |
| 2132 | 2257 | // Make sure there are no NULL's left. |
| 2133 | - if ($null_fix) |
|
| 2134 | - $smcFunc['db_query']('', ' |
|
| 2258 | + if ($null_fix) { |
|
| 2259 | + $smcFunc['db_query']('', ' |
|
| 2135 | 2260 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2136 | 2261 | SET ' . $change['column'] . ' = {string:default} |
| 2137 | 2262 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2140,6 +2265,7 @@ discard block |
||
| 2140 | 2265 | 'db_error_skip' => true, |
| 2141 | 2266 | ) |
| 2142 | 2267 | ); |
| 2268 | + } |
|
| 2143 | 2269 | |
| 2144 | 2270 | // Do the actual alteration. |
| 2145 | 2271 | $smcFunc['db_query']('', ' |
@@ -2168,8 +2294,9 @@ discard block |
||
| 2168 | 2294 | } |
| 2169 | 2295 | |
| 2170 | 2296 | // Not a column we need to check on? |
| 2171 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2172 | - return; |
|
| 2297 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2298 | + return; |
|
| 2299 | + } |
|
| 2173 | 2300 | |
| 2174 | 2301 | // Break it up you (six|seven). |
| 2175 | 2302 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2188,13 +2315,13 @@ discard block |
||
| 2188 | 2315 | 'new_name' => $temp[2], |
| 2189 | 2316 | )); |
| 2190 | 2317 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2191 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2192 | - return; |
|
| 2318 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2319 | + return; |
|
| 2320 | + } |
|
| 2193 | 2321 | |
| 2194 | 2322 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2195 | 2323 | $smcFunc['db_free_result']($request); |
| 2196 | - } |
|
| 2197 | - else |
|
| 2324 | + } else |
|
| 2198 | 2325 | { |
| 2199 | 2326 | // Do this the old fashion, sure method way. |
| 2200 | 2327 | $request = $smcFunc['db_query']('', ' |
@@ -2205,21 +2332,24 @@ discard block |
||
| 2205 | 2332 | )); |
| 2206 | 2333 | // Mayday! |
| 2207 | 2334 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2208 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2209 | - return; |
|
| 2335 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2336 | + return; |
|
| 2337 | + } |
|
| 2210 | 2338 | |
| 2211 | 2339 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2212 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2213 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2340 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2341 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2214 | 2342 | { |
| 2215 | 2343 | $current_type = $row['Type']; |
| 2344 | + } |
|
| 2216 | 2345 | break; |
| 2217 | 2346 | } |
| 2218 | 2347 | } |
| 2219 | 2348 | |
| 2220 | 2349 | // If this doesn't match, the column may of been altered for a reason. |
| 2221 | - if (trim($current_type) != trim($temp[3])) |
|
| 2222 | - $temp[3] = $current_type; |
|
| 2350 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2351 | + $temp[3] = $current_type; |
|
| 2352 | + } |
|
| 2223 | 2353 | |
| 2224 | 2354 | // Piece this back together. |
| 2225 | 2355 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2231,8 +2361,9 @@ discard block |
||
| 2231 | 2361 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2232 | 2362 | global $step_progress, $is_debug, $upcontext; |
| 2233 | 2363 | |
| 2234 | - if ($_GET['substep'] < $substep) |
|
| 2235 | - $_GET['substep'] = $substep; |
|
| 2364 | + if ($_GET['substep'] < $substep) { |
|
| 2365 | + $_GET['substep'] = $substep; |
|
| 2366 | + } |
|
| 2236 | 2367 | |
| 2237 | 2368 | if ($command_line) |
| 2238 | 2369 | { |
@@ -2245,29 +2376,33 @@ discard block |
||
| 2245 | 2376 | } |
| 2246 | 2377 | |
| 2247 | 2378 | @set_time_limit(300); |
| 2248 | - if (function_exists('apache_reset_timeout')) |
|
| 2249 | - @apache_reset_timeout(); |
|
| 2379 | + if (function_exists('apache_reset_timeout')) { |
|
| 2380 | + @apache_reset_timeout(); |
|
| 2381 | + } |
|
| 2250 | 2382 | |
| 2251 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2252 | - return; |
|
| 2383 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2384 | + return; |
|
| 2385 | + } |
|
| 2253 | 2386 | |
| 2254 | 2387 | // Do we have some custom step progress stuff? |
| 2255 | 2388 | if (!empty($step_progress)) |
| 2256 | 2389 | { |
| 2257 | 2390 | $upcontext['substep_progress'] = 0; |
| 2258 | 2391 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2259 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2260 | - $upcontext['substep_progress'] = 99.9; |
|
| 2261 | - else |
|
| 2262 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2392 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2393 | + $upcontext['substep_progress'] = 99.9; |
|
| 2394 | + } else { |
|
| 2395 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2396 | + } |
|
| 2263 | 2397 | |
| 2264 | 2398 | // Make it nicely rounded. |
| 2265 | 2399 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2266 | 2400 | } |
| 2267 | 2401 | |
| 2268 | 2402 | // If this is XML we just exit right away! |
| 2269 | - if (isset($_GET['xml'])) |
|
| 2270 | - return upgradeExit(); |
|
| 2403 | + if (isset($_GET['xml'])) { |
|
| 2404 | + return upgradeExit(); |
|
| 2405 | + } |
|
| 2271 | 2406 | |
| 2272 | 2407 | // We're going to pause after this! |
| 2273 | 2408 | $upcontext['pause'] = true; |
@@ -2275,13 +2410,15 @@ discard block |
||
| 2275 | 2410 | $upcontext['query_string'] = ''; |
| 2276 | 2411 | foreach ($_GET as $k => $v) |
| 2277 | 2412 | { |
| 2278 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2279 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2413 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2414 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2415 | + } |
|
| 2280 | 2416 | } |
| 2281 | 2417 | |
| 2282 | 2418 | // Custom warning? |
| 2283 | - if (!empty($custom_warning)) |
|
| 2284 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2419 | + if (!empty($custom_warning)) { |
|
| 2420 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2421 | + } |
|
| 2285 | 2422 | |
| 2286 | 2423 | upgradeExit(); |
| 2287 | 2424 | } |
@@ -2296,25 +2433,26 @@ discard block |
||
| 2296 | 2433 | ob_implicit_flush(true); |
| 2297 | 2434 | @set_time_limit(600); |
| 2298 | 2435 | |
| 2299 | - if (!isset($_SERVER['argv'])) |
|
| 2300 | - $_SERVER['argv'] = array(); |
|
| 2436 | + if (!isset($_SERVER['argv'])) { |
|
| 2437 | + $_SERVER['argv'] = array(); |
|
| 2438 | + } |
|
| 2301 | 2439 | $_GET['maint'] = 1; |
| 2302 | 2440 | |
| 2303 | 2441 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2304 | 2442 | { |
| 2305 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2306 | - $_GET['lang'] = $match[1]; |
|
| 2307 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2308 | - continue; |
|
| 2309 | - elseif ($arg == '--no-maintenance') |
|
| 2310 | - $_GET['maint'] = 0; |
|
| 2311 | - elseif ($arg == '--debug') |
|
| 2312 | - $is_debug = true; |
|
| 2313 | - elseif ($arg == '--backup') |
|
| 2314 | - $_POST['backup'] = 1; |
|
| 2315 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2316 | - $_GET['conv'] = 1; |
|
| 2317 | - elseif ($i != 0) |
|
| 2443 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2444 | + $_GET['lang'] = $match[1]; |
|
| 2445 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2446 | + continue; |
|
| 2447 | + } elseif ($arg == '--no-maintenance') { |
|
| 2448 | + $_GET['maint'] = 0; |
|
| 2449 | + } elseif ($arg == '--debug') { |
|
| 2450 | + $is_debug = true; |
|
| 2451 | + } elseif ($arg == '--backup') { |
|
| 2452 | + $_POST['backup'] = 1; |
|
| 2453 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2454 | + $_GET['conv'] = 1; |
|
| 2455 | + } elseif ($i != 0) |
|
| 2318 | 2456 | { |
| 2319 | 2457 | echo 'SMF Command-line Upgrader |
| 2320 | 2458 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2328,10 +2466,12 @@ discard block |
||
| 2328 | 2466 | } |
| 2329 | 2467 | } |
| 2330 | 2468 | |
| 2331 | - if (!php_version_check()) |
|
| 2332 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2333 | - if (!db_version_check()) |
|
| 2334 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2469 | + if (!php_version_check()) { |
|
| 2470 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2471 | + } |
|
| 2472 | + if (!db_version_check()) { |
|
| 2473 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2474 | + } |
|
| 2335 | 2475 | |
| 2336 | 2476 | // Do some checks to make sure they have proper privileges |
| 2337 | 2477 | db_extend('packages'); |
@@ -2346,34 +2486,39 @@ discard block |
||
| 2346 | 2486 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2347 | 2487 | |
| 2348 | 2488 | // Sorry... we need CREATE, ALTER and DROP |
| 2349 | - if (!$create || !$alter || !$drop) |
|
| 2350 | - 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); |
|
| 2489 | + if (!$create || !$alter || !$drop) { |
|
| 2490 | + 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); |
|
| 2491 | + } |
|
| 2351 | 2492 | |
| 2352 | 2493 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2353 | 2494 | && @file_exists($sourcedir . '/QueryString.php') |
| 2354 | 2495 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2355 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2356 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2496 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2497 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2498 | + } |
|
| 2357 | 2499 | |
| 2358 | 2500 | // Do a quick version spot check. |
| 2359 | 2501 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2360 | 2502 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2361 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2362 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2503 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2504 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2505 | + } |
|
| 2363 | 2506 | |
| 2364 | 2507 | // Make sure Settings.php is writable. |
| 2365 | 2508 | quickFileWritable($boarddir . '/Settings.php'); |
| 2366 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2367 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2509 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2510 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2511 | + } |
|
| 2368 | 2512 | |
| 2369 | 2513 | // Make sure Settings_bak.php is writable. |
| 2370 | 2514 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2371 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2372 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2515 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2516 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2517 | + } |
|
| 2373 | 2518 | |
| 2374 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2375 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2376 | - elseif (isset($modSettings['agreement'])) |
|
| 2519 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2520 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2521 | + } elseif (isset($modSettings['agreement'])) |
|
| 2377 | 2522 | { |
| 2378 | 2523 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2379 | 2524 | fwrite($fp, $modSettings['agreement']); |
@@ -2383,31 +2528,36 @@ discard block |
||
| 2383 | 2528 | // Make sure Themes is writable. |
| 2384 | 2529 | quickFileWritable($modSettings['theme_dir']); |
| 2385 | 2530 | |
| 2386 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2387 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2531 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2532 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2533 | + } |
|
| 2388 | 2534 | |
| 2389 | 2535 | // Make sure cache directory exists and is writable! |
| 2390 | 2536 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2391 | - if (!file_exists($cachedir_temp)) |
|
| 2392 | - @mkdir($cachedir_temp); |
|
| 2537 | + if (!file_exists($cachedir_temp)) { |
|
| 2538 | + @mkdir($cachedir_temp); |
|
| 2539 | + } |
|
| 2393 | 2540 | |
| 2394 | 2541 | // Make sure the cache temp dir is writable. |
| 2395 | 2542 | quickFileWritable($cachedir_temp); |
| 2396 | 2543 | |
| 2397 | - if (!is_writable($cachedir_temp)) |
|
| 2398 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2544 | + if (!is_writable($cachedir_temp)) { |
|
| 2545 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2546 | + } |
|
| 2399 | 2547 | |
| 2400 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2401 | - print_error('Error: Unable to find language files!', true); |
|
| 2402 | - else |
|
| 2548 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2549 | + print_error('Error: Unable to find language files!', true); |
|
| 2550 | + } else |
|
| 2403 | 2551 | { |
| 2404 | 2552 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2405 | 2553 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2406 | 2554 | |
| 2407 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2408 | - print_error('Error: Language files out of date.', true); |
|
| 2409 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2410 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2555 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2556 | + print_error('Error: Language files out of date.', true); |
|
| 2557 | + } |
|
| 2558 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2559 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2560 | + } |
|
| 2411 | 2561 | |
| 2412 | 2562 | // Otherwise include it! |
| 2413 | 2563 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2426,8 +2576,9 @@ discard block |
||
| 2426 | 2576 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
| 2427 | 2577 | |
| 2428 | 2578 | // Done it already? |
| 2429 | - if (!empty($_POST['utf8_done'])) |
|
| 2430 | - return true; |
|
| 2579 | + if (!empty($_POST['utf8_done'])) { |
|
| 2580 | + return true; |
|
| 2581 | + } |
|
| 2431 | 2582 | |
| 2432 | 2583 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2433 | 2584 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2440,8 +2591,7 @@ discard block |
||
| 2440 | 2591 | ); |
| 2441 | 2592 | |
| 2442 | 2593 | return true; |
| 2443 | - } |
|
| 2444 | - else |
|
| 2594 | + } else |
|
| 2445 | 2595 | { |
| 2446 | 2596 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2447 | 2597 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2485,8 +2635,9 @@ discard block |
||
| 2485 | 2635 | ) |
| 2486 | 2636 | ); |
| 2487 | 2637 | $db_charsets = array(); |
| 2488 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2489 | - $db_charsets[] = $row['Charset']; |
|
| 2638 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2639 | + $db_charsets[] = $row['Charset']; |
|
| 2640 | + } |
|
| 2490 | 2641 | |
| 2491 | 2642 | $smcFunc['db_free_result']($request); |
| 2492 | 2643 | |
@@ -2522,13 +2673,15 @@ discard block |
||
| 2522 | 2673 | // If there's a fulltext index, we need to drop it first... |
| 2523 | 2674 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2524 | 2675 | { |
| 2525 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2526 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2676 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2677 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2527 | 2678 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2679 | + } |
|
| 2528 | 2680 | $smcFunc['db_free_result']($request); |
| 2529 | 2681 | |
| 2530 | - if (isset($upcontext['fulltext_index'])) |
|
| 2531 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2682 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2683 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2684 | + } |
|
| 2532 | 2685 | } |
| 2533 | 2686 | |
| 2534 | 2687 | // Drop it and make a note... |
@@ -2718,8 +2871,9 @@ discard block |
||
| 2718 | 2871 | $replace = '%field%'; |
| 2719 | 2872 | |
| 2720 | 2873 | // Build a huge REPLACE statement... |
| 2721 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2722 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2874 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 2875 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2876 | + } |
|
| 2723 | 2877 | } |
| 2724 | 2878 | |
| 2725 | 2879 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2729,9 +2883,10 @@ discard block |
||
| 2729 | 2883 | $upcontext['table_count'] = count($queryTables); |
| 2730 | 2884 | |
| 2731 | 2885 | // What ones have we already done? |
| 2732 | - foreach ($queryTables as $id => $table) |
|
| 2733 | - if ($id < $_GET['substep']) |
|
| 2886 | + foreach ($queryTables as $id => $table) { |
|
| 2887 | + if ($id < $_GET['substep']) |
|
| 2734 | 2888 | $upcontext['previous_tables'][] = $table; |
| 2889 | + } |
|
| 2735 | 2890 | |
| 2736 | 2891 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2737 | 2892 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2768,8 +2923,9 @@ discard block |
||
| 2768 | 2923 | nextSubstep($substep); |
| 2769 | 2924 | |
| 2770 | 2925 | // Just to make sure it doesn't time out. |
| 2771 | - if (function_exists('apache_reset_timeout')) |
|
| 2772 | - @apache_reset_timeout(); |
|
| 2926 | + if (function_exists('apache_reset_timeout')) { |
|
| 2927 | + @apache_reset_timeout(); |
|
| 2928 | + } |
|
| 2773 | 2929 | |
| 2774 | 2930 | $table_charsets = array(); |
| 2775 | 2931 | |
@@ -2792,8 +2948,9 @@ discard block |
||
| 2792 | 2948 | |
| 2793 | 2949 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2794 | 2950 | if ($charset != 'utf8') { |
| 2795 | - if (!isset($table_charsets[$charset])) |
|
| 2796 | - $table_charsets[$charset] = array(); |
|
| 2951 | + if (!isset($table_charsets[$charset])) { |
|
| 2952 | + $table_charsets[$charset] = array(); |
|
| 2953 | + } |
|
| 2797 | 2954 | |
| 2798 | 2955 | $table_charsets[$charset][] = $column_info; |
| 2799 | 2956 | } |
@@ -2834,10 +2991,11 @@ discard block |
||
| 2834 | 2991 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2835 | 2992 | { |
| 2836 | 2993 | $update = ''; |
| 2837 | - foreach ($table_charsets as $charset => $columns) |
|
| 2838 | - foreach ($columns as $column) |
|
| 2994 | + foreach ($table_charsets as $charset => $columns) { |
|
| 2995 | + foreach ($columns as $column) |
|
| 2839 | 2996 | $update .= ' |
| 2840 | 2997 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 2998 | + } |
|
| 2841 | 2999 | |
| 2842 | 3000 | $smcFunc['db_query']('', ' |
| 2843 | 3001 | UPDATE {raw:table_name} |
@@ -2862,8 +3020,9 @@ discard block |
||
| 2862 | 3020 | // Now do the actual conversion (if still needed). |
| 2863 | 3021 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2864 | 3022 | { |
| 2865 | - if ($command_line) |
|
| 2866 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3023 | + if ($command_line) { |
|
| 3024 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3025 | + } |
|
| 2867 | 3026 | |
| 2868 | 3027 | $smcFunc['db_query']('', ' |
| 2869 | 3028 | ALTER TABLE {raw:table_name} |
@@ -2873,12 +3032,14 @@ discard block |
||
| 2873 | 3032 | ) |
| 2874 | 3033 | ); |
| 2875 | 3034 | |
| 2876 | - if ($command_line) |
|
| 2877 | - echo " done.\n"; |
|
| 3035 | + if ($command_line) { |
|
| 3036 | + echo " done.\n"; |
|
| 3037 | + } |
|
| 2878 | 3038 | } |
| 2879 | 3039 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 2880 | - if (isset($_GET['xml'])) |
|
| 2881 | - return upgradeExit(); |
|
| 3040 | + if (isset($_GET['xml'])) { |
|
| 3041 | + return upgradeExit(); |
|
| 3042 | + } |
|
| 2882 | 3043 | } |
| 2883 | 3044 | |
| 2884 | 3045 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2907,8 +3068,8 @@ discard block |
||
| 2907 | 3068 | ); |
| 2908 | 3069 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2909 | 3070 | { |
| 2910 | - 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) |
|
| 2911 | - $smcFunc['db_query']('', ' |
|
| 3071 | + 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) { |
|
| 3072 | + $smcFunc['db_query']('', ' |
|
| 2912 | 3073 | UPDATE {db_prefix}log_actions |
| 2913 | 3074 | SET extra = {string:extra} |
| 2914 | 3075 | WHERE id_action = {int:current_action}', |
@@ -2917,6 +3078,7 @@ discard block |
||
| 2917 | 3078 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 2918 | 3079 | ) |
| 2919 | 3080 | ); |
| 3081 | + } |
|
| 2920 | 3082 | } |
| 2921 | 3083 | $smcFunc['db_free_result']($request); |
| 2922 | 3084 | |
@@ -2938,15 +3100,17 @@ discard block |
||
| 2938 | 3100 | // First thing's first - did we already do this? |
| 2939 | 3101 | if (!empty($modSettings['json_done'])) |
| 2940 | 3102 | { |
| 2941 | - if ($command_line) |
|
| 2942 | - return DeleteUpgrade(); |
|
| 2943 | - else |
|
| 2944 | - return true; |
|
| 3103 | + if ($command_line) { |
|
| 3104 | + return DeleteUpgrade(); |
|
| 3105 | + } else { |
|
| 3106 | + return true; |
|
| 3107 | + } |
|
| 2945 | 3108 | } |
| 2946 | 3109 | |
| 2947 | 3110 | // Done it already - js wise? |
| 2948 | - if (!empty($_POST['json_done'])) |
|
| 2949 | - return true; |
|
| 3111 | + if (!empty($_POST['json_done'])) { |
|
| 3112 | + return true; |
|
| 3113 | + } |
|
| 2950 | 3114 | |
| 2951 | 3115 | // List of tables affected by this function |
| 2952 | 3116 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2978,12 +3142,14 @@ discard block |
||
| 2978 | 3142 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 2979 | 3143 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 2980 | 3144 | |
| 2981 | - foreach ($keys as $id => $table) |
|
| 2982 | - if ($id < $_GET['substep']) |
|
| 3145 | + foreach ($keys as $id => $table) { |
|
| 3146 | + if ($id < $_GET['substep']) |
|
| 2983 | 3147 | $upcontext['previous_tables'][] = $table; |
| 3148 | + } |
|
| 2984 | 3149 | |
| 2985 | - if ($command_line) |
|
| 2986 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3150 | + if ($command_line) { |
|
| 3151 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3152 | + } |
|
| 2987 | 3153 | |
| 2988 | 3154 | if (!$support_js || isset($_GET['xml'])) |
| 2989 | 3155 | { |
@@ -3023,8 +3189,9 @@ discard block |
||
| 3023 | 3189 | |
| 3024 | 3190 | // Loop through and fix these... |
| 3025 | 3191 | $new_settings = array(); |
| 3026 | - if ($command_line) |
|
| 3027 | - echo "\n" . 'Fixing some settings...'; |
|
| 3192 | + if ($command_line) { |
|
| 3193 | + echo "\n" . 'Fixing some settings...'; |
|
| 3194 | + } |
|
| 3028 | 3195 | |
| 3029 | 3196 | foreach ($serialized_settings as $var) |
| 3030 | 3197 | { |
@@ -3032,22 +3199,24 @@ discard block |
||
| 3032 | 3199 | { |
| 3033 | 3200 | // Attempt to unserialize the setting |
| 3034 | 3201 | $temp = @safe_unserialize($modSettings[$var]); |
| 3035 | - if (!$temp && $command_line) |
|
| 3036 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3037 | - elseif ($temp !== false) |
|
| 3038 | - $new_settings[$var] = json_encode($temp); |
|
| 3202 | + if (!$temp && $command_line) { |
|
| 3203 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3204 | + } elseif ($temp !== false) { |
|
| 3205 | + $new_settings[$var] = json_encode($temp); |
|
| 3206 | + } |
|
| 3039 | 3207 | } |
| 3040 | 3208 | } |
| 3041 | 3209 | |
| 3042 | 3210 | // Update everything at once |
| 3043 | - if (!function_exists('cache_put_data')) |
|
| 3044 | - require_once($sourcedir . '/Load.php'); |
|
| 3211 | + if (!function_exists('cache_put_data')) { |
|
| 3212 | + require_once($sourcedir . '/Load.php'); |
|
| 3213 | + } |
|
| 3045 | 3214 | updateSettings($new_settings, true); |
| 3046 | 3215 | |
| 3047 | - if ($command_line) |
|
| 3048 | - echo ' done.'; |
|
| 3049 | - } |
|
| 3050 | - elseif ($table == 'themes') |
|
| 3216 | + if ($command_line) { |
|
| 3217 | + echo ' done.'; |
|
| 3218 | + } |
|
| 3219 | + } elseif ($table == 'themes') |
|
| 3051 | 3220 | { |
| 3052 | 3221 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3053 | 3222 | $query = $smcFunc['db_query']('', ' |
@@ -3066,10 +3235,11 @@ discard block |
||
| 3066 | 3235 | |
| 3067 | 3236 | if ($command_line) |
| 3068 | 3237 | { |
| 3069 | - if ($temp === false) |
|
| 3070 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3071 | - else |
|
| 3072 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3238 | + if ($temp === false) { |
|
| 3239 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3240 | + } else { |
|
| 3241 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3242 | + } |
|
| 3073 | 3243 | } |
| 3074 | 3244 | |
| 3075 | 3245 | if ($temp !== false) |
@@ -3091,15 +3261,15 @@ discard block |
||
| 3091 | 3261 | ) |
| 3092 | 3262 | ); |
| 3093 | 3263 | |
| 3094 | - if ($command_line) |
|
| 3095 | - echo ' done.'; |
|
| 3264 | + if ($command_line) { |
|
| 3265 | + echo ' done.'; |
|
| 3266 | + } |
|
| 3096 | 3267 | } |
| 3097 | 3268 | } |
| 3098 | 3269 | |
| 3099 | 3270 | $smcFunc['db_free_result']($query); |
| 3100 | 3271 | } |
| 3101 | - } |
|
| 3102 | - else |
|
| 3272 | + } else |
|
| 3103 | 3273 | { |
| 3104 | 3274 | // First item is always the key... |
| 3105 | 3275 | $key = $info[0]; |
@@ -3110,8 +3280,7 @@ discard block |
||
| 3110 | 3280 | { |
| 3111 | 3281 | $col_select = $info[1]; |
| 3112 | 3282 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3113 | - } |
|
| 3114 | - else |
|
| 3283 | + } else |
|
| 3115 | 3284 | { |
| 3116 | 3285 | $col_select = implode(', ', $info); |
| 3117 | 3286 | } |
@@ -3144,8 +3313,7 @@ discard block |
||
| 3144 | 3313 | if ($temp === false && $command_line) |
| 3145 | 3314 | { |
| 3146 | 3315 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3147 | - } |
|
| 3148 | - else |
|
| 3316 | + } else |
|
| 3149 | 3317 | { |
| 3150 | 3318 | $row[$col] = json_encode($temp); |
| 3151 | 3319 | |
@@ -3170,16 +3338,18 @@ discard block |
||
| 3170 | 3338 | } |
| 3171 | 3339 | } |
| 3172 | 3340 | |
| 3173 | - if ($command_line) |
|
| 3174 | - echo ' done.'; |
|
| 3341 | + if ($command_line) { |
|
| 3342 | + echo ' done.'; |
|
| 3343 | + } |
|
| 3175 | 3344 | |
| 3176 | 3345 | // Free up some memory... |
| 3177 | 3346 | $smcFunc['db_free_result']($query); |
| 3178 | 3347 | } |
| 3179 | 3348 | } |
| 3180 | 3349 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3181 | - if (isset($_GET['xml'])) |
|
| 3182 | - return upgradeExit(); |
|
| 3350 | + if (isset($_GET['xml'])) { |
|
| 3351 | + return upgradeExit(); |
|
| 3352 | + } |
|
| 3183 | 3353 | } |
| 3184 | 3354 | |
| 3185 | 3355 | if ($command_line) |
@@ -3194,8 +3364,9 @@ discard block |
||
| 3194 | 3364 | |
| 3195 | 3365 | $_GET['substep'] = 0; |
| 3196 | 3366 | // Make sure we move on! |
| 3197 | - if ($command_line) |
|
| 3198 | - return DeleteUpgrade(); |
|
| 3367 | + if ($command_line) { |
|
| 3368 | + return DeleteUpgrade(); |
|
| 3369 | + } |
|
| 3199 | 3370 | |
| 3200 | 3371 | return true; |
| 3201 | 3372 | } |
@@ -3215,14 +3386,16 @@ discard block |
||
| 3215 | 3386 | global $upcontext, $txt, $settings; |
| 3216 | 3387 | |
| 3217 | 3388 | // Don't call me twice! |
| 3218 | - if (!empty($upcontext['chmod_called'])) |
|
| 3219 | - return; |
|
| 3389 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3390 | + return; |
|
| 3391 | + } |
|
| 3220 | 3392 | |
| 3221 | 3393 | $upcontext['chmod_called'] = true; |
| 3222 | 3394 | |
| 3223 | 3395 | // Nothing? |
| 3224 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3225 | - return; |
|
| 3396 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3397 | + return; |
|
| 3398 | + } |
|
| 3226 | 3399 | |
| 3227 | 3400 | // Was it a problem with Windows? |
| 3228 | 3401 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3254,11 +3427,12 @@ discard block |
||
| 3254 | 3427 | 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\'); |
| 3255 | 3428 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3256 | 3429 | |
| 3257 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3258 | - echo ' |
|
| 3430 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3431 | + echo ' |
|
| 3259 | 3432 | content.write(\'<hr>\n\t\t\t\'); |
| 3260 | 3433 | 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\'); |
| 3261 | 3434 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3435 | + } |
|
| 3262 | 3436 | |
| 3263 | 3437 | echo ' |
| 3264 | 3438 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3266,17 +3440,19 @@ discard block |
||
| 3266 | 3440 | } |
| 3267 | 3441 | </script>'; |
| 3268 | 3442 | |
| 3269 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3270 | - echo ' |
|
| 3443 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3444 | + echo ' |
|
| 3271 | 3445 | <div class="error_message red"> |
| 3272 | 3446 | The following error was encountered when trying to connect:<br><br> |
| 3273 | 3447 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3274 | 3448 | </div> |
| 3275 | 3449 | <br>'; |
| 3450 | + } |
|
| 3276 | 3451 | |
| 3277 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3278 | - echo ' |
|
| 3452 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3453 | + echo ' |
|
| 3279 | 3454 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3455 | + } |
|
| 3280 | 3456 | |
| 3281 | 3457 | echo ' |
| 3282 | 3458 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3311,10 +3487,11 @@ discard block |
||
| 3311 | 3487 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
| 3312 | 3488 | </div>'; |
| 3313 | 3489 | |
| 3314 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3315 | - echo ' |
|
| 3490 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3491 | + echo ' |
|
| 3316 | 3492 | </form>'; |
| 3317 | -} |
|
| 3493 | + } |
|
| 3494 | + } |
|
| 3318 | 3495 | |
| 3319 | 3496 | function template_upgrade_above() |
| 3320 | 3497 | { |
@@ -3374,9 +3551,10 @@ discard block |
||
| 3374 | 3551 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3375 | 3552 | <ul>'; |
| 3376 | 3553 | |
| 3377 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3378 | - echo ' |
|
| 3554 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3555 | + echo ' |
|
| 3379 | 3556 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3557 | + } |
|
| 3380 | 3558 | |
| 3381 | 3559 | echo ' |
| 3382 | 3560 | </ul> |
@@ -3389,8 +3567,8 @@ discard block |
||
| 3389 | 3567 | </div> |
| 3390 | 3568 | </div>'; |
| 3391 | 3569 | |
| 3392 | - if (isset($upcontext['step_progress'])) |
|
| 3393 | - echo ' |
|
| 3570 | + if (isset($upcontext['step_progress'])) { |
|
| 3571 | + echo ' |
|
| 3394 | 3572 | <br> |
| 3395 | 3573 | <br> |
| 3396 | 3574 | <div id="progress_bar_step"> |
@@ -3399,6 +3577,7 @@ discard block |
||
| 3399 | 3577 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3400 | 3578 | </div> |
| 3401 | 3579 | </div>'; |
| 3580 | + } |
|
| 3402 | 3581 | |
| 3403 | 3582 | echo ' |
| 3404 | 3583 | <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> |
@@ -3429,32 +3608,36 @@ discard block |
||
| 3429 | 3608 | { |
| 3430 | 3609 | global $upcontext, $txt; |
| 3431 | 3610 | |
| 3432 | - if (!empty($upcontext['pause'])) |
|
| 3433 | - echo ' |
|
| 3611 | + if (!empty($upcontext['pause'])) { |
|
| 3612 | + echo ' |
|
| 3434 | 3613 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3435 | 3614 | |
| 3436 | 3615 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3437 | 3616 | <h3> |
| 3438 | 3617 | ', $txt['upgrade_paused_overload'], ' |
| 3439 | 3618 | </h3>'; |
| 3619 | + } |
|
| 3440 | 3620 | |
| 3441 | - if (!empty($upcontext['custom_warning'])) |
|
| 3442 | - echo ' |
|
| 3621 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3622 | + echo ' |
|
| 3443 | 3623 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3444 | 3624 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3445 | 3625 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3446 | 3626 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3447 | 3627 | </div>'; |
| 3628 | + } |
|
| 3448 | 3629 | |
| 3449 | 3630 | echo ' |
| 3450 | 3631 | <div class="righttext" style="margin: 1ex;">'; |
| 3451 | 3632 | |
| 3452 | - if (!empty($upcontext['continue'])) |
|
| 3453 | - echo ' |
|
| 3633 | + if (!empty($upcontext['continue'])) { |
|
| 3634 | + echo ' |
|
| 3454 | 3635 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
| 3455 | - if (!empty($upcontext['skip'])) |
|
| 3456 | - echo ' |
|
| 3636 | + } |
|
| 3637 | + if (!empty($upcontext['skip'])) { |
|
| 3638 | + echo ' |
|
| 3457 | 3639 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
| 3640 | + } |
|
| 3458 | 3641 | |
| 3459 | 3642 | echo ' |
| 3460 | 3643 | </div> |
@@ -3504,11 +3687,12 @@ discard block |
||
| 3504 | 3687 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3505 | 3688 | <smf>'; |
| 3506 | 3689 | |
| 3507 | - if (!empty($upcontext['get_data'])) |
|
| 3508 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3690 | + if (!empty($upcontext['get_data'])) { |
|
| 3691 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3509 | 3692 | echo ' |
| 3510 | 3693 | <get key="', $k, '">', $v, '</get>'; |
| 3511 | -} |
|
| 3694 | + } |
|
| 3695 | + } |
|
| 3512 | 3696 | |
| 3513 | 3697 | function template_xml_below() |
| 3514 | 3698 | { |
@@ -3549,8 +3733,8 @@ discard block |
||
| 3549 | 3733 | template_chmod(); |
| 3550 | 3734 | |
| 3551 | 3735 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3552 | - if ($upcontext['is_large_forum']) |
|
| 3553 | - echo ' |
|
| 3736 | + if ($upcontext['is_large_forum']) { |
|
| 3737 | + echo ' |
|
| 3554 | 3738 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3555 | 3739 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3556 | 3740 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3558,10 +3742,11 @@ discard block |
||
| 3558 | 3742 | ', $txt['upgrade_warning_lots_data'], ' |
| 3559 | 3743 | </div> |
| 3560 | 3744 | </div>'; |
| 3745 | + } |
|
| 3561 | 3746 | |
| 3562 | 3747 | // A warning message? |
| 3563 | - if (!empty($upcontext['warning'])) |
|
| 3564 | - echo ' |
|
| 3748 | + if (!empty($upcontext['warning'])) { |
|
| 3749 | + echo ' |
|
| 3565 | 3750 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3566 | 3751 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3567 | 3752 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3569,6 +3754,7 @@ discard block |
||
| 3569 | 3754 | ', $upcontext['warning'], ' |
| 3570 | 3755 | </div> |
| 3571 | 3756 | </div>'; |
| 3757 | + } |
|
| 3572 | 3758 | |
| 3573 | 3759 | // Paths are incorrect? |
| 3574 | 3760 | echo ' |
@@ -3584,20 +3770,22 @@ discard block |
||
| 3584 | 3770 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3585 | 3771 | { |
| 3586 | 3772 | $ago = time() - $upcontext['started']; |
| 3587 | - if ($ago < 60) |
|
| 3588 | - $ago = $ago . ' seconds'; |
|
| 3589 | - elseif ($ago < 3600) |
|
| 3590 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3591 | - else |
|
| 3592 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3773 | + if ($ago < 60) { |
|
| 3774 | + $ago = $ago . ' seconds'; |
|
| 3775 | + } elseif ($ago < 3600) { |
|
| 3776 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3777 | + } else { |
|
| 3778 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3779 | + } |
|
| 3593 | 3780 | |
| 3594 | 3781 | $active = time() - $upcontext['updated']; |
| 3595 | - if ($active < 60) |
|
| 3596 | - $updated = $active . ' seconds'; |
|
| 3597 | - elseif ($active < 3600) |
|
| 3598 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3599 | - else |
|
| 3600 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3782 | + if ($active < 60) { |
|
| 3783 | + $updated = $active . ' seconds'; |
|
| 3784 | + } elseif ($active < 3600) { |
|
| 3785 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3786 | + } else { |
|
| 3787 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3788 | + } |
|
| 3601 | 3789 | |
| 3602 | 3790 | echo ' |
| 3603 | 3791 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3606,16 +3794,18 @@ discard block |
||
| 3606 | 3794 | <div style="padding-left: 6ex;"> |
| 3607 | 3795 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3608 | 3796 | |
| 3609 | - if ($active < 600) |
|
| 3610 | - echo ' |
|
| 3797 | + if ($active < 600) { |
|
| 3798 | + echo ' |
|
| 3611 | 3799 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3800 | + } |
|
| 3612 | 3801 | |
| 3613 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3614 | - echo ' |
|
| 3802 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3803 | + echo ' |
|
| 3615 | 3804 | <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.'; |
| 3616 | - else |
|
| 3617 | - echo ' |
|
| 3805 | + } else { |
|
| 3806 | + echo ' |
|
| 3618 | 3807 | <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!'); |
| 3808 | + } |
|
| 3619 | 3809 | |
| 3620 | 3810 | echo ' |
| 3621 | 3811 | </div> |
@@ -3631,9 +3821,10 @@ discard block |
||
| 3631 | 3821 | <td> |
| 3632 | 3822 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
| 3633 | 3823 | |
| 3634 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3635 | - echo ' |
|
| 3824 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3825 | + echo ' |
|
| 3636 | 3826 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3827 | + } |
|
| 3637 | 3828 | |
| 3638 | 3829 | echo ' |
| 3639 | 3830 | </td> |
@@ -3644,9 +3835,10 @@ discard block |
||
| 3644 | 3835 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
| 3645 | 3836 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3646 | 3837 | |
| 3647 | - if (!empty($upcontext['password_failed'])) |
|
| 3648 | - echo ' |
|
| 3838 | + if (!empty($upcontext['password_failed'])) { |
|
| 3839 | + echo ' |
|
| 3649 | 3840 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3841 | + } |
|
| 3650 | 3842 | |
| 3651 | 3843 | echo ' |
| 3652 | 3844 | </td> |
@@ -3717,8 +3909,8 @@ discard block |
||
| 3717 | 3909 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3718 | 3910 | |
| 3719 | 3911 | // Warning message? |
| 3720 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3721 | - echo ' |
|
| 3912 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 3913 | + echo ' |
|
| 3722 | 3914 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3723 | 3915 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3724 | 3916 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3726,6 +3918,7 @@ discard block |
||
| 3726 | 3918 | ', $upcontext['upgrade_options_warning'], ' |
| 3727 | 3919 | </div> |
| 3728 | 3920 | </div>'; |
| 3921 | + } |
|
| 3729 | 3922 | |
| 3730 | 3923 | echo ' |
| 3731 | 3924 | <table> |
@@ -3768,8 +3961,8 @@ discard block |
||
| 3768 | 3961 | </td> |
| 3769 | 3962 | </tr>'; |
| 3770 | 3963 | |
| 3771 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3772 | - echo ' |
|
| 3964 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 3965 | + echo ' |
|
| 3773 | 3966 | <tr valign="top"> |
| 3774 | 3967 | <td width="2%"> |
| 3775 | 3968 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3778,6 +3971,7 @@ discard block |
||
| 3778 | 3971 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3779 | 3972 | </td> |
| 3780 | 3973 | </tr>'; |
| 3974 | + } |
|
| 3781 | 3975 | |
| 3782 | 3976 | echo ' |
| 3783 | 3977 | <tr valign="top"> |
@@ -3815,10 +4009,11 @@ discard block |
||
| 3815 | 4009 | </div>'; |
| 3816 | 4010 | |
| 3817 | 4011 | // Dont any tables so far? |
| 3818 | - if (!empty($upcontext['previous_tables'])) |
|
| 3819 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4012 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4013 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3820 | 4014 | echo ' |
| 3821 | 4015 | <br>Completed Table: "', $table, '".'; |
| 4016 | + } |
|
| 3822 | 4017 | |
| 3823 | 4018 | echo ' |
| 3824 | 4019 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3855,12 +4050,13 @@ discard block |
||
| 3855 | 4050 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3856 | 4051 | |
| 3857 | 4052 | // If debug flood the screen. |
| 3858 | - if ($is_debug) |
|
| 3859 | - echo ' |
|
| 4053 | + if ($is_debug) { |
|
| 4054 | + echo ' |
|
| 3860 | 4055 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3861 | 4056 | |
| 3862 | 4057 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 3863 | 4058 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4059 | + } |
|
| 3864 | 4060 | |
| 3865 | 4061 | echo ' |
| 3866 | 4062 | // Get the next update... |
@@ -3893,8 +4089,9 @@ discard block |
||
| 3893 | 4089 | { |
| 3894 | 4090 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 3895 | 4091 | |
| 3896 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 3897 | - $is_debug = true; |
|
| 4092 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4093 | + $is_debug = true; |
|
| 4094 | + } |
|
| 3898 | 4095 | |
| 3899 | 4096 | echo ' |
| 3900 | 4097 | <h3>Executing database changes</h3> |
@@ -3909,8 +4106,9 @@ discard block |
||
| 3909 | 4106 | { |
| 3910 | 4107 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 3911 | 4108 | { |
| 3912 | - if ($num != 0) |
|
| 3913 | - echo ' Successful!'; |
|
| 4109 | + if ($num != 0) { |
|
| 4110 | + echo ' Successful!'; |
|
| 4111 | + } |
|
| 3914 | 4112 | echo '<br>' . $item; |
| 3915 | 4113 | } |
| 3916 | 4114 | if (!empty($upcontext['changes_complete'])) |
@@ -3923,28 +4121,32 @@ discard block |
||
| 3923 | 4121 | $seconds = intval($active % 60); |
| 3924 | 4122 | |
| 3925 | 4123 | $totalTime = ''; |
| 3926 | - if ($hours > 0) |
|
| 3927 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3928 | - if ($minutes > 0) |
|
| 3929 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3930 | - if ($seconds > 0) |
|
| 3931 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4124 | + if ($hours > 0) { |
|
| 4125 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4126 | + } |
|
| 4127 | + if ($minutes > 0) { |
|
| 4128 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4129 | + } |
|
| 4130 | + if ($seconds > 0) { |
|
| 4131 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4132 | + } |
|
| 3932 | 4133 | } |
| 3933 | 4134 | |
| 3934 | - if ($is_debug && !empty($totalTime)) |
|
| 3935 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 3936 | - else |
|
| 3937 | - echo ' Successful!<br><br>'; |
|
| 4135 | + if ($is_debug && !empty($totalTime)) { |
|
| 4136 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4137 | + } else { |
|
| 4138 | + echo ' Successful!<br><br>'; |
|
| 4139 | + } |
|
| 3938 | 4140 | |
| 3939 | 4141 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 3940 | 4142 | } |
| 3941 | - } |
|
| 3942 | - else |
|
| 4143 | + } else |
|
| 3943 | 4144 | { |
| 3944 | 4145 | // Tell them how many files we have in total. |
| 3945 | - if ($upcontext['file_count'] > 1) |
|
| 3946 | - echo ' |
|
| 4146 | + if ($upcontext['file_count'] > 1) { |
|
| 4147 | + echo ' |
|
| 3947 | 4148 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4149 | + } |
|
| 3948 | 4150 | |
| 3949 | 4151 | echo ' |
| 3950 | 4152 | <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> |
@@ -3960,19 +4162,23 @@ discard block |
||
| 3960 | 4162 | $seconds = intval($active % 60); |
| 3961 | 4163 | |
| 3962 | 4164 | $totalTime = ''; |
| 3963 | - if ($hours > 0) |
|
| 3964 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3965 | - if ($minutes > 0) |
|
| 3966 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3967 | - if ($seconds > 0) |
|
| 3968 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4165 | + if ($hours > 0) { |
|
| 4166 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4167 | + } |
|
| 4168 | + if ($minutes > 0) { |
|
| 4169 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4170 | + } |
|
| 4171 | + if ($seconds > 0) { |
|
| 4172 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4173 | + } |
|
| 3969 | 4174 | } |
| 3970 | 4175 | |
| 3971 | 4176 | echo ' |
| 3972 | 4177 | <br><span id="upgradeCompleted">'; |
| 3973 | 4178 | |
| 3974 | - if (!empty($totalTime)) |
|
| 3975 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4179 | + if (!empty($totalTime)) { |
|
| 4180 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4181 | + } |
|
| 3976 | 4182 | |
| 3977 | 4183 | echo '</span> |
| 3978 | 4184 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4009,9 +4215,10 @@ discard block |
||
| 4009 | 4215 | var getData = ""; |
| 4010 | 4216 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4011 | 4217 | |
| 4012 | - if ($is_debug) |
|
| 4013 | - echo ' |
|
| 4218 | + if ($is_debug) { |
|
| 4219 | + echo ' |
|
| 4014 | 4220 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4221 | + } |
|
| 4015 | 4222 | |
| 4016 | 4223 | echo ' |
| 4017 | 4224 | function getNextItem() |
@@ -4051,9 +4258,10 @@ discard block |
||
| 4051 | 4258 | document.getElementById("error_block").style.display = ""; |
| 4052 | 4259 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4053 | 4260 | |
| 4054 | - if ($is_debug) |
|
| 4055 | - echo ' |
|
| 4261 | + if ($is_debug) { |
|
| 4262 | + echo ' |
|
| 4056 | 4263 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4264 | + } |
|
| 4057 | 4265 | |
| 4058 | 4266 | echo ' |
| 4059 | 4267 | } |
@@ -4074,9 +4282,10 @@ discard block |
||
| 4074 | 4282 | document.getElementById("error_block").style.display = ""; |
| 4075 | 4283 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4076 | 4284 | |
| 4077 | - if ($is_debug) |
|
| 4078 | - echo ' |
|
| 4285 | + if ($is_debug) { |
|
| 4286 | + echo ' |
|
| 4079 | 4287 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4288 | + } |
|
| 4080 | 4289 | |
| 4081 | 4290 | echo ' |
| 4082 | 4291 | } |
@@ -4135,8 +4344,8 @@ discard block |
||
| 4135 | 4344 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4136 | 4345 | {'; |
| 4137 | 4346 | |
| 4138 | - if ($is_debug) |
|
| 4139 | - echo ' |
|
| 4347 | + if ($is_debug) { |
|
| 4348 | + echo ' |
|
| 4140 | 4349 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4141 | 4350 | |
| 4142 | 4351 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4154,6 +4363,7 @@ discard block |
||
| 4154 | 4363 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4155 | 4364 | |
| 4156 | 4365 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4366 | + } |
|
| 4157 | 4367 | |
| 4158 | 4368 | echo ' |
| 4159 | 4369 | |
@@ -4161,9 +4371,10 @@ discard block |
||
| 4161 | 4371 | document.getElementById(\'contbutt\').disabled = 0; |
| 4162 | 4372 | document.getElementById(\'database_done\').value = 1;'; |
| 4163 | 4373 | |
| 4164 | - if ($upcontext['file_count'] > 1) |
|
| 4165 | - echo ' |
|
| 4374 | + if ($upcontext['file_count'] > 1) { |
|
| 4375 | + echo ' |
|
| 4166 | 4376 | document.getElementById(\'info1\').style.display = "none";'; |
| 4377 | + } |
|
| 4167 | 4378 | |
| 4168 | 4379 | echo ' |
| 4169 | 4380 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4176,9 +4387,10 @@ discard block |
||
| 4176 | 4387 | lastItem = 0; |
| 4177 | 4388 | prevFile = curFile;'; |
| 4178 | 4389 | |
| 4179 | - if ($is_debug) |
|
| 4180 | - echo ' |
|
| 4390 | + if ($is_debug) { |
|
| 4391 | + echo ' |
|
| 4181 | 4392 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4393 | + } |
|
| 4182 | 4394 | |
| 4183 | 4395 | echo ' |
| 4184 | 4396 | getNextItem(); |
@@ -4186,8 +4398,8 @@ discard block |
||
| 4186 | 4398 | }'; |
| 4187 | 4399 | |
| 4188 | 4400 | // If debug scroll the screen. |
| 4189 | - if ($is_debug) |
|
| 4190 | - echo ' |
|
| 4401 | + if ($is_debug) { |
|
| 4402 | + echo ' |
|
| 4191 | 4403 | if (iLastSubStepProgress == -1) |
| 4192 | 4404 | { |
| 4193 | 4405 | // Give it consistent dots. |
@@ -4206,6 +4418,7 @@ discard block |
||
| 4206 | 4418 | |
| 4207 | 4419 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4208 | 4420 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4421 | + } |
|
| 4209 | 4422 | |
| 4210 | 4423 | echo ' |
| 4211 | 4424 | // Update the page. |
@@ -4266,9 +4479,10 @@ discard block |
||
| 4266 | 4479 | }'; |
| 4267 | 4480 | |
| 4268 | 4481 | // Start things off assuming we've not errored. |
| 4269 | - if (empty($upcontext['error_message'])) |
|
| 4270 | - echo ' |
|
| 4482 | + if (empty($upcontext['error_message'])) { |
|
| 4483 | + echo ' |
|
| 4271 | 4484 | getNextItem();'; |
| 4485 | + } |
|
| 4272 | 4486 | |
| 4273 | 4487 | echo ' |
| 4274 | 4488 | //# sourceURL=dynamicScript-dbch.js |
@@ -4286,18 +4500,21 @@ discard block |
||
| 4286 | 4500 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4287 | 4501 | <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>'; |
| 4288 | 4502 | |
| 4289 | - if (!empty($upcontext['error_message'])) |
|
| 4290 | - echo ' |
|
| 4503 | + if (!empty($upcontext['error_message'])) { |
|
| 4504 | + echo ' |
|
| 4291 | 4505 | <error>', $upcontext['error_message'], '</error>'; |
| 4506 | + } |
|
| 4292 | 4507 | |
| 4293 | - if (!empty($upcontext['error_string'])) |
|
| 4294 | - echo ' |
|
| 4508 | + if (!empty($upcontext['error_string'])) { |
|
| 4509 | + echo ' |
|
| 4295 | 4510 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4511 | + } |
|
| 4296 | 4512 | |
| 4297 | - if ($is_debug) |
|
| 4298 | - echo ' |
|
| 4513 | + if ($is_debug) { |
|
| 4514 | + echo ' |
|
| 4299 | 4515 | <curtime>', time(), '</curtime>'; |
| 4300 | -} |
|
| 4516 | + } |
|
| 4517 | + } |
|
| 4301 | 4518 | |
| 4302 | 4519 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4303 | 4520 | function template_convert_utf8() |
@@ -4316,18 +4533,20 @@ discard block |
||
| 4316 | 4533 | </div>'; |
| 4317 | 4534 | |
| 4318 | 4535 | // Done any tables so far? |
| 4319 | - if (!empty($upcontext['previous_tables'])) |
|
| 4320 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4536 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4537 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4321 | 4538 | echo ' |
| 4322 | 4539 | <br>Completed Table: "', $table, '".'; |
| 4540 | + } |
|
| 4323 | 4541 | |
| 4324 | 4542 | echo ' |
| 4325 | 4543 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4326 | 4544 | |
| 4327 | 4545 | // If we dropped their index, let's let them know |
| 4328 | - if ($upcontext['dropping_index']) |
|
| 4329 | - echo ' |
|
| 4546 | + if ($upcontext['dropping_index']) { |
|
| 4547 | + echo ' |
|
| 4330 | 4548 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated in the admin area after the upgrade is complete.</span>'; |
| 4549 | + } |
|
| 4331 | 4550 | |
| 4332 | 4551 | // Completion notification |
| 4333 | 4552 | echo ' |
@@ -4364,12 +4583,13 @@ discard block |
||
| 4364 | 4583 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4365 | 4584 | |
| 4366 | 4585 | // If debug flood the screen. |
| 4367 | - if ($is_debug) |
|
| 4368 | - echo ' |
|
| 4586 | + if ($is_debug) { |
|
| 4587 | + echo ' |
|
| 4369 | 4588 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4370 | 4589 | |
| 4371 | 4590 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4372 | 4591 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4592 | + } |
|
| 4373 | 4593 | |
| 4374 | 4594 | echo ' |
| 4375 | 4595 | // Get the next update... |
@@ -4417,19 +4637,21 @@ discard block |
||
| 4417 | 4637 | </div>'; |
| 4418 | 4638 | |
| 4419 | 4639 | // Dont any tables so far? |
| 4420 | - if (!empty($upcontext['previous_tables'])) |
|
| 4421 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4640 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4641 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4422 | 4642 | echo ' |
| 4423 | 4643 | <br>Completed Table: "', $table, '".'; |
| 4644 | + } |
|
| 4424 | 4645 | |
| 4425 | 4646 | echo ' |
| 4426 | 4647 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4427 | 4648 | <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>'; |
| 4428 | 4649 | |
| 4429 | 4650 | // Try to make sure substep was reset. |
| 4430 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4431 | - echo ' |
|
| 4651 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4652 | + echo ' |
|
| 4432 | 4653 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4654 | + } |
|
| 4433 | 4655 | |
| 4434 | 4656 | // Continue please! |
| 4435 | 4657 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4462,12 +4684,13 @@ discard block |
||
| 4462 | 4684 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4463 | 4685 | |
| 4464 | 4686 | // If debug flood the screen. |
| 4465 | - if ($is_debug) |
|
| 4466 | - echo ' |
|
| 4687 | + if ($is_debug) { |
|
| 4688 | + echo ' |
|
| 4467 | 4689 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4468 | 4690 | |
| 4469 | 4691 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4470 | 4692 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4693 | + } |
|
| 4471 | 4694 | |
| 4472 | 4695 | echo ' |
| 4473 | 4696 | // Get the next update... |
@@ -4503,8 +4726,8 @@ discard block |
||
| 4503 | 4726 | <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> |
| 4504 | 4727 | <form action="', $boardurl, '/index.php">'; |
| 4505 | 4728 | |
| 4506 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4507 | - echo ' |
|
| 4729 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4730 | + echo ' |
|
| 4508 | 4731 | <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> |
| 4509 | 4732 | <script> |
| 4510 | 4733 | function doTheDelete(theCheck) |
@@ -4516,6 +4739,7 @@ discard block |
||
| 4516 | 4739 | } |
| 4517 | 4740 | </script> |
| 4518 | 4741 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4742 | + } |
|
| 4519 | 4743 | |
| 4520 | 4744 | $active = time() - $upcontext['started']; |
| 4521 | 4745 | $hours = floor($active / 3600); |
@@ -4525,16 +4749,20 @@ discard block |
||
| 4525 | 4749 | if ($is_debug) |
| 4526 | 4750 | { |
| 4527 | 4751 | $totalTime = ''; |
| 4528 | - if ($hours > 0) |
|
| 4529 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4530 | - if ($minutes > 0) |
|
| 4531 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4532 | - if ($seconds > 0) |
|
| 4533 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4752 | + if ($hours > 0) { |
|
| 4753 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4754 | + } |
|
| 4755 | + if ($minutes > 0) { |
|
| 4756 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4757 | + } |
|
| 4758 | + if ($seconds > 0) { |
|
| 4759 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4760 | + } |
|
| 4534 | 4761 | } |
| 4535 | 4762 | |
| 4536 | - if ($is_debug && !empty($totalTime)) |
|
| 4537 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4763 | + if ($is_debug && !empty($totalTime)) { |
|
| 4764 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4765 | + } |
|
| 4538 | 4766 | |
| 4539 | 4767 | echo '<br> |
| 4540 | 4768 | 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> |
@@ -4561,8 +4789,9 @@ discard block |
||
| 4561 | 4789 | |
| 4562 | 4790 | $current_substep = $_GET['substep']; |
| 4563 | 4791 | |
| 4564 | - if (empty($_GET['a'])) |
|
| 4565 | - $_GET['a'] = 0; |
|
| 4792 | + if (empty($_GET['a'])) { |
|
| 4793 | + $_GET['a'] = 0; |
|
| 4794 | + } |
|
| 4566 | 4795 | $step_progress['name'] = 'Converting ips'; |
| 4567 | 4796 | $step_progress['current'] = $_GET['a']; |
| 4568 | 4797 | |
@@ -4605,16 +4834,19 @@ discard block |
||
| 4605 | 4834 | 'empty' => '', |
| 4606 | 4835 | 'limit' => $limit, |
| 4607 | 4836 | )); |
| 4608 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4609 | - $arIp[] = $row[$oldCol]; |
|
| 4837 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4838 | + $arIp[] = $row[$oldCol]; |
|
| 4839 | + } |
|
| 4610 | 4840 | $smcFunc['db_free_result']($request); |
| 4611 | 4841 | |
| 4612 | 4842 | // Special case, null ip could keep us in a loop. |
| 4613 | - if (is_null($arIp[0])) |
|
| 4614 | - unset($arIp[0]); |
|
| 4843 | + if (is_null($arIp[0])) { |
|
| 4844 | + unset($arIp[0]); |
|
| 4845 | + } |
|
| 4615 | 4846 | |
| 4616 | - if (empty($arIp)) |
|
| 4617 | - $is_done = true; |
|
| 4847 | + if (empty($arIp)) { |
|
| 4848 | + $is_done = true; |
|
| 4849 | + } |
|
| 4618 | 4850 | |
| 4619 | 4851 | $updates = array(); |
| 4620 | 4852 | $cases = array(); |
@@ -4623,16 +4855,18 @@ discard block |
||
| 4623 | 4855 | { |
| 4624 | 4856 | $arIp[$i] = trim($arIp[$i]); |
| 4625 | 4857 | |
| 4626 | - if (empty($arIp[$i])) |
|
| 4627 | - continue; |
|
| 4858 | + if (empty($arIp[$i])) { |
|
| 4859 | + continue; |
|
| 4860 | + } |
|
| 4628 | 4861 | |
| 4629 | 4862 | $updates['ip' . $i] = $arIp[$i]; |
| 4630 | 4863 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4631 | 4864 | |
| 4632 | 4865 | if ($setSize > 0 && $i % $setSize === 0) |
| 4633 | 4866 | { |
| 4634 | - if (count($updates) == 1) |
|
| 4635 | - continue; |
|
| 4867 | + if (count($updates) == 1) { |
|
| 4868 | + continue; |
|
| 4869 | + } |
|
| 4636 | 4870 | |
| 4637 | 4871 | $updates['whereSet'] = array_values($updates); |
| 4638 | 4872 | $smcFunc['db_query']('', ' |
@@ -4666,8 +4900,7 @@ discard block |
||
| 4666 | 4900 | 'ip' => $ip |
| 4667 | 4901 | )); |
| 4668 | 4902 | } |
| 4669 | - } |
|
| 4670 | - else |
|
| 4903 | + } else |
|
| 4671 | 4904 | { |
| 4672 | 4905 | $updates['whereSet'] = array_values($updates); |
| 4673 | 4906 | $smcFunc['db_query']('', ' |
@@ -4681,9 +4914,9 @@ discard block |
||
| 4681 | 4914 | $updates |
| 4682 | 4915 | ); |
| 4683 | 4916 | } |
| 4917 | + } else { |
|
| 4918 | + $is_done = true; |
|
| 4684 | 4919 | } |
| 4685 | - else |
|
| 4686 | - $is_done = true; |
|
| 4687 | 4920 | |
| 4688 | 4921 | $_GET['a'] += $limit; |
| 4689 | 4922 | $step_progress['current'] = $_GET['a']; |
@@ -4709,10 +4942,11 @@ discard block |
||
| 4709 | 4942 | |
| 4710 | 4943 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4711 | 4944 | |
| 4712 | - if (isset($columns[$column])) |
|
| 4713 | - return $columns[$column]; |
|
| 4714 | - else |
|
| 4715 | - return null; |
|
| 4716 | -} |
|
| 4945 | + if (isset($columns[$column])) { |
|
| 4946 | + return $columns[$column]; |
|
| 4947 | + } else { |
|
| 4948 | + return null; |
|
| 4949 | + } |
|
| 4950 | + } |
|
| 4717 | 4951 | |
| 4718 | 4952 | ?> |
| 4719 | 4953 | \ No newline at end of file |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
| 21 | 21 | |
| 22 | 22 | // Let's pull in useful classes |
| 23 | -if (!defined('SMF')) |
|
| 23 | +if (!defined('SMF')) { |
|
| 24 | 24 | define('SMF', 1); |
| 25 | +} |
|
| 25 | 26 | |
| 26 | 27 | require_once('Sources/Class-Package.php'); |
| 27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
| 63 | 64 | |
| 64 | 65 | list ($charcode) = pg_fetch_row($request); |
| 65 | 66 | |
| 66 | - if ($charcode == 'UTF8') |
|
| 67 | - return true; |
|
| 68 | - else |
|
| 69 | - return false; |
|
| 67 | + if ($charcode == 'UTF8') { |
|
| 68 | + return true; |
|
| 69 | + } else { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 70 | 72 | }, |
| 71 | 73 | 'utf8_version' => '8.0', |
| 72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
| 76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
| 77 | 79 | |
| 78 | 80 | // Is it reserved? |
| 79 | - if ($value == 'pg_') |
|
| 80 | - return $txt['error_db_prefix_reserved']; |
|
| 81 | + if ($value == 'pg_') { |
|
| 82 | + return $txt['error_db_prefix_reserved']; |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Is the prefix numeric? |
| 83 | - if (preg_match('~^\d~', $value)) |
|
| 84 | - return $txt['error_db_prefix_numeric']; |
|
| 86 | + if (preg_match('~^\d~', $value)) { |
|
| 87 | + return $txt['error_db_prefix_numeric']; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | return true; |
| 87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
| 128 | 132 | $incontext['skip'] = false; |
| 129 | 133 | |
| 130 | 134 | // Call the step and if it returns false that means pause! |
| 131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 132 | - break; |
|
| 133 | - elseif (function_exists($step[2])) |
|
| 134 | - $incontext['current_step']++; |
|
| 135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 136 | + break; |
|
| 137 | + } elseif (function_exists($step[2])) { |
|
| 138 | + $incontext['current_step']++; |
|
| 139 | + } |
|
| 135 | 140 | |
| 136 | 141 | // No warnings pass on. |
| 137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
| 147 | 152 | global $databases; |
| 148 | 153 | |
| 149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
| 150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
| 151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
| 156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 157 | + } |
|
| 152 | 158 | |
| 153 | 159 | // Enable error reporting. |
| 154 | 160 | error_reporting(E_ALL); |
@@ -164,21 +170,23 @@ discard block |
||
| 164 | 170 | { |
| 165 | 171 | ob_start(); |
| 166 | 172 | |
| 167 | - if (ini_get('session.save_handler') == 'user') |
|
| 168 | - @ini_set('session.save_handler', 'files'); |
|
| 169 | - if (function_exists('session_start')) |
|
| 170 | - @session_start(); |
|
| 171 | - } |
|
| 172 | - else |
|
| 173 | + if (ini_get('session.save_handler') == 'user') { |
|
| 174 | + @ini_set('session.save_handler', 'files'); |
|
| 175 | + } |
|
| 176 | + if (function_exists('session_start')) { |
|
| 177 | + @session_start(); |
|
| 178 | + } |
|
| 179 | + } else |
|
| 173 | 180 | { |
| 174 | 181 | ob_start('ob_gzhandler'); |
| 175 | 182 | |
| 176 | - if (ini_get('session.save_handler') == 'user') |
|
| 177 | - @ini_set('session.save_handler', 'files'); |
|
| 183 | + if (ini_get('session.save_handler') == 'user') { |
|
| 184 | + @ini_set('session.save_handler', 'files'); |
|
| 185 | + } |
|
| 178 | 186 | session_start(); |
| 179 | 187 | |
| 180 | - if (!headers_sent()) |
|
| 181 | - echo '<!DOCTYPE html> |
|
| 188 | + if (!headers_sent()) { |
|
| 189 | + echo '<!DOCTYPE html> |
|
| 182 | 190 | <html> |
| 183 | 191 | <head> |
| 184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
| 187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
| 188 | 196 | </body> |
| 189 | 197 | </html>'; |
| 198 | + } |
|
| 190 | 199 | exit; |
| 191 | 200 | } |
| 192 | 201 | |
| 193 | 202 | // Add slashes, as long as they aren't already being added. |
| 194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
| 195 | - foreach ($_POST as $k => $v) |
|
| 203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
| 204 | + foreach ($_POST as $k => $v) |
|
| 196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
| 197 | 206 | $_POST[$k] = addslashes($v); |
| 207 | + } |
|
| 198 | 208 | |
| 199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
| 200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
| 215 | 225 | $ftp->close(); |
| 216 | 226 | |
| 217 | 227 | unset($_SESSION['installer_temp_ftp']); |
| 218 | - } |
|
| 219 | - else |
|
| 228 | + } else |
|
| 220 | 229 | { |
| 221 | 230 | @unlink(__FILE__); |
| 222 | 231 | |
@@ -237,10 +246,11 @@ discard block |
||
| 237 | 246 | { |
| 238 | 247 | // Get PHP's default timezone, if set |
| 239 | 248 | $ini_tz = ini_get('date.timezone'); |
| 240 | - if (!empty($ini_tz)) |
|
| 241 | - $timezone_id = $ini_tz; |
|
| 242 | - else |
|
| 243 | - $timezone_id = ''; |
|
| 249 | + if (!empty($ini_tz)) { |
|
| 250 | + $timezone_id = $ini_tz; |
|
| 251 | + } else { |
|
| 252 | + $timezone_id = ''; |
|
| 253 | + } |
|
| 244 | 254 | |
| 245 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 246 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -270,8 +280,9 @@ discard block |
||
| 270 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 271 | 281 | while ($entry = $dir->read()) |
| 272 | 282 | { |
| 273 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 274 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 285 | + } |
|
| 275 | 286 | } |
| 276 | 287 | $dir->close(); |
| 277 | 288 | } |
@@ -306,10 +317,11 @@ discard block |
||
| 306 | 317 | } |
| 307 | 318 | |
| 308 | 319 | // Override the language file? |
| 309 | - if (isset($_GET['lang_file'])) |
|
| 310 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 311 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 312 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 320 | + if (isset($_GET['lang_file'])) { |
|
| 321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 324 | + } |
|
| 313 | 325 | |
| 314 | 326 | // Make sure it exists, if it doesn't reset it. |
| 315 | 327 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -318,8 +330,9 @@ discard block |
||
| 318 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 319 | 331 | |
| 320 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 321 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 322 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 335 | + } |
|
| 323 | 336 | } |
| 324 | 337 | |
| 325 | 338 | // And now include the actual language file itself. |
@@ -332,15 +345,18 @@ discard block |
||
| 332 | 345 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
| 333 | 346 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
| 334 | 347 | |
| 335 | - if (empty($sourcedir)) |
|
| 336 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 348 | + if (empty($sourcedir)) { |
|
| 349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 350 | + } |
|
| 337 | 351 | |
| 338 | 352 | // Need this to check whether we need the database password. |
| 339 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
| 340 | - if (!defined('SMF')) |
|
| 341 | - define('SMF', 1); |
|
| 342 | - if (empty($smcFunc)) |
|
| 343 | - $smcFunc = array(); |
|
| 354 | + if (!defined('SMF')) { |
|
| 355 | + define('SMF', 1); |
|
| 356 | + } |
|
| 357 | + if (empty($smcFunc)) { |
|
| 358 | + $smcFunc = array(); |
|
| 359 | + } |
|
| 344 | 360 | |
| 345 | 361 | $modSettings['disableQueryCheck'] = true; |
| 346 | 362 | |
@@ -348,8 +364,9 @@ discard block |
||
| 348 | 364 | if (!$db_connection) |
| 349 | 365 | { |
| 350 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 351 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 352 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 369 | + } |
|
| 353 | 370 | |
| 354 | 371 | $db_options = array('persist' => $db_persist); |
| 355 | 372 | $port = ''; |
@@ -360,19 +377,20 @@ discard block |
||
| 360 | 377 | if ($db_type == 'mysql') |
| 361 | 378 | { |
| 362 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
| 363 | - } |
|
| 364 | - elseif ($db_type == 'postgresql') |
|
| 380 | + } elseif ($db_type == 'postgresql') |
|
| 365 | 381 | { |
| 366 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
| 367 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
| 368 | 384 | } |
| 369 | 385 | } |
| 370 | 386 | |
| 371 | - if (!empty($port)) |
|
| 372 | - $db_options['port'] = $port; |
|
| 387 | + if (!empty($port)) { |
|
| 388 | + $db_options['port'] = $port; |
|
| 389 | + } |
|
| 373 | 390 | |
| 374 | - if (!$db_connection) |
|
| 375 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 391 | + if (!$db_connection) { |
|
| 392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 393 | + } |
|
| 376 | 394 | } |
| 377 | 395 | } |
| 378 | 396 | |
@@ -400,8 +418,9 @@ discard block |
||
| 400 | 418 | // @todo REMOVE THIS!! |
| 401 | 419 | else |
| 402 | 420 | { |
| 403 | - if (function_exists('doStep' . $_GET['step'])) |
|
| 404 | - call_user_func('doStep' . $_GET['step']); |
|
| 421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
| 422 | + call_user_func('doStep' . $_GET['step']); |
|
| 423 | + } |
|
| 405 | 424 | } |
| 406 | 425 | // Show the footer. |
| 407 | 426 | template_install_below(); |
@@ -419,8 +438,9 @@ discard block |
||
| 419 | 438 | $incontext['sub_template'] = 'welcome_message'; |
| 420 | 439 | |
| 421 | 440 | // Done the submission? |
| 422 | - if (isset($_POST['contbutt'])) |
|
| 423 | - return true; |
|
| 441 | + if (isset($_POST['contbutt'])) { |
|
| 442 | + return true; |
|
| 443 | + } |
|
| 424 | 444 | |
| 425 | 445 | // See if we think they have already installed it? |
| 426 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -428,14 +448,17 @@ discard block |
||
| 428 | 448 | $probably_installed = 0; |
| 429 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
| 430 | 450 | { |
| 431 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
| 432 | - $probably_installed++; |
|
| 433 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
| 434 | - $probably_installed++; |
|
| 451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
| 452 | + $probably_installed++; |
|
| 453 | + } |
|
| 454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
| 455 | + $probably_installed++; |
|
| 456 | + } |
|
| 435 | 457 | } |
| 436 | 458 | |
| 437 | - if ($probably_installed == 2) |
|
| 438 | - $incontext['warning'] = $txt['error_already_installed']; |
|
| 459 | + if ($probably_installed == 2) { |
|
| 460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
| 461 | + } |
|
| 439 | 462 | } |
| 440 | 463 | |
| 441 | 464 | // Is some database support even compiled in? |
@@ -450,45 +473,54 @@ discard block |
||
| 450 | 473 | $databases[$key]['supported'] = false; |
| 451 | 474 | $notFoundSQLFile = true; |
| 452 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
| 476 | + } else { |
|
| 477 | + $incontext['supported_databases'][] = $db; |
|
| 453 | 478 | } |
| 454 | - else |
|
| 455 | - $incontext['supported_databases'][] = $db; |
|
| 456 | 479 | } |
| 457 | 480 | } |
| 458 | 481 | |
| 459 | 482 | // Check the PHP version. |
| 460 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
| 461 | - $error = 'error_php_too_low'; |
|
| 483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
| 484 | + $error = 'error_php_too_low'; |
|
| 485 | + } |
|
| 462 | 486 | // Make sure we have a supported database |
| 463 | - elseif (empty($incontext['supported_databases'])) |
|
| 464 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 487 | + elseif (empty($incontext['supported_databases'])) { |
|
| 488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 489 | + } |
|
| 465 | 490 | // How about session support? Some crazy sysadmin remove it? |
| 466 | - elseif (!function_exists('session_start')) |
|
| 467 | - $error = 'error_session_missing'; |
|
| 491 | + elseif (!function_exists('session_start')) { |
|
| 492 | + $error = 'error_session_missing'; |
|
| 493 | + } |
|
| 468 | 494 | // Make sure they uploaded all the files. |
| 469 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
| 470 | - $error = 'error_missing_files'; |
|
| 495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
| 496 | + $error = 'error_missing_files'; |
|
| 497 | + } |
|
| 471 | 498 | // Very simple check on the session.save_path for Windows. |
| 472 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
| 473 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
| 474 | - $error = 'error_session_save_path'; |
|
| 500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
| 501 | + $error = 'error_session_save_path'; |
|
| 502 | + } |
|
| 475 | 503 | |
| 476 | 504 | // Since each of the three messages would look the same, anyway... |
| 477 | - if (isset($error)) |
|
| 478 | - $incontext['error'] = $txt[$error]; |
|
| 505 | + if (isset($error)) { |
|
| 506 | + $incontext['error'] = $txt[$error]; |
|
| 507 | + } |
|
| 479 | 508 | |
| 480 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
| 481 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
| 482 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
| 511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 512 | + } |
|
| 483 | 513 | |
| 484 | 514 | // Confirm mbstring is loaded... |
| 485 | - if (!extension_loaded('mbstring')) |
|
| 486 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
| 515 | + if (!extension_loaded('mbstring')) { |
|
| 516 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
| 517 | + } |
|
| 487 | 518 | |
| 488 | 519 | // Check for https stream support. |
| 489 | 520 | $supported_streams = stream_get_wrappers(); |
| 490 | - if (!in_array('https', $supported_streams)) |
|
| 491 | - $incontext['warning'] = $txt['install_no_https']; |
|
| 521 | + if (!in_array('https', $supported_streams)) { |
|
| 522 | + $incontext['warning'] = $txt['install_no_https']; |
|
| 523 | + } |
|
| 492 | 524 | |
| 493 | 525 | return false; |
| 494 | 526 | } |
@@ -514,12 +546,14 @@ discard block |
||
| 514 | 546 | 'db_last_error.php', |
| 515 | 547 | ); |
| 516 | 548 | |
| 517 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
| 518 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 549 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
| 550 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 551 | + } |
|
| 519 | 552 | |
| 520 | 553 | // With mod_security installed, we could attempt to fix it with .htaccess. |
| 521 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
| 522 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 554 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
| 555 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 556 | + } |
|
| 523 | 557 | |
| 524 | 558 | $failed_files = array(); |
| 525 | 559 | |
@@ -535,12 +569,14 @@ discard block |
||
| 535 | 569 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
| 536 | 570 | |
| 537 | 571 | // Well, 755 hopefully worked... if not, try 777. |
| 538 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
| 539 | - $failed_files[] = $file; |
|
| 572 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
| 573 | + $failed_files[] = $file; |
|
| 574 | + } |
|
| 540 | 575 | } |
| 541 | 576 | } |
| 542 | - foreach ($extra_files as $file) |
|
| 543 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 577 | + foreach ($extra_files as $file) { |
|
| 578 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 579 | + } |
|
| 544 | 580 | } |
| 545 | 581 | // Windows is trickier. Let's try opening for r+... |
| 546 | 582 | else |
@@ -550,30 +586,35 @@ discard block |
||
| 550 | 586 | foreach ($writable_files as $file) |
| 551 | 587 | { |
| 552 | 588 | // Folders can't be opened for write... but the index.php in them can ;) |
| 553 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
| 554 | - $file .= '/index.php'; |
|
| 589 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
| 590 | + $file .= '/index.php'; |
|
| 591 | + } |
|
| 555 | 592 | |
| 556 | 593 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 557 | 594 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
| 558 | 595 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
| 559 | 596 | |
| 560 | 597 | // Hmm, okay, try just for write in that case... |
| 561 | - if (!is_resource($fp)) |
|
| 562 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 598 | + if (!is_resource($fp)) { |
|
| 599 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 600 | + } |
|
| 563 | 601 | |
| 564 | - if (!is_resource($fp)) |
|
| 565 | - $failed_files[] = $file; |
|
| 602 | + if (!is_resource($fp)) { |
|
| 603 | + $failed_files[] = $file; |
|
| 604 | + } |
|
| 566 | 605 | |
| 567 | 606 | @fclose($fp); |
| 568 | 607 | } |
| 569 | - foreach ($extra_files as $file) |
|
| 570 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 608 | + foreach ($extra_files as $file) { |
|
| 609 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 610 | + } |
|
| 571 | 611 | } |
| 572 | 612 | |
| 573 | 613 | $failure = count($failed_files) >= 1; |
| 574 | 614 | |
| 575 | - if (!isset($_SERVER)) |
|
| 576 | - return !$failure; |
|
| 615 | + if (!isset($_SERVER)) { |
|
| 616 | + return !$failure; |
|
| 617 | + } |
|
| 577 | 618 | |
| 578 | 619 | // Put the list into context. |
| 579 | 620 | $incontext['failed_files'] = $failed_files; |
@@ -621,19 +662,23 @@ discard block |
||
| 621 | 662 | |
| 622 | 663 | if (!isset($ftp) || $ftp->error !== false) |
| 623 | 664 | { |
| 624 | - if (!isset($ftp)) |
|
| 625 | - $ftp = new ftp_connection(null); |
|
| 665 | + if (!isset($ftp)) { |
|
| 666 | + $ftp = new ftp_connection(null); |
|
| 667 | + } |
|
| 626 | 668 | // Save the error so we can mess with listing... |
| 627 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
| 628 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 669 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
| 670 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 671 | + } |
|
| 629 | 672 | |
| 630 | 673 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 631 | 674 | |
| 632 | - if (empty($_POST['ftp_path']) && $found_path) |
|
| 633 | - $_POST['ftp_path'] = $detect_path; |
|
| 675 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
| 676 | + $_POST['ftp_path'] = $detect_path; |
|
| 677 | + } |
|
| 634 | 678 | |
| 635 | - if (!isset($_POST['ftp_username'])) |
|
| 636 | - $_POST['ftp_username'] = $username; |
|
| 679 | + if (!isset($_POST['ftp_username'])) { |
|
| 680 | + $_POST['ftp_username'] = $username; |
|
| 681 | + } |
|
| 637 | 682 | |
| 638 | 683 | // Set the username etc, into context. |
| 639 | 684 | $incontext['ftp'] = array( |
@@ -645,8 +690,7 @@ discard block |
||
| 645 | 690 | ); |
| 646 | 691 | |
| 647 | 692 | return false; |
| 648 | - } |
|
| 649 | - else |
|
| 693 | + } else |
|
| 650 | 694 | { |
| 651 | 695 | $_SESSION['installer_temp_ftp'] = array( |
| 652 | 696 | 'server' => $_POST['ftp_server'], |
@@ -660,10 +704,12 @@ discard block |
||
| 660 | 704 | |
| 661 | 705 | foreach ($failed_files as $file) |
| 662 | 706 | { |
| 663 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 664 | - $ftp->chmod($file, 0755); |
|
| 665 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 666 | - $ftp->chmod($file, 0777); |
|
| 707 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 708 | + $ftp->chmod($file, 0755); |
|
| 709 | + } |
|
| 710 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 711 | + $ftp->chmod($file, 0777); |
|
| 712 | + } |
|
| 667 | 713 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 668 | 714 | { |
| 669 | 715 | $failed_files_updated[] = $file; |
@@ -719,15 +765,17 @@ discard block |
||
| 719 | 765 | |
| 720 | 766 | if (!$foundOne) |
| 721 | 767 | { |
| 722 | - if (isset($db['default_host'])) |
|
| 723 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 768 | + if (isset($db['default_host'])) { |
|
| 769 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 770 | + } |
|
| 724 | 771 | if (isset($db['default_user'])) |
| 725 | 772 | { |
| 726 | 773 | $incontext['db']['user'] = ini_get($db['default_user']); |
| 727 | 774 | $incontext['db']['name'] = ini_get($db['default_user']); |
| 728 | 775 | } |
| 729 | - if (isset($db['default_password'])) |
|
| 730 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 776 | + if (isset($db['default_password'])) { |
|
| 777 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 778 | + } |
|
| 731 | 779 | |
| 732 | 780 | // For simplicity and less confusion, leave the port blank by default |
| 733 | 781 | $incontext['db']['port'] = ''; |
@@ -746,10 +794,10 @@ discard block |
||
| 746 | 794 | $incontext['db']['server'] = $_POST['db_server']; |
| 747 | 795 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
| 748 | 796 | |
| 749 | - if (!empty($_POST['db_port'])) |
|
| 750 | - $incontext['db']['port'] = $_POST['db_port']; |
|
| 751 | - } |
|
| 752 | - else |
|
| 797 | + if (!empty($_POST['db_port'])) { |
|
| 798 | + $incontext['db']['port'] = $_POST['db_port']; |
|
| 799 | + } |
|
| 800 | + } else |
|
| 753 | 801 | { |
| 754 | 802 | $incontext['db']['prefix'] = 'smf_'; |
| 755 | 803 | } |
@@ -785,10 +833,11 @@ discard block |
||
| 785 | 833 | if (!empty($_POST['db_port'])) |
| 786 | 834 | { |
| 787 | 835 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
| 788 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
| 789 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 790 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
| 791 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 836 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
| 837 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 838 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
| 839 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 840 | + } |
|
| 792 | 841 | } |
| 793 | 842 | |
| 794 | 843 | // God I hope it saved! |
@@ -801,8 +850,9 @@ discard block |
||
| 801 | 850 | // Make sure it works. |
| 802 | 851 | require(dirname(__FILE__) . '/Settings.php'); |
| 803 | 852 | |
| 804 | - if (empty($sourcedir)) |
|
| 805 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 853 | + if (empty($sourcedir)) { |
|
| 854 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 855 | + } |
|
| 806 | 856 | |
| 807 | 857 | // Better find the database file! |
| 808 | 858 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -812,18 +862,21 @@ discard block |
||
| 812 | 862 | } |
| 813 | 863 | |
| 814 | 864 | // Now include it for database functions! |
| 815 | - if (!defined('SMF')) |
|
| 816 | - define('SMF', 1); |
|
| 865 | + if (!defined('SMF')) { |
|
| 866 | + define('SMF', 1); |
|
| 867 | + } |
|
| 817 | 868 | |
| 818 | 869 | $modSettings['disableQueryCheck'] = true; |
| 819 | - if (empty($smcFunc)) |
|
| 820 | - $smcFunc = array(); |
|
| 870 | + if (empty($smcFunc)) { |
|
| 871 | + $smcFunc = array(); |
|
| 872 | + } |
|
| 821 | 873 | |
| 822 | 874 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 823 | 875 | |
| 824 | 876 | // What - running PHP4? The shame! |
| 825 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 826 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 877 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 878 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 879 | + } |
|
| 827 | 880 | |
| 828 | 881 | // Attempt a connection. |
| 829 | 882 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -911,12 +964,14 @@ discard block |
||
| 911 | 964 | $incontext['page_title'] = $txt['install_settings']; |
| 912 | 965 | |
| 913 | 966 | // Let's see if we got the database type correct. |
| 914 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
| 915 | - $db_type = $_POST['db_type']; |
|
| 967 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
| 968 | + $db_type = $_POST['db_type']; |
|
| 969 | + } |
|
| 916 | 970 | |
| 917 | 971 | // Else we'd better be able to get the connection. |
| 918 | - else |
|
| 919 | - load_database(); |
|
| 972 | + else { |
|
| 973 | + load_database(); |
|
| 974 | + } |
|
| 920 | 975 | |
| 921 | 976 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
| 922 | 977 | |
@@ -936,12 +991,14 @@ discard block |
||
| 936 | 991 | // Submitting? |
| 937 | 992 | if (isset($_POST['boardurl'])) |
| 938 | 993 | { |
| 939 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 940 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 941 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 942 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 943 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 944 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 994 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 995 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 996 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 997 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 998 | + } |
|
| 999 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1000 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1001 | + } |
|
| 945 | 1002 | |
| 946 | 1003 | // Save these variables. |
| 947 | 1004 | $vars = array( |
@@ -980,10 +1037,10 @@ discard block |
||
| 980 | 1037 | { |
| 981 | 1038 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
| 982 | 1039 | return false; |
| 983 | - } |
|
| 984 | - else |
|
| 985 | - // Set the character set here. |
|
| 1040 | + } else { |
|
| 1041 | + // Set the character set here. |
|
| 986 | 1042 | updateSettingsFile(array('db_character_set' => 'utf8')); |
| 1043 | + } |
|
| 987 | 1044 | } |
| 988 | 1045 | |
| 989 | 1046 | // Good, skip on. |
@@ -1003,8 +1060,9 @@ discard block |
||
| 1003 | 1060 | $incontext['continue'] = 1; |
| 1004 | 1061 | |
| 1005 | 1062 | // Already done? |
| 1006 | - if (isset($_POST['pop_done'])) |
|
| 1007 | - return true; |
|
| 1063 | + if (isset($_POST['pop_done'])) { |
|
| 1064 | + return true; |
|
| 1065 | + } |
|
| 1008 | 1066 | |
| 1009 | 1067 | // Reload settings. |
| 1010 | 1068 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1022,8 +1080,9 @@ discard block |
||
| 1022 | 1080 | $modSettings = array(); |
| 1023 | 1081 | if ($result !== false) |
| 1024 | 1082 | { |
| 1025 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1026 | - $modSettings[$row['variable']] = $row['value']; |
|
| 1083 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1084 | + $modSettings[$row['variable']] = $row['value']; |
|
| 1085 | + } |
|
| 1027 | 1086 | $smcFunc['db_free_result']($result); |
| 1028 | 1087 | |
| 1029 | 1088 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1036,20 +1095,22 @@ discard block |
||
| 1036 | 1095 | $modSettings['disableQueryCheck'] = true; |
| 1037 | 1096 | |
| 1038 | 1097 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
| 1039 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
| 1040 | - $smcFunc['db_query']('', ' |
|
| 1098 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1099 | + $smcFunc['db_query']('', ' |
|
| 1041 | 1100 | SET NAMES {string:utf8}', |
| 1042 | 1101 | array( |
| 1043 | 1102 | 'db_error_skip' => true, |
| 1044 | 1103 | 'utf8' => 'utf8', |
| 1045 | 1104 | ) |
| 1046 | 1105 | ); |
| 1106 | + } |
|
| 1047 | 1107 | |
| 1048 | 1108 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
| 1049 | - if (substr(__DIR__, -1) == '\\') |
|
| 1050 | - $attachdir = __DIR__ . 'attachments'; |
|
| 1051 | - else |
|
| 1052 | - $attachdir = __DIR__ . '/attachments'; |
|
| 1109 | + if (substr(__DIR__, -1) == '\\') { |
|
| 1110 | + $attachdir = __DIR__ . 'attachments'; |
|
| 1111 | + } else { |
|
| 1112 | + $attachdir = __DIR__ . '/attachments'; |
|
| 1113 | + } |
|
| 1053 | 1114 | |
| 1054 | 1115 | $replaces = array( |
| 1055 | 1116 | '{$db_prefix}' => $db_prefix, |
@@ -1066,8 +1127,9 @@ discard block |
||
| 1066 | 1127 | |
| 1067 | 1128 | foreach ($txt as $key => $value) |
| 1068 | 1129 | { |
| 1069 | - if (substr($key, 0, 8) == 'default_') |
|
| 1070 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1130 | + if (substr($key, 0, 8) == 'default_') { |
|
| 1131 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1132 | + } |
|
| 1071 | 1133 | } |
| 1072 | 1134 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
| 1073 | 1135 | |
@@ -1082,8 +1144,9 @@ discard block |
||
| 1082 | 1144 | |
| 1083 | 1145 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 1084 | 1146 | { |
| 1085 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 1086 | - $engines[] = $row['Engine']; |
|
| 1147 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 1148 | + $engines[] = $row['Engine']; |
|
| 1149 | + } |
|
| 1087 | 1150 | } |
| 1088 | 1151 | |
| 1089 | 1152 | // Done with this now |
@@ -1107,8 +1170,7 @@ discard block |
||
| 1107 | 1170 | $replaces['START TRANSACTION;'] = ''; |
| 1108 | 1171 | $replaces['COMMIT;'] = ''; |
| 1109 | 1172 | } |
| 1110 | - } |
|
| 1111 | - else |
|
| 1173 | + } else |
|
| 1112 | 1174 | { |
| 1113 | 1175 | $has_innodb = false; |
| 1114 | 1176 | } |
@@ -1130,21 +1192,24 @@ discard block |
||
| 1130 | 1192 | foreach ($sql_lines as $count => $line) |
| 1131 | 1193 | { |
| 1132 | 1194 | // No comments allowed! |
| 1133 | - if (substr(trim($line), 0, 1) != '#') |
|
| 1134 | - $current_statement .= "\n" . rtrim($line); |
|
| 1195 | + if (substr(trim($line), 0, 1) != '#') { |
|
| 1196 | + $current_statement .= "\n" . rtrim($line); |
|
| 1197 | + } |
|
| 1135 | 1198 | |
| 1136 | 1199 | // Is this the end of the query string? |
| 1137 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
| 1138 | - continue; |
|
| 1200 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
| 1201 | + continue; |
|
| 1202 | + } |
|
| 1139 | 1203 | |
| 1140 | 1204 | // Does this table already exist? If so, don't insert more data into it! |
| 1141 | 1205 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
| 1142 | 1206 | { |
| 1143 | 1207 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1144 | - if (!empty($matches[0])) |
|
| 1145 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1146 | - else |
|
| 1147 | - $incontext['sql_results']['insert_dups']++; |
|
| 1208 | + if (!empty($matches[0])) { |
|
| 1209 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1210 | + } else { |
|
| 1211 | + $incontext['sql_results']['insert_dups']++; |
|
| 1212 | + } |
|
| 1148 | 1213 | |
| 1149 | 1214 | $current_statement = ''; |
| 1150 | 1215 | continue; |
@@ -1153,8 +1218,9 @@ discard block |
||
| 1153 | 1218 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
| 1154 | 1219 | { |
| 1155 | 1220 | // Use the appropriate function based on the DB type |
| 1156 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
| 1157 | - $db_errorno = $db_type . '_errno'; |
|
| 1221 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
| 1222 | + $db_errorno = $db_type . '_errno'; |
|
| 1223 | + } |
|
| 1158 | 1224 | |
| 1159 | 1225 | // Error 1050: Table already exists! |
| 1160 | 1226 | // @todo Needs to be made better! |
@@ -1169,18 +1235,18 @@ discard block |
||
| 1169 | 1235 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
| 1170 | 1236 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
| 1171 | 1237 | } |
| 1172 | - } |
|
| 1173 | - else |
|
| 1238 | + } else |
|
| 1174 | 1239 | { |
| 1175 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1176 | - $incontext['sql_results']['tables']++; |
|
| 1177 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1240 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
| 1241 | + $incontext['sql_results']['tables']++; |
|
| 1242 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1178 | 1243 | { |
| 1179 | 1244 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1180 | - if (!empty($matches[0])) |
|
| 1181 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1182 | - else |
|
| 1183 | - $incontext['sql_results']['inserts']++; |
|
| 1245 | + if (!empty($matches[0])) { |
|
| 1246 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1247 | + } else { |
|
| 1248 | + $incontext['sql_results']['inserts']++; |
|
| 1249 | + } |
|
| 1184 | 1250 | } |
| 1185 | 1251 | } |
| 1186 | 1252 | |
@@ -1193,15 +1259,17 @@ discard block |
||
| 1193 | 1259 | // Sort out the context for the SQL. |
| 1194 | 1260 | foreach ($incontext['sql_results'] as $key => $number) |
| 1195 | 1261 | { |
| 1196 | - if ($number == 0) |
|
| 1197 | - unset($incontext['sql_results'][$key]); |
|
| 1198 | - else |
|
| 1199 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1262 | + if ($number == 0) { |
|
| 1263 | + unset($incontext['sql_results'][$key]); |
|
| 1264 | + } else { |
|
| 1265 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1266 | + } |
|
| 1200 | 1267 | } |
| 1201 | 1268 | |
| 1202 | 1269 | // Make sure UTF will be used globally. |
| 1203 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
| 1204 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1270 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
| 1271 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1272 | + } |
|
| 1205 | 1273 | |
| 1206 | 1274 | // Maybe we can auto-detect better cookie settings? |
| 1207 | 1275 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1212,16 +1280,20 @@ discard block |
||
| 1212 | 1280 | $globalCookies = false; |
| 1213 | 1281 | |
| 1214 | 1282 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
| 1215 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
| 1216 | - $globalCookies = true; |
|
| 1283 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
| 1284 | + $globalCookies = true; |
|
| 1285 | + } |
|
| 1217 | 1286 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
| 1218 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
| 1219 | - $localCookies = true; |
|
| 1287 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
| 1288 | + $localCookies = true; |
|
| 1289 | + } |
|
| 1220 | 1290 | |
| 1221 | - if ($globalCookies) |
|
| 1222 | - $newSettings[] = array('globalCookies', '1'); |
|
| 1223 | - if ($localCookies) |
|
| 1224 | - $newSettings[] = array('localCookies', '1'); |
|
| 1291 | + if ($globalCookies) { |
|
| 1292 | + $newSettings[] = array('globalCookies', '1'); |
|
| 1293 | + } |
|
| 1294 | + if ($localCookies) { |
|
| 1295 | + $newSettings[] = array('localCookies', '1'); |
|
| 1296 | + } |
|
| 1225 | 1297 | } |
| 1226 | 1298 | |
| 1227 | 1299 | // Are we allowing stat collection? |
@@ -1239,16 +1311,17 @@ discard block |
||
| 1239 | 1311 | fwrite($fp, $out); |
| 1240 | 1312 | |
| 1241 | 1313 | $return_data = ''; |
| 1242 | - while (!feof($fp)) |
|
| 1243 | - $return_data .= fgets($fp, 128); |
|
| 1314 | + while (!feof($fp)) { |
|
| 1315 | + $return_data .= fgets($fp, 128); |
|
| 1316 | + } |
|
| 1244 | 1317 | |
| 1245 | 1318 | fclose($fp); |
| 1246 | 1319 | |
| 1247 | 1320 | // Get the unique site ID. |
| 1248 | 1321 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1249 | 1322 | |
| 1250 | - if (!empty($ID[1])) |
|
| 1251 | - $smcFunc['db_insert']('replace', |
|
| 1323 | + if (!empty($ID[1])) { |
|
| 1324 | + $smcFunc['db_insert']('replace', |
|
| 1252 | 1325 | $db_prefix . 'settings', |
| 1253 | 1326 | array('variable' => 'string', 'value' => 'string'), |
| 1254 | 1327 | array( |
@@ -1257,11 +1330,12 @@ discard block |
||
| 1257 | 1330 | ), |
| 1258 | 1331 | array('variable') |
| 1259 | 1332 | ); |
| 1333 | + } |
|
| 1260 | 1334 | } |
| 1261 | 1335 | } |
| 1262 | 1336 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1263 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1264 | - $smcFunc['db_query']('', ' |
|
| 1337 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1338 | + $smcFunc['db_query']('', ' |
|
| 1265 | 1339 | DELETE FROM {db_prefix}settings |
| 1266 | 1340 | WHERE variable = {string:enable_sm_stats}', |
| 1267 | 1341 | array( |
@@ -1269,20 +1343,23 @@ discard block |
||
| 1269 | 1343 | 'db_error_skip' => true, |
| 1270 | 1344 | ) |
| 1271 | 1345 | ); |
| 1346 | + } |
|
| 1272 | 1347 | |
| 1273 | 1348 | // Are we enabling SSL? |
| 1274 | - if (!empty($_POST['force_ssl'])) |
|
| 1275 | - $newSettings[] = array('force_ssl', 2); |
|
| 1349 | + if (!empty($_POST['force_ssl'])) { |
|
| 1350 | + $newSettings[] = array('force_ssl', 2); |
|
| 1351 | + } |
|
| 1276 | 1352 | |
| 1277 | 1353 | // Setting a timezone is required. |
| 1278 | 1354 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
| 1279 | 1355 | { |
| 1280 | 1356 | // Get PHP's default timezone, if set |
| 1281 | 1357 | $ini_tz = ini_get('date.timezone'); |
| 1282 | - if (!empty($ini_tz)) |
|
| 1283 | - $timezone_id = $ini_tz; |
|
| 1284 | - else |
|
| 1285 | - $timezone_id = ''; |
|
| 1358 | + if (!empty($ini_tz)) { |
|
| 1359 | + $timezone_id = $ini_tz; |
|
| 1360 | + } else { |
|
| 1361 | + $timezone_id = ''; |
|
| 1362 | + } |
|
| 1286 | 1363 | |
| 1287 | 1364 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 1288 | 1365 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1291,8 +1368,9 @@ discard block |
||
| 1291 | 1368 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
| 1292 | 1369 | } |
| 1293 | 1370 | |
| 1294 | - if (date_default_timezone_set($timezone_id)) |
|
| 1295 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1371 | + if (date_default_timezone_set($timezone_id)) { |
|
| 1372 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1373 | + } |
|
| 1296 | 1374 | } |
| 1297 | 1375 | |
| 1298 | 1376 | if (!empty($newSettings)) |
@@ -1323,16 +1401,18 @@ discard block |
||
| 1323 | 1401 | } |
| 1324 | 1402 | |
| 1325 | 1403 | // MySQL specific stuff |
| 1326 | - if (substr($db_type, 0, 5) != 'mysql') |
|
| 1327 | - return false; |
|
| 1404 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
| 1405 | + return false; |
|
| 1406 | + } |
|
| 1328 | 1407 | |
| 1329 | 1408 | // Find database user privileges. |
| 1330 | 1409 | $privs = array(); |
| 1331 | 1410 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
| 1332 | 1411 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
| 1333 | 1412 | { |
| 1334 | - if ($row['Privilege'] == 'Alter') |
|
| 1335 | - $privs[] = $row['Privilege']; |
|
| 1413 | + if ($row['Privilege'] == 'Alter') { |
|
| 1414 | + $privs[] = $row['Privilege']; |
|
| 1415 | + } |
|
| 1336 | 1416 | } |
| 1337 | 1417 | $smcFunc['db_free_result']($get_privs); |
| 1338 | 1418 | |
@@ -1362,8 +1442,9 @@ discard block |
||
| 1362 | 1442 | $incontext['continue'] = 1; |
| 1363 | 1443 | |
| 1364 | 1444 | // Skipping? |
| 1365 | - if (!empty($_POST['skip'])) |
|
| 1366 | - return true; |
|
| 1445 | + if (!empty($_POST['skip'])) { |
|
| 1446 | + return true; |
|
| 1447 | + } |
|
| 1367 | 1448 | |
| 1368 | 1449 | // Need this to check whether we need the database password. |
| 1369 | 1450 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1380,18 +1461,22 @@ discard block |
||
| 1380 | 1461 | // We need this to properly hash the password for Admin |
| 1381 | 1462 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
| 1382 | 1463 | global $sourcedir; |
| 1383 | - if (function_exists('mb_strtolower')) |
|
| 1384 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1464 | + if (function_exists('mb_strtolower')) { |
|
| 1465 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1466 | + } |
|
| 1385 | 1467 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1386 | 1468 | return utf8_strtolower($string); |
| 1387 | 1469 | }; |
| 1388 | 1470 | |
| 1389 | - if (!isset($_POST['username'])) |
|
| 1390 | - $_POST['username'] = ''; |
|
| 1391 | - if (!isset($_POST['email'])) |
|
| 1392 | - $_POST['email'] = ''; |
|
| 1393 | - if (!isset($_POST['server_email'])) |
|
| 1394 | - $_POST['server_email'] = ''; |
|
| 1471 | + if (!isset($_POST['username'])) { |
|
| 1472 | + $_POST['username'] = ''; |
|
| 1473 | + } |
|
| 1474 | + if (!isset($_POST['email'])) { |
|
| 1475 | + $_POST['email'] = ''; |
|
| 1476 | + } |
|
| 1477 | + if (!isset($_POST['server_email'])) { |
|
| 1478 | + $_POST['server_email'] = ''; |
|
| 1479 | + } |
|
| 1395 | 1480 | |
| 1396 | 1481 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
| 1397 | 1482 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1410,8 +1495,9 @@ discard block |
||
| 1410 | 1495 | 'admin_group' => 1, |
| 1411 | 1496 | ) |
| 1412 | 1497 | ); |
| 1413 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1414 | - $incontext['skip'] = 1; |
|
| 1498 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1499 | + $incontext['skip'] = 1; |
|
| 1500 | + } |
|
| 1415 | 1501 | $smcFunc['db_free_result']($request); |
| 1416 | 1502 | |
| 1417 | 1503 | // Trying to create an account? |
@@ -1442,8 +1528,9 @@ discard block |
||
| 1442 | 1528 | } |
| 1443 | 1529 | |
| 1444 | 1530 | // Update the webmaster's email? |
| 1445 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
| 1446 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1531 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
| 1532 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1533 | + } |
|
| 1447 | 1534 | |
| 1448 | 1535 | // Work out whether we're going to have dodgy characters and remove them. |
| 1449 | 1536 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1466,32 +1553,27 @@ discard block |
||
| 1466 | 1553 | $smcFunc['db_free_result']($result); |
| 1467 | 1554 | |
| 1468 | 1555 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
| 1469 | - } |
|
| 1470 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1556 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1471 | 1557 | { |
| 1472 | 1558 | // Try the previous step again. |
| 1473 | 1559 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
| 1474 | 1560 | return false; |
| 1475 | - } |
|
| 1476 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1561 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1477 | 1562 | { |
| 1478 | 1563 | // Try the previous step again. |
| 1479 | 1564 | $incontext['error'] = $txt['error_invalid_characters_username']; |
| 1480 | 1565 | return false; |
| 1481 | - } |
|
| 1482 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1566 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1483 | 1567 | { |
| 1484 | 1568 | // One step back, this time fill out a proper admin email address. |
| 1485 | 1569 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
| 1486 | 1570 | return false; |
| 1487 | - } |
|
| 1488 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1571 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1489 | 1572 | { |
| 1490 | 1573 | // One step back, this time fill out a proper admin email address. |
| 1491 | 1574 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
| 1492 | 1575 | return false; |
| 1493 | - } |
|
| 1494 | - elseif ($_POST['username'] != '') |
|
| 1576 | + } elseif ($_POST['username'] != '') |
|
| 1495 | 1577 | { |
| 1496 | 1578 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
| 1497 | 1579 | |
@@ -1559,17 +1641,19 @@ discard block |
||
| 1559 | 1641 | reloadSettings(); |
| 1560 | 1642 | |
| 1561 | 1643 | // Bring a warning over. |
| 1562 | - if (!empty($incontext['account_existed'])) |
|
| 1563 | - $incontext['warning'] = $incontext['account_existed']; |
|
| 1644 | + if (!empty($incontext['account_existed'])) { |
|
| 1645 | + $incontext['warning'] = $incontext['account_existed']; |
|
| 1646 | + } |
|
| 1564 | 1647 | |
| 1565 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
| 1566 | - $smcFunc['db_query']('', ' |
|
| 1648 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1649 | + $smcFunc['db_query']('', ' |
|
| 1567 | 1650 | SET NAMES {string:db_character_set}', |
| 1568 | 1651 | array( |
| 1569 | 1652 | 'db_character_set' => $db_character_set, |
| 1570 | 1653 | 'db_error_skip' => true, |
| 1571 | 1654 | ) |
| 1572 | 1655 | ); |
| 1656 | + } |
|
| 1573 | 1657 | |
| 1574 | 1658 | // As track stats is by default enabled let's add some activity. |
| 1575 | 1659 | $smcFunc['db_insert']('ignore', |
@@ -1590,14 +1674,16 @@ discard block |
||
| 1590 | 1674 | // Only proceed if we can load the data. |
| 1591 | 1675 | if ($request) |
| 1592 | 1676 | { |
| 1593 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1594 | - $modSettings[$row[0]] = $row[1]; |
|
| 1677 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1678 | + $modSettings[$row[0]] = $row[1]; |
|
| 1679 | + } |
|
| 1595 | 1680 | $smcFunc['db_free_result']($request); |
| 1596 | 1681 | } |
| 1597 | 1682 | |
| 1598 | 1683 | // Automatically log them in ;) |
| 1599 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
| 1600 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1684 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
| 1685 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1686 | + } |
|
| 1601 | 1687 | |
| 1602 | 1688 | $result = $smcFunc['db_query']('', ' |
| 1603 | 1689 | SELECT value |
@@ -1608,13 +1694,14 @@ discard block |
||
| 1608 | 1694 | 'db_error_skip' => true, |
| 1609 | 1695 | ) |
| 1610 | 1696 | ); |
| 1611 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1612 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1697 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1698 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1699 | + } |
|
| 1613 | 1700 | $smcFunc['db_free_result']($result); |
| 1614 | 1701 | |
| 1615 | - if (empty($db_sessions)) |
|
| 1616 | - $_SESSION['admin_time'] = time(); |
|
| 1617 | - else |
|
| 1702 | + if (empty($db_sessions)) { |
|
| 1703 | + $_SESSION['admin_time'] = time(); |
|
| 1704 | + } else |
|
| 1618 | 1705 | { |
| 1619 | 1706 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
| 1620 | 1707 | |
@@ -1638,8 +1725,9 @@ discard block |
||
| 1638 | 1725 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
| 1639 | 1726 | function($string){ |
| 1640 | 1727 | global $sourcedir; |
| 1641 | - if (function_exists('mb_strtolower')) |
|
| 1642 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1728 | + if (function_exists('mb_strtolower')) { |
|
| 1729 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1730 | + } |
|
| 1643 | 1731 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1644 | 1732 | return utf8_strtolower($string); |
| 1645 | 1733 | }; |
@@ -1655,8 +1743,9 @@ discard block |
||
| 1655 | 1743 | ) |
| 1656 | 1744 | ); |
| 1657 | 1745 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
| 1658 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1659 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1746 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1747 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1748 | + } |
|
| 1660 | 1749 | $smcFunc['db_free_result']($request); |
| 1661 | 1750 | |
| 1662 | 1751 | // Now is the perfect time to fetch the SM files. |
@@ -1675,8 +1764,9 @@ discard block |
||
| 1675 | 1764 | |
| 1676 | 1765 | // Check if we need some stupid MySQL fix. |
| 1677 | 1766 | $server_version = $smcFunc['db_server_info'](); |
| 1678 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1679 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1767 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1768 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1769 | + } |
|
| 1680 | 1770 | |
| 1681 | 1771 | // Some final context for the template. |
| 1682 | 1772 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1696,8 +1786,9 @@ discard block |
||
| 1696 | 1786 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
| 1697 | 1787 | |
| 1698 | 1788 | // @todo Do we just want to read the file in clean, and split it this way always? |
| 1699 | - if (count($settingsArray) == 1) |
|
| 1700 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1789 | + if (count($settingsArray) == 1) { |
|
| 1790 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1791 | + } |
|
| 1701 | 1792 | |
| 1702 | 1793 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1703 | 1794 | { |
@@ -1712,19 +1803,22 @@ discard block |
||
| 1712 | 1803 | continue; |
| 1713 | 1804 | } |
| 1714 | 1805 | |
| 1715 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
| 1716 | - $settingsArray[$i] = ''; |
|
| 1806 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
| 1807 | + $settingsArray[$i] = ''; |
|
| 1808 | + } |
|
| 1717 | 1809 | |
| 1718 | 1810 | // Don't trim or bother with it if it's not a variable. |
| 1719 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 1720 | - continue; |
|
| 1811 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 1812 | + continue; |
|
| 1813 | + } |
|
| 1721 | 1814 | |
| 1722 | 1815 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
| 1723 | 1816 | |
| 1724 | - foreach ($vars as $var => $val) |
|
| 1725 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1817 | + foreach ($vars as $var => $val) { |
|
| 1818 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1726 | 1819 | { |
| 1727 | 1820 | $comment = strstr($settingsArray[$i], '#'); |
| 1821 | + } |
|
| 1728 | 1822 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
| 1729 | 1823 | unset($vars[$var]); |
| 1730 | 1824 | } |
@@ -1734,36 +1828,41 @@ discard block |
||
| 1734 | 1828 | if (!empty($vars)) |
| 1735 | 1829 | { |
| 1736 | 1830 | $settingsArray[$i++] = ''; |
| 1737 | - foreach ($vars as $var => $val) |
|
| 1738 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1831 | + foreach ($vars as $var => $val) { |
|
| 1832 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1833 | + } |
|
| 1739 | 1834 | } |
| 1740 | 1835 | |
| 1741 | 1836 | // Blank out the file - done to fix a oddity with some servers. |
| 1742 | 1837 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
| 1743 | - if (!$fp) |
|
| 1744 | - return false; |
|
| 1838 | + if (!$fp) { |
|
| 1839 | + return false; |
|
| 1840 | + } |
|
| 1745 | 1841 | fclose($fp); |
| 1746 | 1842 | |
| 1747 | 1843 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
| 1748 | 1844 | |
| 1749 | 1845 | // Gotta have one of these ;) |
| 1750 | - if (trim($settingsArray[0]) != '<?php') |
|
| 1751 | - fwrite($fp, "<?php\n"); |
|
| 1846 | + if (trim($settingsArray[0]) != '<?php') { |
|
| 1847 | + fwrite($fp, "<?php\n"); |
|
| 1848 | + } |
|
| 1752 | 1849 | |
| 1753 | 1850 | $lines = count($settingsArray); |
| 1754 | 1851 | for ($i = 0; $i < $lines - 1; $i++) |
| 1755 | 1852 | { |
| 1756 | 1853 | // Don't just write a bunch of blank lines. |
| 1757 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
| 1758 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1854 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
| 1855 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1856 | + } |
|
| 1759 | 1857 | } |
| 1760 | 1858 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
| 1761 | 1859 | fclose($fp); |
| 1762 | 1860 | |
| 1763 | 1861 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 1764 | 1862 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 1765 | - if (function_exists('opcache_invalidate')) |
|
| 1766 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1863 | + if (function_exists('opcache_invalidate')) { |
|
| 1864 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1865 | + } |
|
| 1767 | 1866 | |
| 1768 | 1867 | return true; |
| 1769 | 1868 | } |
@@ -1788,9 +1887,9 @@ discard block |
||
| 1788 | 1887 | SecFilterScanPOST Off |
| 1789 | 1888 | </IfModule>'; |
| 1790 | 1889 | |
| 1791 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
| 1792 | - return true; |
|
| 1793 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1890 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
| 1891 | + return true; |
|
| 1892 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1794 | 1893 | { |
| 1795 | 1894 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
| 1796 | 1895 | |
@@ -1802,29 +1901,28 @@ discard block |
||
| 1802 | 1901 | fwrite($ht_handle, $htaccess_addition); |
| 1803 | 1902 | fclose($ht_handle); |
| 1804 | 1903 | return true; |
| 1904 | + } else { |
|
| 1905 | + return false; |
|
| 1805 | 1906 | } |
| 1806 | - else |
|
| 1807 | - return false; |
|
| 1907 | + } else { |
|
| 1908 | + return true; |
|
| 1808 | 1909 | } |
| 1809 | - else |
|
| 1810 | - return true; |
|
| 1811 | - } |
|
| 1812 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
| 1813 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1814 | - elseif (is_writable(dirname(__FILE__))) |
|
| 1910 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
| 1911 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1912 | + } elseif (is_writable(dirname(__FILE__))) |
|
| 1815 | 1913 | { |
| 1816 | 1914 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
| 1817 | 1915 | { |
| 1818 | 1916 | fwrite($ht_handle, $htaccess_addition); |
| 1819 | 1917 | fclose($ht_handle); |
| 1820 | 1918 | return true; |
| 1919 | + } else { |
|
| 1920 | + return false; |
|
| 1821 | 1921 | } |
| 1822 | - else |
|
| 1922 | + } else { |
|
| 1823 | 1923 | return false; |
| 1824 | 1924 | } |
| 1825 | - else |
|
| 1826 | - return false; |
|
| 1827 | -} |
|
| 1925 | + } |
|
| 1828 | 1926 | |
| 1829 | 1927 | function template_install_above() |
| 1830 | 1928 | { |
@@ -1862,9 +1960,10 @@ discard block |
||
| 1862 | 1960 | <label for="installer_language">', $txt['installer_language'], ':</label> |
| 1863 | 1961 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
| 1864 | 1962 | |
| 1865 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
| 1866 | - echo ' |
|
| 1963 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
| 1964 | + echo ' |
|
| 1867 | 1965 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
| 1966 | + } |
|
| 1868 | 1967 | |
| 1869 | 1968 | echo ' |
| 1870 | 1969 | </select> |
@@ -1884,9 +1983,10 @@ discard block |
||
| 1884 | 1983 | <h2>', $txt['upgrade_progress'], '</h2> |
| 1885 | 1984 | <ul>'; |
| 1886 | 1985 | |
| 1887 | - foreach ($incontext['steps'] as $num => $step) |
|
| 1888 | - echo ' |
|
| 1986 | + foreach ($incontext['steps'] as $num => $step) { |
|
| 1987 | + echo ' |
|
| 1889 | 1988 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 1989 | + } |
|
| 1890 | 1990 | |
| 1891 | 1991 | echo ' |
| 1892 | 1992 | </ul> |
@@ -1911,20 +2011,23 @@ discard block |
||
| 1911 | 2011 | echo ' |
| 1912 | 2012 | <div>'; |
| 1913 | 2013 | |
| 1914 | - if (!empty($incontext['continue'])) |
|
| 1915 | - echo ' |
|
| 2014 | + if (!empty($incontext['continue'])) { |
|
| 2015 | + echo ' |
|
| 1916 | 2016 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
| 1917 | - if (!empty($incontext['skip'])) |
|
| 1918 | - echo ' |
|
| 2017 | + } |
|
| 2018 | + if (!empty($incontext['skip'])) { |
|
| 2019 | + echo ' |
|
| 1919 | 2020 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
| 2021 | + } |
|
| 1920 | 2022 | echo ' |
| 1921 | 2023 | </div>'; |
| 1922 | 2024 | } |
| 1923 | 2025 | |
| 1924 | 2026 | // Show the closing form tag and other data only if not in the last step |
| 1925 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
| 1926 | - echo ' |
|
| 2027 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
| 2028 | + echo ' |
|
| 1927 | 2029 | </form>'; |
| 2030 | + } |
|
| 1928 | 2031 | |
| 1929 | 2032 | echo ' |
| 1930 | 2033 | </div> |
@@ -1959,13 +2062,15 @@ discard block |
||
| 1959 | 2062 | </div>'; |
| 1960 | 2063 | |
| 1961 | 2064 | // Show the warnings, or not. |
| 1962 | - if (template_warning_divs()) |
|
| 1963 | - echo ' |
|
| 2065 | + if (template_warning_divs()) { |
|
| 2066 | + echo ' |
|
| 1964 | 2067 | <h3>', $txt['install_all_lovely'], '</h3>'; |
| 2068 | + } |
|
| 1965 | 2069 | |
| 1966 | 2070 | // Say we want the continue button! |
| 1967 | - if (empty($incontext['error'])) |
|
| 1968 | - $incontext['continue'] = 1; |
|
| 2071 | + if (empty($incontext['error'])) { |
|
| 2072 | + $incontext['continue'] = 1; |
|
| 2073 | + } |
|
| 1969 | 2074 | |
| 1970 | 2075 | // For the latest version stuff. |
| 1971 | 2076 | echo ' |
@@ -1999,8 +2104,8 @@ discard block |
||
| 1999 | 2104 | global $txt, $incontext; |
| 2000 | 2105 | |
| 2001 | 2106 | // Errors are very serious.. |
| 2002 | - if (!empty($incontext['error'])) |
|
| 2003 | - echo ' |
|
| 2107 | + if (!empty($incontext['error'])) { |
|
| 2108 | + echo ' |
|
| 2004 | 2109 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2005 | 2110 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2006 | 2111 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2008,9 +2113,10 @@ discard block |
||
| 2008 | 2113 | ', $incontext['error'], ' |
| 2009 | 2114 | </div> |
| 2010 | 2115 | </div>'; |
| 2116 | + } |
|
| 2011 | 2117 | // A warning message? |
| 2012 | - elseif (!empty($incontext['warning'])) |
|
| 2013 | - echo ' |
|
| 2118 | + elseif (!empty($incontext['warning'])) { |
|
| 2119 | + echo ' |
|
| 2014 | 2120 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2015 | 2121 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2016 | 2122 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2018,6 +2124,7 @@ discard block |
||
| 2018 | 2124 | ', $incontext['warning'], ' |
| 2019 | 2125 | </div> |
| 2020 | 2126 | </div>'; |
| 2127 | + } |
|
| 2021 | 2128 | |
| 2022 | 2129 | return empty($incontext['error']) && empty($incontext['warning']); |
| 2023 | 2130 | } |
@@ -2033,27 +2140,30 @@ discard block |
||
| 2033 | 2140 | <li>', $incontext['failed_files']), '</li> |
| 2034 | 2141 | </ul>'; |
| 2035 | 2142 | |
| 2036 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
| 2037 | - echo ' |
|
| 2143 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
| 2144 | + echo ' |
|
| 2038 | 2145 | <hr> |
| 2039 | 2146 | <p>', $txt['chmod_linux_info'], '</p> |
| 2040 | 2147 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
| 2148 | + } |
|
| 2041 | 2149 | |
| 2042 | 2150 | // This is serious! |
| 2043 | - if (!template_warning_divs()) |
|
| 2044 | - return; |
|
| 2151 | + if (!template_warning_divs()) { |
|
| 2152 | + return; |
|
| 2153 | + } |
|
| 2045 | 2154 | |
| 2046 | 2155 | echo ' |
| 2047 | 2156 | <hr> |
| 2048 | 2157 | <p>', $txt['ftp_setup_info'], '</p>'; |
| 2049 | 2158 | |
| 2050 | - if (!empty($incontext['ftp_errors'])) |
|
| 2051 | - echo ' |
|
| 2159 | + if (!empty($incontext['ftp_errors'])) { |
|
| 2160 | + echo ' |
|
| 2052 | 2161 | <div class="error_message"> |
| 2053 | 2162 | ', $txt['error_ftp_no_connect'], '<br><br> |
| 2054 | 2163 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
| 2055 | 2164 | </div> |
| 2056 | 2165 | <br>'; |
| 2166 | + } |
|
| 2057 | 2167 | |
| 2058 | 2168 | echo ' |
| 2059 | 2169 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2113,17 +2223,17 @@ discard block |
||
| 2113 | 2223 | <td> |
| 2114 | 2224 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
| 2115 | 2225 | |
| 2116 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
| 2117 | - echo ' |
|
| 2226 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
| 2227 | + echo ' |
|
| 2118 | 2228 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
| 2229 | + } |
|
| 2119 | 2230 | |
| 2120 | 2231 | echo ' |
| 2121 | 2232 | </select> |
| 2122 | 2233 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
| 2123 | 2234 | </td> |
| 2124 | 2235 | </tr>'; |
| 2125 | - } |
|
| 2126 | - else |
|
| 2236 | + } else |
|
| 2127 | 2237 | { |
| 2128 | 2238 | echo ' |
| 2129 | 2239 | <tr style="display: none;"> |
@@ -2315,9 +2425,10 @@ discard block |
||
| 2315 | 2425 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
| 2316 | 2426 | <ul>'; |
| 2317 | 2427 | |
| 2318 | - foreach ($incontext['failures'] as $line => $fail) |
|
| 2319 | - echo ' |
|
| 2428 | + foreach ($incontext['failures'] as $line => $fail) { |
|
| 2429 | + echo ' |
|
| 2320 | 2430 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
| 2431 | + } |
|
| 2321 | 2432 | |
| 2322 | 2433 | echo ' |
| 2323 | 2434 | </ul>'; |
@@ -2378,15 +2489,16 @@ discard block |
||
| 2378 | 2489 | </tr> |
| 2379 | 2490 | </table>'; |
| 2380 | 2491 | |
| 2381 | - if ($incontext['require_db_confirm']) |
|
| 2382 | - echo ' |
|
| 2492 | + if ($incontext['require_db_confirm']) { |
|
| 2493 | + echo ' |
|
| 2383 | 2494 | <h2>', $txt['user_settings_database'], '</h2> |
| 2384 | 2495 | <p>', $txt['user_settings_database_info'], '</p> |
| 2385 | 2496 | |
| 2386 | 2497 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
| 2387 | 2498 | <input type="password" name="password3" size="30" class="input_password" /> |
| 2388 | 2499 | </div>'; |
| 2389 | -} |
|
| 2500 | + } |
|
| 2501 | + } |
|
| 2390 | 2502 | |
| 2391 | 2503 | // Tell them it's done, and to delete. |
| 2392 | 2504 | function template_delete_install() |
@@ -2399,14 +2511,15 @@ discard block |
||
| 2399 | 2511 | template_warning_divs(); |
| 2400 | 2512 | |
| 2401 | 2513 | // Install directory still writable? |
| 2402 | - if ($incontext['dir_still_writable']) |
|
| 2403 | - echo ' |
|
| 2514 | + if ($incontext['dir_still_writable']) { |
|
| 2515 | + echo ' |
|
| 2404 | 2516 | <em>', $txt['still_writable'], '</em><br> |
| 2405 | 2517 | <br>'; |
| 2518 | + } |
|
| 2406 | 2519 | |
| 2407 | 2520 | // Don't show the box if it's like 99% sure it won't work :P. |
| 2408 | - if ($incontext['probably_delete_install']) |
|
| 2409 | - echo ' |
|
| 2521 | + if ($incontext['probably_delete_install']) { |
|
| 2522 | + echo ' |
|
| 2410 | 2523 | <div style="margin: 1ex; font-weight: bold;"> |
| 2411 | 2524 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
| 2412 | 2525 | </div> |
@@ -2422,6 +2535,7 @@ discard block |
||
| 2422 | 2535 | } |
| 2423 | 2536 | </script> |
| 2424 | 2537 | <br>'; |
| 2538 | + } |
|
| 2425 | 2539 | |
| 2426 | 2540 | echo ' |
| 2427 | 2541 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |