@@ -502,6 +502,9 @@ discard block |
||
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | // Used to direct the user to another location. |
| 505 | +/** |
|
| 506 | + * @param string $location |
|
| 507 | + */ |
|
| 505 | 508 | function redirectLocation($location, $addForm = true) |
| 506 | 509 | { |
| 507 | 510 | global $upgradeurl, $upcontext, $command_line; |
@@ -1745,6 +1748,9 @@ discard block |
||
| 1745 | 1748 | return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path)); |
| 1746 | 1749 | } |
| 1747 | 1750 | |
| 1751 | +/** |
|
| 1752 | + * @param string $filename |
|
| 1753 | + */ |
|
| 1748 | 1754 | function parse_sql($filename) |
| 1749 | 1755 | { |
| 1750 | 1756 | global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning; |
@@ -1779,6 +1785,10 @@ discard block |
||
| 1779 | 1785 | |
| 1780 | 1786 | // Our custom error handler - does nothing but does stop public errors from XML! |
| 1781 | 1787 | set_error_handler( |
| 1788 | + |
|
| 1789 | + /** |
|
| 1790 | + * @param string $errno |
|
| 1791 | + */ |
|
| 1782 | 1792 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1783 | 1793 | { |
| 1784 | 1794 | if ($support_js) |
@@ -1993,6 +2003,9 @@ discard block |
||
| 1993 | 2003 | return true; |
| 1994 | 2004 | } |
| 1995 | 2005 | |
| 2006 | +/** |
|
| 2007 | + * @param string $string |
|
| 2008 | + */ |
|
| 1996 | 2009 | function upgrade_query($string, $unbuffered = false) |
| 1997 | 2010 | { |
| 1998 | 2011 | global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings; |
@@ -4763,7 +4776,7 @@ discard block |
||
| 4763 | 4776 | * @param int $setSize The amount of entries after which to update the database. |
| 4764 | 4777 | * |
| 4765 | 4778 | * newCol needs to be a varbinary(16) null able field |
| 4766 | - * @return bool |
|
| 4779 | + * @return boolean|null |
|
| 4767 | 4780 | */ |
| 4768 | 4781 | function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100) |
| 4769 | 4782 | { |
@@ -4931,9 +4944,8 @@ discard block |
||
| 4931 | 4944 | * settings file isn't using any advanced configuration setups in the Settings.php file. A copy is made as Settings_org.php |
| 4932 | 4945 | * to preserve all changes prior to migration. |
| 4933 | 4946 | * |
| 4934 | - * @param array $config_vars An array of one or more variables to update |
|
| 4935 | 4947 | * |
| 4936 | - * @return void We either succesfully update the Settings file, or throw a error here. |
|
| 4948 | + * @return boolean|null We either succesfully update the Settings file, or throw a error here. |
|
| 4937 | 4949 | */ |
| 4938 | 4950 | function migrateSettingsFile($changes) |
| 4939 | 4951 | { |
@@ -5343,9 +5355,8 @@ discard block |
||
| 5343 | 5355 | * Prior to checking these settings, we look for advanced setups such as integrations or if variables have been moved |
| 5344 | 5356 | * to another file. If these are detected, we abort. |
| 5345 | 5357 | * |
| 5346 | - * @param array $config_vars An array of one or more variables to update |
|
| 5347 | 5358 | * |
| 5348 | - * @return void We either succesfully update the Settings file, or throw a error here. |
|
| 5359 | + * @return boolean We either succesfully update the Settings file, or throw a error here. |
|
| 5349 | 5360 | */ |
| 5350 | 5361 | |
| 5351 | 5362 | function detectSettingsFileMigrationNeeded() |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $upcontext['inactive_timeout'] = 10; |
| 76 | 76 | |
| 77 | 77 | // The helper is crucial. Include it first thing. |
| 78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
| 80 | +} |
|
| 80 | 81 | |
| 81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 82 | 83 | |
@@ -107,11 +108,14 @@ discard block |
||
| 107 | 108 | ini_set('default_socket_timeout', 900); |
| 108 | 109 | } |
| 109 | 110 | // Clean the upgrade path if this is from the client. |
| 110 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 111 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 111 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 112 | + for ($i = 1; |
|
| 113 | +} |
|
| 114 | +$i < $_SERVER['argc']; $i++) |
|
| 112 | 115 | { |
| 113 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 114 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 116 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 117 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 118 | + } |
|
| 115 | 119 | } |
| 116 | 120 | |
| 117 | 121 | // Are we from the client? |
@@ -119,16 +123,17 @@ discard block |
||
| 119 | 123 | { |
| 120 | 124 | $command_line = true; |
| 121 | 125 | $disable_security = true; |
| 122 | -} |
|
| 123 | -else |
|
| 126 | +} else { |
|
| 124 | 127 | $command_line = false; |
| 128 | +} |
|
| 125 | 129 | |
| 126 | 130 | // Load this now just because we can. |
| 127 | 131 | require_once($upgrade_path . '/Settings.php'); |
| 128 | 132 | |
| 129 | 133 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 130 | -if (isset($language)) |
|
| 134 | +if (isset($language)) { |
|
| 131 | 135 | $language = str_ireplace('-utf8', '', $language); |
| 136 | +} |
|
| 132 | 137 | |
| 133 | 138 | // Are we logged in? |
| 134 | 139 | if (isset($upgradeData)) |
@@ -136,10 +141,12 @@ discard block |
||
| 136 | 141 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 137 | 142 | |
| 138 | 143 | // Check for sensible values. |
| 139 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 140 | - $upcontext['user']['started'] = time(); |
|
| 141 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 142 | - $upcontext['user']['updated'] = 0; |
|
| 144 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 145 | + $upcontext['user']['started'] = time(); |
|
| 146 | + } |
|
| 147 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 148 | + $upcontext['user']['updated'] = 0; |
|
| 149 | + } |
|
| 143 | 150 | |
| 144 | 151 | $upcontext['started'] = $upcontext['user']['started']; |
| 145 | 152 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -204,8 +211,9 @@ discard block |
||
| 204 | 211 | 'db_error_skip' => true, |
| 205 | 212 | ) |
| 206 | 213 | ); |
| 207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 208 | - $modSettings[$row['variable']] = $row['value']; |
|
| 214 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 215 | + $modSettings[$row['variable']] = $row['value']; |
|
| 216 | + } |
|
| 209 | 217 | $smcFunc['db_free_result']($request); |
| 210 | 218 | } |
| 211 | 219 | |
@@ -215,14 +223,17 @@ discard block |
||
| 215 | 223 | $modSettings['theme_url'] = 'Themes/default'; |
| 216 | 224 | $modSettings['images_url'] = 'Themes/default/images'; |
| 217 | 225 | } |
| 218 | -if (!isset($settings['default_theme_url'])) |
|
| 226 | +if (!isset($settings['default_theme_url'])) { |
|
| 219 | 227 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 220 | -if (!isset($settings['default_theme_dir'])) |
|
| 228 | +} |
|
| 229 | +if (!isset($settings['default_theme_dir'])) { |
|
| 221 | 230 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 231 | +} |
|
| 222 | 232 | |
| 223 | 233 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
| 224 | -if (httpsOn()) |
|
| 234 | +if (httpsOn()) { |
|
| 225 | 235 | $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
| 236 | +} |
|
| 226 | 237 | |
| 227 | 238 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 228 | 239 | // Default title... |
@@ -240,13 +251,15 @@ discard block |
||
| 240 | 251 | $support_js = $upcontext['upgrade_status']['js']; |
| 241 | 252 | |
| 242 | 253 | // Only set this if the upgrader status says so. |
| 243 | - if (empty($is_debug)) |
|
| 244 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 254 | + if (empty($is_debug)) { |
|
| 255 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 256 | + } |
|
| 245 | 257 | |
| 246 | 258 | // Load the language. |
| 247 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 248 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 249 | -} |
|
| 259 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 260 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 261 | + } |
|
| 262 | + } |
|
| 250 | 263 | // Set the defaults. |
| 251 | 264 | else |
| 252 | 265 | { |
@@ -264,15 +277,18 @@ discard block |
||
| 264 | 277 | } |
| 265 | 278 | |
| 266 | 279 | // If this isn't the first stage see whether they are logging in and resuming. |
| 267 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 280 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 268 | 281 | checkLogin(); |
| 282 | +} |
|
| 269 | 283 | |
| 270 | -if ($command_line) |
|
| 284 | +if ($command_line) { |
|
| 271 | 285 | cmdStep0(); |
| 286 | +} |
|
| 272 | 287 | |
| 273 | 288 | // Don't error if we're using xml. |
| 274 | -if (isset($_GET['xml'])) |
|
| 289 | +if (isset($_GET['xml'])) { |
|
| 275 | 290 | $upcontext['return_error'] = true; |
| 291 | +} |
|
| 276 | 292 | |
| 277 | 293 | // Loop through all the steps doing each one as required. |
| 278 | 294 | $upcontext['overall_percent'] = 0; |
@@ -293,9 +309,9 @@ discard block |
||
| 293 | 309 | } |
| 294 | 310 | |
| 295 | 311 | // Call the step and if it returns false that means pause! |
| 296 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 297 | - break; |
|
| 298 | - elseif (function_exists($step[2])) { |
|
| 312 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 313 | + break; |
|
| 314 | + } elseif (function_exists($step[2])) { |
|
| 299 | 315 | //Start each new step with this unset, so the 'normal' template is called first |
| 300 | 316 | unset($_GET['xml']); |
| 301 | 317 | //Clear out warnings at the start of each step |
@@ -341,17 +357,18 @@ discard block |
||
| 341 | 357 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 342 | 358 | if (!empty($command_line)) |
| 343 | 359 | { |
| 344 | - if (function_exists('debug_print_backtrace')) |
|
| 345 | - debug_print_backtrace(); |
|
| 360 | + if (function_exists('debug_print_backtrace')) { |
|
| 361 | + debug_print_backtrace(); |
|
| 362 | + } |
|
| 346 | 363 | |
| 347 | 364 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
| 348 | 365 | flush(); |
| 349 | 366 | die(); |
| 350 | 367 | } |
| 351 | 368 | |
| 352 | - if (!isset($_GET['xml'])) |
|
| 353 | - template_upgrade_above(); |
|
| 354 | - else |
|
| 369 | + if (!isset($_GET['xml'])) { |
|
| 370 | + template_upgrade_above(); |
|
| 371 | + } else |
|
| 355 | 372 | { |
| 356 | 373 | header('content-type: text/xml; charset=UTF-8'); |
| 357 | 374 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -373,25 +390,29 @@ discard block |
||
| 373 | 390 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 374 | 391 | |
| 375 | 392 | // Custom stuff to pass back? |
| 376 | - if (!empty($upcontext['query_string'])) |
|
| 377 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 393 | + if (!empty($upcontext['query_string'])) { |
|
| 394 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 395 | + } |
|
| 378 | 396 | |
| 379 | 397 | // Call the appropriate subtemplate |
| 380 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 381 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 382 | - else |
|
| 383 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 398 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 399 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 400 | + } else { |
|
| 401 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 402 | + } |
|
| 384 | 403 | } |
| 385 | 404 | |
| 386 | 405 | // Was there an error? |
| 387 | - if (!empty($upcontext['forced_error_message'])) |
|
| 388 | - echo $upcontext['forced_error_message']; |
|
| 406 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 407 | + echo $upcontext['forced_error_message']; |
|
| 408 | + } |
|
| 389 | 409 | |
| 390 | 410 | // Show the footer. |
| 391 | - if (!isset($_GET['xml'])) |
|
| 392 | - template_upgrade_below(); |
|
| 393 | - else |
|
| 394 | - template_xml_below(); |
|
| 411 | + if (!isset($_GET['xml'])) { |
|
| 412 | + template_upgrade_below(); |
|
| 413 | + } else { |
|
| 414 | + template_xml_below(); |
|
| 415 | + } |
|
| 395 | 416 | } |
| 396 | 417 | |
| 397 | 418 | |
@@ -403,15 +424,19 @@ discard block |
||
| 403 | 424 | $seconds = intval($active % 60); |
| 404 | 425 | |
| 405 | 426 | $totalTime = ''; |
| 406 | - if ($hours > 0) |
|
| 407 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 408 | - if ($minutes > 0) |
|
| 409 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 410 | - if ($seconds > 0) |
|
| 411 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 427 | + if ($hours > 0) { |
|
| 428 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 429 | + } |
|
| 430 | + if ($minutes > 0) { |
|
| 431 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 432 | + } |
|
| 433 | + if ($seconds > 0) { |
|
| 434 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 435 | + } |
|
| 412 | 436 | |
| 413 | - if (!empty($totalTime)) |
|
| 414 | - echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
| 437 | + if (!empty($totalTime)) { |
|
| 438 | + echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
| 439 | + } |
|
| 415 | 440 | } |
| 416 | 441 | |
| 417 | 442 | // Bang - gone! |
@@ -432,8 +457,9 @@ discard block |
||
| 432 | 457 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 433 | 458 | while ($entry = $dir->read()) |
| 434 | 459 | { |
| 435 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 436 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 460 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 461 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 462 | + } |
|
| 437 | 463 | } |
| 438 | 464 | $dir->close(); |
| 439 | 465 | } |
@@ -468,10 +494,11 @@ discard block |
||
| 468 | 494 | } |
| 469 | 495 | |
| 470 | 496 | // Override the language file? |
| 471 | - if (isset($_GET['lang_file'])) |
|
| 472 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 473 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 474 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 497 | + if (isset($_GET['lang_file'])) { |
|
| 498 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 499 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 500 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 501 | + } |
|
| 475 | 502 | |
| 476 | 503 | // Make sure it exists, if it doesn't reset it. |
| 477 | 504 | 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'])) |
@@ -480,12 +507,14 @@ discard block |
||
| 480 | 507 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 481 | 508 | |
| 482 | 509 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 483 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 484 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 510 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 511 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 512 | + } |
|
| 485 | 513 | |
| 486 | 514 | // For backup we load the english at first -> second language overwrite the english one |
| 487 | - if (count($incontext['detected_languages']) > 1) |
|
| 488 | - require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 515 | + if (count($incontext['detected_languages']) > 1) { |
|
| 516 | + require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 517 | + } |
|
| 489 | 518 | } |
| 490 | 519 | |
| 491 | 520 | // And now include the actual language file itself. |
@@ -493,11 +522,12 @@ discard block |
||
| 493 | 522 | |
| 494 | 523 | // Which language did we load? Assume that he likes his language. |
| 495 | 524 | preg_match('~^Install\.(.+[^-utf8])\.php$~', $_SESSION['installer_temp_lang'], $matches); |
| 496 | - if (empty($matches[1])) |
|
| 497 | - $matches = [ |
|
| 525 | + if (empty($matches[1])) { |
|
| 526 | + $matches = [ |
|
| 498 | 527 | 0 => 'nothing', |
| 499 | 528 | 1 => 'english', |
| 500 | 529 | ]; |
| 530 | + } |
|
| 501 | 531 | $user_info['language'] = $matches[1]; |
| 502 | 532 | } |
| 503 | 533 | |
@@ -507,8 +537,9 @@ discard block |
||
| 507 | 537 | global $upgradeurl, $upcontext, $command_line; |
| 508 | 538 | |
| 509 | 539 | // Command line users can't be redirected. |
| 510 | - if ($command_line) |
|
| 511 | - upgradeExit(true); |
|
| 540 | + if ($command_line) { |
|
| 541 | + upgradeExit(true); |
|
| 542 | + } |
|
| 512 | 543 | |
| 513 | 544 | // Are we providing the core info? |
| 514 | 545 | if ($addForm) |
@@ -534,12 +565,14 @@ discard block |
||
| 534 | 565 | define('SMF', 1); |
| 535 | 566 | |
| 536 | 567 | // Start the session. |
| 537 | - if (@ini_get('session.save_handler') == 'user') |
|
| 538 | - @ini_set('session.save_handler', 'files'); |
|
| 568 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 569 | + @ini_set('session.save_handler', 'files'); |
|
| 570 | + } |
|
| 539 | 571 | @session_start(); |
| 540 | 572 | |
| 541 | - if (empty($smcFunc)) |
|
| 542 | - $smcFunc = array(); |
|
| 573 | + if (empty($smcFunc)) { |
|
| 574 | + $smcFunc = array(); |
|
| 575 | + } |
|
| 543 | 576 | |
| 544 | 577 | // We need this for authentication and some upgrade code |
| 545 | 578 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -566,24 +599,27 @@ discard block |
||
| 566 | 599 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 567 | 600 | |
| 568 | 601 | // Make the connection... |
| 569 | - if (empty($db_connection)) |
|
| 570 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 571 | - else |
|
| 572 | - // If we've returned here, ping/reconnect to be safe |
|
| 602 | + if (empty($db_connection)) { |
|
| 603 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 604 | + } else { |
|
| 605 | + // If we've returned here, ping/reconnect to be safe |
|
| 573 | 606 | $smcFunc['db_ping']($db_connection); |
| 607 | + } |
|
| 574 | 608 | |
| 575 | 609 | // Oh dear god!! |
| 576 | - if ($db_connection === null) |
|
| 577 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 610 | + if ($db_connection === null) { |
|
| 611 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 612 | + } |
|
| 578 | 613 | |
| 579 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 580 | - $smcFunc['db_query']('', ' |
|
| 614 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 615 | + $smcFunc['db_query']('', ' |
|
| 581 | 616 | SET NAMES {string:db_character_set}', |
| 582 | 617 | array( |
| 583 | 618 | 'db_error_skip' => true, |
| 584 | 619 | 'db_character_set' => $db_character_set, |
| 585 | 620 | ) |
| 586 | 621 | ); |
| 622 | + } |
|
| 587 | 623 | |
| 588 | 624 | // Load the modSettings data... |
| 589 | 625 | $request = $smcFunc['db_query']('', ' |
@@ -594,11 +630,11 @@ discard block |
||
| 594 | 630 | ) |
| 595 | 631 | ); |
| 596 | 632 | $modSettings = array(); |
| 597 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 598 | - $modSettings[$row['variable']] = $row['value']; |
|
| 633 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 634 | + $modSettings[$row['variable']] = $row['value']; |
|
| 635 | + } |
|
| 599 | 636 | $smcFunc['db_free_result']($request); |
| 600 | - } |
|
| 601 | - else |
|
| 637 | + } else |
|
| 602 | 638 | { |
| 603 | 639 | 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.'); |
| 604 | 640 | } |
@@ -612,9 +648,10 @@ discard block |
||
| 612 | 648 | cleanRequest(); |
| 613 | 649 | } |
| 614 | 650 | |
| 615 | - if (!isset($_GET['substep'])) |
|
| 616 | - $_GET['substep'] = 0; |
|
| 617 | -} |
|
| 651 | + if (!isset($_GET['substep'])) { |
|
| 652 | + $_GET['substep'] = 0; |
|
| 653 | + } |
|
| 654 | + } |
|
| 618 | 655 | |
| 619 | 656 | function initialize_inputs() |
| 620 | 657 | { |
@@ -644,8 +681,9 @@ discard block |
||
| 644 | 681 | $dh = opendir(dirname(__FILE__)); |
| 645 | 682 | while ($file = readdir($dh)) |
| 646 | 683 | { |
| 647 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 648 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 684 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 685 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 686 | + } |
|
| 649 | 687 | } |
| 650 | 688 | closedir($dh); |
| 651 | 689 | |
@@ -674,8 +712,9 @@ discard block |
||
| 674 | 712 | $temp = 'upgrade_php?step'; |
| 675 | 713 | while (strlen($temp) > 4) |
| 676 | 714 | { |
| 677 | - if (isset($_GET[$temp])) |
|
| 678 | - unset($_GET[$temp]); |
|
| 715 | + if (isset($_GET[$temp])) { |
|
| 716 | + unset($_GET[$temp]); |
|
| 717 | + } |
|
| 679 | 718 | $temp = substr($temp, 1); |
| 680 | 719 | } |
| 681 | 720 | |
@@ -702,32 +741,39 @@ discard block |
||
| 702 | 741 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 703 | 742 | |
| 704 | 743 | // Need legacy scripts? |
| 705 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 706 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 707 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 708 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 709 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 710 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 744 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 745 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 746 | + } |
|
| 747 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 748 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 749 | + } |
|
| 750 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 751 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 752 | + } |
|
| 711 | 753 | |
| 712 | 754 | // We don't need "-utf8" files anymore... |
| 713 | 755 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 714 | 756 | |
| 715 | 757 | // This needs to exist! |
| 716 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 717 | - 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>]'); |
|
| 718 | - else |
|
| 719 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 758 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 759 | + 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>]'); |
|
| 760 | + } else { |
|
| 761 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 762 | + } |
|
| 720 | 763 | |
| 721 | - if (!$check) |
|
| 722 | - // 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. |
|
| 764 | + if (!$check) { |
|
| 765 | + // 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. |
|
| 723 | 766 | 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.'); |
| 767 | + } |
|
| 724 | 768 | |
| 725 | 769 | // Do they meet the install requirements? |
| 726 | - if (!php_version_check()) |
|
| 727 | - 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.'); |
|
| 770 | + if (!php_version_check()) { |
|
| 771 | + 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.'); |
|
| 772 | + } |
|
| 728 | 773 | |
| 729 | - if (!db_version_check()) |
|
| 730 | - 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.'); |
|
| 774 | + if (!db_version_check()) { |
|
| 775 | + 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.'); |
|
| 776 | + } |
|
| 731 | 777 | |
| 732 | 778 | // Do some checks to make sure they have proper privileges |
| 733 | 779 | db_extend('packages'); |
@@ -742,14 +788,16 @@ discard block |
||
| 742 | 788 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 743 | 789 | |
| 744 | 790 | // Sorry... we need CREATE, ALTER and DROP |
| 745 | - if (!$create || !$alter || !$drop) |
|
| 746 | - 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.'); |
|
| 791 | + if (!$create || !$alter || !$drop) { |
|
| 792 | + 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.'); |
|
| 793 | + } |
|
| 747 | 794 | |
| 748 | 795 | // Do a quick version spot check. |
| 749 | 796 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 750 | 797 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 751 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 752 | - 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.'); |
|
| 798 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 799 | + 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.'); |
|
| 800 | + } |
|
| 753 | 801 | |
| 754 | 802 | // What absolutely needs to be writable? |
| 755 | 803 | $writable_files = array( |
@@ -758,12 +806,13 @@ discard block |
||
| 758 | 806 | ); |
| 759 | 807 | |
| 760 | 808 | // Only check for minified writable files if we have it enabled or not set. |
| 761 | - if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) |
|
| 762 | - $writable_files += array( |
|
| 809 | + if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) { |
|
| 810 | + $writable_files += array( |
|
| 763 | 811 | $modSettings['theme_dir'] . '/css/minified.css', |
| 764 | 812 | $modSettings['theme_dir'] . '/scripts/minified.js', |
| 765 | 813 | $modSettings['theme_dir'] . '/scripts/minified_deferred.js', |
| 766 | 814 | ); |
| 815 | + } |
|
| 767 | 816 | |
| 768 | 817 | // Do we need to add this setting? |
| 769 | 818 | $need_settings_update = empty($modSettings['custom_avatar_dir']); |
@@ -775,12 +824,13 @@ discard block |
||
| 775 | 824 | quickFileWritable($custom_av_dir); |
| 776 | 825 | |
| 777 | 826 | // Are we good now? |
| 778 | - if (!is_writable($custom_av_dir)) |
|
| 779 | - 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)); |
|
| 780 | - elseif ($need_settings_update) |
|
| 827 | + if (!is_writable($custom_av_dir)) { |
|
| 828 | + 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)); |
|
| 829 | + } elseif ($need_settings_update) |
|
| 781 | 830 | { |
| 782 | - if (!function_exists('cache_put_data')) |
|
| 783 | - require_once($sourcedir . '/Load.php'); |
|
| 831 | + if (!function_exists('cache_put_data')) { |
|
| 832 | + require_once($sourcedir . '/Load.php'); |
|
| 833 | + } |
|
| 784 | 834 | |
| 785 | 835 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 786 | 836 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
@@ -790,29 +840,34 @@ discard block |
||
| 790 | 840 | |
| 791 | 841 | // Check the cache directory. |
| 792 | 842 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 793 | - if (!file_exists($cachedir_temp)) |
|
| 794 | - @mkdir($cachedir_temp); |
|
| 843 | + if (!file_exists($cachedir_temp)) { |
|
| 844 | + @mkdir($cachedir_temp); |
|
| 845 | + } |
|
| 795 | 846 | |
| 796 | - if (!file_exists($cachedir_temp)) |
|
| 797 | - 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.'); |
|
| 847 | + if (!file_exists($cachedir_temp)) { |
|
| 848 | + 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.'); |
|
| 849 | + } |
|
| 798 | 850 | |
| 799 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 800 | - 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>.'); |
|
| 801 | - elseif (!isset($_GET['skiplang'])) |
|
| 851 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 852 | + 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>.'); |
|
| 853 | + } elseif (!isset($_GET['skiplang'])) |
|
| 802 | 854 | { |
| 803 | 855 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 804 | 856 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 805 | 857 | |
| 806 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 807 | - 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>]'); |
|
| 858 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 859 | + 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>]'); |
|
| 860 | + } |
|
| 808 | 861 | } |
| 809 | 862 | |
| 810 | - if (!makeFilesWritable($writable_files)) |
|
| 811 | - return false; |
|
| 863 | + if (!makeFilesWritable($writable_files)) { |
|
| 864 | + return false; |
|
| 865 | + } |
|
| 812 | 866 | |
| 813 | 867 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 814 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 815 | - 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.'); |
|
| 868 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 869 | + 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.'); |
|
| 870 | + } |
|
| 816 | 871 | |
| 817 | 872 | // Upgrade the agreement. |
| 818 | 873 | elseif (isset($modSettings['agreement'])) |
@@ -823,8 +878,8 @@ discard block |
||
| 823 | 878 | } |
| 824 | 879 | |
| 825 | 880 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 826 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 827 | - $upcontext['warning'] = ' |
|
| 881 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 882 | + $upcontext['warning'] = ' |
|
| 828 | 883 | 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> |
| 829 | 884 | <ul> |
| 830 | 885 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -832,19 +887,23 @@ discard block |
||
| 832 | 887 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 833 | 888 | </ul> |
| 834 | 889 | 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.'; |
| 890 | + } |
|
| 835 | 891 | |
| 836 | 892 | // Confirm mbstring is loaded... |
| 837 | - if (!extension_loaded('mbstring')) |
|
| 838 | - return throw_error($txt['install_no_mbstring']); |
|
| 893 | + if (!extension_loaded('mbstring')) { |
|
| 894 | + return throw_error($txt['install_no_mbstring']); |
|
| 895 | + } |
|
| 839 | 896 | |
| 840 | 897 | // Check for https stream support. |
| 841 | 898 | $supported_streams = stream_get_wrappers(); |
| 842 | - if (!in_array('https', $supported_streams)) |
|
| 843 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 899 | + if (!in_array('https', $supported_streams)) { |
|
| 900 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 901 | + } |
|
| 844 | 902 | |
| 845 | 903 | // Either we're logged in or we're going to present the login. |
| 846 | - if (checkLogin()) |
|
| 847 | - return true; |
|
| 904 | + if (checkLogin()) { |
|
| 905 | + return true; |
|
| 906 | + } |
|
| 848 | 907 | |
| 849 | 908 | $upcontext += createToken('login'); |
| 850 | 909 | |
@@ -858,15 +917,17 @@ discard block |
||
| 858 | 917 | global $smcFunc, $db_type, $support_js; |
| 859 | 918 | |
| 860 | 919 | // Don't bother if the security is disabled. |
| 861 | - if ($disable_security) |
|
| 862 | - return true; |
|
| 920 | + if ($disable_security) { |
|
| 921 | + return true; |
|
| 922 | + } |
|
| 863 | 923 | |
| 864 | 924 | // Are we trying to login? |
| 865 | 925 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 866 | 926 | { |
| 867 | 927 | // If we've disabled security pick a suitable name! |
| 868 | - if (empty($_POST['user'])) |
|
| 869 | - $_POST['user'] = 'Administrator'; |
|
| 928 | + if (empty($_POST['user'])) { |
|
| 929 | + $_POST['user'] = 'Administrator'; |
|
| 930 | + } |
|
| 870 | 931 | |
| 871 | 932 | // Before 2.0 these column names were different! |
| 872 | 933 | $oldDB = false; |
@@ -881,16 +942,17 @@ discard block |
||
| 881 | 942 | 'db_error_skip' => true, |
| 882 | 943 | ) |
| 883 | 944 | ); |
| 884 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 885 | - $oldDB = true; |
|
| 945 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 946 | + $oldDB = true; |
|
| 947 | + } |
|
| 886 | 948 | $smcFunc['db_free_result']($request); |
| 887 | 949 | } |
| 888 | 950 | |
| 889 | 951 | // Get what we believe to be their details. |
| 890 | 952 | if (!$disable_security) |
| 891 | 953 | { |
| 892 | - if ($oldDB) |
|
| 893 | - $request = $smcFunc['db_query']('', ' |
|
| 954 | + if ($oldDB) { |
|
| 955 | + $request = $smcFunc['db_query']('', ' |
|
| 894 | 956 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 895 | 957 | additionalGroups AS additional_groups, lngfile |
| 896 | 958 | FROM {db_prefix}members |
@@ -900,8 +962,8 @@ discard block |
||
| 900 | 962 | 'db_error_skip' => true, |
| 901 | 963 | ) |
| 902 | 964 | ); |
| 903 | - else |
|
| 904 | - $request = $smcFunc['db_query']('', ' |
|
| 965 | + } else { |
|
| 966 | + $request = $smcFunc['db_query']('', ' |
|
| 905 | 967 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 906 | 968 | FROM {db_prefix}members |
| 907 | 969 | WHERE member_name = {string:member_name}', |
@@ -910,6 +972,7 @@ discard block |
||
| 910 | 972 | 'db_error_skip' => true, |
| 911 | 973 | ) |
| 912 | 974 | ); |
| 975 | + } |
|
| 913 | 976 | if ($smcFunc['db_num_rows']($request) != 0) |
| 914 | 977 | { |
| 915 | 978 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -917,16 +980,17 @@ discard block |
||
| 917 | 980 | $groups = explode(',', $addGroups); |
| 918 | 981 | $groups[] = $id_group; |
| 919 | 982 | |
| 920 | - foreach ($groups as $k => $v) |
|
| 921 | - $groups[$k] = (int) $v; |
|
| 983 | + foreach ($groups as $k => $v) { |
|
| 984 | + $groups[$k] = (int) $v; |
|
| 985 | + } |
|
| 922 | 986 | |
| 923 | 987 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 924 | 988 | |
| 925 | 989 | // We don't use "-utf8" anymore... |
| 926 | 990 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 991 | + } else { |
|
| 992 | + $upcontext['username_incorrect'] = true; |
|
| 927 | 993 | } |
| 928 | - else |
|
| 929 | - $upcontext['username_incorrect'] = true; |
|
| 930 | 994 | |
| 931 | 995 | $smcFunc['db_free_result']($request); |
| 932 | 996 | } |
@@ -937,13 +1001,14 @@ discard block |
||
| 937 | 1001 | { |
| 938 | 1002 | $upcontext['upgrade_status']['js'] = 1; |
| 939 | 1003 | $support_js = 1; |
| 1004 | + } else { |
|
| 1005 | + $support_js = 0; |
|
| 940 | 1006 | } |
| 941 | - else |
|
| 942 | - $support_js = 0; |
|
| 943 | 1007 | |
| 944 | 1008 | // Note down the version we are coming from. |
| 945 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 946 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1009 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 1010 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1011 | + } |
|
| 947 | 1012 | |
| 948 | 1013 | // Didn't get anywhere? |
| 949 | 1014 | 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'])) |
@@ -977,15 +1042,15 @@ discard block |
||
| 977 | 1042 | 'db_error_skip' => true, |
| 978 | 1043 | ) |
| 979 | 1044 | ); |
| 980 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 981 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1045 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1046 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1047 | + } |
|
| 982 | 1048 | $smcFunc['db_free_result']($request); |
| 983 | 1049 | } |
| 984 | 1050 | |
| 985 | 1051 | $upcontext['user']['id'] = $id_member; |
| 986 | 1052 | $upcontext['user']['name'] = $name; |
| 987 | - } |
|
| 988 | - else |
|
| 1053 | + } else |
|
| 989 | 1054 | { |
| 990 | 1055 | $upcontext['user']['id'] = 1; |
| 991 | 1056 | $upcontext['user']['name'] = 'Administrator'; |
@@ -1001,11 +1066,11 @@ discard block |
||
| 1001 | 1066 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 1002 | 1067 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 1003 | 1068 | |
| 1004 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 1005 | - $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'] . '.'; |
|
| 1006 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 1007 | - $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'] . '.'; |
|
| 1008 | - else |
|
| 1069 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 1070 | + $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'] . '.'; |
|
| 1071 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 1072 | + $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'] . '.'; |
|
| 1073 | + } else |
|
| 1009 | 1074 | { |
| 1010 | 1075 | // Set this as the new language. |
| 1011 | 1076 | $upcontext['language'] = $user_language; |
@@ -1052,8 +1117,9 @@ discard block |
||
| 1052 | 1117 | $upcontext['migrateSettingsNeeded'] = detectSettingsFileMigrationNeeded() ? 1 : 0; |
| 1053 | 1118 | |
| 1054 | 1119 | // If we've not submitted then we're done. |
| 1055 | - if (empty($_POST['upcont'])) |
|
| 1056 | - return false; |
|
| 1120 | + if (empty($_POST['upcont'])) { |
|
| 1121 | + return false; |
|
| 1122 | + } |
|
| 1057 | 1123 | |
| 1058 | 1124 | // Firstly, if they're enabling SM stat collection just do it. |
| 1059 | 1125 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -1073,16 +1139,17 @@ discard block |
||
| 1073 | 1139 | fwrite($fp, $out); |
| 1074 | 1140 | |
| 1075 | 1141 | $return_data = ''; |
| 1076 | - while (!feof($fp)) |
|
| 1077 | - $return_data .= fgets($fp, 128); |
|
| 1142 | + while (!feof($fp)) { |
|
| 1143 | + $return_data .= fgets($fp, 128); |
|
| 1144 | + } |
|
| 1078 | 1145 | |
| 1079 | 1146 | fclose($fp); |
| 1080 | 1147 | |
| 1081 | 1148 | // Get the unique site ID. |
| 1082 | 1149 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1083 | 1150 | |
| 1084 | - if (!empty($ID[1])) |
|
| 1085 | - $smcFunc['db_insert']('replace', |
|
| 1151 | + if (!empty($ID[1])) { |
|
| 1152 | + $smcFunc['db_insert']('replace', |
|
| 1086 | 1153 | $db_prefix . 'settings', |
| 1087 | 1154 | array('variable' => 'string', 'value' => 'string'), |
| 1088 | 1155 | array( |
@@ -1091,9 +1158,9 @@ discard block |
||
| 1091 | 1158 | ), |
| 1092 | 1159 | array('variable') |
| 1093 | 1160 | ); |
| 1161 | + } |
|
| 1094 | 1162 | } |
| 1095 | - } |
|
| 1096 | - else |
|
| 1163 | + } else |
|
| 1097 | 1164 | { |
| 1098 | 1165 | $smcFunc['db_insert']('replace', |
| 1099 | 1166 | $db_prefix . 'settings', |
@@ -1104,8 +1171,8 @@ discard block |
||
| 1104 | 1171 | } |
| 1105 | 1172 | } |
| 1106 | 1173 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1107 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1108 | - $smcFunc['db_query']('', ' |
|
| 1174 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1175 | + $smcFunc['db_query']('', ' |
|
| 1109 | 1176 | DELETE FROM {db_prefix}settings |
| 1110 | 1177 | WHERE variable = {string:enable_sm_stats}', |
| 1111 | 1178 | array( |
@@ -1113,6 +1180,7 @@ discard block |
||
| 1113 | 1180 | 'db_error_skip' => true, |
| 1114 | 1181 | ) |
| 1115 | 1182 | ); |
| 1183 | + } |
|
| 1116 | 1184 | |
| 1117 | 1185 | // Deleting old karma stuff? |
| 1118 | 1186 | if (!empty($_POST['delete_karma'])) |
@@ -1127,20 +1195,22 @@ discard block |
||
| 1127 | 1195 | ); |
| 1128 | 1196 | |
| 1129 | 1197 | // Cleaning up old karma member settings. |
| 1130 | - if ($upcontext['karma_installed']['good']) |
|
| 1131 | - $smcFunc['db_query']('', ' |
|
| 1198 | + if ($upcontext['karma_installed']['good']) { |
|
| 1199 | + $smcFunc['db_query']('', ' |
|
| 1132 | 1200 | ALTER TABLE {db_prefix}members |
| 1133 | 1201 | DROP karma_good', |
| 1134 | 1202 | array() |
| 1135 | 1203 | ); |
| 1204 | + } |
|
| 1136 | 1205 | |
| 1137 | 1206 | // Does karma bad was enable? |
| 1138 | - if ($upcontext['karma_installed']['bad']) |
|
| 1139 | - $smcFunc['db_query']('', ' |
|
| 1207 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1208 | + $smcFunc['db_query']('', ' |
|
| 1140 | 1209 | ALTER TABLE {db_prefix}members |
| 1141 | 1210 | DROP karma_bad', |
| 1142 | 1211 | array() |
| 1143 | 1212 | ); |
| 1213 | + } |
|
| 1144 | 1214 | |
| 1145 | 1215 | // Cleaning up old karma permissions. |
| 1146 | 1216 | $smcFunc['db_query']('', ' |
@@ -1158,32 +1228,37 @@ discard block |
||
| 1158 | 1228 | } |
| 1159 | 1229 | |
| 1160 | 1230 | // Emptying the error log? |
| 1161 | - if (!empty($_POST['empty_error'])) |
|
| 1162 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1231 | + if (!empty($_POST['empty_error'])) { |
|
| 1232 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1163 | 1233 | TRUNCATE {db_prefix}log_errors', |
| 1164 | 1234 | array( |
| 1165 | 1235 | ) |
| 1166 | 1236 | ); |
| 1237 | + } |
|
| 1167 | 1238 | |
| 1168 | 1239 | $changes = array(); |
| 1169 | 1240 | |
| 1170 | 1241 | // Add proxy settings. |
| 1171 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1172 | - $changes += array( |
|
| 1242 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1243 | + $changes += array( |
|
| 1173 | 1244 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1174 | 1245 | 'image_proxy_maxsize' => 5190, |
| 1175 | 1246 | 'image_proxy_enabled' => 0, |
| 1176 | 1247 | ); |
| 1248 | + } |
|
| 1177 | 1249 | |
| 1178 | 1250 | // If $boardurl reflects https, set force_ssl |
| 1179 | - if (!function_exists('cache_put_data')) |
|
| 1180 | - require_once($sourcedir . '/Load.php'); |
|
| 1181 | - if (stripos($boardurl, 'https://') !== false) |
|
| 1182 | - updateSettings(array('force_ssl' => '1')); |
|
| 1251 | + if (!function_exists('cache_put_data')) { |
|
| 1252 | + require_once($sourcedir . '/Load.php'); |
|
| 1253 | + } |
|
| 1254 | + if (stripos($boardurl, 'https://') !== false) { |
|
| 1255 | + updateSettings(array('force_ssl' => '1')); |
|
| 1256 | + } |
|
| 1183 | 1257 | |
| 1184 | 1258 | // If we're overriding the language follow it through. |
| 1185 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1186 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1259 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1260 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1261 | + } |
|
| 1187 | 1262 | |
| 1188 | 1263 | if (!empty($_POST['maint'])) |
| 1189 | 1264 | { |
@@ -1195,26 +1270,29 @@ discard block |
||
| 1195 | 1270 | { |
| 1196 | 1271 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1197 | 1272 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1198 | - } |
|
| 1199 | - else |
|
| 1273 | + } else |
|
| 1200 | 1274 | { |
| 1201 | 1275 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1202 | 1276 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1203 | 1277 | } |
| 1204 | 1278 | } |
| 1205 | 1279 | |
| 1206 | - if ($command_line) |
|
| 1207 | - echo ' * Updating Settings.php...'; |
|
| 1280 | + if ($command_line) { |
|
| 1281 | + echo ' * Updating Settings.php...'; |
|
| 1282 | + } |
|
| 1208 | 1283 | |
| 1209 | 1284 | // Fix some old paths. |
| 1210 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1211 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1285 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1286 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1287 | + } |
|
| 1212 | 1288 | |
| 1213 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1214 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1289 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1290 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1291 | + } |
|
| 1215 | 1292 | |
| 1216 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1217 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1293 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1294 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1295 | + } |
|
| 1218 | 1296 | |
| 1219 | 1297 | // If they have a "host:port" setup for the host, split that into separate values |
| 1220 | 1298 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1225,32 +1303,36 @@ discard block |
||
| 1225 | 1303 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1226 | 1304 | |
| 1227 | 1305 | // Only set this if we're not using the default port |
| 1228 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1229 | - $changes['db_port'] = (int) $db_port; |
|
| 1230 | - } |
|
| 1231 | - elseif (!empty($db_port)) |
|
| 1306 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1307 | + $changes['db_port'] = (int) $db_port; |
|
| 1308 | + } |
|
| 1309 | + } elseif (!empty($db_port)) |
|
| 1232 | 1310 | { |
| 1233 | 1311 | // If db_port is set and is the same as the default, set it to '' |
| 1234 | 1312 | if ($db_type == 'mysql') |
| 1235 | 1313 | { |
| 1236 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1237 | - $changes['db_port'] = '\'\''; |
|
| 1238 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1239 | - $changes['db_port'] = '\'\''; |
|
| 1314 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1315 | + $changes['db_port'] = '\'\''; |
|
| 1316 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1317 | + $changes['db_port'] = '\'\''; |
|
| 1318 | + } |
|
| 1240 | 1319 | } |
| 1241 | 1320 | } |
| 1242 | 1321 | |
| 1243 | 1322 | // Maybe we haven't had this option yet? |
| 1244 | - if (empty($packagesdir)) |
|
| 1245 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1323 | + if (empty($packagesdir)) { |
|
| 1324 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1325 | + } |
|
| 1246 | 1326 | |
| 1247 | 1327 | // Add support for $tasksdir var. |
| 1248 | - if (empty($tasksdir)) |
|
| 1249 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1328 | + if (empty($tasksdir)) { |
|
| 1329 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1330 | + } |
|
| 1250 | 1331 | |
| 1251 | 1332 | // Make sure we fix the language as well. |
| 1252 | - if (stristr($language, '-utf8')) |
|
| 1253 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1333 | + if (stristr($language, '-utf8')) { |
|
| 1334 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1335 | + } |
|
| 1254 | 1336 | |
| 1255 | 1337 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1256 | 1338 | |
@@ -1261,8 +1343,7 @@ discard block |
||
| 1261 | 1343 | $changes['upgradeData'] = '"' . base64_encode(json_encode($upcontext['user'])) . '"'; |
| 1262 | 1344 | |
| 1263 | 1345 | migrateSettingsFile($changes); |
| 1264 | - } |
|
| 1265 | - else |
|
| 1346 | + } else |
|
| 1266 | 1347 | { |
| 1267 | 1348 | // Update Settings.php with the new settings. |
| 1268 | 1349 | require_once($sourcedir . '/Subs-Admin.php'); |
@@ -1272,8 +1353,9 @@ discard block |
||
| 1272 | 1353 | move_db_last_error_to_cachedir(); |
| 1273 | 1354 | } |
| 1274 | 1355 | |
| 1275 | - if ($command_line) |
|
| 1276 | - echo ' Successful.' . "\n"; |
|
| 1356 | + if ($command_line) { |
|
| 1357 | + echo ' Successful.' . "\n"; |
|
| 1358 | + } |
|
| 1277 | 1359 | |
| 1278 | 1360 | // Are we doing debug? |
| 1279 | 1361 | if (isset($_POST['debug'])) |
@@ -1283,8 +1365,9 @@ discard block |
||
| 1283 | 1365 | } |
| 1284 | 1366 | |
| 1285 | 1367 | // If we're not backing up then jump one. |
| 1286 | - if (empty($_POST['backup'])) |
|
| 1287 | - $upcontext['current_step']++; |
|
| 1368 | + if (empty($_POST['backup'])) { |
|
| 1369 | + $upcontext['current_step']++; |
|
| 1370 | + } |
|
| 1288 | 1371 | |
| 1289 | 1372 | // If we've got here then let's proceed to the next step! |
| 1290 | 1373 | return true; |
@@ -1299,8 +1382,9 @@ discard block |
||
| 1299 | 1382 | $upcontext['page_title'] = $txt['backup_database']; |
| 1300 | 1383 | |
| 1301 | 1384 | // Done it already - js wise? |
| 1302 | - if (!empty($_POST['backup_done'])) |
|
| 1303 | - return true; |
|
| 1385 | + if (!empty($_POST['backup_done'])) { |
|
| 1386 | + return true; |
|
| 1387 | + } |
|
| 1304 | 1388 | |
| 1305 | 1389 | // Some useful stuff here. |
| 1306 | 1390 | db_extend(); |
@@ -1314,9 +1398,10 @@ discard block |
||
| 1314 | 1398 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1315 | 1399 | |
| 1316 | 1400 | $table_names = array(); |
| 1317 | - foreach ($tables as $table) |
|
| 1318 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1401 | + foreach ($tables as $table) { |
|
| 1402 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1319 | 1403 | $table_names[] = $table; |
| 1404 | + } |
|
| 1320 | 1405 | |
| 1321 | 1406 | $upcontext['table_count'] = count($table_names); |
| 1322 | 1407 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1326,12 +1411,14 @@ discard block |
||
| 1326 | 1411 | $file_steps = $upcontext['table_count']; |
| 1327 | 1412 | |
| 1328 | 1413 | // What ones have we already done? |
| 1329 | - foreach ($table_names as $id => $table) |
|
| 1330 | - if ($id < $_GET['substep']) |
|
| 1414 | + foreach ($table_names as $id => $table) { |
|
| 1415 | + if ($id < $_GET['substep']) |
|
| 1331 | 1416 | $upcontext['previous_tables'][] = $table; |
| 1417 | + } |
|
| 1332 | 1418 | |
| 1333 | - if ($command_line) |
|
| 1334 | - echo 'Backing Up Tables.'; |
|
| 1419 | + if ($command_line) { |
|
| 1420 | + echo 'Backing Up Tables.'; |
|
| 1421 | + } |
|
| 1335 | 1422 | |
| 1336 | 1423 | // If we don't support javascript we backup here. |
| 1337 | 1424 | if (!$support_js || isset($_GET['xml'])) |
@@ -1350,8 +1437,9 @@ discard block |
||
| 1350 | 1437 | backupTable($table_names[$substep]); |
| 1351 | 1438 | |
| 1352 | 1439 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1353 | - if (isset($_GET['xml'])) |
|
| 1354 | - return upgradeExit(); |
|
| 1440 | + if (isset($_GET['xml'])) { |
|
| 1441 | + return upgradeExit(); |
|
| 1442 | + } |
|
| 1355 | 1443 | } |
| 1356 | 1444 | |
| 1357 | 1445 | if ($command_line) |
@@ -1384,9 +1472,10 @@ discard block |
||
| 1384 | 1472 | |
| 1385 | 1473 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1386 | 1474 | |
| 1387 | - if ($command_line) |
|
| 1388 | - echo ' done.'; |
|
| 1389 | -} |
|
| 1475 | + if ($command_line) { |
|
| 1476 | + echo ' done.'; |
|
| 1477 | + } |
|
| 1478 | + } |
|
| 1390 | 1479 | |
| 1391 | 1480 | // Step 2: Everything. |
| 1392 | 1481 | function DatabaseChanges() |
@@ -1395,8 +1484,9 @@ discard block |
||
| 1395 | 1484 | global $upcontext, $support_js, $db_type; |
| 1396 | 1485 | |
| 1397 | 1486 | // Have we just completed this? |
| 1398 | - if (!empty($_POST['database_done'])) |
|
| 1399 | - return true; |
|
| 1487 | + if (!empty($_POST['database_done'])) { |
|
| 1488 | + return true; |
|
| 1489 | + } |
|
| 1400 | 1490 | |
| 1401 | 1491 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1402 | 1492 | $upcontext['page_title'] = $txt['database_changes']; |
@@ -1411,15 +1501,16 @@ discard block |
||
| 1411 | 1501 | ); |
| 1412 | 1502 | |
| 1413 | 1503 | // How many files are there in total? |
| 1414 | - if (isset($_GET['filecount'])) |
|
| 1415 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1416 | - else |
|
| 1504 | + if (isset($_GET['filecount'])) { |
|
| 1505 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1506 | + } else |
|
| 1417 | 1507 | { |
| 1418 | 1508 | $upcontext['file_count'] = 0; |
| 1419 | 1509 | foreach ($files as $file) |
| 1420 | 1510 | { |
| 1421 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1422 | - $upcontext['file_count']++; |
|
| 1511 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1512 | + $upcontext['file_count']++; |
|
| 1513 | + } |
|
| 1423 | 1514 | } |
| 1424 | 1515 | } |
| 1425 | 1516 | |
@@ -1429,9 +1520,9 @@ discard block |
||
| 1429 | 1520 | $upcontext['cur_file_num'] = 0; |
| 1430 | 1521 | foreach ($files as $file) |
| 1431 | 1522 | { |
| 1432 | - if ($did_not_do) |
|
| 1433 | - $did_not_do--; |
|
| 1434 | - else |
|
| 1523 | + if ($did_not_do) { |
|
| 1524 | + $did_not_do--; |
|
| 1525 | + } else |
|
| 1435 | 1526 | { |
| 1436 | 1527 | $upcontext['cur_file_num']++; |
| 1437 | 1528 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1458,12 +1549,13 @@ discard block |
||
| 1458 | 1549 | // Flag to move on to the next. |
| 1459 | 1550 | $upcontext['completed_step'] = true; |
| 1460 | 1551 | // Did we complete the whole file? |
| 1461 | - if ($nextFile) |
|
| 1462 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1552 | + if ($nextFile) { |
|
| 1553 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1554 | + } |
|
| 1463 | 1555 | return upgradeExit(); |
| 1556 | + } elseif ($support_js) { |
|
| 1557 | + break; |
|
| 1464 | 1558 | } |
| 1465 | - elseif ($support_js) |
|
| 1466 | - break; |
|
| 1467 | 1559 | } |
| 1468 | 1560 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1469 | 1561 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1489,8 +1581,9 @@ discard block |
||
| 1489 | 1581 | global $user_info, $maintenance, $smcFunc, $db_type, $txt, $settings; |
| 1490 | 1582 | |
| 1491 | 1583 | // Now it's nice to have some of the basic SMF source files. |
| 1492 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1493 | - redirectLocation('&ssi=1'); |
|
| 1584 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1585 | + redirectLocation('&ssi=1'); |
|
| 1586 | + } |
|
| 1494 | 1587 | |
| 1495 | 1588 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1496 | 1589 | $upcontext['page_title'] = $txt['upgrade_complete']; |
@@ -1506,14 +1599,16 @@ discard block |
||
| 1506 | 1599 | // Are we in maintenance mode? |
| 1507 | 1600 | if (isset($upcontext['user']['main'])) |
| 1508 | 1601 | { |
| 1509 | - if ($command_line) |
|
| 1510 | - echo ' * '; |
|
| 1602 | + if ($command_line) { |
|
| 1603 | + echo ' * '; |
|
| 1604 | + } |
|
| 1511 | 1605 | $upcontext['removed_maintenance'] = true; |
| 1512 | 1606 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1513 | 1607 | } |
| 1514 | 1608 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1515 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1516 | - $changes['maintenance'] = 1; |
|
| 1609 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1610 | + $changes['maintenance'] = 1; |
|
| 1611 | + } |
|
| 1517 | 1612 | |
| 1518 | 1613 | // Wipe this out... |
| 1519 | 1614 | $upcontext['user'] = array(); |
@@ -1528,21 +1623,23 @@ discard block |
||
| 1528 | 1623 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1529 | 1624 | |
| 1530 | 1625 | // Now is the perfect time to fetch the SM files. |
| 1531 | - if ($command_line) |
|
| 1532 | - cli_scheduled_fetchSMfiles(); |
|
| 1533 | - else |
|
| 1626 | + if ($command_line) { |
|
| 1627 | + cli_scheduled_fetchSMfiles(); |
|
| 1628 | + } else |
|
| 1534 | 1629 | { |
| 1535 | 1630 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1536 | 1631 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
| 1537 | 1632 | scheduled_fetchSMfiles(); // Now go get those files! |
| 1538 | 1633 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
| 1539 | - if (httpsOn()) |
|
| 1540 | - $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
| 1634 | + if (httpsOn()) { |
|
| 1635 | + $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
| 1636 | + } |
|
| 1541 | 1637 | } |
| 1542 | 1638 | |
| 1543 | 1639 | // Log what we've done. |
| 1544 | - if (empty($user_info['id'])) |
|
| 1545 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1640 | + if (empty($user_info['id'])) { |
|
| 1641 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1642 | + } |
|
| 1546 | 1643 | |
| 1547 | 1644 | // Log the action manually, so CLI still works. |
| 1548 | 1645 | $smcFunc['db_insert']('', |
@@ -1561,8 +1658,9 @@ discard block |
||
| 1561 | 1658 | |
| 1562 | 1659 | // Save the current database version. |
| 1563 | 1660 | $server_version = $smcFunc['db_server_info'](); |
| 1564 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1565 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1661 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1662 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1663 | + } |
|
| 1566 | 1664 | |
| 1567 | 1665 | if ($command_line) |
| 1568 | 1666 | { |
@@ -1574,8 +1672,9 @@ discard block |
||
| 1574 | 1672 | |
| 1575 | 1673 | // Make sure it says we're done. |
| 1576 | 1674 | $upcontext['overall_percent'] = 100; |
| 1577 | - if (isset($upcontext['step_progress'])) |
|
| 1578 | - unset($upcontext['step_progress']); |
|
| 1675 | + if (isset($upcontext['step_progress'])) { |
|
| 1676 | + unset($upcontext['step_progress']); |
|
| 1677 | + } |
|
| 1579 | 1678 | |
| 1580 | 1679 | $_GET['substep'] = 0; |
| 1581 | 1680 | return false; |
@@ -1586,8 +1685,9 @@ discard block |
||
| 1586 | 1685 | { |
| 1587 | 1686 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1588 | 1687 | |
| 1589 | - if (empty($modSettings['time_format'])) |
|
| 1590 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1688 | + if (empty($modSettings['time_format'])) { |
|
| 1689 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1690 | + } |
|
| 1591 | 1691 | |
| 1592 | 1692 | // What files do we want to get |
| 1593 | 1693 | $request = $smcFunc['db_query']('', ' |
@@ -1621,8 +1721,9 @@ discard block |
||
| 1621 | 1721 | $file_data = fetch_web_data($url); |
| 1622 | 1722 | |
| 1623 | 1723 | // If we got an error - give up - the site might be down. |
| 1624 | - if ($file_data === false) |
|
| 1625 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1724 | + if ($file_data === false) { |
|
| 1725 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1726 | + } |
|
| 1626 | 1727 | |
| 1627 | 1728 | // Save the file to the database. |
| 1628 | 1729 | $smcFunc['db_query']('substring', ' |
@@ -1664,8 +1765,9 @@ discard block |
||
| 1664 | 1765 | $themeData = array(); |
| 1665 | 1766 | foreach ($values as $variable => $value) |
| 1666 | 1767 | { |
| 1667 | - if (!isset($value) || $value === null) |
|
| 1668 | - $value = 0; |
|
| 1768 | + if (!isset($value) || $value === null) { |
|
| 1769 | + $value = 0; |
|
| 1770 | + } |
|
| 1669 | 1771 | |
| 1670 | 1772 | $themeData[] = array(0, 1, $variable, $value); |
| 1671 | 1773 | } |
@@ -1694,8 +1796,9 @@ discard block |
||
| 1694 | 1796 | |
| 1695 | 1797 | foreach ($values as $variable => $value) |
| 1696 | 1798 | { |
| 1697 | - if (empty($modSettings[$value[0]])) |
|
| 1698 | - continue; |
|
| 1799 | + if (empty($modSettings[$value[0]])) { |
|
| 1800 | + continue; |
|
| 1801 | + } |
|
| 1699 | 1802 | |
| 1700 | 1803 | $smcFunc['db_query']('', ' |
| 1701 | 1804 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1781,19 +1884,21 @@ discard block |
||
| 1781 | 1884 | set_error_handler( |
| 1782 | 1885 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1783 | 1886 | { |
| 1784 | - if ($support_js) |
|
| 1785 | - return true; |
|
| 1786 | - else |
|
| 1787 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1887 | + if ($support_js) { |
|
| 1888 | + return true; |
|
| 1889 | + } else { |
|
| 1890 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1891 | + } |
|
| 1788 | 1892 | } |
| 1789 | 1893 | ); |
| 1790 | 1894 | |
| 1791 | 1895 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1792 | 1896 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1793 | - if ($db_type == 'mysql') |
|
| 1794 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1795 | - else |
|
| 1796 | - $db_collation = ''; |
|
| 1897 | + if ($db_type == 'mysql') { |
|
| 1898 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1899 | + } else { |
|
| 1900 | + $db_collation = ''; |
|
| 1901 | + } |
|
| 1797 | 1902 | |
| 1798 | 1903 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1799 | 1904 | |
@@ -1805,8 +1910,9 @@ discard block |
||
| 1805 | 1910 | $last_step = ''; |
| 1806 | 1911 | |
| 1807 | 1912 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1808 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1809 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1913 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1914 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1915 | + } |
|
| 1810 | 1916 | |
| 1811 | 1917 | // Count the total number of steps within this file - for progress. |
| 1812 | 1918 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1826,15 +1932,18 @@ discard block |
||
| 1826 | 1932 | $do_current = $substep >= $_GET['substep']; |
| 1827 | 1933 | |
| 1828 | 1934 | // Get rid of any comments in the beginning of the line... |
| 1829 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1830 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1935 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1936 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1937 | + } |
|
| 1831 | 1938 | |
| 1832 | 1939 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1833 | - if ($is_debug && !$support_js && $command_line) |
|
| 1834 | - flush(); |
|
| 1940 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1941 | + flush(); |
|
| 1942 | + } |
|
| 1835 | 1943 | |
| 1836 | - if (trim($line) === '') |
|
| 1837 | - continue; |
|
| 1944 | + if (trim($line) === '') { |
|
| 1945 | + continue; |
|
| 1946 | + } |
|
| 1838 | 1947 | |
| 1839 | 1948 | if (trim(substr($line, 0, 3)) === '---') |
| 1840 | 1949 | { |
@@ -1844,8 +1953,9 @@ discard block |
||
| 1844 | 1953 | if (trim($current_data) != '' && $type !== '}') |
| 1845 | 1954 | { |
| 1846 | 1955 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1847 | - if ($command_line) |
|
| 1848 | - echo $upcontext['error_message']; |
|
| 1956 | + if ($command_line) { |
|
| 1957 | + echo $upcontext['error_message']; |
|
| 1958 | + } |
|
| 1849 | 1959 | } |
| 1850 | 1960 | |
| 1851 | 1961 | if ($type == ' ') |
@@ -1863,17 +1973,18 @@ discard block |
||
| 1863 | 1973 | if ($do_current) |
| 1864 | 1974 | { |
| 1865 | 1975 | $upcontext['actioned_items'][] = $last_step; |
| 1866 | - if ($command_line) |
|
| 1867 | - echo ' * '; |
|
| 1976 | + if ($command_line) { |
|
| 1977 | + echo ' * '; |
|
| 1978 | + } |
|
| 1868 | 1979 | } |
| 1869 | - } |
|
| 1870 | - elseif ($type == '#') |
|
| 1980 | + } elseif ($type == '#') |
|
| 1871 | 1981 | { |
| 1872 | 1982 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1873 | 1983 | |
| 1874 | 1984 | $upcontext['current_debug_item_num']++; |
| 1875 | - if (trim($line) != '---#') |
|
| 1876 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1985 | + if (trim($line) != '---#') { |
|
| 1986 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1987 | + } |
|
| 1877 | 1988 | |
| 1878 | 1989 | // Have we already done something? |
| 1879 | 1990 | if (isset($_GET['xml']) && $done_something) |
@@ -1884,34 +1995,36 @@ discard block |
||
| 1884 | 1995 | |
| 1885 | 1996 | if ($do_current) |
| 1886 | 1997 | { |
| 1887 | - if (trim($line) == '---#' && $command_line) |
|
| 1888 | - echo ' done.', $endl; |
|
| 1889 | - elseif ($command_line) |
|
| 1890 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1891 | - elseif (trim($line) != '---#') |
|
| 1998 | + if (trim($line) == '---#' && $command_line) { |
|
| 1999 | + echo ' done.', $endl; |
|
| 2000 | + } elseif ($command_line) { |
|
| 2001 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 2002 | + } elseif (trim($line) != '---#') |
|
| 1892 | 2003 | { |
| 1893 | - if ($is_debug) |
|
| 1894 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2004 | + if ($is_debug) { |
|
| 2005 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2006 | + } |
|
| 1895 | 2007 | } |
| 1896 | 2008 | } |
| 1897 | 2009 | |
| 1898 | 2010 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1899 | 2011 | { |
| 1900 | - if ($command_line) |
|
| 1901 | - echo ' * '; |
|
| 1902 | - else |
|
| 1903 | - $upcontext['actioned_items'][] = $last_step; |
|
| 2012 | + if ($command_line) { |
|
| 2013 | + echo ' * '; |
|
| 2014 | + } else { |
|
| 2015 | + $upcontext['actioned_items'][] = $last_step; |
|
| 2016 | + } |
|
| 1904 | 2017 | } |
| 1905 | 2018 | |
| 1906 | 2019 | // Small step - only if we're actually doing stuff. |
| 1907 | - if ($do_current) |
|
| 1908 | - nextSubstep(++$substep); |
|
| 1909 | - else |
|
| 1910 | - $substep++; |
|
| 1911 | - } |
|
| 1912 | - elseif ($type == '{') |
|
| 1913 | - $current_type = 'code'; |
|
| 1914 | - elseif ($type == '}') |
|
| 2020 | + if ($do_current) { |
|
| 2021 | + nextSubstep(++$substep); |
|
| 2022 | + } else { |
|
| 2023 | + $substep++; |
|
| 2024 | + } |
|
| 2025 | + } elseif ($type == '{') { |
|
| 2026 | + $current_type = 'code'; |
|
| 2027 | + } elseif ($type == '}') |
|
| 1915 | 2028 | { |
| 1916 | 2029 | $current_type = 'sql'; |
| 1917 | 2030 | |
@@ -1924,8 +2037,9 @@ discard block |
||
| 1924 | 2037 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1925 | 2038 | { |
| 1926 | 2039 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1927 | - if ($command_line) |
|
| 1928 | - echo $upcontext['error_message']; |
|
| 2040 | + if ($command_line) { |
|
| 2041 | + echo $upcontext['error_message']; |
|
| 2042 | + } |
|
| 1929 | 2043 | } |
| 1930 | 2044 | |
| 1931 | 2045 | // Done with code! |
@@ -2013,8 +2127,9 @@ discard block |
||
| 2013 | 2127 | $db_unbuffered = false; |
| 2014 | 2128 | |
| 2015 | 2129 | // Failure?! |
| 2016 | - if ($result !== false) |
|
| 2017 | - return $result; |
|
| 2130 | + if ($result !== false) { |
|
| 2131 | + return $result; |
|
| 2132 | + } |
|
| 2018 | 2133 | |
| 2019 | 2134 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 2020 | 2135 | // If MySQL we do something more clever. |
@@ -2042,54 +2157,61 @@ discard block |
||
| 2042 | 2157 | { |
| 2043 | 2158 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 2044 | 2159 | $result = mysqli_query($db_connection, $string); |
| 2045 | - if ($result !== false) |
|
| 2046 | - return $result; |
|
| 2160 | + if ($result !== false) { |
|
| 2161 | + return $result; |
|
| 2162 | + } |
|
| 2047 | 2163 | } |
| 2048 | - } |
|
| 2049 | - elseif ($mysqli_errno == 2013) |
|
| 2164 | + } elseif ($mysqli_errno == 2013) |
|
| 2050 | 2165 | { |
| 2051 | 2166 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 2052 | 2167 | mysqli_select_db($db_connection, $db_name); |
| 2053 | 2168 | if ($db_connection) |
| 2054 | 2169 | { |
| 2055 | 2170 | $result = mysqli_query($db_connection, $string); |
| 2056 | - if ($result !== false) |
|
| 2057 | - return $result; |
|
| 2171 | + if ($result !== false) { |
|
| 2172 | + return $result; |
|
| 2173 | + } |
|
| 2058 | 2174 | } |
| 2059 | 2175 | } |
| 2060 | 2176 | // Duplicate column name... should be okay ;). |
| 2061 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 2062 | - return false; |
|
| 2177 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2178 | + return false; |
|
| 2179 | + } |
|
| 2063 | 2180 | // Duplicate insert... make sure it's the proper type of query ;). |
| 2064 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 2065 | - return false; |
|
| 2181 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2182 | + return false; |
|
| 2183 | + } |
|
| 2066 | 2184 | // Creating an index on a non-existent column. |
| 2067 | - elseif ($mysqli_errno == 1072) |
|
| 2068 | - return false; |
|
| 2069 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 2070 | - return false; |
|
| 2185 | + elseif ($mysqli_errno == 1072) { |
|
| 2186 | + return false; |
|
| 2187 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2188 | + return false; |
|
| 2189 | + } |
|
| 2071 | 2190 | } |
| 2072 | 2191 | // If a table already exists don't go potty. |
| 2073 | 2192 | else |
| 2074 | 2193 | { |
| 2075 | 2194 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 2076 | 2195 | { |
| 2077 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 2078 | - return true; |
|
| 2079 | - } |
|
| 2080 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2196 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2197 | + return true; |
|
| 2198 | + } |
|
| 2199 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2081 | 2200 | { |
| 2082 | - if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) |
|
| 2083 | - return true; |
|
| 2201 | + if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) { |
|
| 2202 | + return true; |
|
| 2203 | + } |
|
| 2084 | 2204 | } |
| 2085 | 2205 | } |
| 2086 | 2206 | |
| 2087 | 2207 | // Get the query string so we pass everything. |
| 2088 | 2208 | $query_string = ''; |
| 2089 | - foreach ($_GET as $k => $v) |
|
| 2090 | - $query_string .= ';' . $k . '=' . $v; |
|
| 2091 | - if (strlen($query_string) != 0) |
|
| 2092 | - $query_string = '?' . substr($query_string, 1); |
|
| 2209 | + foreach ($_GET as $k => $v) { |
|
| 2210 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2211 | + } |
|
| 2212 | + if (strlen($query_string) != 0) { |
|
| 2213 | + $query_string = '?' . substr($query_string, 1); |
|
| 2214 | + } |
|
| 2093 | 2215 | |
| 2094 | 2216 | if ($command_line) |
| 2095 | 2217 | { |
@@ -2144,16 +2266,18 @@ discard block |
||
| 2144 | 2266 | { |
| 2145 | 2267 | $found |= 1; |
| 2146 | 2268 | // Do some checks on the data if we have it set. |
| 2147 | - if (isset($change['col_type'])) |
|
| 2148 | - $found &= $change['col_type'] === $column['type']; |
|
| 2149 | - if (isset($change['null_allowed'])) |
|
| 2150 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2151 | - if (isset($change['default'])) |
|
| 2152 | - $found &= $change['default'] === $column['default']; |
|
| 2269 | + if (isset($change['col_type'])) { |
|
| 2270 | + $found &= $change['col_type'] === $column['type']; |
|
| 2271 | + } |
|
| 2272 | + if (isset($change['null_allowed'])) { |
|
| 2273 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2274 | + } |
|
| 2275 | + if (isset($change['default'])) { |
|
| 2276 | + $found &= $change['default'] === $column['default']; |
|
| 2277 | + } |
|
| 2153 | 2278 | } |
| 2154 | 2279 | } |
| 2155 | - } |
|
| 2156 | - elseif ($change['type'] === 'index') |
|
| 2280 | + } elseif ($change['type'] === 'index') |
|
| 2157 | 2281 | { |
| 2158 | 2282 | $request = upgrade_query(' |
| 2159 | 2283 | SHOW INDEX |
@@ -2162,9 +2286,10 @@ discard block |
||
| 2162 | 2286 | { |
| 2163 | 2287 | $cur_index = array(); |
| 2164 | 2288 | |
| 2165 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2166 | - if ($row['Key_name'] === $change['name']) |
|
| 2289 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2290 | + if ($row['Key_name'] === $change['name']) |
|
| 2167 | 2291 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2292 | + } |
|
| 2168 | 2293 | |
| 2169 | 2294 | ksort($cur_index, SORT_NUMERIC); |
| 2170 | 2295 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2174,14 +2299,17 @@ discard block |
||
| 2174 | 2299 | } |
| 2175 | 2300 | |
| 2176 | 2301 | // If we're trying to add and it's added, we're done. |
| 2177 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2178 | - return true; |
|
| 2302 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2303 | + return true; |
|
| 2304 | + } |
|
| 2179 | 2305 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2180 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2181 | - return true; |
|
| 2306 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2307 | + return true; |
|
| 2308 | + } |
|
| 2182 | 2309 | // Otherwise is it just a test? |
| 2183 | - elseif ($is_test) |
|
| 2184 | - return false; |
|
| 2310 | + elseif ($is_test) { |
|
| 2311 | + return false; |
|
| 2312 | + } |
|
| 2185 | 2313 | |
| 2186 | 2314 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2187 | 2315 | $running = false; |
@@ -2192,8 +2320,9 @@ discard block |
||
| 2192 | 2320 | SHOW FULL PROCESSLIST'); |
| 2193 | 2321 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2194 | 2322 | { |
| 2195 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2196 | - $found = true; |
|
| 2323 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2324 | + $found = true; |
|
| 2325 | + } |
|
| 2197 | 2326 | } |
| 2198 | 2327 | |
| 2199 | 2328 | // Can't find it? Then we need to run it fools! |
@@ -2205,8 +2334,9 @@ discard block |
||
| 2205 | 2334 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2206 | 2335 | ' . $change['text'], true) !== false; |
| 2207 | 2336 | |
| 2208 | - if (!$success) |
|
| 2209 | - return false; |
|
| 2337 | + if (!$success) { |
|
| 2338 | + return false; |
|
| 2339 | + } |
|
| 2210 | 2340 | |
| 2211 | 2341 | // Return |
| 2212 | 2342 | $running = true; |
@@ -2248,8 +2378,9 @@ discard block |
||
| 2248 | 2378 | 'db_error_skip' => true, |
| 2249 | 2379 | ) |
| 2250 | 2380 | ); |
| 2251 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2252 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2381 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2382 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2383 | + } |
|
| 2253 | 2384 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2254 | 2385 | $smcFunc['db_free_result']($request); |
| 2255 | 2386 | |
@@ -2271,18 +2402,19 @@ discard block |
||
| 2271 | 2402 | ) |
| 2272 | 2403 | ); |
| 2273 | 2404 | // No results? Just forget it all together. |
| 2274 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2275 | - unset($table_row['Collation']); |
|
| 2276 | - else |
|
| 2277 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2405 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2406 | + unset($table_row['Collation']); |
|
| 2407 | + } else { |
|
| 2408 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2409 | + } |
|
| 2278 | 2410 | $smcFunc['db_free_result']($request); |
| 2279 | 2411 | } |
| 2280 | 2412 | |
| 2281 | 2413 | if ($column_fix) |
| 2282 | 2414 | { |
| 2283 | 2415 | // Make sure there are no NULL's left. |
| 2284 | - if ($null_fix) |
|
| 2285 | - $smcFunc['db_query']('', ' |
|
| 2416 | + if ($null_fix) { |
|
| 2417 | + $smcFunc['db_query']('', ' |
|
| 2286 | 2418 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2287 | 2419 | SET ' . $change['column'] . ' = {string:default} |
| 2288 | 2420 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2291,6 +2423,7 @@ discard block |
||
| 2291 | 2423 | 'db_error_skip' => true, |
| 2292 | 2424 | ) |
| 2293 | 2425 | ); |
| 2426 | + } |
|
| 2294 | 2427 | |
| 2295 | 2428 | // Do the actual alteration. |
| 2296 | 2429 | $smcFunc['db_query']('', ' |
@@ -2319,8 +2452,9 @@ discard block |
||
| 2319 | 2452 | } |
| 2320 | 2453 | |
| 2321 | 2454 | // Not a column we need to check on? |
| 2322 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2323 | - return; |
|
| 2455 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2456 | + return; |
|
| 2457 | + } |
|
| 2324 | 2458 | |
| 2325 | 2459 | // Break it up you (six|seven). |
| 2326 | 2460 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2339,13 +2473,13 @@ discard block |
||
| 2339 | 2473 | 'new_name' => $temp[2], |
| 2340 | 2474 | )); |
| 2341 | 2475 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2342 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2343 | - return; |
|
| 2476 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2477 | + return; |
|
| 2478 | + } |
|
| 2344 | 2479 | |
| 2345 | 2480 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2346 | 2481 | $smcFunc['db_free_result']($request); |
| 2347 | - } |
|
| 2348 | - else |
|
| 2482 | + } else |
|
| 2349 | 2483 | { |
| 2350 | 2484 | // Do this the old fashion, sure method way. |
| 2351 | 2485 | $request = $smcFunc['db_query']('', ' |
@@ -2356,21 +2490,24 @@ discard block |
||
| 2356 | 2490 | )); |
| 2357 | 2491 | // Mayday! |
| 2358 | 2492 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2359 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2360 | - return; |
|
| 2493 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2494 | + return; |
|
| 2495 | + } |
|
| 2361 | 2496 | |
| 2362 | 2497 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2363 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2364 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2498 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2499 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2365 | 2500 | { |
| 2366 | 2501 | $current_type = $row['Type']; |
| 2502 | + } |
|
| 2367 | 2503 | break; |
| 2368 | 2504 | } |
| 2369 | 2505 | } |
| 2370 | 2506 | |
| 2371 | 2507 | // If this doesn't match, the column may of been altered for a reason. |
| 2372 | - if (trim($current_type) != trim($temp[3])) |
|
| 2373 | - $temp[3] = $current_type; |
|
| 2508 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2509 | + $temp[3] = $current_type; |
|
| 2510 | + } |
|
| 2374 | 2511 | |
| 2375 | 2512 | // Piece this back together. |
| 2376 | 2513 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2382,8 +2519,9 @@ discard block |
||
| 2382 | 2519 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2383 | 2520 | global $step_progress, $is_debug, $upcontext; |
| 2384 | 2521 | |
| 2385 | - if ($_GET['substep'] < $substep) |
|
| 2386 | - $_GET['substep'] = $substep; |
|
| 2522 | + if ($_GET['substep'] < $substep) { |
|
| 2523 | + $_GET['substep'] = $substep; |
|
| 2524 | + } |
|
| 2387 | 2525 | |
| 2388 | 2526 | if ($command_line) |
| 2389 | 2527 | { |
@@ -2396,29 +2534,33 @@ discard block |
||
| 2396 | 2534 | } |
| 2397 | 2535 | |
| 2398 | 2536 | @set_time_limit(300); |
| 2399 | - if (function_exists('apache_reset_timeout')) |
|
| 2400 | - @apache_reset_timeout(); |
|
| 2537 | + if (function_exists('apache_reset_timeout')) { |
|
| 2538 | + @apache_reset_timeout(); |
|
| 2539 | + } |
|
| 2401 | 2540 | |
| 2402 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2403 | - return; |
|
| 2541 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2542 | + return; |
|
| 2543 | + } |
|
| 2404 | 2544 | |
| 2405 | 2545 | // Do we have some custom step progress stuff? |
| 2406 | 2546 | if (!empty($step_progress)) |
| 2407 | 2547 | { |
| 2408 | 2548 | $upcontext['substep_progress'] = 0; |
| 2409 | 2549 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2410 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2411 | - $upcontext['substep_progress'] = 99.9; |
|
| 2412 | - else |
|
| 2413 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2550 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2551 | + $upcontext['substep_progress'] = 99.9; |
|
| 2552 | + } else { |
|
| 2553 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2554 | + } |
|
| 2414 | 2555 | |
| 2415 | 2556 | // Make it nicely rounded. |
| 2416 | 2557 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2417 | 2558 | } |
| 2418 | 2559 | |
| 2419 | 2560 | // If this is XML we just exit right away! |
| 2420 | - if (isset($_GET['xml'])) |
|
| 2421 | - return upgradeExit(); |
|
| 2561 | + if (isset($_GET['xml'])) { |
|
| 2562 | + return upgradeExit(); |
|
| 2563 | + } |
|
| 2422 | 2564 | |
| 2423 | 2565 | // We're going to pause after this! |
| 2424 | 2566 | $upcontext['pause'] = true; |
@@ -2426,13 +2568,15 @@ discard block |
||
| 2426 | 2568 | $upcontext['query_string'] = ''; |
| 2427 | 2569 | foreach ($_GET as $k => $v) |
| 2428 | 2570 | { |
| 2429 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2430 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2571 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2572 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2573 | + } |
|
| 2431 | 2574 | } |
| 2432 | 2575 | |
| 2433 | 2576 | // Custom warning? |
| 2434 | - if (!empty($custom_warning)) |
|
| 2435 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2577 | + if (!empty($custom_warning)) { |
|
| 2578 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2579 | + } |
|
| 2436 | 2580 | |
| 2437 | 2581 | upgradeExit(); |
| 2438 | 2582 | } |
@@ -2447,25 +2591,26 @@ discard block |
||
| 2447 | 2591 | ob_implicit_flush(true); |
| 2448 | 2592 | @set_time_limit(600); |
| 2449 | 2593 | |
| 2450 | - if (!isset($_SERVER['argv'])) |
|
| 2451 | - $_SERVER['argv'] = array(); |
|
| 2594 | + if (!isset($_SERVER['argv'])) { |
|
| 2595 | + $_SERVER['argv'] = array(); |
|
| 2596 | + } |
|
| 2452 | 2597 | $_GET['maint'] = 1; |
| 2453 | 2598 | |
| 2454 | 2599 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2455 | 2600 | { |
| 2456 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2457 | - $_GET['lang'] = $match[1]; |
|
| 2458 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2459 | - continue; |
|
| 2460 | - elseif ($arg == '--no-maintenance') |
|
| 2461 | - $_GET['maint'] = 0; |
|
| 2462 | - elseif ($arg == '--debug') |
|
| 2463 | - $is_debug = true; |
|
| 2464 | - elseif ($arg == '--backup') |
|
| 2465 | - $_POST['backup'] = 1; |
|
| 2466 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2467 | - $_GET['conv'] = 1; |
|
| 2468 | - elseif ($i != 0) |
|
| 2601 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2602 | + $_GET['lang'] = $match[1]; |
|
| 2603 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2604 | + continue; |
|
| 2605 | + } elseif ($arg == '--no-maintenance') { |
|
| 2606 | + $_GET['maint'] = 0; |
|
| 2607 | + } elseif ($arg == '--debug') { |
|
| 2608 | + $is_debug = true; |
|
| 2609 | + } elseif ($arg == '--backup') { |
|
| 2610 | + $_POST['backup'] = 1; |
|
| 2611 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2612 | + $_GET['conv'] = 1; |
|
| 2613 | + } elseif ($i != 0) |
|
| 2469 | 2614 | { |
| 2470 | 2615 | echo 'SMF Command-line Upgrader |
| 2471 | 2616 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2479,10 +2624,12 @@ discard block |
||
| 2479 | 2624 | } |
| 2480 | 2625 | } |
| 2481 | 2626 | |
| 2482 | - if (!php_version_check()) |
|
| 2483 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2484 | - if (!db_version_check()) |
|
| 2485 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2627 | + if (!php_version_check()) { |
|
| 2628 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2629 | + } |
|
| 2630 | + if (!db_version_check()) { |
|
| 2631 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2632 | + } |
|
| 2486 | 2633 | |
| 2487 | 2634 | // Do some checks to make sure they have proper privileges |
| 2488 | 2635 | db_extend('packages'); |
@@ -2497,34 +2644,39 @@ discard block |
||
| 2497 | 2644 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2498 | 2645 | |
| 2499 | 2646 | // Sorry... we need CREATE, ALTER and DROP |
| 2500 | - if (!$create || !$alter || !$drop) |
|
| 2501 | - 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); |
|
| 2647 | + if (!$create || !$alter || !$drop) { |
|
| 2648 | + 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); |
|
| 2649 | + } |
|
| 2502 | 2650 | |
| 2503 | 2651 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2504 | 2652 | && @file_exists($sourcedir . '/QueryString.php') |
| 2505 | 2653 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2506 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2507 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2654 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2655 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2656 | + } |
|
| 2508 | 2657 | |
| 2509 | 2658 | // Do a quick version spot check. |
| 2510 | 2659 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2511 | 2660 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2512 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2513 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2661 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2662 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2663 | + } |
|
| 2514 | 2664 | |
| 2515 | 2665 | // Make sure Settings.php is writable. |
| 2516 | 2666 | quickFileWritable($boarddir . '/Settings.php'); |
| 2517 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2518 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2667 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2668 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2669 | + } |
|
| 2519 | 2670 | |
| 2520 | 2671 | // Make sure Settings_bak.php is writable. |
| 2521 | 2672 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2522 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2523 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2673 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2674 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2675 | + } |
|
| 2524 | 2676 | |
| 2525 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2526 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2527 | - elseif (isset($modSettings['agreement'])) |
|
| 2677 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2678 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2679 | + } elseif (isset($modSettings['agreement'])) |
|
| 2528 | 2680 | { |
| 2529 | 2681 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2530 | 2682 | fwrite($fp, $modSettings['agreement']); |
@@ -2534,36 +2686,42 @@ discard block |
||
| 2534 | 2686 | // Make sure Themes is writable. |
| 2535 | 2687 | quickFileWritable($modSettings['theme_dir']); |
| 2536 | 2688 | |
| 2537 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2538 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2689 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2690 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2691 | + } |
|
| 2539 | 2692 | |
| 2540 | 2693 | // Make sure cache directory exists and is writable! |
| 2541 | 2694 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2542 | - if (!file_exists($cachedir_temp)) |
|
| 2543 | - @mkdir($cachedir_temp); |
|
| 2695 | + if (!file_exists($cachedir_temp)) { |
|
| 2696 | + @mkdir($cachedir_temp); |
|
| 2697 | + } |
|
| 2544 | 2698 | |
| 2545 | 2699 | // Make sure the cache temp dir is writable. |
| 2546 | 2700 | quickFileWritable($cachedir_temp); |
| 2547 | 2701 | |
| 2548 | - if (!is_writable($cachedir_temp)) |
|
| 2549 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2702 | + if (!is_writable($cachedir_temp)) { |
|
| 2703 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2704 | + } |
|
| 2550 | 2705 | |
| 2551 | 2706 | // Make sure db_last_error.php is writable. |
| 2552 | 2707 | quickFileWritable($cachedir_temp . '/db_last_error.php'); |
| 2553 | - if (!is_writable($cachedir_temp . '/db_last_error.php')) |
|
| 2554 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2708 | + if (!is_writable($cachedir_temp . '/db_last_error.php')) { |
|
| 2709 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2710 | + } |
|
| 2555 | 2711 | |
| 2556 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2557 | - print_error('Error: Unable to find language files!', true); |
|
| 2558 | - else |
|
| 2712 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2713 | + print_error('Error: Unable to find language files!', true); |
|
| 2714 | + } else |
|
| 2559 | 2715 | { |
| 2560 | 2716 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2561 | 2717 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2562 | 2718 | |
| 2563 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2564 | - print_error('Error: Language files out of date.', true); |
|
| 2565 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2566 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2719 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2720 | + print_error('Error: Language files out of date.', true); |
|
| 2721 | + } |
|
| 2722 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2723 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2724 | + } |
|
| 2567 | 2725 | |
| 2568 | 2726 | // Otherwise include it! |
| 2569 | 2727 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2583,8 +2741,9 @@ discard block |
||
| 2583 | 2741 | global $db_prefix, $db_type, $command_line, $support_js, $txt; |
| 2584 | 2742 | |
| 2585 | 2743 | // Done it already? |
| 2586 | - if (!empty($_POST['utf8_done'])) |
|
| 2587 | - return true; |
|
| 2744 | + if (!empty($_POST['utf8_done'])) { |
|
| 2745 | + return true; |
|
| 2746 | + } |
|
| 2588 | 2747 | |
| 2589 | 2748 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2590 | 2749 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2597,8 +2756,7 @@ discard block |
||
| 2597 | 2756 | ); |
| 2598 | 2757 | |
| 2599 | 2758 | return true; |
| 2600 | - } |
|
| 2601 | - else |
|
| 2759 | + } else |
|
| 2602 | 2760 | { |
| 2603 | 2761 | $upcontext['page_title'] = $txt['converting_utf8']; |
| 2604 | 2762 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2642,8 +2800,9 @@ discard block |
||
| 2642 | 2800 | ) |
| 2643 | 2801 | ); |
| 2644 | 2802 | $db_charsets = array(); |
| 2645 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2646 | - $db_charsets[] = $row['Charset']; |
|
| 2803 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2804 | + $db_charsets[] = $row['Charset']; |
|
| 2805 | + } |
|
| 2647 | 2806 | |
| 2648 | 2807 | $smcFunc['db_free_result']($request); |
| 2649 | 2808 | |
@@ -2679,13 +2838,15 @@ discard block |
||
| 2679 | 2838 | // If there's a fulltext index, we need to drop it first... |
| 2680 | 2839 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2681 | 2840 | { |
| 2682 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2683 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2841 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2842 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2684 | 2843 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2844 | + } |
|
| 2685 | 2845 | $smcFunc['db_free_result']($request); |
| 2686 | 2846 | |
| 2687 | - if (isset($upcontext['fulltext_index'])) |
|
| 2688 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2847 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2848 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2849 | + } |
|
| 2689 | 2850 | } |
| 2690 | 2851 | |
| 2691 | 2852 | // Drop it and make a note... |
@@ -2875,8 +3036,9 @@ discard block |
||
| 2875 | 3036 | $replace = '%field%'; |
| 2876 | 3037 | |
| 2877 | 3038 | // Build a huge REPLACE statement... |
| 2878 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2879 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3039 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 3040 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3041 | + } |
|
| 2880 | 3042 | } |
| 2881 | 3043 | |
| 2882 | 3044 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2886,9 +3048,10 @@ discard block |
||
| 2886 | 3048 | $upcontext['table_count'] = count($queryTables); |
| 2887 | 3049 | |
| 2888 | 3050 | // What ones have we already done? |
| 2889 | - foreach ($queryTables as $id => $table) |
|
| 2890 | - if ($id < $_GET['substep']) |
|
| 3051 | + foreach ($queryTables as $id => $table) { |
|
| 3052 | + if ($id < $_GET['substep']) |
|
| 2891 | 3053 | $upcontext['previous_tables'][] = $table; |
| 3054 | + } |
|
| 2892 | 3055 | |
| 2893 | 3056 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2894 | 3057 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2925,8 +3088,9 @@ discard block |
||
| 2925 | 3088 | nextSubstep($substep); |
| 2926 | 3089 | |
| 2927 | 3090 | // Just to make sure it doesn't time out. |
| 2928 | - if (function_exists('apache_reset_timeout')) |
|
| 2929 | - @apache_reset_timeout(); |
|
| 3091 | + if (function_exists('apache_reset_timeout')) { |
|
| 3092 | + @apache_reset_timeout(); |
|
| 3093 | + } |
|
| 2930 | 3094 | |
| 2931 | 3095 | $table_charsets = array(); |
| 2932 | 3096 | |
@@ -2949,8 +3113,9 @@ discard block |
||
| 2949 | 3113 | |
| 2950 | 3114 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2951 | 3115 | if ($charset != 'utf8') { |
| 2952 | - if (!isset($table_charsets[$charset])) |
|
| 2953 | - $table_charsets[$charset] = array(); |
|
| 3116 | + if (!isset($table_charsets[$charset])) { |
|
| 3117 | + $table_charsets[$charset] = array(); |
|
| 3118 | + } |
|
| 2954 | 3119 | |
| 2955 | 3120 | $table_charsets[$charset][] = $column_info; |
| 2956 | 3121 | } |
@@ -2991,10 +3156,11 @@ discard block |
||
| 2991 | 3156 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2992 | 3157 | { |
| 2993 | 3158 | $update = ''; |
| 2994 | - foreach ($table_charsets as $charset => $columns) |
|
| 2995 | - foreach ($columns as $column) |
|
| 3159 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3160 | + foreach ($columns as $column) |
|
| 2996 | 3161 | $update .= ' |
| 2997 | 3162 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3163 | + } |
|
| 2998 | 3164 | |
| 2999 | 3165 | $smcFunc['db_query']('', ' |
| 3000 | 3166 | UPDATE {raw:table_name} |
@@ -3019,8 +3185,9 @@ discard block |
||
| 3019 | 3185 | // Now do the actual conversion (if still needed). |
| 3020 | 3186 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 3021 | 3187 | { |
| 3022 | - if ($command_line) |
|
| 3023 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3188 | + if ($command_line) { |
|
| 3189 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3190 | + } |
|
| 3024 | 3191 | |
| 3025 | 3192 | $smcFunc['db_query']('', ' |
| 3026 | 3193 | ALTER TABLE {raw:table_name} |
@@ -3030,12 +3197,14 @@ discard block |
||
| 3030 | 3197 | ) |
| 3031 | 3198 | ); |
| 3032 | 3199 | |
| 3033 | - if ($command_line) |
|
| 3034 | - echo " done.\n"; |
|
| 3200 | + if ($command_line) { |
|
| 3201 | + echo " done.\n"; |
|
| 3202 | + } |
|
| 3035 | 3203 | } |
| 3036 | 3204 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3037 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 3038 | - return upgradeExit(); |
|
| 3205 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3206 | + return upgradeExit(); |
|
| 3207 | + } |
|
| 3039 | 3208 | } |
| 3040 | 3209 | |
| 3041 | 3210 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -3064,8 +3233,8 @@ discard block |
||
| 3064 | 3233 | ); |
| 3065 | 3234 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3066 | 3235 | { |
| 3067 | - 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) |
|
| 3068 | - $smcFunc['db_query']('', ' |
|
| 3236 | + 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) { |
|
| 3237 | + $smcFunc['db_query']('', ' |
|
| 3069 | 3238 | UPDATE {db_prefix}log_actions |
| 3070 | 3239 | SET extra = {string:extra} |
| 3071 | 3240 | WHERE id_action = {int:current_action}', |
@@ -3074,6 +3243,7 @@ discard block |
||
| 3074 | 3243 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 3075 | 3244 | ) |
| 3076 | 3245 | ); |
| 3246 | + } |
|
| 3077 | 3247 | } |
| 3078 | 3248 | $smcFunc['db_free_result']($request); |
| 3079 | 3249 | |
@@ -3095,15 +3265,17 @@ discard block |
||
| 3095 | 3265 | // First thing's first - did we already do this? |
| 3096 | 3266 | if (!empty($modSettings['json_done'])) |
| 3097 | 3267 | { |
| 3098 | - if ($command_line) |
|
| 3099 | - return DeleteUpgrade(); |
|
| 3100 | - else |
|
| 3101 | - return true; |
|
| 3268 | + if ($command_line) { |
|
| 3269 | + return DeleteUpgrade(); |
|
| 3270 | + } else { |
|
| 3271 | + return true; |
|
| 3272 | + } |
|
| 3102 | 3273 | } |
| 3103 | 3274 | |
| 3104 | 3275 | // Done it already - js wise? |
| 3105 | - if (!empty($_POST['json_done'])) |
|
| 3106 | - return true; |
|
| 3276 | + if (!empty($_POST['json_done'])) { |
|
| 3277 | + return true; |
|
| 3278 | + } |
|
| 3107 | 3279 | |
| 3108 | 3280 | // List of tables affected by this function |
| 3109 | 3281 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3135,12 +3307,14 @@ discard block |
||
| 3135 | 3307 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3136 | 3308 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3137 | 3309 | |
| 3138 | - foreach ($keys as $id => $table) |
|
| 3139 | - if ($id < $_GET['substep']) |
|
| 3310 | + foreach ($keys as $id => $table) { |
|
| 3311 | + if ($id < $_GET['substep']) |
|
| 3140 | 3312 | $upcontext['previous_tables'][] = $table; |
| 3313 | + } |
|
| 3141 | 3314 | |
| 3142 | - if ($command_line) |
|
| 3143 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3315 | + if ($command_line) { |
|
| 3316 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3317 | + } |
|
| 3144 | 3318 | |
| 3145 | 3319 | if (!$support_js || isset($_GET['xml'])) |
| 3146 | 3320 | { |
@@ -3180,8 +3354,9 @@ discard block |
||
| 3180 | 3354 | |
| 3181 | 3355 | // Loop through and fix these... |
| 3182 | 3356 | $new_settings = array(); |
| 3183 | - if ($command_line) |
|
| 3184 | - echo "\n" . 'Fixing some settings...'; |
|
| 3357 | + if ($command_line) { |
|
| 3358 | + echo "\n" . 'Fixing some settings...'; |
|
| 3359 | + } |
|
| 3185 | 3360 | |
| 3186 | 3361 | foreach ($serialized_settings as $var) |
| 3187 | 3362 | { |
@@ -3189,22 +3364,24 @@ discard block |
||
| 3189 | 3364 | { |
| 3190 | 3365 | // Attempt to unserialize the setting |
| 3191 | 3366 | $temp = @safe_unserialize($modSettings[$var]); |
| 3192 | - if (!$temp && $command_line) |
|
| 3193 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3194 | - elseif ($temp !== false) |
|
| 3195 | - $new_settings[$var] = json_encode($temp); |
|
| 3367 | + if (!$temp && $command_line) { |
|
| 3368 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3369 | + } elseif ($temp !== false) { |
|
| 3370 | + $new_settings[$var] = json_encode($temp); |
|
| 3371 | + } |
|
| 3196 | 3372 | } |
| 3197 | 3373 | } |
| 3198 | 3374 | |
| 3199 | 3375 | // Update everything at once |
| 3200 | - if (!function_exists('cache_put_data')) |
|
| 3201 | - require_once($sourcedir . '/Load.php'); |
|
| 3376 | + if (!function_exists('cache_put_data')) { |
|
| 3377 | + require_once($sourcedir . '/Load.php'); |
|
| 3378 | + } |
|
| 3202 | 3379 | updateSettings($new_settings, true); |
| 3203 | 3380 | |
| 3204 | - if ($command_line) |
|
| 3205 | - echo ' done.'; |
|
| 3206 | - } |
|
| 3207 | - elseif ($table == 'themes') |
|
| 3381 | + if ($command_line) { |
|
| 3382 | + echo ' done.'; |
|
| 3383 | + } |
|
| 3384 | + } elseif ($table == 'themes') |
|
| 3208 | 3385 | { |
| 3209 | 3386 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3210 | 3387 | $query = $smcFunc['db_query']('', ' |
@@ -3223,10 +3400,11 @@ discard block |
||
| 3223 | 3400 | |
| 3224 | 3401 | if ($command_line) |
| 3225 | 3402 | { |
| 3226 | - if ($temp === false) |
|
| 3227 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3228 | - else |
|
| 3229 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3403 | + if ($temp === false) { |
|
| 3404 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3405 | + } else { |
|
| 3406 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3407 | + } |
|
| 3230 | 3408 | } |
| 3231 | 3409 | |
| 3232 | 3410 | if ($temp !== false) |
@@ -3248,15 +3426,15 @@ discard block |
||
| 3248 | 3426 | ) |
| 3249 | 3427 | ); |
| 3250 | 3428 | |
| 3251 | - if ($command_line) |
|
| 3252 | - echo ' done.'; |
|
| 3429 | + if ($command_line) { |
|
| 3430 | + echo ' done.'; |
|
| 3431 | + } |
|
| 3253 | 3432 | } |
| 3254 | 3433 | } |
| 3255 | 3434 | |
| 3256 | 3435 | $smcFunc['db_free_result']($query); |
| 3257 | 3436 | } |
| 3258 | - } |
|
| 3259 | - else |
|
| 3437 | + } else |
|
| 3260 | 3438 | { |
| 3261 | 3439 | // First item is always the key... |
| 3262 | 3440 | $key = $info[0]; |
@@ -3267,8 +3445,7 @@ discard block |
||
| 3267 | 3445 | { |
| 3268 | 3446 | $col_select = $info[1]; |
| 3269 | 3447 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3270 | - } |
|
| 3271 | - else |
|
| 3448 | + } else |
|
| 3272 | 3449 | { |
| 3273 | 3450 | $col_select = implode(', ', $info); |
| 3274 | 3451 | } |
@@ -3301,8 +3478,7 @@ discard block |
||
| 3301 | 3478 | if ($temp === false && $command_line) |
| 3302 | 3479 | { |
| 3303 | 3480 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3304 | - } |
|
| 3305 | - else |
|
| 3481 | + } else |
|
| 3306 | 3482 | { |
| 3307 | 3483 | $row[$col] = json_encode($temp); |
| 3308 | 3484 | |
@@ -3327,16 +3503,18 @@ discard block |
||
| 3327 | 3503 | } |
| 3328 | 3504 | } |
| 3329 | 3505 | |
| 3330 | - if ($command_line) |
|
| 3331 | - echo ' done.'; |
|
| 3506 | + if ($command_line) { |
|
| 3507 | + echo ' done.'; |
|
| 3508 | + } |
|
| 3332 | 3509 | |
| 3333 | 3510 | // Free up some memory... |
| 3334 | 3511 | $smcFunc['db_free_result']($query); |
| 3335 | 3512 | } |
| 3336 | 3513 | } |
| 3337 | 3514 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3338 | - if (isset($_GET['xml'])) |
|
| 3339 | - return upgradeExit(); |
|
| 3515 | + if (isset($_GET['xml'])) { |
|
| 3516 | + return upgradeExit(); |
|
| 3517 | + } |
|
| 3340 | 3518 | } |
| 3341 | 3519 | |
| 3342 | 3520 | if ($command_line) |
@@ -3351,8 +3529,9 @@ discard block |
||
| 3351 | 3529 | |
| 3352 | 3530 | $_GET['substep'] = 0; |
| 3353 | 3531 | // Make sure we move on! |
| 3354 | - if ($command_line) |
|
| 3355 | - return DeleteUpgrade(); |
|
| 3532 | + if ($command_line) { |
|
| 3533 | + return DeleteUpgrade(); |
|
| 3534 | + } |
|
| 3356 | 3535 | |
| 3357 | 3536 | return true; |
| 3358 | 3537 | } |
@@ -3409,14 +3588,16 @@ discard block |
||
| 3409 | 3588 | global $upcontext, $txt, $settings; |
| 3410 | 3589 | |
| 3411 | 3590 | // Don't call me twice! |
| 3412 | - if (!empty($upcontext['chmod_called'])) |
|
| 3413 | - return; |
|
| 3591 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3592 | + return; |
|
| 3593 | + } |
|
| 3414 | 3594 | |
| 3415 | 3595 | $upcontext['chmod_called'] = true; |
| 3416 | 3596 | |
| 3417 | 3597 | // Nothing? |
| 3418 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3419 | - return; |
|
| 3598 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3599 | + return; |
|
| 3600 | + } |
|
| 3420 | 3601 | |
| 3421 | 3602 | // Was it a problem with Windows? |
| 3422 | 3603 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3448,11 +3629,12 @@ discard block |
||
| 3448 | 3629 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\'); |
| 3449 | 3630 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3450 | 3631 | |
| 3451 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3452 | - echo ' |
|
| 3632 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3633 | + echo ' |
|
| 3453 | 3634 | content.write(\'<hr>\n\t\t\t\'); |
| 3454 | 3635 | content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\'); |
| 3455 | 3636 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3637 | + } |
|
| 3456 | 3638 | |
| 3457 | 3639 | echo ' |
| 3458 | 3640 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3460,17 +3642,19 @@ discard block |
||
| 3460 | 3642 | } |
| 3461 | 3643 | </script>'; |
| 3462 | 3644 | |
| 3463 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3464 | - echo ' |
|
| 3645 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3646 | + echo ' |
|
| 3465 | 3647 | <div class="error_message red"> |
| 3466 | 3648 | ', $txt['upgrade_ftp_error'], '<br><br> |
| 3467 | 3649 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3468 | 3650 | </div> |
| 3469 | 3651 | <br>'; |
| 3652 | + } |
|
| 3470 | 3653 | |
| 3471 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3472 | - echo ' |
|
| 3654 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3655 | + echo ' |
|
| 3473 | 3656 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3657 | + } |
|
| 3474 | 3658 | |
| 3475 | 3659 | echo ' |
| 3476 | 3660 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3507,10 +3691,11 @@ discard block |
||
| 3507 | 3691 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div> |
| 3508 | 3692 | </div>'; |
| 3509 | 3693 | |
| 3510 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3511 | - echo ' |
|
| 3694 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3695 | + echo ' |
|
| 3512 | 3696 | </form>'; |
| 3513 | -} |
|
| 3697 | + } |
|
| 3698 | + } |
|
| 3514 | 3699 | |
| 3515 | 3700 | function template_upgrade_above() |
| 3516 | 3701 | { |
@@ -3570,9 +3755,10 @@ discard block |
||
| 3570 | 3755 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3571 | 3756 | <ul>'; |
| 3572 | 3757 | |
| 3573 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3574 | - echo ' |
|
| 3758 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3759 | + echo ' |
|
| 3575 | 3760 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3761 | + } |
|
| 3576 | 3762 | |
| 3577 | 3763 | echo ' |
| 3578 | 3764 | </ul> |
@@ -3585,8 +3771,8 @@ discard block |
||
| 3585 | 3771 | </div> |
| 3586 | 3772 | </div>'; |
| 3587 | 3773 | |
| 3588 | - if (isset($upcontext['step_progress'])) |
|
| 3589 | - echo ' |
|
| 3774 | + if (isset($upcontext['step_progress'])) { |
|
| 3775 | + echo ' |
|
| 3590 | 3776 | <br> |
| 3591 | 3777 | <br> |
| 3592 | 3778 | <div id="progress_bar_step"> |
@@ -3595,6 +3781,7 @@ discard block |
||
| 3595 | 3781 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3596 | 3782 | </div> |
| 3597 | 3783 | </div>'; |
| 3784 | + } |
|
| 3598 | 3785 | |
| 3599 | 3786 | echo ' |
| 3600 | 3787 | <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> |
@@ -3625,32 +3812,36 @@ discard block |
||
| 3625 | 3812 | { |
| 3626 | 3813 | global $upcontext, $txt; |
| 3627 | 3814 | |
| 3628 | - if (!empty($upcontext['pause'])) |
|
| 3629 | - echo ' |
|
| 3815 | + if (!empty($upcontext['pause'])) { |
|
| 3816 | + echo ' |
|
| 3630 | 3817 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3631 | 3818 | |
| 3632 | 3819 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3633 | 3820 | <h3> |
| 3634 | 3821 | ', $txt['upgrade_paused_overload'], ' |
| 3635 | 3822 | </h3>'; |
| 3823 | + } |
|
| 3636 | 3824 | |
| 3637 | - if (!empty($upcontext['custom_warning'])) |
|
| 3638 | - echo ' |
|
| 3825 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3826 | + echo ' |
|
| 3639 | 3827 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3640 | 3828 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3641 | 3829 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3642 | 3830 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3643 | 3831 | </div>'; |
| 3832 | + } |
|
| 3644 | 3833 | |
| 3645 | 3834 | echo ' |
| 3646 | 3835 | <div class="righttext" style="margin: 1ex;">'; |
| 3647 | 3836 | |
| 3648 | - if (!empty($upcontext['continue'])) |
|
| 3649 | - echo ' |
|
| 3837 | + if (!empty($upcontext['continue'])) { |
|
| 3838 | + echo ' |
|
| 3650 | 3839 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
| 3651 | - if (!empty($upcontext['skip'])) |
|
| 3652 | - echo ' |
|
| 3840 | + } |
|
| 3841 | + if (!empty($upcontext['skip'])) { |
|
| 3842 | + echo ' |
|
| 3653 | 3843 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
| 3844 | + } |
|
| 3654 | 3845 | |
| 3655 | 3846 | echo ' |
| 3656 | 3847 | </div> |
@@ -3701,11 +3892,12 @@ discard block |
||
| 3701 | 3892 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3702 | 3893 | <smf>'; |
| 3703 | 3894 | |
| 3704 | - if (!empty($upcontext['get_data'])) |
|
| 3705 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3895 | + if (!empty($upcontext['get_data'])) { |
|
| 3896 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3706 | 3897 | echo ' |
| 3707 | 3898 | <get key="', $k, '">', $v, '</get>'; |
| 3708 | -} |
|
| 3899 | + } |
|
| 3900 | + } |
|
| 3709 | 3901 | |
| 3710 | 3902 | function template_xml_below() |
| 3711 | 3903 | { |
@@ -3747,8 +3939,8 @@ discard block |
||
| 3747 | 3939 | template_chmod(); |
| 3748 | 3940 | |
| 3749 | 3941 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3750 | - if ($upcontext['is_large_forum']) |
|
| 3751 | - echo ' |
|
| 3942 | + if ($upcontext['is_large_forum']) { |
|
| 3943 | + echo ' |
|
| 3752 | 3944 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3753 | 3945 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3754 | 3946 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3756,10 +3948,11 @@ discard block |
||
| 3756 | 3948 | ', $txt['upgrade_warning_lots_data'], ' |
| 3757 | 3949 | </div> |
| 3758 | 3950 | </div>'; |
| 3951 | + } |
|
| 3759 | 3952 | |
| 3760 | 3953 | // A warning message? |
| 3761 | - if (!empty($upcontext['warning'])) |
|
| 3762 | - echo ' |
|
| 3954 | + if (!empty($upcontext['warning'])) { |
|
| 3955 | + echo ' |
|
| 3763 | 3956 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3764 | 3957 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3765 | 3958 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3767,6 +3960,7 @@ discard block |
||
| 3767 | 3960 | ', $upcontext['warning'], ' |
| 3768 | 3961 | </div> |
| 3769 | 3962 | </div>'; |
| 3963 | + } |
|
| 3770 | 3964 | |
| 3771 | 3965 | // Paths are incorrect? |
| 3772 | 3966 | echo ' |
@@ -3782,20 +3976,22 @@ discard block |
||
| 3782 | 3976 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3783 | 3977 | { |
| 3784 | 3978 | $ago = time() - $upcontext['started']; |
| 3785 | - if ($ago < 60) |
|
| 3786 | - $ago = $ago . ' seconds'; |
|
| 3787 | - elseif ($ago < 3600) |
|
| 3788 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3789 | - else |
|
| 3790 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3979 | + if ($ago < 60) { |
|
| 3980 | + $ago = $ago . ' seconds'; |
|
| 3981 | + } elseif ($ago < 3600) { |
|
| 3982 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3983 | + } else { |
|
| 3984 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3985 | + } |
|
| 3791 | 3986 | |
| 3792 | 3987 | $active = time() - $upcontext['updated']; |
| 3793 | - if ($active < 60) |
|
| 3794 | - $updated = $active . ' seconds'; |
|
| 3795 | - elseif ($active < 3600) |
|
| 3796 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3797 | - else |
|
| 3798 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3988 | + if ($active < 60) { |
|
| 3989 | + $updated = $active . ' seconds'; |
|
| 3990 | + } elseif ($active < 3600) { |
|
| 3991 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3992 | + } else { |
|
| 3993 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3994 | + } |
|
| 3799 | 3995 | |
| 3800 | 3996 | echo ' |
| 3801 | 3997 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3804,16 +4000,18 @@ discard block |
||
| 3804 | 4000 | <div style="padding-left: 6ex;"> |
| 3805 | 4001 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3806 | 4002 | |
| 3807 | - if ($active < 600) |
|
| 3808 | - echo ' |
|
| 4003 | + if ($active < 600) { |
|
| 4004 | + echo ' |
|
| 3809 | 4005 | ', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], ''; |
| 4006 | + } |
|
| 3810 | 4007 | |
| 3811 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3812 | - echo ' |
|
| 4008 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 4009 | + echo ' |
|
| 3813 | 4010 | <br><br>',$txt['upgrade_run'], ''; |
| 3814 | - else |
|
| 3815 | - echo ' |
|
| 4011 | + } else { |
|
| 4012 | + echo ' |
|
| 3816 | 4013 | <br><br>', $txt['upgrade_script_timeout'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_script_timeout2'], ' ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
| 4014 | + } |
|
| 3817 | 4015 | |
| 3818 | 4016 | echo ' |
| 3819 | 4017 | </div> |
@@ -3829,9 +4027,10 @@ discard block |
||
| 3829 | 4027 | <td> |
| 3830 | 4028 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
| 3831 | 4029 | |
| 3832 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3833 | - echo ' |
|
| 4030 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 4031 | + echo ' |
|
| 3834 | 4032 | <div class="smalltext" style="color: red;">', $txt['upgrade_wrong_username'], '</div>'; |
| 4033 | + } |
|
| 3835 | 4034 | |
| 3836 | 4035 | echo ' |
| 3837 | 4036 | </td> |
@@ -3842,9 +4041,10 @@ discard block |
||
| 3842 | 4041 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
| 3843 | 4042 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3844 | 4043 | |
| 3845 | - if (!empty($upcontext['password_failed'])) |
|
| 3846 | - echo ' |
|
| 4044 | + if (!empty($upcontext['password_failed'])) { |
|
| 4045 | + echo ' |
|
| 3847 | 4046 | <div class="smalltext" style="color: red;">', $txt['upgrade_wrong_password'], '</div>'; |
| 4047 | + } |
|
| 3848 | 4048 | |
| 3849 | 4049 | echo ' |
| 3850 | 4050 | </td> |
@@ -3916,8 +4116,8 @@ discard block |
||
| 3916 | 4116 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3917 | 4117 | |
| 3918 | 4118 | // Warning message? |
| 3919 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3920 | - echo ' |
|
| 4119 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 4120 | + echo ' |
|
| 3921 | 4121 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3922 | 4122 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3923 | 4123 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3925,6 +4125,7 @@ discard block |
||
| 3925 | 4125 | ', $upcontext['upgrade_options_warning'], ' |
| 3926 | 4126 | </div> |
| 3927 | 4127 | </div>'; |
| 4128 | + } |
|
| 3928 | 4129 | |
| 3929 | 4130 | echo ' |
| 3930 | 4131 | <table> |
@@ -3967,8 +4168,8 @@ discard block |
||
| 3967 | 4168 | </td> |
| 3968 | 4169 | </tr>'; |
| 3969 | 4170 | |
| 3970 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3971 | - echo ' |
|
| 4171 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 4172 | + echo ' |
|
| 3972 | 4173 | <tr valign="top"> |
| 3973 | 4174 | <td width="2%"> |
| 3974 | 4175 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
@@ -3977,6 +4178,7 @@ discard block |
||
| 3977 | 4178 | <label for="delete_karma">', $txt['upgrade_delete_karma'], '</label> |
| 3978 | 4179 | </td> |
| 3979 | 4180 | </tr>'; |
| 4181 | + } |
|
| 3980 | 4182 | |
| 3981 | 4183 | echo ' |
| 3982 | 4184 | <tr valign="top"> |
@@ -4024,10 +4226,11 @@ discard block |
||
| 4024 | 4226 | </div>'; |
| 4025 | 4227 | |
| 4026 | 4228 | // Dont any tables so far? |
| 4027 | - if (!empty($upcontext['previous_tables'])) |
|
| 4028 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4229 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4230 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4029 | 4231 | echo ' |
| 4030 | 4232 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4233 | + } |
|
| 4031 | 4234 | |
| 4032 | 4235 | echo ' |
| 4033 | 4236 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -4065,12 +4268,13 @@ discard block |
||
| 4065 | 4268 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4066 | 4269 | |
| 4067 | 4270 | // If debug flood the screen. |
| 4068 | - if ($is_debug) |
|
| 4069 | - echo ' |
|
| 4271 | + if ($is_debug) { |
|
| 4272 | + echo ' |
|
| 4070 | 4273 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4071 | 4274 | |
| 4072 | 4275 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4073 | 4276 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4277 | + } |
|
| 4074 | 4278 | |
| 4075 | 4279 | echo ' |
| 4076 | 4280 | // Get the next update... |
@@ -4103,8 +4307,9 @@ discard block |
||
| 4103 | 4307 | { |
| 4104 | 4308 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt; |
| 4105 | 4309 | |
| 4106 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 4107 | - $is_debug = true; |
|
| 4310 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4311 | + $is_debug = true; |
|
| 4312 | + } |
|
| 4108 | 4313 | |
| 4109 | 4314 | echo ' |
| 4110 | 4315 | <h3>', $txt['upgrade_db_changes'], '</h3> |
@@ -4119,8 +4324,9 @@ discard block |
||
| 4119 | 4324 | { |
| 4120 | 4325 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 4121 | 4326 | { |
| 4122 | - if ($num != 0) |
|
| 4123 | - echo ' Successful!'; |
|
| 4327 | + if ($num != 0) { |
|
| 4328 | + echo ' Successful!'; |
|
| 4329 | + } |
|
| 4124 | 4330 | echo '<br>' . $item; |
| 4125 | 4331 | } |
| 4126 | 4332 | if (!empty($upcontext['changes_complete'])) |
@@ -4133,29 +4339,33 @@ discard block |
||
| 4133 | 4339 | $seconds = intval($active % 60); |
| 4134 | 4340 | |
| 4135 | 4341 | $totalTime = ''; |
| 4136 | - if ($hours > 0) |
|
| 4137 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4138 | - if ($minutes > 0) |
|
| 4139 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4140 | - if ($seconds > 0) |
|
| 4141 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4342 | + if ($hours > 0) { |
|
| 4343 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4344 | + } |
|
| 4345 | + if ($minutes > 0) { |
|
| 4346 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4347 | + } |
|
| 4348 | + if ($seconds > 0) { |
|
| 4349 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4350 | + } |
|
| 4142 | 4351 | } |
| 4143 | 4352 | |
| 4144 | - if ($is_debug && !empty($totalTime)) |
|
| 4145 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4146 | - else |
|
| 4147 | - echo ' Successful!<br><br>'; |
|
| 4353 | + if ($is_debug && !empty($totalTime)) { |
|
| 4354 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4355 | + } else { |
|
| 4356 | + echo ' Successful!<br><br>'; |
|
| 4357 | + } |
|
| 4148 | 4358 | |
| 4149 | 4359 | echo ' |
| 4150 | 4360 | <span id="commess" style="font-weight: bold;">', $txt['upgrade_db_complete'], '</span><br>'; |
| 4151 | 4361 | } |
| 4152 | - } |
|
| 4153 | - else |
|
| 4362 | + } else |
|
| 4154 | 4363 | { |
| 4155 | 4364 | // Tell them how many files we have in total. |
| 4156 | - if ($upcontext['file_count'] > 1) |
|
| 4157 | - echo ' |
|
| 4365 | + if ($upcontext['file_count'] > 1) { |
|
| 4366 | + echo ' |
|
| 4158 | 4367 | <strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4368 | + } |
|
| 4159 | 4369 | |
| 4160 | 4370 | echo ' |
| 4161 | 4371 | <h3 id="info2"><strong>', $txt['upgrade_executing'], '</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> ', $txt['upgrade_of'], ' <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -4172,20 +4382,24 @@ discard block |
||
| 4172 | 4382 | $seconds = intval($active % 60); |
| 4173 | 4383 | |
| 4174 | 4384 | $totalTime = ''; |
| 4175 | - if ($hours > 0) |
|
| 4176 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4177 | - if ($minutes > 0) |
|
| 4178 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4179 | - if ($seconds > 0) |
|
| 4180 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4385 | + if ($hours > 0) { |
|
| 4386 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4387 | + } |
|
| 4388 | + if ($minutes > 0) { |
|
| 4389 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4390 | + } |
|
| 4391 | + if ($seconds > 0) { |
|
| 4392 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4393 | + } |
|
| 4181 | 4394 | } |
| 4182 | 4395 | |
| 4183 | 4396 | echo ' |
| 4184 | 4397 | <br> |
| 4185 | 4398 | <span id="upgradeCompleted">'; |
| 4186 | 4399 | |
| 4187 | - if (!empty($totalTime)) |
|
| 4188 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4400 | + if (!empty($totalTime)) { |
|
| 4401 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4402 | + } |
|
| 4189 | 4403 | |
| 4190 | 4404 | echo ' |
| 4191 | 4405 | </span> |
@@ -4223,9 +4437,10 @@ discard block |
||
| 4223 | 4437 | var getData = ""; |
| 4224 | 4438 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4225 | 4439 | |
| 4226 | - if ($is_debug) |
|
| 4227 | - echo ' |
|
| 4440 | + if ($is_debug) { |
|
| 4441 | + echo ' |
|
| 4228 | 4442 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4443 | + } |
|
| 4229 | 4444 | |
| 4230 | 4445 | echo ' |
| 4231 | 4446 | function getNextItem() |
@@ -4265,9 +4480,10 @@ discard block |
||
| 4265 | 4480 | document.getElementById("error_block").style.display = ""; |
| 4266 | 4481 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4267 | 4482 | |
| 4268 | - if ($is_debug) |
|
| 4269 | - echo ' |
|
| 4483 | + if ($is_debug) { |
|
| 4484 | + echo ' |
|
| 4270 | 4485 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4486 | + } |
|
| 4271 | 4487 | |
| 4272 | 4488 | echo ' |
| 4273 | 4489 | } |
@@ -4288,9 +4504,10 @@ discard block |
||
| 4288 | 4504 | document.getElementById("error_block").style.display = ""; |
| 4289 | 4505 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4290 | 4506 | |
| 4291 | - if ($is_debug) |
|
| 4292 | - echo ' |
|
| 4507 | + if ($is_debug) { |
|
| 4508 | + echo ' |
|
| 4293 | 4509 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4510 | + } |
|
| 4294 | 4511 | |
| 4295 | 4512 | echo ' |
| 4296 | 4513 | } |
@@ -4349,8 +4566,8 @@ discard block |
||
| 4349 | 4566 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4350 | 4567 | {'; |
| 4351 | 4568 | |
| 4352 | - if ($is_debug) |
|
| 4353 | - echo ' |
|
| 4569 | + if ($is_debug) { |
|
| 4570 | + echo ' |
|
| 4354 | 4571 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4355 | 4572 | |
| 4356 | 4573 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4368,6 +4585,7 @@ discard block |
||
| 4368 | 4585 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4369 | 4586 | |
| 4370 | 4587 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4588 | + } |
|
| 4371 | 4589 | |
| 4372 | 4590 | echo ' |
| 4373 | 4591 | |
@@ -4375,9 +4593,10 @@ discard block |
||
| 4375 | 4593 | document.getElementById(\'contbutt\').disabled = 0; |
| 4376 | 4594 | document.getElementById(\'database_done\').value = 1;'; |
| 4377 | 4595 | |
| 4378 | - if ($upcontext['file_count'] > 1) |
|
| 4379 | - echo ' |
|
| 4596 | + if ($upcontext['file_count'] > 1) { |
|
| 4597 | + echo ' |
|
| 4380 | 4598 | document.getElementById(\'info1\').style.display = "none";'; |
| 4599 | + } |
|
| 4381 | 4600 | |
| 4382 | 4601 | echo ' |
| 4383 | 4602 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4390,9 +4609,10 @@ discard block |
||
| 4390 | 4609 | lastItem = 0; |
| 4391 | 4610 | prevFile = curFile;'; |
| 4392 | 4611 | |
| 4393 | - if ($is_debug) |
|
| 4394 | - echo ' |
|
| 4612 | + if ($is_debug) { |
|
| 4613 | + echo ' |
|
| 4395 | 4614 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4615 | + } |
|
| 4396 | 4616 | |
| 4397 | 4617 | echo ' |
| 4398 | 4618 | getNextItem(); |
@@ -4400,8 +4620,8 @@ discard block |
||
| 4400 | 4620 | }'; |
| 4401 | 4621 | |
| 4402 | 4622 | // If debug scroll the screen. |
| 4403 | - if ($is_debug) |
|
| 4404 | - echo ' |
|
| 4623 | + if ($is_debug) { |
|
| 4624 | + echo ' |
|
| 4405 | 4625 | if (iLastSubStepProgress == -1) |
| 4406 | 4626 | { |
| 4407 | 4627 | // Give it consistent dots. |
@@ -4420,6 +4640,7 @@ discard block |
||
| 4420 | 4640 | |
| 4421 | 4641 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4422 | 4642 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4643 | + } |
|
| 4423 | 4644 | |
| 4424 | 4645 | echo ' |
| 4425 | 4646 | // Update the page. |
@@ -4480,9 +4701,10 @@ discard block |
||
| 4480 | 4701 | }'; |
| 4481 | 4702 | |
| 4482 | 4703 | // Start things off assuming we've not errored. |
| 4483 | - if (empty($upcontext['error_message'])) |
|
| 4484 | - echo ' |
|
| 4704 | + if (empty($upcontext['error_message'])) { |
|
| 4705 | + echo ' |
|
| 4485 | 4706 | getNextItem();'; |
| 4707 | + } |
|
| 4486 | 4708 | |
| 4487 | 4709 | echo ' |
| 4488 | 4710 | //# sourceURL=dynamicScript-dbch.js |
@@ -4500,18 +4722,21 @@ discard block |
||
| 4500 | 4722 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4501 | 4723 | <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>'; |
| 4502 | 4724 | |
| 4503 | - if (!empty($upcontext['error_message'])) |
|
| 4504 | - echo ' |
|
| 4725 | + if (!empty($upcontext['error_message'])) { |
|
| 4726 | + echo ' |
|
| 4505 | 4727 | <error>', $upcontext['error_message'], '</error>'; |
| 4728 | + } |
|
| 4506 | 4729 | |
| 4507 | - if (!empty($upcontext['error_string'])) |
|
| 4508 | - echo ' |
|
| 4730 | + if (!empty($upcontext['error_string'])) { |
|
| 4731 | + echo ' |
|
| 4509 | 4732 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4733 | + } |
|
| 4510 | 4734 | |
| 4511 | - if ($is_debug) |
|
| 4512 | - echo ' |
|
| 4735 | + if ($is_debug) { |
|
| 4736 | + echo ' |
|
| 4513 | 4737 | <curtime>', time(), '</curtime>'; |
| 4514 | -} |
|
| 4738 | + } |
|
| 4739 | + } |
|
| 4515 | 4740 | |
| 4516 | 4741 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4517 | 4742 | function template_convert_utf8() |
@@ -4528,18 +4753,20 @@ discard block |
||
| 4528 | 4753 | </div>'; |
| 4529 | 4754 | |
| 4530 | 4755 | // Done any tables so far? |
| 4531 | - if (!empty($upcontext['previous_tables'])) |
|
| 4532 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4756 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4757 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4533 | 4758 | echo ' |
| 4534 | 4759 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4760 | + } |
|
| 4535 | 4761 | |
| 4536 | 4762 | echo ' |
| 4537 | 4763 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4538 | 4764 | |
| 4539 | 4765 | // If we dropped their index, let's let them know |
| 4540 | - if ($upcontext['dropping_index']) |
|
| 4541 | - echo ' |
|
| 4766 | + if ($upcontext['dropping_index']) { |
|
| 4767 | + echo ' |
|
| 4542 | 4768 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</span>'; |
| 4769 | + } |
|
| 4543 | 4770 | |
| 4544 | 4771 | // Completion notification |
| 4545 | 4772 | echo ' |
@@ -4576,12 +4803,13 @@ discard block |
||
| 4576 | 4803 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4577 | 4804 | |
| 4578 | 4805 | // If debug flood the screen. |
| 4579 | - if ($is_debug) |
|
| 4580 | - echo ' |
|
| 4806 | + if ($is_debug) { |
|
| 4807 | + echo ' |
|
| 4581 | 4808 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4582 | 4809 | |
| 4583 | 4810 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4584 | 4811 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4812 | + } |
|
| 4585 | 4813 | |
| 4586 | 4814 | echo ' |
| 4587 | 4815 | // Get the next update... |
@@ -4627,19 +4855,21 @@ discard block |
||
| 4627 | 4855 | </div>'; |
| 4628 | 4856 | |
| 4629 | 4857 | // Dont any tables so far? |
| 4630 | - if (!empty($upcontext['previous_tables'])) |
|
| 4631 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4858 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4859 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4632 | 4860 | echo ' |
| 4633 | 4861 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4862 | + } |
|
| 4634 | 4863 | |
| 4635 | 4864 | echo ' |
| 4636 | 4865 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4637 | 4866 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</span>'; |
| 4638 | 4867 | |
| 4639 | 4868 | // Try to make sure substep was reset. |
| 4640 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4641 | - echo ' |
|
| 4869 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4870 | + echo ' |
|
| 4642 | 4871 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4872 | + } |
|
| 4643 | 4873 | |
| 4644 | 4874 | // Continue please! |
| 4645 | 4875 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4672,12 +4902,13 @@ discard block |
||
| 4672 | 4902 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4673 | 4903 | |
| 4674 | 4904 | // If debug flood the screen. |
| 4675 | - if ($is_debug) |
|
| 4676 | - echo ' |
|
| 4905 | + if ($is_debug) { |
|
| 4906 | + echo ' |
|
| 4677 | 4907 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4678 | 4908 | |
| 4679 | 4909 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4680 | 4910 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4911 | + } |
|
| 4681 | 4912 | |
| 4682 | 4913 | echo ' |
| 4683 | 4914 | // Get the next update... |
@@ -4713,8 +4944,8 @@ discard block |
||
| 4713 | 4944 | <h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>. ', $txt['upgrade_done3'], '</h3> |
| 4714 | 4945 | <form action="', $boardurl, '/index.php">'; |
| 4715 | 4946 | |
| 4716 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4717 | - echo ' |
|
| 4947 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4948 | + echo ' |
|
| 4718 | 4949 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], '</label> <em>', $txt['upgrade_delete_server'], '</em> |
| 4719 | 4950 | <script> |
| 4720 | 4951 | function doTheDelete(theCheck) |
@@ -4725,6 +4956,7 @@ discard block |
||
| 4725 | 4956 | } |
| 4726 | 4957 | </script> |
| 4727 | 4958 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4959 | + } |
|
| 4728 | 4960 | |
| 4729 | 4961 | $active = time() - $upcontext['started']; |
| 4730 | 4962 | $hours = floor($active / 3600); |
@@ -4734,17 +4966,21 @@ discard block |
||
| 4734 | 4966 | if ($is_debug) |
| 4735 | 4967 | { |
| 4736 | 4968 | $totalTime = ''; |
| 4737 | - if ($hours > 0) |
|
| 4738 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4739 | - if ($minutes > 0) |
|
| 4740 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4741 | - if ($seconds > 0) |
|
| 4742 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4969 | + if ($hours > 0) { |
|
| 4970 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4971 | + } |
|
| 4972 | + if ($minutes > 0) { |
|
| 4973 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4974 | + } |
|
| 4975 | + if ($seconds > 0) { |
|
| 4976 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4977 | + } |
|
| 4743 | 4978 | } |
| 4744 | 4979 | |
| 4745 | - if ($is_debug && !empty($totalTime)) |
|
| 4746 | - echo ' |
|
| 4980 | + if ($is_debug && !empty($totalTime)) { |
|
| 4981 | + echo ' |
|
| 4747 | 4982 | <br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>'; |
| 4983 | + } |
|
| 4748 | 4984 | |
| 4749 | 4985 | echo '<br> |
| 4750 | 4986 | ', sprintf($txt['upgrade_problems'], 'http://simplemachines.org'), '<br> |
@@ -4771,8 +5007,9 @@ discard block |
||
| 4771 | 5007 | |
| 4772 | 5008 | $current_substep = $_GET['substep']; |
| 4773 | 5009 | |
| 4774 | - if (empty($_GET['a'])) |
|
| 4775 | - $_GET['a'] = 0; |
|
| 5010 | + if (empty($_GET['a'])) { |
|
| 5011 | + $_GET['a'] = 0; |
|
| 5012 | + } |
|
| 4776 | 5013 | $step_progress['name'] = 'Converting ips'; |
| 4777 | 5014 | $step_progress['current'] = $_GET['a']; |
| 4778 | 5015 | |
@@ -4815,16 +5052,19 @@ discard block |
||
| 4815 | 5052 | 'empty' => '', |
| 4816 | 5053 | 'limit' => $limit, |
| 4817 | 5054 | )); |
| 4818 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4819 | - $arIp[] = $row[$oldCol]; |
|
| 5055 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 5056 | + $arIp[] = $row[$oldCol]; |
|
| 5057 | + } |
|
| 4820 | 5058 | $smcFunc['db_free_result']($request); |
| 4821 | 5059 | |
| 4822 | 5060 | // Special case, null ip could keep us in a loop. |
| 4823 | - if (is_null($arIp[0])) |
|
| 4824 | - unset($arIp[0]); |
|
| 5061 | + if (is_null($arIp[0])) { |
|
| 5062 | + unset($arIp[0]); |
|
| 5063 | + } |
|
| 4825 | 5064 | |
| 4826 | - if (empty($arIp)) |
|
| 4827 | - $is_done = true; |
|
| 5065 | + if (empty($arIp)) { |
|
| 5066 | + $is_done = true; |
|
| 5067 | + } |
|
| 4828 | 5068 | |
| 4829 | 5069 | $updates = array(); |
| 4830 | 5070 | $cases = array(); |
@@ -4833,16 +5073,18 @@ discard block |
||
| 4833 | 5073 | { |
| 4834 | 5074 | $arIp[$i] = trim($arIp[$i]); |
| 4835 | 5075 | |
| 4836 | - if (empty($arIp[$i])) |
|
| 4837 | - continue; |
|
| 5076 | + if (empty($arIp[$i])) { |
|
| 5077 | + continue; |
|
| 5078 | + } |
|
| 4838 | 5079 | |
| 4839 | 5080 | $updates['ip' . $i] = $arIp[$i]; |
| 4840 | 5081 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4841 | 5082 | |
| 4842 | 5083 | if ($setSize > 0 && $i % $setSize === 0) |
| 4843 | 5084 | { |
| 4844 | - if (count($updates) == 1) |
|
| 4845 | - continue; |
|
| 5085 | + if (count($updates) == 1) { |
|
| 5086 | + continue; |
|
| 5087 | + } |
|
| 4846 | 5088 | |
| 4847 | 5089 | $updates['whereSet'] = array_values($updates); |
| 4848 | 5090 | $smcFunc['db_query']('', ' |
@@ -4876,8 +5118,7 @@ discard block |
||
| 4876 | 5118 | 'ip' => $ip |
| 4877 | 5119 | )); |
| 4878 | 5120 | } |
| 4879 | - } |
|
| 4880 | - else |
|
| 5121 | + } else |
|
| 4881 | 5122 | { |
| 4882 | 5123 | $updates['whereSet'] = array_values($updates); |
| 4883 | 5124 | $smcFunc['db_query']('', ' |
@@ -4891,9 +5132,9 @@ discard block |
||
| 4891 | 5132 | $updates |
| 4892 | 5133 | ); |
| 4893 | 5134 | } |
| 5135 | + } else { |
|
| 5136 | + $is_done = true; |
|
| 4894 | 5137 | } |
| 4895 | - else |
|
| 4896 | - $is_done = true; |
|
| 4897 | 5138 | |
| 4898 | 5139 | $_GET['a'] += $limit; |
| 4899 | 5140 | $step_progress['current'] = $_GET['a']; |
@@ -4919,11 +5160,12 @@ discard block |
||
| 4919 | 5160 | |
| 4920 | 5161 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4921 | 5162 | |
| 4922 | - if (isset($columns[$column])) |
|
| 4923 | - return $columns[$column]; |
|
| 4924 | - else |
|
| 4925 | - return null; |
|
| 4926 | -} |
|
| 5163 | + if (isset($columns[$column])) { |
|
| 5164 | + return $columns[$column]; |
|
| 5165 | + } else { |
|
| 5166 | + return null; |
|
| 5167 | + } |
|
| 5168 | + } |
|
| 4927 | 5169 | |
| 4928 | 5170 | /** |
| 4929 | 5171 | * Takes the changes to be made during the upgradeOptions step, grabs all known Settings data from Settings.php, then runs |
@@ -5197,18 +5439,20 @@ discard block |
||
| 5197 | 5439 | global $$setVar; |
| 5198 | 5440 | |
| 5199 | 5441 | // Find the setting. |
| 5200 | - if ($setType == 'string' || $setType == 'string_fatal') |
|
| 5201 | - $original[$setVar] = isset($$setVar) ? '\'' . addslashes($$setVar) . '\'' : (strpos('fatal', $setType) ? null : '\'\''); |
|
| 5202 | - elseif ($setType == 'int' || $setType == 'int_fatal') |
|
| 5203 | - $original[$setVar] = isset($$setVar) ? (int) $$setVar : (strpos('fatal', $setType) ? null : 0); |
|
| 5204 | - elseif ($setType == 'bool' || $setType == 'bool_fatal') |
|
| 5205 | - $original[$setVar] = isset($$setVar) && in_array($$setVar, array(1, true)) ? 'true' : (strpos('fatal', $setType) ? null : 'false'); |
|
| 5206 | - elseif ($setType == 'null' || $setType == 'null_fatal') |
|
| 5207 | - $original[$setVar] = isset($$setVar) && in_array($$setVar, array(1, true)) ? 'true' : (strpos('fatal', $setType) ? null : 'null'); |
|
| 5442 | + if ($setType == 'string' || $setType == 'string_fatal') { |
|
| 5443 | + $original[$setVar] = isset($$setVar) ? '\'' . addslashes($$setVar) . '\'' : (strpos('fatal', $setType) ? null : '\'\''); |
|
| 5444 | + } elseif ($setType == 'int' || $setType == 'int_fatal') { |
|
| 5445 | + $original[$setVar] = isset($$setVar) ? (int) $$setVar : (strpos('fatal', $setType) ? null : 0); |
|
| 5446 | + } elseif ($setType == 'bool' || $setType == 'bool_fatal') { |
|
| 5447 | + $original[$setVar] = isset($$setVar) && in_array($$setVar, array(1, true)) ? 'true' : (strpos('fatal', $setType) ? null : 'false'); |
|
| 5448 | + } elseif ($setType == 'null' || $setType == 'null_fatal') { |
|
| 5449 | + $original[$setVar] = isset($$setVar) && in_array($$setVar, array(1, true)) ? 'true' : (strpos('fatal', $setType) ? null : 'null'); |
|
| 5450 | + } |
|
| 5208 | 5451 | |
| 5209 | 5452 | // Well this isn't good. Do we fix it or bail? |
| 5210 | - if (is_null($original) && $setType != 'null' && strpos('fatal', $setType) > -1) |
|
| 5211 | - return throw_error('The upgrader could not copy a setting (' . $setVar . ') from your Settings file. Unable to migrate your Settings file to a new version.'); |
|
| 5453 | + if (is_null($original) && $setType != 'null' && strpos('fatal', $setType) > -1) { |
|
| 5454 | + return throw_error('The upgrader could not copy a setting (' . $setVar . ') from your Settings file. Unable to migrate your Settings file to a new version.'); |
|
| 5455 | + } |
|
| 5212 | 5456 | } |
| 5213 | 5457 | |
| 5214 | 5458 | // Finally, merge the changes with the new ones. |
@@ -5216,8 +5460,9 @@ discard block |
||
| 5216 | 5460 | foreach ($changes as $setVar => $value) |
| 5217 | 5461 | { |
| 5218 | 5462 | // Nothing needed here. |
| 5219 | - if ($setVar != 'upgradeData' && $config_vars[$setVar] == $changes[$setVar]) |
|
| 5220 | - continue; |
|
| 5463 | + if ($setVar != 'upgradeData' && $config_vars[$setVar] == $changes[$setVar]) { |
|
| 5464 | + continue; |
|
| 5465 | + } |
|
| 5221 | 5466 | |
| 5222 | 5467 | $config_vars[$setVar] = $value; |
| 5223 | 5468 | } |
@@ -5230,15 +5475,17 @@ discard block |
||
| 5230 | 5475 | $last_settings_change = filemtime($boarddir . '/Settings.php'); |
| 5231 | 5476 | |
| 5232 | 5477 | // remove any /r's that made there way in here |
| 5233 | - foreach ($settingsArray as $k => $dummy) |
|
| 5234 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 5478 | + foreach ($settingsArray as $k => $dummy) { |
|
| 5479 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 5480 | + } |
|
| 5235 | 5481 | |
| 5236 | 5482 | // go line by line and see whats changing |
| 5237 | 5483 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 5238 | 5484 | { |
| 5239 | 5485 | // Don't trim or bother with it if it's not a variable. |
| 5240 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 5241 | - continue; |
|
| 5486 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 5487 | + continue; |
|
| 5488 | + } |
|
| 5242 | 5489 | |
| 5243 | 5490 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
| 5244 | 5491 | |
@@ -5246,9 +5493,9 @@ discard block |
||
| 5246 | 5493 | foreach ($config_vars as $var => $val) |
| 5247 | 5494 | { |
| 5248 | 5495 | // be sure someone is not updating db_last_error this with a group |
| 5249 | - if ($var === 'db_last_error') |
|
| 5250 | - unset($config_vars[$var]); |
|
| 5251 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 5496 | + if ($var === 'db_last_error') { |
|
| 5497 | + unset($config_vars[$var]); |
|
| 5498 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 5252 | 5499 | { |
| 5253 | 5500 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 5254 | 5501 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -5259,34 +5506,39 @@ discard block |
||
| 5259 | 5506 | } |
| 5260 | 5507 | |
| 5261 | 5508 | // End of the file ... maybe |
| 5262 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
| 5263 | - $end = $i; |
|
| 5509 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
| 5510 | + $end = $i; |
|
| 5511 | + } |
|
| 5264 | 5512 | } |
| 5265 | 5513 | |
| 5266 | 5514 | // This should never happen, but apparently it is happening. |
| 5267 | - if (empty($end) || $end < 10) |
|
| 5268 | - $end = count($settingsArray) - 1; |
|
| 5515 | + if (empty($end) || $end < 10) { |
|
| 5516 | + $end = count($settingsArray) - 1; |
|
| 5517 | + } |
|
| 5269 | 5518 | |
| 5270 | 5519 | // Still more variables to go? Then lets add them at the end. |
| 5271 | 5520 | if (!empty($config_vars)) |
| 5272 | 5521 | { |
| 5273 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
| 5274 | - $settingsArray[$end++] = ''; |
|
| 5275 | - else |
|
| 5276 | - $end++; |
|
| 5522 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
| 5523 | + $settingsArray[$end++] = ''; |
|
| 5524 | + } else { |
|
| 5525 | + $end++; |
|
| 5526 | + } |
|
| 5277 | 5527 | |
| 5278 | 5528 | // Add in any newly defined vars that were passed |
| 5279 | - foreach ($config_vars as $var => $val) |
|
| 5280 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 5529 | + foreach ($config_vars as $var => $val) { |
|
| 5530 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 5531 | + } |
|
| 5281 | 5532 | |
| 5282 | 5533 | $settingsArray[$end] = '?' . '>'; |
| 5534 | + } else { |
|
| 5535 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 5283 | 5536 | } |
| 5284 | - else |
|
| 5285 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 5286 | 5537 | |
| 5287 | 5538 | // Sanity error checking: the file needs to be at least 12 lines. |
| 5288 | - if (count($settingsArray) < 12) |
|
| 5289 | - return throw_error('The upgrader could not process your Settings file for updates. Unable to migrate your Settings file to a new version.'); |
|
| 5539 | + if (count($settingsArray) < 12) { |
|
| 5540 | + return throw_error('The upgrader could not process your Settings file for updates. Unable to migrate your Settings file to a new version.'); |
|
| 5541 | + } |
|
| 5290 | 5542 | |
| 5291 | 5543 | // Try to avoid a few pitfalls: |
| 5292 | 5544 | // - like a possible race condition, |
@@ -5294,8 +5546,9 @@ discard block |
||
| 5294 | 5546 | // |
| 5295 | 5547 | // Check before you act: if cache is enabled, we can do a simple write test |
| 5296 | 5548 | // to validate that we even write things on this filesystem. |
| 5297 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 5298 | - $cachedir = $boarddir . '/cache'; |
|
| 5549 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 5550 | + $cachedir = $boarddir . '/cache'; |
|
| 5551 | + } |
|
| 5299 | 5552 | |
| 5300 | 5553 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
| 5301 | 5554 | if ($test_fp) |
@@ -5306,8 +5559,9 @@ discard block |
||
| 5306 | 5559 | |
| 5307 | 5560 | // Oops. Low disk space, perhaps. Don't mess with Settings.php then. |
| 5308 | 5561 | // No means no. :P |
| 5309 | - if ($written_bytes !== 4) |
|
| 5310 | - return throw_error('The upgrader could not write a test file, perhaps not enough storage? Unable to migrate your Settings file to a new version.'); |
|
| 5562 | + if ($written_bytes !== 4) { |
|
| 5563 | + return throw_error('The upgrader could not write a test file, perhaps not enough storage? Unable to migrate your Settings file to a new version.'); |
|
| 5564 | + } |
|
| 5311 | 5565 | } |
| 5312 | 5566 | |
| 5313 | 5567 | // Protect me from what I want! :P |
@@ -5325,8 +5579,9 @@ discard block |
||
| 5325 | 5579 | // survey says ... |
| 5326 | 5580 | if ($written_bytes !== strlen($write_settings) && !$settings_backup_fail) |
| 5327 | 5581 | { |
| 5328 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
| 5329 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 5582 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
| 5583 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 5584 | + } |
|
| 5330 | 5585 | |
| 5331 | 5586 | return throw_error('The upgrader detected a bad Settings file and reverted the changes. Unable to migrate your Settings file to a new version.'); |
| 5332 | 5587 | } |
@@ -5334,9 +5589,10 @@ discard block |
||
| 5334 | 5589 | |
| 5335 | 5590 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 5336 | 5591 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 5337 | - if (function_exists('opcache_invalidate')) |
|
| 5338 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 5339 | -} |
|
| 5592 | + if (function_exists('opcache_invalidate')) { |
|
| 5593 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 5594 | + } |
|
| 5595 | + } |
|
| 5340 | 5596 | |
| 5341 | 5597 | /** |
| 5342 | 5598 | * Determine if we should auto select the migrate Settings file. This is determined by a variety of missing settings. |
@@ -5353,23 +5609,27 @@ discard block |
||
| 5353 | 5609 | global $boarddir, $packagesdir, $tasksdir, $db_server, $db_type, $image_proxy_enabled, $db_show_debug; |
| 5354 | 5610 | |
| 5355 | 5611 | // We should not migrate if db_show_debug is in there, some dev stuff going on here. |
| 5356 | - if (isset($db_show_debug)) |
|
| 5357 | - return false; |
|
| 5612 | + if (isset($db_show_debug)) { |
|
| 5613 | + return false; |
|
| 5614 | + } |
|
| 5358 | 5615 | |
| 5359 | 5616 | $file_contents = file_get_contents($boarddir . '/Settings.php'); |
| 5360 | 5617 | |
| 5361 | 5618 | // Is there a include statement somewhere in there? Some advanced handling of the variables elsewhere? |
| 5362 | 5619 | // Try our best to stay away from the cachedir match. |
| 5363 | - if (preg_match('~\sinclude\((?:(?!\(isset\(\$cachedir))~im', $file_contents)) |
|
| 5364 | - return false; |
|
| 5620 | + if (preg_match('~\sinclude\((?:(?!\(isset\(\$cachedir))~im', $file_contents)) { |
|
| 5621 | + return false; |
|
| 5622 | + } |
|
| 5365 | 5623 | |
| 5366 | 5624 | // If we find a mention of $GLOBALS, there may be a integration going on. |
| 5367 | - if (preg_match('~\$GLOBALS\[~im', $file_contents)) |
|
| 5368 | - return false; |
|
| 5625 | + if (preg_match('~\$GLOBALS\[~im', $file_contents)) { |
|
| 5626 | + return false; |
|
| 5627 | + } |
|
| 5369 | 5628 | |
| 5370 | 5629 | // If these are not set, it makes us a canidate to migrate. |
| 5371 | - if (!isset($packagesdir, $tasksdir, $db_server, $db_type, $image_proxy_enabled)) |
|
| 5372 | - return true; |
|
| 5630 | + if (!isset($packagesdir, $tasksdir, $db_server, $db_type, $image_proxy_enabled)) { |
|
| 5631 | + return true; |
|
| 5632 | + } |
|
| 5373 | 5633 | |
| 5374 | 5634 | return false; |
| 5375 | 5635 | } |