@@ -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 |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
| 23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
| 24 | 25 | |
| 25 | 26 | // Attempt to load the member's profile data. |
| 26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
| 27 | - fatal_lang_error('not_a_user', false, 404); |
|
| 27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
| 28 | + fatal_lang_error('not_a_user', false, 404); |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | // Set up the stuff and load the user. |
| 30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
| 49 | 51 | |
| 50 | 52 | // See if they have broken any warning levels... |
| 51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
| 52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
| 53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
| 55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
| 57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
| 55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
| 57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
| 59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | // They haven't even been registered for a full day!? |
| 60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
| 61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
| 62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 63 | - else |
|
| 64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
| 65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 66 | + } else { |
|
| 67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | // Set the age... |
| 67 | 71 | if (empty($context['member']['birth_date']) || substr($context['member']['birthdate'], 0, 4) < 1002) |
@@ -70,8 +74,7 @@ discard block |
||
| 70 | 74 | 'age' => $txt['not_applicable'], |
| 71 | 75 | 'today_is_birthday' => false |
| 72 | 76 | ); |
| 73 | - } |
|
| 74 | - else |
|
| 77 | + } else |
|
| 75 | 78 | { |
| 76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
| 77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
| 84 | 87 | if (allowedTo('moderate_forum')) |
| 85 | 88 | { |
| 86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
| 87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
| 88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 89 | - else |
|
| 90 | - $context['member']['hostname'] = ''; |
|
| 90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
| 91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 92 | + } else { |
|
| 93 | + $context['member']['hostname'] = ''; |
|
| 94 | + } |
|
| 91 | 95 | |
| 92 | 96 | $context['can_see_ip'] = true; |
| 97 | + } else { |
|
| 98 | + $context['can_see_ip'] = false; |
|
| 93 | 99 | } |
| 94 | - else |
|
| 95 | - $context['can_see_ip'] = false; |
|
| 96 | 100 | |
| 97 | 101 | // Are they hidden? |
| 98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
| 103 | 107 | include_once($sourcedir . '/Who.php'); |
| 104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
| 105 | 109 | |
| 106 | - if ($action !== false) |
|
| 107 | - $context['member']['action'] = $action; |
|
| 110 | + if ($action !== false) { |
|
| 111 | + $context['member']['action'] = $action; |
|
| 112 | + } |
|
| 108 | 113 | } |
| 109 | 114 | |
| 110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
| 167 | 172 | { |
| 168 | 173 | // Work out what restrictions we actually have. |
| 169 | 174 | $ban_restrictions = array(); |
| 170 | - foreach (array('access', 'register', 'login', 'post') as $type) |
|
| 171 | - if ($row['cannot_' . $type]) |
|
| 175 | + foreach (array('access', 'register', 'login', 'post') as $type) { |
|
| 176 | + if ($row['cannot_' . $type]) |
|
| 172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
| 178 | + } |
|
| 173 | 179 | |
| 174 | 180 | // No actual ban in place? |
| 175 | - if (empty($ban_restrictions)) |
|
| 176 | - continue; |
|
| 181 | + if (empty($ban_restrictions)) { |
|
| 182 | + continue; |
|
| 183 | + } |
|
| 177 | 184 | |
| 178 | 185 | // Prepare the link for context. |
| 179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -196,9 +203,10 @@ discard block |
||
| 196 | 203 | $context['print_custom_fields'] = array(); |
| 197 | 204 | |
| 198 | 205 | // Any custom profile fields? |
| 199 | - if (!empty($context['custom_fields'])) |
|
| 200 | - foreach ($context['custom_fields'] as $custom) |
|
| 206 | + if (!empty($context['custom_fields'])) { |
|
| 207 | + foreach ($context['custom_fields'] as $custom) |
|
| 201 | 208 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 209 | + } |
|
| 202 | 210 | |
| 203 | 211 | } |
| 204 | 212 | |
@@ -242,14 +250,16 @@ discard block |
||
| 242 | 250 | $row['extra'] = !empty($row['extra']) ? smf_json_decode($row['extra'], true) : array(); |
| 243 | 251 | $alerts[$id_alert] = $row; |
| 244 | 252 | |
| 245 | - if (!empty($row['sender_id'])) |
|
| 246 | - $senders[] = $row['sender_id']; |
|
| 253 | + if (!empty($row['sender_id'])) { |
|
| 254 | + $senders[] = $row['sender_id']; |
|
| 255 | + } |
|
| 247 | 256 | } |
| 248 | 257 | $smcFunc['db_free_result']($request); |
| 249 | 258 | |
| 250 | 259 | $senders = loadMemberData($senders); |
| 251 | - foreach ($senders as $member) |
|
| 252 | - loadMemberContext($member); |
|
| 260 | + foreach ($senders as $member) { |
|
| 261 | + loadMemberContext($member); |
|
| 262 | + } |
|
| 253 | 263 | |
| 254 | 264 | // Now go through and actually make with the text. |
| 255 | 265 | loadLanguage('Alerts'); |
@@ -263,12 +273,15 @@ discard block |
||
| 263 | 273 | $msgs = array(); |
| 264 | 274 | foreach ($alerts as $id_alert => $alert) |
| 265 | 275 | { |
| 266 | - if (isset($alert['extra']['board'])) |
|
| 267 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 268 | - if (isset($alert['extra']['topic'])) |
|
| 269 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 270 | - if ($alert['content_type'] == 'msg') |
|
| 271 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 276 | + if (isset($alert['extra']['board'])) { |
|
| 277 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 278 | + } |
|
| 279 | + if (isset($alert['extra']['topic'])) { |
|
| 280 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 281 | + } |
|
| 282 | + if ($alert['content_type'] == 'msg') { |
|
| 283 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 284 | + } |
|
| 272 | 285 | } |
| 273 | 286 | |
| 274 | 287 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -283,8 +296,9 @@ discard block |
||
| 283 | 296 | 'boards' => array_keys($boards), |
| 284 | 297 | ) |
| 285 | 298 | ); |
| 286 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 287 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 299 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 300 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 301 | + } |
|
| 288 | 302 | } |
| 289 | 303 | if (!empty($topics)) |
| 290 | 304 | { |
@@ -299,8 +313,9 @@ discard block |
||
| 299 | 313 | 'topics' => array_keys($topics), |
| 300 | 314 | ) |
| 301 | 315 | ); |
| 302 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 303 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 317 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 318 | + } |
|
| 304 | 319 | } |
| 305 | 320 | if (!empty($msgs)) |
| 306 | 321 | { |
@@ -315,26 +330,33 @@ discard block |
||
| 315 | 330 | 'msgs' => array_keys($msgs), |
| 316 | 331 | ) |
| 317 | 332 | ); |
| 318 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 319 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 333 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 334 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 335 | + } |
|
| 320 | 336 | } |
| 321 | 337 | |
| 322 | 338 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
| 323 | 339 | foreach ($alerts as $id_alert => $alert) |
| 324 | 340 | { |
| 325 | - if (!empty($alert['text'])) |
|
| 326 | - continue; |
|
| 327 | - if (isset($alert['extra']['board'])) |
|
| 328 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 329 | - if (isset($alert['extra']['topic'])) |
|
| 330 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 331 | - if ($alert['content_type'] == 'msg') |
|
| 332 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 333 | - if ($alert['content_type'] == 'profile') |
|
| 334 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 335 | - |
|
| 336 | - if (!empty($memberContext[$alert['sender_id']])) |
|
| 337 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 341 | + if (!empty($alert['text'])) { |
|
| 342 | + continue; |
|
| 343 | + } |
|
| 344 | + if (isset($alert['extra']['board'])) { |
|
| 345 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 346 | + } |
|
| 347 | + if (isset($alert['extra']['topic'])) { |
|
| 348 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 349 | + } |
|
| 350 | + if ($alert['content_type'] == 'msg') { |
|
| 351 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 352 | + } |
|
| 353 | + if ($alert['content_type'] == 'profile') { |
|
| 354 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
| 358 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 359 | + } |
|
| 338 | 360 | |
| 339 | 361 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
| 340 | 362 | if (isset($txt[$string])) |
@@ -422,11 +444,11 @@ discard block |
||
| 422 | 444 | checkSession('request'); |
| 423 | 445 | |
| 424 | 446 | // Call it! |
| 425 | - if ($action == 'remove') |
|
| 426 | - alert_delete($toMark, $memID); |
|
| 427 | - |
|
| 428 | - else |
|
| 429 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 447 | + if ($action == 'remove') { |
|
| 448 | + alert_delete($toMark, $memID); |
|
| 449 | + } else { |
|
| 450 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 451 | + } |
|
| 430 | 452 | |
| 431 | 453 | // Set a nice update message. |
| 432 | 454 | $_SESSION['update_message'] = true; |
@@ -476,23 +498,27 @@ discard block |
||
| 476 | 498 | ); |
| 477 | 499 | |
| 478 | 500 | // Set the page title |
| 479 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
| 480 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 481 | - else |
|
| 482 | - $context['page_title'] = $txt['showPosts']; |
|
| 501 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
| 502 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 503 | + } else { |
|
| 504 | + $context['page_title'] = $txt['showPosts']; |
|
| 505 | + } |
|
| 483 | 506 | |
| 484 | 507 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
| 485 | 508 | |
| 486 | 509 | // Is the load average too high to allow searching just now? |
| 487 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
| 488 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 510 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
| 511 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 512 | + } |
|
| 489 | 513 | |
| 490 | 514 | // If we're specifically dealing with attachments use that function! |
| 491 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
| 492 | - return showAttachments($memID); |
|
| 515 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
| 516 | + return showAttachments($memID); |
|
| 517 | + } |
|
| 493 | 518 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
| 494 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
| 495 | - return showUnwatched($memID); |
|
| 519 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
| 520 | + return showUnwatched($memID); |
|
| 521 | + } |
|
| 496 | 522 | |
| 497 | 523 | // Are we just viewing topics? |
| 498 | 524 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -515,27 +541,30 @@ discard block |
||
| 515 | 541 | $smcFunc['db_free_result']($request); |
| 516 | 542 | |
| 517 | 543 | // Trying to remove a message that doesn't exist. |
| 518 | - if (empty($info)) |
|
| 519 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 544 | + if (empty($info)) { |
|
| 545 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 546 | + } |
|
| 520 | 547 | |
| 521 | 548 | // We can be lazy, since removeMessage() will check the permissions for us. |
| 522 | 549 | require_once($sourcedir . '/RemoveTopic.php'); |
| 523 | 550 | removeMessage((int) $_GET['delete']); |
| 524 | 551 | |
| 525 | 552 | // Add it to the mod log. |
| 526 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 527 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 553 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 554 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 555 | + } |
|
| 528 | 556 | |
| 529 | 557 | // Back to... where we are now ;). |
| 530 | 558 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
| 531 | 559 | } |
| 532 | 560 | |
| 533 | 561 | // Default to 10. |
| 534 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 535 | - $_REQUEST['viewscount'] = '10'; |
|
| 562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 563 | + $_REQUEST['viewscount'] = '10'; |
|
| 564 | + } |
|
| 536 | 565 | |
| 537 | - if ($context['is_topics']) |
|
| 538 | - $request = $smcFunc['db_query']('', ' |
|
| 566 | + if ($context['is_topics']) { |
|
| 567 | + $request = $smcFunc['db_query']('', ' |
|
| 539 | 568 | SELECT COUNT(*) |
| 540 | 569 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 541 | 570 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -548,8 +577,8 @@ discard block |
||
| 548 | 577 | 'board' => $board, |
| 549 | 578 | ) |
| 550 | 579 | ); |
| 551 | - else |
|
| 552 | - $request = $smcFunc['db_query']('', ' |
|
| 580 | + } else { |
|
| 581 | + $request = $smcFunc['db_query']('', ' |
|
| 553 | 582 | SELECT COUNT(*) |
| 554 | 583 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 555 | 584 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -562,6 +591,7 @@ discard block |
||
| 562 | 591 | 'board' => $board, |
| 563 | 592 | ) |
| 564 | 593 | ); |
| 594 | + } |
|
| 565 | 595 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
| 566 | 596 | $smcFunc['db_free_result']($request); |
| 567 | 597 | |
@@ -582,10 +612,11 @@ discard block |
||
| 582 | 612 | |
| 583 | 613 | $range_limit = ''; |
| 584 | 614 | |
| 585 | - if ($context['is_topics']) |
|
| 586 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 587 | - else |
|
| 588 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 615 | + if ($context['is_topics']) { |
|
| 616 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 617 | + } else { |
|
| 618 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 619 | + } |
|
| 589 | 620 | |
| 590 | 621 | $maxIndex = $maxPerPage; |
| 591 | 622 | |
@@ -611,9 +642,9 @@ discard block |
||
| 611 | 642 | { |
| 612 | 643 | $margin *= 5; |
| 613 | 644 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
| 645 | + } else { |
|
| 646 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 614 | 647 | } |
| 615 | - else |
|
| 616 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 617 | 648 | } |
| 618 | 649 | |
| 619 | 650 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -645,8 +676,7 @@ discard block |
||
| 645 | 676 | 'max' => $maxIndex, |
| 646 | 677 | ) |
| 647 | 678 | ); |
| 648 | - } |
|
| 649 | - else |
|
| 679 | + } else |
|
| 650 | 680 | { |
| 651 | 681 | $request = $smcFunc['db_query']('', ' |
| 652 | 682 | SELECT |
@@ -675,8 +705,9 @@ discard block |
||
| 675 | 705 | } |
| 676 | 706 | |
| 677 | 707 | // Make sure we quit this loop. |
| 678 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
| 679 | - break; |
|
| 708 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
| 709 | + break; |
|
| 710 | + } |
|
| 680 | 711 | $looped = true; |
| 681 | 712 | $range_limit = ''; |
| 682 | 713 | } |
@@ -720,19 +751,21 @@ discard block |
||
| 720 | 751 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
| 721 | 752 | ); |
| 722 | 753 | |
| 723 | - if ($user_info['id'] == $row['id_member_started']) |
|
| 724 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
| 754 | + if ($user_info['id'] == $row['id_member_started']) { |
|
| 755 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
| 756 | + } |
|
| 725 | 757 | $board_ids['any'][$row['id_board']][] = $counter; |
| 726 | 758 | } |
| 727 | 759 | $smcFunc['db_free_result']($request); |
| 728 | 760 | |
| 729 | 761 | // All posts were retrieved in reverse order, get them right again. |
| 730 | - if ($reverse) |
|
| 731 | - $context['posts'] = array_reverse($context['posts'], true); |
|
| 762 | + if ($reverse) { |
|
| 763 | + $context['posts'] = array_reverse($context['posts'], true); |
|
| 764 | + } |
|
| 732 | 765 | |
| 733 | 766 | // These are all the permissions that are different from board to board.. |
| 734 | - if ($context['is_topics']) |
|
| 735 | - $permissions = array( |
|
| 767 | + if ($context['is_topics']) { |
|
| 768 | + $permissions = array( |
|
| 736 | 769 | 'own' => array( |
| 737 | 770 | 'post_reply_own' => 'can_reply', |
| 738 | 771 | ), |
@@ -740,8 +773,8 @@ discard block |
||
| 740 | 773 | 'post_reply_any' => 'can_reply', |
| 741 | 774 | ) |
| 742 | 775 | ); |
| 743 | - else |
|
| 744 | - $permissions = array( |
|
| 776 | + } else { |
|
| 777 | + $permissions = array( |
|
| 745 | 778 | 'own' => array( |
| 746 | 779 | 'post_reply_own' => 'can_reply', |
| 747 | 780 | 'delete_own' => 'can_delete', |
@@ -751,6 +784,7 @@ discard block |
||
| 751 | 784 | 'delete_any' => 'can_delete', |
| 752 | 785 | ) |
| 753 | 786 | ); |
| 787 | + } |
|
| 754 | 788 | |
| 755 | 789 | // For every permission in the own/any lists... |
| 756 | 790 | foreach ($permissions as $type => $list) |
@@ -761,19 +795,22 @@ discard block |
||
| 761 | 795 | $boards = boardsAllowedTo($permission); |
| 762 | 796 | |
| 763 | 797 | // Hmm, they can do it on all boards, can they? |
| 764 | - if (!empty($boards) && $boards[0] == 0) |
|
| 765 | - $boards = array_keys($board_ids[$type]); |
|
| 798 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 799 | + $boards = array_keys($board_ids[$type]); |
|
| 800 | + } |
|
| 766 | 801 | |
| 767 | 802 | // Now go through each board they can do the permission on. |
| 768 | 803 | foreach ($boards as $board_id) |
| 769 | 804 | { |
| 770 | 805 | // There aren't any posts displayed from this board. |
| 771 | - if (!isset($board_ids[$type][$board_id])) |
|
| 772 | - continue; |
|
| 806 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 807 | + continue; |
|
| 808 | + } |
|
| 773 | 809 | |
| 774 | 810 | // Set the permission to true ;). |
| 775 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 776 | - $context['posts'][$counter][$allowed] = true; |
|
| 811 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 812 | + $context['posts'][$counter][$allowed] = true; |
|
| 813 | + } |
|
| 777 | 814 | } |
| 778 | 815 | } |
| 779 | 816 | } |
@@ -804,8 +841,9 @@ discard block |
||
| 804 | 841 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
| 805 | 842 | |
| 806 | 843 | // Make sure we can't actually see anything... |
| 807 | - if (empty($boardsAllowed)) |
|
| 808 | - $boardsAllowed = array(-1); |
|
| 844 | + if (empty($boardsAllowed)) { |
|
| 845 | + $boardsAllowed = array(-1); |
|
| 846 | + } |
|
| 809 | 847 | |
| 810 | 848 | require_once($sourcedir . '/Subs-List.php'); |
| 811 | 849 | |
@@ -956,8 +994,8 @@ discard block |
||
| 956 | 994 | ) |
| 957 | 995 | ); |
| 958 | 996 | $attachments = array(); |
| 959 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 960 | - $attachments[] = array( |
|
| 997 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 998 | + $attachments[] = array( |
|
| 961 | 999 | 'id' => $row['id_attach'], |
| 962 | 1000 | 'filename' => $row['filename'], |
| 963 | 1001 | 'downloads' => $row['downloads'], |
@@ -969,6 +1007,7 @@ discard block |
||
| 969 | 1007 | 'board_name' => $row['name'], |
| 970 | 1008 | 'approved' => $row['approved'], |
| 971 | 1009 | ); |
| 1010 | + } |
|
| 972 | 1011 | |
| 973 | 1012 | $smcFunc['db_free_result']($request); |
| 974 | 1013 | |
@@ -1023,8 +1062,9 @@ discard block |
||
| 1023 | 1062 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
| 1024 | 1063 | |
| 1025 | 1064 | // Only the owner can see the list (if the function is enabled of course) |
| 1026 | - if ($user_info['id'] != $memID) |
|
| 1027 | - return; |
|
| 1065 | + if ($user_info['id'] != $memID) { |
|
| 1066 | + return; |
|
| 1067 | + } |
|
| 1028 | 1068 | |
| 1029 | 1069 | require_once($sourcedir . '/Subs-List.php'); |
| 1030 | 1070 | |
@@ -1170,8 +1210,9 @@ discard block |
||
| 1170 | 1210 | ); |
| 1171 | 1211 | |
| 1172 | 1212 | $topics = array(); |
| 1173 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1174 | - $topics[] = $row['id_topic']; |
|
| 1213 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1214 | + $topics[] = $row['id_topic']; |
|
| 1215 | + } |
|
| 1175 | 1216 | |
| 1176 | 1217 | $smcFunc['db_free_result']($request); |
| 1177 | 1218 | |
@@ -1191,8 +1232,9 @@ discard block |
||
| 1191 | 1232 | 'topics' => $topics, |
| 1192 | 1233 | ) |
| 1193 | 1234 | ); |
| 1194 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1195 | - $topicsInfo[] = $row; |
|
| 1235 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1236 | + $topicsInfo[] = $row; |
|
| 1237 | + } |
|
| 1196 | 1238 | $smcFunc['db_free_result']($request); |
| 1197 | 1239 | } |
| 1198 | 1240 | |
@@ -1240,8 +1282,9 @@ discard block |
||
| 1240 | 1282 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
| 1241 | 1283 | |
| 1242 | 1284 | // Is the load average too high to allow searching just now? |
| 1243 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
| 1244 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1285 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
| 1286 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1287 | + } |
|
| 1245 | 1288 | |
| 1246 | 1289 | // General user statistics. |
| 1247 | 1290 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1399,11 +1442,13 @@ discard block |
||
| 1399 | 1442 | } |
| 1400 | 1443 | $smcFunc['db_free_result']($result); |
| 1401 | 1444 | |
| 1402 | - if ($maxPosts > 0) |
|
| 1403 | - for ($hour = 0; $hour < 24; $hour++) |
|
| 1445 | + if ($maxPosts > 0) { |
|
| 1446 | + for ($hour = 0; |
|
| 1447 | + } |
|
| 1448 | + $hour < 24; $hour++) |
|
| 1404 | 1449 | { |
| 1405 | - if (!isset($context['posts_by_time'][$hour])) |
|
| 1406 | - $context['posts_by_time'][$hour] = array( |
|
| 1450 | + if (!isset($context['posts_by_time'][$hour])) { |
|
| 1451 | + $context['posts_by_time'][$hour] = array( |
|
| 1407 | 1452 | 'hour' => $hour, |
| 1408 | 1453 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
| 1409 | 1454 | 'posts' => 0, |
@@ -1411,7 +1456,7 @@ discard block |
||
| 1411 | 1456 | 'relative_percent' => 0, |
| 1412 | 1457 | 'is_last' => $hour == 23, |
| 1413 | 1458 | ); |
| 1414 | - else |
|
| 1459 | + } else |
|
| 1415 | 1460 | { |
| 1416 | 1461 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
| 1417 | 1462 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1444,8 +1489,9 @@ discard block |
||
| 1444 | 1489 | |
| 1445 | 1490 | foreach ($subActions as $sa => $action) |
| 1446 | 1491 | { |
| 1447 | - if (!allowedTo($action[2])) |
|
| 1448 | - unset($subActions[$sa]); |
|
| 1492 | + if (!allowedTo($action[2])) { |
|
| 1493 | + unset($subActions[$sa]); |
|
| 1494 | + } |
|
| 1449 | 1495 | } |
| 1450 | 1496 | |
| 1451 | 1497 | // Create the tabs for the template. |
@@ -1463,15 +1509,18 @@ discard block |
||
| 1463 | 1509 | ); |
| 1464 | 1510 | |
| 1465 | 1511 | // Moderation must be on to track edits. |
| 1466 | - if (empty($modSettings['userlog_enabled'])) |
|
| 1467 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1512 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 1513 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1514 | + } |
|
| 1468 | 1515 | |
| 1469 | 1516 | // Group requests must be active to show it... |
| 1470 | - if (empty($modSettings['show_group_membership'])) |
|
| 1471 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1517 | + if (empty($modSettings['show_group_membership'])) { |
|
| 1518 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1519 | + } |
|
| 1472 | 1520 | |
| 1473 | - if (empty($subActions)) |
|
| 1474 | - fatal_lang_error('no_access', false); |
|
| 1521 | + if (empty($subActions)) { |
|
| 1522 | + fatal_lang_error('no_access', false); |
|
| 1523 | + } |
|
| 1475 | 1524 | |
| 1476 | 1525 | $keys = array_keys($subActions); |
| 1477 | 1526 | $default = array_shift($keys); |
@@ -1484,9 +1533,10 @@ discard block |
||
| 1484 | 1533 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
| 1485 | 1534 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
| 1486 | 1535 | |
| 1487 | - if (!empty($call)) |
|
| 1488 | - call_user_func($call, $memID); |
|
| 1489 | -} |
|
| 1536 | + if (!empty($call)) { |
|
| 1537 | + call_user_func($call, $memID); |
|
| 1538 | + } |
|
| 1539 | + } |
|
| 1490 | 1540 | |
| 1491 | 1541 | /** |
| 1492 | 1542 | * Handles tracking a user's activity |
@@ -1502,8 +1552,9 @@ discard block |
||
| 1502 | 1552 | isAllowedTo('moderate_forum'); |
| 1503 | 1553 | |
| 1504 | 1554 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
| 1505 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
| 1506 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1555 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
| 1556 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1557 | + } |
|
| 1507 | 1558 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
| 1508 | 1559 | |
| 1509 | 1560 | // Set the options for the list component. |
@@ -1669,8 +1720,9 @@ discard block |
||
| 1669 | 1720 | ) |
| 1670 | 1721 | ); |
| 1671 | 1722 | $message_members = array(); |
| 1672 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1673 | - $message_members[] = $row['id_member']; |
|
| 1723 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1724 | + $message_members[] = $row['id_member']; |
|
| 1725 | + } |
|
| 1674 | 1726 | $smcFunc['db_free_result']($request); |
| 1675 | 1727 | |
| 1676 | 1728 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1685,8 +1737,9 @@ discard block |
||
| 1685 | 1737 | 'ip_list' => $ips, |
| 1686 | 1738 | ) |
| 1687 | 1739 | ); |
| 1688 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1689 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1740 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1741 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1742 | + } |
|
| 1690 | 1743 | $smcFunc['db_free_result']($request); |
| 1691 | 1744 | } |
| 1692 | 1745 | |
@@ -1700,8 +1753,9 @@ discard block |
||
| 1700 | 1753 | 'ip_list' => $ips, |
| 1701 | 1754 | ) |
| 1702 | 1755 | ); |
| 1703 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1704 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1756 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1757 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1758 | + } |
|
| 1705 | 1759 | $smcFunc['db_free_result']($request); |
| 1706 | 1760 | } |
| 1707 | 1761 | } |
@@ -1761,8 +1815,8 @@ discard block |
||
| 1761 | 1815 | )) |
| 1762 | 1816 | ); |
| 1763 | 1817 | $error_messages = array(); |
| 1764 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1765 | - $error_messages[] = array( |
|
| 1818 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1819 | + $error_messages[] = array( |
|
| 1766 | 1820 | 'ip' => inet_dtop($row['ip']), |
| 1767 | 1821 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
| 1768 | 1822 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1770,6 +1824,7 @@ discard block |
||
| 1770 | 1824 | 'time' => timeformat($row['log_time']), |
| 1771 | 1825 | 'timestamp' => forum_time(true, $row['log_time']), |
| 1772 | 1826 | ); |
| 1827 | + } |
|
| 1773 | 1828 | $smcFunc['db_free_result']($request); |
| 1774 | 1829 | |
| 1775 | 1830 | return $error_messages; |
@@ -1832,8 +1887,8 @@ discard block |
||
| 1832 | 1887 | )) |
| 1833 | 1888 | ); |
| 1834 | 1889 | $messages = array(); |
| 1835 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1836 | - $messages[] = array( |
|
| 1890 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1891 | + $messages[] = array( |
|
| 1837 | 1892 | 'ip' => inet_dtop($row['poster_ip']), |
| 1838 | 1893 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
| 1839 | 1894 | 'board' => array( |
@@ -1846,6 +1901,7 @@ discard block |
||
| 1846 | 1901 | 'time' => timeformat($row['poster_time']), |
| 1847 | 1902 | 'timestamp' => forum_time(true, $row['poster_time']) |
| 1848 | 1903 | ); |
| 1904 | + } |
|
| 1849 | 1905 | $smcFunc['db_free_result']($request); |
| 1850 | 1906 | |
| 1851 | 1907 | return $messages; |
@@ -1872,19 +1928,20 @@ discard block |
||
| 1872 | 1928 | $context['sub_template'] = 'trackIP'; |
| 1873 | 1929 | $context['page_title'] = $txt['profile']; |
| 1874 | 1930 | $context['base_url'] = $scripturl . '?action=trackip'; |
| 1875 | - } |
|
| 1876 | - else |
|
| 1931 | + } else |
|
| 1877 | 1932 | { |
| 1878 | 1933 | $context['ip'] = $user_profile[$memID]['member_ip']; |
| 1879 | 1934 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
| 1880 | 1935 | } |
| 1881 | 1936 | |
| 1882 | 1937 | // Searching? |
| 1883 | - if (isset($_REQUEST['searchip'])) |
|
| 1884 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1938 | + if (isset($_REQUEST['searchip'])) { |
|
| 1939 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1940 | + } |
|
| 1885 | 1941 | |
| 1886 | - if (isValidIP($context['ip']) === false) |
|
| 1887 | - fatal_lang_error('invalid_tracking_ip', false); |
|
| 1942 | + if (isValidIP($context['ip']) === false) { |
|
| 1943 | + fatal_lang_error('invalid_tracking_ip', false); |
|
| 1944 | + } |
|
| 1888 | 1945 | |
| 1889 | 1946 | //mysql didn't support like search with varbinary |
| 1890 | 1947 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1892,8 +1949,9 @@ discard block |
||
| 1892 | 1949 | $ip_var = $context['ip']; |
| 1893 | 1950 | $ip_string = '= {inet:ip_address}'; |
| 1894 | 1951 | |
| 1895 | - if (empty($context['tracking_area'])) |
|
| 1896 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1952 | + if (empty($context['tracking_area'])) { |
|
| 1953 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1954 | + } |
|
| 1897 | 1955 | |
| 1898 | 1956 | $request = $smcFunc['db_query']('', ' |
| 1899 | 1957 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1904,8 +1962,9 @@ discard block |
||
| 1904 | 1962 | ) |
| 1905 | 1963 | ); |
| 1906 | 1964 | $context['ips'] = array(); |
| 1907 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1908 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1965 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1966 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1967 | + } |
|
| 1909 | 1968 | $smcFunc['db_free_result']($request); |
| 1910 | 1969 | |
| 1911 | 1970 | ksort($context['ips']); |
@@ -2134,8 +2193,9 @@ discard block |
||
| 2134 | 2193 | foreach ($context['whois_servers'] as $whois) |
| 2135 | 2194 | { |
| 2136 | 2195 | // Strip off the "decimal point" and anything following... |
| 2137 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
| 2138 | - $context['auto_whois_server'] = $whois; |
|
| 2196 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
| 2197 | + $context['auto_whois_server'] = $whois; |
|
| 2198 | + } |
|
| 2139 | 2199 | } |
| 2140 | 2200 | } |
| 2141 | 2201 | } |
@@ -2152,10 +2212,11 @@ discard block |
||
| 2152 | 2212 | // Gonna want this for the list. |
| 2153 | 2213 | require_once($sourcedir . '/Subs-List.php'); |
| 2154 | 2214 | |
| 2155 | - if ($memID == 0) |
|
| 2156 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2157 | - else |
|
| 2158 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2215 | + if ($memID == 0) { |
|
| 2216 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2217 | + } else { |
|
| 2218 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2219 | + } |
|
| 2159 | 2220 | |
| 2160 | 2221 | // Start with the user messages. |
| 2161 | 2222 | $listOptions = array( |
@@ -2265,12 +2326,13 @@ discard block |
||
| 2265 | 2326 | ) |
| 2266 | 2327 | ); |
| 2267 | 2328 | $logins = array(); |
| 2268 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2269 | - $logins[] = array( |
|
| 2329 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2330 | + $logins[] = array( |
|
| 2270 | 2331 | 'time' => timeformat($row['time']), |
| 2271 | 2332 | 'ip' => inet_dtop($row['ip']), |
| 2272 | 2333 | 'ip2' => inet_dtop($row['ip2']), |
| 2273 | 2334 | ); |
| 2335 | + } |
|
| 2274 | 2336 | $smcFunc['db_free_result']($request); |
| 2275 | 2337 | |
| 2276 | 2338 | return $logins; |
@@ -2295,11 +2357,12 @@ discard block |
||
| 2295 | 2357 | ) |
| 2296 | 2358 | ); |
| 2297 | 2359 | $context['custom_field_titles'] = array(); |
| 2298 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2299 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2360 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2361 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2300 | 2362 | 'title' => $row['field_name'], |
| 2301 | 2363 | 'parse_bbc' => $row['bbc'], |
| 2302 | 2364 | ); |
| 2365 | + } |
|
| 2303 | 2366 | $smcFunc['db_free_result']($request); |
| 2304 | 2367 | |
| 2305 | 2368 | // Set the options for the error lists. |
@@ -2438,19 +2501,22 @@ discard block |
||
| 2438 | 2501 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2439 | 2502 | { |
| 2440 | 2503 | $extra = smf_json_decode($row['extra'], true); |
| 2441 | - if (!empty($extra['applicator'])) |
|
| 2442 | - $members[] = $extra['applicator']; |
|
| 2504 | + if (!empty($extra['applicator'])) { |
|
| 2505 | + $members[] = $extra['applicator']; |
|
| 2506 | + } |
|
| 2443 | 2507 | |
| 2444 | 2508 | // Work out what the name of the action is. |
| 2445 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
| 2446 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2447 | - elseif (isset($txt[$row['action']])) |
|
| 2448 | - $action_text = $txt[$row['action']]; |
|
| 2509 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
| 2510 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2511 | + } elseif (isset($txt[$row['action']])) { |
|
| 2512 | + $action_text = $txt[$row['action']]; |
|
| 2513 | + } |
|
| 2449 | 2514 | // Custom field? |
| 2450 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
| 2451 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2452 | - else |
|
| 2453 | - $action_text = $row['action']; |
|
| 2515 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
| 2516 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2517 | + } else { |
|
| 2518 | + $action_text = $row['action']; |
|
| 2519 | + } |
|
| 2454 | 2520 | |
| 2455 | 2521 | // Parse BBC? |
| 2456 | 2522 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2482,13 +2548,15 @@ discard block |
||
| 2482 | 2548 | ) |
| 2483 | 2549 | ); |
| 2484 | 2550 | $members = array(); |
| 2485 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2486 | - $members[$row['id_member']] = $row['real_name']; |
|
| 2551 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2552 | + $members[$row['id_member']] = $row['real_name']; |
|
| 2553 | + } |
|
| 2487 | 2554 | $smcFunc['db_free_result']($request); |
| 2488 | 2555 | |
| 2489 | - foreach ($edits as $key => $value) |
|
| 2490 | - if (isset($members[$value['id_member']])) |
|
| 2556 | + foreach ($edits as $key => $value) { |
|
| 2557 | + if (isset($members[$value['id_member']])) |
|
| 2491 | 2558 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
| 2559 | + } |
|
| 2492 | 2560 | } |
| 2493 | 2561 | |
| 2494 | 2562 | return $edits; |
@@ -2689,10 +2757,11 @@ discard block |
||
| 2689 | 2757 | $context['board'] = $board; |
| 2690 | 2758 | |
| 2691 | 2759 | // Determine which groups this user is in. |
| 2692 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
| 2693 | - $curGroups = array(); |
|
| 2694 | - else |
|
| 2695 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2760 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
| 2761 | + $curGroups = array(); |
|
| 2762 | + } else { |
|
| 2763 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2764 | + } |
|
| 2696 | 2765 | $curGroups[] = $user_profile[$memID]['id_group']; |
| 2697 | 2766 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
| 2698 | 2767 | |
@@ -2712,28 +2781,30 @@ discard block |
||
| 2712 | 2781 | $context['no_access_boards'] = array(); |
| 2713 | 2782 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2714 | 2783 | { |
| 2715 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
| 2716 | - $context['no_access_boards'][] = array( |
|
| 2784 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
| 2785 | + $context['no_access_boards'][] = array( |
|
| 2717 | 2786 | 'id' => $row['id_board'], |
| 2718 | 2787 | 'name' => $row['name'], |
| 2719 | 2788 | 'is_last' => false, |
| 2720 | 2789 | ); |
| 2721 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
| 2722 | - $context['boards'][$row['id_board']] = array( |
|
| 2790 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
| 2791 | + $context['boards'][$row['id_board']] = array( |
|
| 2723 | 2792 | 'id' => $row['id_board'], |
| 2724 | 2793 | 'name' => $row['name'], |
| 2725 | 2794 | 'selected' => $board == $row['id_board'], |
| 2726 | 2795 | 'profile' => $row['id_profile'], |
| 2727 | 2796 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
| 2728 | 2797 | ); |
| 2798 | + } |
|
| 2729 | 2799 | } |
| 2730 | 2800 | $smcFunc['db_free_result']($request); |
| 2731 | 2801 | |
| 2732 | 2802 | require_once($sourcedir . '/Subs-Boards.php'); |
| 2733 | 2803 | sortBoards($context['boards']); |
| 2734 | 2804 | |
| 2735 | - if (!empty($context['no_access_boards'])) |
|
| 2736 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2805 | + if (!empty($context['no_access_boards'])) { |
|
| 2806 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2807 | + } |
|
| 2737 | 2808 | |
| 2738 | 2809 | $context['member']['permissions'] = array( |
| 2739 | 2810 | 'general' => array(), |
@@ -2742,8 +2813,9 @@ discard block |
||
| 2742 | 2813 | |
| 2743 | 2814 | // If you're an admin we know you can do everything, we might as well leave. |
| 2744 | 2815 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
| 2745 | - if ($context['member']['has_all_permissions']) |
|
| 2746 | - return; |
|
| 2816 | + if ($context['member']['has_all_permissions']) { |
|
| 2817 | + return; |
|
| 2818 | + } |
|
| 2747 | 2819 | |
| 2748 | 2820 | $denied = array(); |
| 2749 | 2821 | |
@@ -2762,21 +2834,24 @@ discard block |
||
| 2762 | 2834 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2763 | 2835 | { |
| 2764 | 2836 | // We don't know about this permission, it doesn't exist :P. |
| 2765 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2766 | - continue; |
|
| 2837 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2838 | + continue; |
|
| 2839 | + } |
|
| 2767 | 2840 | |
| 2768 | - if (empty($row['add_deny'])) |
|
| 2769 | - $denied[] = $row['permission']; |
|
| 2841 | + if (empty($row['add_deny'])) { |
|
| 2842 | + $denied[] = $row['permission']; |
|
| 2843 | + } |
|
| 2770 | 2844 | |
| 2771 | 2845 | // Permissions that end with _own or _any consist of two parts. |
| 2772 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2773 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2774 | - else |
|
| 2775 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2846 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2847 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2848 | + } else { |
|
| 2849 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2850 | + } |
|
| 2776 | 2851 | |
| 2777 | 2852 | // Add this permission if it doesn't exist yet. |
| 2778 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
| 2779 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2853 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
| 2854 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2780 | 2855 | 'id' => $row['permission'], |
| 2781 | 2856 | 'groups' => array( |
| 2782 | 2857 | 'allowed' => array(), |
@@ -2786,6 +2861,7 @@ discard block |
||
| 2786 | 2861 | 'is_denied' => false, |
| 2787 | 2862 | 'is_global' => true, |
| 2788 | 2863 | ); |
| 2864 | + } |
|
| 2789 | 2865 | |
| 2790 | 2866 | // Add the membergroup to either the denied or the allowed groups. |
| 2791 | 2867 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2819,18 +2895,20 @@ discard block |
||
| 2819 | 2895 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2820 | 2896 | { |
| 2821 | 2897 | // We don't know about this permission, it doesn't exist :P. |
| 2822 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2823 | - continue; |
|
| 2898 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2899 | + continue; |
|
| 2900 | + } |
|
| 2824 | 2901 | |
| 2825 | 2902 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
| 2826 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2827 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2828 | - else |
|
| 2829 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2903 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2904 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2905 | + } else { |
|
| 2906 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2907 | + } |
|
| 2830 | 2908 | |
| 2831 | 2909 | // Create the structure for this permission. |
| 2832 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
| 2833 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2910 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
| 2911 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2834 | 2912 | 'id' => $row['permission'], |
| 2835 | 2913 | 'groups' => array( |
| 2836 | 2914 | 'allowed' => array(), |
@@ -2840,6 +2918,7 @@ discard block |
||
| 2840 | 2918 | 'is_denied' => false, |
| 2841 | 2919 | 'is_global' => empty($board), |
| 2842 | 2920 | ); |
| 2921 | + } |
|
| 2843 | 2922 | |
| 2844 | 2923 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
| 2845 | 2924 | |
@@ -2858,8 +2937,9 @@ discard block |
||
| 2858 | 2937 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
| 2859 | 2938 | |
| 2860 | 2939 | // Firstly, can we actually even be here? |
| 2861 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
| 2862 | - fatal_lang_error('no_access', false); |
|
| 2940 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
| 2941 | + fatal_lang_error('no_access', false); |
|
| 2942 | + } |
|
| 2863 | 2943 | |
| 2864 | 2944 | // Make sure things which are disabled stay disabled. |
| 2865 | 2945 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2946,9 +3026,10 @@ discard block |
||
| 2946 | 3026 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
| 2947 | 3027 | ); |
| 2948 | 3028 | $context['current_level'] = 0; |
| 2949 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
| 2950 | - if ($context['member']['warning'] >= $limit) |
|
| 3029 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
| 3030 | + if ($context['member']['warning'] >= $limit) |
|
| 2951 | 3031 | $context['current_level'] = $limit; |
| 2952 | -} |
|
| 3032 | + } |
|
| 3033 | + } |
|
| 2953 | 3034 | |
| 2954 | 3035 | ?> |
| 2955 | 3036 | \ No newline at end of file |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | 'value' => $txt['date'], |
| 137 | 137 | ), |
| 138 | 138 | 'data' => array( |
| 139 | - 'function' => function ($rowData) use ($txt) |
|
| 139 | + 'function' => function($rowData) use ($txt) |
|
| 140 | 140 | { |
| 141 | 141 | // Recurring every year or just a single year? |
| 142 | 142 | $year = $rowData['year'] == '1001' ? sprintf('(%1$s)', $txt['every_year']) : $rowData['year']; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | checkSession(); |
| 219 | 219 | |
| 220 | 220 | // Not too long good sir? |
| 221 | - $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
|
| 221 | + $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
|
| 222 | 222 | $_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0; |
| 223 | 223 | |
| 224 | 224 | if (isset($_REQUEST['delete'])) |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main controlling function doesn't have much to do... yet. |
@@ -43,8 +44,7 @@ discard block |
||
| 43 | 44 | 'settings' => 'ModifyCalendarSettings' |
| 44 | 45 | ); |
| 45 | 46 | $default = 'holidays'; |
| 46 | - } |
|
| 47 | - else |
|
| 47 | + } else |
|
| 48 | 48 | { |
| 49 | 49 | $subActions = array( |
| 50 | 50 | 'settings' => 'ModifyCalendarSettings' |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | 'help' => 'calendar', |
| 61 | 61 | 'description' => $txt['calendar_settings_desc'], |
| 62 | 62 | ); |
| 63 | - if (!empty($modSettings['cal_enabled'])) |
|
| 64 | - $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 63 | + if (!empty($modSettings['cal_enabled'])) { |
|
| 64 | + $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 65 | 65 | 'holidays' => array( |
| 66 | 66 | 'description' => $txt['manage_holidays_desc'], |
| 67 | 67 | ), |
@@ -69,6 +69,7 @@ discard block |
||
| 69 | 69 | 'description' => $txt['calendar_settings_desc'], |
| 70 | 70 | ), |
| 71 | 71 | ); |
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | call_integration_hook('integrate_manage_calendar', array(&$subActions)); |
| 74 | 75 | |
@@ -88,8 +89,9 @@ discard block |
||
| 88 | 89 | checkSession(); |
| 89 | 90 | validateToken('admin-mc'); |
| 90 | 91 | |
| 91 | - foreach ($_REQUEST['holiday'] as $id => $value) |
|
| 92 | - $_REQUEST['holiday'][$id] = (int) $id; |
|
| 92 | + foreach ($_REQUEST['holiday'] as $id => $value) { |
|
| 93 | + $_REQUEST['holiday'][$id] = (int) $id; |
|
| 94 | + } |
|
| 93 | 95 | |
| 94 | 96 | // Now the IDs are "safe" do the delete... |
| 95 | 97 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -209,8 +211,9 @@ discard block |
||
| 209 | 211 | $context['sub_template'] = 'edit_holiday'; |
| 210 | 212 | |
| 211 | 213 | // Cast this for safety... |
| 212 | - if (isset($_REQUEST['holiday'])) |
|
| 213 | - $_REQUEST['holiday'] = (int) $_REQUEST['holiday']; |
|
| 214 | + if (isset($_REQUEST['holiday'])) { |
|
| 215 | + $_REQUEST['holiday'] = (int) $_REQUEST['holiday']; |
|
| 216 | + } |
|
| 214 | 217 | |
| 215 | 218 | // Submitting? |
| 216 | 219 | if (isset($_POST[$context['session_var']]) && (isset($_REQUEST['delete']) || $_REQUEST['title'] != '')) |
@@ -221,19 +224,19 @@ discard block |
||
| 221 | 224 | $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
| 222 | 225 | $_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0; |
| 223 | 226 | |
| 224 | - if (isset($_REQUEST['delete'])) |
|
| 225 | - $smcFunc['db_query']('', ' |
|
| 227 | + if (isset($_REQUEST['delete'])) { |
|
| 228 | + $smcFunc['db_query']('', ' |
|
| 226 | 229 | DELETE FROM {db_prefix}calendar_holidays |
| 227 | 230 | WHERE id_holiday = {int:selected_holiday}', |
| 228 | 231 | array( |
| 229 | 232 | 'selected_holiday' => $_REQUEST['holiday'], |
| 230 | 233 | ) |
| 231 | 234 | ); |
| 232 | - else |
|
| 235 | + } else |
|
| 233 | 236 | { |
| 234 | 237 | $date = strftime($_REQUEST['year'] <= 4 ? '1001-%m-%d' : '%Y-%m-%d', mktime(0, 0, 0, $_REQUEST['month'], $_REQUEST['day'], $_REQUEST['year'])); |
| 235 | - if (isset($_REQUEST['edit'])) |
|
| 236 | - $smcFunc['db_query']('', ' |
|
| 238 | + if (isset($_REQUEST['edit'])) { |
|
| 239 | + $smcFunc['db_query']('', ' |
|
| 237 | 240 | UPDATE {db_prefix}calendar_holidays |
| 238 | 241 | SET event_date = {date:holiday_date}, title = {string:holiday_title} |
| 239 | 242 | WHERE id_holiday = {int:selected_holiday}', |
@@ -243,8 +246,8 @@ discard block |
||
| 243 | 246 | 'holiday_title' => $_REQUEST['title'], |
| 244 | 247 | ) |
| 245 | 248 | ); |
| 246 | - else |
|
| 247 | - $smcFunc['db_insert']('', |
|
| 249 | + } else { |
|
| 250 | + $smcFunc['db_insert']('', |
|
| 248 | 251 | '{db_prefix}calendar_holidays', |
| 249 | 252 | array( |
| 250 | 253 | 'event_date' => 'date', 'title' => 'string-60', |
@@ -254,6 +257,7 @@ discard block |
||
| 254 | 257 | ), |
| 255 | 258 | array('id_holiday') |
| 256 | 259 | ); |
| 260 | + } |
|
| 257 | 261 | } |
| 258 | 262 | |
| 259 | 263 | updateSettings(array( |
@@ -265,14 +269,15 @@ discard block |
||
| 265 | 269 | } |
| 266 | 270 | |
| 267 | 271 | // Default states... |
| 268 | - if ($context['is_new']) |
|
| 269 | - $context['holiday'] = array( |
|
| 272 | + if ($context['is_new']) { |
|
| 273 | + $context['holiday'] = array( |
|
| 270 | 274 | 'id' => 0, |
| 271 | 275 | 'day' => date('d'), |
| 272 | 276 | 'month' => date('m'), |
| 273 | 277 | 'year' => '0000', |
| 274 | 278 | 'title' => '' |
| 275 | 279 | ); |
| 280 | + } |
|
| 276 | 281 | // If it's not new load the data. |
| 277 | 282 | else |
| 278 | 283 | { |
@@ -285,14 +290,15 @@ discard block |
||
| 285 | 290 | 'selected_holiday' => $_REQUEST['holiday'], |
| 286 | 291 | ) |
| 287 | 292 | ); |
| 288 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 289 | - $context['holiday'] = array( |
|
| 293 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 294 | + $context['holiday'] = array( |
|
| 290 | 295 | 'id' => $row['id_holiday'], |
| 291 | 296 | 'day' => $row['day'], |
| 292 | 297 | 'month' => $row['month'], |
| 293 | 298 | 'year' => $row['year'] <= 4 ? 0 : $row['year'], |
| 294 | 299 | 'title' => $row['title'] |
| 295 | 300 | ); |
| 301 | + } |
|
| 296 | 302 | $smcFunc['db_free_result']($request); |
| 297 | 303 | } |
| 298 | 304 | |
@@ -319,16 +325,17 @@ discard block |
||
| 319 | 325 | array( |
| 320 | 326 | ) |
| 321 | 327 | ); |
| 322 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 323 | - $boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 328 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 329 | + $boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 330 | + } |
|
| 324 | 331 | $smcFunc['db_free_result']($request); |
| 325 | 332 | |
| 326 | 333 | require_once($sourcedir . '/Subs-Boards.php'); |
| 327 | 334 | sortBoards($boards); |
| 328 | 335 | |
| 329 | 336 | // Look, all the calendar settings - of which there are many! |
| 330 | - if (!empty($modSettings['cal_enabled'])) |
|
| 331 | - $config_vars = array( |
|
| 337 | + if (!empty($modSettings['cal_enabled'])) { |
|
| 338 | + $config_vars = array( |
|
| 332 | 339 | array('check', 'cal_enabled'), |
| 333 | 340 | '', |
| 334 | 341 | // All the permissions: |
@@ -371,14 +378,16 @@ discard block |
||
| 371 | 378 | array('check', 'cal_short_days'), |
| 372 | 379 | array('check', 'cal_short_months'), |
| 373 | 380 | ); |
| 374 | - else |
|
| 375 | - $config_vars = array( |
|
| 381 | + } else { |
|
| 382 | + $config_vars = array( |
|
| 376 | 383 | array('check', 'cal_enabled'), |
| 377 | 384 | ); |
| 385 | + } |
|
| 378 | 386 | |
| 379 | 387 | call_integration_hook('integrate_modify_calendar_settings', array(&$config_vars)); |
| 380 | - if ($return_config) |
|
| 381 | - return $config_vars; |
|
| 388 | + if ($return_config) { |
|
| 389 | + return $config_vars; |
|
| 390 | + } |
|
| 382 | 391 | |
| 383 | 392 | // Get the settings template fired up. |
| 384 | 393 | require_once($sourcedir . '/ManageServer.php'); |