@@ -68,11 +68,14 @@ discard block |
||
68 | 68 | ini_set('default_socket_timeout', 900); |
69 | 69 | } |
70 | 70 | // Clean the upgrade path if this is from the client. |
71 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
72 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
71 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
72 | + for ($i = 1; |
|
73 | +} |
|
74 | +$i < $_SERVER['argc']; $i++) |
|
73 | 75 | { |
74 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
75 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
76 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
77 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
78 | + } |
|
76 | 79 | } |
77 | 80 | |
78 | 81 | // Are we from the client? |
@@ -80,9 +83,9 @@ discard block |
||
80 | 83 | { |
81 | 84 | $command_line = true; |
82 | 85 | $disable_security = 1; |
83 | -} |
|
84 | -else |
|
86 | +} else { |
|
85 | 87 | $command_line = false; |
88 | +} |
|
86 | 89 | |
87 | 90 | // Load this now just because we can. |
88 | 91 | require_once($upgrade_path . '/Settings.php'); |
@@ -93,10 +96,12 @@ discard block |
||
93 | 96 | $upcontext['user'] = unserialize(base64_decode($upgradeData)); |
94 | 97 | |
95 | 98 | // Check for sensible values. |
96 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
97 | - $upcontext['user']['started'] = time(); |
|
98 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
99 | - $upcontext['user']['updated'] = 0; |
|
99 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
100 | + $upcontext['user']['started'] = time(); |
|
101 | + } |
|
102 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
103 | + $upcontext['user']['updated'] = 0; |
|
104 | + } |
|
100 | 105 | |
101 | 106 | $upcontext['started'] = $upcontext['user']['started']; |
102 | 107 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -159,8 +164,9 @@ discard block |
||
159 | 164 | { |
160 | 165 | $word = trim($word, '-_\''); |
161 | 166 | |
162 | - if ($word != '') |
|
163 | - $returned_words[] = substr($word, 0, 20); |
|
167 | + if ($word != '') { |
|
168 | + $returned_words[] = substr($word, 0, 20); |
|
169 | + } |
|
164 | 170 | } |
165 | 171 | |
166 | 172 | return array_unique($returned_words); |
@@ -187,8 +193,9 @@ discard block |
||
187 | 193 | { |
188 | 194 | function md5_hmac($data, $key) |
189 | 195 | { |
190 | - if (strlen($key) > 64) |
|
191 | - $key = pack('H*', md5($key)); |
|
196 | + if (strlen($key) > 64) { |
|
197 | + $key = pack('H*', md5($key)); |
|
198 | + } |
|
192 | 199 | $key = str_pad($key, 64, chr(0x00)); |
193 | 200 | |
194 | 201 | $k_ipad = $key ^ str_repeat(chr(0x36), 64); |
@@ -199,8 +206,9 @@ discard block |
||
199 | 206 | } |
200 | 207 | |
201 | 208 | // Don't do security check if on Yabbse |
202 | -if (!isset($modSettings['smfVersion'])) |
|
209 | +if (!isset($modSettings['smfVersion'])) { |
|
203 | 210 | $disable_security = true; |
211 | +} |
|
204 | 212 | |
205 | 213 | // This only exists if we're on SMF ;) |
206 | 214 | if (isset($modSettings['smfVersion'])) |
@@ -218,8 +226,9 @@ discard block |
||
218 | 226 | 'db_error_skip' => true, |
219 | 227 | ) |
220 | 228 | ); |
221 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
222 | - $modSettings[$row['variable']] = $row['value']; |
|
229 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
230 | + $modSettings[$row['variable']] = $row['value']; |
|
231 | + } |
|
223 | 232 | $smcFunc['db_free_result']($request); |
224 | 233 | } |
225 | 234 | |
@@ -229,10 +238,12 @@ discard block |
||
229 | 238 | $modSettings['theme_url'] = 'Themes/default'; |
230 | 239 | $modSettings['images_url'] = 'Themes/default/images'; |
231 | 240 | } |
232 | -if (!isset($settings['default_theme_url'])) |
|
241 | +if (!isset($settings['default_theme_url'])) { |
|
233 | 242 | $settings['default_theme_url'] = $modSettings['theme_url']; |
234 | -if (!isset($settings['default_theme_dir'])) |
|
243 | +} |
|
244 | +if (!isset($settings['default_theme_dir'])) { |
|
235 | 245 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
246 | +} |
|
236 | 247 | |
237 | 248 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
238 | 249 | // Default title... |
@@ -250,13 +261,15 @@ discard block |
||
250 | 261 | $support_js = $upcontext['upgrade_status']['js']; |
251 | 262 | |
252 | 263 | // Only set this if the upgrader status says so. |
253 | - if (empty($is_debug)) |
|
254 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
264 | + if (empty($is_debug)) { |
|
265 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
266 | + } |
|
255 | 267 | |
256 | 268 | // Load the language. |
257 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
258 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
259 | -} |
|
269 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
270 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
271 | + } |
|
272 | + } |
|
260 | 273 | // Set the defaults. |
261 | 274 | else |
262 | 275 | { |
@@ -274,15 +287,18 @@ discard block |
||
274 | 287 | } |
275 | 288 | |
276 | 289 | // If this isn't the first stage see whether they are logging in and resuming. |
277 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
290 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
278 | 291 | checkLogin(); |
292 | +} |
|
279 | 293 | |
280 | -if ($command_line) |
|
294 | +if ($command_line) { |
|
281 | 295 | cmdStep0(); |
296 | +} |
|
282 | 297 | |
283 | 298 | // Don't error if we're using xml. |
284 | -if (isset($_GET['xml'])) |
|
299 | +if (isset($_GET['xml'])) { |
|
285 | 300 | $upcontext['return_error'] = true; |
301 | +} |
|
286 | 302 | |
287 | 303 | // Loop through all the steps doing each one as required. |
288 | 304 | $upcontext['overall_percent'] = 0; |
@@ -303,10 +319,11 @@ discard block |
||
303 | 319 | } |
304 | 320 | |
305 | 321 | // Call the step and if it returns false that means pause! |
306 | - if (function_exists($step[2]) && $step[2]() === false) |
|
307 | - break; |
|
308 | - elseif (function_exists($step[2])) |
|
309 | - $upcontext['current_step']++; |
|
322 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
323 | + break; |
|
324 | + } elseif (function_exists($step[2])) { |
|
325 | + $upcontext['current_step']++; |
|
326 | + } |
|
310 | 327 | } |
311 | 328 | $upcontext['overall_percent'] += $step[3]; |
312 | 329 | } |
@@ -345,17 +362,18 @@ discard block |
||
345 | 362 | // This should not happen my dear... HELP ME DEVELOPERS!! |
346 | 363 | if (!empty($command_line)) |
347 | 364 | { |
348 | - if (function_exists('debug_print_backtrace')) |
|
349 | - debug_print_backtrace(); |
|
365 | + if (function_exists('debug_print_backtrace')) { |
|
366 | + debug_print_backtrace(); |
|
367 | + } |
|
350 | 368 | |
351 | 369 | 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.'; |
352 | 370 | flush(); |
353 | 371 | die(); |
354 | 372 | } |
355 | 373 | |
356 | - if (!isset($_GET['xml'])) |
|
357 | - template_upgrade_above(); |
|
358 | - else |
|
374 | + if (!isset($_GET['xml'])) { |
|
375 | + template_upgrade_above(); |
|
376 | + } else |
|
359 | 377 | { |
360 | 378 | header('Content-Type: text/xml; charset=UTF-8'); |
361 | 379 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -377,21 +395,24 @@ discard block |
||
377 | 395 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(safe_serialize($upcontext['upgrade_status'])); |
378 | 396 | |
379 | 397 | // Custom stuff to pass back? |
380 | - if (!empty($upcontext['query_string'])) |
|
381 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
398 | + if (!empty($upcontext['query_string'])) { |
|
399 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
400 | + } |
|
382 | 401 | |
383 | 402 | call_user_func('template_' . $upcontext['sub_template']); |
384 | 403 | } |
385 | 404 | |
386 | 405 | // Was there an error? |
387 | - if (!empty($upcontext['forced_error_message'])) |
|
388 | - echo $upcontext['forced_error_message']; |
|
406 | + if (!empty($upcontext['forced_error_message'])) { |
|
407 | + echo $upcontext['forced_error_message']; |
|
408 | + } |
|
389 | 409 | |
390 | 410 | // Show the footer. |
391 | - if (!isset($_GET['xml'])) |
|
392 | - template_upgrade_below(); |
|
393 | - else |
|
394 | - template_xml_below(); |
|
411 | + if (!isset($_GET['xml'])) { |
|
412 | + template_upgrade_below(); |
|
413 | + } else { |
|
414 | + template_xml_below(); |
|
415 | + } |
|
395 | 416 | } |
396 | 417 | |
397 | 418 | |
@@ -403,15 +424,19 @@ discard block |
||
403 | 424 | $seconds = intval($active % 60); |
404 | 425 | |
405 | 426 | $totalTime = ''; |
406 | - if ($hours > 0) |
|
407 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
408 | - if ($minutes > 0) |
|
409 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
410 | - if ($seconds > 0) |
|
411 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
427 | + if ($hours > 0) { |
|
428 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
429 | + } |
|
430 | + if ($minutes > 0) { |
|
431 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
432 | + } |
|
433 | + if ($seconds > 0) { |
|
434 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
435 | + } |
|
412 | 436 | |
413 | - if (!empty($totalTime)) |
|
414 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
437 | + if (!empty($totalTime)) { |
|
438 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
439 | + } |
|
415 | 440 | } |
416 | 441 | |
417 | 442 | // Bang - gone! |
@@ -424,8 +449,9 @@ discard block |
||
424 | 449 | global $upgradeurl, $upcontext, $command_line; |
425 | 450 | |
426 | 451 | // Command line users can't be redirected. |
427 | - if ($command_line) |
|
428 | - upgradeExit(true); |
|
452 | + if ($command_line) { |
|
453 | + upgradeExit(true); |
|
454 | + } |
|
429 | 455 | |
430 | 456 | // Are we providing the core info? |
431 | 457 | if ($addForm) |
@@ -448,19 +474,22 @@ discard block |
||
448 | 474 | global $modSettings, $sourcedir, $smcFunc; |
449 | 475 | |
450 | 476 | // Do the non-SSI stuff... |
451 | - if (function_exists('set_magic_quotes_runtime')) |
|
452 | - @set_magic_quotes_runtime(0); |
|
477 | + if (function_exists('set_magic_quotes_runtime')) { |
|
478 | + @set_magic_quotes_runtime(0); |
|
479 | + } |
|
453 | 480 | |
454 | 481 | error_reporting(E_ALL); |
455 | 482 | define('SMF', 1); |
456 | 483 | |
457 | 484 | // Start the session. |
458 | - if (@ini_get('session.save_handler') == 'user') |
|
459 | - @ini_set('session.save_handler', 'files'); |
|
485 | + if (@ini_get('session.save_handler') == 'user') { |
|
486 | + @ini_set('session.save_handler', 'files'); |
|
487 | + } |
|
460 | 488 | @session_start(); |
461 | 489 | |
462 | - if (empty($smcFunc)) |
|
463 | - $smcFunc = array(); |
|
490 | + if (empty($smcFunc)) { |
|
491 | + $smcFunc = array(); |
|
492 | + } |
|
464 | 493 | |
465 | 494 | // We need this for authentication and some upgrade code |
466 | 495 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -473,8 +502,9 @@ discard block |
||
473 | 502 | initialize_inputs(); |
474 | 503 | |
475 | 504 | // Get the database going! |
476 | - if (empty($db_type)) |
|
477 | - $db_type = 'mysql'; |
|
505 | + if (empty($db_type)) { |
|
506 | + $db_type = 'mysql'; |
|
507 | + } |
|
478 | 508 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
479 | 509 | { |
480 | 510 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -483,17 +513,19 @@ discard block |
||
483 | 513 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
484 | 514 | |
485 | 515 | // Oh dear god!! |
486 | - if ($db_connection === null) |
|
487 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
516 | + if ($db_connection === null) { |
|
517 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
518 | + } |
|
488 | 519 | |
489 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
490 | - $smcFunc['db_query']('', ' |
|
520 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
521 | + $smcFunc['db_query']('', ' |
|
491 | 522 | SET NAMES {string:db_character_set}', |
492 | 523 | array( |
493 | 524 | 'db_error_skip' => true, |
494 | 525 | 'db_character_set' => $db_character_set, |
495 | 526 | ) |
496 | 527 | ); |
528 | + } |
|
497 | 529 | |
498 | 530 | // Load the modSettings data... |
499 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -504,11 +536,11 @@ discard block |
||
504 | 536 | ) |
505 | 537 | ); |
506 | 538 | $modSettings = array(); |
507 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
508 | - $modSettings[$row['variable']] = $row['value']; |
|
539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
540 | + $modSettings[$row['variable']] = $row['value']; |
|
541 | + } |
|
509 | 542 | $smcFunc['db_free_result']($request); |
510 | - } |
|
511 | - else |
|
543 | + } else |
|
512 | 544 | { |
513 | 545 | 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.'); |
514 | 546 | } |
@@ -522,9 +554,10 @@ discard block |
||
522 | 554 | cleanRequest(); |
523 | 555 | } |
524 | 556 | |
525 | - if (!isset($_GET['substep'])) |
|
526 | - $_GET['substep'] = 0; |
|
527 | -} |
|
557 | + if (!isset($_GET['substep'])) { |
|
558 | + $_GET['substep'] = 0; |
|
559 | + } |
|
560 | + } |
|
528 | 561 | |
529 | 562 | function initialize_inputs() |
530 | 563 | { |
@@ -562,8 +595,9 @@ discard block |
||
562 | 595 | $dh = opendir(dirname(__FILE__)); |
563 | 596 | while ($file = readdir($dh)) |
564 | 597 | { |
565 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
566 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
598 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
599 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
600 | + } |
|
567 | 601 | } |
568 | 602 | closedir($dh); |
569 | 603 | |
@@ -593,8 +627,9 @@ discard block |
||
593 | 627 | { |
594 | 628 | $upcontext['remote_files_available'] = false; |
595 | 629 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
596 | - if ($test) |
|
597 | - $upcontext['remote_files_available'] = true; |
|
630 | + if ($test) { |
|
631 | + $upcontext['remote_files_available'] = true; |
|
632 | + } |
|
598 | 633 | @fclose($test); |
599 | 634 | } |
600 | 635 | |
@@ -602,8 +637,9 @@ discard block |
||
602 | 637 | $temp = 'upgrade_php?step'; |
603 | 638 | while (strlen($temp) > 4) |
604 | 639 | { |
605 | - if (isset($_GET[$temp])) |
|
606 | - unset($_GET[$temp]); |
|
640 | + if (isset($_GET[$temp])) { |
|
641 | + unset($_GET[$temp]); |
|
642 | + } |
|
607 | 643 | $temp = substr($temp, 1); |
608 | 644 | } |
609 | 645 | |
@@ -629,29 +665,36 @@ discard block |
||
629 | 665 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $type . '.sql'); |
630 | 666 | |
631 | 667 | // Need legacy scripts? |
632 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
633 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
634 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
635 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
636 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
637 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
668 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
669 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
670 | + } |
|
671 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
672 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
673 | + } |
|
674 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
675 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
676 | + } |
|
638 | 677 | |
639 | 678 | // This needs to exist! |
640 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
641 | - 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>]'); |
|
642 | - else |
|
643 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
679 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
680 | + 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>]'); |
|
681 | + } else { |
|
682 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
683 | + } |
|
644 | 684 | |
645 | - if (!$check) |
|
646 | - // 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. |
|
685 | + if (!$check) { |
|
686 | + // 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. |
|
647 | 687 | 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.'); |
688 | + } |
|
648 | 689 | |
649 | 690 | // Do they meet the install requirements? |
650 | - if (!php_version_check()) |
|
651 | - 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.'); |
|
691 | + if (!php_version_check()) { |
|
692 | + 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.'); |
|
693 | + } |
|
652 | 694 | |
653 | - if (!db_version_check()) |
|
654 | - 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.'); |
|
695 | + if (!db_version_check()) { |
|
696 | + 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.'); |
|
697 | + } |
|
655 | 698 | |
656 | 699 | // Do some checks to make sure they have proper privileges |
657 | 700 | db_extend('packages'); |
@@ -666,14 +709,16 @@ discard block |
||
666 | 709 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
667 | 710 | |
668 | 711 | // Sorry... we need CREATE, ALTER and DROP |
669 | - if (!$create || !$alter || !$drop) |
|
670 | - 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.'); |
|
712 | + if (!$create || !$alter || !$drop) { |
|
713 | + 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.'); |
|
714 | + } |
|
671 | 715 | |
672 | 716 | // Do a quick version spot check. |
673 | 717 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
674 | 718 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
675 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
676 | - 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.'); |
|
719 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
720 | + 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.'); |
|
721 | + } |
|
677 | 722 | |
678 | 723 | // What absolutely needs to be writable? |
679 | 724 | $writable_files = array( |
@@ -695,12 +740,13 @@ discard block |
||
695 | 740 | quickFileWritable($custom_av_dir); |
696 | 741 | |
697 | 742 | // Are we good now? |
698 | - if (!is_writable($custom_av_dir)) |
|
699 | - 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)); |
|
700 | - elseif ($need_settings_update) |
|
743 | + if (!is_writable($custom_av_dir)) { |
|
744 | + 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)); |
|
745 | + } elseif ($need_settings_update) |
|
701 | 746 | { |
702 | - if (!function_exists('cache_put_data')) |
|
703 | - require_once($sourcedir . '/Load.php'); |
|
747 | + if (!function_exists('cache_put_data')) { |
|
748 | + require_once($sourcedir . '/Load.php'); |
|
749 | + } |
|
704 | 750 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
705 | 751 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
706 | 752 | } |
@@ -709,28 +755,33 @@ discard block |
||
709 | 755 | |
710 | 756 | // Check the cache directory. |
711 | 757 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
712 | - if (!file_exists($cachedir_temp)) |
|
713 | - @mkdir($cachedir_temp); |
|
714 | - if (!file_exists($cachedir_temp)) |
|
715 | - 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.'); |
|
716 | - |
|
717 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
718 | - 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>.'); |
|
719 | - elseif (!isset($_GET['skiplang'])) |
|
758 | + if (!file_exists($cachedir_temp)) { |
|
759 | + @mkdir($cachedir_temp); |
|
760 | + } |
|
761 | + if (!file_exists($cachedir_temp)) { |
|
762 | + 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.'); |
|
763 | + } |
|
764 | + |
|
765 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
766 | + 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>.'); |
|
767 | + } elseif (!isset($_GET['skiplang'])) |
|
720 | 768 | { |
721 | 769 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
722 | 770 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
723 | 771 | |
724 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
725 | - 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>]'); |
|
772 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
773 | + 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>]'); |
|
774 | + } |
|
726 | 775 | } |
727 | 776 | |
728 | - if (!makeFilesWritable($writable_files)) |
|
729 | - return false; |
|
777 | + if (!makeFilesWritable($writable_files)) { |
|
778 | + return false; |
|
779 | + } |
|
730 | 780 | |
731 | 781 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
732 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
733 | - 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.'); |
|
782 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
783 | + 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.'); |
|
784 | + } |
|
734 | 785 | |
735 | 786 | // Upgrade the agreement. |
736 | 787 | elseif (isset($modSettings['agreement'])) |
@@ -741,8 +792,8 @@ discard block |
||
741 | 792 | } |
742 | 793 | |
743 | 794 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
744 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
745 | - $upcontext['warning'] = ' |
|
795 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
796 | + $upcontext['warning'] = ' |
|
746 | 797 | 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> |
747 | 798 | <ul> |
748 | 799 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -750,10 +801,12 @@ discard block |
||
750 | 801 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
751 | 802 | </ul> |
752 | 803 | 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.'; |
804 | + } |
|
753 | 805 | |
754 | 806 | // Either we're logged in or we're going to present the login. |
755 | - if (checkLogin()) |
|
756 | - return true; |
|
807 | + if (checkLogin()) { |
|
808 | + return true; |
|
809 | + } |
|
757 | 810 | |
758 | 811 | $upcontext += createToken('login'); |
759 | 812 | |
@@ -770,8 +823,9 @@ discard block |
||
770 | 823 | if (isset($_POST['contbutt']) && (!empty($_POST['user']) || $disable_security)) |
771 | 824 | { |
772 | 825 | // If we've disabled security pick a suitable name! |
773 | - if (empty($_POST['user'])) |
|
774 | - $_POST['user'] = 'Administrator'; |
|
826 | + if (empty($_POST['user'])) { |
|
827 | + $_POST['user'] = 'Administrator'; |
|
828 | + } |
|
775 | 829 | |
776 | 830 | // Before 2.0 these column names were different! |
777 | 831 | $oldDB = false; |
@@ -786,16 +840,17 @@ discard block |
||
786 | 840 | 'db_error_skip' => true, |
787 | 841 | ) |
788 | 842 | ); |
789 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
790 | - $oldDB = true; |
|
843 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
844 | + $oldDB = true; |
|
845 | + } |
|
791 | 846 | $smcFunc['db_free_result']($request); |
792 | 847 | } |
793 | 848 | |
794 | 849 | // Get what we believe to be their details. |
795 | 850 | if (!$disable_security) |
796 | 851 | { |
797 | - if ($oldDB) |
|
798 | - $request = $smcFunc['db_query']('', ' |
|
852 | + if ($oldDB) { |
|
853 | + $request = $smcFunc['db_query']('', ' |
|
799 | 854 | SELECT id_member, memberName AS member_name, passwd, id_group, |
800 | 855 | additionalGroups AS additional_groups, lngfile |
801 | 856 | FROM {db_prefix}members |
@@ -805,8 +860,8 @@ discard block |
||
805 | 860 | 'db_error_skip' => true, |
806 | 861 | ) |
807 | 862 | ); |
808 | - else |
|
809 | - $request = $smcFunc['db_query']('', ' |
|
863 | + } else { |
|
864 | + $request = $smcFunc['db_query']('', ' |
|
810 | 865 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
811 | 866 | FROM {db_prefix}members |
812 | 867 | WHERE member_name = {string:member_name}', |
@@ -815,6 +870,7 @@ discard block |
||
815 | 870 | 'db_error_skip' => true, |
816 | 871 | ) |
817 | 872 | ); |
873 | + } |
|
818 | 874 | if ($smcFunc['db_num_rows']($request) != 0) |
819 | 875 | { |
820 | 876 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -822,13 +878,14 @@ discard block |
||
822 | 878 | $groups = explode(',', $addGroups); |
823 | 879 | $groups[] = $id_group; |
824 | 880 | |
825 | - foreach ($groups as $k => $v) |
|
826 | - $groups[$k] = (int) $v; |
|
881 | + foreach ($groups as $k => $v) { |
|
882 | + $groups[$k] = (int) $v; |
|
883 | + } |
|
827 | 884 | |
828 | 885 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
886 | + } else { |
|
887 | + $upcontext['username_incorrect'] = true; |
|
829 | 888 | } |
830 | - else |
|
831 | - $upcontext['username_incorrect'] = true; |
|
832 | 889 | $smcFunc['db_free_result']($request); |
833 | 890 | } |
834 | 891 | $upcontext['username'] = $_POST['user']; |
@@ -838,13 +895,14 @@ discard block |
||
838 | 895 | { |
839 | 896 | $upcontext['upgrade_status']['js'] = 1; |
840 | 897 | $support_js = 1; |
898 | + } else { |
|
899 | + $support_js = 0; |
|
841 | 900 | } |
842 | - else |
|
843 | - $support_js = 0; |
|
844 | 901 | |
845 | 902 | // Note down the version we are coming from. |
846 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
847 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
903 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
904 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
905 | + } |
|
848 | 906 | |
849 | 907 | // Didn't get anywhere? |
850 | 908 | 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'])) |
@@ -878,15 +936,15 @@ discard block |
||
878 | 936 | 'db_error_skip' => true, |
879 | 937 | ) |
880 | 938 | ); |
881 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
882 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
939 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
940 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
941 | + } |
|
883 | 942 | $smcFunc['db_free_result']($request); |
884 | 943 | } |
885 | 944 | |
886 | 945 | $upcontext['user']['id'] = $id_member; |
887 | 946 | $upcontext['user']['name'] = $name; |
888 | - } |
|
889 | - else |
|
947 | + } else |
|
890 | 948 | { |
891 | 949 | $upcontext['user']['id'] = 1; |
892 | 950 | $upcontext['user']['name'] = 'Administrator'; |
@@ -902,11 +960,11 @@ discard block |
||
902 | 960 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
903 | 961 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
904 | 962 | |
905 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
906 | - $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'] . '.'; |
|
907 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
908 | - $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'] . '.'; |
|
909 | - else |
|
963 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
964 | + $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'] . '.'; |
|
965 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
966 | + $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'] . '.'; |
|
967 | + } else |
|
910 | 968 | { |
911 | 969 | // Set this as the new language. |
912 | 970 | $upcontext['language'] = $user_language; |
@@ -950,8 +1008,9 @@ discard block |
||
950 | 1008 | unset($member_columns); |
951 | 1009 | |
952 | 1010 | // If we've not submitted then we're done. |
953 | - if (empty($_POST['upcont'])) |
|
954 | - return false; |
|
1011 | + if (empty($_POST['upcont'])) { |
|
1012 | + return false; |
|
1013 | + } |
|
955 | 1014 | |
956 | 1015 | require_once($sourcedir . '/Subs-Admin.php'); |
957 | 1016 | updateSettingsFile(array('image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'')); |
@@ -969,25 +1028,26 @@ discard block |
||
969 | 1028 | fwrite($fp, $out); |
970 | 1029 | |
971 | 1030 | $return_data = ''; |
972 | - while (!feof($fp)) |
|
973 | - $return_data .= fgets($fp, 128); |
|
1031 | + while (!feof($fp)) { |
|
1032 | + $return_data .= fgets($fp, 128); |
|
1033 | + } |
|
974 | 1034 | |
975 | 1035 | fclose($fp); |
976 | 1036 | |
977 | 1037 | // Get the unique site ID. |
978 | 1038 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
979 | 1039 | |
980 | - if (!empty($ID[1])) |
|
981 | - $smcFunc['db_insert']('replace', |
|
1040 | + if (!empty($ID[1])) { |
|
1041 | + $smcFunc['db_insert']('replace', |
|
982 | 1042 | $db_prefix . 'settings', |
983 | 1043 | array('variable' => 'string', 'value' => 'string'), |
984 | 1044 | array('allow_sm_stats', $ID[1]), |
985 | 1045 | array('variable') |
986 | 1046 | ); |
1047 | + } |
|
987 | 1048 | } |
988 | - } |
|
989 | - else |
|
990 | - $smcFunc['db_query']('', ' |
|
1049 | + } else { |
|
1050 | + $smcFunc['db_query']('', ' |
|
991 | 1051 | DELETE FROM {db_prefix}settings |
992 | 1052 | WHERE variable = {string:allow_sm_stats}', |
993 | 1053 | array( |
@@ -995,6 +1055,7 @@ discard block |
||
995 | 1055 | 'db_error_skip' => true, |
996 | 1056 | ) |
997 | 1057 | ); |
1058 | + } |
|
998 | 1059 | |
999 | 1060 | // Deleting old karma stuff? |
1000 | 1061 | if (!empty($_POST['delete_karma'])) |
@@ -1009,20 +1070,22 @@ discard block |
||
1009 | 1070 | ); |
1010 | 1071 | |
1011 | 1072 | // Cleaning up old karma member settings. |
1012 | - if ($upcontext['karma_installed']['good']) |
|
1013 | - $smcFunc['db_query']('', ' |
|
1073 | + if ($upcontext['karma_installed']['good']) { |
|
1074 | + $smcFunc['db_query']('', ' |
|
1014 | 1075 | ALTER TABLE {db_prefix}members |
1015 | 1076 | DROP karma_good', |
1016 | 1077 | array() |
1017 | 1078 | ); |
1079 | + } |
|
1018 | 1080 | |
1019 | 1081 | // Does karma bad was enable? |
1020 | - if ($upcontext['karma_installed']['bad']) |
|
1021 | - $smcFunc['db_query']('', ' |
|
1082 | + if ($upcontext['karma_installed']['bad']) { |
|
1083 | + $smcFunc['db_query']('', ' |
|
1022 | 1084 | ALTER TABLE {db_prefix}members |
1023 | 1085 | DROP karma_bad', |
1024 | 1086 | array() |
1025 | 1087 | ); |
1088 | + } |
|
1026 | 1089 | |
1027 | 1090 | // Cleaning up old karma permissions. |
1028 | 1091 | $smcFunc['db_query']('', ' |
@@ -1035,18 +1098,20 @@ discard block |
||
1035 | 1098 | } |
1036 | 1099 | |
1037 | 1100 | // Emptying the error log? |
1038 | - if (!empty($_POST['empty_error'])) |
|
1039 | - $smcFunc['db_query']('truncate_table', ' |
|
1101 | + if (!empty($_POST['empty_error'])) { |
|
1102 | + $smcFunc['db_query']('truncate_table', ' |
|
1040 | 1103 | TRUNCATE {db_prefix}log_errors', |
1041 | 1104 | array( |
1042 | 1105 | ) |
1043 | 1106 | ); |
1107 | + } |
|
1044 | 1108 | |
1045 | 1109 | $changes = array(); |
1046 | 1110 | |
1047 | 1111 | // If we're overriding the language follow it through. |
1048 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
1049 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1112 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
1113 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1114 | + } |
|
1050 | 1115 | |
1051 | 1116 | if (!empty($_POST['maint'])) |
1052 | 1117 | { |
@@ -1058,37 +1123,42 @@ discard block |
||
1058 | 1123 | { |
1059 | 1124 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
1060 | 1125 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
1061 | - } |
|
1062 | - else |
|
1126 | + } else |
|
1063 | 1127 | { |
1064 | 1128 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
1065 | 1129 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
1066 | 1130 | } |
1067 | 1131 | } |
1068 | 1132 | |
1069 | - if ($command_line) |
|
1070 | - echo ' * Updating Settings.php...'; |
|
1133 | + if ($command_line) { |
|
1134 | + echo ' * Updating Settings.php...'; |
|
1135 | + } |
|
1071 | 1136 | |
1072 | 1137 | // Backup the current one first. |
1073 | 1138 | copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
1074 | 1139 | |
1075 | 1140 | // Fix some old paths. |
1076 | - if (substr($boarddir, 0, 1) == '.') |
|
1077 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1141 | + if (substr($boarddir, 0, 1) == '.') { |
|
1142 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1143 | + } |
|
1078 | 1144 | |
1079 | - if (substr($sourcedir, 0, 1) == '.') |
|
1080 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1145 | + if (substr($sourcedir, 0, 1) == '.') { |
|
1146 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1147 | + } |
|
1081 | 1148 | |
1082 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
1083 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1149 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
1150 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1151 | + } |
|
1084 | 1152 | |
1085 | 1153 | // Not had the database type added before? |
1086 | - if (empty($db_type)) |
|
1087 | - $changes['db_type'] = 'mysql'; |
|
1154 | + if (empty($db_type)) { |
|
1155 | + $changes['db_type'] = 'mysql'; |
|
1156 | + } |
|
1088 | 1157 | |
1089 | 1158 | // For now we offer a option, this may change in future versions when mysql is completely removed. |
1090 | - if (!empty($_POST['convertMysql']) && $db_type == 'mysql') |
|
1091 | - $changes['db_type'] = '\'mysqli\''; |
|
1159 | + if (!empty($_POST['convertMysql']) && $db_type == 'mysql') { |
|
1160 | + $changes['db_type'] = '\'mysqli\''; |
|
1161 | + } |
|
1092 | 1162 | |
1093 | 1163 | // If they have a "host:port" setup for the host, split that into separate values |
1094 | 1164 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1099,28 +1169,31 @@ discard block |
||
1099 | 1169 | $changes['db_server'] = '\'' . $db_server . '\''; |
1100 | 1170 | |
1101 | 1171 | // Only set this if we're not using the default port |
1102 | - if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) |
|
1103 | - $changes['db_port'] = (int) $db_port; |
|
1104 | - } |
|
1105 | - elseif (!empty($db_port)) |
|
1172 | + if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) { |
|
1173 | + $changes['db_port'] = (int) $db_port; |
|
1174 | + } |
|
1175 | + } elseif (!empty($db_port)) |
|
1106 | 1176 | { |
1107 | 1177 | // If db_port is set and is the same as the default, set it to '' |
1108 | 1178 | if ($db_type == 'mysql' || $db_type == 'mysqli') |
1109 | 1179 | { |
1110 | - if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) |
|
1111 | - $changes['db_port'] = '\'\''; |
|
1112 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
1113 | - $changes['db_port'] = '\'\''; |
|
1180 | + if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) { |
|
1181 | + $changes['db_port'] = '\'\''; |
|
1182 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
1183 | + $changes['db_port'] = '\'\''; |
|
1184 | + } |
|
1114 | 1185 | } |
1115 | 1186 | } |
1116 | 1187 | |
1117 | 1188 | // Maybe we haven't had this option yet? |
1118 | - if (empty($packagesdir)) |
|
1119 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1189 | + if (empty($packagesdir)) { |
|
1190 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1191 | + } |
|
1120 | 1192 | |
1121 | 1193 | // Add support for $tasksdir var. |
1122 | - if (empty($tasksdir)) |
|
1123 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1194 | + if (empty($tasksdir)) { |
|
1195 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1196 | + } |
|
1124 | 1197 | |
1125 | 1198 | // @todo Maybe change the cookie name if going to 1.1, too? |
1126 | 1199 | |
@@ -1165,8 +1238,7 @@ discard block |
||
1165 | 1238 | $found_old = true; |
1166 | 1239 | // Replace the old line with the new code |
1167 | 1240 | $settings_file = str_replace('$db_last_error = ' . $db_last_error . ';', $error_catching_header . $error_catching, $settings_file); |
1168 | - } |
|
1169 | - else |
|
1241 | + } else |
|
1170 | 1242 | { |
1171 | 1243 | $found_old = false; |
1172 | 1244 | // We want the comments as well as the code... |
@@ -1197,8 +1269,9 @@ discard block |
||
1197 | 1269 | fclose($file); |
1198 | 1270 | } |
1199 | 1271 | |
1200 | - if ($command_line) |
|
1201 | - echo ' Successful.' . "\n"; |
|
1272 | + if ($command_line) { |
|
1273 | + echo ' Successful.' . "\n"; |
|
1274 | + } |
|
1202 | 1275 | |
1203 | 1276 | // Are we doing debug? |
1204 | 1277 | if (isset($_POST['debug'])) |
@@ -1208,8 +1281,9 @@ discard block |
||
1208 | 1281 | } |
1209 | 1282 | |
1210 | 1283 | // If we're not backing up then jump one. |
1211 | - if (empty($_POST['backup'])) |
|
1212 | - $upcontext['current_step']++; |
|
1284 | + if (empty($_POST['backup'])) { |
|
1285 | + $upcontext['current_step']++; |
|
1286 | + } |
|
1213 | 1287 | |
1214 | 1288 | // If we've got here then let's proceed to the next step! |
1215 | 1289 | return true; |
@@ -1224,8 +1298,9 @@ discard block |
||
1224 | 1298 | $upcontext['page_title'] = 'Backup Database'; |
1225 | 1299 | |
1226 | 1300 | // Done it already - js wise? |
1227 | - if (!empty($_POST['backup_done'])) |
|
1228 | - return true; |
|
1301 | + if (!empty($_POST['backup_done'])) { |
|
1302 | + return true; |
|
1303 | + } |
|
1229 | 1304 | |
1230 | 1305 | // Some useful stuff here. |
1231 | 1306 | db_extend(); |
@@ -1239,9 +1314,10 @@ discard block |
||
1239 | 1314 | $tables = $smcFunc['db_list_tables']($db, $filter); |
1240 | 1315 | |
1241 | 1316 | $table_names = array(); |
1242 | - foreach ($tables as $table) |
|
1243 | - if (substr($table, 0, 7) !== 'backup_') |
|
1317 | + foreach ($tables as $table) { |
|
1318 | + if (substr($table, 0, 7) !== 'backup_') |
|
1244 | 1319 | $table_names[] = $table; |
1320 | + } |
|
1245 | 1321 | |
1246 | 1322 | $upcontext['table_count'] = count($table_names); |
1247 | 1323 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1251,12 +1327,14 @@ discard block |
||
1251 | 1327 | $file_steps = $upcontext['table_count']; |
1252 | 1328 | |
1253 | 1329 | // What ones have we already done? |
1254 | - foreach ($table_names as $id => $table) |
|
1255 | - if ($id < $_GET['substep']) |
|
1330 | + foreach ($table_names as $id => $table) { |
|
1331 | + if ($id < $_GET['substep']) |
|
1256 | 1332 | $upcontext['previous_tables'][] = $table; |
1333 | + } |
|
1257 | 1334 | |
1258 | - if ($command_line) |
|
1259 | - echo 'Backing Up Tables.'; |
|
1335 | + if ($command_line) { |
|
1336 | + echo 'Backing Up Tables.'; |
|
1337 | + } |
|
1260 | 1338 | |
1261 | 1339 | // If we don't support javascript we backup here. |
1262 | 1340 | if (!$support_js || isset($_GET['xml'])) |
@@ -1275,8 +1353,9 @@ discard block |
||
1275 | 1353 | backupTable($table_names[$substep]); |
1276 | 1354 | |
1277 | 1355 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1278 | - if (isset($_GET['xml'])) |
|
1279 | - return upgradeExit(); |
|
1356 | + if (isset($_GET['xml'])) { |
|
1357 | + return upgradeExit(); |
|
1358 | + } |
|
1280 | 1359 | } |
1281 | 1360 | |
1282 | 1361 | if ($command_line) |
@@ -1309,9 +1388,10 @@ discard block |
||
1309 | 1388 | |
1310 | 1389 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
1311 | 1390 | |
1312 | - if ($command_line) |
|
1313 | - echo ' done.'; |
|
1314 | -} |
|
1391 | + if ($command_line) { |
|
1392 | + echo ' done.'; |
|
1393 | + } |
|
1394 | + } |
|
1315 | 1395 | |
1316 | 1396 | // Step 2: Everything. |
1317 | 1397 | function DatabaseChanges() |
@@ -1320,8 +1400,9 @@ discard block |
||
1320 | 1400 | global $upcontext, $support_js, $db_type; |
1321 | 1401 | |
1322 | 1402 | // Have we just completed this? |
1323 | - if (!empty($_POST['database_done'])) |
|
1324 | - return true; |
|
1403 | + if (!empty($_POST['database_done'])) { |
|
1404 | + return true; |
|
1405 | + } |
|
1325 | 1406 | |
1326 | 1407 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
1327 | 1408 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1338,15 +1419,16 @@ discard block |
||
1338 | 1419 | ); |
1339 | 1420 | |
1340 | 1421 | // How many files are there in total? |
1341 | - if (isset($_GET['filecount'])) |
|
1342 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1343 | - else |
|
1422 | + if (isset($_GET['filecount'])) { |
|
1423 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1424 | + } else |
|
1344 | 1425 | { |
1345 | 1426 | $upcontext['file_count'] = 0; |
1346 | 1427 | foreach ($files as $file) |
1347 | 1428 | { |
1348 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
1349 | - $upcontext['file_count']++; |
|
1429 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
1430 | + $upcontext['file_count']++; |
|
1431 | + } |
|
1350 | 1432 | } |
1351 | 1433 | } |
1352 | 1434 | |
@@ -1356,9 +1438,9 @@ discard block |
||
1356 | 1438 | $upcontext['cur_file_num'] = 0; |
1357 | 1439 | foreach ($files as $file) |
1358 | 1440 | { |
1359 | - if ($did_not_do) |
|
1360 | - $did_not_do--; |
|
1361 | - else |
|
1441 | + if ($did_not_do) { |
|
1442 | + $did_not_do--; |
|
1443 | + } else |
|
1362 | 1444 | { |
1363 | 1445 | $upcontext['cur_file_num']++; |
1364 | 1446 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1385,12 +1467,13 @@ discard block |
||
1385 | 1467 | // Flag to move on to the next. |
1386 | 1468 | $upcontext['completed_step'] = true; |
1387 | 1469 | // Did we complete the whole file? |
1388 | - if ($nextFile) |
|
1389 | - $upcontext['current_debug_item_num'] = -1; |
|
1470 | + if ($nextFile) { |
|
1471 | + $upcontext['current_debug_item_num'] = -1; |
|
1472 | + } |
|
1390 | 1473 | return upgradeExit(); |
1474 | + } elseif ($support_js) { |
|
1475 | + break; |
|
1391 | 1476 | } |
1392 | - elseif ($support_js) |
|
1393 | - break; |
|
1394 | 1477 | } |
1395 | 1478 | // Set the progress bar to be right as if we had - even if we hadn't... |
1396 | 1479 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1414,8 +1497,9 @@ discard block |
||
1414 | 1497 | global $db_prefix, $upcontext, $boarddir, $packagesdir, $settings, $smcFunc, $command_line; |
1415 | 1498 | |
1416 | 1499 | // Sorry. Not supported for command line users. |
1417 | - if ($command_line) |
|
1418 | - return true; |
|
1500 | + if ($command_line) { |
|
1501 | + return true; |
|
1502 | + } |
|
1419 | 1503 | |
1420 | 1504 | // Skipping first? |
1421 | 1505 | if (!empty($_POST['skip'])) |
@@ -1425,8 +1509,9 @@ discard block |
||
1425 | 1509 | } |
1426 | 1510 | |
1427 | 1511 | // If we get here withOUT SSI we need to redirect to ensure we get it! |
1428 | - if (!isset($_GET['ssi']) || !function_exists('mktree')) |
|
1429 | - redirectLocation('&ssi=1'); |
|
1512 | + if (!isset($_GET['ssi']) || !function_exists('mktree')) { |
|
1513 | + redirectLocation('&ssi=1'); |
|
1514 | + } |
|
1430 | 1515 | |
1431 | 1516 | $upcontext['sub_template'] = 'clean_mods'; |
1432 | 1517 | $upcontext['page_title'] = 'Cleanup Modifications'; |
@@ -1435,8 +1520,9 @@ discard block |
||
1435 | 1520 | $upcontext['skip'] = true; |
1436 | 1521 | |
1437 | 1522 | // If we're on the second redirect continue... |
1438 | - if (isset($_POST['cleandone2'])) |
|
1439 | - return true; |
|
1523 | + if (isset($_POST['cleandone2'])) { |
|
1524 | + return true; |
|
1525 | + } |
|
1440 | 1526 | |
1441 | 1527 | // Do we already know about some writable files? |
1442 | 1528 | if (isset($_POST['writable_files'])) |
@@ -1451,8 +1537,9 @@ discard block |
||
1451 | 1537 | } |
1452 | 1538 | |
1453 | 1539 | // Make sure we have some sort of packages directory. |
1454 | - if (!isset($packagesdir)) |
|
1455 | - $packagesdir = $boarddir . '/Packages'; |
|
1540 | + if (!isset($packagesdir)) { |
|
1541 | + $packagesdir = $boarddir . '/Packages'; |
|
1542 | + } |
|
1456 | 1543 | |
1457 | 1544 | // Load all theme paths.... |
1458 | 1545 | $request = $smcFunc['db_query']('', ' |
@@ -1470,10 +1557,11 @@ discard block |
||
1470 | 1557 | $theme_paths = array(); |
1471 | 1558 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1472 | 1559 | { |
1473 | - if ($row['id_theme'] == 1) |
|
1474 | - $settings['default_' . $row['variable']] = $row['value']; |
|
1475 | - elseif ($row['variable'] == 'theme_dir') |
|
1476 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
1560 | + if ($row['id_theme'] == 1) { |
|
1561 | + $settings['default_' . $row['variable']] = $row['value']; |
|
1562 | + } elseif ($row['variable'] == 'theme_dir') { |
|
1563 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
1564 | + } |
|
1477 | 1565 | } |
1478 | 1566 | $smcFunc['db_free_result']($request); |
1479 | 1567 | |
@@ -1497,8 +1585,7 @@ discard block |
||
1497 | 1585 | $status = 'Missing'; |
1498 | 1586 | $status_color = 'red'; |
1499 | 1587 | $result = 'Removed'; |
1500 | - } |
|
1501 | - else |
|
1588 | + } else |
|
1502 | 1589 | { |
1503 | 1590 | $status = 'Installed'; |
1504 | 1591 | $status_color = 'green'; |
@@ -1523,12 +1610,14 @@ discard block |
||
1523 | 1610 | $smcFunc['db_free_result']($request); |
1524 | 1611 | |
1525 | 1612 | // Don't carry on if there are none. |
1526 | - if (empty($upcontext['packages'])) |
|
1527 | - return true; |
|
1613 | + if (empty($upcontext['packages'])) { |
|
1614 | + return true; |
|
1615 | + } |
|
1528 | 1616 | |
1529 | 1617 | // Setup some basics. |
1530 | - if (!empty($upcontext['user']['version'])) |
|
1531 | - $_SESSION['version_emulate'] = $upcontext['user']['version']; |
|
1618 | + if (!empty($upcontext['user']['version'])) { |
|
1619 | + $_SESSION['version_emulate'] = $upcontext['user']['version']; |
|
1620 | + } |
|
1532 | 1621 | |
1533 | 1622 | // Before we get started, don't report notice errors. |
1534 | 1623 | $oldErrorReporting = error_reporting(E_ALL ^ E_NOTICE); |
@@ -1551,34 +1640,40 @@ discard block |
||
1551 | 1640 | foreach ($upcontext['packages'] as $id => $package) |
1552 | 1641 | { |
1553 | 1642 | // Can't do anything about this.... |
1554 | - if ($package['missing_file']) |
|
1555 | - continue; |
|
1643 | + if ($package['missing_file']) { |
|
1644 | + continue; |
|
1645 | + } |
|
1556 | 1646 | |
1557 | 1647 | // Not testing *and* this wasn't checked? |
1558 | - if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id]))) |
|
1559 | - continue; |
|
1648 | + if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id]))) { |
|
1649 | + continue; |
|
1650 | + } |
|
1560 | 1651 | |
1561 | 1652 | // What are the themes this was installed into? |
1562 | 1653 | $cur_theme_paths = array(); |
1563 | - foreach ($theme_paths as $tid => $data) |
|
1564 | - if ($tid != 1 && in_array($tid, $package['themes'])) |
|
1654 | + foreach ($theme_paths as $tid => $data) { |
|
1655 | + if ($tid != 1 && in_array($tid, $package['themes'])) |
|
1565 | 1656 | $cur_theme_paths[$tid] = $data; |
1657 | + } |
|
1566 | 1658 | |
1567 | 1659 | // Get the modifications data if applicable. |
1568 | 1660 | $filename = $package['filename']; |
1569 | 1661 | $packageInfo = getPackageInfo($filename); |
1570 | - if (!is_array($packageInfo)) |
|
1571 | - continue; |
|
1662 | + if (!is_array($packageInfo)) { |
|
1663 | + continue; |
|
1664 | + } |
|
1572 | 1665 | |
1573 | 1666 | $info = parsePackageInfo($packageInfo['xml'], $test, 'uninstall'); |
1574 | 1667 | // Also get the reinstall details... |
1575 | - if (isset($_POST['remove'])) |
|
1576 | - $infoInstall = parsePackageInfo($packageInfo['xml'], true); |
|
1668 | + if (isset($_POST['remove'])) { |
|
1669 | + $infoInstall = parsePackageInfo($packageInfo['xml'], true); |
|
1670 | + } |
|
1577 | 1671 | |
1578 | - if (is_file($packagesdir . '/' . $filename)) |
|
1579 | - read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1580 | - else |
|
1581 | - copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1672 | + if (is_file($packagesdir . '/' . $filename)) { |
|
1673 | + read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1674 | + } else { |
|
1675 | + copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1676 | + } |
|
1582 | 1677 | |
1583 | 1678 | // Work out how we uninstall... |
1584 | 1679 | $files = array(); |
@@ -1590,16 +1685,18 @@ discard block |
||
1590 | 1685 | if ($change['type'] == 'modification') |
1591 | 1686 | { |
1592 | 1687 | $contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']); |
1593 | - if ($change['boardmod']) |
|
1594 | - $results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths); |
|
1595 | - else |
|
1596 | - $results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths); |
|
1688 | + if ($change['boardmod']) { |
|
1689 | + $results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths); |
|
1690 | + } else { |
|
1691 | + $results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths); |
|
1692 | + } |
|
1597 | 1693 | |
1598 | 1694 | foreach ($results as $action) |
1599 | 1695 | { |
1600 | 1696 | // Something we can remove? Probably means it existed! |
1601 | - if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files)) |
|
1602 | - $files[] = $action['filename']; |
|
1697 | + if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files)) { |
|
1698 | + $files[] = $action['filename']; |
|
1699 | + } |
|
1603 | 1700 | if ($action['type'] == 'failure') |
1604 | 1701 | { |
1605 | 1702 | $upcontext['packages'][$id]['needs_removing'] = true; |
@@ -1615,17 +1712,19 @@ discard block |
||
1615 | 1712 | $upcontext['packages'][$id]['file_count'] = count($files); |
1616 | 1713 | |
1617 | 1714 | // If we've done something save the changes! |
1618 | - if (!$test) |
|
1619 | - package_flush_cache(); |
|
1715 | + if (!$test) { |
|
1716 | + package_flush_cache(); |
|
1717 | + } |
|
1620 | 1718 | |
1621 | 1719 | // Are we attempting to reinstall this thing? |
1622 | 1720 | if (isset($_POST['remove']) && !$test && isset($infoInstall)) |
1623 | 1721 | { |
1624 | 1722 | // Need to extract again I'm afraid. |
1625 | - if (is_file($packagesdir . '/' . $filename)) |
|
1626 | - read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1627 | - else |
|
1628 | - copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1723 | + if (is_file($packagesdir . '/' . $filename)) { |
|
1724 | + read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1725 | + } else { |
|
1726 | + copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
1727 | + } |
|
1629 | 1728 | |
1630 | 1729 | $errors = false; |
1631 | 1730 | $upcontext['packages'][$id]['result'] = 'Removed'; |
@@ -1634,15 +1733,17 @@ discard block |
||
1634 | 1733 | if ($change['type'] == 'modification') |
1635 | 1734 | { |
1636 | 1735 | $contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']); |
1637 | - if ($change['boardmod']) |
|
1638 | - $results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths); |
|
1639 | - else |
|
1640 | - $results = parseModification($contents, true, $change['reverse'], $cur_theme_paths); |
|
1736 | + if ($change['boardmod']) { |
|
1737 | + $results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths); |
|
1738 | + } else { |
|
1739 | + $results = parseModification($contents, true, $change['reverse'], $cur_theme_paths); |
|
1740 | + } |
|
1641 | 1741 | |
1642 | 1742 | // Are there any errors? |
1643 | - foreach ($results as $action) |
|
1644 | - if ($action['type'] == 'failure') |
|
1743 | + foreach ($results as $action) { |
|
1744 | + if ($action['type'] == 'failure') |
|
1645 | 1745 | $errors = true; |
1746 | + } |
|
1646 | 1747 | } |
1647 | 1748 | } |
1648 | 1749 | if (!$errors) |
@@ -1655,10 +1756,11 @@ discard block |
||
1655 | 1756 | if ($change['type'] == 'modification') |
1656 | 1757 | { |
1657 | 1758 | $contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']); |
1658 | - if ($change['boardmod']) |
|
1659 | - $results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths); |
|
1660 | - else |
|
1661 | - $results = parseModification($contents, false, $change['reverse'], $cur_theme_paths); |
|
1759 | + if ($change['boardmod']) { |
|
1760 | + $results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths); |
|
1761 | + } else { |
|
1762 | + $results = parseModification($contents, false, $change['reverse'], $cur_theme_paths); |
|
1763 | + } |
|
1662 | 1764 | } |
1663 | 1765 | } |
1664 | 1766 | |
@@ -1677,9 +1779,10 @@ discard block |
||
1677 | 1779 | $writable_files = array(); |
1678 | 1780 | foreach ($upcontext['packages'] as $package) |
1679 | 1781 | { |
1680 | - if (!empty($package['files'])) |
|
1681 | - foreach ($package['files'] as $file) |
|
1782 | + if (!empty($package['files'])) { |
|
1783 | + foreach ($package['files'] as $file) |
|
1682 | 1784 | $writable_files[] = $file; |
1785 | + } |
|
1683 | 1786 | } |
1684 | 1787 | |
1685 | 1788 | if (!empty($writable_files)) |
@@ -1687,13 +1790,15 @@ discard block |
||
1687 | 1790 | $writable_files = array_unique($writable_files); |
1688 | 1791 | $upcontext['writable_files'] = $writable_files; |
1689 | 1792 | |
1690 | - if (!makeFilesWritable($writable_files)) |
|
1691 | - return false; |
|
1793 | + if (!makeFilesWritable($writable_files)) { |
|
1794 | + return false; |
|
1795 | + } |
|
1692 | 1796 | } |
1693 | 1797 | } |
1694 | 1798 | |
1695 | - if (file_exists($packagesdir . '/temp')) |
|
1696 | - deltree($packagesdir . '/temp'); |
|
1799 | + if (file_exists($packagesdir . '/temp')) { |
|
1800 | + deltree($packagesdir . '/temp'); |
|
1801 | + } |
|
1697 | 1802 | |
1698 | 1803 | // Removing/Reinstalling any packages? |
1699 | 1804 | if (isset($_POST['remove'])) |
@@ -1701,32 +1806,35 @@ discard block |
||
1701 | 1806 | $deletes = array(); |
1702 | 1807 | foreach ($_POST['remove'] as $id => $dummy) |
1703 | 1808 | { |
1704 | - if (!in_array((int) $id, $reinstall_worked)) |
|
1705 | - $deletes[] = (int) $id; |
|
1809 | + if (!in_array((int) $id, $reinstall_worked)) { |
|
1810 | + $deletes[] = (int) $id; |
|
1811 | + } |
|
1706 | 1812 | } |
1707 | 1813 | |
1708 | - if (!empty($deletes)) |
|
1709 | - upgrade_query(' |
|
1814 | + if (!empty($deletes)) { |
|
1815 | + upgrade_query(' |
|
1710 | 1816 | UPDATE ' . $db_prefix . 'log_packages |
1711 | 1817 | SET install_state = 0 |
1712 | 1818 | WHERE id_install IN (' . implode(',', $deletes) . ')'); |
1819 | + } |
|
1713 | 1820 | |
1714 | 1821 | // Ensure we don't lose our changes! |
1715 | 1822 | package_put_contents($packagesdir . '/installed.list', time()); |
1716 | 1823 | |
1717 | 1824 | $upcontext['sub_template'] = 'cleanup_done'; |
1718 | 1825 | return false; |
1719 | - } |
|
1720 | - else |
|
1826 | + } else |
|
1721 | 1827 | { |
1722 | 1828 | $allgood = true; |
1723 | 1829 | // Is there actually anything that needs our attention? |
1724 | - foreach ($upcontext['packages'] as $package) |
|
1725 | - if ($package['color'] != 'green') |
|
1830 | + foreach ($upcontext['packages'] as $package) { |
|
1831 | + if ($package['color'] != 'green') |
|
1726 | 1832 | $allgood = false; |
1833 | + } |
|
1727 | 1834 | |
1728 | - if ($allgood) |
|
1729 | - return true; |
|
1835 | + if ($allgood) { |
|
1836 | + return true; |
|
1837 | + } |
|
1730 | 1838 | } |
1731 | 1839 | |
1732 | 1840 | $_GET['substep'] = 0; |
@@ -1740,8 +1848,9 @@ discard block |
||
1740 | 1848 | global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
1741 | 1849 | |
1742 | 1850 | // Now it's nice to have some of the basic SMF source files. |
1743 | - if (!isset($_GET['ssi']) && !$command_line) |
|
1744 | - redirectLocation('&ssi=1'); |
|
1851 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
1852 | + redirectLocation('&ssi=1'); |
|
1853 | + } |
|
1745 | 1854 | |
1746 | 1855 | $upcontext['sub_template'] = 'upgrade_complete'; |
1747 | 1856 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1757,14 +1866,16 @@ discard block |
||
1757 | 1866 | // Are we in maintenance mode? |
1758 | 1867 | if (isset($upcontext['user']['main'])) |
1759 | 1868 | { |
1760 | - if ($command_line) |
|
1761 | - echo ' * '; |
|
1869 | + if ($command_line) { |
|
1870 | + echo ' * '; |
|
1871 | + } |
|
1762 | 1872 | $upcontext['removed_maintenance'] = true; |
1763 | 1873 | $changes['maintenance'] = $upcontext['user']['main']; |
1764 | 1874 | } |
1765 | 1875 | // Otherwise if somehow we are in 2 let's go to 1. |
1766 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
1767 | - $changes['maintenance'] = 1; |
|
1876 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
1877 | + $changes['maintenance'] = 1; |
|
1878 | + } |
|
1768 | 1879 | |
1769 | 1880 | // Wipe this out... |
1770 | 1881 | $upcontext['user'] = array(); |
@@ -1780,9 +1891,9 @@ discard block |
||
1780 | 1891 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1781 | 1892 | |
1782 | 1893 | // Now is the perfect time to fetch the SM files. |
1783 | - if ($command_line) |
|
1784 | - cli_scheduled_fetchSMfiles(); |
|
1785 | - else |
|
1894 | + if ($command_line) { |
|
1895 | + cli_scheduled_fetchSMfiles(); |
|
1896 | + } else |
|
1786 | 1897 | { |
1787 | 1898 | require_once($sourcedir . '/ScheduledTasks.php'); |
1788 | 1899 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1790,8 +1901,9 @@ discard block |
||
1790 | 1901 | } |
1791 | 1902 | |
1792 | 1903 | // Log what we've done. |
1793 | - if (empty($user_info['id'])) |
|
1794 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1904 | + if (empty($user_info['id'])) { |
|
1905 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1906 | + } |
|
1795 | 1907 | |
1796 | 1908 | // Log the action manually, so CLI still works. |
1797 | 1909 | $smcFunc['db_insert']('', |
@@ -1810,8 +1922,9 @@ discard block |
||
1810 | 1922 | |
1811 | 1923 | // Save the current database version. |
1812 | 1924 | $server_version = $smcFunc['db_server_info'](); |
1813 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1814 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1925 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1926 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1927 | + } |
|
1815 | 1928 | |
1816 | 1929 | if ($command_line) |
1817 | 1930 | { |
@@ -1823,8 +1936,9 @@ discard block |
||
1823 | 1936 | |
1824 | 1937 | // Make sure it says we're done. |
1825 | 1938 | $upcontext['overall_percent'] = 100; |
1826 | - if (isset($upcontext['step_progress'])) |
|
1827 | - unset($upcontext['step_progress']); |
|
1939 | + if (isset($upcontext['step_progress'])) { |
|
1940 | + unset($upcontext['step_progress']); |
|
1941 | + } |
|
1828 | 1942 | |
1829 | 1943 | $_GET['substep'] = 0; |
1830 | 1944 | return false; |
@@ -1835,8 +1949,9 @@ discard block |
||
1835 | 1949 | { |
1836 | 1950 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
1837 | 1951 | |
1838 | - if (empty($modSettings['time_format'])) |
|
1839 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1952 | + if (empty($modSettings['time_format'])) { |
|
1953 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1954 | + } |
|
1840 | 1955 | |
1841 | 1956 | // What files do we want to get |
1842 | 1957 | $request = $smcFunc['db_query']('', ' |
@@ -1870,8 +1985,9 @@ discard block |
||
1870 | 1985 | $file_data = fetch_web_data($url); |
1871 | 1986 | |
1872 | 1987 | // If we got an error - give up - the site might be down. |
1873 | - if ($file_data === false) |
|
1874 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1988 | + if ($file_data === false) { |
|
1989 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1990 | + } |
|
1875 | 1991 | |
1876 | 1992 | // Save the file to the database. |
1877 | 1993 | $smcFunc['db_query']('substring', ' |
@@ -1913,8 +2029,9 @@ discard block |
||
1913 | 2029 | $themeData = array(); |
1914 | 2030 | foreach ($values as $variable => $value) |
1915 | 2031 | { |
1916 | - if (!isset($value) || $value === null) |
|
1917 | - $value = 0; |
|
2032 | + if (!isset($value) || $value === null) { |
|
2033 | + $value = 0; |
|
2034 | + } |
|
1918 | 2035 | |
1919 | 2036 | $themeData[] = array(0, 1, $variable, $value); |
1920 | 2037 | } |
@@ -1943,8 +2060,9 @@ discard block |
||
1943 | 2060 | |
1944 | 2061 | foreach ($values as $variable => $value) |
1945 | 2062 | { |
1946 | - if (empty($modSettings[$value[0]])) |
|
1947 | - continue; |
|
2063 | + if (empty($modSettings[$value[0]])) { |
|
2064 | + continue; |
|
2065 | + } |
|
1948 | 2066 | |
1949 | 2067 | $smcFunc['db_query']('', ' |
1950 | 2068 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1977,8 +2095,9 @@ discard block |
||
1977 | 2095 | |
1978 | 2096 | $settingsArray = file($boarddir . '/Settings_bak.php'); |
1979 | 2097 | |
1980 | - if (count($settingsArray) == 1) |
|
1981 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
2098 | + if (count($settingsArray) == 1) { |
|
2099 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
2100 | + } |
|
1982 | 2101 | |
1983 | 2102 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1984 | 2103 | { |
@@ -1991,9 +2110,9 @@ discard block |
||
1991 | 2110 | { |
1992 | 2111 | if (isset($settingsArray[$i]) && strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
1993 | 2112 | { |
1994 | - if ($val == '#remove#') |
|
1995 | - unset($settingsArray[$i]); |
|
1996 | - else |
|
2113 | + if ($val == '#remove#') { |
|
2114 | + unset($settingsArray[$i]); |
|
2115 | + } else |
|
1997 | 2116 | { |
1998 | 2117 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
1999 | 2118 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
@@ -2005,22 +2124,25 @@ discard block |
||
2005 | 2124 | } |
2006 | 2125 | if (isset($settingsArray[$i])) |
2007 | 2126 | { |
2008 | - if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') |
|
2009 | - $end = $i; |
|
2127 | + if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') { |
|
2128 | + $end = $i; |
|
2129 | + } |
|
2010 | 2130 | } |
2011 | 2131 | } |
2012 | 2132 | |
2013 | 2133 | // Assume end-of-file if the end wasn't found. |
2014 | - if (empty($end) || $end < 10) |
|
2015 | - $end = count($settingsArray); |
|
2134 | + if (empty($end) || $end < 10) { |
|
2135 | + $end = count($settingsArray); |
|
2136 | + } |
|
2016 | 2137 | |
2017 | 2138 | if (!empty($config_vars)) |
2018 | 2139 | { |
2019 | 2140 | $settingsArray[$end++] = ''; |
2020 | 2141 | foreach ($config_vars as $var => $val) |
2021 | 2142 | { |
2022 | - if ($val != '#remove#') |
|
2023 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
2143 | + if ($val != '#remove#') { |
|
2144 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
2145 | + } |
|
2024 | 2146 | } |
2025 | 2147 | } |
2026 | 2148 | // This should be the last line and even last bytes of the file. |
@@ -2033,8 +2155,9 @@ discard block |
||
2033 | 2155 | $fp = fopen($boarddir . '/Settings.php', 'r+'); |
2034 | 2156 | for ($i = 0; $i < $end; $i++) |
2035 | 2157 | { |
2036 | - if (isset($settingsArray[$i])) |
|
2037 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
2158 | + if (isset($settingsArray[$i])) { |
|
2159 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
2160 | + } |
|
2038 | 2161 | } |
2039 | 2162 | fwrite($fp, rtrim($settingsArray[$i])); |
2040 | 2163 | fclose($fp); |
@@ -2065,8 +2188,9 @@ discard block |
||
2065 | 2188 | global $smcFunc; |
2066 | 2189 | static $member_groups = array(); |
2067 | 2190 | |
2068 | - if (!empty($member_groups)) |
|
2069 | - return $member_groups; |
|
2191 | + if (!empty($member_groups)) { |
|
2192 | + return $member_groups; |
|
2193 | + } |
|
2070 | 2194 | |
2071 | 2195 | $request = $smcFunc['db_query']('', ' |
2072 | 2196 | SELECT group_name, id_group |
@@ -2091,8 +2215,9 @@ discard block |
||
2091 | 2215 | ) |
2092 | 2216 | ); |
2093 | 2217 | } |
2094 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
2095 | - $member_groups[trim($row[0])] = $row[1]; |
|
2218 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
2219 | + $member_groups[trim($row[0])] = $row[1]; |
|
2220 | + } |
|
2096 | 2221 | $smcFunc['db_free_result']($request); |
2097 | 2222 | |
2098 | 2223 | return $member_groups; |
@@ -2145,10 +2270,11 @@ discard block |
||
2145 | 2270 | { |
2146 | 2271 | global $support_js; |
2147 | 2272 | |
2148 | - if ($support_js) |
|
2149 | - return true; |
|
2150 | - else |
|
2151 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
2273 | + if ($support_js) { |
|
2274 | + return true; |
|
2275 | + } else { |
|
2276 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
2277 | + } |
|
2152 | 2278 | } |
2153 | 2279 | } |
2154 | 2280 | |
@@ -2166,8 +2292,9 @@ discard block |
||
2166 | 2292 | 'db_error_skip' => true, |
2167 | 2293 | ) |
2168 | 2294 | ); |
2169 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2170 | - die('Unable to find members table!'); |
|
2295 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2296 | + die('Unable to find members table!'); |
|
2297 | + } |
|
2171 | 2298 | $table_status = $smcFunc['db_fetch_assoc']($request); |
2172 | 2299 | $smcFunc['db_free_result']($request); |
2173 | 2300 | |
@@ -2182,17 +2309,20 @@ discard block |
||
2182 | 2309 | ) |
2183 | 2310 | ); |
2184 | 2311 | // Got something? |
2185 | - if ($smcFunc['db_num_rows']($request) !== 0) |
|
2186 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2312 | + if ($smcFunc['db_num_rows']($request) !== 0) { |
|
2313 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2314 | + } |
|
2187 | 2315 | $smcFunc['db_free_result']($request); |
2188 | 2316 | |
2189 | 2317 | // Excellent! |
2190 | - if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) |
|
2191 | - $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
2318 | + if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) { |
|
2319 | + $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
2320 | + } |
|
2192 | 2321 | } |
2193 | 2322 | } |
2194 | - if (empty($db_collation)) |
|
2195 | - $db_collation = ''; |
|
2323 | + if (empty($db_collation)) { |
|
2324 | + $db_collation = ''; |
|
2325 | + } |
|
2196 | 2326 | |
2197 | 2327 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
2198 | 2328 | |
@@ -2204,8 +2334,9 @@ discard block |
||
2204 | 2334 | $last_step = ''; |
2205 | 2335 | |
2206 | 2336 | // Make sure all newly created tables will have the proper characters set. |
2207 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
2208 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
2337 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
2338 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
2339 | + } |
|
2209 | 2340 | |
2210 | 2341 | // Count the total number of steps within this file - for progress. |
2211 | 2342 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -2225,15 +2356,18 @@ discard block |
||
2225 | 2356 | $do_current = $substep >= $_GET['substep']; |
2226 | 2357 | |
2227 | 2358 | // Get rid of any comments in the beginning of the line... |
2228 | - if (substr(trim($line), 0, 2) === '/*') |
|
2229 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
2359 | + if (substr(trim($line), 0, 2) === '/*') { |
|
2360 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
2361 | + } |
|
2230 | 2362 | |
2231 | 2363 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
2232 | - if ($is_debug && !$support_js && $command_line) |
|
2233 | - flush(); |
|
2364 | + if ($is_debug && !$support_js && $command_line) { |
|
2365 | + flush(); |
|
2366 | + } |
|
2234 | 2367 | |
2235 | - if (trim($line) === '') |
|
2236 | - continue; |
|
2368 | + if (trim($line) === '') { |
|
2369 | + continue; |
|
2370 | + } |
|
2237 | 2371 | |
2238 | 2372 | if (trim(substr($line, 0, 3)) === '---') |
2239 | 2373 | { |
@@ -2243,8 +2377,9 @@ discard block |
||
2243 | 2377 | if (trim($current_data) != '' && $type !== '}') |
2244 | 2378 | { |
2245 | 2379 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
2246 | - if ($command_line) |
|
2247 | - echo $upcontext['error_message']; |
|
2380 | + if ($command_line) { |
|
2381 | + echo $upcontext['error_message']; |
|
2382 | + } |
|
2248 | 2383 | } |
2249 | 2384 | |
2250 | 2385 | if ($type == ' ') |
@@ -2262,17 +2397,18 @@ discard block |
||
2262 | 2397 | if ($do_current) |
2263 | 2398 | { |
2264 | 2399 | $upcontext['actioned_items'][] = $last_step; |
2265 | - if ($command_line) |
|
2266 | - echo ' * '; |
|
2400 | + if ($command_line) { |
|
2401 | + echo ' * '; |
|
2402 | + } |
|
2267 | 2403 | } |
2268 | - } |
|
2269 | - elseif ($type == '#') |
|
2404 | + } elseif ($type == '#') |
|
2270 | 2405 | { |
2271 | 2406 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
2272 | 2407 | |
2273 | 2408 | $upcontext['current_debug_item_num']++; |
2274 | - if (trim($line) != '---#') |
|
2275 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
2409 | + if (trim($line) != '---#') { |
|
2410 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
2411 | + } |
|
2276 | 2412 | |
2277 | 2413 | // Have we already done something? |
2278 | 2414 | if (isset($_GET['xml']) && $done_something) |
@@ -2283,34 +2419,36 @@ discard block |
||
2283 | 2419 | |
2284 | 2420 | if ($do_current) |
2285 | 2421 | { |
2286 | - if (trim($line) == '---#' && $command_line) |
|
2287 | - echo ' done.', $endl; |
|
2288 | - elseif ($command_line) |
|
2289 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
2290 | - elseif (trim($line) != '---#') |
|
2422 | + if (trim($line) == '---#' && $command_line) { |
|
2423 | + echo ' done.', $endl; |
|
2424 | + } elseif ($command_line) { |
|
2425 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
2426 | + } elseif (trim($line) != '---#') |
|
2291 | 2427 | { |
2292 | - if ($is_debug) |
|
2293 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
2428 | + if ($is_debug) { |
|
2429 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
2430 | + } |
|
2294 | 2431 | } |
2295 | 2432 | } |
2296 | 2433 | |
2297 | 2434 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
2298 | 2435 | { |
2299 | - if ($command_line) |
|
2300 | - echo ' * '; |
|
2301 | - else |
|
2302 | - $upcontext['actioned_items'][] = $last_step; |
|
2436 | + if ($command_line) { |
|
2437 | + echo ' * '; |
|
2438 | + } else { |
|
2439 | + $upcontext['actioned_items'][] = $last_step; |
|
2440 | + } |
|
2303 | 2441 | } |
2304 | 2442 | |
2305 | 2443 | // Small step - only if we're actually doing stuff. |
2306 | - if ($do_current) |
|
2307 | - nextSubstep(++$substep); |
|
2308 | - else |
|
2309 | - $substep++; |
|
2310 | - } |
|
2311 | - elseif ($type == '{') |
|
2312 | - $current_type = 'code'; |
|
2313 | - elseif ($type == '}') |
|
2444 | + if ($do_current) { |
|
2445 | + nextSubstep(++$substep); |
|
2446 | + } else { |
|
2447 | + $substep++; |
|
2448 | + } |
|
2449 | + } elseif ($type == '{') { |
|
2450 | + $current_type = 'code'; |
|
2451 | + } elseif ($type == '}') |
|
2314 | 2452 | { |
2315 | 2453 | $current_type = 'sql'; |
2316 | 2454 | |
@@ -2323,8 +2461,9 @@ discard block |
||
2323 | 2461 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
2324 | 2462 | { |
2325 | 2463 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
2326 | - if ($command_line) |
|
2327 | - echo $upcontext['error_message']; |
|
2464 | + if ($command_line) { |
|
2465 | + echo $upcontext['error_message']; |
|
2466 | + } |
|
2328 | 2467 | } |
2329 | 2468 | |
2330 | 2469 | // Done with code! |
@@ -2404,8 +2543,9 @@ discard block |
||
2404 | 2543 | $db_unbuffered = false; |
2405 | 2544 | |
2406 | 2545 | // Failure?! |
2407 | - if ($result !== false) |
|
2408 | - return $result; |
|
2546 | + if ($result !== false) { |
|
2547 | + return $result; |
|
2548 | + } |
|
2409 | 2549 | |
2410 | 2550 | $db_error_message = $smcFunc['db_error']($db_connection); |
2411 | 2551 | // If MySQL we do something more clever. |
@@ -2433,54 +2573,61 @@ discard block |
||
2433 | 2573 | { |
2434 | 2574 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
2435 | 2575 | $result = mysqli_query($db_connection, $string); |
2436 | - if ($result !== false) |
|
2437 | - return $result; |
|
2576 | + if ($result !== false) { |
|
2577 | + return $result; |
|
2578 | + } |
|
2438 | 2579 | } |
2439 | - } |
|
2440 | - elseif ($mysqli_errno == 2013) |
|
2580 | + } elseif ($mysqli_errno == 2013) |
|
2441 | 2581 | { |
2442 | 2582 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
2443 | 2583 | mysqli_select_db($db_connection, $db_name); |
2444 | 2584 | if ($db_connection) |
2445 | 2585 | { |
2446 | 2586 | $result = mysqli_query($db_connection, $string); |
2447 | - if ($result !== false) |
|
2448 | - return $result; |
|
2587 | + if ($result !== false) { |
|
2588 | + return $result; |
|
2589 | + } |
|
2449 | 2590 | } |
2450 | 2591 | } |
2451 | 2592 | // Duplicate column name... should be okay ;). |
2452 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
2453 | - return false; |
|
2593 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
2594 | + return false; |
|
2595 | + } |
|
2454 | 2596 | // Duplicate insert... make sure it's the proper type of query ;). |
2455 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
2456 | - return false; |
|
2597 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
2598 | + return false; |
|
2599 | + } |
|
2457 | 2600 | // Creating an index on a non-existent column. |
2458 | - elseif ($mysqli_errno == 1072) |
|
2459 | - return false; |
|
2460 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
2461 | - return false; |
|
2601 | + elseif ($mysqli_errno == 1072) { |
|
2602 | + return false; |
|
2603 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
2604 | + return false; |
|
2605 | + } |
|
2462 | 2606 | } |
2463 | 2607 | // If a table already exists don't go potty. |
2464 | 2608 | else |
2465 | 2609 | { |
2466 | 2610 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
2467 | 2611 | { |
2468 | - if (strpos($db_error_message, 'exist') !== false) |
|
2469 | - return true; |
|
2470 | - } |
|
2471 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2612 | + if (strpos($db_error_message, 'exist') !== false) { |
|
2613 | + return true; |
|
2614 | + } |
|
2615 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2472 | 2616 | { |
2473 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
2474 | - return true; |
|
2617 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
2618 | + return true; |
|
2619 | + } |
|
2475 | 2620 | } |
2476 | 2621 | } |
2477 | 2622 | |
2478 | 2623 | // Get the query string so we pass everything. |
2479 | 2624 | $query_string = ''; |
2480 | - foreach ($_GET as $k => $v) |
|
2481 | - $query_string .= ';' . $k . '=' . $v; |
|
2482 | - if (strlen($query_string) != 0) |
|
2483 | - $query_string = '?' . substr($query_string, 1); |
|
2625 | + foreach ($_GET as $k => $v) { |
|
2626 | + $query_string .= ';' . $k . '=' . $v; |
|
2627 | + } |
|
2628 | + if (strlen($query_string) != 0) { |
|
2629 | + $query_string = '?' . substr($query_string, 1); |
|
2630 | + } |
|
2484 | 2631 | |
2485 | 2632 | if ($command_line) |
2486 | 2633 | { |
@@ -2566,16 +2713,18 @@ discard block |
||
2566 | 2713 | { |
2567 | 2714 | $found |= 1; |
2568 | 2715 | // Do some checks on the data if we have it set. |
2569 | - if (isset($change['col_type'])) |
|
2570 | - $found &= $change['col_type'] === $column['type']; |
|
2571 | - if (isset($change['null_allowed'])) |
|
2572 | - $found &= $column['null'] == $change['null_allowed']; |
|
2573 | - if (isset($change['default'])) |
|
2574 | - $found &= $change['default'] === $column['default']; |
|
2716 | + if (isset($change['col_type'])) { |
|
2717 | + $found &= $change['col_type'] === $column['type']; |
|
2718 | + } |
|
2719 | + if (isset($change['null_allowed'])) { |
|
2720 | + $found &= $column['null'] == $change['null_allowed']; |
|
2721 | + } |
|
2722 | + if (isset($change['default'])) { |
|
2723 | + $found &= $change['default'] === $column['default']; |
|
2724 | + } |
|
2575 | 2725 | } |
2576 | 2726 | } |
2577 | - } |
|
2578 | - elseif ($change['type'] === 'index') |
|
2727 | + } elseif ($change['type'] === 'index') |
|
2579 | 2728 | { |
2580 | 2729 | $request = upgrade_query(' |
2581 | 2730 | SHOW INDEX |
@@ -2584,9 +2733,10 @@ discard block |
||
2584 | 2733 | { |
2585 | 2734 | $cur_index = array(); |
2586 | 2735 | |
2587 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2588 | - if ($row['Key_name'] === $change['name']) |
|
2736 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2737 | + if ($row['Key_name'] === $change['name']) |
|
2589 | 2738 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2739 | + } |
|
2590 | 2740 | |
2591 | 2741 | ksort($cur_index, SORT_NUMERIC); |
2592 | 2742 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2596,14 +2746,17 @@ discard block |
||
2596 | 2746 | } |
2597 | 2747 | |
2598 | 2748 | // If we're trying to add and it's added, we're done. |
2599 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
2600 | - return true; |
|
2749 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
2750 | + return true; |
|
2751 | + } |
|
2601 | 2752 | // Otherwise if we're removing and it wasn't found we're also done. |
2602 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
2603 | - return true; |
|
2753 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
2754 | + return true; |
|
2755 | + } |
|
2604 | 2756 | // Otherwise is it just a test? |
2605 | - elseif ($is_test) |
|
2606 | - return false; |
|
2757 | + elseif ($is_test) { |
|
2758 | + return false; |
|
2759 | + } |
|
2607 | 2760 | |
2608 | 2761 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
2609 | 2762 | $running = false; |
@@ -2614,8 +2767,9 @@ discard block |
||
2614 | 2767 | SHOW FULL PROCESSLIST'); |
2615 | 2768 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2616 | 2769 | { |
2617 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
2618 | - $found = true; |
|
2770 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
2771 | + $found = true; |
|
2772 | + } |
|
2619 | 2773 | } |
2620 | 2774 | |
2621 | 2775 | // Can't find it? Then we need to run it fools! |
@@ -2627,8 +2781,9 @@ discard block |
||
2627 | 2781 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
2628 | 2782 | ' . $change['text'], true) !== false; |
2629 | 2783 | |
2630 | - if (!$success) |
|
2631 | - return false; |
|
2784 | + if (!$success) { |
|
2785 | + return false; |
|
2786 | + } |
|
2632 | 2787 | |
2633 | 2788 | // Return |
2634 | 2789 | $running = true; |
@@ -2661,8 +2816,7 @@ discard block |
||
2661 | 2816 | { |
2662 | 2817 | $column_fix = true; |
2663 | 2818 | $null_fix = !$change['null_allowed']; |
2664 | - } |
|
2665 | - else |
|
2819 | + } else |
|
2666 | 2820 | { |
2667 | 2821 | $request = $smcFunc['db_query']('', ' |
2668 | 2822 | SHOW FULL COLUMNS |
@@ -2673,8 +2827,9 @@ discard block |
||
2673 | 2827 | 'db_error_skip' => true, |
2674 | 2828 | ) |
2675 | 2829 | ); |
2676 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2677 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2830 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2831 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2832 | + } |
|
2678 | 2833 | $table_row = $smcFunc['db_fetch_assoc']($request); |
2679 | 2834 | $smcFunc['db_free_result']($request); |
2680 | 2835 | |
@@ -2696,10 +2851,11 @@ discard block |
||
2696 | 2851 | ) |
2697 | 2852 | ); |
2698 | 2853 | // No results? Just forget it all together. |
2699 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2700 | - unset($table_row['Collation']); |
|
2701 | - else |
|
2702 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2854 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2855 | + unset($table_row['Collation']); |
|
2856 | + } else { |
|
2857 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2858 | + } |
|
2703 | 2859 | $smcFunc['db_free_result']($request); |
2704 | 2860 | } |
2705 | 2861 | } |
@@ -2707,8 +2863,8 @@ discard block |
||
2707 | 2863 | if ($column_fix) |
2708 | 2864 | { |
2709 | 2865 | // Make sure there are no NULL's left. |
2710 | - if ($null_fix) |
|
2711 | - $smcFunc['db_query']('', ' |
|
2866 | + if ($null_fix) { |
|
2867 | + $smcFunc['db_query']('', ' |
|
2712 | 2868 | UPDATE {db_prefix}' . $change['table'] . ' |
2713 | 2869 | SET ' . $change['column'] . ' = {string:default} |
2714 | 2870 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2717,6 +2873,7 @@ discard block |
||
2717 | 2873 | 'db_error_skip' => true, |
2718 | 2874 | ) |
2719 | 2875 | ); |
2876 | + } |
|
2720 | 2877 | |
2721 | 2878 | // Do the actual alteration. |
2722 | 2879 | $smcFunc['db_query']('', ' |
@@ -2745,8 +2902,9 @@ discard block |
||
2745 | 2902 | } |
2746 | 2903 | |
2747 | 2904 | // Not a column we need to check on? |
2748 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
2749 | - return; |
|
2905 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
2906 | + return; |
|
2907 | + } |
|
2750 | 2908 | |
2751 | 2909 | // Break it up you (six|seven). |
2752 | 2910 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2765,13 +2923,13 @@ discard block |
||
2765 | 2923 | 'new_name' => $temp[2], |
2766 | 2924 | )); |
2767 | 2925 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2768 | - if ($smcFunc['db_num_rows'] != 1) |
|
2769 | - return; |
|
2926 | + if ($smcFunc['db_num_rows'] != 1) { |
|
2927 | + return; |
|
2928 | + } |
|
2770 | 2929 | |
2771 | 2930 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
2772 | 2931 | $smcFunc['db_free_result']($request); |
2773 | - } |
|
2774 | - else |
|
2932 | + } else |
|
2775 | 2933 | { |
2776 | 2934 | // Do this the old fashion, sure method way. |
2777 | 2935 | $request = $smcFunc['db_query']('', ' |
@@ -2782,21 +2940,24 @@ discard block |
||
2782 | 2940 | )); |
2783 | 2941 | // Mayday! |
2784 | 2942 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2785 | - if ($smcFunc['db_num_rows'] == 0) |
|
2786 | - return; |
|
2943 | + if ($smcFunc['db_num_rows'] == 0) { |
|
2944 | + return; |
|
2945 | + } |
|
2787 | 2946 | |
2788 | 2947 | // Oh where, oh where has my little field gone. Oh where can it be... |
2789 | - while ($row = $smcFunc['db_query']($request)) |
|
2790 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2948 | + while ($row = $smcFunc['db_query']($request)) { |
|
2949 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2791 | 2950 | { |
2792 | 2951 | $current_type = $row['Type']; |
2952 | + } |
|
2793 | 2953 | break; |
2794 | 2954 | } |
2795 | 2955 | } |
2796 | 2956 | |
2797 | 2957 | // If this doesn't match, the column may of been altered for a reason. |
2798 | - if (trim($current_type) != trim($temp[3])) |
|
2799 | - $temp[3] = $current_type; |
|
2958 | + if (trim($current_type) != trim($temp[3])) { |
|
2959 | + $temp[3] = $current_type; |
|
2960 | + } |
|
2800 | 2961 | |
2801 | 2962 | // Piece this back together. |
2802 | 2963 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2808,8 +2969,9 @@ discard block |
||
2808 | 2969 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2809 | 2970 | global $step_progress, $is_debug, $upcontext; |
2810 | 2971 | |
2811 | - if ($_GET['substep'] < $substep) |
|
2812 | - $_GET['substep'] = $substep; |
|
2972 | + if ($_GET['substep'] < $substep) { |
|
2973 | + $_GET['substep'] = $substep; |
|
2974 | + } |
|
2813 | 2975 | |
2814 | 2976 | if ($command_line) |
2815 | 2977 | { |
@@ -2822,29 +2984,33 @@ discard block |
||
2822 | 2984 | } |
2823 | 2985 | |
2824 | 2986 | @set_time_limit(300); |
2825 | - if (function_exists('apache_reset_timeout')) |
|
2826 | - @apache_reset_timeout(); |
|
2987 | + if (function_exists('apache_reset_timeout')) { |
|
2988 | + @apache_reset_timeout(); |
|
2989 | + } |
|
2827 | 2990 | |
2828 | - if (time() - $start_time <= $timeLimitThreshold) |
|
2829 | - return; |
|
2991 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
2992 | + return; |
|
2993 | + } |
|
2830 | 2994 | |
2831 | 2995 | // Do we have some custom step progress stuff? |
2832 | 2996 | if (!empty($step_progress)) |
2833 | 2997 | { |
2834 | 2998 | $upcontext['substep_progress'] = 0; |
2835 | 2999 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2836 | - if ($step_progress['current'] > $step_progress['total']) |
|
2837 | - $upcontext['substep_progress'] = 99.9; |
|
2838 | - else |
|
2839 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
3000 | + if ($step_progress['current'] > $step_progress['total']) { |
|
3001 | + $upcontext['substep_progress'] = 99.9; |
|
3002 | + } else { |
|
3003 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
3004 | + } |
|
2840 | 3005 | |
2841 | 3006 | // Make it nicely rounded. |
2842 | 3007 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
2843 | 3008 | } |
2844 | 3009 | |
2845 | 3010 | // If this is XML we just exit right away! |
2846 | - if (isset($_GET['xml'])) |
|
2847 | - return upgradeExit(); |
|
3011 | + if (isset($_GET['xml'])) { |
|
3012 | + return upgradeExit(); |
|
3013 | + } |
|
2848 | 3014 | |
2849 | 3015 | // We're going to pause after this! |
2850 | 3016 | $upcontext['pause'] = true; |
@@ -2852,13 +3018,15 @@ discard block |
||
2852 | 3018 | $upcontext['query_string'] = ''; |
2853 | 3019 | foreach ($_GET as $k => $v) |
2854 | 3020 | { |
2855 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
2856 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
3021 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
3022 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
3023 | + } |
|
2857 | 3024 | } |
2858 | 3025 | |
2859 | 3026 | // Custom warning? |
2860 | - if (!empty($custom_warning)) |
|
2861 | - $upcontext['custom_warning'] = $custom_warning; |
|
3027 | + if (!empty($custom_warning)) { |
|
3028 | + $upcontext['custom_warning'] = $custom_warning; |
|
3029 | + } |
|
2862 | 3030 | |
2863 | 3031 | upgradeExit(); |
2864 | 3032 | } |
@@ -2873,25 +3041,26 @@ discard block |
||
2873 | 3041 | ob_implicit_flush(true); |
2874 | 3042 | @set_time_limit(600); |
2875 | 3043 | |
2876 | - if (!isset($_SERVER['argv'])) |
|
2877 | - $_SERVER['argv'] = array(); |
|
3044 | + if (!isset($_SERVER['argv'])) { |
|
3045 | + $_SERVER['argv'] = array(); |
|
3046 | + } |
|
2878 | 3047 | $_GET['maint'] = 1; |
2879 | 3048 | |
2880 | 3049 | foreach ($_SERVER['argv'] as $i => $arg) |
2881 | 3050 | { |
2882 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
2883 | - $_GET['lang'] = $match[1]; |
|
2884 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
2885 | - continue; |
|
2886 | - elseif ($arg == '--no-maintenance') |
|
2887 | - $_GET['maint'] = 0; |
|
2888 | - elseif ($arg == '--debug') |
|
2889 | - $is_debug = true; |
|
2890 | - elseif ($arg == '--backup') |
|
2891 | - $_POST['backup'] = 1; |
|
2892 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
2893 | - $_GET['conv'] = 1; |
|
2894 | - elseif ($i != 0) |
|
3051 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
3052 | + $_GET['lang'] = $match[1]; |
|
3053 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
3054 | + continue; |
|
3055 | + } elseif ($arg == '--no-maintenance') { |
|
3056 | + $_GET['maint'] = 0; |
|
3057 | + } elseif ($arg == '--debug') { |
|
3058 | + $is_debug = true; |
|
3059 | + } elseif ($arg == '--backup') { |
|
3060 | + $_POST['backup'] = 1; |
|
3061 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
3062 | + $_GET['conv'] = 1; |
|
3063 | + } elseif ($i != 0) |
|
2895 | 3064 | { |
2896 | 3065 | echo 'SMF Command-line Upgrader |
2897 | 3066 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2905,10 +3074,12 @@ discard block |
||
2905 | 3074 | } |
2906 | 3075 | } |
2907 | 3076 | |
2908 | - if (!php_version_check()) |
|
2909 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2910 | - if (!db_version_check()) |
|
2911 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
3077 | + if (!php_version_check()) { |
|
3078 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
3079 | + } |
|
3080 | + if (!db_version_check()) { |
|
3081 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
3082 | + } |
|
2912 | 3083 | |
2913 | 3084 | // Do some checks to make sure they have proper privileges |
2914 | 3085 | db_extend('packages'); |
@@ -2923,34 +3094,39 @@ discard block |
||
2923 | 3094 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
2924 | 3095 | |
2925 | 3096 | // Sorry... we need CREATE, ALTER and DROP |
2926 | - if (!$create || !$alter || !$drop) |
|
2927 | - 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); |
|
3097 | + if (!$create || !$alter || !$drop) { |
|
3098 | + 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); |
|
3099 | + } |
|
2928 | 3100 | |
2929 | 3101 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
2930 | 3102 | && @file_exists($sourcedir . '/QueryString.php') |
2931 | 3103 | && @file_exists($sourcedir . '/ManageBoards.php'); |
2932 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
2933 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
3104 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
3105 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
3106 | + } |
|
2934 | 3107 | |
2935 | 3108 | // Do a quick version spot check. |
2936 | 3109 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
2937 | 3110 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2938 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
2939 | - print_error('Error: Some files have not yet been updated properly.'); |
|
3111 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
3112 | + print_error('Error: Some files have not yet been updated properly.'); |
|
3113 | + } |
|
2940 | 3114 | |
2941 | 3115 | // Make sure Settings.php is writable. |
2942 | 3116 | quickFileWritable($boarddir . '/Settings.php'); |
2943 | - if (!is_writable($boarddir . '/Settings.php')) |
|
2944 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
3117 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
3118 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
3119 | + } |
|
2945 | 3120 | |
2946 | 3121 | // Make sure Settings_bak.php is writable. |
2947 | 3122 | quickFileWritable($boarddir . '/Settings_bak.php'); |
2948 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
2949 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
3123 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
3124 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
3125 | + } |
|
2950 | 3126 | |
2951 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
2952 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2953 | - elseif (isset($modSettings['agreement'])) |
|
3127 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
3128 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
3129 | + } elseif (isset($modSettings['agreement'])) |
|
2954 | 3130 | { |
2955 | 3131 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
2956 | 3132 | fwrite($fp, $modSettings['agreement']); |
@@ -2960,31 +3136,36 @@ discard block |
||
2960 | 3136 | // Make sure Themes is writable. |
2961 | 3137 | quickFileWritable($modSettings['theme_dir']); |
2962 | 3138 | |
2963 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
2964 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
3139 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
3140 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
3141 | + } |
|
2965 | 3142 | |
2966 | 3143 | // Make sure cache directory exists and is writable! |
2967 | 3144 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
2968 | - if (!file_exists($cachedir_temp)) |
|
2969 | - @mkdir($cachedir_temp); |
|
3145 | + if (!file_exists($cachedir_temp)) { |
|
3146 | + @mkdir($cachedir_temp); |
|
3147 | + } |
|
2970 | 3148 | |
2971 | 3149 | // Make sure the cache temp dir is writable. |
2972 | 3150 | quickFileWritable($cachedir_temp); |
2973 | 3151 | |
2974 | - if (!is_writable($cachedir_temp)) |
|
2975 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
3152 | + if (!is_writable($cachedir_temp)) { |
|
3153 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
3154 | + } |
|
2976 | 3155 | |
2977 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
2978 | - print_error('Error: Unable to find language files!', true); |
|
2979 | - else |
|
3156 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
3157 | + print_error('Error: Unable to find language files!', true); |
|
3158 | + } else |
|
2980 | 3159 | { |
2981 | 3160 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
2982 | 3161 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
2983 | 3162 | |
2984 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
2985 | - print_error('Error: Language files out of date.', true); |
|
2986 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
2987 | - print_error('Error: Install language is missing for selected language.', true); |
|
3163 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
3164 | + print_error('Error: Language files out of date.', true); |
|
3165 | + } |
|
3166 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
3167 | + print_error('Error: Install language is missing for selected language.', true); |
|
3168 | + } |
|
2988 | 3169 | |
2989 | 3170 | // Otherwise include it! |
2990 | 3171 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2999,14 +3180,16 @@ discard block |
||
2999 | 3180 | { |
3000 | 3181 | static $fp = null; |
3001 | 3182 | |
3002 | - if ($fp === null) |
|
3003 | - $fp = fopen('php://stderr', 'wb'); |
|
3183 | + if ($fp === null) { |
|
3184 | + $fp = fopen('php://stderr', 'wb'); |
|
3185 | + } |
|
3004 | 3186 | |
3005 | 3187 | fwrite($fp, $message . "\n"); |
3006 | 3188 | |
3007 | - if ($fatal) |
|
3008 | - exit; |
|
3009 | -} |
|
3189 | + if ($fatal) { |
|
3190 | + exit; |
|
3191 | + } |
|
3192 | + } |
|
3010 | 3193 | |
3011 | 3194 | function throw_error($message) |
3012 | 3195 | { |
@@ -3023,8 +3206,9 @@ discard block |
||
3023 | 3206 | { |
3024 | 3207 | global $upcontext, $boarddir; |
3025 | 3208 | |
3026 | - if (empty($files)) |
|
3027 | - return true; |
|
3209 | + if (empty($files)) { |
|
3210 | + return true; |
|
3211 | + } |
|
3028 | 3212 | |
3029 | 3213 | $failure = false; |
3030 | 3214 | // On linux, it's easy - just use is_writable! |
@@ -3039,14 +3223,16 @@ discard block |
||
3039 | 3223 | @chmod($file, 0755); |
3040 | 3224 | |
3041 | 3225 | // Well, 755 hopefully worked... if not, try 777. |
3042 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
3043 | - $failure = true; |
|
3226 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
3227 | + $failure = true; |
|
3228 | + } |
|
3044 | 3229 | // Otherwise remove it as it's good! |
3045 | - else |
|
3046 | - unset($files[$k]); |
|
3230 | + else { |
|
3231 | + unset($files[$k]); |
|
3232 | + } |
|
3233 | + } else { |
|
3234 | + unset($files[$k]); |
|
3047 | 3235 | } |
3048 | - else |
|
3049 | - unset($files[$k]); |
|
3050 | 3236 | } |
3051 | 3237 | } |
3052 | 3238 | // Windows is trickier. Let's try opening for r+... |
@@ -3057,30 +3243,35 @@ discard block |
||
3057 | 3243 | foreach ($files as $k => $file) |
3058 | 3244 | { |
3059 | 3245 | // Folders can't be opened for write... but the index.php in them can ;). |
3060 | - if (is_dir($file)) |
|
3061 | - $file .= '/index.php'; |
|
3246 | + if (is_dir($file)) { |
|
3247 | + $file .= '/index.php'; |
|
3248 | + } |
|
3062 | 3249 | |
3063 | 3250 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
3064 | 3251 | @chmod($file, 0777); |
3065 | 3252 | $fp = @fopen($file, 'r+'); |
3066 | 3253 | |
3067 | 3254 | // Hmm, okay, try just for write in that case... |
3068 | - if (!$fp) |
|
3069 | - $fp = @fopen($file, 'w'); |
|
3255 | + if (!$fp) { |
|
3256 | + $fp = @fopen($file, 'w'); |
|
3257 | + } |
|
3070 | 3258 | |
3071 | - if (!$fp) |
|
3072 | - $failure = true; |
|
3073 | - else |
|
3074 | - unset($files[$k]); |
|
3259 | + if (!$fp) { |
|
3260 | + $failure = true; |
|
3261 | + } else { |
|
3262 | + unset($files[$k]); |
|
3263 | + } |
|
3075 | 3264 | @fclose($fp); |
3076 | 3265 | } |
3077 | 3266 | } |
3078 | 3267 | |
3079 | - if (empty($files)) |
|
3080 | - return true; |
|
3268 | + if (empty($files)) { |
|
3269 | + return true; |
|
3270 | + } |
|
3081 | 3271 | |
3082 | - if (!isset($_SERVER)) |
|
3083 | - return !$failure; |
|
3272 | + if (!isset($_SERVER)) { |
|
3273 | + return !$failure; |
|
3274 | + } |
|
3084 | 3275 | |
3085 | 3276 | // What still needs to be done? |
3086 | 3277 | $upcontext['chmod']['files'] = $files; |
@@ -3131,36 +3322,40 @@ discard block |
||
3131 | 3322 | |
3132 | 3323 | if (!isset($ftp) || $ftp->error !== false) |
3133 | 3324 | { |
3134 | - if (!isset($ftp)) |
|
3135 | - $ftp = new ftp_connection(null); |
|
3325 | + if (!isset($ftp)) { |
|
3326 | + $ftp = new ftp_connection(null); |
|
3327 | + } |
|
3136 | 3328 | // Save the error so we can mess with listing... |
3137 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
3138 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
3329 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
3330 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
3331 | + } |
|
3139 | 3332 | |
3140 | 3333 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
3141 | 3334 | |
3142 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
3143 | - $upcontext['chmod']['path'] = $detect_path; |
|
3335 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
3336 | + $upcontext['chmod']['path'] = $detect_path; |
|
3337 | + } |
|
3144 | 3338 | |
3145 | - if (!isset($upcontext['chmod']['username'])) |
|
3146 | - $upcontext['chmod']['username'] = $username; |
|
3339 | + if (!isset($upcontext['chmod']['username'])) { |
|
3340 | + $upcontext['chmod']['username'] = $username; |
|
3341 | + } |
|
3147 | 3342 | |
3148 | 3343 | // Don't forget the login token. |
3149 | 3344 | $upcontext += createToken('login'); |
3150 | 3345 | |
3151 | 3346 | return false; |
3152 | - } |
|
3153 | - else |
|
3347 | + } else |
|
3154 | 3348 | { |
3155 | 3349 | // We want to do a relative path for FTP. |
3156 | 3350 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
3157 | 3351 | { |
3158 | 3352 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
3159 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
3160 | - $ftp_root = substr($ftp_root, 0, -1); |
|
3353 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
3354 | + $ftp_root = substr($ftp_root, 0, -1); |
|
3355 | + } |
|
3356 | + } else { |
|
3357 | + $ftp_root = $boarddir; |
|
3161 | 3358 | } |
3162 | - else |
|
3163 | - $ftp_root = $boarddir; |
|
3164 | 3359 | |
3165 | 3360 | // Save the info for next time! |
3166 | 3361 | $_SESSION['installer_temp_ftp'] = array( |
@@ -3174,10 +3369,12 @@ discard block |
||
3174 | 3369 | |
3175 | 3370 | foreach ($files as $k => $file) |
3176 | 3371 | { |
3177 | - if (!is_writable($file)) |
|
3178 | - $ftp->chmod($file, 0755); |
|
3179 | - if (!is_writable($file)) |
|
3180 | - $ftp->chmod($file, 0777); |
|
3372 | + if (!is_writable($file)) { |
|
3373 | + $ftp->chmod($file, 0755); |
|
3374 | + } |
|
3375 | + if (!is_writable($file)) { |
|
3376 | + $ftp->chmod($file, 0777); |
|
3377 | + } |
|
3181 | 3378 | |
3182 | 3379 | // Assuming that didn't work calculate the path without the boarddir. |
3183 | 3380 | if (!is_writable($file)) |
@@ -3186,19 +3383,23 @@ discard block |
||
3186 | 3383 | { |
3187 | 3384 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
3188 | 3385 | $ftp->chmod($ftp_file, 0755); |
3189 | - if (!is_writable($file)) |
|
3190 | - $ftp->chmod($ftp_file, 0777); |
|
3386 | + if (!is_writable($file)) { |
|
3387 | + $ftp->chmod($ftp_file, 0777); |
|
3388 | + } |
|
3191 | 3389 | // Sometimes an extra slash can help... |
3192 | 3390 | $ftp_file = '/' . $ftp_file; |
3193 | - if (!is_writable($file)) |
|
3194 | - $ftp->chmod($ftp_file, 0755); |
|
3195 | - if (!is_writable($file)) |
|
3196 | - $ftp->chmod($ftp_file, 0777); |
|
3391 | + if (!is_writable($file)) { |
|
3392 | + $ftp->chmod($ftp_file, 0755); |
|
3393 | + } |
|
3394 | + if (!is_writable($file)) { |
|
3395 | + $ftp->chmod($ftp_file, 0777); |
|
3396 | + } |
|
3197 | 3397 | } |
3198 | 3398 | } |
3199 | 3399 | |
3200 | - if (is_writable($file)) |
|
3201 | - unset($files[$k]); |
|
3400 | + if (is_writable($file)) { |
|
3401 | + unset($files[$k]); |
|
3402 | + } |
|
3202 | 3403 | } |
3203 | 3404 | |
3204 | 3405 | $ftp->close(); |
@@ -3208,16 +3409,18 @@ discard block |
||
3208 | 3409 | // What remains? |
3209 | 3410 | $upcontext['chmod']['files'] = $files; |
3210 | 3411 | |
3211 | - if (empty($files)) |
|
3212 | - return true; |
|
3412 | + if (empty($files)) { |
|
3413 | + return true; |
|
3414 | + } |
|
3213 | 3415 | |
3214 | 3416 | return false; |
3215 | 3417 | } |
3216 | 3418 | |
3217 | 3419 | function quickFileWritable($file) |
3218 | 3420 | { |
3219 | - if (is_writable($file)) |
|
3220 | - return true; |
|
3421 | + if (is_writable($file)) { |
|
3422 | + return true; |
|
3423 | + } |
|
3221 | 3424 | |
3222 | 3425 | @chmod($file, 0755); |
3223 | 3426 | |
@@ -3227,17 +3430,19 @@ discard block |
||
3227 | 3430 | foreach ($chmod_values as $val) |
3228 | 3431 | { |
3229 | 3432 | // If it's writable, break out of the loop |
3230 | - if (is_writable($file)) |
|
3231 | - break; |
|
3232 | - else |
|
3233 | - @chmod($file, $val); |
|
3433 | + if (is_writable($file)) { |
|
3434 | + break; |
|
3435 | + } else { |
|
3436 | + @chmod($file, $val); |
|
3437 | + } |
|
3234 | 3438 | } |
3235 | 3439 | } |
3236 | 3440 | function smf_strtolower($string) |
3237 | 3441 | { |
3238 | 3442 | global $sourcedir; |
3239 | - if (function_exists('mb_strtolower')) |
|
3240 | - return mb_strtolower($string, 'UTF-8'); |
|
3443 | + if (function_exists('mb_strtolower')) { |
|
3444 | + return mb_strtolower($string, 'UTF-8'); |
|
3445 | + } |
|
3241 | 3446 | require_once($sourcedir . '/Subs-Charset.php'); |
3242 | 3447 | return utf8_strtolower($string); |
3243 | 3448 | } |
@@ -3260,8 +3465,7 @@ discard block |
||
3260 | 3465 | ); |
3261 | 3466 | |
3262 | 3467 | return true; |
3263 | - } |
|
3264 | - else |
|
3468 | + } else |
|
3265 | 3469 | { |
3266 | 3470 | $upcontext['page_title'] = 'Converting to UTF8'; |
3267 | 3471 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -3305,8 +3509,9 @@ discard block |
||
3305 | 3509 | ) |
3306 | 3510 | ); |
3307 | 3511 | $db_charsets = array(); |
3308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3309 | - $db_charsets[] = $row['Charset']; |
|
3512 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3513 | + $db_charsets[] = $row['Charset']; |
|
3514 | + } |
|
3310 | 3515 | |
3311 | 3516 | $smcFunc['db_free_result']($request); |
3312 | 3517 | |
@@ -3342,13 +3547,15 @@ discard block |
||
3342 | 3547 | // If there's a fulltext index, we need to drop it first... |
3343 | 3548 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
3344 | 3549 | { |
3345 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3346 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
3550 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3551 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
3347 | 3552 | $upcontext['fulltext_index'][] = $row['Key_name']; |
3553 | + } |
|
3348 | 3554 | $smcFunc['db_free_result']($request); |
3349 | 3555 | |
3350 | - if (isset($upcontext['fulltext_index'])) |
|
3351 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
3556 | + if (isset($upcontext['fulltext_index'])) { |
|
3557 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
3558 | + } |
|
3352 | 3559 | } |
3353 | 3560 | |
3354 | 3561 | // Drop it and make a note... |
@@ -3540,8 +3747,9 @@ discard block |
||
3540 | 3747 | $replace = '%field%'; |
3541 | 3748 | |
3542 | 3749 | // Build a huge REPLACE statement... |
3543 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
3544 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
3750 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
3751 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
3752 | + } |
|
3545 | 3753 | } |
3546 | 3754 | |
3547 | 3755 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -3575,8 +3783,9 @@ discard block |
||
3575 | 3783 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
3576 | 3784 | |
3577 | 3785 | // Just to make sure it doesn't time out. |
3578 | - if (function_exists('apache_reset_timeout')) |
|
3579 | - @apache_reset_timeout(); |
|
3786 | + if (function_exists('apache_reset_timeout')) { |
|
3787 | + @apache_reset_timeout(); |
|
3788 | + } |
|
3580 | 3789 | |
3581 | 3790 | $table_charsets = array(); |
3582 | 3791 | |
@@ -3597,8 +3806,9 @@ discard block |
||
3597 | 3806 | { |
3598 | 3807 | list($charset) = explode('_', $collation); |
3599 | 3808 | |
3600 | - if (!isset($table_charsets[$charset])) |
|
3601 | - $table_charsets[$charset] = array(); |
|
3809 | + if (!isset($table_charsets[$charset])) { |
|
3810 | + $table_charsets[$charset] = array(); |
|
3811 | + } |
|
3602 | 3812 | |
3603 | 3813 | $table_charsets[$charset][] = $column_info; |
3604 | 3814 | } |
@@ -3638,10 +3848,11 @@ discard block |
||
3638 | 3848 | if (isset($translation_tables[$upcontext['charset_detected']])) |
3639 | 3849 | { |
3640 | 3850 | $update = ''; |
3641 | - foreach ($table_charsets as $charset => $columns) |
|
3642 | - foreach ($columns as $column) |
|
3851 | + foreach ($table_charsets as $charset => $columns) { |
|
3852 | + foreach ($columns as $column) |
|
3643 | 3853 | $update .= ' |
3644 | 3854 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
3855 | + } |
|
3645 | 3856 | |
3646 | 3857 | $smcFunc['db_query']('', ' |
3647 | 3858 | UPDATE {raw:table_name} |
@@ -3666,8 +3877,9 @@ discard block |
||
3666 | 3877 | // Now do the actual conversion (if still needed). |
3667 | 3878 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
3668 | 3879 | { |
3669 | - if ($command_line) |
|
3670 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3880 | + if ($command_line) { |
|
3881 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3882 | + } |
|
3671 | 3883 | |
3672 | 3884 | $smcFunc['db_query']('', ' |
3673 | 3885 | ALTER TABLE {raw:table_name} |
@@ -3677,8 +3889,9 @@ discard block |
||
3677 | 3889 | ) |
3678 | 3890 | ); |
3679 | 3891 | |
3680 | - if ($command_line) |
|
3681 | - echo " done.\n"; |
|
3892 | + if ($command_line) { |
|
3893 | + echo " done.\n"; |
|
3894 | + } |
|
3682 | 3895 | } |
3683 | 3896 | } |
3684 | 3897 | |
@@ -3708,8 +3921,8 @@ discard block |
||
3708 | 3921 | ); |
3709 | 3922 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3710 | 3923 | { |
3711 | - 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) |
|
3712 | - $smcFunc['db_query']('', ' |
|
3924 | + 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) { |
|
3925 | + $smcFunc['db_query']('', ' |
|
3713 | 3926 | UPDATE {db_prefix}log_actions |
3714 | 3927 | SET extra = {string:extra} |
3715 | 3928 | WHERE id_action = {int:current_action}', |
@@ -3718,6 +3931,7 @@ discard block |
||
3718 | 3931 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
3719 | 3932 | ) |
3720 | 3933 | ); |
3934 | + } |
|
3721 | 3935 | } |
3722 | 3936 | $smcFunc['db_free_result']($request); |
3723 | 3937 | |
@@ -3739,15 +3953,17 @@ discard block |
||
3739 | 3953 | // First thing's first - did we already do this? |
3740 | 3954 | if (!empty($modSettings['json_done'])) |
3741 | 3955 | { |
3742 | - if ($command_line) |
|
3743 | - return DeleteUpgrade(); |
|
3744 | - else |
|
3745 | - return true; |
|
3956 | + if ($command_line) { |
|
3957 | + return DeleteUpgrade(); |
|
3958 | + } else { |
|
3959 | + return true; |
|
3960 | + } |
|
3746 | 3961 | } |
3747 | 3962 | |
3748 | 3963 | // Done it already - js wise? |
3749 | - if (!empty($_POST['json_done'])) |
|
3750 | - return true; |
|
3964 | + if (!empty($_POST['json_done'])) { |
|
3965 | + return true; |
|
3966 | + } |
|
3751 | 3967 | |
3752 | 3968 | // List of tables affected by this function |
3753 | 3969 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3779,12 +3995,14 @@ discard block |
||
3779 | 3995 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
3780 | 3996 | $file_steps = $upcontext['table_count']; |
3781 | 3997 | |
3782 | - foreach ($keys as $id => $table) |
|
3783 | - if ($id < $_GET['substep']) |
|
3998 | + foreach ($keys as $id => $table) { |
|
3999 | + if ($id < $_GET['substep']) |
|
3784 | 4000 | $upcontext['previous_tables'][] = $table; |
4001 | + } |
|
3785 | 4002 | |
3786 | - if ($command_line) |
|
3787 | - echo 'Converting data from serialize() to json_encode().'; |
|
4003 | + if ($command_line) { |
|
4004 | + echo 'Converting data from serialize() to json_encode().'; |
|
4005 | + } |
|
3788 | 4006 | |
3789 | 4007 | if (!$support_js || isset($_GET['xml'])) |
3790 | 4008 | { |
@@ -3824,8 +4042,9 @@ discard block |
||
3824 | 4042 | |
3825 | 4043 | // Loop through and fix these... |
3826 | 4044 | $new_settings = array(); |
3827 | - if ($command_line) |
|
3828 | - echo "\n" . 'Fixing some settings...'; |
|
4045 | + if ($command_line) { |
|
4046 | + echo "\n" . 'Fixing some settings...'; |
|
4047 | + } |
|
3829 | 4048 | |
3830 | 4049 | foreach ($serialized_settings as $var) |
3831 | 4050 | { |
@@ -3833,22 +4052,24 @@ discard block |
||
3833 | 4052 | { |
3834 | 4053 | // Attempt to unserialize the setting |
3835 | 4054 | $temp = @safe_unserialize($modSettings[$var]); |
3836 | - if (!$temp && $command_line) |
|
3837 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3838 | - elseif ($temp !== false) |
|
3839 | - $new_settings[$var] = json_encode($temp); |
|
4055 | + if (!$temp && $command_line) { |
|
4056 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
4057 | + } elseif ($temp !== false) { |
|
4058 | + $new_settings[$var] = json_encode($temp); |
|
4059 | + } |
|
3840 | 4060 | } |
3841 | 4061 | } |
3842 | 4062 | |
3843 | 4063 | // Update everything at once |
3844 | - if (!function_exists('cache_put_data')) |
|
3845 | - require_once($sourcedir . '/Load.php'); |
|
4064 | + if (!function_exists('cache_put_data')) { |
|
4065 | + require_once($sourcedir . '/Load.php'); |
|
4066 | + } |
|
3846 | 4067 | updateSettings($new_settings, true); |
3847 | 4068 | |
3848 | - if ($command_line) |
|
3849 | - echo ' done.'; |
|
3850 | - } |
|
3851 | - elseif ($table == 'themes') |
|
4069 | + if ($command_line) { |
|
4070 | + echo ' done.'; |
|
4071 | + } |
|
4072 | + } elseif ($table == 'themes') |
|
3852 | 4073 | { |
3853 | 4074 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3854 | 4075 | $query = $smcFunc['db_query']('', ' |
@@ -3867,10 +4088,11 @@ discard block |
||
3867 | 4088 | |
3868 | 4089 | if ($command_line) |
3869 | 4090 | { |
3870 | - if ($temp === false) |
|
3871 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3872 | - else |
|
3873 | - echo "\n" . 'Fixing admin preferences...'; |
|
4091 | + if ($temp === false) { |
|
4092 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
4093 | + } else { |
|
4094 | + echo "\n" . 'Fixing admin preferences...'; |
|
4095 | + } |
|
3874 | 4096 | } |
3875 | 4097 | |
3876 | 4098 | if ($temp !== false) |
@@ -3890,15 +4112,15 @@ discard block |
||
3890 | 4112 | ) |
3891 | 4113 | ); |
3892 | 4114 | |
3893 | - if ($command_line) |
|
3894 | - echo ' done.'; |
|
4115 | + if ($command_line) { |
|
4116 | + echo ' done.'; |
|
4117 | + } |
|
3895 | 4118 | } |
3896 | 4119 | } |
3897 | 4120 | |
3898 | 4121 | $smcFunc['db_free_result']($query); |
3899 | 4122 | } |
3900 | - } |
|
3901 | - else |
|
4123 | + } else |
|
3902 | 4124 | { |
3903 | 4125 | // First item is always the key... |
3904 | 4126 | $key = $info[0]; |
@@ -3909,8 +4131,7 @@ discard block |
||
3909 | 4131 | { |
3910 | 4132 | $col_select = $info[1]; |
3911 | 4133 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3912 | - } |
|
3913 | - else |
|
4134 | + } else |
|
3914 | 4135 | { |
3915 | 4136 | $col_select = implode(', ', $info); |
3916 | 4137 | } |
@@ -3943,8 +4164,7 @@ discard block |
||
3943 | 4164 | if ($temp === false && $command_line) |
3944 | 4165 | { |
3945 | 4166 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
3946 | - } |
|
3947 | - else |
|
4167 | + } else |
|
3948 | 4168 | { |
3949 | 4169 | $row[$col] = json_encode($temp); |
3950 | 4170 | |
@@ -3969,16 +4189,18 @@ discard block |
||
3969 | 4189 | } |
3970 | 4190 | } |
3971 | 4191 | |
3972 | - if ($command_line) |
|
3973 | - echo ' done.'; |
|
4192 | + if ($command_line) { |
|
4193 | + echo ' done.'; |
|
4194 | + } |
|
3974 | 4195 | |
3975 | 4196 | // Free up some memory... |
3976 | 4197 | $smcFunc['db_free_result']($query); |
3977 | 4198 | } |
3978 | 4199 | } |
3979 | 4200 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3980 | - if (isset($_GET['xml'])) |
|
3981 | - return upgradeExit(); |
|
4201 | + if (isset($_GET['xml'])) { |
|
4202 | + return upgradeExit(); |
|
4203 | + } |
|
3982 | 4204 | } |
3983 | 4205 | |
3984 | 4206 | if ($command_line) |
@@ -3993,8 +4215,9 @@ discard block |
||
3993 | 4215 | |
3994 | 4216 | $_GET['substep'] = 0; |
3995 | 4217 | // Make sure we move on! |
3996 | - if ($command_line) |
|
3997 | - return DeleteUpgrade(); |
|
4218 | + if ($command_line) { |
|
4219 | + return DeleteUpgrade(); |
|
4220 | + } |
|
3998 | 4221 | |
3999 | 4222 | return true; |
4000 | 4223 | } |
@@ -4014,14 +4237,16 @@ discard block |
||
4014 | 4237 | global $upcontext, $txt, $settings; |
4015 | 4238 | |
4016 | 4239 | // Don't call me twice! |
4017 | - if (!empty($upcontext['chmod_called'])) |
|
4018 | - return; |
|
4240 | + if (!empty($upcontext['chmod_called'])) { |
|
4241 | + return; |
|
4242 | + } |
|
4019 | 4243 | |
4020 | 4244 | $upcontext['chmod_called'] = true; |
4021 | 4245 | |
4022 | 4246 | // Nothing? |
4023 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
4024 | - return; |
|
4247 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
4248 | + return; |
|
4249 | + } |
|
4025 | 4250 | |
4026 | 4251 | // Was it a problem with Windows? |
4027 | 4252 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -4053,11 +4278,12 @@ discard block |
||
4053 | 4278 | 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\'); |
4054 | 4279 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
4055 | 4280 | |
4056 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
4057 | - echo ' |
|
4281 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
4282 | + echo ' |
|
4058 | 4283 | content.write(\'<hr>\n\t\t\t\'); |
4059 | 4284 | 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\'); |
4060 | 4285 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
4286 | + } |
|
4061 | 4287 | |
4062 | 4288 | echo ' |
4063 | 4289 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -4065,17 +4291,19 @@ discard block |
||
4065 | 4291 | } |
4066 | 4292 | </script>'; |
4067 | 4293 | |
4068 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
4069 | - echo ' |
|
4294 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
4295 | + echo ' |
|
4070 | 4296 | <div class="error_message red"> |
4071 | 4297 | The following error was encountered when trying to connect:<br><br> |
4072 | 4298 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
4073 | 4299 | </div> |
4074 | 4300 | <br>'; |
4301 | + } |
|
4075 | 4302 | |
4076 | - if (empty($upcontext['chmod_in_form'])) |
|
4077 | - echo ' |
|
4303 | + if (empty($upcontext['chmod_in_form'])) { |
|
4304 | + echo ' |
|
4078 | 4305 | <form action="', $upcontext['form_url'], '" method="post">'; |
4306 | + } |
|
4079 | 4307 | |
4080 | 4308 | echo ' |
4081 | 4309 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -4110,10 +4338,11 @@ discard block |
||
4110 | 4338 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
4111 | 4339 | </div>'; |
4112 | 4340 | |
4113 | - if (empty($upcontext['chmod_in_form'])) |
|
4114 | - echo ' |
|
4341 | + if (empty($upcontext['chmod_in_form'])) { |
|
4342 | + echo ' |
|
4115 | 4343 | </form>'; |
4116 | -} |
|
4344 | + } |
|
4345 | + } |
|
4117 | 4346 | |
4118 | 4347 | function template_upgrade_above() |
4119 | 4348 | { |
@@ -4173,9 +4402,10 @@ discard block |
||
4173 | 4402 | <h2>', $txt['upgrade_progress'], '</h2> |
4174 | 4403 | <ul>'; |
4175 | 4404 | |
4176 | - foreach ($upcontext['steps'] as $num => $step) |
|
4177 | - echo ' |
|
4405 | + foreach ($upcontext['steps'] as $num => $step) { |
|
4406 | + echo ' |
|
4178 | 4407 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
4408 | + } |
|
4179 | 4409 | |
4180 | 4410 | echo ' |
4181 | 4411 | </ul> |
@@ -4188,8 +4418,8 @@ discard block |
||
4188 | 4418 | </div> |
4189 | 4419 | </div>'; |
4190 | 4420 | |
4191 | - if (isset($upcontext['step_progress'])) |
|
4192 | - echo ' |
|
4421 | + if (isset($upcontext['step_progress'])) { |
|
4422 | + echo ' |
|
4193 | 4423 | <br> |
4194 | 4424 | <br> |
4195 | 4425 | <div id="progress_bar_step"> |
@@ -4198,6 +4428,7 @@ discard block |
||
4198 | 4428 | <span>', $txt['upgrade_step_progress'], '</span> |
4199 | 4429 | </div> |
4200 | 4430 | </div>'; |
4431 | + } |
|
4201 | 4432 | |
4202 | 4433 | echo ' |
4203 | 4434 | <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> |
@@ -4228,32 +4459,36 @@ discard block |
||
4228 | 4459 | { |
4229 | 4460 | global $upcontext, $txt; |
4230 | 4461 | |
4231 | - if (!empty($upcontext['pause'])) |
|
4232 | - echo ' |
|
4462 | + if (!empty($upcontext['pause'])) { |
|
4463 | + echo ' |
|
4233 | 4464 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
4234 | 4465 | |
4235 | 4466 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
4236 | 4467 | <h3> |
4237 | 4468 | ', $txt['upgrade_paused_overload'], ' |
4238 | 4469 | </h3>'; |
4470 | + } |
|
4239 | 4471 | |
4240 | - if (!empty($upcontext['custom_warning'])) |
|
4241 | - echo ' |
|
4472 | + if (!empty($upcontext['custom_warning'])) { |
|
4473 | + echo ' |
|
4242 | 4474 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
4243 | 4475 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
4244 | 4476 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
4245 | 4477 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
4246 | 4478 | </div>'; |
4479 | + } |
|
4247 | 4480 | |
4248 | 4481 | echo ' |
4249 | 4482 | <div class="righttext" style="margin: 1ex;">'; |
4250 | 4483 | |
4251 | - if (!empty($upcontext['continue'])) |
|
4252 | - echo ' |
|
4484 | + if (!empty($upcontext['continue'])) { |
|
4485 | + echo ' |
|
4253 | 4486 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
4254 | - if (!empty($upcontext['skip'])) |
|
4255 | - echo ' |
|
4487 | + } |
|
4488 | + if (!empty($upcontext['skip'])) { |
|
4489 | + echo ' |
|
4256 | 4490 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
4491 | + } |
|
4257 | 4492 | |
4258 | 4493 | echo ' |
4259 | 4494 | </div> |
@@ -4303,11 +4538,12 @@ discard block |
||
4303 | 4538 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
4304 | 4539 | <smf>'; |
4305 | 4540 | |
4306 | - if (!empty($upcontext['get_data'])) |
|
4307 | - foreach ($upcontext['get_data'] as $k => $v) |
|
4541 | + if (!empty($upcontext['get_data'])) { |
|
4542 | + foreach ($upcontext['get_data'] as $k => $v) |
|
4308 | 4543 | echo ' |
4309 | 4544 | <get key="', $k, '">', $v, '</get>'; |
4310 | -} |
|
4545 | + } |
|
4546 | + } |
|
4311 | 4547 | |
4312 | 4548 | function template_xml_below() |
4313 | 4549 | { |
@@ -4348,8 +4584,8 @@ discard block |
||
4348 | 4584 | template_chmod(); |
4349 | 4585 | |
4350 | 4586 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
4351 | - if ($upcontext['is_large_forum']) |
|
4352 | - echo ' |
|
4587 | + if ($upcontext['is_large_forum']) { |
|
4588 | + echo ' |
|
4353 | 4589 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
4354 | 4590 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
4355 | 4591 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -4357,10 +4593,11 @@ discard block |
||
4357 | 4593 | ', $txt['upgrade_warning_lots_data'], ' |
4358 | 4594 | </div> |
4359 | 4595 | </div>'; |
4596 | + } |
|
4360 | 4597 | |
4361 | 4598 | // A warning message? |
4362 | - if (!empty($upcontext['warning'])) |
|
4363 | - echo ' |
|
4599 | + if (!empty($upcontext['warning'])) { |
|
4600 | + echo ' |
|
4364 | 4601 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
4365 | 4602 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
4366 | 4603 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -4368,6 +4605,7 @@ discard block |
||
4368 | 4605 | ', $upcontext['warning'], ' |
4369 | 4606 | </div> |
4370 | 4607 | </div>'; |
4608 | + } |
|
4371 | 4609 | |
4372 | 4610 | // Paths are incorrect? |
4373 | 4611 | echo ' |
@@ -4383,20 +4621,22 @@ discard block |
||
4383 | 4621 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
4384 | 4622 | { |
4385 | 4623 | $ago = time() - $upcontext['started']; |
4386 | - if ($ago < 60) |
|
4387 | - $ago = $ago . ' seconds'; |
|
4388 | - elseif ($ago < 3600) |
|
4389 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
4390 | - else |
|
4391 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
4624 | + if ($ago < 60) { |
|
4625 | + $ago = $ago . ' seconds'; |
|
4626 | + } elseif ($ago < 3600) { |
|
4627 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
4628 | + } else { |
|
4629 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
4630 | + } |
|
4392 | 4631 | |
4393 | 4632 | $active = time() - $upcontext['updated']; |
4394 | - if ($active < 60) |
|
4395 | - $updated = $active . ' seconds'; |
|
4396 | - elseif ($active < 3600) |
|
4397 | - $updated = (int) ($active / 60) . ' minutes'; |
|
4398 | - else |
|
4399 | - $updated = (int) ($active / 3600) . ' hours'; |
|
4633 | + if ($active < 60) { |
|
4634 | + $updated = $active . ' seconds'; |
|
4635 | + } elseif ($active < 3600) { |
|
4636 | + $updated = (int) ($active / 60) . ' minutes'; |
|
4637 | + } else { |
|
4638 | + $updated = (int) ($active / 3600) . ' hours'; |
|
4639 | + } |
|
4400 | 4640 | |
4401 | 4641 | echo ' |
4402 | 4642 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -4405,16 +4645,18 @@ discard block |
||
4405 | 4645 | <div style="padding-left: 6ex;"> |
4406 | 4646 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
4407 | 4647 | |
4408 | - if ($active < 600) |
|
4409 | - echo ' |
|
4648 | + if ($active < 600) { |
|
4649 | + echo ' |
|
4410 | 4650 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
4651 | + } |
|
4411 | 4652 | |
4412 | - if ($active > $upcontext['inactive_timeout']) |
|
4413 | - echo ' |
|
4653 | + if ($active > $upcontext['inactive_timeout']) { |
|
4654 | + echo ' |
|
4414 | 4655 | <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.'; |
4415 | - else |
|
4416 | - echo ' |
|
4656 | + } else { |
|
4657 | + echo ' |
|
4417 | 4658 | <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!'); |
4659 | + } |
|
4418 | 4660 | |
4419 | 4661 | echo ' |
4420 | 4662 | </div> |
@@ -4430,9 +4672,10 @@ discard block |
||
4430 | 4672 | <td> |
4431 | 4673 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
4432 | 4674 | |
4433 | - if (!empty($upcontext['username_incorrect'])) |
|
4434 | - echo ' |
|
4675 | + if (!empty($upcontext['username_incorrect'])) { |
|
4676 | + echo ' |
|
4435 | 4677 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
4678 | + } |
|
4436 | 4679 | |
4437 | 4680 | echo ' |
4438 | 4681 | </td> |
@@ -4443,9 +4686,10 @@ discard block |
||
4443 | 4686 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
4444 | 4687 | <input type="hidden" name="hash_passwrd" value="">'; |
4445 | 4688 | |
4446 | - if (!empty($upcontext['password_failed'])) |
|
4447 | - echo ' |
|
4689 | + if (!empty($upcontext['password_failed'])) { |
|
4690 | + echo ' |
|
4448 | 4691 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
4692 | + } |
|
4449 | 4693 | |
4450 | 4694 | echo ' |
4451 | 4695 | </td> |
@@ -4516,8 +4760,8 @@ discard block |
||
4516 | 4760 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
4517 | 4761 | |
4518 | 4762 | // Warning message? |
4519 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
4520 | - echo ' |
|
4763 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
4764 | + echo ' |
|
4521 | 4765 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
4522 | 4766 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
4523 | 4767 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -4525,6 +4769,7 @@ discard block |
||
4525 | 4769 | ', $upcontext['upgrade_options_warning'], ' |
4526 | 4770 | </div> |
4527 | 4771 | </div>'; |
4772 | + } |
|
4528 | 4773 | |
4529 | 4774 | echo ' |
4530 | 4775 | <table> |
@@ -4552,8 +4797,8 @@ discard block |
||
4552 | 4797 | </tr>'; |
4553 | 4798 | |
4554 | 4799 | // Offer mysql users to switch to mysqli |
4555 | - if ($db_type == 'mysql' && function_exists('mysqli_query')) |
|
4556 | - echo ' |
|
4800 | + if ($db_type == 'mysql' && function_exists('mysqli_query')) { |
|
4801 | + echo ' |
|
4557 | 4802 | <tr valign="top"> |
4558 | 4803 | <td width="2%"> |
4559 | 4804 | <input type="checkbox" name="convertMysql" id="convertMysql" value="1" checked class="input_check"> |
@@ -4563,6 +4808,7 @@ discard block |
||
4563 | 4808 | <strong class="smalltext"><a href="http://wiki.simplemachines.org/smf/Upgrading-MySQLi-Functionality" target="_blank">More information about MySQLi</a></strong><br> |
4564 | 4809 | </td> |
4565 | 4810 | </tr>'; |
4811 | + } |
|
4566 | 4812 | |
4567 | 4813 | echo ' |
4568 | 4814 | <tr valign="top"> |
@@ -4582,8 +4828,8 @@ discard block |
||
4582 | 4828 | </td> |
4583 | 4829 | </tr>'; |
4584 | 4830 | |
4585 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
4586 | - echo ' |
|
4831 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
4832 | + echo ' |
|
4587 | 4833 | <tr valign="top"> |
4588 | 4834 | <td width="2%"> |
4589 | 4835 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -4592,6 +4838,7 @@ discard block |
||
4592 | 4838 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
4593 | 4839 | </td> |
4594 | 4840 | </tr>'; |
4841 | + } |
|
4595 | 4842 | |
4596 | 4843 | echo ' |
4597 | 4844 | <tr valign="top"> |
@@ -4627,10 +4874,11 @@ discard block |
||
4627 | 4874 | <span id="debuginfo"></span>'; |
4628 | 4875 | |
4629 | 4876 | // Dont any tables so far? |
4630 | - if (!empty($upcontext['previous_tables'])) |
|
4631 | - foreach ($upcontext['previous_tables'] as $table) |
|
4877 | + if (!empty($upcontext['previous_tables'])) { |
|
4878 | + foreach ($upcontext['previous_tables'] as $table) |
|
4632 | 4879 | echo ' |
4633 | 4880 | <br>Completed Table: "', $table, '".'; |
4881 | + } |
|
4634 | 4882 | |
4635 | 4883 | echo ' |
4636 | 4884 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -4667,12 +4915,13 @@ discard block |
||
4667 | 4915 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4668 | 4916 | |
4669 | 4917 | // If debug flood the screen. |
4670 | - if ($is_debug) |
|
4671 | - echo ' |
|
4918 | + if ($is_debug) { |
|
4919 | + echo ' |
|
4672 | 4920 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4673 | 4921 | |
4674 | 4922 | if (document.getElementById(\'debuginfo\').scrollHeight) |
4675 | 4923 | document.getElementById(\'debuginfo\').scrollTop = document.getElementById(\'debuginfo\').scrollHeight;'; |
4924 | + } |
|
4676 | 4925 | |
4677 | 4926 | echo ' |
4678 | 4927 | // Get the next update... |
@@ -4704,8 +4953,9 @@ discard block |
||
4704 | 4953 | { |
4705 | 4954 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
4706 | 4955 | |
4707 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
4708 | - $is_debug = true; |
|
4956 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
4957 | + $is_debug = true; |
|
4958 | + } |
|
4709 | 4959 | |
4710 | 4960 | echo ' |
4711 | 4961 | <h3>Executing database changes</h3> |
@@ -4720,8 +4970,9 @@ discard block |
||
4720 | 4970 | { |
4721 | 4971 | foreach ($upcontext['actioned_items'] as $num => $item) |
4722 | 4972 | { |
4723 | - if ($num != 0) |
|
4724 | - echo ' Successful!'; |
|
4973 | + if ($num != 0) { |
|
4974 | + echo ' Successful!'; |
|
4975 | + } |
|
4725 | 4976 | echo '<br>' . $item; |
4726 | 4977 | } |
4727 | 4978 | if (!empty($upcontext['changes_complete'])) |
@@ -4734,28 +4985,32 @@ discard block |
||
4734 | 4985 | $seconds = intval($active % 60); |
4735 | 4986 | |
4736 | 4987 | $totalTime = ''; |
4737 | - if ($hours > 0) |
|
4738 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4739 | - if ($minutes > 0) |
|
4740 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4741 | - if ($seconds > 0) |
|
4742 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4988 | + if ($hours > 0) { |
|
4989 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4990 | + } |
|
4991 | + if ($minutes > 0) { |
|
4992 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4993 | + } |
|
4994 | + if ($seconds > 0) { |
|
4995 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4996 | + } |
|
4743 | 4997 | } |
4744 | 4998 | |
4745 | - if ($is_debug && !empty($totalTime)) |
|
4746 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4747 | - else |
|
4748 | - echo ' Successful!<br><br>'; |
|
4999 | + if ($is_debug && !empty($totalTime)) { |
|
5000 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
5001 | + } else { |
|
5002 | + echo ' Successful!<br><br>'; |
|
5003 | + } |
|
4749 | 5004 | |
4750 | 5005 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
4751 | 5006 | } |
4752 | - } |
|
4753 | - else |
|
5007 | + } else |
|
4754 | 5008 | { |
4755 | 5009 | // Tell them how many files we have in total. |
4756 | - if ($upcontext['file_count'] > 1) |
|
4757 | - echo ' |
|
5010 | + if ($upcontext['file_count'] > 1) { |
|
5011 | + echo ' |
|
4758 | 5012 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
5013 | + } |
|
4759 | 5014 | |
4760 | 5015 | echo ' |
4761 | 5016 | <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> |
@@ -4771,19 +5026,23 @@ discard block |
||
4771 | 5026 | $seconds = intval($active % 60); |
4772 | 5027 | |
4773 | 5028 | $totalTime = ''; |
4774 | - if ($hours > 0) |
|
4775 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4776 | - if ($minutes > 0) |
|
4777 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4778 | - if ($seconds > 0) |
|
4779 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
5029 | + if ($hours > 0) { |
|
5030 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
5031 | + } |
|
5032 | + if ($minutes > 0) { |
|
5033 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
5034 | + } |
|
5035 | + if ($seconds > 0) { |
|
5036 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
5037 | + } |
|
4780 | 5038 | } |
4781 | 5039 | |
4782 | 5040 | echo ' |
4783 | 5041 | <br><span id="upgradeCompleted">'; |
4784 | 5042 | |
4785 | - if (!empty($totalTime)) |
|
4786 | - echo 'Completed in ', $totalTime, '<br>'; |
|
5043 | + if (!empty($totalTime)) { |
|
5044 | + echo 'Completed in ', $totalTime, '<br>'; |
|
5045 | + } |
|
4787 | 5046 | |
4788 | 5047 | echo '</span> |
4789 | 5048 | <div id="debug_section" style="height: 200px; overflow: auto;"> |
@@ -4820,9 +5079,10 @@ discard block |
||
4820 | 5079 | var getData = ""; |
4821 | 5080 | var debugItems = ', $upcontext['debug_items'], ';'; |
4822 | 5081 | |
4823 | - if ($is_debug) |
|
4824 | - echo ' |
|
5082 | + if ($is_debug) { |
|
5083 | + echo ' |
|
4825 | 5084 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
5085 | + } |
|
4826 | 5086 | |
4827 | 5087 | echo ' |
4828 | 5088 | function getNextItem() |
@@ -4862,9 +5122,10 @@ discard block |
||
4862 | 5122 | document.getElementById("error_block").style.display = ""; |
4863 | 5123 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4864 | 5124 | |
4865 | - if ($is_debug) |
|
4866 | - echo ' |
|
5125 | + if ($is_debug) { |
|
5126 | + echo ' |
|
4867 | 5127 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
5128 | + } |
|
4868 | 5129 | |
4869 | 5130 | echo ' |
4870 | 5131 | } |
@@ -4885,9 +5146,10 @@ discard block |
||
4885 | 5146 | document.getElementById("error_block").style.display = ""; |
4886 | 5147 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
4887 | 5148 | |
4888 | - if ($is_debug) |
|
4889 | - echo ' |
|
5149 | + if ($is_debug) { |
|
5150 | + echo ' |
|
4890 | 5151 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
5152 | + } |
|
4891 | 5153 | |
4892 | 5154 | echo ' |
4893 | 5155 | } |
@@ -4946,8 +5208,8 @@ discard block |
||
4946 | 5208 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
4947 | 5209 | {'; |
4948 | 5210 | |
4949 | - if ($is_debug) |
|
4950 | - echo ' |
|
5211 | + if ($is_debug) { |
|
5212 | + echo ' |
|
4951 | 5213 | document.getElementById(\'debug_section\').style.display = "none"; |
4952 | 5214 | |
4953 | 5215 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4965,6 +5227,7 @@ discard block |
||
4965 | 5227 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
4966 | 5228 | |
4967 | 5229 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
5230 | + } |
|
4968 | 5231 | |
4969 | 5232 | echo ' |
4970 | 5233 | |
@@ -4972,9 +5235,10 @@ discard block |
||
4972 | 5235 | document.getElementById(\'contbutt\').disabled = 0; |
4973 | 5236 | document.getElementById(\'database_done\').value = 1;'; |
4974 | 5237 | |
4975 | - if ($upcontext['file_count'] > 1) |
|
4976 | - echo ' |
|
5238 | + if ($upcontext['file_count'] > 1) { |
|
5239 | + echo ' |
|
4977 | 5240 | document.getElementById(\'info1\').style.display = "none";'; |
5241 | + } |
|
4978 | 5242 | |
4979 | 5243 | echo ' |
4980 | 5244 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4987,9 +5251,10 @@ discard block |
||
4987 | 5251 | lastItem = 0; |
4988 | 5252 | prevFile = curFile;'; |
4989 | 5253 | |
4990 | - if ($is_debug) |
|
4991 | - echo ' |
|
5254 | + if ($is_debug) { |
|
5255 | + echo ' |
|
4992 | 5256 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
5257 | + } |
|
4993 | 5258 | |
4994 | 5259 | echo ' |
4995 | 5260 | getNextItem(); |
@@ -4997,8 +5262,8 @@ discard block |
||
4997 | 5262 | }'; |
4998 | 5263 | |
4999 | 5264 | // If debug scroll the screen. |
5000 | - if ($is_debug) |
|
5001 | - echo ' |
|
5265 | + if ($is_debug) { |
|
5266 | + echo ' |
|
5002 | 5267 | if (iLastSubStepProgress == -1) |
5003 | 5268 | { |
5004 | 5269 | // Give it consistent dots. |
@@ -5017,6 +5282,7 @@ discard block |
||
5017 | 5282 | |
5018 | 5283 | if (document.getElementById(\'debug_section\').scrollHeight) |
5019 | 5284 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
5285 | + } |
|
5020 | 5286 | |
5021 | 5287 | echo ' |
5022 | 5288 | // Update the page. |
@@ -5077,9 +5343,10 @@ discard block |
||
5077 | 5343 | }'; |
5078 | 5344 | |
5079 | 5345 | // Start things off assuming we've not errored. |
5080 | - if (empty($upcontext['error_message'])) |
|
5081 | - echo ' |
|
5346 | + if (empty($upcontext['error_message'])) { |
|
5347 | + echo ' |
|
5082 | 5348 | getNextItem();'; |
5349 | + } |
|
5083 | 5350 | |
5084 | 5351 | echo ' |
5085 | 5352 | </script>'; |
@@ -5096,18 +5363,21 @@ discard block |
||
5096 | 5363 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
5097 | 5364 | <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>'; |
5098 | 5365 | |
5099 | - if (!empty($upcontext['error_message'])) |
|
5100 | - echo ' |
|
5366 | + if (!empty($upcontext['error_message'])) { |
|
5367 | + echo ' |
|
5101 | 5368 | <error>', $upcontext['error_message'], '</error>'; |
5369 | + } |
|
5102 | 5370 | |
5103 | - if (!empty($upcontext['error_string'])) |
|
5104 | - echo ' |
|
5371 | + if (!empty($upcontext['error_string'])) { |
|
5372 | + echo ' |
|
5105 | 5373 | <sql>', $upcontext['error_string'], '</sql>'; |
5374 | + } |
|
5106 | 5375 | |
5107 | - if ($is_debug) |
|
5108 | - echo ' |
|
5376 | + if ($is_debug) { |
|
5377 | + echo ' |
|
5109 | 5378 | <curtime>', time(), '</curtime>'; |
5110 | -} |
|
5379 | + } |
|
5380 | + } |
|
5111 | 5381 | |
5112 | 5382 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
5113 | 5383 | function template_convert_utf8() |
@@ -5124,18 +5394,20 @@ discard block |
||
5124 | 5394 | <span id="debuginfo"></span>'; |
5125 | 5395 | |
5126 | 5396 | // Done any tables so far? |
5127 | - if (!empty($upcontext['previous_tables'])) |
|
5128 | - foreach ($upcontext['previous_tables'] as $table) |
|
5397 | + if (!empty($upcontext['previous_tables'])) { |
|
5398 | + foreach ($upcontext['previous_tables'] as $table) |
|
5129 | 5399 | echo ' |
5130 | 5400 | <br>Completed Table: "', $table, '".'; |
5401 | + } |
|
5131 | 5402 | |
5132 | 5403 | echo ' |
5133 | 5404 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
5134 | 5405 | |
5135 | 5406 | // If we dropped their index, let's let them know |
5136 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
5137 | - echo ' |
|
5407 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
5408 | + echo ' |
|
5138 | 5409 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
5410 | + } |
|
5139 | 5411 | |
5140 | 5412 | echo ' |
5141 | 5413 | <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>'; |
@@ -5171,9 +5443,10 @@ discard block |
||
5171 | 5443 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
5172 | 5444 | |
5173 | 5445 | // If debug flood the screen. |
5174 | - if ($is_debug) |
|
5175 | - echo ' |
|
5446 | + if ($is_debug) { |
|
5447 | + echo ' |
|
5176 | 5448 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
5449 | + } |
|
5177 | 5450 | |
5178 | 5451 | echo ' |
5179 | 5452 | // Get the next update... |
@@ -5242,14 +5515,16 @@ discard block |
||
5242 | 5515 | <input type="hidden" name="cleandone" value="1">'; |
5243 | 5516 | |
5244 | 5517 | // Files to make writable? |
5245 | - if (!empty($upcontext['writable_files'])) |
|
5246 | - echo ' |
|
5518 | + if (!empty($upcontext['writable_files'])) { |
|
5519 | + echo ' |
|
5247 | 5520 | <input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">'; |
5521 | + } |
|
5248 | 5522 | |
5249 | 5523 | // We'll want a continue button... |
5250 | - if (empty($upcontext['chmod']['files'])) |
|
5251 | - $upcontext['continue'] = 1; |
|
5252 | -} |
|
5524 | + if (empty($upcontext['chmod']['files'])) { |
|
5525 | + $upcontext['continue'] = 1; |
|
5526 | + } |
|
5527 | + } |
|
5253 | 5528 | |
5254 | 5529 | // Finished with the mods - let them know what we've done. |
5255 | 5530 | function template_cleanup_done() |
@@ -5311,8 +5586,9 @@ discard block |
||
5311 | 5586 | "', $language['name'], '" Language Pack |
5312 | 5587 | <div class="smalltext">('; |
5313 | 5588 | |
5314 | - foreach ($language['files'] as $k => $file) |
|
5315 | - echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')'; |
|
5589 | + foreach ($language['files'] as $k => $file) { |
|
5590 | + echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')'; |
|
5591 | + } |
|
5316 | 5592 | |
5317 | 5593 | echo ' |
5318 | 5594 | </div> |
@@ -5329,8 +5605,9 @@ discard block |
||
5329 | 5605 | "', $theme['name'], '" Theme |
5330 | 5606 | <div class="smalltext">('; |
5331 | 5607 | |
5332 | - foreach ($theme['files'] as $k => $file) |
|
5333 | - echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')'; |
|
5608 | + foreach ($theme['files'] as $k => $file) { |
|
5609 | + echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')'; |
|
5610 | + } |
|
5334 | 5611 | |
5335 | 5612 | echo ' |
5336 | 5613 | </div> |
@@ -5341,47 +5618,54 @@ discard block |
||
5341 | 5618 | |
5342 | 5619 | echo ' |
5343 | 5620 | </table>'; |
5344 | - } |
|
5345 | - else |
|
5621 | + } else |
|
5346 | 5622 | { |
5347 | 5623 | $langFiles = 0; |
5348 | 5624 | $themeFiles = 0; |
5349 | - if (!empty($upcontext['languages'])) |
|
5350 | - foreach ($upcontext['languages'] as $lang) |
|
5625 | + if (!empty($upcontext['languages'])) { |
|
5626 | + foreach ($upcontext['languages'] as $lang) |
|
5351 | 5627 | $langFiles += count($lang['files']); |
5352 | - if (!empty($upcontext['themes'])) |
|
5353 | - foreach ($upcontext['themes'] as $theme) |
|
5628 | + } |
|
5629 | + if (!empty($upcontext['themes'])) { |
|
5630 | + foreach ($upcontext['themes'] as $theme) |
|
5354 | 5631 | $themeFiles += count($theme['files']); |
5632 | + } |
|
5355 | 5633 | echo sprintf('Found <strong>%d</strong> language files and <strong>%d</strong> templates requiring an update so far.', $langFiles, $themeFiles) . '<br>'; |
5356 | 5634 | |
5357 | 5635 | // What we're currently doing? |
5358 | - if (!empty($upcontext['current_message'])) |
|
5359 | - echo ' |
|
5636 | + if (!empty($upcontext['current_message'])) { |
|
5637 | + echo ' |
|
5360 | 5638 | ', $upcontext['current_message']; |
5639 | + } |
|
5361 | 5640 | } |
5362 | 5641 | |
5363 | 5642 | echo ' |
5364 | 5643 | <input type="hidden" name="uptempdone" value="1">'; |
5365 | 5644 | |
5366 | - if (!empty($upcontext['languages'])) |
|
5367 | - echo ' |
|
5645 | + if (!empty($upcontext['languages'])) { |
|
5646 | + echo ' |
|
5368 | 5647 | <input type="hidden" name="languages" value="', base64_encode(safe_serialize($upcontext['languages'])), '">'; |
5369 | - if (!empty($upcontext['themes'])) |
|
5370 | - echo ' |
|
5648 | + } |
|
5649 | + if (!empty($upcontext['themes'])) { |
|
5650 | + echo ' |
|
5371 | 5651 | <input type="hidden" name="themes" value="', base64_encode(safe_serialize($upcontext['themes'])), '">'; |
5372 | - if (!empty($upcontext['writable_files'])) |
|
5373 | - echo ' |
|
5652 | + } |
|
5653 | + if (!empty($upcontext['writable_files'])) { |
|
5654 | + echo ' |
|
5374 | 5655 | <input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">'; |
5656 | + } |
|
5375 | 5657 | |
5376 | 5658 | // Offer them the option to upgrade from YaBB SE? |
5377 | - if (!empty($upcontext['can_upgrade_yabbse'])) |
|
5378 | - echo ' |
|
5659 | + if (!empty($upcontext['can_upgrade_yabbse'])) { |
|
5660 | + echo ' |
|
5379 | 5661 | <br><label for="conv"><input type="checkbox" name="conv" id="conv" value="1" class="input_check"> Convert the existing YaBB SE template and set it as default.</label><br>'; |
5662 | + } |
|
5380 | 5663 | |
5381 | 5664 | // We'll want a continue button... assuming chmod is OK (Otherwise let them use connect!) |
5382 | - if (empty($upcontext['chmod']['files']) || $upcontext['is_test']) |
|
5383 | - $upcontext['continue'] = 1; |
|
5384 | -} |
|
5665 | + if (empty($upcontext['chmod']['files']) || $upcontext['is_test']) { |
|
5666 | + $upcontext['continue'] = 1; |
|
5667 | + } |
|
5668 | + } |
|
5385 | 5669 | |
5386 | 5670 | // Template for the database backup tool/ |
5387 | 5671 | function template_serialize_json() |
@@ -5398,19 +5682,21 @@ discard block |
||
5398 | 5682 | <span id="debuginfo"></span>'; |
5399 | 5683 | |
5400 | 5684 | // Dont any tables so far? |
5401 | - if (!empty($upcontext['previous_tables'])) |
|
5402 | - foreach ($upcontext['previous_tables'] as $table) |
|
5685 | + if (!empty($upcontext['previous_tables'])) { |
|
5686 | + foreach ($upcontext['previous_tables'] as $table) |
|
5403 | 5687 | echo ' |
5404 | 5688 | <br>Completed Table: "', $table, '".'; |
5689 | + } |
|
5405 | 5690 | |
5406 | 5691 | echo ' |
5407 | 5692 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
5408 | 5693 | <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>'; |
5409 | 5694 | |
5410 | 5695 | // Try to make sure substep was reset. |
5411 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
5412 | - echo ' |
|
5696 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
5697 | + echo ' |
|
5413 | 5698 | <input type="hidden" name="substep" id="substep" value="0">'; |
5699 | + } |
|
5414 | 5700 | |
5415 | 5701 | // Continue please! |
5416 | 5702 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -5443,9 +5729,10 @@ discard block |
||
5443 | 5729 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
5444 | 5730 | |
5445 | 5731 | // If debug flood the screen. |
5446 | - if ($is_debug) |
|
5447 | - echo ' |
|
5732 | + if ($is_debug) { |
|
5733 | + echo ' |
|
5448 | 5734 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
5735 | + } |
|
5449 | 5736 | |
5450 | 5737 | echo ' |
5451 | 5738 | // Get the next update... |
@@ -5480,8 +5767,8 @@ discard block |
||
5480 | 5767 | <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> |
5481 | 5768 | <form action="', $boardurl, '/index.php">'; |
5482 | 5769 | |
5483 | - if (!empty($upcontext['can_delete_script'])) |
|
5484 | - echo ' |
|
5770 | + if (!empty($upcontext['can_delete_script'])) { |
|
5771 | + echo ' |
|
5485 | 5772 | <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> |
5486 | 5773 | <script> |
5487 | 5774 | function doTheDelete(theCheck) |
@@ -5493,6 +5780,7 @@ discard block |
||
5493 | 5780 | } |
5494 | 5781 | </script> |
5495 | 5782 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
5783 | + } |
|
5496 | 5784 | |
5497 | 5785 | $active = time() - $upcontext['started']; |
5498 | 5786 | $hours = floor($active / 3600); |
@@ -5502,16 +5790,20 @@ discard block |
||
5502 | 5790 | if ($is_debug) |
5503 | 5791 | { |
5504 | 5792 | $totalTime = ''; |
5505 | - if ($hours > 0) |
|
5506 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
5507 | - if ($minutes > 0) |
|
5508 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
5509 | - if ($seconds > 0) |
|
5510 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
5793 | + if ($hours > 0) { |
|
5794 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
5795 | + } |
|
5796 | + if ($minutes > 0) { |
|
5797 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
5798 | + } |
|
5799 | + if ($seconds > 0) { |
|
5800 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
5801 | + } |
|
5511 | 5802 | } |
5512 | 5803 | |
5513 | - if ($is_debug && !empty($totalTime)) |
|
5514 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
5804 | + if ($is_debug && !empty($totalTime)) { |
|
5805 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
5806 | + } |
|
5515 | 5807 | |
5516 | 5808 | echo '<br> |
5517 | 5809 | 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> |
@@ -5571,16 +5863,19 @@ discard block |
||
5571 | 5863 | 'empty' => '', |
5572 | 5864 | 'limit' => $limit, |
5573 | 5865 | )); |
5574 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
5575 | - $arIp[] = $row[$oldCol]; |
|
5866 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
5867 | + $arIp[] = $row[$oldCol]; |
|
5868 | + } |
|
5576 | 5869 | $smcFunc['db_free_result']($request); |
5577 | 5870 | |
5578 | 5871 | // Special case, null ip could keep us in a loop. |
5579 | - if (is_null($arIp[0])) |
|
5580 | - unset($arIp[0]); |
|
5872 | + if (is_null($arIp[0])) { |
|
5873 | + unset($arIp[0]); |
|
5874 | + } |
|
5581 | 5875 | |
5582 | - if (empty($arIp)) |
|
5583 | - $is_done = true; |
|
5876 | + if (empty($arIp)) { |
|
5877 | + $is_done = true; |
|
5878 | + } |
|
5584 | 5879 | |
5585 | 5880 | $updates = array(); |
5586 | 5881 | $cases = array(); |
@@ -5589,16 +5884,18 @@ discard block |
||
5589 | 5884 | { |
5590 | 5885 | $arIp[$i] = trim($arIp[$i]); |
5591 | 5886 | |
5592 | - if (empty($arIp[$i])) |
|
5593 | - continue; |
|
5887 | + if (empty($arIp[$i])) { |
|
5888 | + continue; |
|
5889 | + } |
|
5594 | 5890 | |
5595 | 5891 | $updates['ip' . $i] = $arIp[$i]; |
5596 | 5892 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
5597 | 5893 | |
5598 | 5894 | if ($setSize > 0 && $i % $setSize === 0) |
5599 | 5895 | { |
5600 | - if (count($updates) == 1) |
|
5601 | - continue; |
|
5896 | + if (count($updates) == 1) { |
|
5897 | + continue; |
|
5898 | + } |
|
5602 | 5899 | |
5603 | 5900 | $updates['whereSet'] = array_values($updates); |
5604 | 5901 | $smcFunc['db_query']('', ' |
@@ -5632,8 +5929,7 @@ discard block |
||
5632 | 5929 | 'ip' => $ip |
5633 | 5930 | )); |
5634 | 5931 | } |
5635 | - } |
|
5636 | - else |
|
5932 | + } else |
|
5637 | 5933 | { |
5638 | 5934 | $updates['whereSet'] = array_values($updates); |
5639 | 5935 | $request = $smcFunc['db_query']('', ' |
@@ -5647,9 +5943,9 @@ discard block |
||
5647 | 5943 | $updates |
5648 | 5944 | ); |
5649 | 5945 | } |
5946 | + } else { |
|
5947 | + $is_done = true; |
|
5650 | 5948 | } |
5651 | - else |
|
5652 | - $is_done = true; |
|
5653 | 5949 | |
5654 | 5950 | $_GET['a'] += $limit; |
5655 | 5951 | $step_progress['current'] = $_GET['a']; |