@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 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 = '1001-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']) : '1001-01-01'; |
|
| 108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
| 109 | + $value = '1001-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']) : '1001-01-01'; |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + $value = '1001-01-01'; |
|
| 110 | 115 | } |
| 111 | - else |
|
| 112 | - $value = '1001-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]) : '1001-01-01'; |
| 129 | 132 | return true; |
| 130 | - } |
|
| 131 | - else |
|
| 133 | + } else |
|
| 132 | 134 | { |
| 133 | 135 | $value = empty($cur_profile['birthdate']) ? '1 |
| 134 | 136 | 001-01-01' : $cur_profile['birthdate']; |
@@ -151,10 +153,11 @@ discard block |
||
| 151 | 153 | 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)); |
| 152 | 154 | } |
| 153 | 155 | // As long as it doesn't equal "N/A"... |
| 154 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
| 155 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 156 | - else |
|
| 157 | - $value = $cur_profile['date_registered']; |
|
| 156 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
| 157 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 158 | + } else { |
|
| 159 | + $value = $cur_profile['date_registered']; |
|
| 160 | + } |
|
| 158 | 161 | |
| 159 | 162 | return true; |
| 160 | 163 | }, |
@@ -178,8 +181,9 @@ discard block |
||
| 178 | 181 | { |
| 179 | 182 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
| 180 | 183 | |
| 181 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
| 182 | - return false; |
|
| 184 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
| 185 | + return false; |
|
| 186 | + } |
|
| 183 | 187 | |
| 184 | 188 | $isValid = profileValidateEmail($value, $context['id_member']); |
| 185 | 189 | |
@@ -255,11 +259,11 @@ discard block |
||
| 255 | 259 | |
| 256 | 260 | if (isset($context['profile_languages'][$value])) |
| 257 | 261 | { |
| 258 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
| 259 | - $_SESSION['language'] = $value; |
|
| 262 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
| 263 | + $_SESSION['language'] = $value; |
|
| 264 | + } |
|
| 260 | 265 | return true; |
| 261 | - } |
|
| 262 | - else |
|
| 266 | + } else |
|
| 263 | 267 | { |
| 264 | 268 | $value = $cur_profile['lngfile']; |
| 265 | 269 | return false; |
@@ -283,13 +287,14 @@ discard block |
||
| 283 | 287 | |
| 284 | 288 | // Maybe they are trying to change their password as well? |
| 285 | 289 | $resetPassword = true; |
| 286 | - 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) |
|
| 287 | - $resetPassword = false; |
|
| 290 | + 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) { |
|
| 291 | + $resetPassword = false; |
|
| 292 | + } |
|
| 288 | 293 | |
| 289 | 294 | // Do the reset... this will send them an email too. |
| 290 | - if ($resetPassword) |
|
| 291 | - resetPassword($context['id_member'], $value); |
|
| 292 | - elseif ($value !== null) |
|
| 295 | + if ($resetPassword) { |
|
| 296 | + resetPassword($context['id_member'], $value); |
|
| 297 | + } elseif ($value !== null) |
|
| 293 | 298 | { |
| 294 | 299 | 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))); |
| 295 | 300 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -313,20 +318,23 @@ discard block |
||
| 313 | 318 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
| 314 | 319 | { |
| 315 | 320 | // If we didn't try it then ignore it! |
| 316 | - if ($value == '') |
|
| 317 | - return false; |
|
| 321 | + if ($value == '') { |
|
| 322 | + return false; |
|
| 323 | + } |
|
| 318 | 324 | |
| 319 | 325 | // Do the two entries for the password even match? |
| 320 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
| 321 | - return 'bad_new_password'; |
|
| 326 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
| 327 | + return 'bad_new_password'; |
|
| 328 | + } |
|
| 322 | 329 | |
| 323 | 330 | // Let's get the validation function into play... |
| 324 | 331 | require_once($sourcedir . '/Subs-Auth.php'); |
| 325 | 332 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
| 326 | 333 | |
| 327 | 334 | // Were there errors? |
| 328 | - if ($passwordErrors != null) |
|
| 329 | - return 'password_' . $passwordErrors; |
|
| 335 | + if ($passwordErrors != null) { |
|
| 336 | + return 'password_' . $passwordErrors; |
|
| 337 | + } |
|
| 330 | 338 | |
| 331 | 339 | // Set up the new password variable... ready for storage. |
| 332 | 340 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -351,8 +359,9 @@ discard block |
||
| 351 | 359 | 'permission' => 'profile_blurb', |
| 352 | 360 | 'input_validate' => function(&$value) use ($smcFunc) |
| 353 | 361 | { |
| 354 | - if ($smcFunc['strlen']($value) > 50) |
|
| 355 | - return 'personal_text_too_long'; |
|
| 362 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 363 | + return 'personal_text_too_long'; |
|
| 364 | + } |
|
| 356 | 365 | |
| 357 | 366 | return true; |
| 358 | 367 | }, |
@@ -387,10 +396,11 @@ discard block |
||
| 387 | 396 | 'permission' => 'moderate_forum', |
| 388 | 397 | 'input_validate' => function(&$value) |
| 389 | 398 | { |
| 390 | - if (!is_numeric($value)) |
|
| 391 | - return 'digits_only'; |
|
| 392 | - else |
|
| 393 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 399 | + if (!is_numeric($value)) { |
|
| 400 | + return 'digits_only'; |
|
| 401 | + } else { |
|
| 402 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 403 | + } |
|
| 394 | 404 | return true; |
| 395 | 405 | }, |
| 396 | 406 | ), |
@@ -406,15 +416,16 @@ discard block |
||
| 406 | 416 | { |
| 407 | 417 | $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)); |
| 408 | 418 | |
| 409 | - if (trim($value) == '') |
|
| 410 | - return 'no_name'; |
|
| 411 | - elseif ($smcFunc['strlen']($value) > 60) |
|
| 412 | - return 'name_too_long'; |
|
| 413 | - elseif ($cur_profile['real_name'] != $value) |
|
| 419 | + if (trim($value) == '') { |
|
| 420 | + return 'no_name'; |
|
| 421 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
| 422 | + return 'name_too_long'; |
|
| 423 | + } elseif ($cur_profile['real_name'] != $value) |
|
| 414 | 424 | { |
| 415 | 425 | require_once($sourcedir . '/Subs-Members.php'); |
| 416 | - if (isReservedName($value, $context['id_member'])) |
|
| 417 | - return 'name_taken'; |
|
| 426 | + if (isReservedName($value, $context['id_member'])) { |
|
| 427 | + return 'name_taken'; |
|
| 428 | + } |
|
| 418 | 429 | } |
| 419 | 430 | return true; |
| 420 | 431 | }, |
@@ -472,8 +483,9 @@ discard block |
||
| 472 | 483 | 'selected' => $set == $context['member']['smiley_set']['id'] |
| 473 | 484 | ); |
| 474 | 485 | |
| 475 | - if ($context['smiley_sets'][$i]['selected']) |
|
| 476 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 486 | + if ($context['smiley_sets'][$i]['selected']) { |
|
| 487 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 488 | + } |
|
| 477 | 489 | } |
| 478 | 490 | return true; |
| 479 | 491 | }, |
@@ -482,8 +494,9 @@ discard block |
||
| 482 | 494 | global $modSettings; |
| 483 | 495 | |
| 484 | 496 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
| 485 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
| 486 | - $value = ''; |
|
| 497 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
| 498 | + $value = ''; |
|
| 499 | + } |
|
| 487 | 500 | return true; |
| 488 | 501 | }, |
| 489 | 502 | ), |
@@ -498,8 +511,9 @@ discard block |
||
| 498 | 511 | loadLanguage('Settings'); |
| 499 | 512 | |
| 500 | 513 | $context['allow_no_censored'] = false; |
| 501 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
| 502 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 514 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
| 515 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 516 | + } |
|
| 503 | 517 | |
| 504 | 518 | return true; |
| 505 | 519 | }, |
@@ -546,8 +560,9 @@ discard block |
||
| 546 | 560 | 'input_validate' => function($value) |
| 547 | 561 | { |
| 548 | 562 | $tz = smf_list_timezones(); |
| 549 | - if (!isset($tz[$value])) |
|
| 550 | - return 'bad_timezone'; |
|
| 563 | + if (!isset($tz[$value])) { |
|
| 564 | + return 'bad_timezone'; |
|
| 565 | + } |
|
| 551 | 566 | |
| 552 | 567 | return true; |
| 553 | 568 | }, |
@@ -562,8 +577,9 @@ discard block |
||
| 562 | 577 | 'enabled' => !empty($modSettings['titlesEnable']), |
| 563 | 578 | 'input_validate' => function(&$value) use ($smcFunc) |
| 564 | 579 | { |
| 565 | - if ($smcFunc['strlen']($value) > 50) |
|
| 566 | - return 'user_title_too_long'; |
|
| 580 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 581 | + return 'user_title_too_long'; |
|
| 582 | + } |
|
| 567 | 583 | |
| 568 | 584 | return true; |
| 569 | 585 | }, |
@@ -585,10 +601,12 @@ discard block |
||
| 585 | 601 | // Fix the URL... |
| 586 | 602 | 'input_validate' => function(&$value) |
| 587 | 603 | { |
| 588 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
| 589 | - $value = 'http://' . $value; |
|
| 590 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
| 591 | - $value = ''; |
|
| 604 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
| 605 | + $value = 'http://' . $value; |
|
| 606 | + } |
|
| 607 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
| 608 | + $value = ''; |
|
| 609 | + } |
|
| 592 | 610 | return true; |
| 593 | 611 | }, |
| 594 | 612 | 'link_with' => 'website', |
@@ -602,16 +620,19 @@ discard block |
||
| 602 | 620 | foreach ($profile_fields as $key => $field) |
| 603 | 621 | { |
| 604 | 622 | // Do we have permission to do this? |
| 605 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
| 606 | - unset($profile_fields[$key]); |
|
| 623 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
| 624 | + unset($profile_fields[$key]); |
|
| 625 | + } |
|
| 607 | 626 | |
| 608 | 627 | // Is it enabled? |
| 609 | - if (isset($field['enabled']) && !$field['enabled']) |
|
| 610 | - unset($profile_fields[$key]); |
|
| 628 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
| 629 | + unset($profile_fields[$key]); |
|
| 630 | + } |
|
| 611 | 631 | |
| 612 | 632 | // Is it specifically disabled? |
| 613 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
| 614 | - unset($profile_fields[$key]); |
|
| 633 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
| 634 | + unset($profile_fields[$key]); |
|
| 635 | + } |
|
| 615 | 636 | } |
| 616 | 637 | } |
| 617 | 638 | |
@@ -636,9 +657,10 @@ discard block |
||
| 636 | 657 | loadProfileFields(true); |
| 637 | 658 | |
| 638 | 659 | // First check for any linked sets. |
| 639 | - foreach ($profile_fields as $key => $field) |
|
| 640 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 660 | + foreach ($profile_fields as $key => $field) { |
|
| 661 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 641 | 662 | $fields[] = $key; |
| 663 | + } |
|
| 642 | 664 | |
| 643 | 665 | $i = 0; |
| 644 | 666 | $last_type = ''; |
@@ -650,38 +672,46 @@ discard block |
||
| 650 | 672 | $cur_field = &$profile_fields[$field]; |
| 651 | 673 | |
| 652 | 674 | // Does it have a preload and does that preload succeed? |
| 653 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
| 654 | - continue; |
|
| 675 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
| 676 | + continue; |
|
| 677 | + } |
|
| 655 | 678 | |
| 656 | 679 | // If this is anything but complex we need to do more cleaning! |
| 657 | 680 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
| 658 | 681 | { |
| 659 | - if (!isset($cur_field['label'])) |
|
| 660 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 682 | + if (!isset($cur_field['label'])) { |
|
| 683 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 684 | + } |
|
| 661 | 685 | |
| 662 | 686 | // Everything has a value! |
| 663 | - if (!isset($cur_field['value'])) |
|
| 664 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 687 | + if (!isset($cur_field['value'])) { |
|
| 688 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 689 | + } |
|
| 665 | 690 | |
| 666 | 691 | // Any input attributes? |
| 667 | 692 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
| 668 | 693 | } |
| 669 | 694 | |
| 670 | 695 | // Was there an error with this field on posting? |
| 671 | - if (isset($context['profile_errors'][$field])) |
|
| 672 | - $cur_field['is_error'] = true; |
|
| 696 | + if (isset($context['profile_errors'][$field])) { |
|
| 697 | + $cur_field['is_error'] = true; |
|
| 698 | + } |
|
| 673 | 699 | |
| 674 | 700 | // Any javascript stuff? |
| 675 | - if (!empty($cur_field['js_submit'])) |
|
| 676 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 677 | - if (!empty($cur_field['js'])) |
|
| 678 | - $context['profile_javascript'] .= $cur_field['js']; |
|
| 701 | + if (!empty($cur_field['js_submit'])) { |
|
| 702 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 703 | + } |
|
| 704 | + if (!empty($cur_field['js'])) { |
|
| 705 | + $context['profile_javascript'] .= $cur_field['js']; |
|
| 706 | + } |
|
| 679 | 707 | |
| 680 | 708 | // Any template stuff? |
| 681 | - if (!empty($cur_field['prehtml'])) |
|
| 682 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 683 | - if (!empty($cur_field['posthtml'])) |
|
| 684 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 709 | + if (!empty($cur_field['prehtml'])) { |
|
| 710 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 711 | + } |
|
| 712 | + if (!empty($cur_field['posthtml'])) { |
|
| 713 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 714 | + } |
|
| 685 | 715 | |
| 686 | 716 | // Finally put it into context? |
| 687 | 717 | if ($cur_field['type'] != 'hidden') |
@@ -714,12 +744,14 @@ discard block |
||
| 714 | 744 | }, false);' : ''), true); |
| 715 | 745 | |
| 716 | 746 | // Any onsubmit javascript? |
| 717 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
| 718 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 747 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
| 748 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 749 | + } |
|
| 719 | 750 | |
| 720 | 751 | // Any totally custom stuff? |
| 721 | - if (!empty($context['profile_javascript'])) |
|
| 722 | - addInlineJavaScript($context['profile_javascript'], true); |
|
| 752 | + if (!empty($context['profile_javascript'])) { |
|
| 753 | + addInlineJavaScript($context['profile_javascript'], true); |
|
| 754 | + } |
|
| 723 | 755 | |
| 724 | 756 | // Free up some memory. |
| 725 | 757 | unset($profile_fields); |
@@ -740,8 +772,9 @@ discard block |
||
| 740 | 772 | |
| 741 | 773 | // This allows variables to call activities when they save - by default just to reload their settings |
| 742 | 774 | $context['profile_execute_on_save'] = array(); |
| 743 | - if ($context['user']['is_owner']) |
|
| 744 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 775 | + if ($context['user']['is_owner']) { |
|
| 776 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 777 | + } |
|
| 745 | 778 | |
| 746 | 779 | // Assume we log nothing. |
| 747 | 780 | $context['log_changes'] = array(); |
@@ -749,8 +782,9 @@ discard block |
||
| 749 | 782 | // Cycle through the profile fields working out what to do! |
| 750 | 783 | foreach ($profile_fields as $key => $field) |
| 751 | 784 | { |
| 752 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
| 753 | - continue; |
|
| 785 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
| 786 | + continue; |
|
| 787 | + } |
|
| 754 | 788 | |
| 755 | 789 | // What gets updated? |
| 756 | 790 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -778,12 +812,13 @@ discard block |
||
| 778 | 812 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
| 779 | 813 | |
| 780 | 814 | // Finally, clean up certain types. |
| 781 | - if ($field['cast_type'] == 'int') |
|
| 782 | - $_POST[$key] = (int) $_POST[$key]; |
|
| 783 | - elseif ($field['cast_type'] == 'float') |
|
| 784 | - $_POST[$key] = (float) $_POST[$key]; |
|
| 785 | - elseif ($field['cast_type'] == 'check') |
|
| 786 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 815 | + if ($field['cast_type'] == 'int') { |
|
| 816 | + $_POST[$key] = (int) $_POST[$key]; |
|
| 817 | + } elseif ($field['cast_type'] == 'float') { |
|
| 818 | + $_POST[$key] = (float) $_POST[$key]; |
|
| 819 | + } elseif ($field['cast_type'] == 'check') { |
|
| 820 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 821 | + } |
|
| 787 | 822 | |
| 788 | 823 | // If we got here we're doing OK. |
| 789 | 824 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -794,11 +829,12 @@ discard block |
||
| 794 | 829 | $cur_profile[$key] = $_POST[$key]; |
| 795 | 830 | |
| 796 | 831 | // Are we logging it? |
| 797 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
| 798 | - $context['log_changes'][$key] = array( |
|
| 832 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
| 833 | + $context['log_changes'][$key] = array( |
|
| 799 | 834 | 'previous' => $old_profile[$key], |
| 800 | 835 | 'new' => $_POST[$key], |
| 801 | 836 | ); |
| 837 | + } |
|
| 802 | 838 | } |
| 803 | 839 | |
| 804 | 840 | // Logging group changes are a bit different... |
@@ -831,10 +867,11 @@ discard block |
||
| 831 | 867 | { |
| 832 | 868 | foreach ($groups as $id => $group) |
| 833 | 869 | { |
| 834 | - if (isset($context['member_groups'][$group])) |
|
| 835 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 836 | - else |
|
| 837 | - unset($additional_groups[$type][$id]); |
|
| 870 | + if (isset($context['member_groups'][$group])) { |
|
| 871 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 872 | + } else { |
|
| 873 | + unset($additional_groups[$type][$id]); |
|
| 874 | + } |
|
| 838 | 875 | } |
| 839 | 876 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
| 840 | 877 | } |
@@ -845,10 +882,11 @@ discard block |
||
| 845 | 882 | } |
| 846 | 883 | |
| 847 | 884 | // @todo Temporary |
| 848 | - if ($context['user']['is_owner']) |
|
| 849 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 850 | - else |
|
| 851 | - $changeOther = allowedTo('profile_extra_any'); |
|
| 885 | + if ($context['user']['is_owner']) { |
|
| 886 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 887 | + } else { |
|
| 888 | + $changeOther = allowedTo('profile_extra_any'); |
|
| 889 | + } |
|
| 852 | 890 | if ($changeOther && empty($post_errors)) |
| 853 | 891 | { |
| 854 | 892 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -856,8 +894,9 @@ discard block |
||
| 856 | 894 | { |
| 857 | 895 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
| 858 | 896 | |
| 859 | - if (!empty($custom_fields_errors)) |
|
| 860 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 897 | + if (!empty($custom_fields_errors)) { |
|
| 898 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 899 | + } |
|
| 861 | 900 | } |
| 862 | 901 | } |
| 863 | 902 | |
@@ -883,9 +922,9 @@ discard block |
||
| 883 | 922 | if ($context['user']['is_owner']) |
| 884 | 923 | { |
| 885 | 924 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
| 925 | + } else { |
|
| 926 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 886 | 927 | } |
| 887 | - else |
|
| 888 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 889 | 928 | |
| 890 | 929 | // Arrays of all the changes - makes things easier. |
| 891 | 930 | $profile_bools = array(); |
@@ -896,22 +935,25 @@ discard block |
||
| 896 | 935 | 'ignore_boards', |
| 897 | 936 | ); |
| 898 | 937 | |
| 899 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
| 900 | - $_POST['ignore_brd'] = array(); |
|
| 938 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
| 939 | + $_POST['ignore_brd'] = array(); |
|
| 940 | + } |
|
| 901 | 941 | |
| 902 | 942 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
| 903 | 943 | if (isset($_POST['ignore_brd'])) |
| 904 | 944 | { |
| 905 | - if (!is_array($_POST['ignore_brd'])) |
|
| 906 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 945 | + if (!is_array($_POST['ignore_brd'])) { |
|
| 946 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 947 | + } |
|
| 907 | 948 | |
| 908 | 949 | foreach ($_POST['ignore_brd'] as $k => $d) |
| 909 | 950 | { |
| 910 | 951 | $d = (int) $d; |
| 911 | - if ($d != 0) |
|
| 912 | - $_POST['ignore_brd'][$k] = $d; |
|
| 913 | - else |
|
| 914 | - unset($_POST['ignore_brd'][$k]); |
|
| 952 | + if ($d != 0) { |
|
| 953 | + $_POST['ignore_brd'][$k] = $d; |
|
| 954 | + } else { |
|
| 955 | + unset($_POST['ignore_brd'][$k]); |
|
| 956 | + } |
|
| 915 | 957 | } |
| 916 | 958 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
| 917 | 959 | unset($_POST['ignore_brd']); |
@@ -924,21 +966,26 @@ discard block |
||
| 924 | 966 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
| 925 | 967 | //makeAvatarChanges($memID, $post_errors); |
| 926 | 968 | |
| 927 | - if (!empty($_REQUEST['sa'])) |
|
| 928 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 969 | + if (!empty($_REQUEST['sa'])) { |
|
| 970 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 971 | + } |
|
| 929 | 972 | |
| 930 | - foreach ($profile_bools as $var) |
|
| 931 | - if (isset($_POST[$var])) |
|
| 973 | + foreach ($profile_bools as $var) { |
|
| 974 | + if (isset($_POST[$var])) |
|
| 932 | 975 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
| 933 | - foreach ($profile_ints as $var) |
|
| 934 | - if (isset($_POST[$var])) |
|
| 976 | + } |
|
| 977 | + foreach ($profile_ints as $var) { |
|
| 978 | + if (isset($_POST[$var])) |
|
| 935 | 979 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
| 936 | - foreach ($profile_floats as $var) |
|
| 937 | - if (isset($_POST[$var])) |
|
| 980 | + } |
|
| 981 | + foreach ($profile_floats as $var) { |
|
| 982 | + if (isset($_POST[$var])) |
|
| 938 | 983 | $profile_vars[$var] = (float) $_POST[$var]; |
| 939 | - foreach ($profile_strings as $var) |
|
| 940 | - if (isset($_POST[$var])) |
|
| 984 | + } |
|
| 985 | + foreach ($profile_strings as $var) { |
|
| 986 | + if (isset($_POST[$var])) |
|
| 941 | 987 | $profile_vars[$var] = $_POST[$var]; |
| 988 | + } |
|
| 942 | 989 | } |
| 943 | 990 | } |
| 944 | 991 | |
@@ -972,8 +1019,9 @@ discard block |
||
| 972 | 1019 | ); |
| 973 | 1020 | |
| 974 | 1021 | // Can't change reserved vars. |
| 975 | - 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)) |
|
| 976 | - fatal_lang_error('no_access', false); |
|
| 1022 | + 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)) { |
|
| 1023 | + fatal_lang_error('no_access', false); |
|
| 1024 | + } |
|
| 977 | 1025 | |
| 978 | 1026 | // Don't allow any overriding of custom fields with default or non-default options. |
| 979 | 1027 | $request = $smcFunc['db_query']('', ' |
@@ -985,8 +1033,9 @@ discard block |
||
| 985 | 1033 | ) |
| 986 | 1034 | ); |
| 987 | 1035 | $custom_fields = array(); |
| 988 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 989 | - $custom_fields[] = $row['col_name']; |
|
| 1036 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1037 | + $custom_fields[] = $row['col_name']; |
|
| 1038 | + } |
|
| 990 | 1039 | $smcFunc['db_free_result']($request); |
| 991 | 1040 | |
| 992 | 1041 | // These are the theme changes... |
@@ -995,33 +1044,39 @@ discard block |
||
| 995 | 1044 | { |
| 996 | 1045 | foreach ($_POST['options'] as $opt => $val) |
| 997 | 1046 | { |
| 998 | - if (in_array($opt, $custom_fields)) |
|
| 999 | - continue; |
|
| 1047 | + if (in_array($opt, $custom_fields)) { |
|
| 1048 | + continue; |
|
| 1049 | + } |
|
| 1000 | 1050 | |
| 1001 | 1051 | // These need to be controlled. |
| 1002 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1003 | - $val = max(0, min($val, 50)); |
|
| 1052 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1053 | + $val = max(0, min($val, 50)); |
|
| 1054 | + } |
|
| 1004 | 1055 | // We don't set this per theme anymore. |
| 1005 | - elseif ($opt == 'allow_no_censored') |
|
| 1006 | - continue; |
|
| 1056 | + elseif ($opt == 'allow_no_censored') { |
|
| 1057 | + continue; |
|
| 1058 | + } |
|
| 1007 | 1059 | |
| 1008 | 1060 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1009 | 1061 | } |
| 1010 | 1062 | } |
| 1011 | 1063 | |
| 1012 | 1064 | $erase_options = array(); |
| 1013 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
| 1014 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 1065 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
| 1066 | + foreach ($_POST['default_options'] as $opt => $val) |
|
| 1015 | 1067 | { |
| 1016 | 1068 | if (in_array($opt, $custom_fields)) |
| 1017 | 1069 | continue; |
| 1070 | + } |
|
| 1018 | 1071 | |
| 1019 | 1072 | // These need to be controlled. |
| 1020 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1021 | - $val = max(0, min($val, 50)); |
|
| 1073 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1074 | + $val = max(0, min($val, 50)); |
|
| 1075 | + } |
|
| 1022 | 1076 | // Only let admins and owners change the censor. |
| 1023 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
| 1024 | - continue; |
|
| 1077 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
| 1078 | + continue; |
|
| 1079 | + } |
|
| 1025 | 1080 | |
| 1026 | 1081 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1027 | 1082 | $erase_options[] = $opt; |
@@ -1057,8 +1112,9 @@ discard block |
||
| 1057 | 1112 | |
| 1058 | 1113 | // Admins can choose any theme, even if it's not enabled... |
| 1059 | 1114 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
| 1060 | - foreach ($themes as $t) |
|
| 1061 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1115 | + foreach ($themes as $t) { |
|
| 1116 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1117 | + } |
|
| 1062 | 1118 | } |
| 1063 | 1119 | } |
| 1064 | 1120 | |
@@ -1077,8 +1133,9 @@ discard block |
||
| 1077 | 1133 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
| 1078 | 1134 | { |
| 1079 | 1135 | // Make sure only integers are deleted. |
| 1080 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
| 1081 | - $_POST['notify_boards'][$index] = (int) $id; |
|
| 1136 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
| 1137 | + $_POST['notify_boards'][$index] = (int) $id; |
|
| 1138 | + } |
|
| 1082 | 1139 | |
| 1083 | 1140 | // id_board = 0 is reserved for topic notifications. |
| 1084 | 1141 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1097,8 +1154,9 @@ discard block |
||
| 1097 | 1154 | // We are editing topic notifications...... |
| 1098 | 1155 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1099 | 1156 | { |
| 1100 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
| 1101 | - $_POST['notify_topics'][$index] = (int) $id; |
|
| 1157 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
| 1158 | + $_POST['notify_topics'][$index] = (int) $id; |
|
| 1159 | + } |
|
| 1102 | 1160 | |
| 1103 | 1161 | // Make sure there are no zeros left. |
| 1104 | 1162 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1112,16 +1170,18 @@ discard block |
||
| 1112 | 1170 | 'selected_member' => $memID, |
| 1113 | 1171 | ) |
| 1114 | 1172 | ); |
| 1115 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1116 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1173 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1174 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1175 | + } |
|
| 1117 | 1176 | } |
| 1118 | 1177 | |
| 1119 | 1178 | // We are removing topic preferences |
| 1120 | 1179 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1121 | 1180 | { |
| 1122 | 1181 | $prefs = array(); |
| 1123 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1124 | - $prefs[] = 'topic_notify_' . $topic; |
|
| 1182 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1183 | + $prefs[] = 'topic_notify_' . $topic; |
|
| 1184 | + } |
|
| 1125 | 1185 | deleteNotifyPrefs($memID, $prefs); |
| 1126 | 1186 | } |
| 1127 | 1187 | |
@@ -1129,8 +1189,9 @@ discard block |
||
| 1129 | 1189 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
| 1130 | 1190 | { |
| 1131 | 1191 | $prefs = array(); |
| 1132 | - foreach ($_POST['notify_boards'] as $board) |
|
| 1133 | - $prefs[] = 'board_notify_' . $board; |
|
| 1192 | + foreach ($_POST['notify_boards'] as $board) { |
|
| 1193 | + $prefs[] = 'board_notify_' . $board; |
|
| 1194 | + } |
|
| 1134 | 1195 | deleteNotifyPrefs($memID, $prefs); |
| 1135 | 1196 | } |
| 1136 | 1197 | } |
@@ -1151,8 +1212,9 @@ discard block |
||
| 1151 | 1212 | |
| 1152 | 1213 | $errors = array(); |
| 1153 | 1214 | |
| 1154 | - if ($sanitize && isset($_POST['customfield'])) |
|
| 1155 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1215 | + if ($sanitize && isset($_POST['customfield'])) { |
|
| 1216 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1217 | + } |
|
| 1156 | 1218 | |
| 1157 | 1219 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
| 1158 | 1220 | |
@@ -1177,48 +1239,49 @@ discard block |
||
| 1177 | 1239 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
| 1178 | 1240 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
| 1179 | 1241 | */ |
| 1180 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
| 1181 | - continue; |
|
| 1242 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
| 1243 | + continue; |
|
| 1244 | + } |
|
| 1182 | 1245 | |
| 1183 | 1246 | // Validate the user data. |
| 1184 | - if ($row['field_type'] == 'check') |
|
| 1185 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1186 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1247 | + if ($row['field_type'] == 'check') { |
|
| 1248 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1249 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1187 | 1250 | { |
| 1188 | 1251 | $value = $row['default_value']; |
| 1189 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1190 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1252 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
| 1253 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1191 | 1254 | $value = $v; |
| 1255 | + } |
|
| 1192 | 1256 | } |
| 1193 | 1257 | // Otherwise some form of text! |
| 1194 | 1258 | else |
| 1195 | 1259 | { |
| 1196 | 1260 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
| 1197 | - if ($row['field_length']) |
|
| 1198 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1261 | + if ($row['field_length']) { |
|
| 1262 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1263 | + } |
|
| 1199 | 1264 | |
| 1200 | 1265 | // Any masks? |
| 1201 | 1266 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
| 1202 | 1267 | { |
| 1203 | 1268 | if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
| 1204 | 1269 | { |
| 1205 | - if ($returnErrors) |
|
| 1206 | - $errors[] = 'custom_field_mail_fail'; |
|
| 1207 | - |
|
| 1208 | - else |
|
| 1209 | - $value = ''; |
|
| 1210 | - } |
|
| 1211 | - elseif ($row['mask'] == 'number') |
|
| 1270 | + if ($returnErrors) { |
|
| 1271 | + $errors[] = 'custom_field_mail_fail'; |
|
| 1272 | + } else { |
|
| 1273 | + $value = ''; |
|
| 1274 | + } |
|
| 1275 | + } elseif ($row['mask'] == 'number') |
|
| 1212 | 1276 | { |
| 1213 | 1277 | $value = (int) $value; |
| 1214 | - } |
|
| 1215 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1278 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1216 | 1279 | { |
| 1217 | - if ($returnErrors) |
|
| 1218 | - $errors[] = 'custom_field_regex_fail'; |
|
| 1219 | - |
|
| 1220 | - else |
|
| 1221 | - $value = ''; |
|
| 1280 | + if ($returnErrors) { |
|
| 1281 | + $errors[] = 'custom_field_regex_fail'; |
|
| 1282 | + } else { |
|
| 1283 | + $value = ''; |
|
| 1284 | + } |
|
| 1222 | 1285 | } |
| 1223 | 1286 | } |
| 1224 | 1287 | } |
@@ -1244,8 +1307,9 @@ discard block |
||
| 1244 | 1307 | |
| 1245 | 1308 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
| 1246 | 1309 | |
| 1247 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
| 1248 | - $errors = array_merge($errors, $hook_errors); |
|
| 1310 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
| 1311 | + $errors = array_merge($errors, $hook_errors); |
|
| 1312 | + } |
|
| 1249 | 1313 | |
| 1250 | 1314 | // Make those changes! |
| 1251 | 1315 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1263,9 +1327,10 @@ discard block |
||
| 1263 | 1327 | } |
| 1264 | 1328 | } |
| 1265 | 1329 | |
| 1266 | - if ($returnErrors) |
|
| 1267 | - return $errors; |
|
| 1268 | -} |
|
| 1330 | + if ($returnErrors) { |
|
| 1331 | + return $errors; |
|
| 1332 | + } |
|
| 1333 | + } |
|
| 1269 | 1334 | |
| 1270 | 1335 | /** |
| 1271 | 1336 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1277,8 +1342,9 @@ discard block |
||
| 1277 | 1342 | global $context, $txt, $modSettings; |
| 1278 | 1343 | |
| 1279 | 1344 | // Do a quick check to ensure people aren't getting here illegally! |
| 1280 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
| 1281 | - fatal_lang_error('no_access', false); |
|
| 1345 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
| 1346 | + fatal_lang_error('no_access', false); |
|
| 1347 | + } |
|
| 1282 | 1348 | |
| 1283 | 1349 | // Can we email the user direct? |
| 1284 | 1350 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1308,9 +1374,10 @@ discard block |
||
| 1308 | 1374 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
| 1309 | 1375 | $call = call_helper($subActions[$context['list_area']][0], true); |
| 1310 | 1376 | |
| 1311 | - if (!empty($call)) |
|
| 1312 | - call_user_func($call, $memID); |
|
| 1313 | -} |
|
| 1377 | + if (!empty($call)) { |
|
| 1378 | + call_user_func($call, $memID); |
|
| 1379 | + } |
|
| 1380 | + } |
|
| 1314 | 1381 | |
| 1315 | 1382 | /** |
| 1316 | 1383 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1324,9 +1391,10 @@ discard block |
||
| 1324 | 1391 | |
| 1325 | 1392 | // For making changes! |
| 1326 | 1393 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
| 1327 | - foreach ($buddiesArray as $k => $dummy) |
|
| 1328 | - if ($dummy == '') |
|
| 1394 | + foreach ($buddiesArray as $k => $dummy) { |
|
| 1395 | + if ($dummy == '') |
|
| 1329 | 1396 | unset($buddiesArray[$k]); |
| 1397 | + } |
|
| 1330 | 1398 | |
| 1331 | 1399 | // Removing a buddy? |
| 1332 | 1400 | if (isset($_GET['remove'])) |
@@ -1338,10 +1406,11 @@ discard block |
||
| 1338 | 1406 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1339 | 1407 | |
| 1340 | 1408 | // Heh, I'm lazy, do it the easy way... |
| 1341 | - foreach ($buddiesArray as $key => $buddy) |
|
| 1342 | - if ($buddy == (int) $_GET['remove']) |
|
| 1409 | + foreach ($buddiesArray as $key => $buddy) { |
|
| 1410 | + if ($buddy == (int) $_GET['remove']) |
|
| 1343 | 1411 | { |
| 1344 | 1412 | unset($buddiesArray[$key]); |
| 1413 | + } |
|
| 1345 | 1414 | $_SESSION['prf-save'] = true; |
| 1346 | 1415 | } |
| 1347 | 1416 | |
@@ -1351,8 +1420,7 @@ discard block |
||
| 1351 | 1420 | |
| 1352 | 1421 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1353 | 1422 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
| 1354 | - } |
|
| 1355 | - elseif (isset($_POST['new_buddy'])) |
|
| 1423 | + } elseif (isset($_POST['new_buddy'])) |
|
| 1356 | 1424 | { |
| 1357 | 1425 | checkSession(); |
| 1358 | 1426 | |
@@ -1365,8 +1433,9 @@ discard block |
||
| 1365 | 1433 | { |
| 1366 | 1434 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
| 1367 | 1435 | |
| 1368 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1369 | - unset($new_buddies[$k]); |
|
| 1436 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1437 | + unset($new_buddies[$k]); |
|
| 1438 | + } |
|
| 1370 | 1439 | } |
| 1371 | 1440 | |
| 1372 | 1441 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1386,16 +1455,18 @@ discard block |
||
| 1386 | 1455 | ) |
| 1387 | 1456 | ); |
| 1388 | 1457 | |
| 1389 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1390 | - $_SESSION['prf-save'] = true; |
|
| 1458 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1459 | + $_SESSION['prf-save'] = true; |
|
| 1460 | + } |
|
| 1391 | 1461 | |
| 1392 | 1462 | // Add the new member to the buddies array. |
| 1393 | 1463 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1394 | 1464 | { |
| 1395 | - if (in_array($row['id_member'], $buddiesArray)) |
|
| 1396 | - continue; |
|
| 1397 | - else |
|
| 1398 | - $buddiesArray[] = (int) $row['id_member']; |
|
| 1465 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
| 1466 | + continue; |
|
| 1467 | + } else { |
|
| 1468 | + $buddiesArray[] = (int) $row['id_member']; |
|
| 1469 | + } |
|
| 1399 | 1470 | } |
| 1400 | 1471 | $smcFunc['db_free_result']($request); |
| 1401 | 1472 | |
@@ -1425,18 +1496,20 @@ discard block |
||
| 1425 | 1496 | |
| 1426 | 1497 | $context['custom_pf'] = array(); |
| 1427 | 1498 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
| 1428 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1429 | - if (!isset($disabled_fields[$row['col_name']])) |
|
| 1499 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1500 | + if (!isset($disabled_fields[$row['col_name']])) |
|
| 1430 | 1501 | $context['custom_pf'][$row['col_name']] = array( |
| 1431 | 1502 | 'label' => $row['field_name'], |
| 1432 | 1503 | 'type' => $row['field_type'], |
| 1433 | 1504 | 'bbc' => !empty($row['bbc']), |
| 1434 | 1505 | 'enclose' => $row['enclose'], |
| 1435 | 1506 | ); |
| 1507 | + } |
|
| 1436 | 1508 | |
| 1437 | 1509 | // Gotta disable the gender option. |
| 1438 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
| 1439 | - unset($context['custom_pf']['cust_gender']); |
|
| 1510 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
| 1511 | + unset($context['custom_pf']['cust_gender']); |
|
| 1512 | + } |
|
| 1440 | 1513 | |
| 1441 | 1514 | $smcFunc['db_free_result']($request); |
| 1442 | 1515 | |
@@ -1453,8 +1526,9 @@ discard block |
||
| 1453 | 1526 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
| 1454 | 1527 | ) |
| 1455 | 1528 | ); |
| 1456 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1457 | - $buddies[] = $row['id_member']; |
|
| 1529 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1530 | + $buddies[] = $row['id_member']; |
|
| 1531 | + } |
|
| 1458 | 1532 | $smcFunc['db_free_result']($result); |
| 1459 | 1533 | } |
| 1460 | 1534 | |
@@ -1482,30 +1556,32 @@ discard block |
||
| 1482 | 1556 | continue; |
| 1483 | 1557 | } |
| 1484 | 1558 | |
| 1485 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1486 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1487 | - |
|
| 1488 | - elseif ($column['type'] == 'check') |
|
| 1489 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1559 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1560 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1561 | + } elseif ($column['type'] == 'check') { |
|
| 1562 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1563 | + } |
|
| 1490 | 1564 | |
| 1491 | 1565 | // Enclosing the user input within some other text? |
| 1492 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1493 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1566 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1567 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1494 | 1568 | '{SCRIPTURL}' => $scripturl, |
| 1495 | 1569 | '{IMAGES_URL}' => $settings['images_url'], |
| 1496 | 1570 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1497 | 1571 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
| 1498 | 1572 | )); |
| 1573 | + } |
|
| 1499 | 1574 | } |
| 1500 | 1575 | } |
| 1501 | 1576 | } |
| 1502 | 1577 | |
| 1503 | 1578 | if (isset($_SESSION['prf-save'])) |
| 1504 | 1579 | { |
| 1505 | - if ($_SESSION['prf-save'] === true) |
|
| 1506 | - $context['saved_successful'] = true; |
|
| 1507 | - else |
|
| 1508 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1580 | + if ($_SESSION['prf-save'] === true) { |
|
| 1581 | + $context['saved_successful'] = true; |
|
| 1582 | + } else { |
|
| 1583 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1584 | + } |
|
| 1509 | 1585 | |
| 1510 | 1586 | unset($_SESSION['prf-save']); |
| 1511 | 1587 | } |
@@ -1525,9 +1601,10 @@ discard block |
||
| 1525 | 1601 | |
| 1526 | 1602 | // For making changes! |
| 1527 | 1603 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
| 1528 | - foreach ($ignoreArray as $k => $dummy) |
|
| 1529 | - if ($dummy == '') |
|
| 1604 | + foreach ($ignoreArray as $k => $dummy) { |
|
| 1605 | + if ($dummy == '') |
|
| 1530 | 1606 | unset($ignoreArray[$k]); |
| 1607 | + } |
|
| 1531 | 1608 | |
| 1532 | 1609 | // Removing a member from the ignore list? |
| 1533 | 1610 | if (isset($_GET['remove'])) |
@@ -1537,10 +1614,11 @@ discard block |
||
| 1537 | 1614 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1538 | 1615 | |
| 1539 | 1616 | // Heh, I'm lazy, do it the easy way... |
| 1540 | - foreach ($ignoreArray as $key => $id_remove) |
|
| 1541 | - if ($id_remove == (int) $_GET['remove']) |
|
| 1617 | + foreach ($ignoreArray as $key => $id_remove) { |
|
| 1618 | + if ($id_remove == (int) $_GET['remove']) |
|
| 1542 | 1619 | { |
| 1543 | 1620 | unset($ignoreArray[$key]); |
| 1621 | + } |
|
| 1544 | 1622 | $_SESSION['prf-save'] = true; |
| 1545 | 1623 | } |
| 1546 | 1624 | |
@@ -1550,8 +1628,7 @@ discard block |
||
| 1550 | 1628 | |
| 1551 | 1629 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1552 | 1630 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
| 1553 | - } |
|
| 1554 | - elseif (isset($_POST['new_ignore'])) |
|
| 1631 | + } elseif (isset($_POST['new_ignore'])) |
|
| 1555 | 1632 | { |
| 1556 | 1633 | checkSession(); |
| 1557 | 1634 | // Prepare the string for extraction... |
@@ -1563,8 +1640,9 @@ discard block |
||
| 1563 | 1640 | { |
| 1564 | 1641 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
| 1565 | 1642 | |
| 1566 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1567 | - unset($new_entries[$k]); |
|
| 1643 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1644 | + unset($new_entries[$k]); |
|
| 1645 | + } |
|
| 1568 | 1646 | } |
| 1569 | 1647 | |
| 1570 | 1648 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1582,16 +1660,18 @@ discard block |
||
| 1582 | 1660 | ) |
| 1583 | 1661 | ); |
| 1584 | 1662 | |
| 1585 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1586 | - $_SESSION['prf-save'] = true; |
|
| 1663 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1664 | + $_SESSION['prf-save'] = true; |
|
| 1665 | + } |
|
| 1587 | 1666 | |
| 1588 | 1667 | // Add the new member to the buddies array. |
| 1589 | 1668 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1590 | 1669 | { |
| 1591 | - if (in_array($row['id_member'], $ignoreArray)) |
|
| 1592 | - continue; |
|
| 1593 | - else |
|
| 1594 | - $ignoreArray[] = (int) $row['id_member']; |
|
| 1670 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
| 1671 | + continue; |
|
| 1672 | + } else { |
|
| 1673 | + $ignoreArray[] = (int) $row['id_member']; |
|
| 1674 | + } |
|
| 1595 | 1675 | } |
| 1596 | 1676 | $smcFunc['db_free_result']($request); |
| 1597 | 1677 | |
@@ -1620,8 +1700,9 @@ discard block |
||
| 1620 | 1700 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
| 1621 | 1701 | ) |
| 1622 | 1702 | ); |
| 1623 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1624 | - $ignored[] = $row['id_member']; |
|
| 1703 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1704 | + $ignored[] = $row['id_member']; |
|
| 1705 | + } |
|
| 1625 | 1706 | $smcFunc['db_free_result']($result); |
| 1626 | 1707 | } |
| 1627 | 1708 | |
@@ -1640,10 +1721,11 @@ discard block |
||
| 1640 | 1721 | |
| 1641 | 1722 | if (isset($_SESSION['prf-save'])) |
| 1642 | 1723 | { |
| 1643 | - if ($_SESSION['prf-save'] === true) |
|
| 1644 | - $context['saved_successful'] = true; |
|
| 1645 | - else |
|
| 1646 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1724 | + if ($_SESSION['prf-save'] === true) { |
|
| 1725 | + $context['saved_successful'] = true; |
|
| 1726 | + } else { |
|
| 1727 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1728 | + } |
|
| 1647 | 1729 | |
| 1648 | 1730 | unset($_SESSION['prf-save']); |
| 1649 | 1731 | } |
@@ -1659,8 +1741,9 @@ discard block |
||
| 1659 | 1741 | global $context, $txt; |
| 1660 | 1742 | |
| 1661 | 1743 | loadThemeOptions($memID); |
| 1662 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
| 1663 | - loadCustomFields($memID, 'account'); |
|
| 1744 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
| 1745 | + loadCustomFields($memID, 'account'); |
|
| 1746 | + } |
|
| 1664 | 1747 | |
| 1665 | 1748 | $context['sub_template'] = 'edit_options'; |
| 1666 | 1749 | $context['page_desc'] = $txt['account_info']; |
@@ -1687,8 +1770,9 @@ discard block |
||
| 1687 | 1770 | global $context, $txt; |
| 1688 | 1771 | |
| 1689 | 1772 | loadThemeOptions($memID); |
| 1690 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
| 1691 | - loadCustomFields($memID, 'forumprofile'); |
|
| 1773 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
| 1774 | + loadCustomFields($memID, 'forumprofile'); |
|
| 1775 | + } |
|
| 1692 | 1776 | |
| 1693 | 1777 | $context['sub_template'] = 'edit_options'; |
| 1694 | 1778 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1721,18 +1805,21 @@ discard block |
||
| 1721 | 1805 | $dirs = array(); |
| 1722 | 1806 | $files = array(); |
| 1723 | 1807 | |
| 1724 | - if (!$dir) |
|
| 1725 | - return array(); |
|
| 1808 | + if (!$dir) { |
|
| 1809 | + return array(); |
|
| 1810 | + } |
|
| 1726 | 1811 | |
| 1727 | 1812 | while ($line = $dir->read()) |
| 1728 | 1813 | { |
| 1729 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
| 1730 | - continue; |
|
| 1814 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
| 1815 | + continue; |
|
| 1816 | + } |
|
| 1731 | 1817 | |
| 1732 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
| 1733 | - $dirs[] = $line; |
|
| 1734 | - else |
|
| 1735 | - $files[] = $line; |
|
| 1818 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
| 1819 | + $dirs[] = $line; |
|
| 1820 | + } else { |
|
| 1821 | + $files[] = $line; |
|
| 1822 | + } |
|
| 1736 | 1823 | } |
| 1737 | 1824 | $dir->close(); |
| 1738 | 1825 | |
@@ -1753,14 +1840,15 @@ discard block |
||
| 1753 | 1840 | foreach ($dirs as $line) |
| 1754 | 1841 | { |
| 1755 | 1842 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
| 1756 | - if (!empty($tmp)) |
|
| 1757 | - $result[] = array( |
|
| 1843 | + if (!empty($tmp)) { |
|
| 1844 | + $result[] = array( |
|
| 1758 | 1845 | 'filename' => $smcFunc['htmlspecialchars']($line), |
| 1759 | 1846 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
| 1760 | 1847 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
| 1761 | 1848 | 'is_dir' => true, |
| 1762 | 1849 | 'files' => $tmp |
| 1763 | 1850 | ); |
| 1851 | + } |
|
| 1764 | 1852 | unset($tmp); |
| 1765 | 1853 | } |
| 1766 | 1854 | |
@@ -1770,8 +1858,9 @@ discard block |
||
| 1770 | 1858 | $extension = substr(strrchr($line, '.'), 1); |
| 1771 | 1859 | |
| 1772 | 1860 | // Make sure it is an image. |
| 1773 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
| 1774 | - continue; |
|
| 1861 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
| 1862 | + continue; |
|
| 1863 | + } |
|
| 1775 | 1864 | |
| 1776 | 1865 | $result[] = array( |
| 1777 | 1866 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1779,8 +1868,9 @@ discard block |
||
| 1779 | 1868 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
| 1780 | 1869 | 'is_dir' => false |
| 1781 | 1870 | ); |
| 1782 | - if ($level == 1) |
|
| 1783 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1871 | + if ($level == 1) { |
|
| 1872 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1873 | + } |
|
| 1784 | 1874 | } |
| 1785 | 1875 | |
| 1786 | 1876 | return $result; |
@@ -1799,8 +1889,9 @@ discard block |
||
| 1799 | 1889 | loadSubTemplate('options'); |
| 1800 | 1890 | |
| 1801 | 1891 | loadThemeOptions($memID); |
| 1802 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
| 1803 | - loadCustomFields($memID, 'theme'); |
|
| 1892 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
| 1893 | + loadCustomFields($memID, 'theme'); |
|
| 1894 | + } |
|
| 1804 | 1895 | |
| 1805 | 1896 | $context['sub_template'] = 'edit_options'; |
| 1806 | 1897 | $context['page_desc'] = $txt['theme_info']; |
@@ -1854,16 +1945,19 @@ discard block |
||
| 1854 | 1945 | { |
| 1855 | 1946 | global $txt, $context, $modSettings, $smcFunc, $sourcedir; |
| 1856 | 1947 | |
| 1857 | - if (!isset($context['token_check'])) |
|
| 1858 | - $context['token_check'] = 'profile-nt' . $memID; |
|
| 1948 | + if (!isset($context['token_check'])) { |
|
| 1949 | + $context['token_check'] = 'profile-nt' . $memID; |
|
| 1950 | + } |
|
| 1859 | 1951 | |
| 1860 | 1952 | is_not_guest(); |
| 1861 | - if (!$context['user']['is_owner']) |
|
| 1862 | - isAllowedTo('profile_extra_any'); |
|
| 1953 | + if (!$context['user']['is_owner']) { |
|
| 1954 | + isAllowedTo('profile_extra_any'); |
|
| 1955 | + } |
|
| 1863 | 1956 | |
| 1864 | 1957 | // Set the post action if we're coming from the profile... |
| 1865 | - if (!isset($context['action'])) |
|
| 1866 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1958 | + if (!isset($context['action'])) { |
|
| 1959 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1960 | + } |
|
| 1867 | 1961 | |
| 1868 | 1962 | // What options are set |
| 1869 | 1963 | loadThemeOptions($memID); |
@@ -1950,28 +2044,34 @@ discard block |
||
| 1950 | 2044 | ); |
| 1951 | 2045 | |
| 1952 | 2046 | // There are certain things that are disabled at the group level. |
| 1953 | - if (empty($modSettings['cal_enabled'])) |
|
| 1954 | - unset($alert_types['calendar']); |
|
| 2047 | + if (empty($modSettings['cal_enabled'])) { |
|
| 2048 | + unset($alert_types['calendar']); |
|
| 2049 | + } |
|
| 1955 | 2050 | |
| 1956 | 2051 | // Disable paid subscriptions at group level if they're disabled |
| 1957 | - if (empty($modSettings['paid_enabled'])) |
|
| 1958 | - unset($alert_types['paidsubs']); |
|
| 2052 | + if (empty($modSettings['paid_enabled'])) { |
|
| 2053 | + unset($alert_types['paidsubs']); |
|
| 2054 | + } |
|
| 1959 | 2055 | |
| 1960 | 2056 | // Disable membergroup requests at group level if they're disabled |
| 1961 | - if (empty($modSettings['show_group_membership'])) |
|
| 1962 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2057 | + if (empty($modSettings['show_group_membership'])) { |
|
| 2058 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2059 | + } |
|
| 1963 | 2060 | |
| 1964 | 2061 | // Disable mentions if they're disabled |
| 1965 | - if (empty($modSettings['enable_mentions'])) |
|
| 1966 | - unset($alert_types['msg']['msg_mention']); |
|
| 2062 | + if (empty($modSettings['enable_mentions'])) { |
|
| 2063 | + unset($alert_types['msg']['msg_mention']); |
|
| 2064 | + } |
|
| 1967 | 2065 | |
| 1968 | 2066 | // Disable likes if they're disabled |
| 1969 | - if (empty($modSettings['enable_likes'])) |
|
| 1970 | - unset($alert_types['msg']['msg_like']); |
|
| 2067 | + if (empty($modSettings['enable_likes'])) { |
|
| 2068 | + unset($alert_types['msg']['msg_like']); |
|
| 2069 | + } |
|
| 1971 | 2070 | |
| 1972 | 2071 | // Disable buddy requests if they're disabled |
| 1973 | - if (empty($modSettings['enable_buddylist'])) |
|
| 1974 | - unset($alert_types['members']['buddy_request']); |
|
| 2072 | + if (empty($modSettings['enable_buddylist'])) { |
|
| 2073 | + unset($alert_types['members']['buddy_request']); |
|
| 2074 | + } |
|
| 1975 | 2075 | |
| 1976 | 2076 | // Now, now, we could pass this through global but we should really get into the habit of |
| 1977 | 2077 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -1999,15 +2099,17 @@ discard block |
||
| 1999 | 2099 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
| 2000 | 2100 | } |
| 2001 | 2101 | |
| 2002 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
| 2003 | - unset($alert_types['members']['request_group']); |
|
| 2102 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
| 2103 | + unset($alert_types['members']['request_group']); |
|
| 2104 | + } |
|
| 2004 | 2105 | |
| 2005 | 2106 | foreach ($alert_types as $group => $items) |
| 2006 | 2107 | { |
| 2007 | 2108 | foreach ($items as $alert_key => $alert_value) |
| 2008 | 2109 | { |
| 2009 | - if (!isset($alert_value['permission'])) |
|
| 2010 | - continue; |
|
| 2110 | + if (!isset($alert_value['permission'])) { |
|
| 2111 | + continue; |
|
| 2112 | + } |
|
| 2011 | 2113 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
| 2012 | 2114 | { |
| 2013 | 2115 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2015,12 +2117,14 @@ discard block |
||
| 2015 | 2117 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
| 2016 | 2118 | } |
| 2017 | 2119 | |
| 2018 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
| 2019 | - unset ($alert_types[$group][$alert_key]); |
|
| 2120 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
| 2121 | + unset ($alert_types[$group][$alert_key]); |
|
| 2122 | + } |
|
| 2020 | 2123 | } |
| 2021 | 2124 | |
| 2022 | - if (empty($alert_types[$group])) |
|
| 2023 | - unset ($alert_types[$group]); |
|
| 2125 | + if (empty($alert_types[$group])) { |
|
| 2126 | + unset ($alert_types[$group]); |
|
| 2127 | + } |
|
| 2024 | 2128 | } |
| 2025 | 2129 | } |
| 2026 | 2130 | |
@@ -2052,9 +2156,9 @@ discard block |
||
| 2052 | 2156 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
| 2053 | 2157 | break; |
| 2054 | 2158 | case 'select': |
| 2055 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
| 2056 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2057 | - else |
|
| 2159 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
| 2160 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2161 | + } else |
|
| 2058 | 2162 | { |
| 2059 | 2163 | // We didn't have a sane value. Let's grab the first item from the possibles. |
| 2060 | 2164 | $keys = array_keys($this_option['opts']); |
@@ -2074,23 +2178,28 @@ discard block |
||
| 2074 | 2178 | $this_value = 0; |
| 2075 | 2179 | foreach ($context['alert_bits'] as $type => $bitvalue) |
| 2076 | 2180 | { |
| 2077 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
| 2078 | - $this_value |= $bitvalue; |
|
| 2181 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
| 2182 | + $this_value |= $bitvalue; |
|
| 2183 | + } |
|
| 2184 | + } |
|
| 2185 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
| 2186 | + $update_prefs[$item_key] = $this_value; |
|
| 2079 | 2187 | } |
| 2080 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
| 2081 | - $update_prefs[$item_key] = $this_value; |
|
| 2082 | 2188 | } |
| 2083 | 2189 | } |
| 2084 | 2190 | |
| 2085 | - if (!empty($_POST['opt_alert_timeout'])) |
|
| 2086 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2191 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
| 2192 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2193 | + } |
|
| 2087 | 2194 | |
| 2088 | - if (!empty($_POST['notify_announcements'])) |
|
| 2089 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2195 | + if (!empty($_POST['notify_announcements'])) { |
|
| 2196 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2197 | + } |
|
| 2090 | 2198 | |
| 2091 | 2199 | setNotifyPrefs((int) $memID, $update_prefs); |
| 2092 | - foreach ($update_prefs as $pref => $value) |
|
| 2093 | - $context['alert_prefs'][$pref] = $value; |
|
| 2200 | + foreach ($update_prefs as $pref => $value) { |
|
| 2201 | + $context['alert_prefs'][$pref] = $value; |
|
| 2202 | + } |
|
| 2094 | 2203 | |
| 2095 | 2204 | makeNotificationChanges($memID); |
| 2096 | 2205 | |
@@ -2120,8 +2229,9 @@ discard block |
||
| 2120 | 2229 | |
| 2121 | 2230 | // Now we're all set up. |
| 2122 | 2231 | is_not_guest(); |
| 2123 | - if (!$context['user']['is_owner']) |
|
| 2124 | - fatal_error('no_access'); |
|
| 2232 | + if (!$context['user']['is_owner']) { |
|
| 2233 | + fatal_error('no_access'); |
|
| 2234 | + } |
|
| 2125 | 2235 | |
| 2126 | 2236 | checkSession('get'); |
| 2127 | 2237 | |
@@ -2153,8 +2263,9 @@ discard block |
||
| 2153 | 2263 | { |
| 2154 | 2264 | global $smcFunc; |
| 2155 | 2265 | |
| 2156 | - if (empty($toMark) || empty($memID)) |
|
| 2157 | - return false; |
|
| 2266 | + if (empty($toMark) || empty($memID)) { |
|
| 2267 | + return false; |
|
| 2268 | + } |
|
| 2158 | 2269 | |
| 2159 | 2270 | $toMark = (array) $toMark; |
| 2160 | 2271 | |
@@ -2188,8 +2299,9 @@ discard block |
||
| 2188 | 2299 | { |
| 2189 | 2300 | global $smcFunc; |
| 2190 | 2301 | |
| 2191 | - if (empty($toDelete)) |
|
| 2192 | - return false; |
|
| 2302 | + if (empty($toDelete)) { |
|
| 2303 | + return false; |
|
| 2304 | + } |
|
| 2193 | 2305 | |
| 2194 | 2306 | $toDelete = (array) $toDelete; |
| 2195 | 2307 | |
@@ -2224,8 +2336,9 @@ discard block |
||
| 2224 | 2336 | { |
| 2225 | 2337 | global $smcFunc; |
| 2226 | 2338 | |
| 2227 | - if (empty($memID)) |
|
| 2228 | - return false; |
|
| 2339 | + if (empty($memID)) { |
|
| 2340 | + return false; |
|
| 2341 | + } |
|
| 2229 | 2342 | |
| 2230 | 2343 | $request = $smcFunc['db_query']('', ' |
| 2231 | 2344 | SELECT id_alert |
@@ -2302,8 +2415,9 @@ discard block |
||
| 2302 | 2415 | { |
| 2303 | 2416 | $link = $topic['link']; |
| 2304 | 2417 | |
| 2305 | - if ($topic['new']) |
|
| 2306 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2418 | + if ($topic['new']) { |
|
| 2419 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2420 | + } |
|
| 2307 | 2421 | |
| 2308 | 2422 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
| 2309 | 2423 | |
@@ -2454,8 +2568,9 @@ discard block |
||
| 2454 | 2568 | { |
| 2455 | 2569 | $link = $board['link']; |
| 2456 | 2570 | |
| 2457 | - if ($board['new']) |
|
| 2458 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2571 | + if ($board['new']) { |
|
| 2572 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2573 | + } |
|
| 2459 | 2574 | |
| 2460 | 2575 | return $link; |
| 2461 | 2576 | }, |
@@ -2655,8 +2770,8 @@ discard block |
||
| 2655 | 2770 | ) |
| 2656 | 2771 | ); |
| 2657 | 2772 | $notification_boards = array(); |
| 2658 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2659 | - $notification_boards[] = array( |
|
| 2773 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2774 | + $notification_boards[] = array( |
|
| 2660 | 2775 | 'id' => $row['id_board'], |
| 2661 | 2776 | 'name' => $row['name'], |
| 2662 | 2777 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2664,6 +2779,7 @@ discard block |
||
| 2664 | 2779 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
| 2665 | 2780 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
| 2666 | 2781 | ); |
| 2782 | + } |
|
| 2667 | 2783 | $smcFunc['db_free_result']($request); |
| 2668 | 2784 | |
| 2669 | 2785 | return $notification_boards; |
@@ -2678,17 +2794,18 @@ discard block |
||
| 2678 | 2794 | { |
| 2679 | 2795 | global $context, $options, $cur_profile, $smcFunc; |
| 2680 | 2796 | |
| 2681 | - if (isset($_POST['default_options'])) |
|
| 2682 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2797 | + if (isset($_POST['default_options'])) { |
|
| 2798 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2799 | + } |
|
| 2683 | 2800 | |
| 2684 | 2801 | if ($context['user']['is_owner']) |
| 2685 | 2802 | { |
| 2686 | 2803 | $context['member']['options'] = $options; |
| 2687 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
| 2688 | - foreach ($_POST['options'] as $k => $v) |
|
| 2804 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
| 2805 | + foreach ($_POST['options'] as $k => $v) |
|
| 2689 | 2806 | $context['member']['options'][$k] = $v; |
| 2690 | - } |
|
| 2691 | - else |
|
| 2807 | + } |
|
| 2808 | + } else |
|
| 2692 | 2809 | { |
| 2693 | 2810 | $request = $smcFunc['db_query']('', ' |
| 2694 | 2811 | SELECT id_member, variable, value |
@@ -2709,8 +2826,9 @@ discard block |
||
| 2709 | 2826 | continue; |
| 2710 | 2827 | } |
| 2711 | 2828 | |
| 2712 | - if (isset($_POST['options'][$row['variable']])) |
|
| 2713 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2829 | + if (isset($_POST['options'][$row['variable']])) { |
|
| 2830 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2831 | + } |
|
| 2714 | 2832 | $context['member']['options'][$row['variable']] = $row['value']; |
| 2715 | 2833 | } |
| 2716 | 2834 | $smcFunc['db_free_result']($request); |
@@ -2718,8 +2836,9 @@ discard block |
||
| 2718 | 2836 | // Load up the default theme options for any missing. |
| 2719 | 2837 | foreach ($temp as $k => $v) |
| 2720 | 2838 | { |
| 2721 | - if (!isset($context['member']['options'][$k])) |
|
| 2722 | - $context['member']['options'][$k] = $v; |
|
| 2839 | + if (!isset($context['member']['options'][$k])) { |
|
| 2840 | + $context['member']['options'][$k] = $v; |
|
| 2841 | + } |
|
| 2723 | 2842 | } |
| 2724 | 2843 | } |
| 2725 | 2844 | } |
@@ -2734,8 +2853,9 @@ discard block |
||
| 2734 | 2853 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
| 2735 | 2854 | |
| 2736 | 2855 | // Have the admins enabled this option? |
| 2737 | - if (empty($modSettings['allow_ignore_boards'])) |
|
| 2738 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2856 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
| 2857 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2858 | + } |
|
| 2739 | 2859 | |
| 2740 | 2860 | // Find all the boards this user is allowed to see. |
| 2741 | 2861 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2755,12 +2875,13 @@ discard block |
||
| 2755 | 2875 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2756 | 2876 | { |
| 2757 | 2877 | // This category hasn't been set up yet.. |
| 2758 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 2759 | - $context['categories'][$row['id_cat']] = array( |
|
| 2878 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 2879 | + $context['categories'][$row['id_cat']] = array( |
|
| 2760 | 2880 | 'id' => $row['id_cat'], |
| 2761 | 2881 | 'name' => $row['cat_name'], |
| 2762 | 2882 | 'boards' => array() |
| 2763 | 2883 | ); |
| 2884 | + } |
|
| 2764 | 2885 | |
| 2765 | 2886 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 2766 | 2887 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2790,18 +2911,20 @@ discard block |
||
| 2790 | 2911 | } |
| 2791 | 2912 | |
| 2792 | 2913 | $max_boards = ceil(count($temp_boards) / 2); |
| 2793 | - if ($max_boards == 1) |
|
| 2794 | - $max_boards = 2; |
|
| 2914 | + if ($max_boards == 1) { |
|
| 2915 | + $max_boards = 2; |
|
| 2916 | + } |
|
| 2795 | 2917 | |
| 2796 | 2918 | // Now, alternate them so they can be shown left and right ;). |
| 2797 | 2919 | $context['board_columns'] = array(); |
| 2798 | 2920 | for ($i = 0; $i < $max_boards; $i++) |
| 2799 | 2921 | { |
| 2800 | 2922 | $context['board_columns'][] = $temp_boards[$i]; |
| 2801 | - if (isset($temp_boards[$i + $max_boards])) |
|
| 2802 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2803 | - else |
|
| 2804 | - $context['board_columns'][] = array(); |
|
| 2923 | + if (isset($temp_boards[$i + $max_boards])) { |
|
| 2924 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2925 | + } else { |
|
| 2926 | + $context['board_columns'][] = array(); |
|
| 2927 | + } |
|
| 2805 | 2928 | } |
| 2806 | 2929 | |
| 2807 | 2930 | loadThemeOptions($memID); |
@@ -2870,8 +2993,9 @@ discard block |
||
| 2870 | 2993 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2871 | 2994 | { |
| 2872 | 2995 | // We should skip the administrator group if they don't have the admin_forum permission! |
| 2873 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
| 2874 | - continue; |
|
| 2996 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
| 2997 | + continue; |
|
| 2998 | + } |
|
| 2875 | 2999 | |
| 2876 | 3000 | $context['member_groups'][$row['id_group']] = array( |
| 2877 | 3001 | 'id' => $row['id_group'], |
@@ -2917,16 +3041,17 @@ discard block |
||
| 2917 | 3041 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
| 2918 | 3042 | // Warning message for signature image limits? |
| 2919 | 3043 | $context['signature_warning'] = ''; |
| 2920 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
| 2921 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 2922 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
| 2923 | - $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 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
| 3045 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 3046 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
| 3047 | + $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']); |
|
| 3048 | + } |
|
| 2924 | 3049 | |
| 2925 | 3050 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
| 2926 | 3051 | |
| 2927 | - if (empty($context['do_preview'])) |
|
| 2928 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 2929 | - else |
|
| 3052 | + if (empty($context['do_preview'])) { |
|
| 3053 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 3054 | + } else |
|
| 2930 | 3055 | { |
| 2931 | 3056 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
| 2932 | 3057 | $validation = profileValidateSignature($signature); |
@@ -2936,8 +3061,9 @@ discard block |
||
| 2936 | 3061 | $context['post_errors'] = array(); |
| 2937 | 3062 | } |
| 2938 | 3063 | $context['post_errors'][] = 'signature_not_yet_saved'; |
| 2939 | - if ($validation !== true && $validation !== false) |
|
| 2940 | - $context['post_errors'][] = $validation; |
|
| 3064 | + if ($validation !== true && $validation !== false) { |
|
| 3065 | + $context['post_errors'][] = $validation; |
|
| 3066 | + } |
|
| 2941 | 3067 | |
| 2942 | 3068 | censorText($context['member']['signature']); |
| 2943 | 3069 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2947,8 +3073,9 @@ discard block |
||
| 2947 | 3073 | } |
| 2948 | 3074 | |
| 2949 | 3075 | // Load the spell checker? |
| 2950 | - if ($context['show_spellchecking']) |
|
| 2951 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3076 | + if ($context['show_spellchecking']) { |
|
| 3077 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3078 | + } |
|
| 2952 | 3079 | |
| 2953 | 3080 | return true; |
| 2954 | 3081 | } |
@@ -2982,8 +3109,7 @@ discard block |
||
| 2982 | 3109 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
| 2983 | 3110 | ); |
| 2984 | 3111 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
| 2985 | - } |
|
| 2986 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3112 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 2987 | 3113 | { |
| 2988 | 3114 | $context['member']['avatar'] += array( |
| 2989 | 3115 | 'choice' => 'upload', |
@@ -2993,33 +3119,34 @@ discard block |
||
| 2993 | 3119 | $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']; |
| 2994 | 3120 | } |
| 2995 | 3121 | // Use "avatar_original" here so we show what the user entered even if the image proxy is enabled |
| 2996 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
| 2997 | - $context['member']['avatar'] += array( |
|
| 3122 | + elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
| 3123 | + $context['member']['avatar'] += array( |
|
| 2998 | 3124 | 'choice' => 'external', |
| 2999 | 3125 | 'server_pic' => 'blank.png', |
| 3000 | 3126 | 'external' => $cur_profile['avatar_original'] |
| 3001 | 3127 | ); |
| 3002 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
| 3003 | - $context['member']['avatar'] += array( |
|
| 3128 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
| 3129 | + $context['member']['avatar'] += array( |
|
| 3004 | 3130 | 'choice' => 'server_stored', |
| 3005 | 3131 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
| 3006 | 3132 | 'external' => 'http://' |
| 3007 | 3133 | ); |
| 3008 | - else |
|
| 3009 | - $context['member']['avatar'] += array( |
|
| 3134 | + } else { |
|
| 3135 | + $context['member']['avatar'] += array( |
|
| 3010 | 3136 | 'choice' => 'none', |
| 3011 | 3137 | 'server_pic' => 'blank.png', |
| 3012 | 3138 | 'external' => 'http://' |
| 3013 | 3139 | ); |
| 3140 | + } |
|
| 3014 | 3141 | |
| 3015 | 3142 | // Get a list of all the avatars. |
| 3016 | 3143 | if ($context['member']['avatar']['allow_server_stored']) |
| 3017 | 3144 | { |
| 3018 | 3145 | $context['avatar_list'] = array(); |
| 3019 | 3146 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
| 3147 | + } else { |
|
| 3148 | + $context['avatars'] = array(); |
|
| 3020 | 3149 | } |
| 3021 | - else |
|
| 3022 | - $context['avatars'] = array(); |
|
| 3023 | 3150 | |
| 3024 | 3151 | // Second level selected avatar... |
| 3025 | 3152 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3048,19 +3175,22 @@ discard block |
||
| 3048 | 3175 | ) |
| 3049 | 3176 | ); |
| 3050 | 3177 | $protected_groups = array(1); |
| 3051 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3052 | - $protected_groups[] = $row['id_group']; |
|
| 3178 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3179 | + $protected_groups[] = $row['id_group']; |
|
| 3180 | + } |
|
| 3053 | 3181 | $smcFunc['db_free_result']($request); |
| 3054 | 3182 | |
| 3055 | 3183 | $protected_groups = array_unique($protected_groups); |
| 3056 | 3184 | } |
| 3057 | 3185 | |
| 3058 | 3186 | // The account page allows the change of your id_group - but not to a protected group! |
| 3059 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
| 3060 | - $value = (int) $value; |
|
| 3187 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
| 3188 | + $value = (int) $value; |
|
| 3189 | + } |
|
| 3061 | 3190 | // ... otherwise it's the old group sir. |
| 3062 | - else |
|
| 3063 | - $value = $old_profile['id_group']; |
|
| 3191 | + else { |
|
| 3192 | + $value = $old_profile['id_group']; |
|
| 3193 | + } |
|
| 3064 | 3194 | |
| 3065 | 3195 | // Find the additional membergroups (if any) |
| 3066 | 3196 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3069,16 +3199,18 @@ discard block |
||
| 3069 | 3199 | foreach ($_POST['additional_groups'] as $group_id) |
| 3070 | 3200 | { |
| 3071 | 3201 | $group_id = (int) $group_id; |
| 3072 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
| 3073 | - $additional_groups[] = $group_id; |
|
| 3202 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
| 3203 | + $additional_groups[] = $group_id; |
|
| 3204 | + } |
|
| 3074 | 3205 | } |
| 3075 | 3206 | |
| 3076 | 3207 | // Put the protected groups back in there if you don't have permission to take them away. |
| 3077 | 3208 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
| 3078 | 3209 | foreach ($old_additional_groups as $group_id) |
| 3079 | 3210 | { |
| 3080 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
| 3081 | - $additional_groups[] = $group_id; |
|
| 3211 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
| 3212 | + $additional_groups[] = $group_id; |
|
| 3213 | + } |
|
| 3082 | 3214 | } |
| 3083 | 3215 | |
| 3084 | 3216 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3110,18 +3242,20 @@ discard block |
||
| 3110 | 3242 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 3111 | 3243 | $smcFunc['db_free_result']($request); |
| 3112 | 3244 | |
| 3113 | - if (empty($another)) |
|
| 3114 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3245 | + if (empty($another)) { |
|
| 3246 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3247 | + } |
|
| 3115 | 3248 | } |
| 3116 | 3249 | } |
| 3117 | 3250 | |
| 3118 | 3251 | // If we are changing group status, update permission cache as necessary. |
| 3119 | 3252 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
| 3120 | 3253 | { |
| 3121 | - if ($context['user']['is_owner']) |
|
| 3122 | - $_SESSION['mc']['time'] = 0; |
|
| 3123 | - else |
|
| 3124 | - updateSettings(array('settings_updated' => time())); |
|
| 3254 | + if ($context['user']['is_owner']) { |
|
| 3255 | + $_SESSION['mc']['time'] = 0; |
|
| 3256 | + } else { |
|
| 3257 | + updateSettings(array('settings_updated' => time())); |
|
| 3258 | + } |
|
| 3125 | 3259 | } |
| 3126 | 3260 | |
| 3127 | 3261 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3142,8 +3276,9 @@ discard block |
||
| 3142 | 3276 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
| 3143 | 3277 | |
| 3144 | 3278 | $memID = $context['id_member']; |
| 3145 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
| 3146 | - return false; |
|
| 3279 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
| 3280 | + return false; |
|
| 3281 | + } |
|
| 3147 | 3282 | |
| 3148 | 3283 | require_once($sourcedir . '/ManageAttachments.php'); |
| 3149 | 3284 | |
@@ -3154,8 +3289,9 @@ discard block |
||
| 3154 | 3289 | $downloadedExternalAvatar = false; |
| 3155 | 3290 | 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'])) |
| 3156 | 3291 | { |
| 3157 | - if (!is_writable($uploadDir)) |
|
| 3158 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3292 | + if (!is_writable($uploadDir)) { |
|
| 3293 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3294 | + } |
|
| 3159 | 3295 | |
| 3160 | 3296 | require_once($sourcedir . '/Subs-Package.php'); |
| 3161 | 3297 | |
@@ -3199,19 +3335,18 @@ discard block |
||
| 3199 | 3335 | |
| 3200 | 3336 | // Get rid of their old avatar. (if uploaded.) |
| 3201 | 3337 | removeAttachments(array('id_member' => $memID)); |
| 3202 | - } |
|
| 3203 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3338 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3204 | 3339 | { |
| 3205 | 3340 | // 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. |
| 3206 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
| 3207 | - $profile_vars['avatar'] = 'gravatar://'; |
|
| 3208 | - else |
|
| 3209 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3341 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
| 3342 | + $profile_vars['avatar'] = 'gravatar://'; |
|
| 3343 | + } else { |
|
| 3344 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3345 | + } |
|
| 3210 | 3346 | |
| 3211 | 3347 | // Get rid of their old avatar. (if uploaded.) |
| 3212 | 3348 | removeAttachments(array('id_member' => $memID)); |
| 3213 | - } |
|
| 3214 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3349 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3215 | 3350 | { |
| 3216 | 3351 | // We need these clean... |
| 3217 | 3352 | $cur_profile['id_attach'] = 0; |
@@ -3223,11 +3358,13 @@ discard block |
||
| 3223 | 3358 | |
| 3224 | 3359 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
| 3225 | 3360 | |
| 3226 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
| 3227 | - $profile_vars['avatar'] = ''; |
|
| 3361 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
| 3362 | + $profile_vars['avatar'] = ''; |
|
| 3363 | + } |
|
| 3228 | 3364 | // Trying to make us do something we'll regret? |
| 3229 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
| 3230 | - return 'bad_avatar_invalid_url'; |
|
| 3365 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
| 3366 | + return 'bad_avatar_invalid_url'; |
|
| 3367 | + } |
|
| 3231 | 3368 | // Should we check dimensions? |
| 3232 | 3369 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
| 3233 | 3370 | { |
@@ -3237,9 +3374,9 @@ discard block |
||
| 3237 | 3374 | 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'])))) |
| 3238 | 3375 | { |
| 3239 | 3376 | // Houston, we have a problem. The avatar is too large!! |
| 3240 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
| 3241 | - return 'bad_avatar_too_large'; |
|
| 3242 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3377 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
| 3378 | + return 'bad_avatar_too_large'; |
|
| 3379 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3243 | 3380 | { |
| 3244 | 3381 | // @todo remove this if appropriate |
| 3245 | 3382 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3249,26 +3386,27 @@ discard block |
||
| 3249 | 3386 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
| 3250 | 3387 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
| 3251 | 3388 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
| 3389 | + } else { |
|
| 3390 | + return 'bad_avatar'; |
|
| 3252 | 3391 | } |
| 3253 | - else |
|
| 3254 | - return 'bad_avatar'; |
|
| 3255 | 3392 | } |
| 3256 | 3393 | } |
| 3257 | 3394 | } |
| 3258 | - } |
|
| 3259 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3395 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3260 | 3396 | { |
| 3261 | 3397 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
| 3262 | 3398 | { |
| 3263 | 3399 | // Get the dimensions of the image. |
| 3264 | 3400 | if (!$downloadedExternalAvatar) |
| 3265 | 3401 | { |
| 3266 | - if (!is_writable($uploadDir)) |
|
| 3267 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3402 | + if (!is_writable($uploadDir)) { |
|
| 3403 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3404 | + } |
|
| 3268 | 3405 | |
| 3269 | 3406 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
| 3270 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
| 3271 | - fatal_lang_error('attach_timeout', 'critical'); |
|
| 3407 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
| 3408 | + fatal_lang_error('attach_timeout', 'critical'); |
|
| 3409 | + } |
|
| 3272 | 3410 | |
| 3273 | 3411 | $_FILES['attachment']['tmp_name'] = $new_filename; |
| 3274 | 3412 | } |
@@ -3381,17 +3519,19 @@ discard block |
||
| 3381 | 3519 | $profile_vars['avatar'] = ''; |
| 3382 | 3520 | |
| 3383 | 3521 | // Delete any temporary file. |
| 3384 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
| 3385 | - @unlink($_FILES['attachment']['tmp_name']); |
|
| 3522 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
| 3523 | + @unlink($_FILES['attachment']['tmp_name']); |
|
| 3524 | + } |
|
| 3386 | 3525 | } |
| 3387 | 3526 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
| 3388 | - else |
|
| 3527 | + else { |
|
| 3528 | + $profile_vars['avatar'] = ''; |
|
| 3529 | + } |
|
| 3530 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
| 3531 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3532 | + } else { |
|
| 3389 | 3533 | $profile_vars['avatar'] = ''; |
| 3390 | 3534 | } |
| 3391 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
| 3392 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3393 | - else |
|
| 3394 | - $profile_vars['avatar'] = ''; |
|
| 3395 | 3535 | |
| 3396 | 3536 | // Setup the profile variables so it shows things right on display! |
| 3397 | 3537 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3439,9 +3579,9 @@ discard block |
||
| 3439 | 3579 | $smiley_parsed = $unparsed_signature; |
| 3440 | 3580 | parsesmileys($smiley_parsed); |
| 3441 | 3581 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
| 3442 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
| 3443 | - return 'signature_allow_smileys'; |
|
| 3444 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3582 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
| 3583 | + return 'signature_allow_smileys'; |
|
| 3584 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3445 | 3585 | { |
| 3446 | 3586 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
| 3447 | 3587 | return 'signature_max_smileys'; |
@@ -3454,14 +3594,15 @@ discard block |
||
| 3454 | 3594 | { |
| 3455 | 3595 | $limit_broke = 0; |
| 3456 | 3596 | // Attempt to allow all sizes of abuse, so to speak. |
| 3457 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 3458 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 3459 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 3460 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3461 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 3462 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3463 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 3464 | - $limit_broke = 'large'; |
|
| 3597 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 3598 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 3599 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 3600 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3601 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 3602 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3603 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 3604 | + $limit_broke = 'large'; |
|
| 3605 | + } |
|
| 3465 | 3606 | |
| 3466 | 3607 | if ($limit_broke) |
| 3467 | 3608 | { |
@@ -3503,24 +3644,26 @@ discard block |
||
| 3503 | 3644 | $width = -1; $height = -1; |
| 3504 | 3645 | |
| 3505 | 3646 | // Does it have predefined restraints? Width first. |
| 3506 | - if ($matches[6][$key]) |
|
| 3507 | - $matches[2][$key] = $matches[6][$key]; |
|
| 3647 | + if ($matches[6][$key]) { |
|
| 3648 | + $matches[2][$key] = $matches[6][$key]; |
|
| 3649 | + } |
|
| 3508 | 3650 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 3509 | 3651 | { |
| 3510 | 3652 | $width = $sig_limits[5]; |
| 3511 | 3653 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 3654 | + } elseif ($matches[2][$key]) { |
|
| 3655 | + $width = $matches[2][$key]; |
|
| 3512 | 3656 | } |
| 3513 | - elseif ($matches[2][$key]) |
|
| 3514 | - $width = $matches[2][$key]; |
|
| 3515 | 3657 | // ... and height. |
| 3516 | 3658 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 3517 | 3659 | { |
| 3518 | 3660 | $height = $sig_limits[6]; |
| 3519 | - if ($width != -1) |
|
| 3520 | - $width = $width * ($height / $matches[4][$key]); |
|
| 3661 | + if ($width != -1) { |
|
| 3662 | + $width = $width * ($height / $matches[4][$key]); |
|
| 3663 | + } |
|
| 3664 | + } elseif ($matches[4][$key]) { |
|
| 3665 | + $height = $matches[4][$key]; |
|
| 3521 | 3666 | } |
| 3522 | - elseif ($matches[4][$key]) |
|
| 3523 | - $height = $matches[4][$key]; |
|
| 3524 | 3667 | |
| 3525 | 3668 | // If the dimensions are still not fixed - we need to check the actual image. |
| 3526 | 3669 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3538,21 +3681,24 @@ discard block |
||
| 3538 | 3681 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 3539 | 3682 | { |
| 3540 | 3683 | $height = $sig_limits[6]; |
| 3541 | - if ($width == -1) |
|
| 3542 | - $width = $sizes[0]; |
|
| 3684 | + if ($width == -1) { |
|
| 3685 | + $width = $sizes[0]; |
|
| 3686 | + } |
|
| 3543 | 3687 | $width = $width * ($height / $sizes[1]); |
| 3688 | + } elseif ($width != -1) { |
|
| 3689 | + $height = $sizes[1]; |
|
| 3544 | 3690 | } |
| 3545 | - elseif ($width != -1) |
|
| 3546 | - $height = $sizes[1]; |
|
| 3547 | 3691 | } |
| 3548 | 3692 | } |
| 3549 | 3693 | |
| 3550 | 3694 | // Did we come up with some changes? If so remake the string. |
| 3551 | - if ($width != -1 || $height != -1) |
|
| 3552 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3695 | + if ($width != -1 || $height != -1) { |
|
| 3696 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3697 | + } |
|
| 3698 | + } |
|
| 3699 | + if (!empty($replaces)) { |
|
| 3700 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3553 | 3701 | } |
| 3554 | - if (!empty($replaces)) |
|
| 3555 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3556 | 3702 | } |
| 3557 | 3703 | } |
| 3558 | 3704 | |
@@ -3596,10 +3742,12 @@ discard block |
||
| 3596 | 3742 | $email = strtr($email, array(''' => '\'')); |
| 3597 | 3743 | |
| 3598 | 3744 | // Check the name and email for validity. |
| 3599 | - if (trim($email) == '') |
|
| 3600 | - return 'no_email'; |
|
| 3601 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 3602 | - return 'bad_email'; |
|
| 3745 | + if (trim($email) == '') { |
|
| 3746 | + return 'no_email'; |
|
| 3747 | + } |
|
| 3748 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 3749 | + return 'bad_email'; |
|
| 3750 | + } |
|
| 3603 | 3751 | |
| 3604 | 3752 | // Email addresses should be and stay unique. |
| 3605 | 3753 | $request = $smcFunc['db_query']('', ' |
@@ -3614,8 +3762,9 @@ discard block |
||
| 3614 | 3762 | ) |
| 3615 | 3763 | ); |
| 3616 | 3764 | |
| 3617 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 3618 | - return 'email_taken'; |
|
| 3765 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 3766 | + return 'email_taken'; |
|
| 3767 | + } |
|
| 3619 | 3768 | $smcFunc['db_free_result']($request); |
| 3620 | 3769 | |
| 3621 | 3770 | return true; |
@@ -3628,8 +3777,9 @@ discard block |
||
| 3628 | 3777 | { |
| 3629 | 3778 | global $modSettings, $context, $cur_profile; |
| 3630 | 3779 | |
| 3631 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
| 3632 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3780 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
| 3781 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3782 | + } |
|
| 3633 | 3783 | |
| 3634 | 3784 | loadUserSettings(); |
| 3635 | 3785 | writeLog(); |
@@ -3645,8 +3795,9 @@ discard block |
||
| 3645 | 3795 | require_once($sourcedir . '/Subs-Post.php'); |
| 3646 | 3796 | |
| 3647 | 3797 | // Shouldn't happen but just in case. |
| 3648 | - if (empty($profile_vars['email_address'])) |
|
| 3649 | - return; |
|
| 3798 | + if (empty($profile_vars['email_address'])) { |
|
| 3799 | + return; |
|
| 3800 | + } |
|
| 3650 | 3801 | |
| 3651 | 3802 | $replacements = array( |
| 3652 | 3803 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3669,8 +3820,9 @@ discard block |
||
| 3669 | 3820 | $_SESSION['log_time'] = 0; |
| 3670 | 3821 | $_SESSION['login_' . $cookiename] = json_encode(array(0, '', 0)); |
| 3671 | 3822 | |
| 3672 | - if (isset($_COOKIE[$cookiename])) |
|
| 3673 | - $_COOKIE[$cookiename] = ''; |
|
| 3823 | + if (isset($_COOKIE[$cookiename])) { |
|
| 3824 | + $_COOKIE[$cookiename] = ''; |
|
| 3825 | + } |
|
| 3674 | 3826 | |
| 3675 | 3827 | loadUserSettings(); |
| 3676 | 3828 | |
@@ -3703,11 +3855,13 @@ discard block |
||
| 3703 | 3855 | $groups[] = $curMember['id_group']; |
| 3704 | 3856 | |
| 3705 | 3857 | // Ensure the query doesn't croak! |
| 3706 | - if (empty($groups)) |
|
| 3707 | - $groups = array(0); |
|
| 3858 | + if (empty($groups)) { |
|
| 3859 | + $groups = array(0); |
|
| 3860 | + } |
|
| 3708 | 3861 | // Just to be sure... |
| 3709 | - foreach ($groups as $k => $v) |
|
| 3710 | - $groups[$k] = (int) $v; |
|
| 3862 | + foreach ($groups as $k => $v) { |
|
| 3863 | + $groups[$k] = (int) $v; |
|
| 3864 | + } |
|
| 3711 | 3865 | |
| 3712 | 3866 | // Get all the membergroups they can join. |
| 3713 | 3867 | $request = $smcFunc['db_query']('', ' |
@@ -3737,12 +3891,14 @@ discard block |
||
| 3737 | 3891 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3738 | 3892 | { |
| 3739 | 3893 | // Can they edit their primary group? |
| 3740 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
| 3741 | - $context['can_edit_primary'] = true; |
|
| 3894 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
| 3895 | + $context['can_edit_primary'] = true; |
|
| 3896 | + } |
|
| 3742 | 3897 | |
| 3743 | 3898 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
| 3744 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
| 3745 | - continue; |
|
| 3899 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
| 3900 | + continue; |
|
| 3901 | + } |
|
| 3746 | 3902 | |
| 3747 | 3903 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
| 3748 | 3904 | 'id' => $row['id_group'], |
@@ -3771,13 +3927,15 @@ discard block |
||
| 3771 | 3927 | ); |
| 3772 | 3928 | |
| 3773 | 3929 | // No changing primary one unless you have enough groups! |
| 3774 | - if (count($context['groups']['member']) < 2) |
|
| 3775 | - $context['can_edit_primary'] = false; |
|
| 3930 | + if (count($context['groups']['member']) < 2) { |
|
| 3931 | + $context['can_edit_primary'] = false; |
|
| 3932 | + } |
|
| 3776 | 3933 | |
| 3777 | 3934 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
| 3778 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
| 3779 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3780 | -} |
|
| 3935 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
| 3936 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3937 | + } |
|
| 3938 | + } |
|
| 3781 | 3939 | |
| 3782 | 3940 | /** |
| 3783 | 3941 | * This function actually makes all the group changes |
@@ -3792,10 +3950,12 @@ discard block |
||
| 3792 | 3950 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
| 3793 | 3951 | |
| 3794 | 3952 | // Let's be extra cautious... |
| 3795 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
| 3796 | - isAllowedTo('manage_membergroups'); |
|
| 3797 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
| 3798 | - fatal_lang_error('no_access', false); |
|
| 3953 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
| 3954 | + isAllowedTo('manage_membergroups'); |
|
| 3955 | + } |
|
| 3956 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
| 3957 | + fatal_lang_error('no_access', false); |
|
| 3958 | + } |
|
| 3799 | 3959 | |
| 3800 | 3960 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
| 3801 | 3961 | |
@@ -3814,8 +3974,9 @@ discard block |
||
| 3814 | 3974 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
| 3815 | 3975 | |
| 3816 | 3976 | // Sanity check!! |
| 3817 | - if ($group_id == 1) |
|
| 3818 | - isAllowedTo('admin_forum'); |
|
| 3977 | + if ($group_id == 1) { |
|
| 3978 | + isAllowedTo('admin_forum'); |
|
| 3979 | + } |
|
| 3819 | 3980 | // Protected groups too! |
| 3820 | 3981 | else |
| 3821 | 3982 | { |
@@ -3832,8 +3993,9 @@ discard block |
||
| 3832 | 3993 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
| 3833 | 3994 | $smcFunc['db_free_result']($request); |
| 3834 | 3995 | |
| 3835 | - if ($is_protected == 1) |
|
| 3836 | - isAllowedTo('admin_forum'); |
|
| 3996 | + if ($is_protected == 1) { |
|
| 3997 | + isAllowedTo('admin_forum'); |
|
| 3998 | + } |
|
| 3837 | 3999 | } |
| 3838 | 4000 | |
| 3839 | 4001 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3855,36 +4017,43 @@ discard block |
||
| 3855 | 4017 | $group_name = $row['group_name']; |
| 3856 | 4018 | |
| 3857 | 4019 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
| 3858 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
| 3859 | - fatal_lang_error('no_access', false); |
|
| 4020 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
| 4021 | + fatal_lang_error('no_access', false); |
|
| 4022 | + } |
|
| 3860 | 4023 | // What about leaving a requestable group we are not a member of? |
| 3861 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
| 3862 | - fatal_lang_error('no_access', false); |
|
| 3863 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
| 3864 | - fatal_lang_error('no_access', false); |
|
| 4024 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
| 4025 | + fatal_lang_error('no_access', false); |
|
| 4026 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
| 4027 | + fatal_lang_error('no_access', false); |
|
| 4028 | + } |
|
| 3865 | 4029 | |
| 3866 | 4030 | // We can't change the primary group if this is hidden! |
| 3867 | - if ($row['hidden'] == 2) |
|
| 3868 | - $canChangePrimary = false; |
|
| 4031 | + if ($row['hidden'] == 2) { |
|
| 4032 | + $canChangePrimary = false; |
|
| 4033 | + } |
|
| 3869 | 4034 | } |
| 3870 | 4035 | |
| 3871 | 4036 | // If this is their old primary, can we change it? |
| 3872 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
| 3873 | - $canChangePrimary = 1; |
|
| 4037 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
| 4038 | + $canChangePrimary = 1; |
|
| 4039 | + } |
|
| 3874 | 4040 | |
| 3875 | 4041 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
| 3876 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
| 3877 | - $canChangePrimary = false; |
|
| 4042 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
| 4043 | + $canChangePrimary = false; |
|
| 4044 | + } |
|
| 3878 | 4045 | |
| 3879 | 4046 | // If this is the one we are acting on, can we even act? |
| 3880 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
| 3881 | - $canChangePrimary = false; |
|
| 4047 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
| 4048 | + $canChangePrimary = false; |
|
| 4049 | + } |
|
| 3882 | 4050 | } |
| 3883 | 4051 | $smcFunc['db_free_result']($request); |
| 3884 | 4052 | |
| 3885 | 4053 | // Didn't find the target? |
| 3886 | - if (!$foundTarget) |
|
| 3887 | - fatal_lang_error('no_access', false); |
|
| 4054 | + if (!$foundTarget) { |
|
| 4055 | + fatal_lang_error('no_access', false); |
|
| 4056 | + } |
|
| 3888 | 4057 | |
| 3889 | 4058 | // Final security check, don't allow users to promote themselves to admin. |
| 3890 | 4059 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3904,8 +4073,9 @@ discard block |
||
| 3904 | 4073 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
| 3905 | 4074 | $smcFunc['db_free_result']($request); |
| 3906 | 4075 | |
| 3907 | - if ($disallow) |
|
| 3908 | - isAllowedTo('admin_forum'); |
|
| 4076 | + if ($disallow) { |
|
| 4077 | + isAllowedTo('admin_forum'); |
|
| 4078 | + } |
|
| 3909 | 4079 | } |
| 3910 | 4080 | |
| 3911 | 4081 | // If we're requesting, add the note then return. |
@@ -3923,8 +4093,9 @@ discard block |
||
| 3923 | 4093 | 'status_open' => 0, |
| 3924 | 4094 | ) |
| 3925 | 4095 | ); |
| 3926 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 3927 | - fatal_lang_error('profile_error_already_requested_group'); |
|
| 4096 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 4097 | + fatal_lang_error('profile_error_already_requested_group'); |
|
| 4098 | + } |
|
| 3928 | 4099 | $smcFunc['db_free_result']($request); |
| 3929 | 4100 | |
| 3930 | 4101 | // Log the request. |
@@ -3958,10 +4129,11 @@ discard block |
||
| 3958 | 4129 | // Are we leaving? |
| 3959 | 4130 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
| 3960 | 4131 | { |
| 3961 | - if ($old_profile['id_group'] == $group_id) |
|
| 3962 | - $newPrimary = 0; |
|
| 3963 | - else |
|
| 3964 | - unset($addGroups[$group_id]); |
|
| 4132 | + if ($old_profile['id_group'] == $group_id) { |
|
| 4133 | + $newPrimary = 0; |
|
| 4134 | + } else { |
|
| 4135 | + unset($addGroups[$group_id]); |
|
| 4136 | + } |
|
| 3965 | 4137 | } |
| 3966 | 4138 | // ... if not, must be joining. |
| 3967 | 4139 | else |
@@ -3969,36 +4141,42 @@ discard block |
||
| 3969 | 4141 | // Can we change the primary, and do we want to? |
| 3970 | 4142 | if ($canChangePrimary) |
| 3971 | 4143 | { |
| 3972 | - if ($old_profile['id_group'] != 0) |
|
| 3973 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4144 | + if ($old_profile['id_group'] != 0) { |
|
| 4145 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4146 | + } |
|
| 3974 | 4147 | $newPrimary = $group_id; |
| 3975 | 4148 | } |
| 3976 | 4149 | // Otherwise it's an additional group... |
| 3977 | - else |
|
| 3978 | - $addGroups[$group_id] = -1; |
|
| 4150 | + else { |
|
| 4151 | + $addGroups[$group_id] = -1; |
|
| 4152 | + } |
|
| 3979 | 4153 | } |
| 3980 | 4154 | } |
| 3981 | 4155 | // Finally, we must be setting the primary. |
| 3982 | 4156 | elseif ($canChangePrimary) |
| 3983 | 4157 | { |
| 3984 | - if ($old_profile['id_group'] != 0) |
|
| 3985 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 3986 | - if (isset($addGroups[$group_id])) |
|
| 3987 | - unset($addGroups[$group_id]); |
|
| 4158 | + if ($old_profile['id_group'] != 0) { |
|
| 4159 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4160 | + } |
|
| 4161 | + if (isset($addGroups[$group_id])) { |
|
| 4162 | + unset($addGroups[$group_id]); |
|
| 4163 | + } |
|
| 3988 | 4164 | $newPrimary = $group_id; |
| 3989 | 4165 | } |
| 3990 | 4166 | |
| 3991 | 4167 | // Finally, we can make the changes! |
| 3992 | - foreach ($addGroups as $id => $dummy) |
|
| 3993 | - if (empty($id)) |
|
| 4168 | + foreach ($addGroups as $id => $dummy) { |
|
| 4169 | + if (empty($id)) |
|
| 3994 | 4170 | unset($addGroups[$id]); |
| 4171 | + } |
|
| 3995 | 4172 | $addGroups = implode(',', array_flip($addGroups)); |
| 3996 | 4173 | |
| 3997 | 4174 | // Ensure that we don't cache permissions if the group is changing. |
| 3998 | - if ($context['user']['is_owner']) |
|
| 3999 | - $_SESSION['mc']['time'] = 0; |
|
| 4000 | - else |
|
| 4001 | - updateSettings(array('settings_updated' => time())); |
|
| 4175 | + if ($context['user']['is_owner']) { |
|
| 4176 | + $_SESSION['mc']['time'] = 0; |
|
| 4177 | + } else { |
|
| 4178 | + updateSettings(array('settings_updated' => time())); |
|
| 4179 | + } |
|
| 4002 | 4180 | |
| 4003 | 4181 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
| 4004 | 4182 | |
@@ -4021,8 +4199,9 @@ discard block |
||
| 4021 | 4199 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
| 4022 | 4200 | { |
| 4023 | 4201 | // Check to ensure we're forcing SSL for authentication |
| 4024 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 4025 | - fatal_lang_error('login_ssl_required'); |
|
| 4202 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 4203 | + fatal_lang_error('login_ssl_required'); |
|
| 4204 | + } |
|
| 4026 | 4205 | |
| 4027 | 4206 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
| 4028 | 4207 | // we do not want too much AJAX to confuse them. |
@@ -4059,8 +4238,7 @@ discard block |
||
| 4059 | 4238 | $context['sub_template'] = 'tfasetup_backup'; |
| 4060 | 4239 | |
| 4061 | 4240 | return; |
| 4062 | - } |
|
| 4063 | - else |
|
| 4241 | + } else |
|
| 4064 | 4242 | { |
| 4065 | 4243 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
| 4066 | 4244 | $context['tfa_error'] = !$valid_code; |
@@ -4068,8 +4246,7 @@ discard block |
||
| 4068 | 4246 | $context['tfa_pass_value'] = $_POST['passwd']; |
| 4069 | 4247 | $context['tfa_value'] = $_POST['tfa_code']; |
| 4070 | 4248 | } |
| 4071 | - } |
|
| 4072 | - else |
|
| 4249 | + } else |
|
| 4073 | 4250 | { |
| 4074 | 4251 | $totp = new \TOTP\Auth(); |
| 4075 | 4252 | $secret = $totp->generateCode(); |
@@ -4079,17 +4256,16 @@ discard block |
||
| 4079 | 4256 | } |
| 4080 | 4257 | |
| 4081 | 4258 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
| 4082 | - } |
|
| 4083 | - elseif (isset($_REQUEST['disable'])) |
|
| 4259 | + } elseif (isset($_REQUEST['disable'])) |
|
| 4084 | 4260 | { |
| 4085 | 4261 | updateMemberData($memID, array( |
| 4086 | 4262 | 'tfa_secret' => '', |
| 4087 | 4263 | 'tfa_backup' => '', |
| 4088 | 4264 | )); |
| 4089 | 4265 | redirectexit('action=profile;area=account;u=' . $memID); |
| 4266 | + } else { |
|
| 4267 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4268 | + } |
|
| 4090 | 4269 | } |
| 4091 | - else |
|
| 4092 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4093 | -} |
|
| 4094 | 4270 | |
| 4095 | 4271 | ?> |
| 4096 | 4272 | \ No newline at end of file |