@@ -81,8 +81,9 @@ discard block |
||
81 | 81 | $upcontext['inactive_timeout'] = 10; |
82 | 82 | |
83 | 83 | // The helper is crucial. Include it first thing. |
84 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
84 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
85 | 85 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
86 | +} |
|
86 | 87 | |
87 | 88 | require_once($upgrade_path . '/upgrade-helper.php'); |
88 | 89 | |
@@ -106,11 +107,14 @@ discard block |
||
106 | 107 | ini_set('default_socket_timeout', 900); |
107 | 108 | } |
108 | 109 | // Clean the upgrade path if this is from the client. |
109 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
110 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
110 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
111 | + for ($i = 1; |
|
112 | +} |
|
113 | +$i < $_SERVER['argc']; $i++) |
|
111 | 114 | { |
112 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
113 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
115 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
116 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
117 | + } |
|
114 | 118 | } |
115 | 119 | |
116 | 120 | // Are we from the client? |
@@ -118,9 +122,9 @@ discard block |
||
118 | 122 | { |
119 | 123 | $command_line = true; |
120 | 124 | $disable_security = true; |
121 | -} |
|
122 | -else |
|
125 | +} else { |
|
123 | 126 | $command_line = false; |
127 | +} |
|
124 | 128 | |
125 | 129 | // Load this now just because we can. |
126 | 130 | require_once($upgrade_path . '/Settings.php'); |
@@ -131,10 +135,12 @@ discard block |
||
131 | 135 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
132 | 136 | |
133 | 137 | // Check for sensible values. |
134 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
135 | - $upcontext['user']['started'] = time(); |
|
136 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
137 | - $upcontext['user']['updated'] = 0; |
|
138 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
139 | + $upcontext['user']['started'] = time(); |
|
140 | + } |
|
141 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
142 | + $upcontext['user']['updated'] = 0; |
|
143 | + } |
|
138 | 144 | |
139 | 145 | $upcontext['started'] = $upcontext['user']['started']; |
140 | 146 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -192,8 +198,9 @@ discard block |
||
192 | 198 | 'db_error_skip' => true, |
193 | 199 | ) |
194 | 200 | ); |
195 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
196 | - $modSettings[$row['variable']] = $row['value']; |
|
201 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
202 | + $modSettings[$row['variable']] = $row['value']; |
|
203 | + } |
|
197 | 204 | $smcFunc['db_free_result']($request); |
198 | 205 | } |
199 | 206 | |
@@ -203,10 +210,12 @@ discard block |
||
203 | 210 | $modSettings['theme_url'] = 'Themes/default'; |
204 | 211 | $modSettings['images_url'] = 'Themes/default/images'; |
205 | 212 | } |
206 | -if (!isset($settings['default_theme_url'])) |
|
213 | +if (!isset($settings['default_theme_url'])) { |
|
207 | 214 | $settings['default_theme_url'] = $modSettings['theme_url']; |
208 | -if (!isset($settings['default_theme_dir'])) |
|
215 | +} |
|
216 | +if (!isset($settings['default_theme_dir'])) { |
|
209 | 217 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
218 | +} |
|
210 | 219 | |
211 | 220 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
212 | 221 | // Default title... |
@@ -224,13 +233,15 @@ discard block |
||
224 | 233 | $support_js = $upcontext['upgrade_status']['js']; |
225 | 234 | |
226 | 235 | // Only set this if the upgrader status says so. |
227 | - if (empty($is_debug)) |
|
228 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
236 | + if (empty($is_debug)) { |
|
237 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
238 | + } |
|
229 | 239 | |
230 | 240 | // Load the language. |
231 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
232 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
233 | -} |
|
241 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
242 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
243 | + } |
|
244 | + } |
|
234 | 245 | // Set the defaults. |
235 | 246 | else |
236 | 247 | { |
@@ -248,15 +259,18 @@ discard block |
||
248 | 259 | } |
249 | 260 | |
250 | 261 | // If this isn't the first stage see whether they are logging in and resuming. |
251 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
262 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
252 | 263 | checkLogin(); |
264 | +} |
|
253 | 265 | |
254 | -if ($command_line) |
|
266 | +if ($command_line) { |
|
255 | 267 | cmdStep0(); |
268 | +} |
|
256 | 269 | |
257 | 270 | // Don't error if we're using xml. |
258 | -if (isset($_GET['xml'])) |
|
271 | +if (isset($_GET['xml'])) { |
|
259 | 272 | $upcontext['return_error'] = true; |
273 | +} |
|
260 | 274 | |
261 | 275 | // Loop through all the steps doing each one as required. |
262 | 276 | $upcontext['overall_percent'] = 0; |
@@ -277,10 +291,11 @@ discard block |
||
277 | 291 | } |
278 | 292 | |
279 | 293 | // Call the step and if it returns false that means pause! |
280 | - if (function_exists($step[2]) && $step[2]() === false) |
|
281 | - break; |
|
282 | - elseif (function_exists($step[2])) |
|
283 | - $upcontext['current_step']++; |
|
294 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
295 | + break; |
|
296 | + } elseif (function_exists($step[2])) { |
|
297 | + $upcontext['current_step']++; |
|
298 | + } |
|
284 | 299 | } |
285 | 300 | $upcontext['overall_percent'] += $step[3]; |
286 | 301 | } |
@@ -319,17 +334,18 @@ discard block |
||
319 | 334 | // This should not happen my dear... HELP ME DEVELOPERS!! |
320 | 335 | if (!empty($command_line)) |
321 | 336 | { |
322 | - if (function_exists('debug_print_backtrace')) |
|
323 | - debug_print_backtrace(); |
|
337 | + if (function_exists('debug_print_backtrace')) { |
|
338 | + debug_print_backtrace(); |
|
339 | + } |
|
324 | 340 | |
325 | 341 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
326 | 342 | flush(); |
327 | 343 | die(); |
328 | 344 | } |
329 | 345 | |
330 | - if (!isset($_GET['xml'])) |
|
331 | - template_upgrade_above(); |
|
332 | - else |
|
346 | + if (!isset($_GET['xml'])) { |
|
347 | + template_upgrade_above(); |
|
348 | + } else |
|
333 | 349 | { |
334 | 350 | header('Content-Type: text/xml; charset=UTF-8'); |
335 | 351 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -351,21 +367,24 @@ discard block |
||
351 | 367 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
352 | 368 | |
353 | 369 | // Custom stuff to pass back? |
354 | - if (!empty($upcontext['query_string'])) |
|
355 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
370 | + if (!empty($upcontext['query_string'])) { |
|
371 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
372 | + } |
|
356 | 373 | |
357 | 374 | call_user_func('template_' . $upcontext['sub_template']); |
358 | 375 | } |
359 | 376 | |
360 | 377 | // Was there an error? |
361 | - if (!empty($upcontext['forced_error_message'])) |
|
362 | - echo $upcontext['forced_error_message']; |
|
378 | + if (!empty($upcontext['forced_error_message'])) { |
|
379 | + echo $upcontext['forced_error_message']; |
|
380 | + } |
|
363 | 381 | |
364 | 382 | // Show the footer. |
365 | - if (!isset($_GET['xml'])) |
|
366 | - template_upgrade_below(); |
|
367 | - else |
|
368 | - template_xml_below(); |
|
383 | + if (!isset($_GET['xml'])) { |
|
384 | + template_upgrade_below(); |
|
385 | + } else { |
|
386 | + template_xml_below(); |
|
387 | + } |
|
369 | 388 | } |
370 | 389 | |
371 | 390 | |
@@ -377,15 +396,19 @@ discard block |
||
377 | 396 | $seconds = intval($active % 60); |
378 | 397 | |
379 | 398 | $totalTime = ''; |
380 | - if ($hours > 0) |
|
381 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
382 | - if ($minutes > 0) |
|
383 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
384 | - if ($seconds > 0) |
|
385 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
399 | + if ($hours > 0) { |
|
400 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
401 | + } |
|
402 | + if ($minutes > 0) { |
|
403 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
404 | + } |
|
405 | + if ($seconds > 0) { |
|
406 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
407 | + } |
|
386 | 408 | |
387 | - if (!empty($totalTime)) |
|
388 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
409 | + if (!empty($totalTime)) { |
|
410 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
411 | + } |
|
389 | 412 | } |
390 | 413 | |
391 | 414 | // Bang - gone! |
@@ -398,8 +421,9 @@ discard block |
||
398 | 421 | global $upgradeurl, $upcontext, $command_line; |
399 | 422 | |
400 | 423 | // Command line users can't be redirected. |
401 | - if ($command_line) |
|
402 | - upgradeExit(true); |
|
424 | + if ($command_line) { |
|
425 | + upgradeExit(true); |
|
426 | + } |
|
403 | 427 | |
404 | 428 | // Are we providing the core info? |
405 | 429 | if ($addForm) |
@@ -422,19 +446,22 @@ discard block |
||
422 | 446 | global $modSettings, $sourcedir, $smcFunc; |
423 | 447 | |
424 | 448 | // Do the non-SSI stuff... |
425 | - if (function_exists('set_magic_quotes_runtime')) |
|
426 | - @set_magic_quotes_runtime(0); |
|
449 | + if (function_exists('set_magic_quotes_runtime')) { |
|
450 | + @set_magic_quotes_runtime(0); |
|
451 | + } |
|
427 | 452 | |
428 | 453 | error_reporting(E_ALL); |
429 | 454 | define('SMF', 1); |
430 | 455 | |
431 | 456 | // Start the session. |
432 | - if (@ini_get('session.save_handler') == 'user') |
|
433 | - @ini_set('session.save_handler', 'files'); |
|
457 | + if (@ini_get('session.save_handler') == 'user') { |
|
458 | + @ini_set('session.save_handler', 'files'); |
|
459 | + } |
|
434 | 460 | @session_start(); |
435 | 461 | |
436 | - if (empty($smcFunc)) |
|
437 | - $smcFunc = array(); |
|
462 | + if (empty($smcFunc)) { |
|
463 | + $smcFunc = array(); |
|
464 | + } |
|
438 | 465 | |
439 | 466 | // We need this for authentication and some upgrade code |
440 | 467 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -446,8 +473,9 @@ discard block |
||
446 | 473 | initialize_inputs(); |
447 | 474 | |
448 | 475 | // Get the database going! |
449 | - if (empty($db_type) || $db_type == 'mysqli') |
|
450 | - $db_type = 'mysql'; |
|
476 | + if (empty($db_type) || $db_type == 'mysqli') { |
|
477 | + $db_type = 'mysql'; |
|
478 | + } |
|
451 | 479 | |
452 | 480 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
453 | 481 | { |
@@ -457,17 +485,19 @@ discard block |
||
457 | 485 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
458 | 486 | |
459 | 487 | // Oh dear god!! |
460 | - if ($db_connection === null) |
|
461 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
488 | + if ($db_connection === null) { |
|
489 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
490 | + } |
|
462 | 491 | |
463 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
464 | - $smcFunc['db_query']('', ' |
|
492 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
493 | + $smcFunc['db_query']('', ' |
|
465 | 494 | SET NAMES {string:db_character_set}', |
466 | 495 | array( |
467 | 496 | 'db_error_skip' => true, |
468 | 497 | 'db_character_set' => $db_character_set, |
469 | 498 | ) |
470 | 499 | ); |
500 | + } |
|
471 | 501 | |
472 | 502 | // Load the modSettings data... |
473 | 503 | $request = $smcFunc['db_query']('', ' |
@@ -478,11 +508,11 @@ discard block |
||
478 | 508 | ) |
479 | 509 | ); |
480 | 510 | $modSettings = array(); |
481 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
482 | - $modSettings[$row['variable']] = $row['value']; |
|
511 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
512 | + $modSettings[$row['variable']] = $row['value']; |
|
513 | + } |
|
483 | 514 | $smcFunc['db_free_result']($request); |
484 | - } |
|
485 | - else |
|
515 | + } else |
|
486 | 516 | { |
487 | 517 | 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.'); |
488 | 518 | } |
@@ -496,9 +526,10 @@ discard block |
||
496 | 526 | cleanRequest(); |
497 | 527 | } |
498 | 528 | |
499 | - if (!isset($_GET['substep'])) |
|
500 | - $_GET['substep'] = 0; |
|
501 | -} |
|
529 | + if (!isset($_GET['substep'])) { |
|
530 | + $_GET['substep'] = 0; |
|
531 | + } |
|
532 | + } |
|
502 | 533 | |
503 | 534 | function initialize_inputs() |
504 | 535 | { |
@@ -528,8 +559,9 @@ discard block |
||
528 | 559 | $dh = opendir(dirname(__FILE__)); |
529 | 560 | while ($file = readdir($dh)) |
530 | 561 | { |
531 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
532 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
562 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
563 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
564 | + } |
|
533 | 565 | } |
534 | 566 | closedir($dh); |
535 | 567 | |
@@ -559,8 +591,9 @@ discard block |
||
559 | 591 | { |
560 | 592 | $upcontext['remote_files_available'] = false; |
561 | 593 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
562 | - if ($test) |
|
563 | - $upcontext['remote_files_available'] = true; |
|
594 | + if ($test) { |
|
595 | + $upcontext['remote_files_available'] = true; |
|
596 | + } |
|
564 | 597 | @fclose($test); |
565 | 598 | } |
566 | 599 | |
@@ -568,8 +601,9 @@ discard block |
||
568 | 601 | $temp = 'upgrade_php?step'; |
569 | 602 | while (strlen($temp) > 4) |
570 | 603 | { |
571 | - if (isset($_GET[$temp])) |
|
572 | - unset($_GET[$temp]); |
|
604 | + if (isset($_GET[$temp])) { |
|
605 | + unset($_GET[$temp]); |
|
606 | + } |
|
573 | 607 | $temp = substr($temp, 1); |
574 | 608 | } |
575 | 609 | |
@@ -596,32 +630,39 @@ discard block |
||
596 | 630 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
597 | 631 | |
598 | 632 | // Need legacy scripts? |
599 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
600 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
601 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
602 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
603 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
604 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
633 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
634 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
635 | + } |
|
636 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
637 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
638 | + } |
|
639 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
640 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
641 | + } |
|
605 | 642 | |
606 | 643 | // We don't need "-utf8" files anymore... |
607 | 644 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
608 | 645 | |
609 | 646 | // This needs to exist! |
610 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
611 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
612 | - else |
|
613 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
647 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
648 | + 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>]'); |
|
649 | + } else { |
|
650 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
651 | + } |
|
614 | 652 | |
615 | - if (!$check) |
|
616 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
653 | + if (!$check) { |
|
654 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
617 | 655 | 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.'); |
656 | + } |
|
618 | 657 | |
619 | 658 | // Do they meet the install requirements? |
620 | - if (!php_version_check()) |
|
621 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
659 | + if (!php_version_check()) { |
|
660 | + 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.'); |
|
661 | + } |
|
622 | 662 | |
623 | - if (!db_version_check()) |
|
624 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
663 | + if (!db_version_check()) { |
|
664 | + 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.'); |
|
665 | + } |
|
625 | 666 | |
626 | 667 | // Do some checks to make sure they have proper privileges |
627 | 668 | db_extend('packages'); |
@@ -636,14 +677,16 @@ discard block |
||
636 | 677 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
637 | 678 | |
638 | 679 | // Sorry... we need CREATE, ALTER and DROP |
639 | - if (!$create || !$alter || !$drop) |
|
640 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
680 | + if (!$create || !$alter || !$drop) { |
|
681 | + 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.'); |
|
682 | + } |
|
641 | 683 | |
642 | 684 | // Do a quick version spot check. |
643 | 685 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
644 | 686 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
645 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
646 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
687 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
688 | + 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.'); |
|
689 | + } |
|
647 | 690 | |
648 | 691 | // What absolutely needs to be writable? |
649 | 692 | $writable_files = array( |
@@ -665,12 +708,13 @@ discard block |
||
665 | 708 | quickFileWritable($custom_av_dir); |
666 | 709 | |
667 | 710 | // Are we good now? |
668 | - if (!is_writable($custom_av_dir)) |
|
669 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
670 | - elseif ($need_settings_update) |
|
711 | + if (!is_writable($custom_av_dir)) { |
|
712 | + 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)); |
|
713 | + } elseif ($need_settings_update) |
|
671 | 714 | { |
672 | - if (!function_exists('cache_put_data')) |
|
673 | - require_once($sourcedir . '/Load.php'); |
|
715 | + if (!function_exists('cache_put_data')) { |
|
716 | + require_once($sourcedir . '/Load.php'); |
|
717 | + } |
|
674 | 718 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
675 | 719 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
676 | 720 | } |
@@ -679,28 +723,33 @@ discard block |
||
679 | 723 | |
680 | 724 | // Check the cache directory. |
681 | 725 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
682 | - if (!file_exists($cachedir_temp)) |
|
683 | - @mkdir($cachedir_temp); |
|
684 | - if (!file_exists($cachedir_temp)) |
|
685 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
686 | - |
|
687 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
688 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
689 | - elseif (!isset($_GET['skiplang'])) |
|
726 | + if (!file_exists($cachedir_temp)) { |
|
727 | + @mkdir($cachedir_temp); |
|
728 | + } |
|
729 | + if (!file_exists($cachedir_temp)) { |
|
730 | + 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.'); |
|
731 | + } |
|
732 | + |
|
733 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
734 | + 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>.'); |
|
735 | + } elseif (!isset($_GET['skiplang'])) |
|
690 | 736 | { |
691 | 737 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
692 | 738 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
693 | 739 | |
694 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
695 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
740 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
741 | + 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>]'); |
|
742 | + } |
|
696 | 743 | } |
697 | 744 | |
698 | - if (!makeFilesWritable($writable_files)) |
|
699 | - return false; |
|
745 | + if (!makeFilesWritable($writable_files)) { |
|
746 | + return false; |
|
747 | + } |
|
700 | 748 | |
701 | 749 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
702 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
703 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
750 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
751 | + 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.'); |
|
752 | + } |
|
704 | 753 | |
705 | 754 | // Upgrade the agreement. |
706 | 755 | elseif (isset($modSettings['agreement'])) |
@@ -711,8 +760,8 @@ discard block |
||
711 | 760 | } |
712 | 761 | |
713 | 762 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
714 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
715 | - $upcontext['warning'] = ' |
|
763 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
764 | + $upcontext['warning'] = ' |
|
716 | 765 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
717 | 766 | <ul> |
718 | 767 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -720,10 +769,12 @@ discard block |
||
720 | 769 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
721 | 770 | </ul> |
722 | 771 | 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.'; |
772 | + } |
|
723 | 773 | |
724 | 774 | // Either we're logged in or we're going to present the login. |
725 | - if (checkLogin()) |
|
726 | - return true; |
|
775 | + if (checkLogin()) { |
|
776 | + return true; |
|
777 | + } |
|
727 | 778 | |
728 | 779 | $upcontext += createToken('login'); |
729 | 780 | |
@@ -737,15 +788,17 @@ discard block |
||
737 | 788 | global $smcFunc, $db_type, $support_js; |
738 | 789 | |
739 | 790 | // Don't bother if the security is disabled. |
740 | - if ($disable_security) |
|
741 | - return true; |
|
791 | + if ($disable_security) { |
|
792 | + return true; |
|
793 | + } |
|
742 | 794 | |
743 | 795 | // Are we trying to login? |
744 | 796 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
745 | 797 | { |
746 | 798 | // If we've disabled security pick a suitable name! |
747 | - if (empty($_POST['user'])) |
|
748 | - $_POST['user'] = 'Administrator'; |
|
799 | + if (empty($_POST['user'])) { |
|
800 | + $_POST['user'] = 'Administrator'; |
|
801 | + } |
|
749 | 802 | |
750 | 803 | // Before 2.0 these column names were different! |
751 | 804 | $oldDB = false; |
@@ -760,16 +813,17 @@ discard block |
||
760 | 813 | 'db_error_skip' => true, |
761 | 814 | ) |
762 | 815 | ); |
763 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
764 | - $oldDB = true; |
|
816 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
817 | + $oldDB = true; |
|
818 | + } |
|
765 | 819 | $smcFunc['db_free_result']($request); |
766 | 820 | } |
767 | 821 | |
768 | 822 | // Get what we believe to be their details. |
769 | 823 | if (!$disable_security) |
770 | 824 | { |
771 | - if ($oldDB) |
|
772 | - $request = $smcFunc['db_query']('', ' |
|
825 | + if ($oldDB) { |
|
826 | + $request = $smcFunc['db_query']('', ' |
|
773 | 827 | SELECT id_member, memberName AS member_name, passwd, id_group, |
774 | 828 | additionalGroups AS additional_groups, lngfile |
775 | 829 | FROM {db_prefix}members |
@@ -779,8 +833,8 @@ discard block |
||
779 | 833 | 'db_error_skip' => true, |
780 | 834 | ) |
781 | 835 | ); |
782 | - else |
|
783 | - $request = $smcFunc['db_query']('', ' |
|
836 | + } else { |
|
837 | + $request = $smcFunc['db_query']('', ' |
|
784 | 838 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
785 | 839 | FROM {db_prefix}members |
786 | 840 | WHERE member_name = {string:member_name}', |
@@ -789,6 +843,7 @@ discard block |
||
789 | 843 | 'db_error_skip' => true, |
790 | 844 | ) |
791 | 845 | ); |
846 | + } |
|
792 | 847 | if ($smcFunc['db_num_rows']($request) != 0) |
793 | 848 | { |
794 | 849 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -796,13 +851,14 @@ discard block |
||
796 | 851 | $groups = explode(',', $addGroups); |
797 | 852 | $groups[] = $id_group; |
798 | 853 | |
799 | - foreach ($groups as $k => $v) |
|
800 | - $groups[$k] = (int) $v; |
|
854 | + foreach ($groups as $k => $v) { |
|
855 | + $groups[$k] = (int) $v; |
|
856 | + } |
|
801 | 857 | |
802 | 858 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
859 | + } else { |
|
860 | + $upcontext['username_incorrect'] = true; |
|
803 | 861 | } |
804 | - else |
|
805 | - $upcontext['username_incorrect'] = true; |
|
806 | 862 | $smcFunc['db_free_result']($request); |
807 | 863 | } |
808 | 864 | $upcontext['username'] = $_POST['user']; |
@@ -812,13 +868,14 @@ discard block |
||
812 | 868 | { |
813 | 869 | $upcontext['upgrade_status']['js'] = 1; |
814 | 870 | $support_js = 1; |
871 | + } else { |
|
872 | + $support_js = 0; |
|
815 | 873 | } |
816 | - else |
|
817 | - $support_js = 0; |
|
818 | 874 | |
819 | 875 | // Note down the version we are coming from. |
820 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
821 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
876 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
877 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
878 | + } |
|
822 | 879 | |
823 | 880 | // Didn't get anywhere? |
824 | 881 | 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'])) |
@@ -852,15 +909,15 @@ discard block |
||
852 | 909 | 'db_error_skip' => true, |
853 | 910 | ) |
854 | 911 | ); |
855 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
856 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
912 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
913 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
914 | + } |
|
857 | 915 | $smcFunc['db_free_result']($request); |
858 | 916 | } |
859 | 917 | |
860 | 918 | $upcontext['user']['id'] = $id_member; |
861 | 919 | $upcontext['user']['name'] = $name; |
862 | - } |
|
863 | - else |
|
920 | + } else |
|
864 | 921 | { |
865 | 922 | $upcontext['user']['id'] = 1; |
866 | 923 | $upcontext['user']['name'] = 'Administrator'; |
@@ -876,11 +933,11 @@ discard block |
||
876 | 933 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
877 | 934 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
878 | 935 | |
879 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
880 | - $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'] . '.'; |
|
881 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
882 | - $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'] . '.'; |
|
883 | - else |
|
936 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
937 | + $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'] . '.'; |
|
938 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
939 | + $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'] . '.'; |
|
940 | + } else |
|
884 | 941 | { |
885 | 942 | // Set this as the new language. |
886 | 943 | $upcontext['language'] = $user_language; |
@@ -924,8 +981,9 @@ discard block |
||
924 | 981 | unset($member_columns); |
925 | 982 | |
926 | 983 | // If we've not submitted then we're done. |
927 | - if (empty($_POST['upcont'])) |
|
928 | - return false; |
|
984 | + if (empty($_POST['upcont'])) { |
|
985 | + return false; |
|
986 | + } |
|
929 | 987 | |
930 | 988 | // Firstly, if they're enabling SM stat collection just do it. |
931 | 989 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats'])) |
@@ -940,25 +998,26 @@ discard block |
||
940 | 998 | fwrite($fp, $out); |
941 | 999 | |
942 | 1000 | $return_data = ''; |
943 | - while (!feof($fp)) |
|
944 | - $return_data .= fgets($fp, 128); |
|
1001 | + while (!feof($fp)) { |
|
1002 | + $return_data .= fgets($fp, 128); |
|
1003 | + } |
|
945 | 1004 | |
946 | 1005 | fclose($fp); |
947 | 1006 | |
948 | 1007 | // Get the unique site ID. |
949 | 1008 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
950 | 1009 | |
951 | - if (!empty($ID[1])) |
|
952 | - $smcFunc['db_insert']('replace', |
|
1010 | + if (!empty($ID[1])) { |
|
1011 | + $smcFunc['db_insert']('replace', |
|
953 | 1012 | $db_prefix . 'settings', |
954 | 1013 | array('variable' => 'string', 'value' => 'string'), |
955 | 1014 | array('allow_sm_stats', $ID[1]), |
956 | 1015 | array('variable') |
957 | 1016 | ); |
1017 | + } |
|
958 | 1018 | } |
959 | - } |
|
960 | - else |
|
961 | - $smcFunc['db_query']('', ' |
|
1019 | + } else { |
|
1020 | + $smcFunc['db_query']('', ' |
|
962 | 1021 | DELETE FROM {db_prefix}settings |
963 | 1022 | WHERE variable = {string:allow_sm_stats}', |
964 | 1023 | array( |
@@ -966,6 +1025,7 @@ discard block |
||
966 | 1025 | 'db_error_skip' => true, |
967 | 1026 | ) |
968 | 1027 | ); |
1028 | + } |
|
969 | 1029 | |
970 | 1030 | // Deleting old karma stuff? |
971 | 1031 | if (!empty($_POST['delete_karma'])) |
@@ -980,20 +1040,22 @@ discard block |
||
980 | 1040 | ); |
981 | 1041 | |
982 | 1042 | // Cleaning up old karma member settings. |
983 | - if ($upcontext['karma_installed']['good']) |
|
984 | - $smcFunc['db_query']('', ' |
|
1043 | + if ($upcontext['karma_installed']['good']) { |
|
1044 | + $smcFunc['db_query']('', ' |
|
985 | 1045 | ALTER TABLE {db_prefix}members |
986 | 1046 | DROP karma_good', |
987 | 1047 | array() |
988 | 1048 | ); |
1049 | + } |
|
989 | 1050 | |
990 | 1051 | // Does karma bad was enable? |
991 | - if ($upcontext['karma_installed']['bad']) |
|
992 | - $smcFunc['db_query']('', ' |
|
1052 | + if ($upcontext['karma_installed']['bad']) { |
|
1053 | + $smcFunc['db_query']('', ' |
|
993 | 1054 | ALTER TABLE {db_prefix}members |
994 | 1055 | DROP karma_bad', |
995 | 1056 | array() |
996 | 1057 | ); |
1058 | + } |
|
997 | 1059 | |
998 | 1060 | // Cleaning up old karma permissions. |
999 | 1061 | $smcFunc['db_query']('', ' |
@@ -1006,26 +1068,29 @@ discard block |
||
1006 | 1068 | } |
1007 | 1069 | |
1008 | 1070 | // Emptying the error log? |
1009 | - if (!empty($_POST['empty_error'])) |
|
1010 | - $smcFunc['db_query']('truncate_table', ' |
|
1071 | + if (!empty($_POST['empty_error'])) { |
|
1072 | + $smcFunc['db_query']('truncate_table', ' |
|
1011 | 1073 | TRUNCATE {db_prefix}log_errors', |
1012 | 1074 | array( |
1013 | 1075 | ) |
1014 | 1076 | ); |
1077 | + } |
|
1015 | 1078 | |
1016 | 1079 | $changes = array(); |
1017 | 1080 | |
1018 | 1081 | // Add proxy settings. |
1019 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
1020 | - $changes += array( |
|
1082 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
1083 | + $changes += array( |
|
1021 | 1084 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
1022 | 1085 | 'image_proxy_maxsize' => 5190, |
1023 | 1086 | 'image_proxy_enabled' => 0, |
1024 | 1087 | ); |
1088 | + } |
|
1025 | 1089 | |
1026 | 1090 | // If we're overriding the language follow it through. |
1027 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
1028 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1091 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
1092 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1093 | + } |
|
1029 | 1094 | |
1030 | 1095 | if (!empty($_POST['maint'])) |
1031 | 1096 | { |
@@ -1037,30 +1102,34 @@ discard block |
||
1037 | 1102 | { |
1038 | 1103 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
1039 | 1104 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
1040 | - } |
|
1041 | - else |
|
1105 | + } else |
|
1042 | 1106 | { |
1043 | 1107 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
1044 | 1108 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
1045 | 1109 | } |
1046 | 1110 | } |
1047 | 1111 | |
1048 | - if ($command_line) |
|
1049 | - echo ' * Updating Settings.php...'; |
|
1112 | + if ($command_line) { |
|
1113 | + echo ' * Updating Settings.php...'; |
|
1114 | + } |
|
1050 | 1115 | |
1051 | 1116 | // Fix some old paths. |
1052 | - if (substr($boarddir, 0, 1) == '.') |
|
1053 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1117 | + if (substr($boarddir, 0, 1) == '.') { |
|
1118 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1119 | + } |
|
1054 | 1120 | |
1055 | - if (substr($sourcedir, 0, 1) == '.') |
|
1056 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1121 | + if (substr($sourcedir, 0, 1) == '.') { |
|
1122 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1123 | + } |
|
1057 | 1124 | |
1058 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
1059 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1125 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
1126 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1127 | + } |
|
1060 | 1128 | |
1061 | 1129 | // Not had the database type added before? |
1062 | - if (empty($db_type)) |
|
1063 | - $changes['db_type'] = 'mysql'; |
|
1130 | + if (empty($db_type)) { |
|
1131 | + $changes['db_type'] = 'mysql'; |
|
1132 | + } |
|
1064 | 1133 | |
1065 | 1134 | // If they have a "host:port" setup for the host, split that into separate values |
1066 | 1135 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1071,32 +1140,36 @@ discard block |
||
1071 | 1140 | $changes['db_server'] = '\'' . $db_server . '\''; |
1072 | 1141 | |
1073 | 1142 | // Only set this if we're not using the default port |
1074 | - if ($db_port != ini_get('mysqli.default_port')) |
|
1075 | - $changes['db_port'] = (int) $db_port; |
|
1076 | - } |
|
1077 | - elseif (!empty($db_port)) |
|
1143 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
1144 | + $changes['db_port'] = (int) $db_port; |
|
1145 | + } |
|
1146 | + } elseif (!empty($db_port)) |
|
1078 | 1147 | { |
1079 | 1148 | // If db_port is set and is the same as the default, set it to '' |
1080 | 1149 | if ($db_type == 'mysql') |
1081 | 1150 | { |
1082 | - if ($db_port == ini_get('mysqli.default_port')) |
|
1083 | - $changes['db_port'] = '\'\''; |
|
1084 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
1085 | - $changes['db_port'] = '\'\''; |
|
1151 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
1152 | + $changes['db_port'] = '\'\''; |
|
1153 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
1154 | + $changes['db_port'] = '\'\''; |
|
1155 | + } |
|
1086 | 1156 | } |
1087 | 1157 | } |
1088 | 1158 | |
1089 | 1159 | // Maybe we haven't had this option yet? |
1090 | - if (empty($packagesdir)) |
|
1091 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1160 | + if (empty($packagesdir)) { |
|
1161 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1162 | + } |
|
1092 | 1163 | |
1093 | 1164 | // Add support for $tasksdir var. |
1094 | - if (empty($tasksdir)) |
|
1095 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1165 | + if (empty($tasksdir)) { |
|
1166 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1167 | + } |
|
1096 | 1168 | |
1097 | 1169 | // Make sure we fix the language as well. |
1098 | - if (stristr($language, '-utf8')) |
|
1099 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1170 | + if (stristr($language, '-utf8')) { |
|
1171 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1172 | + } |
|
1100 | 1173 | |
1101 | 1174 | // @todo Maybe change the cookie name if going to 1.1, too? |
1102 | 1175 | |
@@ -1104,8 +1177,9 @@ discard block |
||
1104 | 1177 | require_once($sourcedir . '/Subs-Admin.php'); |
1105 | 1178 | updateSettingsFile($changes); |
1106 | 1179 | |
1107 | - if ($command_line) |
|
1108 | - echo ' Successful.' . "\n"; |
|
1180 | + if ($command_line) { |
|
1181 | + echo ' Successful.' . "\n"; |
|
1182 | + } |
|
1109 | 1183 | |
1110 | 1184 | // Are we doing debug? |
1111 | 1185 | if (isset($_POST['debug'])) |
@@ -1115,8 +1189,9 @@ discard block |
||
1115 | 1189 | } |
1116 | 1190 | |
1117 | 1191 | // If we're not backing up then jump one. |
1118 | - if (empty($_POST['backup'])) |
|
1119 | - $upcontext['current_step']++; |
|
1192 | + if (empty($_POST['backup'])) { |
|
1193 | + $upcontext['current_step']++; |
|
1194 | + } |
|
1120 | 1195 | |
1121 | 1196 | // If we've got here then let's proceed to the next step! |
1122 | 1197 | return true; |
@@ -1131,8 +1206,9 @@ discard block |
||
1131 | 1206 | $upcontext['page_title'] = 'Backup Database'; |
1132 | 1207 | |
1133 | 1208 | // Done it already - js wise? |
1134 | - if (!empty($_POST['backup_done'])) |
|
1135 | - return true; |
|
1209 | + if (!empty($_POST['backup_done'])) { |
|
1210 | + return true; |
|
1211 | + } |
|
1136 | 1212 | |
1137 | 1213 | // Some useful stuff here. |
1138 | 1214 | db_extend(); |
@@ -1146,9 +1222,10 @@ discard block |
||
1146 | 1222 | $tables = $smcFunc['db_list_tables']($db, $filter); |
1147 | 1223 | |
1148 | 1224 | $table_names = array(); |
1149 | - foreach ($tables as $table) |
|
1150 | - if (substr($table, 0, 7) !== 'backup_') |
|
1225 | + foreach ($tables as $table) { |
|
1226 | + if (substr($table, 0, 7) !== 'backup_') |
|
1151 | 1227 | $table_names[] = $table; |
1228 | + } |
|
1152 | 1229 | |
1153 | 1230 | $upcontext['table_count'] = count($table_names); |
1154 | 1231 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1158,12 +1235,14 @@ discard block |
||
1158 | 1235 | $file_steps = $upcontext['table_count']; |
1159 | 1236 | |
1160 | 1237 | // What ones have we already done? |
1161 | - foreach ($table_names as $id => $table) |
|
1162 | - if ($id < $_GET['substep']) |
|
1238 | + foreach ($table_names as $id => $table) { |
|
1239 | + if ($id < $_GET['substep']) |
|
1163 | 1240 | $upcontext['previous_tables'][] = $table; |
1241 | + } |
|
1164 | 1242 | |
1165 | - if ($command_line) |
|
1166 | - echo 'Backing Up Tables.'; |
|
1243 | + if ($command_line) { |
|
1244 | + echo 'Backing Up Tables.'; |
|
1245 | + } |
|
1167 | 1246 | |
1168 | 1247 | // If we don't support javascript we backup here. |
1169 | 1248 | if (!$support_js || isset($_GET['xml'])) |
@@ -1182,8 +1261,9 @@ discard block |
||
1182 | 1261 | backupTable($table_names[$substep]); |
1183 | 1262 | |
1184 | 1263 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1185 | - if (isset($_GET['xml'])) |
|
1186 | - return upgradeExit(); |
|
1264 | + if (isset($_GET['xml'])) { |
|
1265 | + return upgradeExit(); |
|
1266 | + } |
|
1187 | 1267 | } |
1188 | 1268 | |
1189 | 1269 | if ($command_line) |
@@ -1216,9 +1296,10 @@ discard block |
||
1216 | 1296 | |
1217 | 1297 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
1218 | 1298 | |
1219 | - if ($command_line) |
|
1220 | - echo ' done.'; |
|
1221 | -} |
|
1299 | + if ($command_line) { |
|
1300 | + echo ' done.'; |
|
1301 | + } |
|
1302 | + } |
|
1222 | 1303 | |
1223 | 1304 | // Step 2: Everything. |
1224 | 1305 | function DatabaseChanges() |
@@ -1227,8 +1308,9 @@ discard block |
||
1227 | 1308 | global $upcontext, $support_js, $db_type; |
1228 | 1309 | |
1229 | 1310 | // Have we just completed this? |
1230 | - if (!empty($_POST['database_done'])) |
|
1231 | - return true; |
|
1311 | + if (!empty($_POST['database_done'])) { |
|
1312 | + return true; |
|
1313 | + } |
|
1232 | 1314 | |
1233 | 1315 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
1234 | 1316 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1243,15 +1325,16 @@ discard block |
||
1243 | 1325 | ); |
1244 | 1326 | |
1245 | 1327 | // How many files are there in total? |
1246 | - if (isset($_GET['filecount'])) |
|
1247 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1248 | - else |
|
1328 | + if (isset($_GET['filecount'])) { |
|
1329 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1330 | + } else |
|
1249 | 1331 | { |
1250 | 1332 | $upcontext['file_count'] = 0; |
1251 | 1333 | foreach ($files as $file) |
1252 | 1334 | { |
1253 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
1254 | - $upcontext['file_count']++; |
|
1335 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
1336 | + $upcontext['file_count']++; |
|
1337 | + } |
|
1255 | 1338 | } |
1256 | 1339 | } |
1257 | 1340 | |
@@ -1261,9 +1344,9 @@ discard block |
||
1261 | 1344 | $upcontext['cur_file_num'] = 0; |
1262 | 1345 | foreach ($files as $file) |
1263 | 1346 | { |
1264 | - if ($did_not_do) |
|
1265 | - $did_not_do--; |
|
1266 | - else |
|
1347 | + if ($did_not_do) { |
|
1348 | + $did_not_do--; |
|
1349 | + } else |
|
1267 | 1350 | { |
1268 | 1351 | $upcontext['cur_file_num']++; |
1269 | 1352 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1290,12 +1373,13 @@ discard block |
||
1290 | 1373 | // Flag to move on to the next. |
1291 | 1374 | $upcontext['completed_step'] = true; |
1292 | 1375 | // Did we complete the whole file? |
1293 | - if ($nextFile) |
|
1294 | - $upcontext['current_debug_item_num'] = -1; |
|
1376 | + if ($nextFile) { |
|
1377 | + $upcontext['current_debug_item_num'] = -1; |
|
1378 | + } |
|
1295 | 1379 | return upgradeExit(); |
1380 | + } elseif ($support_js) { |
|
1381 | + break; |
|
1296 | 1382 | } |
1297 | - elseif ($support_js) |
|
1298 | - break; |
|
1299 | 1383 | } |
1300 | 1384 | // Set the progress bar to be right as if we had - even if we hadn't... |
1301 | 1385 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1320,8 +1404,9 @@ discard block |
||
1320 | 1404 | global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
1321 | 1405 | |
1322 | 1406 | // Now it's nice to have some of the basic SMF source files. |
1323 | - if (!isset($_GET['ssi']) && !$command_line) |
|
1324 | - redirectLocation('&ssi=1'); |
|
1407 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
1408 | + redirectLocation('&ssi=1'); |
|
1409 | + } |
|
1325 | 1410 | |
1326 | 1411 | $upcontext['sub_template'] = 'upgrade_complete'; |
1327 | 1412 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1337,14 +1422,16 @@ discard block |
||
1337 | 1422 | // Are we in maintenance mode? |
1338 | 1423 | if (isset($upcontext['user']['main'])) |
1339 | 1424 | { |
1340 | - if ($command_line) |
|
1341 | - echo ' * '; |
|
1425 | + if ($command_line) { |
|
1426 | + echo ' * '; |
|
1427 | + } |
|
1342 | 1428 | $upcontext['removed_maintenance'] = true; |
1343 | 1429 | $changes['maintenance'] = $upcontext['user']['main']; |
1344 | 1430 | } |
1345 | 1431 | // Otherwise if somehow we are in 2 let's go to 1. |
1346 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
1347 | - $changes['maintenance'] = 1; |
|
1432 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
1433 | + $changes['maintenance'] = 1; |
|
1434 | + } |
|
1348 | 1435 | |
1349 | 1436 | // Wipe this out... |
1350 | 1437 | $upcontext['user'] = array(); |
@@ -1359,9 +1446,9 @@ discard block |
||
1359 | 1446 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1360 | 1447 | |
1361 | 1448 | // Now is the perfect time to fetch the SM files. |
1362 | - if ($command_line) |
|
1363 | - cli_scheduled_fetchSMfiles(); |
|
1364 | - else |
|
1449 | + if ($command_line) { |
|
1450 | + cli_scheduled_fetchSMfiles(); |
|
1451 | + } else |
|
1365 | 1452 | { |
1366 | 1453 | require_once($sourcedir . '/ScheduledTasks.php'); |
1367 | 1454 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1369,8 +1456,9 @@ discard block |
||
1369 | 1456 | } |
1370 | 1457 | |
1371 | 1458 | // Log what we've done. |
1372 | - if (empty($user_info['id'])) |
|
1373 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1459 | + if (empty($user_info['id'])) { |
|
1460 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1461 | + } |
|
1374 | 1462 | |
1375 | 1463 | // Log the action manually, so CLI still works. |
1376 | 1464 | $smcFunc['db_insert']('', |
@@ -1389,8 +1477,9 @@ discard block |
||
1389 | 1477 | |
1390 | 1478 | // Save the current database version. |
1391 | 1479 | $server_version = $smcFunc['db_server_info'](); |
1392 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1393 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1480 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1481 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1482 | + } |
|
1394 | 1483 | |
1395 | 1484 | if ($command_line) |
1396 | 1485 | { |
@@ -1402,8 +1491,9 @@ discard block |
||
1402 | 1491 | |
1403 | 1492 | // Make sure it says we're done. |
1404 | 1493 | $upcontext['overall_percent'] = 100; |
1405 | - if (isset($upcontext['step_progress'])) |
|
1406 | - unset($upcontext['step_progress']); |
|
1494 | + if (isset($upcontext['step_progress'])) { |
|
1495 | + unset($upcontext['step_progress']); |
|
1496 | + } |
|
1407 | 1497 | |
1408 | 1498 | $_GET['substep'] = 0; |
1409 | 1499 | return false; |
@@ -1414,8 +1504,9 @@ discard block |
||
1414 | 1504 | { |
1415 | 1505 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
1416 | 1506 | |
1417 | - if (empty($modSettings['time_format'])) |
|
1418 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1507 | + if (empty($modSettings['time_format'])) { |
|
1508 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1509 | + } |
|
1419 | 1510 | |
1420 | 1511 | // What files do we want to get |
1421 | 1512 | $request = $smcFunc['db_query']('', ' |
@@ -1449,8 +1540,9 @@ discard block |
||
1449 | 1540 | $file_data = fetch_web_data($url); |
1450 | 1541 | |
1451 | 1542 | // If we got an error - give up - the site might be down. |
1452 | - if ($file_data === false) |
|
1453 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1543 | + if ($file_data === false) { |
|
1544 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1545 | + } |
|
1454 | 1546 | |
1455 | 1547 | // Save the file to the database. |
1456 | 1548 | $smcFunc['db_query']('substring', ' |
@@ -1492,8 +1584,9 @@ discard block |
||
1492 | 1584 | $themeData = array(); |
1493 | 1585 | foreach ($values as $variable => $value) |
1494 | 1586 | { |
1495 | - if (!isset($value) || $value === null) |
|
1496 | - $value = 0; |
|
1587 | + if (!isset($value) || $value === null) { |
|
1588 | + $value = 0; |
|
1589 | + } |
|
1497 | 1590 | |
1498 | 1591 | $themeData[] = array(0, 1, $variable, $value); |
1499 | 1592 | } |
@@ -1522,8 +1615,9 @@ discard block |
||
1522 | 1615 | |
1523 | 1616 | foreach ($values as $variable => $value) |
1524 | 1617 | { |
1525 | - if (empty($modSettings[$value[0]])) |
|
1526 | - continue; |
|
1618 | + if (empty($modSettings[$value[0]])) { |
|
1619 | + continue; |
|
1620 | + } |
|
1527 | 1621 | |
1528 | 1622 | $smcFunc['db_query']('', ' |
1529 | 1623 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1609,10 +1703,11 @@ discard block |
||
1609 | 1703 | set_error_handler( |
1610 | 1704 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
1611 | 1705 | { |
1612 | - if ($support_js) |
|
1613 | - return true; |
|
1614 | - else |
|
1615 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1706 | + if ($support_js) { |
|
1707 | + return true; |
|
1708 | + } else { |
|
1709 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1710 | + } |
|
1616 | 1711 | } |
1617 | 1712 | ); |
1618 | 1713 | |
@@ -1627,8 +1722,9 @@ discard block |
||
1627 | 1722 | 'db_error_skip' => true, |
1628 | 1723 | ) |
1629 | 1724 | ); |
1630 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1631 | - die('Unable to find members table!'); |
|
1725 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1726 | + die('Unable to find members table!'); |
|
1727 | + } |
|
1632 | 1728 | $table_status = $smcFunc['db_fetch_assoc']($request); |
1633 | 1729 | $smcFunc['db_free_result']($request); |
1634 | 1730 | |
@@ -1643,17 +1739,20 @@ discard block |
||
1643 | 1739 | ) |
1644 | 1740 | ); |
1645 | 1741 | // Got something? |
1646 | - if ($smcFunc['db_num_rows']($request) !== 0) |
|
1647 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
1742 | + if ($smcFunc['db_num_rows']($request) !== 0) { |
|
1743 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
1744 | + } |
|
1648 | 1745 | $smcFunc['db_free_result']($request); |
1649 | 1746 | |
1650 | 1747 | // Excellent! |
1651 | - if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) |
|
1652 | - $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
1748 | + if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) { |
|
1749 | + $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
1750 | + } |
|
1653 | 1751 | } |
1654 | 1752 | } |
1655 | - if (empty($db_collation)) |
|
1656 | - $db_collation = ''; |
|
1753 | + if (empty($db_collation)) { |
|
1754 | + $db_collation = ''; |
|
1755 | + } |
|
1657 | 1756 | |
1658 | 1757 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
1659 | 1758 | |
@@ -1665,8 +1764,9 @@ discard block |
||
1665 | 1764 | $last_step = ''; |
1666 | 1765 | |
1667 | 1766 | // Make sure all newly created tables will have the proper characters set. |
1668 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
1669 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1767 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
1768 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1769 | + } |
|
1670 | 1770 | |
1671 | 1771 | // Count the total number of steps within this file - for progress. |
1672 | 1772 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1686,15 +1786,18 @@ discard block |
||
1686 | 1786 | $do_current = $substep >= $_GET['substep']; |
1687 | 1787 | |
1688 | 1788 | // Get rid of any comments in the beginning of the line... |
1689 | - if (substr(trim($line), 0, 2) === '/*') |
|
1690 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1789 | + if (substr(trim($line), 0, 2) === '/*') { |
|
1790 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1791 | + } |
|
1691 | 1792 | |
1692 | 1793 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
1693 | - if ($is_debug && !$support_js && $command_line) |
|
1694 | - flush(); |
|
1794 | + if ($is_debug && !$support_js && $command_line) { |
|
1795 | + flush(); |
|
1796 | + } |
|
1695 | 1797 | |
1696 | - if (trim($line) === '') |
|
1697 | - continue; |
|
1798 | + if (trim($line) === '') { |
|
1799 | + continue; |
|
1800 | + } |
|
1698 | 1801 | |
1699 | 1802 | if (trim(substr($line, 0, 3)) === '---') |
1700 | 1803 | { |
@@ -1704,8 +1807,9 @@ discard block |
||
1704 | 1807 | if (trim($current_data) != '' && $type !== '}') |
1705 | 1808 | { |
1706 | 1809 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
1707 | - if ($command_line) |
|
1708 | - echo $upcontext['error_message']; |
|
1810 | + if ($command_line) { |
|
1811 | + echo $upcontext['error_message']; |
|
1812 | + } |
|
1709 | 1813 | } |
1710 | 1814 | |
1711 | 1815 | if ($type == ' ') |
@@ -1723,17 +1827,18 @@ discard block |
||
1723 | 1827 | if ($do_current) |
1724 | 1828 | { |
1725 | 1829 | $upcontext['actioned_items'][] = $last_step; |
1726 | - if ($command_line) |
|
1727 | - echo ' * '; |
|
1830 | + if ($command_line) { |
|
1831 | + echo ' * '; |
|
1832 | + } |
|
1728 | 1833 | } |
1729 | - } |
|
1730 | - elseif ($type == '#') |
|
1834 | + } elseif ($type == '#') |
|
1731 | 1835 | { |
1732 | 1836 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
1733 | 1837 | |
1734 | 1838 | $upcontext['current_debug_item_num']++; |
1735 | - if (trim($line) != '---#') |
|
1736 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1839 | + if (trim($line) != '---#') { |
|
1840 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1841 | + } |
|
1737 | 1842 | |
1738 | 1843 | // Have we already done something? |
1739 | 1844 | if (isset($_GET['xml']) && $done_something) |
@@ -1744,34 +1849,36 @@ discard block |
||
1744 | 1849 | |
1745 | 1850 | if ($do_current) |
1746 | 1851 | { |
1747 | - if (trim($line) == '---#' && $command_line) |
|
1748 | - echo ' done.', $endl; |
|
1749 | - elseif ($command_line) |
|
1750 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
1751 | - elseif (trim($line) != '---#') |
|
1852 | + if (trim($line) == '---#' && $command_line) { |
|
1853 | + echo ' done.', $endl; |
|
1854 | + } elseif ($command_line) { |
|
1855 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
1856 | + } elseif (trim($line) != '---#') |
|
1752 | 1857 | { |
1753 | - if ($is_debug) |
|
1754 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1858 | + if ($is_debug) { |
|
1859 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1860 | + } |
|
1755 | 1861 | } |
1756 | 1862 | } |
1757 | 1863 | |
1758 | 1864 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
1759 | 1865 | { |
1760 | - if ($command_line) |
|
1761 | - echo ' * '; |
|
1762 | - else |
|
1763 | - $upcontext['actioned_items'][] = $last_step; |
|
1866 | + if ($command_line) { |
|
1867 | + echo ' * '; |
|
1868 | + } else { |
|
1869 | + $upcontext['actioned_items'][] = $last_step; |
|
1870 | + } |
|
1764 | 1871 | } |
1765 | 1872 | |
1766 | 1873 | // Small step - only if we're actually doing stuff. |
1767 | - if ($do_current) |
|
1768 | - nextSubstep(++$substep); |
|
1769 | - else |
|
1770 | - $substep++; |
|
1771 | - } |
|
1772 | - elseif ($type == '{') |
|
1773 | - $current_type = 'code'; |
|
1774 | - elseif ($type == '}') |
|
1874 | + if ($do_current) { |
|
1875 | + nextSubstep(++$substep); |
|
1876 | + } else { |
|
1877 | + $substep++; |
|
1878 | + } |
|
1879 | + } elseif ($type == '{') { |
|
1880 | + $current_type = 'code'; |
|
1881 | + } elseif ($type == '}') |
|
1775 | 1882 | { |
1776 | 1883 | $current_type = 'sql'; |
1777 | 1884 | |
@@ -1784,8 +1891,9 @@ discard block |
||
1784 | 1891 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
1785 | 1892 | { |
1786 | 1893 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
1787 | - if ($command_line) |
|
1788 | - echo $upcontext['error_message']; |
|
1894 | + if ($command_line) { |
|
1895 | + echo $upcontext['error_message']; |
|
1896 | + } |
|
1789 | 1897 | } |
1790 | 1898 | |
1791 | 1899 | // Done with code! |
@@ -1865,8 +1973,9 @@ discard block |
||
1865 | 1973 | $db_unbuffered = false; |
1866 | 1974 | |
1867 | 1975 | // Failure?! |
1868 | - if ($result !== false) |
|
1869 | - return $result; |
|
1976 | + if ($result !== false) { |
|
1977 | + return $result; |
|
1978 | + } |
|
1870 | 1979 | |
1871 | 1980 | $db_error_message = $smcFunc['db_error']($db_connection); |
1872 | 1981 | // If MySQL we do something more clever. |
@@ -1894,54 +2003,61 @@ discard block |
||
1894 | 2003 | { |
1895 | 2004 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
1896 | 2005 | $result = mysqli_query($db_connection, $string); |
1897 | - if ($result !== false) |
|
1898 | - return $result; |
|
2006 | + if ($result !== false) { |
|
2007 | + return $result; |
|
2008 | + } |
|
1899 | 2009 | } |
1900 | - } |
|
1901 | - elseif ($mysqli_errno == 2013) |
|
2010 | + } elseif ($mysqli_errno == 2013) |
|
1902 | 2011 | { |
1903 | 2012 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
1904 | 2013 | mysqli_select_db($db_connection, $db_name); |
1905 | 2014 | if ($db_connection) |
1906 | 2015 | { |
1907 | 2016 | $result = mysqli_query($db_connection, $string); |
1908 | - if ($result !== false) |
|
1909 | - return $result; |
|
2017 | + if ($result !== false) { |
|
2018 | + return $result; |
|
2019 | + } |
|
1910 | 2020 | } |
1911 | 2021 | } |
1912 | 2022 | // Duplicate column name... should be okay ;). |
1913 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
1914 | - return false; |
|
2023 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
2024 | + return false; |
|
2025 | + } |
|
1915 | 2026 | // Duplicate insert... make sure it's the proper type of query ;). |
1916 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
1917 | - return false; |
|
2027 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
2028 | + return false; |
|
2029 | + } |
|
1918 | 2030 | // Creating an index on a non-existent column. |
1919 | - elseif ($mysqli_errno == 1072) |
|
1920 | - return false; |
|
1921 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
1922 | - return false; |
|
2031 | + elseif ($mysqli_errno == 1072) { |
|
2032 | + return false; |
|
2033 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
2034 | + return false; |
|
2035 | + } |
|
1923 | 2036 | } |
1924 | 2037 | // If a table already exists don't go potty. |
1925 | 2038 | else |
1926 | 2039 | { |
1927 | 2040 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
1928 | 2041 | { |
1929 | - if (strpos($db_error_message, 'exist') !== false) |
|
1930 | - return true; |
|
1931 | - } |
|
1932 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2042 | + if (strpos($db_error_message, 'exist') !== false) { |
|
2043 | + return true; |
|
2044 | + } |
|
2045 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
1933 | 2046 | { |
1934 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
1935 | - return true; |
|
2047 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
2048 | + return true; |
|
2049 | + } |
|
1936 | 2050 | } |
1937 | 2051 | } |
1938 | 2052 | |
1939 | 2053 | // Get the query string so we pass everything. |
1940 | 2054 | $query_string = ''; |
1941 | - foreach ($_GET as $k => $v) |
|
1942 | - $query_string .= ';' . $k . '=' . $v; |
|
1943 | - if (strlen($query_string) != 0) |
|
1944 | - $query_string = '?' . substr($query_string, 1); |
|
2055 | + foreach ($_GET as $k => $v) { |
|
2056 | + $query_string .= ';' . $k . '=' . $v; |
|
2057 | + } |
|
2058 | + if (strlen($query_string) != 0) { |
|
2059 | + $query_string = '?' . substr($query_string, 1); |
|
2060 | + } |
|
1945 | 2061 | |
1946 | 2062 | if ($command_line) |
1947 | 2063 | { |
@@ -1996,16 +2112,18 @@ discard block |
||
1996 | 2112 | { |
1997 | 2113 | $found |= 1; |
1998 | 2114 | // Do some checks on the data if we have it set. |
1999 | - if (isset($change['col_type'])) |
|
2000 | - $found &= $change['col_type'] === $column['type']; |
|
2001 | - if (isset($change['null_allowed'])) |
|
2002 | - $found &= $column['null'] == $change['null_allowed']; |
|
2003 | - if (isset($change['default'])) |
|
2004 | - $found &= $change['default'] === $column['default']; |
|
2115 | + if (isset($change['col_type'])) { |
|
2116 | + $found &= $change['col_type'] === $column['type']; |
|
2117 | + } |
|
2118 | + if (isset($change['null_allowed'])) { |
|
2119 | + $found &= $column['null'] == $change['null_allowed']; |
|
2120 | + } |
|
2121 | + if (isset($change['default'])) { |
|
2122 | + $found &= $change['default'] === $column['default']; |
|
2123 | + } |
|
2005 | 2124 | } |
2006 | 2125 | } |
2007 | - } |
|
2008 | - elseif ($change['type'] === 'index') |
|
2126 | + } elseif ($change['type'] === 'index') |
|
2009 | 2127 | { |
2010 | 2128 | $request = upgrade_query(' |
2011 | 2129 | SHOW INDEX |
@@ -2014,9 +2132,10 @@ discard block |
||
2014 | 2132 | { |
2015 | 2133 | $cur_index = array(); |
2016 | 2134 | |
2017 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2018 | - if ($row['Key_name'] === $change['name']) |
|
2135 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2136 | + if ($row['Key_name'] === $change['name']) |
|
2019 | 2137 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2138 | + } |
|
2020 | 2139 | |
2021 | 2140 | ksort($cur_index, SORT_NUMERIC); |
2022 | 2141 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2026,14 +2145,17 @@ discard block |
||
2026 | 2145 | } |
2027 | 2146 | |
2028 | 2147 | // If we're trying to add and it's added, we're done. |
2029 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
2030 | - return true; |
|
2148 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
2149 | + return true; |
|
2150 | + } |
|
2031 | 2151 | // Otherwise if we're removing and it wasn't found we're also done. |
2032 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
2033 | - return true; |
|
2152 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
2153 | + return true; |
|
2154 | + } |
|
2034 | 2155 | // Otherwise is it just a test? |
2035 | - elseif ($is_test) |
|
2036 | - return false; |
|
2156 | + elseif ($is_test) { |
|
2157 | + return false; |
|
2158 | + } |
|
2037 | 2159 | |
2038 | 2160 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
2039 | 2161 | $running = false; |
@@ -2044,8 +2166,9 @@ discard block |
||
2044 | 2166 | SHOW FULL PROCESSLIST'); |
2045 | 2167 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2046 | 2168 | { |
2047 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
2048 | - $found = true; |
|
2169 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
2170 | + $found = true; |
|
2171 | + } |
|
2049 | 2172 | } |
2050 | 2173 | |
2051 | 2174 | // Can't find it? Then we need to run it fools! |
@@ -2057,8 +2180,9 @@ discard block |
||
2057 | 2180 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
2058 | 2181 | ' . $change['text'], true) !== false; |
2059 | 2182 | |
2060 | - if (!$success) |
|
2061 | - return false; |
|
2183 | + if (!$success) { |
|
2184 | + return false; |
|
2185 | + } |
|
2062 | 2186 | |
2063 | 2187 | // Return |
2064 | 2188 | $running = true; |
@@ -2100,8 +2224,9 @@ discard block |
||
2100 | 2224 | 'db_error_skip' => true, |
2101 | 2225 | ) |
2102 | 2226 | ); |
2103 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2104 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2227 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2228 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2229 | + } |
|
2105 | 2230 | $table_row = $smcFunc['db_fetch_assoc']($request); |
2106 | 2231 | $smcFunc['db_free_result']($request); |
2107 | 2232 | |
@@ -2123,18 +2248,19 @@ discard block |
||
2123 | 2248 | ) |
2124 | 2249 | ); |
2125 | 2250 | // No results? Just forget it all together. |
2126 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2127 | - unset($table_row['Collation']); |
|
2128 | - else |
|
2129 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2251 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2252 | + unset($table_row['Collation']); |
|
2253 | + } else { |
|
2254 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2255 | + } |
|
2130 | 2256 | $smcFunc['db_free_result']($request); |
2131 | 2257 | } |
2132 | 2258 | |
2133 | 2259 | if ($column_fix) |
2134 | 2260 | { |
2135 | 2261 | // Make sure there are no NULL's left. |
2136 | - if ($null_fix) |
|
2137 | - $smcFunc['db_query']('', ' |
|
2262 | + if ($null_fix) { |
|
2263 | + $smcFunc['db_query']('', ' |
|
2138 | 2264 | UPDATE {db_prefix}' . $change['table'] . ' |
2139 | 2265 | SET ' . $change['column'] . ' = {string:default} |
2140 | 2266 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2143,6 +2269,7 @@ discard block |
||
2143 | 2269 | 'db_error_skip' => true, |
2144 | 2270 | ) |
2145 | 2271 | ); |
2272 | + } |
|
2146 | 2273 | |
2147 | 2274 | // Do the actual alteration. |
2148 | 2275 | $smcFunc['db_query']('', ' |
@@ -2171,8 +2298,9 @@ discard block |
||
2171 | 2298 | } |
2172 | 2299 | |
2173 | 2300 | // Not a column we need to check on? |
2174 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
2175 | - return; |
|
2301 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
2302 | + return; |
|
2303 | + } |
|
2176 | 2304 | |
2177 | 2305 | // Break it up you (six|seven). |
2178 | 2306 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2191,13 +2319,13 @@ discard block |
||
2191 | 2319 | 'new_name' => $temp[2], |
2192 | 2320 | )); |
2193 | 2321 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2194 | - if ($smcFunc['db_num_rows'] != 1) |
|
2195 | - return; |
|
2322 | + if ($smcFunc['db_num_rows'] != 1) { |
|
2323 | + return; |
|
2324 | + } |
|
2196 | 2325 | |
2197 | 2326 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
2198 | 2327 | $smcFunc['db_free_result']($request); |
2199 | - } |
|
2200 | - else |
|
2328 | + } else |
|
2201 | 2329 | { |
2202 | 2330 | // Do this the old fashion, sure method way. |
2203 | 2331 | $request = $smcFunc['db_query']('', ' |
@@ -2208,21 +2336,24 @@ discard block |
||
2208 | 2336 | )); |
2209 | 2337 | // Mayday! |
2210 | 2338 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2211 | - if ($smcFunc['db_num_rows'] == 0) |
|
2212 | - return; |
|
2339 | + if ($smcFunc['db_num_rows'] == 0) { |
|
2340 | + return; |
|
2341 | + } |
|
2213 | 2342 | |
2214 | 2343 | // Oh where, oh where has my little field gone. Oh where can it be... |
2215 | - while ($row = $smcFunc['db_query']($request)) |
|
2216 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2344 | + while ($row = $smcFunc['db_query']($request)) { |
|
2345 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2217 | 2346 | { |
2218 | 2347 | $current_type = $row['Type']; |
2348 | + } |
|
2219 | 2349 | break; |
2220 | 2350 | } |
2221 | 2351 | } |
2222 | 2352 | |
2223 | 2353 | // If this doesn't match, the column may of been altered for a reason. |
2224 | - if (trim($current_type) != trim($temp[3])) |
|
2225 | - $temp[3] = $current_type; |
|
2354 | + if (trim($current_type) != trim($temp[3])) { |
|
2355 | + $temp[3] = $current_type; |
|
2356 | + } |
|
2226 | 2357 | |
2227 | 2358 | // Piece this back together. |
2228 | 2359 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2234,8 +2365,9 @@ discard block |
||
2234 | 2365 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2235 | 2366 | global $step_progress, $is_debug, $upcontext; |
2236 | 2367 | |
2237 | - if ($_GET['substep'] < $substep) |
|
2238 | - $_GET['substep'] = $substep; |
|
2368 | + if ($_GET['substep'] < $substep) { |
|
2369 | + $_GET['substep'] = $substep; |
|
2370 | + } |
|
2239 | 2371 | |
2240 | 2372 | if ($command_line) |
2241 | 2373 | { |
@@ -2248,29 +2380,33 @@ discard block |
||
2248 | 2380 | } |
2249 | 2381 | |
2250 | 2382 | @set_time_limit(300); |
2251 | - if (function_exists('apache_reset_timeout')) |
|
2252 | - @apache_reset_timeout(); |
|
2383 | + if (function_exists('apache_reset_timeout')) { |
|
2384 | + @apache_reset_timeout(); |
|
2385 | + } |
|
2253 | 2386 | |
2254 | - if (time() - $start_time <= $timeLimitThreshold) |
|
2255 | - return; |
|
2387 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
2388 | + return; |
|
2389 | + } |
|
2256 | 2390 | |
2257 | 2391 | // Do we have some custom step progress stuff? |
2258 | 2392 | if (!empty($step_progress)) |
2259 | 2393 | { |
2260 | 2394 | $upcontext['substep_progress'] = 0; |
2261 | 2395 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2262 | - if ($step_progress['current'] > $step_progress['total']) |
|
2263 | - $upcontext['substep_progress'] = 99.9; |
|
2264 | - else |
|
2265 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2396 | + if ($step_progress['current'] > $step_progress['total']) { |
|
2397 | + $upcontext['substep_progress'] = 99.9; |
|
2398 | + } else { |
|
2399 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2400 | + } |
|
2266 | 2401 | |
2267 | 2402 | // Make it nicely rounded. |
2268 | 2403 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
2269 | 2404 | } |
2270 | 2405 | |
2271 | 2406 | // If this is XML we just exit right away! |
2272 | - if (isset($_GET['xml'])) |
|
2273 | - return upgradeExit(); |
|
2407 | + if (isset($_GET['xml'])) { |
|
2408 | + return upgradeExit(); |
|
2409 | + } |
|
2274 | 2410 | |
2275 | 2411 | // We're going to pause after this! |
2276 | 2412 | $upcontext['pause'] = true; |
@@ -2278,13 +2414,15 @@ discard block |
||
2278 | 2414 | $upcontext['query_string'] = ''; |
2279 | 2415 | foreach ($_GET as $k => $v) |
2280 | 2416 | { |
2281 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
2282 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2417 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
2418 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2419 | + } |
|
2283 | 2420 | } |
2284 | 2421 | |
2285 | 2422 | // Custom warning? |
2286 | - if (!empty($custom_warning)) |
|
2287 | - $upcontext['custom_warning'] = $custom_warning; |
|
2423 | + if (!empty($custom_warning)) { |
|
2424 | + $upcontext['custom_warning'] = $custom_warning; |
|
2425 | + } |
|
2288 | 2426 | |
2289 | 2427 | upgradeExit(); |
2290 | 2428 | } |
@@ -2299,25 +2437,26 @@ discard block |
||
2299 | 2437 | ob_implicit_flush(true); |
2300 | 2438 | @set_time_limit(600); |
2301 | 2439 | |
2302 | - if (!isset($_SERVER['argv'])) |
|
2303 | - $_SERVER['argv'] = array(); |
|
2440 | + if (!isset($_SERVER['argv'])) { |
|
2441 | + $_SERVER['argv'] = array(); |
|
2442 | + } |
|
2304 | 2443 | $_GET['maint'] = 1; |
2305 | 2444 | |
2306 | 2445 | foreach ($_SERVER['argv'] as $i => $arg) |
2307 | 2446 | { |
2308 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
2309 | - $_GET['lang'] = $match[1]; |
|
2310 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
2311 | - continue; |
|
2312 | - elseif ($arg == '--no-maintenance') |
|
2313 | - $_GET['maint'] = 0; |
|
2314 | - elseif ($arg == '--debug') |
|
2315 | - $is_debug = true; |
|
2316 | - elseif ($arg == '--backup') |
|
2317 | - $_POST['backup'] = 1; |
|
2318 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
2319 | - $_GET['conv'] = 1; |
|
2320 | - elseif ($i != 0) |
|
2447 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
2448 | + $_GET['lang'] = $match[1]; |
|
2449 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
2450 | + continue; |
|
2451 | + } elseif ($arg == '--no-maintenance') { |
|
2452 | + $_GET['maint'] = 0; |
|
2453 | + } elseif ($arg == '--debug') { |
|
2454 | + $is_debug = true; |
|
2455 | + } elseif ($arg == '--backup') { |
|
2456 | + $_POST['backup'] = 1; |
|
2457 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
2458 | + $_GET['conv'] = 1; |
|
2459 | + } elseif ($i != 0) |
|
2321 | 2460 | { |
2322 | 2461 | echo 'SMF Command-line Upgrader |
2323 | 2462 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2331,10 +2470,12 @@ discard block |
||
2331 | 2470 | } |
2332 | 2471 | } |
2333 | 2472 | |
2334 | - if (!php_version_check()) |
|
2335 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2336 | - if (!db_version_check()) |
|
2337 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2473 | + if (!php_version_check()) { |
|
2474 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2475 | + } |
|
2476 | + if (!db_version_check()) { |
|
2477 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2478 | + } |
|
2338 | 2479 | |
2339 | 2480 | // Do some checks to make sure they have proper privileges |
2340 | 2481 | db_extend('packages'); |
@@ -2349,34 +2490,39 @@ discard block |
||
2349 | 2490 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
2350 | 2491 | |
2351 | 2492 | // Sorry... we need CREATE, ALTER and DROP |
2352 | - if (!$create || !$alter || !$drop) |
|
2353 | - 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); |
|
2493 | + if (!$create || !$alter || !$drop) { |
|
2494 | + 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); |
|
2495 | + } |
|
2354 | 2496 | |
2355 | 2497 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
2356 | 2498 | && @file_exists($sourcedir . '/QueryString.php') |
2357 | 2499 | && @file_exists($sourcedir . '/ManageBoards.php'); |
2358 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
2359 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
2500 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
2501 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
2502 | + } |
|
2360 | 2503 | |
2361 | 2504 | // Do a quick version spot check. |
2362 | 2505 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
2363 | 2506 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2364 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
2365 | - print_error('Error: Some files have not yet been updated properly.'); |
|
2507 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
2508 | + print_error('Error: Some files have not yet been updated properly.'); |
|
2509 | + } |
|
2366 | 2510 | |
2367 | 2511 | // Make sure Settings.php is writable. |
2368 | 2512 | quickFileWritable($boarddir . '/Settings.php'); |
2369 | - if (!is_writable($boarddir . '/Settings.php')) |
|
2370 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2513 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
2514 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2515 | + } |
|
2371 | 2516 | |
2372 | 2517 | // Make sure Settings_bak.php is writable. |
2373 | 2518 | quickFileWritable($boarddir . '/Settings_bak.php'); |
2374 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
2375 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2519 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
2520 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2521 | + } |
|
2376 | 2522 | |
2377 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
2378 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2379 | - elseif (isset($modSettings['agreement'])) |
|
2523 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
2524 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2525 | + } elseif (isset($modSettings['agreement'])) |
|
2380 | 2526 | { |
2381 | 2527 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
2382 | 2528 | fwrite($fp, $modSettings['agreement']); |
@@ -2386,31 +2532,36 @@ discard block |
||
2386 | 2532 | // Make sure Themes is writable. |
2387 | 2533 | quickFileWritable($modSettings['theme_dir']); |
2388 | 2534 | |
2389 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
2390 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
2535 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
2536 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
2537 | + } |
|
2391 | 2538 | |
2392 | 2539 | // Make sure cache directory exists and is writable! |
2393 | 2540 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
2394 | - if (!file_exists($cachedir_temp)) |
|
2395 | - @mkdir($cachedir_temp); |
|
2541 | + if (!file_exists($cachedir_temp)) { |
|
2542 | + @mkdir($cachedir_temp); |
|
2543 | + } |
|
2396 | 2544 | |
2397 | 2545 | // Make sure the cache temp dir is writable. |
2398 | 2546 | quickFileWritable($cachedir_temp); |
2399 | 2547 | |
2400 | - if (!is_writable($cachedir_temp)) |
|
2401 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
2548 | + if (!is_writable($cachedir_temp)) { |
|
2549 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
2550 | + } |
|
2402 | 2551 | |
2403 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
2404 | - print_error('Error: Unable to find language files!', true); |
|
2405 | - else |
|
2552 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
2553 | + print_error('Error: Unable to find language files!', true); |
|
2554 | + } else |
|
2406 | 2555 | { |
2407 | 2556 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
2408 | 2557 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
2409 | 2558 | |
2410 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
2411 | - print_error('Error: Language files out of date.', true); |
|
2412 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
2413 | - print_error('Error: Install language is missing for selected language.', true); |
|
2559 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
2560 | + print_error('Error: Language files out of date.', true); |
|
2561 | + } |
|
2562 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
2563 | + print_error('Error: Install language is missing for selected language.', true); |
|
2564 | + } |
|
2414 | 2565 | |
2415 | 2566 | // Otherwise include it! |
2416 | 2567 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2439,8 +2590,7 @@ discard block |
||
2439 | 2590 | ); |
2440 | 2591 | |
2441 | 2592 | return true; |
2442 | - } |
|
2443 | - else |
|
2593 | + } else |
|
2444 | 2594 | { |
2445 | 2595 | $upcontext['page_title'] = 'Converting to UTF8'; |
2446 | 2596 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2484,8 +2634,9 @@ discard block |
||
2484 | 2634 | ) |
2485 | 2635 | ); |
2486 | 2636 | $db_charsets = array(); |
2487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2488 | - $db_charsets[] = $row['Charset']; |
|
2637 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2638 | + $db_charsets[] = $row['Charset']; |
|
2639 | + } |
|
2489 | 2640 | |
2490 | 2641 | $smcFunc['db_free_result']($request); |
2491 | 2642 | |
@@ -2521,13 +2672,15 @@ discard block |
||
2521 | 2672 | // If there's a fulltext index, we need to drop it first... |
2522 | 2673 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
2523 | 2674 | { |
2524 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2525 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2676 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2526 | 2677 | $upcontext['fulltext_index'][] = $row['Key_name']; |
2678 | + } |
|
2527 | 2679 | $smcFunc['db_free_result']($request); |
2528 | 2680 | |
2529 | - if (isset($upcontext['fulltext_index'])) |
|
2530 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2681 | + if (isset($upcontext['fulltext_index'])) { |
|
2682 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2683 | + } |
|
2531 | 2684 | } |
2532 | 2685 | |
2533 | 2686 | // Drop it and make a note... |
@@ -2717,8 +2870,9 @@ discard block |
||
2717 | 2870 | $replace = '%field%'; |
2718 | 2871 | |
2719 | 2872 | // Build a huge REPLACE statement... |
2720 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
2721 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2873 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
2874 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2875 | + } |
|
2722 | 2876 | } |
2723 | 2877 | |
2724 | 2878 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2752,8 +2906,9 @@ discard block |
||
2752 | 2906 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
2753 | 2907 | |
2754 | 2908 | // Just to make sure it doesn't time out. |
2755 | - if (function_exists('apache_reset_timeout')) |
|
2756 | - @apache_reset_timeout(); |
|
2909 | + if (function_exists('apache_reset_timeout')) { |
|
2910 | + @apache_reset_timeout(); |
|
2911 | + } |
|
2757 | 2912 | |
2758 | 2913 | $table_charsets = array(); |
2759 | 2914 | |
@@ -2774,8 +2929,9 @@ discard block |
||
2774 | 2929 | { |
2775 | 2930 | list($charset) = explode('_', $collation); |
2776 | 2931 | |
2777 | - if (!isset($table_charsets[$charset])) |
|
2778 | - $table_charsets[$charset] = array(); |
|
2932 | + if (!isset($table_charsets[$charset])) { |
|
2933 | + $table_charsets[$charset] = array(); |
|
2934 | + } |
|
2779 | 2935 | |
2780 | 2936 | $table_charsets[$charset][] = $column_info; |
2781 | 2937 | } |
@@ -2815,10 +2971,11 @@ discard block |
||
2815 | 2971 | if (isset($translation_tables[$upcontext['charset_detected']])) |
2816 | 2972 | { |
2817 | 2973 | $update = ''; |
2818 | - foreach ($table_charsets as $charset => $columns) |
|
2819 | - foreach ($columns as $column) |
|
2974 | + foreach ($table_charsets as $charset => $columns) { |
|
2975 | + foreach ($columns as $column) |
|
2820 | 2976 | $update .= ' |
2821 | 2977 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
2978 | + } |
|
2822 | 2979 | |
2823 | 2980 | $smcFunc['db_query']('', ' |
2824 | 2981 | UPDATE {raw:table_name} |
@@ -2843,8 +3000,9 @@ discard block |
||
2843 | 3000 | // Now do the actual conversion (if still needed). |
2844 | 3001 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
2845 | 3002 | { |
2846 | - if ($command_line) |
|
2847 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3003 | + if ($command_line) { |
|
3004 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3005 | + } |
|
2848 | 3006 | |
2849 | 3007 | $smcFunc['db_query']('', ' |
2850 | 3008 | ALTER TABLE {raw:table_name} |
@@ -2854,8 +3012,9 @@ discard block |
||
2854 | 3012 | ) |
2855 | 3013 | ); |
2856 | 3014 | |
2857 | - if ($command_line) |
|
2858 | - echo " done.\n"; |
|
3015 | + if ($command_line) { |
|
3016 | + echo " done.\n"; |
|
3017 | + } |
|
2859 | 3018 | } |
2860 | 3019 | } |
2861 | 3020 | |
@@ -2885,8 +3044,8 @@ discard block |
||
2885 | 3044 | ); |
2886 | 3045 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2887 | 3046 | { |
2888 | - 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) |
|
2889 | - $smcFunc['db_query']('', ' |
|
3047 | + 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) { |
|
3048 | + $smcFunc['db_query']('', ' |
|
2890 | 3049 | UPDATE {db_prefix}log_actions |
2891 | 3050 | SET extra = {string:extra} |
2892 | 3051 | WHERE id_action = {int:current_action}', |
@@ -2895,6 +3054,7 @@ discard block |
||
2895 | 3054 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
2896 | 3055 | ) |
2897 | 3056 | ); |
3057 | + } |
|
2898 | 3058 | } |
2899 | 3059 | $smcFunc['db_free_result']($request); |
2900 | 3060 | |
@@ -2916,15 +3076,17 @@ discard block |
||
2916 | 3076 | // First thing's first - did we already do this? |
2917 | 3077 | if (!empty($modSettings['json_done'])) |
2918 | 3078 | { |
2919 | - if ($command_line) |
|
2920 | - return DeleteUpgrade(); |
|
2921 | - else |
|
2922 | - return true; |
|
3079 | + if ($command_line) { |
|
3080 | + return DeleteUpgrade(); |
|
3081 | + } else { |
|
3082 | + return true; |
|
3083 | + } |
|
2923 | 3084 | } |
2924 | 3085 | |
2925 | 3086 | // Done it already - js wise? |
2926 | - if (!empty($_POST['json_done'])) |
|
2927 | - return true; |
|
3087 | + if (!empty($_POST['json_done'])) { |
|
3088 | + return true; |
|
3089 | + } |
|
2928 | 3090 | |
2929 | 3091 | // List of tables affected by this function |
2930 | 3092 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2955,12 +3117,14 @@ discard block |
||
2955 | 3117 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
2956 | 3118 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
2957 | 3119 | |
2958 | - foreach ($keys as $id => $table) |
|
2959 | - if ($id < $_GET['substep']) |
|
3120 | + foreach ($keys as $id => $table) { |
|
3121 | + if ($id < $_GET['substep']) |
|
2960 | 3122 | $upcontext['previous_tables'][] = $table; |
3123 | + } |
|
2961 | 3124 | |
2962 | - if ($command_line) |
|
2963 | - echo 'Converting data from serialize() to json_encode().'; |
|
3125 | + if ($command_line) { |
|
3126 | + echo 'Converting data from serialize() to json_encode().'; |
|
3127 | + } |
|
2964 | 3128 | |
2965 | 3129 | if (!$support_js || isset($_GET['xml'])) |
2966 | 3130 | { |
@@ -3000,8 +3164,9 @@ discard block |
||
3000 | 3164 | |
3001 | 3165 | // Loop through and fix these... |
3002 | 3166 | $new_settings = array(); |
3003 | - if ($command_line) |
|
3004 | - echo "\n" . 'Fixing some settings...'; |
|
3167 | + if ($command_line) { |
|
3168 | + echo "\n" . 'Fixing some settings...'; |
|
3169 | + } |
|
3005 | 3170 | |
3006 | 3171 | foreach ($serialized_settings as $var) |
3007 | 3172 | { |
@@ -3009,22 +3174,24 @@ discard block |
||
3009 | 3174 | { |
3010 | 3175 | // Attempt to unserialize the setting |
3011 | 3176 | $temp = @safe_unserialize($modSettings[$var]); |
3012 | - if (!$temp && $command_line) |
|
3013 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3014 | - elseif ($temp !== false) |
|
3015 | - $new_settings[$var] = json_encode($temp); |
|
3177 | + if (!$temp && $command_line) { |
|
3178 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3179 | + } elseif ($temp !== false) { |
|
3180 | + $new_settings[$var] = json_encode($temp); |
|
3181 | + } |
|
3016 | 3182 | } |
3017 | 3183 | } |
3018 | 3184 | |
3019 | 3185 | // Update everything at once |
3020 | - if (!function_exists('cache_put_data')) |
|
3021 | - require_once($sourcedir . '/Load.php'); |
|
3186 | + if (!function_exists('cache_put_data')) { |
|
3187 | + require_once($sourcedir . '/Load.php'); |
|
3188 | + } |
|
3022 | 3189 | updateSettings($new_settings, true); |
3023 | 3190 | |
3024 | - if ($command_line) |
|
3025 | - echo ' done.'; |
|
3026 | - } |
|
3027 | - elseif ($table == 'themes') |
|
3191 | + if ($command_line) { |
|
3192 | + echo ' done.'; |
|
3193 | + } |
|
3194 | + } elseif ($table == 'themes') |
|
3028 | 3195 | { |
3029 | 3196 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3030 | 3197 | $query = $smcFunc['db_query']('', ' |
@@ -3043,10 +3210,11 @@ discard block |
||
3043 | 3210 | |
3044 | 3211 | if ($command_line) |
3045 | 3212 | { |
3046 | - if ($temp === false) |
|
3047 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3048 | - else |
|
3049 | - echo "\n" . 'Fixing admin preferences...'; |
|
3213 | + if ($temp === false) { |
|
3214 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3215 | + } else { |
|
3216 | + echo "\n" . 'Fixing admin preferences...'; |
|
3217 | + } |
|
3050 | 3218 | } |
3051 | 3219 | |
3052 | 3220 | if ($temp !== false) |
@@ -3068,15 +3236,15 @@ discard block |
||
3068 | 3236 | ) |
3069 | 3237 | ); |
3070 | 3238 | |
3071 | - if ($command_line) |
|
3072 | - echo ' done.'; |
|
3239 | + if ($command_line) { |
|
3240 | + echo ' done.'; |
|
3241 | + } |
|
3073 | 3242 | } |
3074 | 3243 | } |
3075 | 3244 | |
3076 | 3245 | $smcFunc['db_free_result']($query); |
3077 | 3246 | } |
3078 | - } |
|
3079 | - else |
|
3247 | + } else |
|
3080 | 3248 | { |
3081 | 3249 | // First item is always the key... |
3082 | 3250 | $key = $info[0]; |
@@ -3087,8 +3255,7 @@ discard block |
||
3087 | 3255 | { |
3088 | 3256 | $col_select = $info[1]; |
3089 | 3257 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3090 | - } |
|
3091 | - else |
|
3258 | + } else |
|
3092 | 3259 | { |
3093 | 3260 | $col_select = implode(', ', $info); |
3094 | 3261 | } |
@@ -3121,8 +3288,7 @@ discard block |
||
3121 | 3288 | if ($temp === false && $command_line) |
3122 | 3289 | { |
3123 | 3290 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
3124 | - } |
|
3125 | - else |
|
3291 | + } else |
|
3126 | 3292 | { |
3127 | 3293 | $row[$col] = json_encode($temp); |
3128 | 3294 | |
@@ -3147,16 +3313,18 @@ discard block |
||
3147 | 3313 | } |
3148 | 3314 | } |
3149 | 3315 | |
3150 | - if ($command_line) |
|
3151 | - echo ' done.'; |
|
3316 | + if ($command_line) { |
|
3317 | + echo ' done.'; |
|
3318 | + } |
|
3152 | 3319 | |
3153 | 3320 | // Free up some memory... |
3154 | 3321 | $smcFunc['db_free_result']($query); |
3155 | 3322 | } |
3156 | 3323 | } |
3157 | 3324 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3158 | - if (isset($_GET['xml'])) |
|
3159 | - return upgradeExit(); |
|
3325 | + if (isset($_GET['xml'])) { |
|
3326 | + return upgradeExit(); |
|
3327 | + } |
|
3160 | 3328 | } |
3161 | 3329 | |
3162 | 3330 | if ($command_line) |
@@ -3171,8 +3339,9 @@ discard block |
||
3171 | 3339 | |
3172 | 3340 | $_GET['substep'] = 0; |
3173 | 3341 | // Make sure we move on! |
3174 | - if ($command_line) |
|
3175 | - return DeleteUpgrade(); |
|
3342 | + if ($command_line) { |
|
3343 | + return DeleteUpgrade(); |
|
3344 | + } |
|
3176 | 3345 | |
3177 | 3346 | return true; |
3178 | 3347 | } |
@@ -3192,14 +3361,16 @@ discard block |
||
3192 | 3361 | global $upcontext, $txt, $settings; |
3193 | 3362 | |
3194 | 3363 | // Don't call me twice! |
3195 | - if (!empty($upcontext['chmod_called'])) |
|
3196 | - return; |
|
3364 | + if (!empty($upcontext['chmod_called'])) { |
|
3365 | + return; |
|
3366 | + } |
|
3197 | 3367 | |
3198 | 3368 | $upcontext['chmod_called'] = true; |
3199 | 3369 | |
3200 | 3370 | // Nothing? |
3201 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
3202 | - return; |
|
3371 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
3372 | + return; |
|
3373 | + } |
|
3203 | 3374 | |
3204 | 3375 | // Was it a problem with Windows? |
3205 | 3376 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3231,11 +3402,12 @@ discard block |
||
3231 | 3402 | 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\'); |
3232 | 3403 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
3233 | 3404 | |
3234 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
3235 | - echo ' |
|
3405 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
3406 | + echo ' |
|
3236 | 3407 | content.write(\'<hr>\n\t\t\t\'); |
3237 | 3408 | 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\'); |
3238 | 3409 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
3410 | + } |
|
3239 | 3411 | |
3240 | 3412 | echo ' |
3241 | 3413 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3243,17 +3415,19 @@ discard block |
||
3243 | 3415 | } |
3244 | 3416 | </script>'; |
3245 | 3417 | |
3246 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
3247 | - echo ' |
|
3418 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
3419 | + echo ' |
|
3248 | 3420 | <div class="error_message red"> |
3249 | 3421 | The following error was encountered when trying to connect:<br><br> |
3250 | 3422 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
3251 | 3423 | </div> |
3252 | 3424 | <br>'; |
3425 | + } |
|
3253 | 3426 | |
3254 | - if (empty($upcontext['chmod_in_form'])) |
|
3255 | - echo ' |
|
3427 | + if (empty($upcontext['chmod_in_form'])) { |
|
3428 | + echo ' |
|
3256 | 3429 | <form action="', $upcontext['form_url'], '" method="post">'; |
3430 | + } |
|
3257 | 3431 | |
3258 | 3432 | echo ' |
3259 | 3433 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3288,10 +3462,11 @@ discard block |
||
3288 | 3462 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
3289 | 3463 | </div>'; |
3290 | 3464 | |
3291 | - if (empty($upcontext['chmod_in_form'])) |
|
3292 | - echo ' |
|
3465 | + if (empty($upcontext['chmod_in_form'])) { |
|
3466 | + echo ' |
|
3293 | 3467 | </form>'; |
3294 | -} |
|
3468 | + } |
|
3469 | + } |
|
3295 | 3470 | |
3296 | 3471 | function template_upgrade_above() |
3297 | 3472 | { |
@@ -3351,9 +3526,10 @@ discard block |
||
3351 | 3526 | <h2>', $txt['upgrade_progress'], '</h2> |
3352 | 3527 | <ul>'; |
3353 | 3528 | |
3354 | - foreach ($upcontext['steps'] as $num => $step) |
|
3355 | - echo ' |
|
3529 | + foreach ($upcontext['steps'] as $num => $step) { |
|
3530 | + echo ' |
|
3356 | 3531 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
3532 | + } |
|
3357 | 3533 | |
3358 | 3534 | echo ' |
3359 | 3535 | </ul> |
@@ -3366,8 +3542,8 @@ discard block |
||
3366 | 3542 | </div> |
3367 | 3543 | </div>'; |
3368 | 3544 | |
3369 | - if (isset($upcontext['step_progress'])) |
|
3370 | - echo ' |
|
3545 | + if (isset($upcontext['step_progress'])) { |
|
3546 | + echo ' |
|
3371 | 3547 | <br> |
3372 | 3548 | <br> |
3373 | 3549 | <div id="progress_bar_step"> |
@@ -3376,6 +3552,7 @@ discard block |
||
3376 | 3552 | <span>', $txt['upgrade_step_progress'], '</span> |
3377 | 3553 | </div> |
3378 | 3554 | </div>'; |
3555 | + } |
|
3379 | 3556 | |
3380 | 3557 | echo ' |
3381 | 3558 | <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> |
@@ -3406,32 +3583,36 @@ discard block |
||
3406 | 3583 | { |
3407 | 3584 | global $upcontext, $txt; |
3408 | 3585 | |
3409 | - if (!empty($upcontext['pause'])) |
|
3410 | - echo ' |
|
3586 | + if (!empty($upcontext['pause'])) { |
|
3587 | + echo ' |
|
3411 | 3588 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
3412 | 3589 | |
3413 | 3590 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
3414 | 3591 | <h3> |
3415 | 3592 | ', $txt['upgrade_paused_overload'], ' |
3416 | 3593 | </h3>'; |
3594 | + } |
|
3417 | 3595 | |
3418 | - if (!empty($upcontext['custom_warning'])) |
|
3419 | - echo ' |
|
3596 | + if (!empty($upcontext['custom_warning'])) { |
|
3597 | + echo ' |
|
3420 | 3598 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3421 | 3599 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3422 | 3600 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
3423 | 3601 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
3424 | 3602 | </div>'; |
3603 | + } |
|
3425 | 3604 | |
3426 | 3605 | echo ' |
3427 | 3606 | <div class="righttext" style="margin: 1ex;">'; |
3428 | 3607 | |
3429 | - if (!empty($upcontext['continue'])) |
|
3430 | - echo ' |
|
3608 | + if (!empty($upcontext['continue'])) { |
|
3609 | + echo ' |
|
3431 | 3610 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
3432 | - if (!empty($upcontext['skip'])) |
|
3433 | - echo ' |
|
3611 | + } |
|
3612 | + if (!empty($upcontext['skip'])) { |
|
3613 | + echo ' |
|
3434 | 3614 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
3615 | + } |
|
3435 | 3616 | |
3436 | 3617 | echo ' |
3437 | 3618 | </div> |
@@ -3481,11 +3662,12 @@ discard block |
||
3481 | 3662 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
3482 | 3663 | <smf>'; |
3483 | 3664 | |
3484 | - if (!empty($upcontext['get_data'])) |
|
3485 | - foreach ($upcontext['get_data'] as $k => $v) |
|
3665 | + if (!empty($upcontext['get_data'])) { |
|
3666 | + foreach ($upcontext['get_data'] as $k => $v) |
|
3486 | 3667 | echo ' |
3487 | 3668 | <get key="', $k, '">', $v, '</get>'; |
3488 | -} |
|
3669 | + } |
|
3670 | + } |
|
3489 | 3671 | |
3490 | 3672 | function template_xml_below() |
3491 | 3673 | { |
@@ -3526,8 +3708,8 @@ discard block |
||
3526 | 3708 | template_chmod(); |
3527 | 3709 | |
3528 | 3710 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
3529 | - if ($upcontext['is_large_forum']) |
|
3530 | - echo ' |
|
3711 | + if ($upcontext['is_large_forum']) { |
|
3712 | + echo ' |
|
3531 | 3713 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3532 | 3714 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3533 | 3715 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3535,10 +3717,11 @@ discard block |
||
3535 | 3717 | ', $txt['upgrade_warning_lots_data'], ' |
3536 | 3718 | </div> |
3537 | 3719 | </div>'; |
3720 | + } |
|
3538 | 3721 | |
3539 | 3722 | // A warning message? |
3540 | - if (!empty($upcontext['warning'])) |
|
3541 | - echo ' |
|
3723 | + if (!empty($upcontext['warning'])) { |
|
3724 | + echo ' |
|
3542 | 3725 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3543 | 3726 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3544 | 3727 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3546,6 +3729,7 @@ discard block |
||
3546 | 3729 | ', $upcontext['warning'], ' |
3547 | 3730 | </div> |
3548 | 3731 | </div>'; |
3732 | + } |
|
3549 | 3733 | |
3550 | 3734 | // Paths are incorrect? |
3551 | 3735 | echo ' |
@@ -3561,20 +3745,22 @@ discard block |
||
3561 | 3745 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
3562 | 3746 | { |
3563 | 3747 | $ago = time() - $upcontext['started']; |
3564 | - if ($ago < 60) |
|
3565 | - $ago = $ago . ' seconds'; |
|
3566 | - elseif ($ago < 3600) |
|
3567 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
3568 | - else |
|
3569 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
3748 | + if ($ago < 60) { |
|
3749 | + $ago = $ago . ' seconds'; |
|
3750 | + } elseif ($ago < 3600) { |
|
3751 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
3752 | + } else { |
|
3753 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
3754 | + } |
|
3570 | 3755 | |
3571 | 3756 | $active = time() - $upcontext['updated']; |
3572 | - if ($active < 60) |
|
3573 | - $updated = $active . ' seconds'; |
|
3574 | - elseif ($active < 3600) |
|
3575 | - $updated = (int) ($active / 60) . ' minutes'; |
|
3576 | - else |
|
3577 | - $updated = (int) ($active / 3600) . ' hours'; |
|
3757 | + if ($active < 60) { |
|
3758 | + $updated = $active . ' seconds'; |
|
3759 | + } elseif ($active < 3600) { |
|
3760 | + $updated = (int) ($active / 60) . ' minutes'; |
|
3761 | + } else { |
|
3762 | + $updated = (int) ($active / 3600) . ' hours'; |
|
3763 | + } |
|
3578 | 3764 | |
3579 | 3765 | echo ' |
3580 | 3766 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3583,16 +3769,18 @@ discard block |
||
3583 | 3769 | <div style="padding-left: 6ex;"> |
3584 | 3770 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
3585 | 3771 | |
3586 | - if ($active < 600) |
|
3587 | - echo ' |
|
3772 | + if ($active < 600) { |
|
3773 | + echo ' |
|
3588 | 3774 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
3775 | + } |
|
3589 | 3776 | |
3590 | - if ($active > $upcontext['inactive_timeout']) |
|
3591 | - echo ' |
|
3777 | + if ($active > $upcontext['inactive_timeout']) { |
|
3778 | + echo ' |
|
3592 | 3779 | <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.'; |
3593 | - else |
|
3594 | - echo ' |
|
3780 | + } else { |
|
3781 | + echo ' |
|
3595 | 3782 | <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!'); |
3783 | + } |
|
3596 | 3784 | |
3597 | 3785 | echo ' |
3598 | 3786 | </div> |
@@ -3608,9 +3796,10 @@ discard block |
||
3608 | 3796 | <td> |
3609 | 3797 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
3610 | 3798 | |
3611 | - if (!empty($upcontext['username_incorrect'])) |
|
3612 | - echo ' |
|
3799 | + if (!empty($upcontext['username_incorrect'])) { |
|
3800 | + echo ' |
|
3613 | 3801 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
3802 | + } |
|
3614 | 3803 | |
3615 | 3804 | echo ' |
3616 | 3805 | </td> |
@@ -3621,9 +3810,10 @@ discard block |
||
3621 | 3810 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
3622 | 3811 | <input type="hidden" name="hash_passwrd" value="">'; |
3623 | 3812 | |
3624 | - if (!empty($upcontext['password_failed'])) |
|
3625 | - echo ' |
|
3813 | + if (!empty($upcontext['password_failed'])) { |
|
3814 | + echo ' |
|
3626 | 3815 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
3816 | + } |
|
3627 | 3817 | |
3628 | 3818 | echo ' |
3629 | 3819 | </td> |
@@ -3694,8 +3884,8 @@ discard block |
||
3694 | 3884 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
3695 | 3885 | |
3696 | 3886 | // Warning message? |
3697 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
3698 | - echo ' |
|
3887 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
3888 | + echo ' |
|
3699 | 3889 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3700 | 3890 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3701 | 3891 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3703,6 +3893,7 @@ discard block |
||
3703 | 3893 | ', $upcontext['upgrade_options_warning'], ' |
3704 | 3894 | </div> |
3705 | 3895 | </div>'; |
3896 | + } |
|
3706 | 3897 | |
3707 | 3898 | echo ' |
3708 | 3899 | <table> |
@@ -3745,8 +3936,8 @@ discard block |
||
3745 | 3936 | </td> |
3746 | 3937 | </tr>'; |
3747 | 3938 | |
3748 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
3749 | - echo ' |
|
3939 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
3940 | + echo ' |
|
3750 | 3941 | <tr valign="top"> |
3751 | 3942 | <td width="2%"> |
3752 | 3943 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3755,6 +3946,7 @@ discard block |
||
3755 | 3946 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
3756 | 3947 | </td> |
3757 | 3948 | </tr>'; |
3949 | + } |
|
3758 | 3950 | |
3759 | 3951 | echo ' |
3760 | 3952 | <tr valign="top"> |
@@ -3792,10 +3984,11 @@ discard block |
||
3792 | 3984 | </div>'; |
3793 | 3985 | |
3794 | 3986 | // Dont any tables so far? |
3795 | - if (!empty($upcontext['previous_tables'])) |
|
3796 | - foreach ($upcontext['previous_tables'] as $table) |
|
3987 | + if (!empty($upcontext['previous_tables'])) { |
|
3988 | + foreach ($upcontext['previous_tables'] as $table) |
|
3797 | 3989 | echo ' |
3798 | 3990 | <br>Completed Table: "', $table, '".'; |
3991 | + } |
|
3799 | 3992 | |
3800 | 3993 | echo ' |
3801 | 3994 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3832,12 +4025,13 @@ discard block |
||
3832 | 4025 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
3833 | 4026 | |
3834 | 4027 | // If debug flood the screen. |
3835 | - if ($is_debug) |
|
3836 | - echo ' |
|
4028 | + if ($is_debug) { |
|
4029 | + echo ' |
|
3837 | 4030 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
3838 | 4031 | |
3839 | 4032 | if (document.getElementById(\'debug_section\').scrollHeight) |
3840 | 4033 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4034 | + } |
|
3841 | 4035 | |
3842 | 4036 | echo ' |
3843 | 4037 | // Get the next update... |
@@ -3869,8 +4063,9 @@ discard block |
||
3869 | 4063 | { |
3870 | 4064 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
3871 | 4065 | |
3872 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
3873 | - $is_debug = true; |
|
4066 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
4067 | + $is_debug = true; |
|
4068 | + } |
|
3874 | 4069 | |
3875 | 4070 | echo ' |
3876 | 4071 | <h3>Executing database changes</h3> |
@@ -3885,8 +4080,9 @@ discard block |
||
3885 | 4080 | { |
3886 | 4081 | foreach ($upcontext['actioned_items'] as $num => $item) |
3887 | 4082 | { |
3888 | - if ($num != 0) |
|
3889 | - echo ' Successful!'; |
|
4083 | + if ($num != 0) { |
|
4084 | + echo ' Successful!'; |
|
4085 | + } |
|
3890 | 4086 | echo '<br>' . $item; |
3891 | 4087 | } |
3892 | 4088 | if (!empty($upcontext['changes_complete'])) |
@@ -3899,28 +4095,32 @@ discard block |
||
3899 | 4095 | $seconds = intval($active % 60); |
3900 | 4096 | |
3901 | 4097 | $totalTime = ''; |
3902 | - if ($hours > 0) |
|
3903 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3904 | - if ($minutes > 0) |
|
3905 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3906 | - if ($seconds > 0) |
|
3907 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4098 | + if ($hours > 0) { |
|
4099 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4100 | + } |
|
4101 | + if ($minutes > 0) { |
|
4102 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4103 | + } |
|
4104 | + if ($seconds > 0) { |
|
4105 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4106 | + } |
|
3908 | 4107 | } |
3909 | 4108 | |
3910 | - if ($is_debug && !empty($totalTime)) |
|
3911 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
3912 | - else |
|
3913 | - echo ' Successful!<br><br>'; |
|
4109 | + if ($is_debug && !empty($totalTime)) { |
|
4110 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4111 | + } else { |
|
4112 | + echo ' Successful!<br><br>'; |
|
4113 | + } |
|
3914 | 4114 | |
3915 | 4115 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
3916 | 4116 | } |
3917 | - } |
|
3918 | - else |
|
4117 | + } else |
|
3919 | 4118 | { |
3920 | 4119 | // Tell them how many files we have in total. |
3921 | - if ($upcontext['file_count'] > 1) |
|
3922 | - echo ' |
|
4120 | + if ($upcontext['file_count'] > 1) { |
|
4121 | + echo ' |
|
3923 | 4122 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
4123 | + } |
|
3924 | 4124 | |
3925 | 4125 | echo ' |
3926 | 4126 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3936,19 +4136,23 @@ discard block |
||
3936 | 4136 | $seconds = intval($active % 60); |
3937 | 4137 | |
3938 | 4138 | $totalTime = ''; |
3939 | - if ($hours > 0) |
|
3940 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3941 | - if ($minutes > 0) |
|
3942 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3943 | - if ($seconds > 0) |
|
3944 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4139 | + if ($hours > 0) { |
|
4140 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4141 | + } |
|
4142 | + if ($minutes > 0) { |
|
4143 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4144 | + } |
|
4145 | + if ($seconds > 0) { |
|
4146 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4147 | + } |
|
3945 | 4148 | } |
3946 | 4149 | |
3947 | 4150 | echo ' |
3948 | 4151 | <br><span id="upgradeCompleted">'; |
3949 | 4152 | |
3950 | - if (!empty($totalTime)) |
|
3951 | - echo 'Completed in ', $totalTime, '<br>'; |
|
4153 | + if (!empty($totalTime)) { |
|
4154 | + echo 'Completed in ', $totalTime, '<br>'; |
|
4155 | + } |
|
3952 | 4156 | |
3953 | 4157 | echo '</span> |
3954 | 4158 | <div id="debug_section" style="height: 200px; overflow: auto;"> |
@@ -3985,9 +4189,10 @@ discard block |
||
3985 | 4189 | var getData = ""; |
3986 | 4190 | var debugItems = ', $upcontext['debug_items'], ';'; |
3987 | 4191 | |
3988 | - if ($is_debug) |
|
3989 | - echo ' |
|
4192 | + if ($is_debug) { |
|
4193 | + echo ' |
|
3990 | 4194 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
4195 | + } |
|
3991 | 4196 | |
3992 | 4197 | echo ' |
3993 | 4198 | function getNextItem() |
@@ -4027,9 +4232,10 @@ discard block |
||
4027 | 4232 | document.getElementById("error_block").style.display = ""; |
4028 | 4233 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4029 | 4234 | |
4030 | - if ($is_debug) |
|
4031 | - echo ' |
|
4235 | + if ($is_debug) { |
|
4236 | + echo ' |
|
4032 | 4237 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4238 | + } |
|
4033 | 4239 | |
4034 | 4240 | echo ' |
4035 | 4241 | } |
@@ -4050,9 +4256,10 @@ discard block |
||
4050 | 4256 | document.getElementById("error_block").style.display = ""; |
4051 | 4257 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
4052 | 4258 | |
4053 | - if ($is_debug) |
|
4054 | - echo ' |
|
4259 | + if ($is_debug) { |
|
4260 | + echo ' |
|
4055 | 4261 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4262 | + } |
|
4056 | 4263 | |
4057 | 4264 | echo ' |
4058 | 4265 | } |
@@ -4111,8 +4318,8 @@ discard block |
||
4111 | 4318 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
4112 | 4319 | {'; |
4113 | 4320 | |
4114 | - if ($is_debug) |
|
4115 | - echo ' |
|
4321 | + if ($is_debug) { |
|
4322 | + echo ' |
|
4116 | 4323 | document.getElementById(\'debug_section\').style.display = "none"; |
4117 | 4324 | |
4118 | 4325 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4130,6 +4337,7 @@ discard block |
||
4130 | 4337 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
4131 | 4338 | |
4132 | 4339 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
4340 | + } |
|
4133 | 4341 | |
4134 | 4342 | echo ' |
4135 | 4343 | |
@@ -4137,9 +4345,10 @@ discard block |
||
4137 | 4345 | document.getElementById(\'contbutt\').disabled = 0; |
4138 | 4346 | document.getElementById(\'database_done\').value = 1;'; |
4139 | 4347 | |
4140 | - if ($upcontext['file_count'] > 1) |
|
4141 | - echo ' |
|
4348 | + if ($upcontext['file_count'] > 1) { |
|
4349 | + echo ' |
|
4142 | 4350 | document.getElementById(\'info1\').style.display = "none";'; |
4351 | + } |
|
4143 | 4352 | |
4144 | 4353 | echo ' |
4145 | 4354 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4152,9 +4361,10 @@ discard block |
||
4152 | 4361 | lastItem = 0; |
4153 | 4362 | prevFile = curFile;'; |
4154 | 4363 | |
4155 | - if ($is_debug) |
|
4156 | - echo ' |
|
4364 | + if ($is_debug) { |
|
4365 | + echo ' |
|
4157 | 4366 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
4367 | + } |
|
4158 | 4368 | |
4159 | 4369 | echo ' |
4160 | 4370 | getNextItem(); |
@@ -4162,8 +4372,8 @@ discard block |
||
4162 | 4372 | }'; |
4163 | 4373 | |
4164 | 4374 | // If debug scroll the screen. |
4165 | - if ($is_debug) |
|
4166 | - echo ' |
|
4375 | + if ($is_debug) { |
|
4376 | + echo ' |
|
4167 | 4377 | if (iLastSubStepProgress == -1) |
4168 | 4378 | { |
4169 | 4379 | // Give it consistent dots. |
@@ -4182,6 +4392,7 @@ discard block |
||
4182 | 4392 | |
4183 | 4393 | if (document.getElementById(\'debug_section\').scrollHeight) |
4184 | 4394 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4395 | + } |
|
4185 | 4396 | |
4186 | 4397 | echo ' |
4187 | 4398 | // Update the page. |
@@ -4242,9 +4453,10 @@ discard block |
||
4242 | 4453 | }'; |
4243 | 4454 | |
4244 | 4455 | // Start things off assuming we've not errored. |
4245 | - if (empty($upcontext['error_message'])) |
|
4246 | - echo ' |
|
4456 | + if (empty($upcontext['error_message'])) { |
|
4457 | + echo ' |
|
4247 | 4458 | getNextItem();'; |
4459 | + } |
|
4248 | 4460 | |
4249 | 4461 | echo ' |
4250 | 4462 | </script>'; |
@@ -4261,18 +4473,21 @@ discard block |
||
4261 | 4473 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
4262 | 4474 | <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>'; |
4263 | 4475 | |
4264 | - if (!empty($upcontext['error_message'])) |
|
4265 | - echo ' |
|
4476 | + if (!empty($upcontext['error_message'])) { |
|
4477 | + echo ' |
|
4266 | 4478 | <error>', $upcontext['error_message'], '</error>'; |
4479 | + } |
|
4267 | 4480 | |
4268 | - if (!empty($upcontext['error_string'])) |
|
4269 | - echo ' |
|
4481 | + if (!empty($upcontext['error_string'])) { |
|
4482 | + echo ' |
|
4270 | 4483 | <sql>', $upcontext['error_string'], '</sql>'; |
4484 | + } |
|
4271 | 4485 | |
4272 | - if ($is_debug) |
|
4273 | - echo ' |
|
4486 | + if ($is_debug) { |
|
4487 | + echo ' |
|
4274 | 4488 | <curtime>', time(), '</curtime>'; |
4275 | -} |
|
4489 | + } |
|
4490 | + } |
|
4276 | 4491 | |
4277 | 4492 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
4278 | 4493 | function template_convert_utf8() |
@@ -4289,18 +4504,20 @@ discard block |
||
4289 | 4504 | <span id="debuginfo"></span>'; |
4290 | 4505 | |
4291 | 4506 | // Done any tables so far? |
4292 | - if (!empty($upcontext['previous_tables'])) |
|
4293 | - foreach ($upcontext['previous_tables'] as $table) |
|
4507 | + if (!empty($upcontext['previous_tables'])) { |
|
4508 | + foreach ($upcontext['previous_tables'] as $table) |
|
4294 | 4509 | echo ' |
4295 | 4510 | <br>Completed Table: "', $table, '".'; |
4511 | + } |
|
4296 | 4512 | |
4297 | 4513 | echo ' |
4298 | 4514 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
4299 | 4515 | |
4300 | 4516 | // If we dropped their index, let's let them know |
4301 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
4302 | - echo ' |
|
4517 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
4518 | + echo ' |
|
4303 | 4519 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
4520 | + } |
|
4304 | 4521 | |
4305 | 4522 | echo ' |
4306 | 4523 | <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>'; |
@@ -4336,9 +4553,10 @@ discard block |
||
4336 | 4553 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4337 | 4554 | |
4338 | 4555 | // If debug flood the screen. |
4339 | - if ($is_debug) |
|
4340 | - echo ' |
|
4556 | + if ($is_debug) { |
|
4557 | + echo ' |
|
4341 | 4558 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
4559 | + } |
|
4342 | 4560 | |
4343 | 4561 | echo ' |
4344 | 4562 | // Get the next update... |
@@ -4380,19 +4598,21 @@ discard block |
||
4380 | 4598 | <span id="debuginfo"></span>'; |
4381 | 4599 | |
4382 | 4600 | // Dont any tables so far? |
4383 | - if (!empty($upcontext['previous_tables'])) |
|
4384 | - foreach ($upcontext['previous_tables'] as $table) |
|
4601 | + if (!empty($upcontext['previous_tables'])) { |
|
4602 | + foreach ($upcontext['previous_tables'] as $table) |
|
4385 | 4603 | echo ' |
4386 | 4604 | <br>Completed Table: "', $table, '".'; |
4605 | + } |
|
4387 | 4606 | |
4388 | 4607 | echo ' |
4389 | 4608 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
4390 | 4609 | <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>'; |
4391 | 4610 | |
4392 | 4611 | // Try to make sure substep was reset. |
4393 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
4394 | - echo ' |
|
4612 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
4613 | + echo ' |
|
4395 | 4614 | <input type="hidden" name="substep" id="substep" value="0">'; |
4615 | + } |
|
4396 | 4616 | |
4397 | 4617 | // Continue please! |
4398 | 4618 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4425,9 +4645,10 @@ discard block |
||
4425 | 4645 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4426 | 4646 | |
4427 | 4647 | // If debug flood the screen. |
4428 | - if ($is_debug) |
|
4429 | - echo ' |
|
4648 | + if ($is_debug) { |
|
4649 | + echo ' |
|
4430 | 4650 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
4651 | + } |
|
4431 | 4652 | |
4432 | 4653 | echo ' |
4433 | 4654 | // Get the next update... |
@@ -4462,8 +4683,8 @@ discard block |
||
4462 | 4683 | <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> |
4463 | 4684 | <form action="', $boardurl, '/index.php">'; |
4464 | 4685 | |
4465 | - if (!empty($upcontext['can_delete_script'])) |
|
4466 | - echo ' |
|
4686 | + if (!empty($upcontext['can_delete_script'])) { |
|
4687 | + echo ' |
|
4467 | 4688 | <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> |
4468 | 4689 | <script> |
4469 | 4690 | function doTheDelete(theCheck) |
@@ -4475,6 +4696,7 @@ discard block |
||
4475 | 4696 | } |
4476 | 4697 | </script> |
4477 | 4698 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
4699 | + } |
|
4478 | 4700 | |
4479 | 4701 | $active = time() - $upcontext['started']; |
4480 | 4702 | $hours = floor($active / 3600); |
@@ -4484,16 +4706,20 @@ discard block |
||
4484 | 4706 | if ($is_debug) |
4485 | 4707 | { |
4486 | 4708 | $totalTime = ''; |
4487 | - if ($hours > 0) |
|
4488 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4489 | - if ($minutes > 0) |
|
4490 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4491 | - if ($seconds > 0) |
|
4492 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4709 | + if ($hours > 0) { |
|
4710 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4711 | + } |
|
4712 | + if ($minutes > 0) { |
|
4713 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4714 | + } |
|
4715 | + if ($seconds > 0) { |
|
4716 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4717 | + } |
|
4493 | 4718 | } |
4494 | 4719 | |
4495 | - if ($is_debug && !empty($totalTime)) |
|
4496 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4720 | + if ($is_debug && !empty($totalTime)) { |
|
4721 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4722 | + } |
|
4497 | 4723 | |
4498 | 4724 | echo '<br> |
4499 | 4725 | 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> |
@@ -4560,16 +4786,19 @@ discard block |
||
4560 | 4786 | 'empty' => '', |
4561 | 4787 | 'limit' => $limit, |
4562 | 4788 | )); |
4563 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4564 | - $arIp[] = $row[$oldCol]; |
|
4789 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
4790 | + $arIp[] = $row[$oldCol]; |
|
4791 | + } |
|
4565 | 4792 | $smcFunc['db_free_result']($request); |
4566 | 4793 | |
4567 | 4794 | // Special case, null ip could keep us in a loop. |
4568 | - if (is_null($arIp[0])) |
|
4569 | - unset($arIp[0]); |
|
4795 | + if (is_null($arIp[0])) { |
|
4796 | + unset($arIp[0]); |
|
4797 | + } |
|
4570 | 4798 | |
4571 | - if (empty($arIp)) |
|
4572 | - $is_done = true; |
|
4799 | + if (empty($arIp)) { |
|
4800 | + $is_done = true; |
|
4801 | + } |
|
4573 | 4802 | |
4574 | 4803 | $updates = array(); |
4575 | 4804 | $cases = array(); |
@@ -4578,16 +4807,18 @@ discard block |
||
4578 | 4807 | { |
4579 | 4808 | $arIp[$i] = trim($arIp[$i]); |
4580 | 4809 | |
4581 | - if (empty($arIp[$i])) |
|
4582 | - continue; |
|
4810 | + if (empty($arIp[$i])) { |
|
4811 | + continue; |
|
4812 | + } |
|
4583 | 4813 | |
4584 | 4814 | $updates['ip' . $i] = $arIp[$i]; |
4585 | 4815 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
4586 | 4816 | |
4587 | 4817 | if ($setSize > 0 && $i % $setSize === 0) |
4588 | 4818 | { |
4589 | - if (count($updates) == 1) |
|
4590 | - continue; |
|
4819 | + if (count($updates) == 1) { |
|
4820 | + continue; |
|
4821 | + } |
|
4591 | 4822 | |
4592 | 4823 | $updates['whereSet'] = array_values($updates); |
4593 | 4824 | $smcFunc['db_query']('', ' |
@@ -4621,8 +4852,7 @@ discard block |
||
4621 | 4852 | 'ip' => $ip |
4622 | 4853 | )); |
4623 | 4854 | } |
4624 | - } |
|
4625 | - else |
|
4855 | + } else |
|
4626 | 4856 | { |
4627 | 4857 | $updates['whereSet'] = array_values($updates); |
4628 | 4858 | $smcFunc['db_query']('', ' |
@@ -4636,9 +4866,9 @@ discard block |
||
4636 | 4866 | $updates |
4637 | 4867 | ); |
4638 | 4868 | } |
4869 | + } else { |
|
4870 | + $is_done = true; |
|
4639 | 4871 | } |
4640 | - else |
|
4641 | - $is_done = true; |
|
4642 | 4872 | |
4643 | 4873 | $_GET['a'] += $limit; |
4644 | 4874 | $step_progress['current'] = $_GET['a']; |
@@ -4664,10 +4894,11 @@ discard block |
||
4664 | 4894 | |
4665 | 4895 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
4666 | 4896 | |
4667 | - if (isset($columns[$column])) |
|
4668 | - return $columns[$column]; |
|
4669 | - else |
|
4670 | - return null; |
|
4671 | -} |
|
4897 | + if (isset($columns[$column])) { |
|
4898 | + return $columns[$column]; |
|
4899 | + } else { |
|
4900 | + return null; |
|
4901 | + } |
|
4902 | + } |
|
4672 | 4903 | |
4673 | 4904 | ?> |
4674 | 4905 | \ No newline at end of file |
@@ -51,29 +51,34 @@ discard block |
||
51 | 51 | ); |
52 | 52 | |
53 | 53 | // No file? Thats bad. |
54 | -if (!isset($_SERVER['argv'], $_SERVER['argv'][1])) |
|
54 | +if (!isset($_SERVER['argv'], $_SERVER['argv'][1])) { |
|
55 | 55 | die('Error: No File specified' . "\n"); |
56 | +} |
|
56 | 57 | |
57 | 58 | // The file has to exist. |
58 | 59 | $currentFile = $_SERVER['argv'][1]; |
59 | -if (!file_exists($currentFile)) |
|
60 | +if (!file_exists($currentFile)) { |
|
60 | 61 | die('Error: File does not exist' . "\n"); |
62 | +} |
|
61 | 63 | |
62 | 64 | // Is this ignored? |
63 | -foreach ($ignoreFiles as $if) |
|
65 | +foreach ($ignoreFiles as $if) { |
|
64 | 66 | if (preg_match('~' . $if . '~i', $currentFile)) |
65 | 67 | die; |
68 | +} |
|
66 | 69 | |
67 | 70 | // Lets get the main index.php for $forum_version and $software_year. |
68 | 71 | $indexFile = fopen('./index.php', 'r'); |
69 | 72 | $indexContents = fread($indexFile, 850); |
70 | 73 | |
71 | -if (!preg_match('~\$forum_version = \'SMF ([^\']+)\';~i', $indexContents, $versionResults)) |
|
74 | +if (!preg_match('~\$forum_version = \'SMF ([^\']+)\';~i', $indexContents, $versionResults)) { |
|
72 | 75 | die('Error: Could not locate $forum_version' . "\n"); |
76 | +} |
|
73 | 77 | $currentVersion = $versionResults[1]; |
74 | 78 | |
75 | -if (!preg_match('~\$software_year = \'(\d{4})\';~i', $indexContents, $yearResults)) |
|
79 | +if (!preg_match('~\$software_year = \'(\d{4})\';~i', $indexContents, $yearResults)) { |
|
76 | 80 | die('Error: Could not locate $software_year' . "\n"); |
81 | +} |
|
77 | 82 | $currentSoftwareYear = (int) $yearResults[1]; |
78 | 83 | |
79 | 84 | $file = fopen($currentFile, 'r'); |
@@ -94,20 +99,23 @@ discard block |
||
94 | 99 | ); |
95 | 100 | |
96 | 101 | // Just see if the license is there. |
97 | -if (!preg_match('~' . implode('', $match) . '~i', $contents)) |
|
102 | +if (!preg_match('~' . implode('', $match) . '~i', $contents)) { |
|
98 | 103 | die('Error: License File is invalid or not found in ' . $currentFile . "\n"); |
104 | +} |
|
99 | 105 | |
100 | 106 | // Check the year is correct. |
101 | 107 | $yearMatch = $match; |
102 | 108 | $yearMatch[4] = ' \* @copyright ' . $currentSoftwareYear . ' Simple Machines and individual contributors' . '[\r]?\n'; |
103 | -if (!preg_match('~' . implode('', $yearMatch) . '~i', $contents)) |
|
109 | +if (!preg_match('~' . implode('', $yearMatch) . '~i', $contents)) { |
|
104 | 110 | die('Error: The software year is incorrect in ' . $currentFile . "\n"); |
111 | +} |
|
105 | 112 | |
106 | 113 | // Check the version is correct. |
107 | 114 | $versionMatch = $match; |
108 | 115 | $versionMatch[7] = ' \* @version ' . $currentVersion . '[\r]?\n'; |
109 | -if (!preg_match('~' . implode('', $versionMatch) . '~i', $contents)) |
|
116 | +if (!preg_match('~' . implode('', $versionMatch) . '~i', $contents)) { |
|
110 | 117 | die('Error: The version is incorrect in ' . $currentFile . "\n"); |
118 | +} |
|
111 | 119 | |
112 | 120 | // Special check, ugprade.php, install.php copyright templates. |
113 | 121 | if (in_array($currentFile, array('./other/upgrade.php', './other/install.php'))) |
@@ -115,9 +123,11 @@ discard block |
||
115 | 123 | // The code is fairly well into it, just get the entire contents. |
116 | 124 | $upgradeFile = file_get_contents($currentFile); |
117 | 125 | |
118 | - if (!preg_match('~<li class="copyright"><a href="http://www.simplemachines.org/" title="Simple Machines Forum" target="_blank" class="new_win">SMF © (\d{4}), Simple Machines</a></li>~i', $upgradeFile, $upgradeResults)) |
|
119 | - die('Error: Could not locate upgrade template copyright $software_year' . "\n"); |
|
126 | + if (!preg_match('~<li class="copyright"><a href="http://www.simplemachines.org/" title="Simple Machines Forum" target="_blank" class="new_win">SMF © (\d{4}), Simple Machines</a></li>~i', $upgradeFile, $upgradeResults)) { |
|
127 | + die('Error: Could not locate upgrade template copyright $software_year' . "\n"); |
|
128 | + } |
|
120 | 129 | |
121 | - if ((int) $upgradeResults[1] != $currentSoftwareYear) |
|
122 | - die('Error: Upgrade template copyright year is invalid' . "\n"); |
|
123 | -} |
|
124 | 130 | \ No newline at end of file |
131 | + if ((int) $upgradeResults[1] != $currentSoftwareYear) { |
|
132 | + die('Error: Upgrade template copyright year is invalid' . "\n"); |
|
133 | + } |
|
134 | + } |
|
125 | 135 | \ No newline at end of file |