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