@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 3 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $sourcedir, $profile_vars; |
30 | 31 | |
31 | 32 | // Don't load this twice! |
32 | - if (!empty($profile_fields) && !$force_reload) |
|
33 | - return; |
|
33 | + if (!empty($profile_fields) && !$force_reload) { |
|
34 | + return; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
104 | 106 | { |
105 | 107 | // Set to blank? |
106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
107 | - $value = '0001-01-01'; |
|
108 | - else |
|
109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
109 | + $value = '0001-01-01'; |
|
110 | + } else { |
|
111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
112 | + } |
|
113 | + } else { |
|
114 | + $value = '0001-01-01'; |
|
110 | 115 | } |
111 | - else |
|
112 | - $value = '0001-01-01'; |
|
113 | 116 | |
114 | 117 | $profile_vars['birthdate'] = $value; |
115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
127 | 130 | { |
128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '0001-01-01'; |
129 | 132 | return true; |
130 | - } |
|
131 | - else |
|
133 | + } else |
|
132 | 134 | { |
133 | 135 | $value = empty($cur_profile['birthdate']) ? '0001-01-01' : $cur_profile['birthdate']; |
134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
151 | 153 | } |
152 | 154 | // As long as it doesn't equal "N/A"... |
153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
155 | - else |
|
156 | - $value = $cur_profile['date_registered']; |
|
155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
157 | + } else { |
|
158 | + $value = $cur_profile['date_registered']; |
|
159 | + } |
|
157 | 160 | |
158 | 161 | return true; |
159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
177 | 180 | { |
178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
179 | 182 | |
180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
181 | - return false; |
|
183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
184 | + return false; |
|
185 | + } |
|
182 | 186 | |
183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
254 | 258 | |
255 | 259 | if (isset($context['profile_languages'][$value])) |
256 | 260 | { |
257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
258 | - $_SESSION['language'] = $value; |
|
261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
262 | + $_SESSION['language'] = $value; |
|
263 | + } |
|
259 | 264 | return true; |
260 | - } |
|
261 | - else |
|
265 | + } else |
|
262 | 266 | { |
263 | 267 | $value = $cur_profile['lngfile']; |
264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
282 | 286 | |
283 | 287 | // Maybe they are trying to change their password as well? |
284 | 288 | $resetPassword = true; |
285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
286 | - $resetPassword = false; |
|
289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
290 | + $resetPassword = false; |
|
291 | + } |
|
287 | 292 | |
288 | 293 | // Do the reset... this will send them an email too. |
289 | - if ($resetPassword) |
|
290 | - resetPassword($context['id_member'], $value); |
|
291 | - elseif ($value !== null) |
|
294 | + if ($resetPassword) { |
|
295 | + resetPassword($context['id_member'], $value); |
|
296 | + } elseif ($value !== null) |
|
292 | 297 | { |
293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
313 | 318 | { |
314 | 319 | // If we didn't try it then ignore it! |
315 | - if ($value == '') |
|
316 | - return false; |
|
320 | + if ($value == '') { |
|
321 | + return false; |
|
322 | + } |
|
317 | 323 | |
318 | 324 | // Do the two entries for the password even match? |
319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
320 | - return 'bad_new_password'; |
|
325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
326 | + return 'bad_new_password'; |
|
327 | + } |
|
321 | 328 | |
322 | 329 | // Let's get the validation function into play... |
323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
325 | 332 | |
326 | 333 | // Were there errors? |
327 | - if ($passwordErrors != null) |
|
328 | - return 'password_' . $passwordErrors; |
|
334 | + if ($passwordErrors != null) { |
|
335 | + return 'password_' . $passwordErrors; |
|
336 | + } |
|
329 | 337 | |
330 | 338 | // Set up the new password variable... ready for storage. |
331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
350 | 358 | 'permission' => 'profile_blurb', |
351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
352 | 360 | { |
353 | - if ($smcFunc['strlen']($value) > 50) |
|
354 | - return 'personal_text_too_long'; |
|
361 | + if ($smcFunc['strlen']($value) > 50) { |
|
362 | + return 'personal_text_too_long'; |
|
363 | + } |
|
355 | 364 | |
356 | 365 | return true; |
357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
386 | 395 | 'permission' => 'moderate_forum', |
387 | 396 | 'input_validate' => function(&$value) |
388 | 397 | { |
389 | - if (!is_numeric($value)) |
|
390 | - return 'digits_only'; |
|
391 | - else |
|
392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
398 | + if (!is_numeric($value)) { |
|
399 | + return 'digits_only'; |
|
400 | + } else { |
|
401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
402 | + } |
|
393 | 403 | return true; |
394 | 404 | }, |
395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
405 | 415 | { |
406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
407 | 417 | |
408 | - if (trim($value) == '') |
|
409 | - return 'no_name'; |
|
410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
411 | - return 'name_too_long'; |
|
412 | - elseif ($cur_profile['real_name'] != $value) |
|
418 | + if (trim($value) == '') { |
|
419 | + return 'no_name'; |
|
420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
421 | + return 'name_too_long'; |
|
422 | + } elseif ($cur_profile['real_name'] != $value) |
|
413 | 423 | { |
414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
415 | - if (isReservedName($value, $context['id_member'])) |
|
416 | - return 'name_taken'; |
|
425 | + if (isReservedName($value, $context['id_member'])) { |
|
426 | + return 'name_taken'; |
|
427 | + } |
|
417 | 428 | } |
418 | 429 | return true; |
419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
472 | 483 | ); |
473 | 484 | |
474 | - if ($context['smiley_sets'][$i]['selected']) |
|
475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
487 | + } |
|
476 | 488 | } |
477 | 489 | return true; |
478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
481 | 493 | global $modSettings; |
482 | 494 | |
483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
485 | - $value = ''; |
|
496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
497 | + $value = ''; |
|
498 | + } |
|
486 | 499 | return true; |
487 | 500 | }, |
488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
497 | 510 | loadLanguage('Settings'); |
498 | 511 | |
499 | 512 | $context['allow_no_censored'] = false; |
500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
515 | + } |
|
502 | 516 | |
503 | 517 | return true; |
504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
545 | 559 | 'input_validate' => function($value) |
546 | 560 | { |
547 | 561 | $tz = smf_list_timezones(); |
548 | - if (!isset($tz[$value])) |
|
549 | - return 'bad_timezone'; |
|
562 | + if (!isset($tz[$value])) { |
|
563 | + return 'bad_timezone'; |
|
564 | + } |
|
550 | 565 | |
551 | 566 | return true; |
552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
563 | 578 | { |
564 | - if ($smcFunc['strlen']($value) > 50) |
|
565 | - return 'user_title_too_long'; |
|
579 | + if ($smcFunc['strlen']($value) > 50) { |
|
580 | + return 'user_title_too_long'; |
|
581 | + } |
|
566 | 582 | |
567 | 583 | return true; |
568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
584 | 600 | // Fix the URL... |
585 | 601 | 'input_validate' => function(&$value) |
586 | 602 | { |
587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
588 | - $value = 'http://' . $value; |
|
589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
590 | - $value = ''; |
|
603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
604 | + $value = 'http://' . $value; |
|
605 | + } |
|
606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
607 | + $value = ''; |
|
608 | + } |
|
591 | 609 | return true; |
592 | 610 | }, |
593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
601 | 619 | foreach ($profile_fields as $key => $field) |
602 | 620 | { |
603 | 621 | // Do we have permission to do this? |
604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
605 | - unset($profile_fields[$key]); |
|
622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
623 | + unset($profile_fields[$key]); |
|
624 | + } |
|
606 | 625 | |
607 | 626 | // Is it enabled? |
608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
609 | - unset($profile_fields[$key]); |
|
627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
628 | + unset($profile_fields[$key]); |
|
629 | + } |
|
610 | 630 | |
611 | 631 | // Is it specifically disabled? |
612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
613 | - unset($profile_fields[$key]); |
|
632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
633 | + unset($profile_fields[$key]); |
|
634 | + } |
|
614 | 635 | } |
615 | 636 | } |
616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
635 | 656 | loadProfileFields(true); |
636 | 657 | |
637 | 658 | // First check for any linked sets. |
638 | - foreach ($profile_fields as $key => $field) |
|
639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
659 | + foreach ($profile_fields as $key => $field) { |
|
660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
640 | 661 | $fields[] = $key; |
662 | + } |
|
641 | 663 | |
642 | 664 | $i = 0; |
643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
649 | 671 | $cur_field = &$profile_fields[$field]; |
650 | 672 | |
651 | 673 | // Does it have a preload and does that preload succeed? |
652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
653 | - continue; |
|
674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
675 | + continue; |
|
676 | + } |
|
654 | 677 | |
655 | 678 | // If this is anything but complex we need to do more cleaning! |
656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
657 | 680 | { |
658 | - if (!isset($cur_field['label'])) |
|
659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
681 | + if (!isset($cur_field['label'])) { |
|
682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
683 | + } |
|
660 | 684 | |
661 | 685 | // Everything has a value! |
662 | - if (!isset($cur_field['value'])) |
|
663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
686 | + if (!isset($cur_field['value'])) { |
|
687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
688 | + } |
|
664 | 689 | |
665 | 690 | // Any input attributes? |
666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
667 | 692 | } |
668 | 693 | |
669 | 694 | // Was there an error with this field on posting? |
670 | - if (isset($context['profile_errors'][$field])) |
|
671 | - $cur_field['is_error'] = true; |
|
695 | + if (isset($context['profile_errors'][$field])) { |
|
696 | + $cur_field['is_error'] = true; |
|
697 | + } |
|
672 | 698 | |
673 | 699 | // Any javascript stuff? |
674 | - if (!empty($cur_field['js_submit'])) |
|
675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
676 | - if (!empty($cur_field['js'])) |
|
677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
700 | + if (!empty($cur_field['js_submit'])) { |
|
701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
702 | + } |
|
703 | + if (!empty($cur_field['js'])) { |
|
704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
705 | + } |
|
678 | 706 | |
679 | 707 | // Any template stuff? |
680 | - if (!empty($cur_field['prehtml'])) |
|
681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
682 | - if (!empty($cur_field['posthtml'])) |
|
683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
708 | + if (!empty($cur_field['prehtml'])) { |
|
709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
710 | + } |
|
711 | + if (!empty($cur_field['posthtml'])) { |
|
712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
713 | + } |
|
684 | 714 | |
685 | 715 | // Finally put it into context? |
686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
713 | 743 | }, false);' : ''), true); |
714 | 744 | |
715 | 745 | // Any onsubmit javascript? |
716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
748 | + } |
|
718 | 749 | |
719 | 750 | // Any totally custom stuff? |
720 | - if (!empty($context['profile_javascript'])) |
|
721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
751 | + if (!empty($context['profile_javascript'])) { |
|
752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
753 | + } |
|
722 | 754 | |
723 | 755 | // Free up some memory. |
724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
739 | 771 | |
740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
741 | 773 | $context['profile_execute_on_save'] = array(); |
742 | - if ($context['user']['is_owner']) |
|
743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
774 | + if ($context['user']['is_owner']) { |
|
775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
776 | + } |
|
744 | 777 | |
745 | 778 | // Assume we log nothing. |
746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
748 | 781 | // Cycle through the profile fields working out what to do! |
749 | 782 | foreach ($profile_fields as $key => $field) |
750 | 783 | { |
751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
752 | - continue; |
|
784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
785 | + continue; |
|
786 | + } |
|
753 | 787 | |
754 | 788 | // What gets updated? |
755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
778 | 812 | |
779 | 813 | // Finally, clean up certain types. |
780 | - if ($field['cast_type'] == 'int') |
|
781 | - $_POST[$key] = (int) $_POST[$key]; |
|
782 | - elseif ($field['cast_type'] == 'float') |
|
783 | - $_POST[$key] = (float) $_POST[$key]; |
|
784 | - elseif ($field['cast_type'] == 'check') |
|
785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
814 | + if ($field['cast_type'] == 'int') { |
|
815 | + $_POST[$key] = (int) $_POST[$key]; |
|
816 | + } elseif ($field['cast_type'] == 'float') { |
|
817 | + $_POST[$key] = (float) $_POST[$key]; |
|
818 | + } elseif ($field['cast_type'] == 'check') { |
|
819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
820 | + } |
|
786 | 821 | |
787 | 822 | // If we got here we're doing OK. |
788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
793 | 828 | $cur_profile[$key] = $_POST[$key]; |
794 | 829 | |
795 | 830 | // Are we logging it? |
796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
797 | - $context['log_changes'][$key] = array( |
|
831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
832 | + $context['log_changes'][$key] = array( |
|
798 | 833 | 'previous' => $old_profile[$key], |
799 | 834 | 'new' => $_POST[$key], |
800 | 835 | ); |
836 | + } |
|
801 | 837 | } |
802 | 838 | |
803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
830 | 866 | { |
831 | 867 | foreach ($groups as $id => $group) |
832 | 868 | { |
833 | - if (isset($context['member_groups'][$group])) |
|
834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
835 | - else |
|
836 | - unset($additional_groups[$type][$id]); |
|
869 | + if (isset($context['member_groups'][$group])) { |
|
870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
871 | + } else { |
|
872 | + unset($additional_groups[$type][$id]); |
|
873 | + } |
|
837 | 874 | } |
838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
844 | 881 | } |
845 | 882 | |
846 | 883 | // @todo Temporary |
847 | - if ($context['user']['is_owner']) |
|
848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
849 | - else |
|
850 | - $changeOther = allowedTo('profile_extra_any'); |
|
884 | + if ($context['user']['is_owner']) { |
|
885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
886 | + } else { |
|
887 | + $changeOther = allowedTo('profile_extra_any'); |
|
888 | + } |
|
851 | 889 | if ($changeOther && empty($post_errors)) |
852 | 890 | { |
853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
855 | 893 | { |
856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
857 | 895 | |
858 | - if (!empty($custom_fields_errors)) |
|
859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
896 | + if (!empty($custom_fields_errors)) { |
|
897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
898 | + } |
|
860 | 899 | } |
861 | 900 | } |
862 | 901 | |
@@ -882,9 +921,9 @@ discard block |
||
882 | 921 | if ($context['user']['is_owner']) |
883 | 922 | { |
884 | 923 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
924 | + } else { |
|
925 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
885 | 926 | } |
886 | - else |
|
887 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
888 | 927 | |
889 | 928 | // Arrays of all the changes - makes things easier. |
890 | 929 | $profile_bools = array(); |
@@ -895,22 +934,25 @@ discard block |
||
895 | 934 | 'ignore_boards', |
896 | 935 | ); |
897 | 936 | |
898 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
899 | - $_POST['ignore_brd'] = array(); |
|
937 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
938 | + $_POST['ignore_brd'] = array(); |
|
939 | + } |
|
900 | 940 | |
901 | 941 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
902 | 942 | if (isset($_POST['ignore_brd'])) |
903 | 943 | { |
904 | - if (!is_array($_POST['ignore_brd'])) |
|
905 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
944 | + if (!is_array($_POST['ignore_brd'])) { |
|
945 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
946 | + } |
|
906 | 947 | |
907 | 948 | foreach ($_POST['ignore_brd'] as $k => $d) |
908 | 949 | { |
909 | 950 | $d = (int) $d; |
910 | - if ($d != 0) |
|
911 | - $_POST['ignore_brd'][$k] = $d; |
|
912 | - else |
|
913 | - unset($_POST['ignore_brd'][$k]); |
|
951 | + if ($d != 0) { |
|
952 | + $_POST['ignore_brd'][$k] = $d; |
|
953 | + } else { |
|
954 | + unset($_POST['ignore_brd'][$k]); |
|
955 | + } |
|
914 | 956 | } |
915 | 957 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
916 | 958 | unset($_POST['ignore_brd']); |
@@ -923,21 +965,26 @@ discard block |
||
923 | 965 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
924 | 966 | //makeAvatarChanges($memID, $post_errors); |
925 | 967 | |
926 | - if (!empty($_REQUEST['sa'])) |
|
927 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
968 | + if (!empty($_REQUEST['sa'])) { |
|
969 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
970 | + } |
|
928 | 971 | |
929 | - foreach ($profile_bools as $var) |
|
930 | - if (isset($_POST[$var])) |
|
972 | + foreach ($profile_bools as $var) { |
|
973 | + if (isset($_POST[$var])) |
|
931 | 974 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
932 | - foreach ($profile_ints as $var) |
|
933 | - if (isset($_POST[$var])) |
|
975 | + } |
|
976 | + foreach ($profile_ints as $var) { |
|
977 | + if (isset($_POST[$var])) |
|
934 | 978 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
935 | - foreach ($profile_floats as $var) |
|
936 | - if (isset($_POST[$var])) |
|
979 | + } |
|
980 | + foreach ($profile_floats as $var) { |
|
981 | + if (isset($_POST[$var])) |
|
937 | 982 | $profile_vars[$var] = (float) $_POST[$var]; |
938 | - foreach ($profile_strings as $var) |
|
939 | - if (isset($_POST[$var])) |
|
983 | + } |
|
984 | + foreach ($profile_strings as $var) { |
|
985 | + if (isset($_POST[$var])) |
|
940 | 986 | $profile_vars[$var] = $_POST[$var]; |
987 | + } |
|
941 | 988 | } |
942 | 989 | } |
943 | 990 | |
@@ -971,8 +1018,9 @@ discard block |
||
971 | 1018 | ); |
972 | 1019 | |
973 | 1020 | // Can't change reserved vars. |
974 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
975 | - fatal_lang_error('no_access', false); |
|
1021 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
1022 | + fatal_lang_error('no_access', false); |
|
1023 | + } |
|
976 | 1024 | |
977 | 1025 | // Don't allow any overriding of custom fields with default or non-default options. |
978 | 1026 | $request = $smcFunc['db_query']('', ' |
@@ -984,8 +1032,9 @@ discard block |
||
984 | 1032 | ) |
985 | 1033 | ); |
986 | 1034 | $custom_fields = array(); |
987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
988 | - $custom_fields[] = $row['col_name']; |
|
1035 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1036 | + $custom_fields[] = $row['col_name']; |
|
1037 | + } |
|
989 | 1038 | $smcFunc['db_free_result']($request); |
990 | 1039 | |
991 | 1040 | // These are the theme changes... |
@@ -994,33 +1043,39 @@ discard block |
||
994 | 1043 | { |
995 | 1044 | foreach ($_POST['options'] as $opt => $val) |
996 | 1045 | { |
997 | - if (in_array($opt, $custom_fields)) |
|
998 | - continue; |
|
1046 | + if (in_array($opt, $custom_fields)) { |
|
1047 | + continue; |
|
1048 | + } |
|
999 | 1049 | |
1000 | 1050 | // These need to be controlled. |
1001 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1002 | - $val = max(0, min($val, 50)); |
|
1051 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1052 | + $val = max(0, min($val, 50)); |
|
1053 | + } |
|
1003 | 1054 | // We don't set this per theme anymore. |
1004 | - elseif ($opt == 'allow_no_censored') |
|
1005 | - continue; |
|
1055 | + elseif ($opt == 'allow_no_censored') { |
|
1056 | + continue; |
|
1057 | + } |
|
1006 | 1058 | |
1007 | 1059 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
1008 | 1060 | } |
1009 | 1061 | } |
1010 | 1062 | |
1011 | 1063 | $erase_options = array(); |
1012 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
1013 | - foreach ($_POST['default_options'] as $opt => $val) |
|
1064 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
1065 | + foreach ($_POST['default_options'] as $opt => $val) |
|
1014 | 1066 | { |
1015 | 1067 | if (in_array($opt, $custom_fields)) |
1016 | 1068 | continue; |
1069 | + } |
|
1017 | 1070 | |
1018 | 1071 | // These need to be controlled. |
1019 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1020 | - $val = max(0, min($val, 50)); |
|
1072 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1073 | + $val = max(0, min($val, 50)); |
|
1074 | + } |
|
1021 | 1075 | // Only let admins and owners change the censor. |
1022 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
1023 | - continue; |
|
1076 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
1077 | + continue; |
|
1078 | + } |
|
1024 | 1079 | |
1025 | 1080 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
1026 | 1081 | $erase_options[] = $opt; |
@@ -1056,8 +1111,9 @@ discard block |
||
1056 | 1111 | |
1057 | 1112 | // Admins can choose any theme, even if it's not enabled... |
1058 | 1113 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
1059 | - foreach ($themes as $t) |
|
1060 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1114 | + foreach ($themes as $t) { |
|
1115 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1116 | + } |
|
1061 | 1117 | } |
1062 | 1118 | } |
1063 | 1119 | |
@@ -1076,8 +1132,9 @@ discard block |
||
1076 | 1132 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
1077 | 1133 | { |
1078 | 1134 | // Make sure only integers are deleted. |
1079 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
1080 | - $_POST['notify_boards'][$index] = (int) $id; |
|
1135 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
1136 | + $_POST['notify_boards'][$index] = (int) $id; |
|
1137 | + } |
|
1081 | 1138 | |
1082 | 1139 | // id_board = 0 is reserved for topic notifications. |
1083 | 1140 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1096,8 +1153,9 @@ discard block |
||
1096 | 1153 | // We are editing topic notifications...... |
1097 | 1154 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
1098 | 1155 | { |
1099 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
1100 | - $_POST['notify_topics'][$index] = (int) $id; |
|
1156 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
1157 | + $_POST['notify_topics'][$index] = (int) $id; |
|
1158 | + } |
|
1101 | 1159 | |
1102 | 1160 | // Make sure there are no zeros left. |
1103 | 1161 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1111,16 +1169,18 @@ discard block |
||
1111 | 1169 | 'selected_member' => $memID, |
1112 | 1170 | ) |
1113 | 1171 | ); |
1114 | - foreach ($_POST['notify_topics'] as $topic) |
|
1115 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1172 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1173 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1174 | + } |
|
1116 | 1175 | } |
1117 | 1176 | |
1118 | 1177 | // We are removing topic preferences |
1119 | 1178 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
1120 | 1179 | { |
1121 | 1180 | $prefs = array(); |
1122 | - foreach ($_POST['notify_topics'] as $topic) |
|
1123 | - $prefs[] = 'topic_notify_' . $topic; |
|
1181 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1182 | + $prefs[] = 'topic_notify_' . $topic; |
|
1183 | + } |
|
1124 | 1184 | deleteNotifyPrefs($memID, $prefs); |
1125 | 1185 | } |
1126 | 1186 | |
@@ -1128,8 +1188,9 @@ discard block |
||
1128 | 1188 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
1129 | 1189 | { |
1130 | 1190 | $prefs = array(); |
1131 | - foreach ($_POST['notify_boards'] as $board) |
|
1132 | - $prefs[] = 'board_notify_' . $board; |
|
1191 | + foreach ($_POST['notify_boards'] as $board) { |
|
1192 | + $prefs[] = 'board_notify_' . $board; |
|
1193 | + } |
|
1133 | 1194 | deleteNotifyPrefs($memID, $prefs); |
1134 | 1195 | } |
1135 | 1196 | } |
@@ -1150,8 +1211,9 @@ discard block |
||
1150 | 1211 | |
1151 | 1212 | $errors = array(); |
1152 | 1213 | |
1153 | - if ($sanitize && isset($_POST['customfield'])) |
|
1154 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1214 | + if ($sanitize && isset($_POST['customfield'])) { |
|
1215 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1216 | + } |
|
1155 | 1217 | |
1156 | 1218 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
1157 | 1219 | |
@@ -1176,48 +1238,49 @@ discard block |
||
1176 | 1238 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
1177 | 1239 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
1178 | 1240 | */ |
1179 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
1180 | - continue; |
|
1241 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
1242 | + continue; |
|
1243 | + } |
|
1181 | 1244 | |
1182 | 1245 | // Validate the user data. |
1183 | - if ($row['field_type'] == 'check') |
|
1184 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1185 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1246 | + if ($row['field_type'] == 'check') { |
|
1247 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1248 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1186 | 1249 | { |
1187 | 1250 | $value = $row['default_value']; |
1188 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1189 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1251 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
1252 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1190 | 1253 | $value = $v; |
1254 | + } |
|
1191 | 1255 | } |
1192 | 1256 | // Otherwise some form of text! |
1193 | 1257 | else |
1194 | 1258 | { |
1195 | 1259 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
1196 | - if ($row['field_length']) |
|
1197 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1260 | + if ($row['field_length']) { |
|
1261 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1262 | + } |
|
1198 | 1263 | |
1199 | 1264 | // Any masks? |
1200 | 1265 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
1201 | 1266 | { |
1202 | 1267 | if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
1203 | 1268 | { |
1204 | - if ($returnErrors) |
|
1205 | - $errors[] = 'custom_field_mail_fail'; |
|
1206 | - |
|
1207 | - else |
|
1208 | - $value = ''; |
|
1209 | - } |
|
1210 | - elseif ($row['mask'] == 'number') |
|
1269 | + if ($returnErrors) { |
|
1270 | + $errors[] = 'custom_field_mail_fail'; |
|
1271 | + } else { |
|
1272 | + $value = ''; |
|
1273 | + } |
|
1274 | + } elseif ($row['mask'] == 'number') |
|
1211 | 1275 | { |
1212 | 1276 | $value = (int) $value; |
1213 | - } |
|
1214 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1277 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1215 | 1278 | { |
1216 | - if ($returnErrors) |
|
1217 | - $errors[] = 'custom_field_regex_fail'; |
|
1218 | - |
|
1219 | - else |
|
1220 | - $value = ''; |
|
1279 | + if ($returnErrors) { |
|
1280 | + $errors[] = 'custom_field_regex_fail'; |
|
1281 | + } else { |
|
1282 | + $value = ''; |
|
1283 | + } |
|
1221 | 1284 | } |
1222 | 1285 | } |
1223 | 1286 | } |
@@ -1243,8 +1306,9 @@ discard block |
||
1243 | 1306 | |
1244 | 1307 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
1245 | 1308 | |
1246 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
1247 | - $errors = array_merge($errors, $hook_errors); |
|
1309 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
1310 | + $errors = array_merge($errors, $hook_errors); |
|
1311 | + } |
|
1248 | 1312 | |
1249 | 1313 | // Make those changes! |
1250 | 1314 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1262,9 +1326,10 @@ discard block |
||
1262 | 1326 | } |
1263 | 1327 | } |
1264 | 1328 | |
1265 | - if ($returnErrors) |
|
1266 | - return $errors; |
|
1267 | -} |
|
1329 | + if ($returnErrors) { |
|
1330 | + return $errors; |
|
1331 | + } |
|
1332 | + } |
|
1268 | 1333 | |
1269 | 1334 | /** |
1270 | 1335 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1276,8 +1341,9 @@ discard block |
||
1276 | 1341 | global $context, $txt, $modSettings; |
1277 | 1342 | |
1278 | 1343 | // Do a quick check to ensure people aren't getting here illegally! |
1279 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
1280 | - fatal_lang_error('no_access', false); |
|
1344 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
1345 | + fatal_lang_error('no_access', false); |
|
1346 | + } |
|
1281 | 1347 | |
1282 | 1348 | // Can we email the user direct? |
1283 | 1349 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1307,9 +1373,10 @@ discard block |
||
1307 | 1373 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
1308 | 1374 | $call = call_helper($subActions[$context['list_area']][0], true); |
1309 | 1375 | |
1310 | - if (!empty($call)) |
|
1311 | - call_user_func($call, $memID); |
|
1312 | -} |
|
1376 | + if (!empty($call)) { |
|
1377 | + call_user_func($call, $memID); |
|
1378 | + } |
|
1379 | + } |
|
1313 | 1380 | |
1314 | 1381 | /** |
1315 | 1382 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1323,9 +1390,10 @@ discard block |
||
1323 | 1390 | |
1324 | 1391 | // For making changes! |
1325 | 1392 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
1326 | - foreach ($buddiesArray as $k => $dummy) |
|
1327 | - if ($dummy == '') |
|
1393 | + foreach ($buddiesArray as $k => $dummy) { |
|
1394 | + if ($dummy == '') |
|
1328 | 1395 | unset($buddiesArray[$k]); |
1396 | + } |
|
1329 | 1397 | |
1330 | 1398 | // Removing a buddy? |
1331 | 1399 | if (isset($_GET['remove'])) |
@@ -1337,10 +1405,11 @@ discard block |
||
1337 | 1405 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1338 | 1406 | |
1339 | 1407 | // Heh, I'm lazy, do it the easy way... |
1340 | - foreach ($buddiesArray as $key => $buddy) |
|
1341 | - if ($buddy == (int) $_GET['remove']) |
|
1408 | + foreach ($buddiesArray as $key => $buddy) { |
|
1409 | + if ($buddy == (int) $_GET['remove']) |
|
1342 | 1410 | { |
1343 | 1411 | unset($buddiesArray[$key]); |
1412 | + } |
|
1344 | 1413 | $_SESSION['prf-save'] = true; |
1345 | 1414 | } |
1346 | 1415 | |
@@ -1350,8 +1419,7 @@ discard block |
||
1350 | 1419 | |
1351 | 1420 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1352 | 1421 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
1353 | - } |
|
1354 | - elseif (isset($_POST['new_buddy'])) |
|
1422 | + } elseif (isset($_POST['new_buddy'])) |
|
1355 | 1423 | { |
1356 | 1424 | checkSession(); |
1357 | 1425 | |
@@ -1364,8 +1432,9 @@ discard block |
||
1364 | 1432 | { |
1365 | 1433 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
1366 | 1434 | |
1367 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1368 | - unset($new_buddies[$k]); |
|
1435 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1436 | + unset($new_buddies[$k]); |
|
1437 | + } |
|
1369 | 1438 | } |
1370 | 1439 | |
1371 | 1440 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1385,16 +1454,18 @@ discard block |
||
1385 | 1454 | ) |
1386 | 1455 | ); |
1387 | 1456 | |
1388 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1389 | - $_SESSION['prf-save'] = true; |
|
1457 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1458 | + $_SESSION['prf-save'] = true; |
|
1459 | + } |
|
1390 | 1460 | |
1391 | 1461 | // Add the new member to the buddies array. |
1392 | 1462 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1393 | 1463 | { |
1394 | - if (in_array($row['id_member'], $buddiesArray)) |
|
1395 | - continue; |
|
1396 | - else |
|
1397 | - $buddiesArray[] = (int) $row['id_member']; |
|
1464 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
1465 | + continue; |
|
1466 | + } else { |
|
1467 | + $buddiesArray[] = (int) $row['id_member']; |
|
1468 | + } |
|
1398 | 1469 | } |
1399 | 1470 | $smcFunc['db_free_result']($request); |
1400 | 1471 | |
@@ -1424,18 +1495,20 @@ discard block |
||
1424 | 1495 | |
1425 | 1496 | $context['custom_pf'] = array(); |
1426 | 1497 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
1427 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1428 | - if (!isset($disabled_fields[$row['col_name']])) |
|
1498 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1499 | + if (!isset($disabled_fields[$row['col_name']])) |
|
1429 | 1500 | $context['custom_pf'][$row['col_name']] = array( |
1430 | 1501 | 'label' => $row['field_name'], |
1431 | 1502 | 'type' => $row['field_type'], |
1432 | 1503 | 'bbc' => !empty($row['bbc']), |
1433 | 1504 | 'enclose' => $row['enclose'], |
1434 | 1505 | ); |
1506 | + } |
|
1435 | 1507 | |
1436 | 1508 | // Gotta disable the gender option. |
1437 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
1438 | - unset($context['custom_pf']['cust_gender']); |
|
1509 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
1510 | + unset($context['custom_pf']['cust_gender']); |
|
1511 | + } |
|
1439 | 1512 | |
1440 | 1513 | $smcFunc['db_free_result']($request); |
1441 | 1514 | |
@@ -1452,8 +1525,9 @@ discard block |
||
1452 | 1525 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
1453 | 1526 | ) |
1454 | 1527 | ); |
1455 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1456 | - $buddies[] = $row['id_member']; |
|
1528 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1529 | + $buddies[] = $row['id_member']; |
|
1530 | + } |
|
1457 | 1531 | $smcFunc['db_free_result']($result); |
1458 | 1532 | } |
1459 | 1533 | |
@@ -1481,30 +1555,32 @@ discard block |
||
1481 | 1555 | continue; |
1482 | 1556 | } |
1483 | 1557 | |
1484 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1485 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1486 | - |
|
1487 | - elseif ($column['type'] == 'check') |
|
1488 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1558 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1559 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1560 | + } elseif ($column['type'] == 'check') { |
|
1561 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1562 | + } |
|
1489 | 1563 | |
1490 | 1564 | // Enclosing the user input within some other text? |
1491 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1492 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1565 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1566 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1493 | 1567 | '{SCRIPTURL}' => $scripturl, |
1494 | 1568 | '{IMAGES_URL}' => $settings['images_url'], |
1495 | 1569 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1496 | 1570 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
1497 | 1571 | )); |
1572 | + } |
|
1498 | 1573 | } |
1499 | 1574 | } |
1500 | 1575 | } |
1501 | 1576 | |
1502 | 1577 | if (isset($_SESSION['prf-save'])) |
1503 | 1578 | { |
1504 | - if ($_SESSION['prf-save'] === true) |
|
1505 | - $context['saved_successful'] = true; |
|
1506 | - else |
|
1507 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1579 | + if ($_SESSION['prf-save'] === true) { |
|
1580 | + $context['saved_successful'] = true; |
|
1581 | + } else { |
|
1582 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1583 | + } |
|
1508 | 1584 | |
1509 | 1585 | unset($_SESSION['prf-save']); |
1510 | 1586 | } |
@@ -1524,9 +1600,10 @@ discard block |
||
1524 | 1600 | |
1525 | 1601 | // For making changes! |
1526 | 1602 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
1527 | - foreach ($ignoreArray as $k => $dummy) |
|
1528 | - if ($dummy == '') |
|
1603 | + foreach ($ignoreArray as $k => $dummy) { |
|
1604 | + if ($dummy == '') |
|
1529 | 1605 | unset($ignoreArray[$k]); |
1606 | + } |
|
1530 | 1607 | |
1531 | 1608 | // Removing a member from the ignore list? |
1532 | 1609 | if (isset($_GET['remove'])) |
@@ -1536,10 +1613,11 @@ discard block |
||
1536 | 1613 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1537 | 1614 | |
1538 | 1615 | // Heh, I'm lazy, do it the easy way... |
1539 | - foreach ($ignoreArray as $key => $id_remove) |
|
1540 | - if ($id_remove == (int) $_GET['remove']) |
|
1616 | + foreach ($ignoreArray as $key => $id_remove) { |
|
1617 | + if ($id_remove == (int) $_GET['remove']) |
|
1541 | 1618 | { |
1542 | 1619 | unset($ignoreArray[$key]); |
1620 | + } |
|
1543 | 1621 | $_SESSION['prf-save'] = true; |
1544 | 1622 | } |
1545 | 1623 | |
@@ -1549,8 +1627,7 @@ discard block |
||
1549 | 1627 | |
1550 | 1628 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1551 | 1629 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
1552 | - } |
|
1553 | - elseif (isset($_POST['new_ignore'])) |
|
1630 | + } elseif (isset($_POST['new_ignore'])) |
|
1554 | 1631 | { |
1555 | 1632 | checkSession(); |
1556 | 1633 | // Prepare the string for extraction... |
@@ -1562,8 +1639,9 @@ discard block |
||
1562 | 1639 | { |
1563 | 1640 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
1564 | 1641 | |
1565 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1566 | - unset($new_entries[$k]); |
|
1642 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1643 | + unset($new_entries[$k]); |
|
1644 | + } |
|
1567 | 1645 | } |
1568 | 1646 | |
1569 | 1647 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1581,16 +1659,18 @@ discard block |
||
1581 | 1659 | ) |
1582 | 1660 | ); |
1583 | 1661 | |
1584 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1585 | - $_SESSION['prf-save'] = true; |
|
1662 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1663 | + $_SESSION['prf-save'] = true; |
|
1664 | + } |
|
1586 | 1665 | |
1587 | 1666 | // Add the new member to the buddies array. |
1588 | 1667 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1589 | 1668 | { |
1590 | - if (in_array($row['id_member'], $ignoreArray)) |
|
1591 | - continue; |
|
1592 | - else |
|
1593 | - $ignoreArray[] = (int) $row['id_member']; |
|
1669 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
1670 | + continue; |
|
1671 | + } else { |
|
1672 | + $ignoreArray[] = (int) $row['id_member']; |
|
1673 | + } |
|
1594 | 1674 | } |
1595 | 1675 | $smcFunc['db_free_result']($request); |
1596 | 1676 | |
@@ -1619,8 +1699,9 @@ discard block |
||
1619 | 1699 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
1620 | 1700 | ) |
1621 | 1701 | ); |
1622 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1623 | - $ignored[] = $row['id_member']; |
|
1702 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1703 | + $ignored[] = $row['id_member']; |
|
1704 | + } |
|
1624 | 1705 | $smcFunc['db_free_result']($result); |
1625 | 1706 | } |
1626 | 1707 | |
@@ -1639,10 +1720,11 @@ discard block |
||
1639 | 1720 | |
1640 | 1721 | if (isset($_SESSION['prf-save'])) |
1641 | 1722 | { |
1642 | - if ($_SESSION['prf-save'] === true) |
|
1643 | - $context['saved_successful'] = true; |
|
1644 | - else |
|
1645 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1723 | + if ($_SESSION['prf-save'] === true) { |
|
1724 | + $context['saved_successful'] = true; |
|
1725 | + } else { |
|
1726 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1727 | + } |
|
1646 | 1728 | |
1647 | 1729 | unset($_SESSION['prf-save']); |
1648 | 1730 | } |
@@ -1658,8 +1740,9 @@ discard block |
||
1658 | 1740 | global $context, $txt; |
1659 | 1741 | |
1660 | 1742 | loadThemeOptions($memID); |
1661 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
1662 | - loadCustomFields($memID, 'account'); |
|
1743 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
1744 | + loadCustomFields($memID, 'account'); |
|
1745 | + } |
|
1663 | 1746 | |
1664 | 1747 | $context['sub_template'] = 'edit_options'; |
1665 | 1748 | $context['page_desc'] = $txt['account_info']; |
@@ -1686,8 +1769,9 @@ discard block |
||
1686 | 1769 | global $context, $txt; |
1687 | 1770 | |
1688 | 1771 | loadThemeOptions($memID); |
1689 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
1690 | - loadCustomFields($memID, 'forumprofile'); |
|
1772 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
1773 | + loadCustomFields($memID, 'forumprofile'); |
|
1774 | + } |
|
1691 | 1775 | |
1692 | 1776 | $context['sub_template'] = 'edit_options'; |
1693 | 1777 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1720,18 +1804,21 @@ discard block |
||
1720 | 1804 | $dirs = array(); |
1721 | 1805 | $files = array(); |
1722 | 1806 | |
1723 | - if (!$dir) |
|
1724 | - return array(); |
|
1807 | + if (!$dir) { |
|
1808 | + return array(); |
|
1809 | + } |
|
1725 | 1810 | |
1726 | 1811 | while ($line = $dir->read()) |
1727 | 1812 | { |
1728 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
1729 | - continue; |
|
1813 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
1814 | + continue; |
|
1815 | + } |
|
1730 | 1816 | |
1731 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
1732 | - $dirs[] = $line; |
|
1733 | - else |
|
1734 | - $files[] = $line; |
|
1817 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
1818 | + $dirs[] = $line; |
|
1819 | + } else { |
|
1820 | + $files[] = $line; |
|
1821 | + } |
|
1735 | 1822 | } |
1736 | 1823 | $dir->close(); |
1737 | 1824 | |
@@ -1752,14 +1839,15 @@ discard block |
||
1752 | 1839 | foreach ($dirs as $line) |
1753 | 1840 | { |
1754 | 1841 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
1755 | - if (!empty($tmp)) |
|
1756 | - $result[] = array( |
|
1842 | + if (!empty($tmp)) { |
|
1843 | + $result[] = array( |
|
1757 | 1844 | 'filename' => $smcFunc['htmlspecialchars']($line), |
1758 | 1845 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
1759 | 1846 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
1760 | 1847 | 'is_dir' => true, |
1761 | 1848 | 'files' => $tmp |
1762 | 1849 | ); |
1850 | + } |
|
1763 | 1851 | unset($tmp); |
1764 | 1852 | } |
1765 | 1853 | |
@@ -1769,8 +1857,9 @@ discard block |
||
1769 | 1857 | $extension = substr(strrchr($line, '.'), 1); |
1770 | 1858 | |
1771 | 1859 | // Make sure it is an image. |
1772 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
1773 | - continue; |
|
1860 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
1861 | + continue; |
|
1862 | + } |
|
1774 | 1863 | |
1775 | 1864 | $result[] = array( |
1776 | 1865 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1778,8 +1867,9 @@ discard block |
||
1778 | 1867 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
1779 | 1868 | 'is_dir' => false |
1780 | 1869 | ); |
1781 | - if ($level == 1) |
|
1782 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
1870 | + if ($level == 1) { |
|
1871 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
1872 | + } |
|
1783 | 1873 | } |
1784 | 1874 | |
1785 | 1875 | return $result; |
@@ -1795,8 +1885,9 @@ discard block |
||
1795 | 1885 | global $txt, $context; |
1796 | 1886 | |
1797 | 1887 | loadThemeOptions($memID); |
1798 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
1799 | - loadCustomFields($memID, 'theme'); |
|
1888 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
1889 | + loadCustomFields($memID, 'theme'); |
|
1890 | + } |
|
1800 | 1891 | |
1801 | 1892 | $context['sub_template'] = 'edit_options'; |
1802 | 1893 | $context['page_desc'] = $txt['theme_info']; |
@@ -1850,16 +1941,19 @@ discard block |
||
1850 | 1941 | { |
1851 | 1942 | global $txt, $user_profile, $context, $modSettings, $smcFunc, $sourcedir; |
1852 | 1943 | |
1853 | - if (!isset($context['token_check'])) |
|
1854 | - $context['token_check'] = 'profile-nt' . $memID; |
|
1944 | + if (!isset($context['token_check'])) { |
|
1945 | + $context['token_check'] = 'profile-nt' . $memID; |
|
1946 | + } |
|
1855 | 1947 | |
1856 | 1948 | is_not_guest(); |
1857 | - if (!$context['user']['is_owner']) |
|
1858 | - isAllowedTo('profile_extra_any'); |
|
1949 | + if (!$context['user']['is_owner']) { |
|
1950 | + isAllowedTo('profile_extra_any'); |
|
1951 | + } |
|
1859 | 1952 | |
1860 | 1953 | // Set the post action if we're coming from the profile... |
1861 | - if (!isset($context['action'])) |
|
1862 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1954 | + if (!isset($context['action'])) { |
|
1955 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1956 | + } |
|
1863 | 1957 | |
1864 | 1958 | // What options are set |
1865 | 1959 | loadThemeOptions($memID); |
@@ -1946,28 +2040,34 @@ discard block |
||
1946 | 2040 | ); |
1947 | 2041 | |
1948 | 2042 | // There are certain things that are disabled at the group level. |
1949 | - if (empty($modSettings['cal_enabled'])) |
|
1950 | - unset($alert_types['calendar']); |
|
2043 | + if (empty($modSettings['cal_enabled'])) { |
|
2044 | + unset($alert_types['calendar']); |
|
2045 | + } |
|
1951 | 2046 | |
1952 | 2047 | // Disable paid subscriptions at group level if they're disabled |
1953 | - if (empty($modSettings['paid_enabled'])) |
|
1954 | - unset($alert_types['paidsubs']); |
|
2048 | + if (empty($modSettings['paid_enabled'])) { |
|
2049 | + unset($alert_types['paidsubs']); |
|
2050 | + } |
|
1955 | 2051 | |
1956 | 2052 | // Disable membergroup requests at group level if they're disabled |
1957 | - if (empty($modSettings['show_group_membership'])) |
|
1958 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2053 | + if (empty($modSettings['show_group_membership'])) { |
|
2054 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2055 | + } |
|
1959 | 2056 | |
1960 | 2057 | // Disable mentions if they're disabled |
1961 | - if (empty($modSettings['enable_mentions'])) |
|
1962 | - unset($alert_types['msg']['msg_mention']); |
|
2058 | + if (empty($modSettings['enable_mentions'])) { |
|
2059 | + unset($alert_types['msg']['msg_mention']); |
|
2060 | + } |
|
1963 | 2061 | |
1964 | 2062 | // Disable likes if they're disabled |
1965 | - if (empty($modSettings['enable_likes'])) |
|
1966 | - unset($alert_types['msg']['msg_like']); |
|
2063 | + if (empty($modSettings['enable_likes'])) { |
|
2064 | + unset($alert_types['msg']['msg_like']); |
|
2065 | + } |
|
1967 | 2066 | |
1968 | 2067 | // Disable buddy requests if they're disabled |
1969 | - if (empty($modSettings['enable_buddylist'])) |
|
1970 | - unset($alert_types['members']['buddy_request']); |
|
2068 | + if (empty($modSettings['enable_buddylist'])) { |
|
2069 | + unset($alert_types['members']['buddy_request']); |
|
2070 | + } |
|
1971 | 2071 | |
1972 | 2072 | // Now, now, we could pass this through global but we should really get into the habit of |
1973 | 2073 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -1995,15 +2095,17 @@ discard block |
||
1995 | 2095 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
1996 | 2096 | } |
1997 | 2097 | |
1998 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
1999 | - unset($alert_types['members']['request_group']); |
|
2098 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
2099 | + unset($alert_types['members']['request_group']); |
|
2100 | + } |
|
2000 | 2101 | |
2001 | 2102 | foreach ($alert_types as $group => $items) |
2002 | 2103 | { |
2003 | 2104 | foreach ($items as $alert_key => $alert_value) |
2004 | 2105 | { |
2005 | - if (!isset($alert_value['permission'])) |
|
2006 | - continue; |
|
2106 | + if (!isset($alert_value['permission'])) { |
|
2107 | + continue; |
|
2108 | + } |
|
2007 | 2109 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
2008 | 2110 | { |
2009 | 2111 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2011,12 +2113,14 @@ discard block |
||
2011 | 2113 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
2012 | 2114 | } |
2013 | 2115 | |
2014 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
2015 | - unset ($alert_types[$group][$alert_key]); |
|
2116 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
2117 | + unset ($alert_types[$group][$alert_key]); |
|
2118 | + } |
|
2016 | 2119 | } |
2017 | 2120 | |
2018 | - if (empty($alert_types[$group])) |
|
2019 | - unset ($alert_types[$group]); |
|
2121 | + if (empty($alert_types[$group])) { |
|
2122 | + unset ($alert_types[$group]); |
|
2123 | + } |
|
2020 | 2124 | } |
2021 | 2125 | } |
2022 | 2126 | |
@@ -2048,9 +2152,9 @@ discard block |
||
2048 | 2152 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
2049 | 2153 | break; |
2050 | 2154 | case 'select': |
2051 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
2052 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2053 | - else |
|
2155 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
2156 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2157 | + } else |
|
2054 | 2158 | { |
2055 | 2159 | // We didn't have a sane value. Let's grab the first item from the possibles. |
2056 | 2160 | $keys = array_keys($this_option['opts']); |
@@ -2070,23 +2174,28 @@ discard block |
||
2070 | 2174 | $this_value = 0; |
2071 | 2175 | foreach ($context['alert_bits'] as $type => $bitvalue) |
2072 | 2176 | { |
2073 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
2074 | - $this_value |= $bitvalue; |
|
2177 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
2178 | + $this_value |= $bitvalue; |
|
2179 | + } |
|
2180 | + } |
|
2181 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
2182 | + $update_prefs[$item_key] = $this_value; |
|
2075 | 2183 | } |
2076 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
2077 | - $update_prefs[$item_key] = $this_value; |
|
2078 | 2184 | } |
2079 | 2185 | } |
2080 | 2186 | |
2081 | - if (!empty($_POST['opt_alert_timeout'])) |
|
2082 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2187 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
2188 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2189 | + } |
|
2083 | 2190 | |
2084 | - if (!empty($_POST['notify_announcements'])) |
|
2085 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2191 | + if (!empty($_POST['notify_announcements'])) { |
|
2192 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2193 | + } |
|
2086 | 2194 | |
2087 | 2195 | setNotifyPrefs((int) $memID, $update_prefs); |
2088 | - foreach ($update_prefs as $pref => $value) |
|
2089 | - $context['alert_prefs'][$pref] = $value; |
|
2196 | + foreach ($update_prefs as $pref => $value) { |
|
2197 | + $context['alert_prefs'][$pref] = $value; |
|
2198 | + } |
|
2090 | 2199 | |
2091 | 2200 | makeNotificationChanges($memID); |
2092 | 2201 | |
@@ -2116,8 +2225,9 @@ discard block |
||
2116 | 2225 | |
2117 | 2226 | // Now we're all set up. |
2118 | 2227 | is_not_guest(); |
2119 | - if (!$context['user']['is_owner']) |
|
2120 | - fatal_error('no_access'); |
|
2228 | + if (!$context['user']['is_owner']) { |
|
2229 | + fatal_error('no_access'); |
|
2230 | + } |
|
2121 | 2231 | |
2122 | 2232 | checkSession('get'); |
2123 | 2233 | |
@@ -2149,8 +2259,9 @@ discard block |
||
2149 | 2259 | { |
2150 | 2260 | global $smcFunc; |
2151 | 2261 | |
2152 | - if (empty($toMark) || empty($memID)) |
|
2153 | - return false; |
|
2262 | + if (empty($toMark) || empty($memID)) { |
|
2263 | + return false; |
|
2264 | + } |
|
2154 | 2265 | |
2155 | 2266 | $toMark = (array) $toMark; |
2156 | 2267 | |
@@ -2184,8 +2295,9 @@ discard block |
||
2184 | 2295 | { |
2185 | 2296 | global $smcFunc; |
2186 | 2297 | |
2187 | - if (empty($toDelete)) |
|
2188 | - return false; |
|
2298 | + if (empty($toDelete)) { |
|
2299 | + return false; |
|
2300 | + } |
|
2189 | 2301 | |
2190 | 2302 | $toDelete = (array) $toDelete; |
2191 | 2303 | |
@@ -2220,8 +2332,9 @@ discard block |
||
2220 | 2332 | { |
2221 | 2333 | global $smcFunc; |
2222 | 2334 | |
2223 | - if (empty($memID)) |
|
2224 | - return false; |
|
2335 | + if (empty($memID)) { |
|
2336 | + return false; |
|
2337 | + } |
|
2225 | 2338 | |
2226 | 2339 | $request = $smcFunc['db_query']('', ' |
2227 | 2340 | SELECT id_alert |
@@ -2298,8 +2411,9 @@ discard block |
||
2298 | 2411 | { |
2299 | 2412 | $link = $topic['link']; |
2300 | 2413 | |
2301 | - if ($topic['new']) |
|
2302 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2414 | + if ($topic['new']) { |
|
2415 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2416 | + } |
|
2303 | 2417 | |
2304 | 2418 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
2305 | 2419 | |
@@ -2450,8 +2564,9 @@ discard block |
||
2450 | 2564 | { |
2451 | 2565 | $link = $board['link']; |
2452 | 2566 | |
2453 | - if ($board['new']) |
|
2454 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2567 | + if ($board['new']) { |
|
2568 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2569 | + } |
|
2455 | 2570 | |
2456 | 2571 | return $link; |
2457 | 2572 | }, |
@@ -2651,8 +2766,8 @@ discard block |
||
2651 | 2766 | ) |
2652 | 2767 | ); |
2653 | 2768 | $notification_boards = array(); |
2654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2655 | - $notification_boards[] = array( |
|
2769 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2770 | + $notification_boards[] = array( |
|
2656 | 2771 | 'id' => $row['id_board'], |
2657 | 2772 | 'name' => $row['name'], |
2658 | 2773 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2660,6 +2775,7 @@ discard block |
||
2660 | 2775 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
2661 | 2776 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
2662 | 2777 | ); |
2778 | + } |
|
2663 | 2779 | $smcFunc['db_free_result']($request); |
2664 | 2780 | |
2665 | 2781 | return $notification_boards; |
@@ -2674,17 +2790,18 @@ discard block |
||
2674 | 2790 | { |
2675 | 2791 | global $context, $options, $cur_profile, $smcFunc; |
2676 | 2792 | |
2677 | - if (isset($_POST['default_options'])) |
|
2678 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2793 | + if (isset($_POST['default_options'])) { |
|
2794 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2795 | + } |
|
2679 | 2796 | |
2680 | 2797 | if ($context['user']['is_owner']) |
2681 | 2798 | { |
2682 | 2799 | $context['member']['options'] = $options; |
2683 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
2684 | - foreach ($_POST['options'] as $k => $v) |
|
2800 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
2801 | + foreach ($_POST['options'] as $k => $v) |
|
2685 | 2802 | $context['member']['options'][$k] = $v; |
2686 | - } |
|
2687 | - else |
|
2803 | + } |
|
2804 | + } else |
|
2688 | 2805 | { |
2689 | 2806 | $request = $smcFunc['db_query']('', ' |
2690 | 2807 | SELECT id_member, variable, value |
@@ -2705,8 +2822,9 @@ discard block |
||
2705 | 2822 | continue; |
2706 | 2823 | } |
2707 | 2824 | |
2708 | - if (isset($_POST['options'][$row['variable']])) |
|
2709 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
2825 | + if (isset($_POST['options'][$row['variable']])) { |
|
2826 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
2827 | + } |
|
2710 | 2828 | $context['member']['options'][$row['variable']] = $row['value']; |
2711 | 2829 | } |
2712 | 2830 | $smcFunc['db_free_result']($request); |
@@ -2714,8 +2832,9 @@ discard block |
||
2714 | 2832 | // Load up the default theme options for any missing. |
2715 | 2833 | foreach ($temp as $k => $v) |
2716 | 2834 | { |
2717 | - if (!isset($context['member']['options'][$k])) |
|
2718 | - $context['member']['options'][$k] = $v; |
|
2835 | + if (!isset($context['member']['options'][$k])) { |
|
2836 | + $context['member']['options'][$k] = $v; |
|
2837 | + } |
|
2719 | 2838 | } |
2720 | 2839 | } |
2721 | 2840 | } |
@@ -2730,8 +2849,9 @@ discard block |
||
2730 | 2849 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
2731 | 2850 | |
2732 | 2851 | // Have the admins enabled this option? |
2733 | - if (empty($modSettings['allow_ignore_boards'])) |
|
2734 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2852 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
2853 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2854 | + } |
|
2735 | 2855 | |
2736 | 2856 | // Find all the boards this user is allowed to see. |
2737 | 2857 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2751,12 +2871,13 @@ discard block |
||
2751 | 2871 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2752 | 2872 | { |
2753 | 2873 | // This category hasn't been set up yet.. |
2754 | - if (!isset($context['categories'][$row['id_cat']])) |
|
2755 | - $context['categories'][$row['id_cat']] = array( |
|
2874 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
2875 | + $context['categories'][$row['id_cat']] = array( |
|
2756 | 2876 | 'id' => $row['id_cat'], |
2757 | 2877 | 'name' => $row['cat_name'], |
2758 | 2878 | 'boards' => array() |
2759 | 2879 | ); |
2880 | + } |
|
2760 | 2881 | |
2761 | 2882 | // Set this board up, and let the template know when it's a child. (indent them..) |
2762 | 2883 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2786,18 +2907,20 @@ discard block |
||
2786 | 2907 | } |
2787 | 2908 | |
2788 | 2909 | $max_boards = ceil(count($temp_boards) / 2); |
2789 | - if ($max_boards == 1) |
|
2790 | - $max_boards = 2; |
|
2910 | + if ($max_boards == 1) { |
|
2911 | + $max_boards = 2; |
|
2912 | + } |
|
2791 | 2913 | |
2792 | 2914 | // Now, alternate them so they can be shown left and right ;). |
2793 | 2915 | $context['board_columns'] = array(); |
2794 | 2916 | for ($i = 0; $i < $max_boards; $i++) |
2795 | 2917 | { |
2796 | 2918 | $context['board_columns'][] = $temp_boards[$i]; |
2797 | - if (isset($temp_boards[$i + $max_boards])) |
|
2798 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2799 | - else |
|
2800 | - $context['board_columns'][] = array(); |
|
2919 | + if (isset($temp_boards[$i + $max_boards])) { |
|
2920 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2921 | + } else { |
|
2922 | + $context['board_columns'][] = array(); |
|
2923 | + } |
|
2801 | 2924 | } |
2802 | 2925 | |
2803 | 2926 | loadThemeOptions($memID); |
@@ -2866,8 +2989,9 @@ discard block |
||
2866 | 2989 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2867 | 2990 | { |
2868 | 2991 | // We should skip the administrator group if they don't have the admin_forum permission! |
2869 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
2870 | - continue; |
|
2992 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
2993 | + continue; |
|
2994 | + } |
|
2871 | 2995 | |
2872 | 2996 | $context['member_groups'][$row['id_group']] = array( |
2873 | 2997 | 'id' => $row['id_group'], |
@@ -2913,16 +3037,17 @@ discard block |
||
2913 | 3037 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
2914 | 3038 | // Warning message for signature image limits? |
2915 | 3039 | $context['signature_warning'] = ''; |
2916 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
2917 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
2918 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
2919 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3040 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
3041 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
3042 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
3043 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3044 | + } |
|
2920 | 3045 | |
2921 | 3046 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
2922 | 3047 | |
2923 | - if (empty($context['do_preview'])) |
|
2924 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
2925 | - else |
|
3048 | + if (empty($context['do_preview'])) { |
|
3049 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
3050 | + } else |
|
2926 | 3051 | { |
2927 | 3052 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
2928 | 3053 | $validation = profileValidateSignature($signature); |
@@ -2932,8 +3057,9 @@ discard block |
||
2932 | 3057 | $context['post_errors'] = array(); |
2933 | 3058 | } |
2934 | 3059 | $context['post_errors'][] = 'signature_not_yet_saved'; |
2935 | - if ($validation !== true && $validation !== false) |
|
2936 | - $context['post_errors'][] = $validation; |
|
3060 | + if ($validation !== true && $validation !== false) { |
|
3061 | + $context['post_errors'][] = $validation; |
|
3062 | + } |
|
2937 | 3063 | |
2938 | 3064 | censorText($context['member']['signature']); |
2939 | 3065 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2943,8 +3069,9 @@ discard block |
||
2943 | 3069 | } |
2944 | 3070 | |
2945 | 3071 | // Load the spell checker? |
2946 | - if ($context['show_spellchecking']) |
|
2947 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3072 | + if ($context['show_spellchecking']) { |
|
3073 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3074 | + } |
|
2948 | 3075 | |
2949 | 3076 | return true; |
2950 | 3077 | } |
@@ -2978,8 +3105,7 @@ discard block |
||
2978 | 3105 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
2979 | 3106 | ); |
2980 | 3107 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
2981 | - } |
|
2982 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
3108 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
2983 | 3109 | { |
2984 | 3110 | $context['member']['avatar'] += array( |
2985 | 3111 | 'choice' => 'upload', |
@@ -2989,33 +3115,34 @@ discard block |
||
2989 | 3115 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
2990 | 3116 | } |
2991 | 3117 | // Use "avatar_original" here so we show what the user entered even if the image proxy is enabled |
2992 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
2993 | - $context['member']['avatar'] += array( |
|
3118 | + elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
3119 | + $context['member']['avatar'] += array( |
|
2994 | 3120 | 'choice' => 'external', |
2995 | 3121 | 'server_pic' => 'blank.png', |
2996 | 3122 | 'external' => $cur_profile['avatar_original'] |
2997 | 3123 | ); |
2998 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
2999 | - $context['member']['avatar'] += array( |
|
3124 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
3125 | + $context['member']['avatar'] += array( |
|
3000 | 3126 | 'choice' => 'server_stored', |
3001 | 3127 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
3002 | 3128 | 'external' => 'http://' |
3003 | 3129 | ); |
3004 | - else |
|
3005 | - $context['member']['avatar'] += array( |
|
3130 | + } else { |
|
3131 | + $context['member']['avatar'] += array( |
|
3006 | 3132 | 'choice' => 'none', |
3007 | 3133 | 'server_pic' => 'blank.png', |
3008 | 3134 | 'external' => 'http://' |
3009 | 3135 | ); |
3136 | + } |
|
3010 | 3137 | |
3011 | 3138 | // Get a list of all the avatars. |
3012 | 3139 | if ($context['member']['avatar']['allow_server_stored']) |
3013 | 3140 | { |
3014 | 3141 | $context['avatar_list'] = array(); |
3015 | 3142 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
3143 | + } else { |
|
3144 | + $context['avatars'] = array(); |
|
3016 | 3145 | } |
3017 | - else |
|
3018 | - $context['avatars'] = array(); |
|
3019 | 3146 | |
3020 | 3147 | // Second level selected avatar... |
3021 | 3148 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3044,19 +3171,22 @@ discard block |
||
3044 | 3171 | ) |
3045 | 3172 | ); |
3046 | 3173 | $protected_groups = array(1); |
3047 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3048 | - $protected_groups[] = $row['id_group']; |
|
3174 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3175 | + $protected_groups[] = $row['id_group']; |
|
3176 | + } |
|
3049 | 3177 | $smcFunc['db_free_result']($request); |
3050 | 3178 | |
3051 | 3179 | $protected_groups = array_unique($protected_groups); |
3052 | 3180 | } |
3053 | 3181 | |
3054 | 3182 | // The account page allows the change of your id_group - but not to a protected group! |
3055 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
3056 | - $value = (int) $value; |
|
3183 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
3184 | + $value = (int) $value; |
|
3185 | + } |
|
3057 | 3186 | // ... otherwise it's the old group sir. |
3058 | - else |
|
3059 | - $value = $old_profile['id_group']; |
|
3187 | + else { |
|
3188 | + $value = $old_profile['id_group']; |
|
3189 | + } |
|
3060 | 3190 | |
3061 | 3191 | // Find the additional membergroups (if any) |
3062 | 3192 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3065,16 +3195,18 @@ discard block |
||
3065 | 3195 | foreach ($_POST['additional_groups'] as $group_id) |
3066 | 3196 | { |
3067 | 3197 | $group_id = (int) $group_id; |
3068 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
3069 | - $additional_groups[] = $group_id; |
|
3198 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
3199 | + $additional_groups[] = $group_id; |
|
3200 | + } |
|
3070 | 3201 | } |
3071 | 3202 | |
3072 | 3203 | // Put the protected groups back in there if you don't have permission to take them away. |
3073 | 3204 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
3074 | 3205 | foreach ($old_additional_groups as $group_id) |
3075 | 3206 | { |
3076 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
3077 | - $additional_groups[] = $group_id; |
|
3207 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
3208 | + $additional_groups[] = $group_id; |
|
3209 | + } |
|
3078 | 3210 | } |
3079 | 3211 | |
3080 | 3212 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3106,18 +3238,20 @@ discard block |
||
3106 | 3238 | list ($another) = $smcFunc['db_fetch_row']($request); |
3107 | 3239 | $smcFunc['db_free_result']($request); |
3108 | 3240 | |
3109 | - if (empty($another)) |
|
3110 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
3241 | + if (empty($another)) { |
|
3242 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
3243 | + } |
|
3111 | 3244 | } |
3112 | 3245 | } |
3113 | 3246 | |
3114 | 3247 | // If we are changing group status, update permission cache as necessary. |
3115 | 3248 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
3116 | 3249 | { |
3117 | - if ($context['user']['is_owner']) |
|
3118 | - $_SESSION['mc']['time'] = 0; |
|
3119 | - else |
|
3120 | - updateSettings(array('settings_updated' => time())); |
|
3250 | + if ($context['user']['is_owner']) { |
|
3251 | + $_SESSION['mc']['time'] = 0; |
|
3252 | + } else { |
|
3253 | + updateSettings(array('settings_updated' => time())); |
|
3254 | + } |
|
3121 | 3255 | } |
3122 | 3256 | |
3123 | 3257 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3138,8 +3272,9 @@ discard block |
||
3138 | 3272 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
3139 | 3273 | |
3140 | 3274 | $memID = $context['id_member']; |
3141 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
3142 | - return false; |
|
3275 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
3276 | + return false; |
|
3277 | + } |
|
3143 | 3278 | |
3144 | 3279 | require_once($sourcedir . '/ManageAttachments.php'); |
3145 | 3280 | |
@@ -3150,8 +3285,9 @@ discard block |
||
3150 | 3285 | $downloadedExternalAvatar = false; |
3151 | 3286 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
3152 | 3287 | { |
3153 | - if (!is_writable($uploadDir)) |
|
3154 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3288 | + if (!is_writable($uploadDir)) { |
|
3289 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3290 | + } |
|
3155 | 3291 | |
3156 | 3292 | require_once($sourcedir . '/Subs-Package.php'); |
3157 | 3293 | |
@@ -3195,19 +3331,18 @@ discard block |
||
3195 | 3331 | |
3196 | 3332 | // Get rid of their old avatar. (if uploaded.) |
3197 | 3333 | removeAttachments(array('id_member' => $memID)); |
3198 | - } |
|
3199 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3334 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3200 | 3335 | { |
3201 | 3336 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
3202 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
3203 | - $profile_vars['avatar'] = 'gravatar://'; |
|
3204 | - else |
|
3205 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3337 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
3338 | + $profile_vars['avatar'] = 'gravatar://'; |
|
3339 | + } else { |
|
3340 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3341 | + } |
|
3206 | 3342 | |
3207 | 3343 | // Get rid of their old avatar. (if uploaded.) |
3208 | 3344 | removeAttachments(array('id_member' => $memID)); |
3209 | - } |
|
3210 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3345 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3211 | 3346 | { |
3212 | 3347 | // We need these clean... |
3213 | 3348 | $cur_profile['id_attach'] = 0; |
@@ -3219,11 +3354,13 @@ discard block |
||
3219 | 3354 | |
3220 | 3355 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
3221 | 3356 | |
3222 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
3223 | - $profile_vars['avatar'] = ''; |
|
3357 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
3358 | + $profile_vars['avatar'] = ''; |
|
3359 | + } |
|
3224 | 3360 | // Trying to make us do something we'll regret? |
3225 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
3226 | - return 'bad_avatar_invalid_url'; |
|
3361 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
3362 | + return 'bad_avatar_invalid_url'; |
|
3363 | + } |
|
3227 | 3364 | // Should we check dimensions? |
3228 | 3365 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
3229 | 3366 | { |
@@ -3233,9 +3370,9 @@ discard block |
||
3233 | 3370 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
3234 | 3371 | { |
3235 | 3372 | // Houston, we have a problem. The avatar is too large!! |
3236 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
3237 | - return 'bad_avatar_too_large'; |
|
3238 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3373 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
3374 | + return 'bad_avatar_too_large'; |
|
3375 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3239 | 3376 | { |
3240 | 3377 | // @todo remove this if appropriate |
3241 | 3378 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3245,26 +3382,27 @@ discard block |
||
3245 | 3382 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
3246 | 3383 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
3247 | 3384 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
3385 | + } else { |
|
3386 | + return 'bad_avatar'; |
|
3248 | 3387 | } |
3249 | - else |
|
3250 | - return 'bad_avatar'; |
|
3251 | 3388 | } |
3252 | 3389 | } |
3253 | 3390 | } |
3254 | - } |
|
3255 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3391 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3256 | 3392 | { |
3257 | 3393 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
3258 | 3394 | { |
3259 | 3395 | // Get the dimensions of the image. |
3260 | 3396 | if (!$downloadedExternalAvatar) |
3261 | 3397 | { |
3262 | - if (!is_writable($uploadDir)) |
|
3263 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3398 | + if (!is_writable($uploadDir)) { |
|
3399 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3400 | + } |
|
3264 | 3401 | |
3265 | 3402 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
3266 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
3267 | - fatal_lang_error('attach_timeout', 'critical'); |
|
3403 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
3404 | + fatal_lang_error('attach_timeout', 'critical'); |
|
3405 | + } |
|
3268 | 3406 | |
3269 | 3407 | $_FILES['attachment']['tmp_name'] = $new_filename; |
3270 | 3408 | } |
@@ -3377,17 +3515,19 @@ discard block |
||
3377 | 3515 | $profile_vars['avatar'] = ''; |
3378 | 3516 | |
3379 | 3517 | // Delete any temporary file. |
3380 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
3381 | - @unlink($_FILES['attachment']['tmp_name']); |
|
3518 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
3519 | + @unlink($_FILES['attachment']['tmp_name']); |
|
3520 | + } |
|
3382 | 3521 | } |
3383 | 3522 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
3384 | - else |
|
3523 | + else { |
|
3524 | + $profile_vars['avatar'] = ''; |
|
3525 | + } |
|
3526 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
3527 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3528 | + } else { |
|
3385 | 3529 | $profile_vars['avatar'] = ''; |
3386 | 3530 | } |
3387 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
3388 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3389 | - else |
|
3390 | - $profile_vars['avatar'] = ''; |
|
3391 | 3531 | |
3392 | 3532 | // Setup the profile variables so it shows things right on display! |
3393 | 3533 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3435,9 +3575,9 @@ discard block |
||
3435 | 3575 | $smiley_parsed = $unparsed_signature; |
3436 | 3576 | parsesmileys($smiley_parsed); |
3437 | 3577 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
3438 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
3439 | - return 'signature_allow_smileys'; |
|
3440 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3578 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
3579 | + return 'signature_allow_smileys'; |
|
3580 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3441 | 3581 | { |
3442 | 3582 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
3443 | 3583 | return 'signature_max_smileys'; |
@@ -3450,14 +3590,15 @@ discard block |
||
3450 | 3590 | { |
3451 | 3591 | $limit_broke = 0; |
3452 | 3592 | // Attempt to allow all sizes of abuse, so to speak. |
3453 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
3454 | - $limit_broke = $sig_limits[7] . 'px'; |
|
3455 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
3456 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3457 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
3458 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3459 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
3460 | - $limit_broke = 'large'; |
|
3593 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
3594 | + $limit_broke = $sig_limits[7] . 'px'; |
|
3595 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
3596 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3597 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
3598 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3599 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
3600 | + $limit_broke = 'large'; |
|
3601 | + } |
|
3461 | 3602 | |
3462 | 3603 | if ($limit_broke) |
3463 | 3604 | { |
@@ -3499,24 +3640,26 @@ discard block |
||
3499 | 3640 | $width = -1; $height = -1; |
3500 | 3641 | |
3501 | 3642 | // Does it have predefined restraints? Width first. |
3502 | - if ($matches[6][$key]) |
|
3503 | - $matches[2][$key] = $matches[6][$key]; |
|
3643 | + if ($matches[6][$key]) { |
|
3644 | + $matches[2][$key] = $matches[6][$key]; |
|
3645 | + } |
|
3504 | 3646 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
3505 | 3647 | { |
3506 | 3648 | $width = $sig_limits[5]; |
3507 | 3649 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
3650 | + } elseif ($matches[2][$key]) { |
|
3651 | + $width = $matches[2][$key]; |
|
3508 | 3652 | } |
3509 | - elseif ($matches[2][$key]) |
|
3510 | - $width = $matches[2][$key]; |
|
3511 | 3653 | // ... and height. |
3512 | 3654 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
3513 | 3655 | { |
3514 | 3656 | $height = $sig_limits[6]; |
3515 | - if ($width != -1) |
|
3516 | - $width = $width * ($height / $matches[4][$key]); |
|
3657 | + if ($width != -1) { |
|
3658 | + $width = $width * ($height / $matches[4][$key]); |
|
3659 | + } |
|
3660 | + } elseif ($matches[4][$key]) { |
|
3661 | + $height = $matches[4][$key]; |
|
3517 | 3662 | } |
3518 | - elseif ($matches[4][$key]) |
|
3519 | - $height = $matches[4][$key]; |
|
3520 | 3663 | |
3521 | 3664 | // If the dimensions are still not fixed - we need to check the actual image. |
3522 | 3665 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3534,21 +3677,24 @@ discard block |
||
3534 | 3677 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
3535 | 3678 | { |
3536 | 3679 | $height = $sig_limits[6]; |
3537 | - if ($width == -1) |
|
3538 | - $width = $sizes[0]; |
|
3680 | + if ($width == -1) { |
|
3681 | + $width = $sizes[0]; |
|
3682 | + } |
|
3539 | 3683 | $width = $width * ($height / $sizes[1]); |
3684 | + } elseif ($width != -1) { |
|
3685 | + $height = $sizes[1]; |
|
3540 | 3686 | } |
3541 | - elseif ($width != -1) |
|
3542 | - $height = $sizes[1]; |
|
3543 | 3687 | } |
3544 | 3688 | } |
3545 | 3689 | |
3546 | 3690 | // Did we come up with some changes? If so remake the string. |
3547 | - if ($width != -1 || $height != -1) |
|
3548 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3691 | + if ($width != -1 || $height != -1) { |
|
3692 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3693 | + } |
|
3694 | + } |
|
3695 | + if (!empty($replaces)) { |
|
3696 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3549 | 3697 | } |
3550 | - if (!empty($replaces)) |
|
3551 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3552 | 3698 | } |
3553 | 3699 | } |
3554 | 3700 | |
@@ -3592,10 +3738,12 @@ discard block |
||
3592 | 3738 | $email = strtr($email, array(''' => '\'')); |
3593 | 3739 | |
3594 | 3740 | // Check the name and email for validity. |
3595 | - if (trim($email) == '') |
|
3596 | - return 'no_email'; |
|
3597 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
3598 | - return 'bad_email'; |
|
3741 | + if (trim($email) == '') { |
|
3742 | + return 'no_email'; |
|
3743 | + } |
|
3744 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
3745 | + return 'bad_email'; |
|
3746 | + } |
|
3599 | 3747 | |
3600 | 3748 | // Email addresses should be and stay unique. |
3601 | 3749 | $request = $smcFunc['db_query']('', ' |
@@ -3610,8 +3758,9 @@ discard block |
||
3610 | 3758 | ) |
3611 | 3759 | ); |
3612 | 3760 | |
3613 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
3614 | - return 'email_taken'; |
|
3761 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
3762 | + return 'email_taken'; |
|
3763 | + } |
|
3615 | 3764 | $smcFunc['db_free_result']($request); |
3616 | 3765 | |
3617 | 3766 | return true; |
@@ -3624,8 +3773,9 @@ discard block |
||
3624 | 3773 | { |
3625 | 3774 | global $modSettings, $context, $cur_profile; |
3626 | 3775 | |
3627 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
3628 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3776 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
3777 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3778 | + } |
|
3629 | 3779 | |
3630 | 3780 | loadUserSettings(); |
3631 | 3781 | writeLog(); |
@@ -3641,8 +3791,9 @@ discard block |
||
3641 | 3791 | require_once($sourcedir . '/Subs-Post.php'); |
3642 | 3792 | |
3643 | 3793 | // Shouldn't happen but just in case. |
3644 | - if (empty($profile_vars['email_address'])) |
|
3645 | - return; |
|
3794 | + if (empty($profile_vars['email_address'])) { |
|
3795 | + return; |
|
3796 | + } |
|
3646 | 3797 | |
3647 | 3798 | $replacements = array( |
3648 | 3799 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3665,8 +3816,9 @@ discard block |
||
3665 | 3816 | $_SESSION['log_time'] = 0; |
3666 | 3817 | $_SESSION['login_' . $cookiename] = json_encode(array(0, '', 0)); |
3667 | 3818 | |
3668 | - if (isset($_COOKIE[$cookiename])) |
|
3669 | - $_COOKIE[$cookiename] = ''; |
|
3819 | + if (isset($_COOKIE[$cookiename])) { |
|
3820 | + $_COOKIE[$cookiename] = ''; |
|
3821 | + } |
|
3670 | 3822 | |
3671 | 3823 | loadUserSettings(); |
3672 | 3824 | |
@@ -3699,11 +3851,13 @@ discard block |
||
3699 | 3851 | $groups[] = $curMember['id_group']; |
3700 | 3852 | |
3701 | 3853 | // Ensure the query doesn't croak! |
3702 | - if (empty($groups)) |
|
3703 | - $groups = array(0); |
|
3854 | + if (empty($groups)) { |
|
3855 | + $groups = array(0); |
|
3856 | + } |
|
3704 | 3857 | // Just to be sure... |
3705 | - foreach ($groups as $k => $v) |
|
3706 | - $groups[$k] = (int) $v; |
|
3858 | + foreach ($groups as $k => $v) { |
|
3859 | + $groups[$k] = (int) $v; |
|
3860 | + } |
|
3707 | 3861 | |
3708 | 3862 | // Get all the membergroups they can join. |
3709 | 3863 | $request = $smcFunc['db_query']('', ' |
@@ -3733,12 +3887,14 @@ discard block |
||
3733 | 3887 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3734 | 3888 | { |
3735 | 3889 | // Can they edit their primary group? |
3736 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
3737 | - $context['can_edit_primary'] = true; |
|
3890 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
3891 | + $context['can_edit_primary'] = true; |
|
3892 | + } |
|
3738 | 3893 | |
3739 | 3894 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
3740 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
3741 | - continue; |
|
3895 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
3896 | + continue; |
|
3897 | + } |
|
3742 | 3898 | |
3743 | 3899 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
3744 | 3900 | 'id' => $row['id_group'], |
@@ -3767,13 +3923,15 @@ discard block |
||
3767 | 3923 | ); |
3768 | 3924 | |
3769 | 3925 | // No changing primary one unless you have enough groups! |
3770 | - if (count($context['groups']['member']) < 2) |
|
3771 | - $context['can_edit_primary'] = false; |
|
3926 | + if (count($context['groups']['member']) < 2) { |
|
3927 | + $context['can_edit_primary'] = false; |
|
3928 | + } |
|
3772 | 3929 | |
3773 | 3930 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
3774 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
3775 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3776 | -} |
|
3931 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
3932 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3933 | + } |
|
3934 | + } |
|
3777 | 3935 | |
3778 | 3936 | /** |
3779 | 3937 | * This function actually makes all the group changes |
@@ -3788,10 +3946,12 @@ discard block |
||
3788 | 3946 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
3789 | 3947 | |
3790 | 3948 | // Let's be extra cautious... |
3791 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
3792 | - isAllowedTo('manage_membergroups'); |
|
3793 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
3794 | - fatal_lang_error('no_access', false); |
|
3949 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
3950 | + isAllowedTo('manage_membergroups'); |
|
3951 | + } |
|
3952 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
3953 | + fatal_lang_error('no_access', false); |
|
3954 | + } |
|
3795 | 3955 | |
3796 | 3956 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
3797 | 3957 | |
@@ -3810,8 +3970,9 @@ discard block |
||
3810 | 3970 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
3811 | 3971 | |
3812 | 3972 | // Sanity check!! |
3813 | - if ($group_id == 1) |
|
3814 | - isAllowedTo('admin_forum'); |
|
3973 | + if ($group_id == 1) { |
|
3974 | + isAllowedTo('admin_forum'); |
|
3975 | + } |
|
3815 | 3976 | // Protected groups too! |
3816 | 3977 | else |
3817 | 3978 | { |
@@ -3828,8 +3989,9 @@ discard block |
||
3828 | 3989 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
3829 | 3990 | $smcFunc['db_free_result']($request); |
3830 | 3991 | |
3831 | - if ($is_protected == 1) |
|
3832 | - isAllowedTo('admin_forum'); |
|
3992 | + if ($is_protected == 1) { |
|
3993 | + isAllowedTo('admin_forum'); |
|
3994 | + } |
|
3833 | 3995 | } |
3834 | 3996 | |
3835 | 3997 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3851,36 +4013,43 @@ discard block |
||
3851 | 4013 | $group_name = $row['group_name']; |
3852 | 4014 | |
3853 | 4015 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
3854 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
3855 | - fatal_lang_error('no_access', false); |
|
4016 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
4017 | + fatal_lang_error('no_access', false); |
|
4018 | + } |
|
3856 | 4019 | // What about leaving a requestable group we are not a member of? |
3857 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
3858 | - fatal_lang_error('no_access', false); |
|
3859 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
3860 | - fatal_lang_error('no_access', false); |
|
4020 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
4021 | + fatal_lang_error('no_access', false); |
|
4022 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
4023 | + fatal_lang_error('no_access', false); |
|
4024 | + } |
|
3861 | 4025 | |
3862 | 4026 | // We can't change the primary group if this is hidden! |
3863 | - if ($row['hidden'] == 2) |
|
3864 | - $canChangePrimary = false; |
|
4027 | + if ($row['hidden'] == 2) { |
|
4028 | + $canChangePrimary = false; |
|
4029 | + } |
|
3865 | 4030 | } |
3866 | 4031 | |
3867 | 4032 | // If this is their old primary, can we change it? |
3868 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
3869 | - $canChangePrimary = 1; |
|
4033 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
4034 | + $canChangePrimary = 1; |
|
4035 | + } |
|
3870 | 4036 | |
3871 | 4037 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
3872 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
3873 | - $canChangePrimary = false; |
|
4038 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
4039 | + $canChangePrimary = false; |
|
4040 | + } |
|
3874 | 4041 | |
3875 | 4042 | // If this is the one we are acting on, can we even act? |
3876 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
3877 | - $canChangePrimary = false; |
|
4043 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
4044 | + $canChangePrimary = false; |
|
4045 | + } |
|
3878 | 4046 | } |
3879 | 4047 | $smcFunc['db_free_result']($request); |
3880 | 4048 | |
3881 | 4049 | // Didn't find the target? |
3882 | - if (!$foundTarget) |
|
3883 | - fatal_lang_error('no_access', false); |
|
4050 | + if (!$foundTarget) { |
|
4051 | + fatal_lang_error('no_access', false); |
|
4052 | + } |
|
3884 | 4053 | |
3885 | 4054 | // Final security check, don't allow users to promote themselves to admin. |
3886 | 4055 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3900,8 +4069,9 @@ discard block |
||
3900 | 4069 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
3901 | 4070 | $smcFunc['db_free_result']($request); |
3902 | 4071 | |
3903 | - if ($disallow) |
|
3904 | - isAllowedTo('admin_forum'); |
|
4072 | + if ($disallow) { |
|
4073 | + isAllowedTo('admin_forum'); |
|
4074 | + } |
|
3905 | 4075 | } |
3906 | 4076 | |
3907 | 4077 | // If we're requesting, add the note then return. |
@@ -3919,8 +4089,9 @@ discard block |
||
3919 | 4089 | 'status_open' => 0, |
3920 | 4090 | ) |
3921 | 4091 | ); |
3922 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
3923 | - fatal_lang_error('profile_error_already_requested_group'); |
|
4092 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
4093 | + fatal_lang_error('profile_error_already_requested_group'); |
|
4094 | + } |
|
3924 | 4095 | $smcFunc['db_free_result']($request); |
3925 | 4096 | |
3926 | 4097 | // Log the request. |
@@ -3954,10 +4125,11 @@ discard block |
||
3954 | 4125 | // Are we leaving? |
3955 | 4126 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
3956 | 4127 | { |
3957 | - if ($old_profile['id_group'] == $group_id) |
|
3958 | - $newPrimary = 0; |
|
3959 | - else |
|
3960 | - unset($addGroups[$group_id]); |
|
4128 | + if ($old_profile['id_group'] == $group_id) { |
|
4129 | + $newPrimary = 0; |
|
4130 | + } else { |
|
4131 | + unset($addGroups[$group_id]); |
|
4132 | + } |
|
3961 | 4133 | } |
3962 | 4134 | // ... if not, must be joining. |
3963 | 4135 | else |
@@ -3965,36 +4137,42 @@ discard block |
||
3965 | 4137 | // Can we change the primary, and do we want to? |
3966 | 4138 | if ($canChangePrimary) |
3967 | 4139 | { |
3968 | - if ($old_profile['id_group'] != 0) |
|
3969 | - $addGroups[$old_profile['id_group']] = -1; |
|
4140 | + if ($old_profile['id_group'] != 0) { |
|
4141 | + $addGroups[$old_profile['id_group']] = -1; |
|
4142 | + } |
|
3970 | 4143 | $newPrimary = $group_id; |
3971 | 4144 | } |
3972 | 4145 | // Otherwise it's an additional group... |
3973 | - else |
|
3974 | - $addGroups[$group_id] = -1; |
|
4146 | + else { |
|
4147 | + $addGroups[$group_id] = -1; |
|
4148 | + } |
|
3975 | 4149 | } |
3976 | 4150 | } |
3977 | 4151 | // Finally, we must be setting the primary. |
3978 | 4152 | elseif ($canChangePrimary) |
3979 | 4153 | { |
3980 | - if ($old_profile['id_group'] != 0) |
|
3981 | - $addGroups[$old_profile['id_group']] = -1; |
|
3982 | - if (isset($addGroups[$group_id])) |
|
3983 | - unset($addGroups[$group_id]); |
|
4154 | + if ($old_profile['id_group'] != 0) { |
|
4155 | + $addGroups[$old_profile['id_group']] = -1; |
|
4156 | + } |
|
4157 | + if (isset($addGroups[$group_id])) { |
|
4158 | + unset($addGroups[$group_id]); |
|
4159 | + } |
|
3984 | 4160 | $newPrimary = $group_id; |
3985 | 4161 | } |
3986 | 4162 | |
3987 | 4163 | // Finally, we can make the changes! |
3988 | - foreach ($addGroups as $id => $dummy) |
|
3989 | - if (empty($id)) |
|
4164 | + foreach ($addGroups as $id => $dummy) { |
|
4165 | + if (empty($id)) |
|
3990 | 4166 | unset($addGroups[$id]); |
4167 | + } |
|
3991 | 4168 | $addGroups = implode(',', array_flip($addGroups)); |
3992 | 4169 | |
3993 | 4170 | // Ensure that we don't cache permissions if the group is changing. |
3994 | - if ($context['user']['is_owner']) |
|
3995 | - $_SESSION['mc']['time'] = 0; |
|
3996 | - else |
|
3997 | - updateSettings(array('settings_updated' => time())); |
|
4171 | + if ($context['user']['is_owner']) { |
|
4172 | + $_SESSION['mc']['time'] = 0; |
|
4173 | + } else { |
|
4174 | + updateSettings(array('settings_updated' => time())); |
|
4175 | + } |
|
3998 | 4176 | |
3999 | 4177 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
4000 | 4178 | |
@@ -4017,8 +4195,9 @@ discard block |
||
4017 | 4195 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
4018 | 4196 | { |
4019 | 4197 | // Check to ensure we're forcing SSL for authentication |
4020 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
4021 | - fatal_lang_error('login_ssl_required'); |
|
4198 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
4199 | + fatal_lang_error('login_ssl_required'); |
|
4200 | + } |
|
4022 | 4201 | |
4023 | 4202 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
4024 | 4203 | // we do not want too much AJAX to confuse them. |
@@ -4055,8 +4234,7 @@ discard block |
||
4055 | 4234 | $context['sub_template'] = 'tfasetup_backup'; |
4056 | 4235 | |
4057 | 4236 | return; |
4058 | - } |
|
4059 | - else |
|
4237 | + } else |
|
4060 | 4238 | { |
4061 | 4239 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
4062 | 4240 | $context['tfa_error'] = !$valid_code; |
@@ -4064,8 +4242,7 @@ discard block |
||
4064 | 4242 | $context['tfa_pass_value'] = $_POST['passwd']; |
4065 | 4243 | $context['tfa_value'] = $_POST['tfa_code']; |
4066 | 4244 | } |
4067 | - } |
|
4068 | - else |
|
4245 | + } else |
|
4069 | 4246 | { |
4070 | 4247 | $totp = new \TOTP\Auth(); |
4071 | 4248 | $secret = $totp->generateCode(); |
@@ -4075,17 +4252,16 @@ discard block |
||
4075 | 4252 | } |
4076 | 4253 | |
4077 | 4254 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
4078 | - } |
|
4079 | - elseif (isset($_REQUEST['disable'])) |
|
4255 | + } elseif (isset($_REQUEST['disable'])) |
|
4080 | 4256 | { |
4081 | 4257 | updateMemberData($memID, array( |
4082 | 4258 | 'tfa_secret' => '', |
4083 | 4259 | 'tfa_backup' => '', |
4084 | 4260 | )); |
4085 | 4261 | redirectexit('action=profile;area=account;u=' . $memID); |
4262 | + } else { |
|
4263 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
4264 | + } |
|
4086 | 4265 | } |
4087 | - else |
|
4088 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
4089 | -} |
|
4090 | 4266 | |
4091 | 4267 | ?> |
4092 | 4268 | \ No newline at end of file |
@@ -81,8 +81,9 @@ discard block |
||
81 | 81 | $upcontext['inactive_timeout'] = 10; |
82 | 82 | |
83 | 83 | // The helper is crucial. Include it first thing. |
84 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
84 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
85 | 85 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
86 | +} |
|
86 | 87 | |
87 | 88 | require_once($upgrade_path . '/upgrade-helper.php'); |
88 | 89 | |
@@ -106,11 +107,14 @@ discard block |
||
106 | 107 | ini_set('default_socket_timeout', 900); |
107 | 108 | } |
108 | 109 | // Clean the upgrade path if this is from the client. |
109 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
110 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
110 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
111 | + for ($i = 1; |
|
112 | +} |
|
113 | +$i < $_SERVER['argc']; $i++) |
|
111 | 114 | { |
112 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
113 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
115 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
116 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
117 | + } |
|
114 | 118 | } |
115 | 119 | |
116 | 120 | // Are we from the client? |
@@ -118,9 +122,9 @@ discard block |
||
118 | 122 | { |
119 | 123 | $command_line = true; |
120 | 124 | $disable_security = true; |
121 | -} |
|
122 | -else |
|
125 | +} else { |
|
123 | 126 | $command_line = false; |
127 | +} |
|
124 | 128 | |
125 | 129 | // Load this now just because we can. |
126 | 130 | require_once($upgrade_path . '/Settings.php'); |
@@ -131,10 +135,12 @@ discard block |
||
131 | 135 | $upcontext['user'] = unserialize(base64_decode($upgradeData)); |
132 | 136 | |
133 | 137 | // Check for sensible values. |
134 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
135 | - $upcontext['user']['started'] = time(); |
|
136 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
137 | - $upcontext['user']['updated'] = 0; |
|
138 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
139 | + $upcontext['user']['started'] = time(); |
|
140 | + } |
|
141 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
142 | + $upcontext['user']['updated'] = 0; |
|
143 | + } |
|
138 | 144 | |
139 | 145 | $upcontext['started'] = $upcontext['user']['started']; |
140 | 146 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -192,8 +198,9 @@ discard block |
||
192 | 198 | 'db_error_skip' => true, |
193 | 199 | ) |
194 | 200 | ); |
195 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
196 | - $modSettings[$row['variable']] = $row['value']; |
|
201 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
202 | + $modSettings[$row['variable']] = $row['value']; |
|
203 | + } |
|
197 | 204 | $smcFunc['db_free_result']($request); |
198 | 205 | } |
199 | 206 | |
@@ -203,10 +210,12 @@ discard block |
||
203 | 210 | $modSettings['theme_url'] = 'Themes/default'; |
204 | 211 | $modSettings['images_url'] = 'Themes/default/images'; |
205 | 212 | } |
206 | -if (!isset($settings['default_theme_url'])) |
|
213 | +if (!isset($settings['default_theme_url'])) { |
|
207 | 214 | $settings['default_theme_url'] = $modSettings['theme_url']; |
208 | -if (!isset($settings['default_theme_dir'])) |
|
215 | +} |
|
216 | +if (!isset($settings['default_theme_dir'])) { |
|
209 | 217 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
218 | +} |
|
210 | 219 | |
211 | 220 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
212 | 221 | // Default title... |
@@ -224,13 +233,15 @@ discard block |
||
224 | 233 | $support_js = $upcontext['upgrade_status']['js']; |
225 | 234 | |
226 | 235 | // Only set this if the upgrader status says so. |
227 | - if (empty($is_debug)) |
|
228 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
236 | + if (empty($is_debug)) { |
|
237 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
238 | + } |
|
229 | 239 | |
230 | 240 | // Load the language. |
231 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
232 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
233 | -} |
|
241 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
242 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
243 | + } |
|
244 | + } |
|
234 | 245 | // Set the defaults. |
235 | 246 | else |
236 | 247 | { |
@@ -248,15 +259,18 @@ discard block |
||
248 | 259 | } |
249 | 260 | |
250 | 261 | // If this isn't the first stage see whether they are logging in and resuming. |
251 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
262 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
252 | 263 | checkLogin(); |
264 | +} |
|
253 | 265 | |
254 | -if ($command_line) |
|
266 | +if ($command_line) { |
|
255 | 267 | cmdStep0(); |
268 | +} |
|
256 | 269 | |
257 | 270 | // Don't error if we're using xml. |
258 | -if (isset($_GET['xml'])) |
|
271 | +if (isset($_GET['xml'])) { |
|
259 | 272 | $upcontext['return_error'] = true; |
273 | +} |
|
260 | 274 | |
261 | 275 | // Loop through all the steps doing each one as required. |
262 | 276 | $upcontext['overall_percent'] = 0; |
@@ -277,10 +291,11 @@ discard block |
||
277 | 291 | } |
278 | 292 | |
279 | 293 | // Call the step and if it returns false that means pause! |
280 | - if (function_exists($step[2]) && $step[2]() === false) |
|
281 | - break; |
|
282 | - elseif (function_exists($step[2])) |
|
283 | - $upcontext['current_step']++; |
|
294 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
295 | + break; |
|
296 | + } elseif (function_exists($step[2])) { |
|
297 | + $upcontext['current_step']++; |
|
298 | + } |
|
284 | 299 | } |
285 | 300 | $upcontext['overall_percent'] += $step[3]; |
286 | 301 | } |
@@ -319,17 +334,18 @@ discard block |
||
319 | 334 | // This should not happen my dear... HELP ME DEVELOPERS!! |
320 | 335 | if (!empty($command_line)) |
321 | 336 | { |
322 | - if (function_exists('debug_print_backtrace')) |
|
323 | - debug_print_backtrace(); |
|
337 | + if (function_exists('debug_print_backtrace')) { |
|
338 | + debug_print_backtrace(); |
|
339 | + } |
|
324 | 340 | |
325 | 341 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
326 | 342 | flush(); |
327 | 343 | die(); |
328 | 344 | } |
329 | 345 | |
330 | - if (!isset($_GET['xml'])) |
|
331 | - template_upgrade_above(); |
|
332 | - else |
|
346 | + if (!isset($_GET['xml'])) { |
|
347 | + template_upgrade_above(); |
|
348 | + } else |
|
333 | 349 | { |
334 | 350 | header('Content-Type: text/xml; charset=UTF-8'); |
335 | 351 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -351,21 +367,24 @@ discard block |
||
351 | 367 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(safe_serialize($upcontext['upgrade_status'])); |
352 | 368 | |
353 | 369 | // Custom stuff to pass back? |
354 | - if (!empty($upcontext['query_string'])) |
|
355 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
370 | + if (!empty($upcontext['query_string'])) { |
|
371 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
372 | + } |
|
356 | 373 | |
357 | 374 | call_user_func('template_' . $upcontext['sub_template']); |
358 | 375 | } |
359 | 376 | |
360 | 377 | // Was there an error? |
361 | - if (!empty($upcontext['forced_error_message'])) |
|
362 | - echo $upcontext['forced_error_message']; |
|
378 | + if (!empty($upcontext['forced_error_message'])) { |
|
379 | + echo $upcontext['forced_error_message']; |
|
380 | + } |
|
363 | 381 | |
364 | 382 | // Show the footer. |
365 | - if (!isset($_GET['xml'])) |
|
366 | - template_upgrade_below(); |
|
367 | - else |
|
368 | - template_xml_below(); |
|
383 | + if (!isset($_GET['xml'])) { |
|
384 | + template_upgrade_below(); |
|
385 | + } else { |
|
386 | + template_xml_below(); |
|
387 | + } |
|
369 | 388 | } |
370 | 389 | |
371 | 390 | |
@@ -377,15 +396,19 @@ discard block |
||
377 | 396 | $seconds = intval($active % 60); |
378 | 397 | |
379 | 398 | $totalTime = ''; |
380 | - if ($hours > 0) |
|
381 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
382 | - if ($minutes > 0) |
|
383 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
384 | - if ($seconds > 0) |
|
385 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
399 | + if ($hours > 0) { |
|
400 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
401 | + } |
|
402 | + if ($minutes > 0) { |
|
403 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
404 | + } |
|
405 | + if ($seconds > 0) { |
|
406 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
407 | + } |
|
386 | 408 | |
387 | - if (!empty($totalTime)) |
|
388 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
409 | + if (!empty($totalTime)) { |
|
410 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
411 | + } |
|
389 | 412 | } |
390 | 413 | |
391 | 414 | // Bang - gone! |
@@ -398,8 +421,9 @@ discard block |
||
398 | 421 | global $upgradeurl, $upcontext, $command_line; |
399 | 422 | |
400 | 423 | // Command line users can't be redirected. |
401 | - if ($command_line) |
|
402 | - upgradeExit(true); |
|
424 | + if ($command_line) { |
|
425 | + upgradeExit(true); |
|
426 | + } |
|
403 | 427 | |
404 | 428 | // Are we providing the core info? |
405 | 429 | if ($addForm) |
@@ -422,19 +446,22 @@ discard block |
||
422 | 446 | global $modSettings, $sourcedir, $smcFunc; |
423 | 447 | |
424 | 448 | // Do the non-SSI stuff... |
425 | - if (function_exists('set_magic_quotes_runtime')) |
|
426 | - @set_magic_quotes_runtime(0); |
|
449 | + if (function_exists('set_magic_quotes_runtime')) { |
|
450 | + @set_magic_quotes_runtime(0); |
|
451 | + } |
|
427 | 452 | |
428 | 453 | error_reporting(E_ALL); |
429 | 454 | define('SMF', 1); |
430 | 455 | |
431 | 456 | // Start the session. |
432 | - if (@ini_get('session.save_handler') == 'user') |
|
433 | - @ini_set('session.save_handler', 'files'); |
|
457 | + if (@ini_get('session.save_handler') == 'user') { |
|
458 | + @ini_set('session.save_handler', 'files'); |
|
459 | + } |
|
434 | 460 | @session_start(); |
435 | 461 | |
436 | - if (empty($smcFunc)) |
|
437 | - $smcFunc = array(); |
|
462 | + if (empty($smcFunc)) { |
|
463 | + $smcFunc = array(); |
|
464 | + } |
|
438 | 465 | |
439 | 466 | // We need this for authentication and some upgrade code |
440 | 467 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -446,8 +473,9 @@ discard block |
||
446 | 473 | initialize_inputs(); |
447 | 474 | |
448 | 475 | // Get the database going! |
449 | - if (empty($db_type) || $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']; |