@@ -2183,7 +2183,7 @@ discard block |
||
| 2183 | 2183 | * Deletes a single or a group of alerts by ID |
| 2184 | 2184 | * |
| 2185 | 2185 | * @param int|array The ID of a single alert to delete or an array containing the IDs of multiple alerts. The function will convert integers into an array for better handling. |
| 2186 | - * @param bool|int $memID The user ID. Used to update the user unread alerts count. |
|
| 2186 | + * @param integer $memID The user ID. Used to update the user unread alerts count. |
|
| 2187 | 2187 | * @return void|int If the $memID param is set, returns the new amount of unread alerts. |
| 2188 | 2188 | */ |
| 2189 | 2189 | function alert_delete($toDelete, $memID = false) |
@@ -2839,7 +2839,7 @@ discard block |
||
| 2839 | 2839 | /** |
| 2840 | 2840 | * Handles the "manage groups" section of the profile |
| 2841 | 2841 | * |
| 2842 | - * @return true Always returns true |
|
| 2842 | + * @return boolean Always returns true |
|
| 2843 | 2843 | */ |
| 2844 | 2844 | function profileLoadGroups() |
| 2845 | 2845 | { |
@@ -2896,7 +2896,7 @@ discard block |
||
| 2896 | 2896 | /** |
| 2897 | 2897 | * Load key signature context data. |
| 2898 | 2898 | * |
| 2899 | - * @return true Always returns true |
|
| 2899 | + * @return boolean Always returns true |
|
| 2900 | 2900 | */ |
| 2901 | 2901 | function profileLoadSignatureData() |
| 2902 | 2902 | { |
@@ -2960,7 +2960,7 @@ discard block |
||
| 2960 | 2960 | /** |
| 2961 | 2961 | * Load avatar context data. |
| 2962 | 2962 | * |
| 2963 | - * @return true Always returns true |
|
| 2963 | + * @return boolean Always returns true |
|
| 2964 | 2964 | */ |
| 2965 | 2965 | function profileLoadAvatarData() |
| 2966 | 2966 | { |
@@ -3033,7 +3033,7 @@ discard block |
||
| 3033 | 3033 | * Save a members group. |
| 3034 | 3034 | * |
| 3035 | 3035 | * @param int &$value The ID of the (new) primary group |
| 3036 | - * @return true Always returns true |
|
| 3036 | + * @return boolean Always returns true |
|
| 3037 | 3037 | */ |
| 3038 | 3038 | function profileSaveGroups(&$value) |
| 3039 | 3039 | { |
@@ -3138,7 +3138,7 @@ discard block |
||
| 3138 | 3138 | * @todo argh, the avatar here. Take this out of here! |
| 3139 | 3139 | * |
| 3140 | 3140 | * @param string &$value What kind of avatar we're expecting. Can be 'none', 'server_stored', 'gravatar', 'external' or 'upload' |
| 3141 | - * @return bool|string False if success (or if memID is empty and password authentication failed), otherwise a string indicating what error occurred |
|
| 3141 | + * @return false|string False if success (or if memID is empty and password authentication failed), otherwise a string indicating what error occurred |
|
| 3142 | 3142 | */ |
| 3143 | 3143 | function profileSaveAvatarData(&$value) |
| 3144 | 3144 | { |
@@ -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 = '1004-01-01'; |
|
| 108 | - else |
|
| 109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
| 108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
| 109 | + $value = '1004-01-01'; |
|
| 110 | + } else { |
|
| 111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + $value = '1004-01-01'; |
|
| 110 | 115 | } |
| 111 | - else |
|
| 112 | - $value = '1004-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]) : '1004-01-01'; |
| 129 | 132 | return true; |
| 130 | - } |
|
| 131 | - else |
|
| 133 | + } else |
|
| 132 | 134 | { |
| 133 | 135 | $value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate']; |
| 134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
| 150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
| 151 | 153 | } |
| 152 | 154 | // As long as it doesn't equal "N/A"... |
| 153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
| 154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 155 | - else |
|
| 156 | - $value = $cur_profile['date_registered']; |
|
| 155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
| 156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 157 | + } else { |
|
| 158 | + $value = $cur_profile['date_registered']; |
|
| 159 | + } |
|
| 157 | 160 | |
| 158 | 161 | return true; |
| 159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
| 177 | 180 | { |
| 178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
| 179 | 182 | |
| 180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
| 181 | - return false; |
|
| 183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 182 | 186 | |
| 183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
| 184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
| 254 | 258 | |
| 255 | 259 | if (isset($context['profile_languages'][$value])) |
| 256 | 260 | { |
| 257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
| 258 | - $_SESSION['language'] = $value; |
|
| 261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
| 262 | + $_SESSION['language'] = $value; |
|
| 263 | + } |
|
| 259 | 264 | return true; |
| 260 | - } |
|
| 261 | - else |
|
| 265 | + } else |
|
| 262 | 266 | { |
| 263 | 267 | $value = $cur_profile['lngfile']; |
| 264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
| 282 | 286 | |
| 283 | 287 | // Maybe they are trying to change their password as well? |
| 284 | 288 | $resetPassword = true; |
| 285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
| 286 | - $resetPassword = false; |
|
| 289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
| 290 | + $resetPassword = false; |
|
| 291 | + } |
|
| 287 | 292 | |
| 288 | 293 | // Do the reset... this will send them an email too. |
| 289 | - if ($resetPassword) |
|
| 290 | - resetPassword($context['id_member'], $value); |
|
| 291 | - elseif ($value !== null) |
|
| 294 | + if ($resetPassword) { |
|
| 295 | + resetPassword($context['id_member'], $value); |
|
| 296 | + } elseif ($value !== null) |
|
| 292 | 297 | { |
| 293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
| 294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
| 312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
| 313 | 318 | { |
| 314 | 319 | // If we didn't try it then ignore it! |
| 315 | - if ($value == '') |
|
| 316 | - return false; |
|
| 320 | + if ($value == '') { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 317 | 323 | |
| 318 | 324 | // Do the two entries for the password even match? |
| 319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
| 320 | - return 'bad_new_password'; |
|
| 325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
| 326 | + return 'bad_new_password'; |
|
| 327 | + } |
|
| 321 | 328 | |
| 322 | 329 | // Let's get the validation function into play... |
| 323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
| 324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
| 325 | 332 | |
| 326 | 333 | // Were there errors? |
| 327 | - if ($passwordErrors != null) |
|
| 328 | - return 'password_' . $passwordErrors; |
|
| 334 | + if ($passwordErrors != null) { |
|
| 335 | + return 'password_' . $passwordErrors; |
|
| 336 | + } |
|
| 329 | 337 | |
| 330 | 338 | // Set up the new password variable... ready for storage. |
| 331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
| 350 | 358 | 'permission' => 'profile_blurb', |
| 351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
| 352 | 360 | { |
| 353 | - if ($smcFunc['strlen']($value) > 50) |
|
| 354 | - return 'personal_text_too_long'; |
|
| 361 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 362 | + return 'personal_text_too_long'; |
|
| 363 | + } |
|
| 355 | 364 | |
| 356 | 365 | return true; |
| 357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
| 386 | 395 | 'permission' => 'moderate_forum', |
| 387 | 396 | 'input_validate' => function(&$value) |
| 388 | 397 | { |
| 389 | - if (!is_numeric($value)) |
|
| 390 | - return 'digits_only'; |
|
| 391 | - else |
|
| 392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 398 | + if (!is_numeric($value)) { |
|
| 399 | + return 'digits_only'; |
|
| 400 | + } else { |
|
| 401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 402 | + } |
|
| 393 | 403 | return true; |
| 394 | 404 | }, |
| 395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
| 405 | 415 | { |
| 406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
| 407 | 417 | |
| 408 | - if (trim($value) == '') |
|
| 409 | - return 'no_name'; |
|
| 410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
| 411 | - return 'name_too_long'; |
|
| 412 | - elseif ($cur_profile['real_name'] != $value) |
|
| 418 | + if (trim($value) == '') { |
|
| 419 | + return 'no_name'; |
|
| 420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
| 421 | + return 'name_too_long'; |
|
| 422 | + } elseif ($cur_profile['real_name'] != $value) |
|
| 413 | 423 | { |
| 414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
| 415 | - if (isReservedName($value, $context['id_member'])) |
|
| 416 | - return 'name_taken'; |
|
| 425 | + if (isReservedName($value, $context['id_member'])) { |
|
| 426 | + return 'name_taken'; |
|
| 427 | + } |
|
| 417 | 428 | } |
| 418 | 429 | return true; |
| 419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
| 471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
| 472 | 483 | ); |
| 473 | 484 | |
| 474 | - if ($context['smiley_sets'][$i]['selected']) |
|
| 475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
| 486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 487 | + } |
|
| 476 | 488 | } |
| 477 | 489 | return true; |
| 478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
| 481 | 493 | global $modSettings; |
| 482 | 494 | |
| 483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
| 484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
| 485 | - $value = ''; |
|
| 496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
| 497 | + $value = ''; |
|
| 498 | + } |
|
| 486 | 499 | return true; |
| 487 | 500 | }, |
| 488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
| 497 | 510 | loadLanguage('Settings'); |
| 498 | 511 | |
| 499 | 512 | $context['allow_no_censored'] = false; |
| 500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
| 501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
| 514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 515 | + } |
|
| 502 | 516 | |
| 503 | 517 | return true; |
| 504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
| 545 | 559 | 'input_validate' => function($value) |
| 546 | 560 | { |
| 547 | 561 | $tz = smf_list_timezones(); |
| 548 | - if (!isset($tz[$value])) |
|
| 549 | - return 'bad_timezone'; |
|
| 562 | + if (!isset($tz[$value])) { |
|
| 563 | + return 'bad_timezone'; |
|
| 564 | + } |
|
| 550 | 565 | |
| 551 | 566 | return true; |
| 552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
| 561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
| 562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
| 563 | 578 | { |
| 564 | - if ($smcFunc['strlen']($value) > 50) |
|
| 565 | - return 'user_title_too_long'; |
|
| 579 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 580 | + return 'user_title_too_long'; |
|
| 581 | + } |
|
| 566 | 582 | |
| 567 | 583 | return true; |
| 568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
| 584 | 600 | // Fix the URL... |
| 585 | 601 | 'input_validate' => function(&$value) |
| 586 | 602 | { |
| 587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
| 588 | - $value = 'http://' . $value; |
|
| 589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
| 590 | - $value = ''; |
|
| 603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
| 604 | + $value = 'http://' . $value; |
|
| 605 | + } |
|
| 606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
| 607 | + $value = ''; |
|
| 608 | + } |
|
| 591 | 609 | return true; |
| 592 | 610 | }, |
| 593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
| 601 | 619 | foreach ($profile_fields as $key => $field) |
| 602 | 620 | { |
| 603 | 621 | // Do we have permission to do this? |
| 604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
| 605 | - unset($profile_fields[$key]); |
|
| 622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
| 623 | + unset($profile_fields[$key]); |
|
| 624 | + } |
|
| 606 | 625 | |
| 607 | 626 | // Is it enabled? |
| 608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
| 609 | - unset($profile_fields[$key]); |
|
| 627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
| 628 | + unset($profile_fields[$key]); |
|
| 629 | + } |
|
| 610 | 630 | |
| 611 | 631 | // Is it specifically disabled? |
| 612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
| 613 | - unset($profile_fields[$key]); |
|
| 632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
| 633 | + unset($profile_fields[$key]); |
|
| 634 | + } |
|
| 614 | 635 | } |
| 615 | 636 | } |
| 616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
| 635 | 656 | loadProfileFields(true); |
| 636 | 657 | |
| 637 | 658 | // First check for any linked sets. |
| 638 | - foreach ($profile_fields as $key => $field) |
|
| 639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 659 | + foreach ($profile_fields as $key => $field) { |
|
| 660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 640 | 661 | $fields[] = $key; |
| 662 | + } |
|
| 641 | 663 | |
| 642 | 664 | $i = 0; |
| 643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
| 649 | 671 | $cur_field = &$profile_fields[$field]; |
| 650 | 672 | |
| 651 | 673 | // Does it have a preload and does that preload succeed? |
| 652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
| 653 | - continue; |
|
| 674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 654 | 677 | |
| 655 | 678 | // If this is anything but complex we need to do more cleaning! |
| 656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
| 657 | 680 | { |
| 658 | - if (!isset($cur_field['label'])) |
|
| 659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 681 | + if (!isset($cur_field['label'])) { |
|
| 682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 683 | + } |
|
| 660 | 684 | |
| 661 | 685 | // Everything has a value! |
| 662 | - if (!isset($cur_field['value'])) |
|
| 663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 686 | + if (!isset($cur_field['value'])) { |
|
| 687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 688 | + } |
|
| 664 | 689 | |
| 665 | 690 | // Any input attributes? |
| 666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
| 667 | 692 | } |
| 668 | 693 | |
| 669 | 694 | // Was there an error with this field on posting? |
| 670 | - if (isset($context['profile_errors'][$field])) |
|
| 671 | - $cur_field['is_error'] = true; |
|
| 695 | + if (isset($context['profile_errors'][$field])) { |
|
| 696 | + $cur_field['is_error'] = true; |
|
| 697 | + } |
|
| 672 | 698 | |
| 673 | 699 | // Any javascript stuff? |
| 674 | - if (!empty($cur_field['js_submit'])) |
|
| 675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 676 | - if (!empty($cur_field['js'])) |
|
| 677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
| 700 | + if (!empty($cur_field['js_submit'])) { |
|
| 701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 702 | + } |
|
| 703 | + if (!empty($cur_field['js'])) { |
|
| 704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
| 705 | + } |
|
| 678 | 706 | |
| 679 | 707 | // Any template stuff? |
| 680 | - if (!empty($cur_field['prehtml'])) |
|
| 681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 682 | - if (!empty($cur_field['posthtml'])) |
|
| 683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 708 | + if (!empty($cur_field['prehtml'])) { |
|
| 709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 710 | + } |
|
| 711 | + if (!empty($cur_field['posthtml'])) { |
|
| 712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 713 | + } |
|
| 684 | 714 | |
| 685 | 715 | // Finally put it into context? |
| 686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
| 713 | 743 | }, false);' : ''), true); |
| 714 | 744 | |
| 715 | 745 | // Any onsubmit javascript? |
| 716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
| 717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
| 747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 748 | + } |
|
| 718 | 749 | |
| 719 | 750 | // Any totally custom stuff? |
| 720 | - if (!empty($context['profile_javascript'])) |
|
| 721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
| 751 | + if (!empty($context['profile_javascript'])) { |
|
| 752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
| 753 | + } |
|
| 722 | 754 | |
| 723 | 755 | // Free up some memory. |
| 724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
| 739 | 771 | |
| 740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
| 741 | 773 | $context['profile_execute_on_save'] = array(); |
| 742 | - if ($context['user']['is_owner']) |
|
| 743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 774 | + if ($context['user']['is_owner']) { |
|
| 775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 776 | + } |
|
| 744 | 777 | |
| 745 | 778 | // Assume we log nothing. |
| 746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
| 748 | 781 | // Cycle through the profile fields working out what to do! |
| 749 | 782 | foreach ($profile_fields as $key => $field) |
| 750 | 783 | { |
| 751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
| 752 | - continue; |
|
| 784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
| 785 | + continue; |
|
| 786 | + } |
|
| 753 | 787 | |
| 754 | 788 | // What gets updated? |
| 755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
| 777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
| 778 | 812 | |
| 779 | 813 | // Finally, clean up certain types. |
| 780 | - if ($field['cast_type'] == 'int') |
|
| 781 | - $_POST[$key] = (int) $_POST[$key]; |
|
| 782 | - elseif ($field['cast_type'] == 'float') |
|
| 783 | - $_POST[$key] = (float) $_POST[$key]; |
|
| 784 | - elseif ($field['cast_type'] == 'check') |
|
| 785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 814 | + if ($field['cast_type'] == 'int') { |
|
| 815 | + $_POST[$key] = (int) $_POST[$key]; |
|
| 816 | + } elseif ($field['cast_type'] == 'float') { |
|
| 817 | + $_POST[$key] = (float) $_POST[$key]; |
|
| 818 | + } elseif ($field['cast_type'] == 'check') { |
|
| 819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 820 | + } |
|
| 786 | 821 | |
| 787 | 822 | // If we got here we're doing OK. |
| 788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
| 793 | 828 | $cur_profile[$key] = $_POST[$key]; |
| 794 | 829 | |
| 795 | 830 | // Are we logging it? |
| 796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
| 797 | - $context['log_changes'][$key] = array( |
|
| 831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
| 832 | + $context['log_changes'][$key] = array( |
|
| 798 | 833 | 'previous' => $old_profile[$key], |
| 799 | 834 | 'new' => $_POST[$key], |
| 800 | 835 | ); |
| 836 | + } |
|
| 801 | 837 | } |
| 802 | 838 | |
| 803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
| 830 | 866 | { |
| 831 | 867 | foreach ($groups as $id => $group) |
| 832 | 868 | { |
| 833 | - if (isset($context['member_groups'][$group])) |
|
| 834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 835 | - else |
|
| 836 | - unset($additional_groups[$type][$id]); |
|
| 869 | + if (isset($context['member_groups'][$group])) { |
|
| 870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 871 | + } else { |
|
| 872 | + unset($additional_groups[$type][$id]); |
|
| 873 | + } |
|
| 837 | 874 | } |
| 838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
| 839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
| 844 | 881 | } |
| 845 | 882 | |
| 846 | 883 | // @todo Temporary |
| 847 | - if ($context['user']['is_owner']) |
|
| 848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 849 | - else |
|
| 850 | - $changeOther = allowedTo('profile_extra_any'); |
|
| 884 | + if ($context['user']['is_owner']) { |
|
| 885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 886 | + } else { |
|
| 887 | + $changeOther = allowedTo('profile_extra_any'); |
|
| 888 | + } |
|
| 851 | 889 | if ($changeOther && empty($post_errors)) |
| 852 | 890 | { |
| 853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
| 855 | 893 | { |
| 856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
| 857 | 895 | |
| 858 | - if (!empty($custom_fields_errors)) |
|
| 859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 896 | + if (!empty($custom_fields_errors)) { |
|
| 897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 898 | + } |
|
| 860 | 899 | } |
| 861 | 900 | } |
| 862 | 901 | |
@@ -882,9 +921,9 @@ discard block |
||
| 882 | 921 | if ($context['user']['is_owner']) |
| 883 | 922 | { |
| 884 | 923 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
| 924 | + } else { |
|
| 925 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 885 | 926 | } |
| 886 | - else |
|
| 887 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 888 | 927 | |
| 889 | 928 | // Arrays of all the changes - makes things easier. |
| 890 | 929 | $profile_bools = array(); |
@@ -895,22 +934,25 @@ discard block |
||
| 895 | 934 | 'ignore_boards', |
| 896 | 935 | ); |
| 897 | 936 | |
| 898 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
| 899 | - $_POST['ignore_brd'] = array(); |
|
| 937 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
| 938 | + $_POST['ignore_brd'] = array(); |
|
| 939 | + } |
|
| 900 | 940 | |
| 901 | 941 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
| 902 | 942 | if (isset($_POST['ignore_brd'])) |
| 903 | 943 | { |
| 904 | - if (!is_array($_POST['ignore_brd'])) |
|
| 905 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 944 | + if (!is_array($_POST['ignore_brd'])) { |
|
| 945 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 946 | + } |
|
| 906 | 947 | |
| 907 | 948 | foreach ($_POST['ignore_brd'] as $k => $d) |
| 908 | 949 | { |
| 909 | 950 | $d = (int) $d; |
| 910 | - if ($d != 0) |
|
| 911 | - $_POST['ignore_brd'][$k] = $d; |
|
| 912 | - else |
|
| 913 | - unset($_POST['ignore_brd'][$k]); |
|
| 951 | + if ($d != 0) { |
|
| 952 | + $_POST['ignore_brd'][$k] = $d; |
|
| 953 | + } else { |
|
| 954 | + unset($_POST['ignore_brd'][$k]); |
|
| 955 | + } |
|
| 914 | 956 | } |
| 915 | 957 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
| 916 | 958 | unset($_POST['ignore_brd']); |
@@ -923,21 +965,26 @@ discard block |
||
| 923 | 965 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
| 924 | 966 | //makeAvatarChanges($memID, $post_errors); |
| 925 | 967 | |
| 926 | - if (!empty($_REQUEST['sa'])) |
|
| 927 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 968 | + if (!empty($_REQUEST['sa'])) { |
|
| 969 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 970 | + } |
|
| 928 | 971 | |
| 929 | - foreach ($profile_bools as $var) |
|
| 930 | - if (isset($_POST[$var])) |
|
| 972 | + foreach ($profile_bools as $var) { |
|
| 973 | + if (isset($_POST[$var])) |
|
| 931 | 974 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
| 932 | - foreach ($profile_ints as $var) |
|
| 933 | - if (isset($_POST[$var])) |
|
| 975 | + } |
|
| 976 | + foreach ($profile_ints as $var) { |
|
| 977 | + if (isset($_POST[$var])) |
|
| 934 | 978 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
| 935 | - foreach ($profile_floats as $var) |
|
| 936 | - if (isset($_POST[$var])) |
|
| 979 | + } |
|
| 980 | + foreach ($profile_floats as $var) { |
|
| 981 | + if (isset($_POST[$var])) |
|
| 937 | 982 | $profile_vars[$var] = (float) $_POST[$var]; |
| 938 | - foreach ($profile_strings as $var) |
|
| 939 | - if (isset($_POST[$var])) |
|
| 983 | + } |
|
| 984 | + foreach ($profile_strings as $var) { |
|
| 985 | + if (isset($_POST[$var])) |
|
| 940 | 986 | $profile_vars[$var] = $_POST[$var]; |
| 987 | + } |
|
| 941 | 988 | } |
| 942 | 989 | } |
| 943 | 990 | |
@@ -971,8 +1018,9 @@ discard block |
||
| 971 | 1018 | ); |
| 972 | 1019 | |
| 973 | 1020 | // Can't change reserved vars. |
| 974 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
| 975 | - fatal_lang_error('no_access', false); |
|
| 1021 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
| 1022 | + fatal_lang_error('no_access', false); |
|
| 1023 | + } |
|
| 976 | 1024 | |
| 977 | 1025 | // Don't allow any overriding of custom fields with default or non-default options. |
| 978 | 1026 | $request = $smcFunc['db_query']('', ' |
@@ -984,8 +1032,9 @@ discard block |
||
| 984 | 1032 | ) |
| 985 | 1033 | ); |
| 986 | 1034 | $custom_fields = array(); |
| 987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 988 | - $custom_fields[] = $row['col_name']; |
|
| 1035 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1036 | + $custom_fields[] = $row['col_name']; |
|
| 1037 | + } |
|
| 989 | 1038 | $smcFunc['db_free_result']($request); |
| 990 | 1039 | |
| 991 | 1040 | // These are the theme changes... |
@@ -994,33 +1043,39 @@ discard block |
||
| 994 | 1043 | { |
| 995 | 1044 | foreach ($_POST['options'] as $opt => $val) |
| 996 | 1045 | { |
| 997 | - if (in_array($opt, $custom_fields)) |
|
| 998 | - continue; |
|
| 1046 | + if (in_array($opt, $custom_fields)) { |
|
| 1047 | + continue; |
|
| 1048 | + } |
|
| 999 | 1049 | |
| 1000 | 1050 | // These need to be controlled. |
| 1001 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1002 | - $val = max(0, min($val, 50)); |
|
| 1051 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1052 | + $val = max(0, min($val, 50)); |
|
| 1053 | + } |
|
| 1003 | 1054 | // We don't set this per theme anymore. |
| 1004 | - elseif ($opt == 'allow_no_censored') |
|
| 1005 | - continue; |
|
| 1055 | + elseif ($opt == 'allow_no_censored') { |
|
| 1056 | + continue; |
|
| 1057 | + } |
|
| 1006 | 1058 | |
| 1007 | 1059 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1008 | 1060 | } |
| 1009 | 1061 | } |
| 1010 | 1062 | |
| 1011 | 1063 | $erase_options = array(); |
| 1012 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
| 1013 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 1064 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
| 1065 | + foreach ($_POST['default_options'] as $opt => $val) |
|
| 1014 | 1066 | { |
| 1015 | 1067 | if (in_array($opt, $custom_fields)) |
| 1016 | 1068 | continue; |
| 1069 | + } |
|
| 1017 | 1070 | |
| 1018 | 1071 | // These need to be controlled. |
| 1019 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1020 | - $val = max(0, min($val, 50)); |
|
| 1072 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1073 | + $val = max(0, min($val, 50)); |
|
| 1074 | + } |
|
| 1021 | 1075 | // Only let admins and owners change the censor. |
| 1022 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
| 1023 | - continue; |
|
| 1076 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
| 1077 | + continue; |
|
| 1078 | + } |
|
| 1024 | 1079 | |
| 1025 | 1080 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1026 | 1081 | $erase_options[] = $opt; |
@@ -1056,8 +1111,9 @@ discard block |
||
| 1056 | 1111 | |
| 1057 | 1112 | // Admins can choose any theme, even if it's not enabled... |
| 1058 | 1113 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
| 1059 | - foreach ($themes as $t) |
|
| 1060 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1114 | + foreach ($themes as $t) { |
|
| 1115 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1116 | + } |
|
| 1061 | 1117 | } |
| 1062 | 1118 | } |
| 1063 | 1119 | |
@@ -1076,8 +1132,9 @@ discard block |
||
| 1076 | 1132 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
| 1077 | 1133 | { |
| 1078 | 1134 | // Make sure only integers are deleted. |
| 1079 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
| 1080 | - $_POST['notify_boards'][$index] = (int) $id; |
|
| 1135 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
| 1136 | + $_POST['notify_boards'][$index] = (int) $id; |
|
| 1137 | + } |
|
| 1081 | 1138 | |
| 1082 | 1139 | // id_board = 0 is reserved for topic notifications. |
| 1083 | 1140 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1096,8 +1153,9 @@ discard block |
||
| 1096 | 1153 | // We are editing topic notifications...... |
| 1097 | 1154 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1098 | 1155 | { |
| 1099 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
| 1100 | - $_POST['notify_topics'][$index] = (int) $id; |
|
| 1156 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
| 1157 | + $_POST['notify_topics'][$index] = (int) $id; |
|
| 1158 | + } |
|
| 1101 | 1159 | |
| 1102 | 1160 | // Make sure there are no zeros left. |
| 1103 | 1161 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1111,16 +1169,18 @@ discard block |
||
| 1111 | 1169 | 'selected_member' => $memID, |
| 1112 | 1170 | ) |
| 1113 | 1171 | ); |
| 1114 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1115 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1172 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1173 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1174 | + } |
|
| 1116 | 1175 | } |
| 1117 | 1176 | |
| 1118 | 1177 | // We are removing topic preferences |
| 1119 | 1178 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1120 | 1179 | { |
| 1121 | 1180 | $prefs = array(); |
| 1122 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1123 | - $prefs[] = 'topic_notify_' . $topic; |
|
| 1181 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1182 | + $prefs[] = 'topic_notify_' . $topic; |
|
| 1183 | + } |
|
| 1124 | 1184 | deleteNotifyPrefs($memID, $prefs); |
| 1125 | 1185 | } |
| 1126 | 1186 | |
@@ -1128,8 +1188,9 @@ discard block |
||
| 1128 | 1188 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
| 1129 | 1189 | { |
| 1130 | 1190 | $prefs = array(); |
| 1131 | - foreach ($_POST['notify_boards'] as $board) |
|
| 1132 | - $prefs[] = 'board_notify_' . $board; |
|
| 1191 | + foreach ($_POST['notify_boards'] as $board) { |
|
| 1192 | + $prefs[] = 'board_notify_' . $board; |
|
| 1193 | + } |
|
| 1133 | 1194 | deleteNotifyPrefs($memID, $prefs); |
| 1134 | 1195 | } |
| 1135 | 1196 | } |
@@ -1150,8 +1211,9 @@ discard block |
||
| 1150 | 1211 | |
| 1151 | 1212 | $errors = array(); |
| 1152 | 1213 | |
| 1153 | - if ($sanitize && isset($_POST['customfield'])) |
|
| 1154 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1214 | + if ($sanitize && isset($_POST['customfield'])) { |
|
| 1215 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1216 | + } |
|
| 1155 | 1217 | |
| 1156 | 1218 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
| 1157 | 1219 | |
@@ -1176,26 +1238,29 @@ discard block |
||
| 1176 | 1238 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
| 1177 | 1239 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
| 1178 | 1240 | */ |
| 1179 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
| 1180 | - continue; |
|
| 1241 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
| 1242 | + continue; |
|
| 1243 | + } |
|
| 1181 | 1244 | |
| 1182 | 1245 | // Validate the user data. |
| 1183 | - if ($row['field_type'] == 'check') |
|
| 1184 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1185 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1246 | + if ($row['field_type'] == 'check') { |
|
| 1247 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1248 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1186 | 1249 | { |
| 1187 | 1250 | $value = $row['default_value']; |
| 1188 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1189 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1251 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
| 1252 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1190 | 1253 | $value = $v; |
| 1254 | + } |
|
| 1191 | 1255 | } |
| 1192 | 1256 | // Otherwise some form of text! |
| 1193 | 1257 | else |
| 1194 | 1258 | { |
| 1195 | 1259 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
| 1196 | 1260 | |
| 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') |
@@ -1204,36 +1269,34 @@ discard block |
||
| 1204 | 1269 | $valueReference = un_htmlspecialchars($value); |
| 1205 | 1270 | |
| 1206 | 1271 | // Try and avoid some checks. '0' could be a valid non-empty value. |
| 1207 | - if (empty($value) && !is_numeric($value)) |
|
| 1208 | - $value = ''; |
|
| 1272 | + if (empty($value) && !is_numeric($value)) { |
|
| 1273 | + $value = ''; |
|
| 1274 | + } |
|
| 1209 | 1275 | |
| 1210 | 1276 | if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference))) |
| 1211 | 1277 | { |
| 1212 | - if ($returnErrors) |
|
| 1213 | - $errors[] = 'custom_field_nohtml_fail'; |
|
| 1214 | - |
|
| 1215 | - else |
|
| 1216 | - $value = ''; |
|
| 1217 | - } |
|
| 1218 | - elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
| 1278 | + if ($returnErrors) { |
|
| 1279 | + $errors[] = 'custom_field_nohtml_fail'; |
|
| 1280 | + } else { |
|
| 1281 | + $value = ''; |
|
| 1282 | + } |
|
| 1283 | + } elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
| 1219 | 1284 | { |
| 1220 | - if ($returnErrors) |
|
| 1221 | - $errors[] = 'custom_field_mail_fail'; |
|
| 1222 | - |
|
| 1223 | - else |
|
| 1224 | - $value = ''; |
|
| 1225 | - } |
|
| 1226 | - elseif ($row['mask'] == 'number') |
|
| 1285 | + if ($returnErrors) { |
|
| 1286 | + $errors[] = 'custom_field_mail_fail'; |
|
| 1287 | + } else { |
|
| 1288 | + $value = ''; |
|
| 1289 | + } |
|
| 1290 | + } elseif ($row['mask'] == 'number') |
|
| 1227 | 1291 | { |
| 1228 | 1292 | $value = (int) $value; |
| 1229 | - } |
|
| 1230 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1293 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1231 | 1294 | { |
| 1232 | - if ($returnErrors) |
|
| 1233 | - $errors[] = 'custom_field_regex_fail'; |
|
| 1234 | - |
|
| 1235 | - else |
|
| 1236 | - $value = ''; |
|
| 1295 | + if ($returnErrors) { |
|
| 1296 | + $errors[] = 'custom_field_regex_fail'; |
|
| 1297 | + } else { |
|
| 1298 | + $value = ''; |
|
| 1299 | + } |
|
| 1237 | 1300 | } |
| 1238 | 1301 | |
| 1239 | 1302 | unset($valueReference); |
@@ -1261,8 +1324,9 @@ discard block |
||
| 1261 | 1324 | |
| 1262 | 1325 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
| 1263 | 1326 | |
| 1264 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
| 1265 | - $errors = array_merge($errors, $hook_errors); |
|
| 1327 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
| 1328 | + $errors = array_merge($errors, $hook_errors); |
|
| 1329 | + } |
|
| 1266 | 1330 | |
| 1267 | 1331 | // Make those changes! |
| 1268 | 1332 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1280,9 +1344,10 @@ discard block |
||
| 1280 | 1344 | } |
| 1281 | 1345 | } |
| 1282 | 1346 | |
| 1283 | - if ($returnErrors) |
|
| 1284 | - return $errors; |
|
| 1285 | -} |
|
| 1347 | + if ($returnErrors) { |
|
| 1348 | + return $errors; |
|
| 1349 | + } |
|
| 1350 | + } |
|
| 1286 | 1351 | |
| 1287 | 1352 | /** |
| 1288 | 1353 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1294,8 +1359,9 @@ discard block |
||
| 1294 | 1359 | global $context, $txt, $modSettings; |
| 1295 | 1360 | |
| 1296 | 1361 | // Do a quick check to ensure people aren't getting here illegally! |
| 1297 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
| 1298 | - fatal_lang_error('no_access', false); |
|
| 1362 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
| 1363 | + fatal_lang_error('no_access', false); |
|
| 1364 | + } |
|
| 1299 | 1365 | |
| 1300 | 1366 | // Can we email the user direct? |
| 1301 | 1367 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1325,9 +1391,10 @@ discard block |
||
| 1325 | 1391 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
| 1326 | 1392 | $call = call_helper($subActions[$context['list_area']][0], true); |
| 1327 | 1393 | |
| 1328 | - if (!empty($call)) |
|
| 1329 | - call_user_func($call, $memID); |
|
| 1330 | -} |
|
| 1394 | + if (!empty($call)) { |
|
| 1395 | + call_user_func($call, $memID); |
|
| 1396 | + } |
|
| 1397 | + } |
|
| 1331 | 1398 | |
| 1332 | 1399 | /** |
| 1333 | 1400 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1341,9 +1408,10 @@ discard block |
||
| 1341 | 1408 | |
| 1342 | 1409 | // For making changes! |
| 1343 | 1410 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
| 1344 | - foreach ($buddiesArray as $k => $dummy) |
|
| 1345 | - if ($dummy == '') |
|
| 1411 | + foreach ($buddiesArray as $k => $dummy) { |
|
| 1412 | + if ($dummy == '') |
|
| 1346 | 1413 | unset($buddiesArray[$k]); |
| 1414 | + } |
|
| 1347 | 1415 | |
| 1348 | 1416 | // Removing a buddy? |
| 1349 | 1417 | if (isset($_GET['remove'])) |
@@ -1355,10 +1423,11 @@ discard block |
||
| 1355 | 1423 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1356 | 1424 | |
| 1357 | 1425 | // Heh, I'm lazy, do it the easy way... |
| 1358 | - foreach ($buddiesArray as $key => $buddy) |
|
| 1359 | - if ($buddy == (int) $_GET['remove']) |
|
| 1426 | + foreach ($buddiesArray as $key => $buddy) { |
|
| 1427 | + if ($buddy == (int) $_GET['remove']) |
|
| 1360 | 1428 | { |
| 1361 | 1429 | unset($buddiesArray[$key]); |
| 1430 | + } |
|
| 1362 | 1431 | $_SESSION['prf-save'] = true; |
| 1363 | 1432 | } |
| 1364 | 1433 | |
@@ -1368,8 +1437,7 @@ discard block |
||
| 1368 | 1437 | |
| 1369 | 1438 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1370 | 1439 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
| 1371 | - } |
|
| 1372 | - elseif (isset($_POST['new_buddy'])) |
|
| 1440 | + } elseif (isset($_POST['new_buddy'])) |
|
| 1373 | 1441 | { |
| 1374 | 1442 | checkSession(); |
| 1375 | 1443 | |
@@ -1382,8 +1450,9 @@ discard block |
||
| 1382 | 1450 | { |
| 1383 | 1451 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
| 1384 | 1452 | |
| 1385 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1386 | - unset($new_buddies[$k]); |
|
| 1453 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1454 | + unset($new_buddies[$k]); |
|
| 1455 | + } |
|
| 1387 | 1456 | } |
| 1388 | 1457 | |
| 1389 | 1458 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1403,16 +1472,18 @@ discard block |
||
| 1403 | 1472 | ) |
| 1404 | 1473 | ); |
| 1405 | 1474 | |
| 1406 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1407 | - $_SESSION['prf-save'] = true; |
|
| 1475 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1476 | + $_SESSION['prf-save'] = true; |
|
| 1477 | + } |
|
| 1408 | 1478 | |
| 1409 | 1479 | // Add the new member to the buddies array. |
| 1410 | 1480 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1411 | 1481 | { |
| 1412 | - if (in_array($row['id_member'], $buddiesArray)) |
|
| 1413 | - continue; |
|
| 1414 | - else |
|
| 1415 | - $buddiesArray[] = (int) $row['id_member']; |
|
| 1482 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
| 1483 | + continue; |
|
| 1484 | + } else { |
|
| 1485 | + $buddiesArray[] = (int) $row['id_member']; |
|
| 1486 | + } |
|
| 1416 | 1487 | } |
| 1417 | 1488 | $smcFunc['db_free_result']($request); |
| 1418 | 1489 | |
@@ -1442,18 +1513,20 @@ discard block |
||
| 1442 | 1513 | |
| 1443 | 1514 | $context['custom_pf'] = array(); |
| 1444 | 1515 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
| 1445 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1446 | - if (!isset($disabled_fields[$row['col_name']])) |
|
| 1516 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1517 | + if (!isset($disabled_fields[$row['col_name']])) |
|
| 1447 | 1518 | $context['custom_pf'][$row['col_name']] = array( |
| 1448 | 1519 | 'label' => $row['field_name'], |
| 1449 | 1520 | 'type' => $row['field_type'], |
| 1450 | 1521 | 'bbc' => !empty($row['bbc']), |
| 1451 | 1522 | 'enclose' => $row['enclose'], |
| 1452 | 1523 | ); |
| 1524 | + } |
|
| 1453 | 1525 | |
| 1454 | 1526 | // Gotta disable the gender option. |
| 1455 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') |
|
| 1456 | - unset($context['custom_pf']['cust_gender']); |
|
| 1527 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') { |
|
| 1528 | + unset($context['custom_pf']['cust_gender']); |
|
| 1529 | + } |
|
| 1457 | 1530 | |
| 1458 | 1531 | $smcFunc['db_free_result']($request); |
| 1459 | 1532 | |
@@ -1470,8 +1543,9 @@ discard block |
||
| 1470 | 1543 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
| 1471 | 1544 | ) |
| 1472 | 1545 | ); |
| 1473 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1474 | - $buddies[] = $row['id_member']; |
|
| 1546 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1547 | + $buddies[] = $row['id_member']; |
|
| 1548 | + } |
|
| 1475 | 1549 | $smcFunc['db_free_result']($result); |
| 1476 | 1550 | } |
| 1477 | 1551 | |
@@ -1499,30 +1573,32 @@ discard block |
||
| 1499 | 1573 | continue; |
| 1500 | 1574 | } |
| 1501 | 1575 | |
| 1502 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1503 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1504 | - |
|
| 1505 | - elseif ($column['type'] == 'check') |
|
| 1506 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1576 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1577 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1578 | + } elseif ($column['type'] == 'check') { |
|
| 1579 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1580 | + } |
|
| 1507 | 1581 | |
| 1508 | 1582 | // Enclosing the user input within some other text? |
| 1509 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1510 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1583 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1584 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1511 | 1585 | '{SCRIPTURL}' => $scripturl, |
| 1512 | 1586 | '{IMAGES_URL}' => $settings['images_url'], |
| 1513 | 1587 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1514 | 1588 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
| 1515 | 1589 | )); |
| 1590 | + } |
|
| 1516 | 1591 | } |
| 1517 | 1592 | } |
| 1518 | 1593 | } |
| 1519 | 1594 | |
| 1520 | 1595 | if (isset($_SESSION['prf-save'])) |
| 1521 | 1596 | { |
| 1522 | - if ($_SESSION['prf-save'] === true) |
|
| 1523 | - $context['saved_successful'] = true; |
|
| 1524 | - else |
|
| 1525 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1597 | + if ($_SESSION['prf-save'] === true) { |
|
| 1598 | + $context['saved_successful'] = true; |
|
| 1599 | + } else { |
|
| 1600 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1601 | + } |
|
| 1526 | 1602 | |
| 1527 | 1603 | unset($_SESSION['prf-save']); |
| 1528 | 1604 | } |
@@ -1542,9 +1618,10 @@ discard block |
||
| 1542 | 1618 | |
| 1543 | 1619 | // For making changes! |
| 1544 | 1620 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
| 1545 | - foreach ($ignoreArray as $k => $dummy) |
|
| 1546 | - if ($dummy == '') |
|
| 1621 | + foreach ($ignoreArray as $k => $dummy) { |
|
| 1622 | + if ($dummy == '') |
|
| 1547 | 1623 | unset($ignoreArray[$k]); |
| 1624 | + } |
|
| 1548 | 1625 | |
| 1549 | 1626 | // Removing a member from the ignore list? |
| 1550 | 1627 | if (isset($_GET['remove'])) |
@@ -1554,10 +1631,11 @@ discard block |
||
| 1554 | 1631 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1555 | 1632 | |
| 1556 | 1633 | // Heh, I'm lazy, do it the easy way... |
| 1557 | - foreach ($ignoreArray as $key => $id_remove) |
|
| 1558 | - if ($id_remove == (int) $_GET['remove']) |
|
| 1634 | + foreach ($ignoreArray as $key => $id_remove) { |
|
| 1635 | + if ($id_remove == (int) $_GET['remove']) |
|
| 1559 | 1636 | { |
| 1560 | 1637 | unset($ignoreArray[$key]); |
| 1638 | + } |
|
| 1561 | 1639 | $_SESSION['prf-save'] = true; |
| 1562 | 1640 | } |
| 1563 | 1641 | |
@@ -1567,8 +1645,7 @@ discard block |
||
| 1567 | 1645 | |
| 1568 | 1646 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1569 | 1647 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
| 1570 | - } |
|
| 1571 | - elseif (isset($_POST['new_ignore'])) |
|
| 1648 | + } elseif (isset($_POST['new_ignore'])) |
|
| 1572 | 1649 | { |
| 1573 | 1650 | checkSession(); |
| 1574 | 1651 | // Prepare the string for extraction... |
@@ -1580,8 +1657,9 @@ discard block |
||
| 1580 | 1657 | { |
| 1581 | 1658 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
| 1582 | 1659 | |
| 1583 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1584 | - unset($new_entries[$k]); |
|
| 1660 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1661 | + unset($new_entries[$k]); |
|
| 1662 | + } |
|
| 1585 | 1663 | } |
| 1586 | 1664 | |
| 1587 | 1665 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1599,16 +1677,18 @@ discard block |
||
| 1599 | 1677 | ) |
| 1600 | 1678 | ); |
| 1601 | 1679 | |
| 1602 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1603 | - $_SESSION['prf-save'] = true; |
|
| 1680 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1681 | + $_SESSION['prf-save'] = true; |
|
| 1682 | + } |
|
| 1604 | 1683 | |
| 1605 | 1684 | // Add the new member to the buddies array. |
| 1606 | 1685 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1607 | 1686 | { |
| 1608 | - if (in_array($row['id_member'], $ignoreArray)) |
|
| 1609 | - continue; |
|
| 1610 | - else |
|
| 1611 | - $ignoreArray[] = (int) $row['id_member']; |
|
| 1687 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
| 1688 | + continue; |
|
| 1689 | + } else { |
|
| 1690 | + $ignoreArray[] = (int) $row['id_member']; |
|
| 1691 | + } |
|
| 1612 | 1692 | } |
| 1613 | 1693 | $smcFunc['db_free_result']($request); |
| 1614 | 1694 | |
@@ -1637,8 +1717,9 @@ discard block |
||
| 1637 | 1717 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
| 1638 | 1718 | ) |
| 1639 | 1719 | ); |
| 1640 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1641 | - $ignored[] = $row['id_member']; |
|
| 1720 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1721 | + $ignored[] = $row['id_member']; |
|
| 1722 | + } |
|
| 1642 | 1723 | $smcFunc['db_free_result']($result); |
| 1643 | 1724 | } |
| 1644 | 1725 | |
@@ -1657,10 +1738,11 @@ discard block |
||
| 1657 | 1738 | |
| 1658 | 1739 | if (isset($_SESSION['prf-save'])) |
| 1659 | 1740 | { |
| 1660 | - if ($_SESSION['prf-save'] === true) |
|
| 1661 | - $context['saved_successful'] = true; |
|
| 1662 | - else |
|
| 1663 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1741 | + if ($_SESSION['prf-save'] === true) { |
|
| 1742 | + $context['saved_successful'] = true; |
|
| 1743 | + } else { |
|
| 1744 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1745 | + } |
|
| 1664 | 1746 | |
| 1665 | 1747 | unset($_SESSION['prf-save']); |
| 1666 | 1748 | } |
@@ -1676,8 +1758,9 @@ discard block |
||
| 1676 | 1758 | global $context, $txt; |
| 1677 | 1759 | |
| 1678 | 1760 | loadThemeOptions($memID); |
| 1679 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
| 1680 | - loadCustomFields($memID, 'account'); |
|
| 1761 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
| 1762 | + loadCustomFields($memID, 'account'); |
|
| 1763 | + } |
|
| 1681 | 1764 | |
| 1682 | 1765 | $context['sub_template'] = 'edit_options'; |
| 1683 | 1766 | $context['page_desc'] = $txt['account_info']; |
@@ -1704,8 +1787,9 @@ discard block |
||
| 1704 | 1787 | global $context, $txt; |
| 1705 | 1788 | |
| 1706 | 1789 | loadThemeOptions($memID); |
| 1707 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
| 1708 | - loadCustomFields($memID, 'forumprofile'); |
|
| 1790 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
| 1791 | + loadCustomFields($memID, 'forumprofile'); |
|
| 1792 | + } |
|
| 1709 | 1793 | |
| 1710 | 1794 | $context['sub_template'] = 'edit_options'; |
| 1711 | 1795 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1738,18 +1822,21 @@ discard block |
||
| 1738 | 1822 | $dirs = array(); |
| 1739 | 1823 | $files = array(); |
| 1740 | 1824 | |
| 1741 | - if (!$dir) |
|
| 1742 | - return array(); |
|
| 1825 | + if (!$dir) { |
|
| 1826 | + return array(); |
|
| 1827 | + } |
|
| 1743 | 1828 | |
| 1744 | 1829 | while ($line = $dir->read()) |
| 1745 | 1830 | { |
| 1746 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
| 1747 | - continue; |
|
| 1831 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
| 1832 | + continue; |
|
| 1833 | + } |
|
| 1748 | 1834 | |
| 1749 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
| 1750 | - $dirs[] = $line; |
|
| 1751 | - else |
|
| 1752 | - $files[] = $line; |
|
| 1835 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
| 1836 | + $dirs[] = $line; |
|
| 1837 | + } else { |
|
| 1838 | + $files[] = $line; |
|
| 1839 | + } |
|
| 1753 | 1840 | } |
| 1754 | 1841 | $dir->close(); |
| 1755 | 1842 | |
@@ -1770,14 +1857,15 @@ discard block |
||
| 1770 | 1857 | foreach ($dirs as $line) |
| 1771 | 1858 | { |
| 1772 | 1859 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
| 1773 | - if (!empty($tmp)) |
|
| 1774 | - $result[] = array( |
|
| 1860 | + if (!empty($tmp)) { |
|
| 1861 | + $result[] = array( |
|
| 1775 | 1862 | 'filename' => $smcFunc['htmlspecialchars']($line), |
| 1776 | 1863 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
| 1777 | 1864 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
| 1778 | 1865 | 'is_dir' => true, |
| 1779 | 1866 | 'files' => $tmp |
| 1780 | 1867 | ); |
| 1868 | + } |
|
| 1781 | 1869 | unset($tmp); |
| 1782 | 1870 | } |
| 1783 | 1871 | |
@@ -1787,8 +1875,9 @@ discard block |
||
| 1787 | 1875 | $extension = substr(strrchr($line, '.'), 1); |
| 1788 | 1876 | |
| 1789 | 1877 | // Make sure it is an image. |
| 1790 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
| 1791 | - continue; |
|
| 1878 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
| 1879 | + continue; |
|
| 1880 | + } |
|
| 1792 | 1881 | |
| 1793 | 1882 | $result[] = array( |
| 1794 | 1883 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1796,8 +1885,9 @@ discard block |
||
| 1796 | 1885 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
| 1797 | 1886 | 'is_dir' => false |
| 1798 | 1887 | ); |
| 1799 | - if ($level == 1) |
|
| 1800 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1888 | + if ($level == 1) { |
|
| 1889 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1890 | + } |
|
| 1801 | 1891 | } |
| 1802 | 1892 | |
| 1803 | 1893 | return $result; |
@@ -1819,8 +1909,9 @@ discard block |
||
| 1819 | 1909 | call_integration_hook('integrate_theme_options'); |
| 1820 | 1910 | |
| 1821 | 1911 | loadThemeOptions($memID); |
| 1822 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
| 1823 | - loadCustomFields($memID, 'theme'); |
|
| 1912 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
| 1913 | + loadCustomFields($memID, 'theme'); |
|
| 1914 | + } |
|
| 1824 | 1915 | |
| 1825 | 1916 | $context['sub_template'] = 'edit_options'; |
| 1826 | 1917 | $context['page_desc'] = $txt['theme_info']; |
@@ -1874,16 +1965,19 @@ discard block |
||
| 1874 | 1965 | { |
| 1875 | 1966 | global $txt, $context, $modSettings, $smcFunc, $sourcedir; |
| 1876 | 1967 | |
| 1877 | - if (!isset($context['token_check'])) |
|
| 1878 | - $context['token_check'] = 'profile-nt' . $memID; |
|
| 1968 | + if (!isset($context['token_check'])) { |
|
| 1969 | + $context['token_check'] = 'profile-nt' . $memID; |
|
| 1970 | + } |
|
| 1879 | 1971 | |
| 1880 | 1972 | is_not_guest(); |
| 1881 | - if (!$context['user']['is_owner']) |
|
| 1882 | - isAllowedTo('profile_extra_any'); |
|
| 1973 | + if (!$context['user']['is_owner']) { |
|
| 1974 | + isAllowedTo('profile_extra_any'); |
|
| 1975 | + } |
|
| 1883 | 1976 | |
| 1884 | 1977 | // Set the post action if we're coming from the profile... |
| 1885 | - if (!isset($context['action'])) |
|
| 1886 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1978 | + if (!isset($context['action'])) { |
|
| 1979 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1980 | + } |
|
| 1887 | 1981 | |
| 1888 | 1982 | // What options are set |
| 1889 | 1983 | loadThemeOptions($memID); |
@@ -1970,28 +2064,34 @@ discard block |
||
| 1970 | 2064 | ); |
| 1971 | 2065 | |
| 1972 | 2066 | // There are certain things that are disabled at the group level. |
| 1973 | - if (empty($modSettings['cal_enabled'])) |
|
| 1974 | - unset($alert_types['calendar']); |
|
| 2067 | + if (empty($modSettings['cal_enabled'])) { |
|
| 2068 | + unset($alert_types['calendar']); |
|
| 2069 | + } |
|
| 1975 | 2070 | |
| 1976 | 2071 | // Disable paid subscriptions at group level if they're disabled |
| 1977 | - if (empty($modSettings['paid_enabled'])) |
|
| 1978 | - unset($alert_types['paidsubs']); |
|
| 2072 | + if (empty($modSettings['paid_enabled'])) { |
|
| 2073 | + unset($alert_types['paidsubs']); |
|
| 2074 | + } |
|
| 1979 | 2075 | |
| 1980 | 2076 | // Disable membergroup requests at group level if they're disabled |
| 1981 | - if (empty($modSettings['show_group_membership'])) |
|
| 1982 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2077 | + if (empty($modSettings['show_group_membership'])) { |
|
| 2078 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2079 | + } |
|
| 1983 | 2080 | |
| 1984 | 2081 | // Disable mentions if they're disabled |
| 1985 | - if (empty($modSettings['enable_mentions'])) |
|
| 1986 | - unset($alert_types['msg']['msg_mention']); |
|
| 2082 | + if (empty($modSettings['enable_mentions'])) { |
|
| 2083 | + unset($alert_types['msg']['msg_mention']); |
|
| 2084 | + } |
|
| 1987 | 2085 | |
| 1988 | 2086 | // Disable likes if they're disabled |
| 1989 | - if (empty($modSettings['enable_likes'])) |
|
| 1990 | - unset($alert_types['msg']['msg_like']); |
|
| 2087 | + if (empty($modSettings['enable_likes'])) { |
|
| 2088 | + unset($alert_types['msg']['msg_like']); |
|
| 2089 | + } |
|
| 1991 | 2090 | |
| 1992 | 2091 | // Disable buddy requests if they're disabled |
| 1993 | - if (empty($modSettings['enable_buddylist'])) |
|
| 1994 | - unset($alert_types['members']['buddy_request']); |
|
| 2092 | + if (empty($modSettings['enable_buddylist'])) { |
|
| 2093 | + unset($alert_types['members']['buddy_request']); |
|
| 2094 | + } |
|
| 1995 | 2095 | |
| 1996 | 2096 | // Now, now, we could pass this through global but we should really get into the habit of |
| 1997 | 2097 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -2019,15 +2119,17 @@ discard block |
||
| 2019 | 2119 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
| 2020 | 2120 | } |
| 2021 | 2121 | |
| 2022 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
| 2023 | - unset($alert_types['members']['request_group']); |
|
| 2122 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
| 2123 | + unset($alert_types['members']['request_group']); |
|
| 2124 | + } |
|
| 2024 | 2125 | |
| 2025 | 2126 | foreach ($alert_types as $group => $items) |
| 2026 | 2127 | { |
| 2027 | 2128 | foreach ($items as $alert_key => $alert_value) |
| 2028 | 2129 | { |
| 2029 | - if (!isset($alert_value['permission'])) |
|
| 2030 | - continue; |
|
| 2130 | + if (!isset($alert_value['permission'])) { |
|
| 2131 | + continue; |
|
| 2132 | + } |
|
| 2031 | 2133 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
| 2032 | 2134 | { |
| 2033 | 2135 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2035,12 +2137,14 @@ discard block |
||
| 2035 | 2137 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
| 2036 | 2138 | } |
| 2037 | 2139 | |
| 2038 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
| 2039 | - unset ($alert_types[$group][$alert_key]); |
|
| 2140 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
| 2141 | + unset ($alert_types[$group][$alert_key]); |
|
| 2142 | + } |
|
| 2040 | 2143 | } |
| 2041 | 2144 | |
| 2042 | - if (empty($alert_types[$group])) |
|
| 2043 | - unset ($alert_types[$group]); |
|
| 2145 | + if (empty($alert_types[$group])) { |
|
| 2146 | + unset ($alert_types[$group]); |
|
| 2147 | + } |
|
| 2044 | 2148 | } |
| 2045 | 2149 | } |
| 2046 | 2150 | |
@@ -2072,9 +2176,9 @@ discard block |
||
| 2072 | 2176 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
| 2073 | 2177 | break; |
| 2074 | 2178 | case 'select': |
| 2075 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
| 2076 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2077 | - else |
|
| 2179 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
| 2180 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2181 | + } else |
|
| 2078 | 2182 | { |
| 2079 | 2183 | // We didn't have a sane value. Let's grab the first item from the possibles. |
| 2080 | 2184 | $keys = array_keys($this_option['opts']); |
@@ -2094,23 +2198,28 @@ discard block |
||
| 2094 | 2198 | $this_value = 0; |
| 2095 | 2199 | foreach ($context['alert_bits'] as $type => $bitvalue) |
| 2096 | 2200 | { |
| 2097 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
| 2098 | - $this_value |= $bitvalue; |
|
| 2201 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
| 2202 | + $this_value |= $bitvalue; |
|
| 2203 | + } |
|
| 2204 | + } |
|
| 2205 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
| 2206 | + $update_prefs[$item_key] = $this_value; |
|
| 2099 | 2207 | } |
| 2100 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
| 2101 | - $update_prefs[$item_key] = $this_value; |
|
| 2102 | 2208 | } |
| 2103 | 2209 | } |
| 2104 | 2210 | |
| 2105 | - if (!empty($_POST['opt_alert_timeout'])) |
|
| 2106 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2211 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
| 2212 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2213 | + } |
|
| 2107 | 2214 | |
| 2108 | - if (!empty($_POST['notify_announcements'])) |
|
| 2109 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2215 | + if (!empty($_POST['notify_announcements'])) { |
|
| 2216 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2217 | + } |
|
| 2110 | 2218 | |
| 2111 | 2219 | setNotifyPrefs((int) $memID, $update_prefs); |
| 2112 | - foreach ($update_prefs as $pref => $value) |
|
| 2113 | - $context['alert_prefs'][$pref] = $value; |
|
| 2220 | + foreach ($update_prefs as $pref => $value) { |
|
| 2221 | + $context['alert_prefs'][$pref] = $value; |
|
| 2222 | + } |
|
| 2114 | 2223 | |
| 2115 | 2224 | makeNotificationChanges($memID); |
| 2116 | 2225 | |
@@ -2140,8 +2249,9 @@ discard block |
||
| 2140 | 2249 | |
| 2141 | 2250 | // Now we're all set up. |
| 2142 | 2251 | is_not_guest(); |
| 2143 | - if (!$context['user']['is_owner']) |
|
| 2144 | - fatal_error('no_access'); |
|
| 2252 | + if (!$context['user']['is_owner']) { |
|
| 2253 | + fatal_error('no_access'); |
|
| 2254 | + } |
|
| 2145 | 2255 | |
| 2146 | 2256 | checkSession('get'); |
| 2147 | 2257 | |
@@ -2173,8 +2283,9 @@ discard block |
||
| 2173 | 2283 | { |
| 2174 | 2284 | global $smcFunc; |
| 2175 | 2285 | |
| 2176 | - if (empty($toMark) || empty($memID)) |
|
| 2177 | - return false; |
|
| 2286 | + if (empty($toMark) || empty($memID)) { |
|
| 2287 | + return false; |
|
| 2288 | + } |
|
| 2178 | 2289 | |
| 2179 | 2290 | $toMark = (array) $toMark; |
| 2180 | 2291 | |
@@ -2208,8 +2319,9 @@ discard block |
||
| 2208 | 2319 | { |
| 2209 | 2320 | global $smcFunc; |
| 2210 | 2321 | |
| 2211 | - if (empty($toDelete)) |
|
| 2212 | - return false; |
|
| 2322 | + if (empty($toDelete)) { |
|
| 2323 | + return false; |
|
| 2324 | + } |
|
| 2213 | 2325 | |
| 2214 | 2326 | $toDelete = (array) $toDelete; |
| 2215 | 2327 | |
@@ -2244,8 +2356,9 @@ discard block |
||
| 2244 | 2356 | { |
| 2245 | 2357 | global $smcFunc; |
| 2246 | 2358 | |
| 2247 | - if (empty($memID)) |
|
| 2248 | - return false; |
|
| 2359 | + if (empty($memID)) { |
|
| 2360 | + return false; |
|
| 2361 | + } |
|
| 2249 | 2362 | |
| 2250 | 2363 | $request = $smcFunc['db_query']('', ' |
| 2251 | 2364 | SELECT id_alert |
@@ -2322,8 +2435,9 @@ discard block |
||
| 2322 | 2435 | { |
| 2323 | 2436 | $link = $topic['link']; |
| 2324 | 2437 | |
| 2325 | - if ($topic['new']) |
|
| 2326 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2438 | + if ($topic['new']) { |
|
| 2439 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2440 | + } |
|
| 2327 | 2441 | |
| 2328 | 2442 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
| 2329 | 2443 | |
@@ -2474,8 +2588,9 @@ discard block |
||
| 2474 | 2588 | { |
| 2475 | 2589 | $link = $board['link']; |
| 2476 | 2590 | |
| 2477 | - if ($board['new']) |
|
| 2478 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2591 | + if ($board['new']) { |
|
| 2592 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2593 | + } |
|
| 2479 | 2594 | |
| 2480 | 2595 | return $link; |
| 2481 | 2596 | }, |
@@ -2675,8 +2790,8 @@ discard block |
||
| 2675 | 2790 | ) |
| 2676 | 2791 | ); |
| 2677 | 2792 | $notification_boards = array(); |
| 2678 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2679 | - $notification_boards[] = array( |
|
| 2793 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2794 | + $notification_boards[] = array( |
|
| 2680 | 2795 | 'id' => $row['id_board'], |
| 2681 | 2796 | 'name' => $row['name'], |
| 2682 | 2797 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2684,6 +2799,7 @@ discard block |
||
| 2684 | 2799 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
| 2685 | 2800 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
| 2686 | 2801 | ); |
| 2802 | + } |
|
| 2687 | 2803 | $smcFunc['db_free_result']($request); |
| 2688 | 2804 | |
| 2689 | 2805 | return $notification_boards; |
@@ -2698,17 +2814,18 @@ discard block |
||
| 2698 | 2814 | { |
| 2699 | 2815 | global $context, $options, $cur_profile, $smcFunc; |
| 2700 | 2816 | |
| 2701 | - if (isset($_POST['default_options'])) |
|
| 2702 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2817 | + if (isset($_POST['default_options'])) { |
|
| 2818 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2819 | + } |
|
| 2703 | 2820 | |
| 2704 | 2821 | if ($context['user']['is_owner']) |
| 2705 | 2822 | { |
| 2706 | 2823 | $context['member']['options'] = $options; |
| 2707 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
| 2708 | - foreach ($_POST['options'] as $k => $v) |
|
| 2824 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
| 2825 | + foreach ($_POST['options'] as $k => $v) |
|
| 2709 | 2826 | $context['member']['options'][$k] = $v; |
| 2710 | - } |
|
| 2711 | - else |
|
| 2827 | + } |
|
| 2828 | + } else |
|
| 2712 | 2829 | { |
| 2713 | 2830 | $request = $smcFunc['db_query']('', ' |
| 2714 | 2831 | SELECT id_member, variable, value |
@@ -2729,8 +2846,9 @@ discard block |
||
| 2729 | 2846 | continue; |
| 2730 | 2847 | } |
| 2731 | 2848 | |
| 2732 | - if (isset($_POST['options'][$row['variable']])) |
|
| 2733 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2849 | + if (isset($_POST['options'][$row['variable']])) { |
|
| 2850 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2851 | + } |
|
| 2734 | 2852 | $context['member']['options'][$row['variable']] = $row['value']; |
| 2735 | 2853 | } |
| 2736 | 2854 | $smcFunc['db_free_result']($request); |
@@ -2738,8 +2856,9 @@ discard block |
||
| 2738 | 2856 | // Load up the default theme options for any missing. |
| 2739 | 2857 | foreach ($temp as $k => $v) |
| 2740 | 2858 | { |
| 2741 | - if (!isset($context['member']['options'][$k])) |
|
| 2742 | - $context['member']['options'][$k] = $v; |
|
| 2859 | + if (!isset($context['member']['options'][$k])) { |
|
| 2860 | + $context['member']['options'][$k] = $v; |
|
| 2861 | + } |
|
| 2743 | 2862 | } |
| 2744 | 2863 | } |
| 2745 | 2864 | } |
@@ -2754,8 +2873,9 @@ discard block |
||
| 2754 | 2873 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
| 2755 | 2874 | |
| 2756 | 2875 | // Have the admins enabled this option? |
| 2757 | - if (empty($modSettings['allow_ignore_boards'])) |
|
| 2758 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2876 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
| 2877 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2878 | + } |
|
| 2759 | 2879 | |
| 2760 | 2880 | // Find all the boards this user is allowed to see. |
| 2761 | 2881 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2775,12 +2895,13 @@ discard block |
||
| 2775 | 2895 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2776 | 2896 | { |
| 2777 | 2897 | // This category hasn't been set up yet.. |
| 2778 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 2779 | - $context['categories'][$row['id_cat']] = array( |
|
| 2898 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 2899 | + $context['categories'][$row['id_cat']] = array( |
|
| 2780 | 2900 | 'id' => $row['id_cat'], |
| 2781 | 2901 | 'name' => $row['cat_name'], |
| 2782 | 2902 | 'boards' => array() |
| 2783 | 2903 | ); |
| 2904 | + } |
|
| 2784 | 2905 | |
| 2785 | 2906 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 2786 | 2907 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2810,18 +2931,20 @@ discard block |
||
| 2810 | 2931 | } |
| 2811 | 2932 | |
| 2812 | 2933 | $max_boards = ceil(count($temp_boards) / 2); |
| 2813 | - if ($max_boards == 1) |
|
| 2814 | - $max_boards = 2; |
|
| 2934 | + if ($max_boards == 1) { |
|
| 2935 | + $max_boards = 2; |
|
| 2936 | + } |
|
| 2815 | 2937 | |
| 2816 | 2938 | // Now, alternate them so they can be shown left and right ;). |
| 2817 | 2939 | $context['board_columns'] = array(); |
| 2818 | 2940 | for ($i = 0; $i < $max_boards; $i++) |
| 2819 | 2941 | { |
| 2820 | 2942 | $context['board_columns'][] = $temp_boards[$i]; |
| 2821 | - if (isset($temp_boards[$i + $max_boards])) |
|
| 2822 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2823 | - else |
|
| 2824 | - $context['board_columns'][] = array(); |
|
| 2943 | + if (isset($temp_boards[$i + $max_boards])) { |
|
| 2944 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2945 | + } else { |
|
| 2946 | + $context['board_columns'][] = array(); |
|
| 2947 | + } |
|
| 2825 | 2948 | } |
| 2826 | 2949 | |
| 2827 | 2950 | loadThemeOptions($memID); |
@@ -2890,8 +3013,9 @@ discard block |
||
| 2890 | 3013 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2891 | 3014 | { |
| 2892 | 3015 | // We should skip the administrator group if they don't have the admin_forum permission! |
| 2893 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
| 2894 | - continue; |
|
| 3016 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
| 3017 | + continue; |
|
| 3018 | + } |
|
| 2895 | 3019 | |
| 2896 | 3020 | $context['member_groups'][$row['id_group']] = array( |
| 2897 | 3021 | 'id' => $row['id_group'], |
@@ -2937,16 +3061,17 @@ discard block |
||
| 2937 | 3061 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
| 2938 | 3062 | // Warning message for signature image limits? |
| 2939 | 3063 | $context['signature_warning'] = ''; |
| 2940 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
| 2941 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 2942 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
| 2943 | - $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']); |
|
| 3064 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
| 3065 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 3066 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
| 3067 | + $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']); |
|
| 3068 | + } |
|
| 2944 | 3069 | |
| 2945 | 3070 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
| 2946 | 3071 | |
| 2947 | - if (empty($context['do_preview'])) |
|
| 2948 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 2949 | - else |
|
| 3072 | + if (empty($context['do_preview'])) { |
|
| 3073 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 3074 | + } else |
|
| 2950 | 3075 | { |
| 2951 | 3076 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
| 2952 | 3077 | $validation = profileValidateSignature($signature); |
@@ -2956,8 +3081,9 @@ discard block |
||
| 2956 | 3081 | $context['post_errors'] = array(); |
| 2957 | 3082 | } |
| 2958 | 3083 | $context['post_errors'][] = 'signature_not_yet_saved'; |
| 2959 | - if ($validation !== true && $validation !== false) |
|
| 2960 | - $context['post_errors'][] = $validation; |
|
| 3084 | + if ($validation !== true && $validation !== false) { |
|
| 3085 | + $context['post_errors'][] = $validation; |
|
| 3086 | + } |
|
| 2961 | 3087 | |
| 2962 | 3088 | censorText($context['member']['signature']); |
| 2963 | 3089 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2967,8 +3093,9 @@ discard block |
||
| 2967 | 3093 | } |
| 2968 | 3094 | |
| 2969 | 3095 | // Load the spell checker? |
| 2970 | - if ($context['show_spellchecking']) |
|
| 2971 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3096 | + if ($context['show_spellchecking']) { |
|
| 3097 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3098 | + } |
|
| 2972 | 3099 | |
| 2973 | 3100 | return true; |
| 2974 | 3101 | } |
@@ -3002,8 +3129,7 @@ discard block |
||
| 3002 | 3129 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
| 3003 | 3130 | ); |
| 3004 | 3131 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
| 3005 | - } |
|
| 3006 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3132 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3007 | 3133 | { |
| 3008 | 3134 | $context['member']['avatar'] += array( |
| 3009 | 3135 | 'choice' => 'upload', |
@@ -3013,33 +3139,34 @@ discard block |
||
| 3013 | 3139 | $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']; |
| 3014 | 3140 | } |
| 3015 | 3141 | // Use "avatar_original" here so we show what the user entered even if the image proxy is enabled |
| 3016 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
| 3017 | - $context['member']['avatar'] += array( |
|
| 3142 | + elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
| 3143 | + $context['member']['avatar'] += array( |
|
| 3018 | 3144 | 'choice' => 'external', |
| 3019 | 3145 | 'server_pic' => 'blank.png', |
| 3020 | 3146 | 'external' => $cur_profile['avatar_original'] |
| 3021 | 3147 | ); |
| 3022 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
| 3023 | - $context['member']['avatar'] += array( |
|
| 3148 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
| 3149 | + $context['member']['avatar'] += array( |
|
| 3024 | 3150 | 'choice' => 'server_stored', |
| 3025 | 3151 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
| 3026 | 3152 | 'external' => 'http://' |
| 3027 | 3153 | ); |
| 3028 | - else |
|
| 3029 | - $context['member']['avatar'] += array( |
|
| 3154 | + } else { |
|
| 3155 | + $context['member']['avatar'] += array( |
|
| 3030 | 3156 | 'choice' => 'none', |
| 3031 | 3157 | 'server_pic' => 'blank.png', |
| 3032 | 3158 | 'external' => 'http://' |
| 3033 | 3159 | ); |
| 3160 | + } |
|
| 3034 | 3161 | |
| 3035 | 3162 | // Get a list of all the avatars. |
| 3036 | 3163 | if ($context['member']['avatar']['allow_server_stored']) |
| 3037 | 3164 | { |
| 3038 | 3165 | $context['avatar_list'] = array(); |
| 3039 | 3166 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
| 3167 | + } else { |
|
| 3168 | + $context['avatars'] = array(); |
|
| 3040 | 3169 | } |
| 3041 | - else |
|
| 3042 | - $context['avatars'] = array(); |
|
| 3043 | 3170 | |
| 3044 | 3171 | // Second level selected avatar... |
| 3045 | 3172 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3068,19 +3195,22 @@ discard block |
||
| 3068 | 3195 | ) |
| 3069 | 3196 | ); |
| 3070 | 3197 | $protected_groups = array(1); |
| 3071 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3072 | - $protected_groups[] = $row['id_group']; |
|
| 3198 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3199 | + $protected_groups[] = $row['id_group']; |
|
| 3200 | + } |
|
| 3073 | 3201 | $smcFunc['db_free_result']($request); |
| 3074 | 3202 | |
| 3075 | 3203 | $protected_groups = array_unique($protected_groups); |
| 3076 | 3204 | } |
| 3077 | 3205 | |
| 3078 | 3206 | // The account page allows the change of your id_group - but not to a protected group! |
| 3079 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
| 3080 | - $value = (int) $value; |
|
| 3207 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
| 3208 | + $value = (int) $value; |
|
| 3209 | + } |
|
| 3081 | 3210 | // ... otherwise it's the old group sir. |
| 3082 | - else |
|
| 3083 | - $value = $old_profile['id_group']; |
|
| 3211 | + else { |
|
| 3212 | + $value = $old_profile['id_group']; |
|
| 3213 | + } |
|
| 3084 | 3214 | |
| 3085 | 3215 | // Find the additional membergroups (if any) |
| 3086 | 3216 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3089,16 +3219,18 @@ discard block |
||
| 3089 | 3219 | foreach ($_POST['additional_groups'] as $group_id) |
| 3090 | 3220 | { |
| 3091 | 3221 | $group_id = (int) $group_id; |
| 3092 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
| 3093 | - $additional_groups[] = $group_id; |
|
| 3222 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
| 3223 | + $additional_groups[] = $group_id; |
|
| 3224 | + } |
|
| 3094 | 3225 | } |
| 3095 | 3226 | |
| 3096 | 3227 | // Put the protected groups back in there if you don't have permission to take them away. |
| 3097 | 3228 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
| 3098 | 3229 | foreach ($old_additional_groups as $group_id) |
| 3099 | 3230 | { |
| 3100 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
| 3101 | - $additional_groups[] = $group_id; |
|
| 3231 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
| 3232 | + $additional_groups[] = $group_id; |
|
| 3233 | + } |
|
| 3102 | 3234 | } |
| 3103 | 3235 | |
| 3104 | 3236 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3130,18 +3262,20 @@ discard block |
||
| 3130 | 3262 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 3131 | 3263 | $smcFunc['db_free_result']($request); |
| 3132 | 3264 | |
| 3133 | - if (empty($another)) |
|
| 3134 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3265 | + if (empty($another)) { |
|
| 3266 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3267 | + } |
|
| 3135 | 3268 | } |
| 3136 | 3269 | } |
| 3137 | 3270 | |
| 3138 | 3271 | // If we are changing group status, update permission cache as necessary. |
| 3139 | 3272 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
| 3140 | 3273 | { |
| 3141 | - if ($context['user']['is_owner']) |
|
| 3142 | - $_SESSION['mc']['time'] = 0; |
|
| 3143 | - else |
|
| 3144 | - updateSettings(array('settings_updated' => time())); |
|
| 3274 | + if ($context['user']['is_owner']) { |
|
| 3275 | + $_SESSION['mc']['time'] = 0; |
|
| 3276 | + } else { |
|
| 3277 | + updateSettings(array('settings_updated' => time())); |
|
| 3278 | + } |
|
| 3145 | 3279 | } |
| 3146 | 3280 | |
| 3147 | 3281 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3162,8 +3296,9 @@ discard block |
||
| 3162 | 3296 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
| 3163 | 3297 | |
| 3164 | 3298 | $memID = $context['id_member']; |
| 3165 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
| 3166 | - return false; |
|
| 3299 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
| 3300 | + return false; |
|
| 3301 | + } |
|
| 3167 | 3302 | |
| 3168 | 3303 | require_once($sourcedir . '/ManageAttachments.php'); |
| 3169 | 3304 | |
@@ -3174,8 +3309,9 @@ discard block |
||
| 3174 | 3309 | $downloadedExternalAvatar = false; |
| 3175 | 3310 | 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'])) |
| 3176 | 3311 | { |
| 3177 | - if (!is_writable($uploadDir)) |
|
| 3178 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3312 | + if (!is_writable($uploadDir)) { |
|
| 3313 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3314 | + } |
|
| 3179 | 3315 | |
| 3180 | 3316 | require_once($sourcedir . '/Subs-Package.php'); |
| 3181 | 3317 | |
@@ -3219,19 +3355,18 @@ discard block |
||
| 3219 | 3355 | |
| 3220 | 3356 | // Get rid of their old avatar. (if uploaded.) |
| 3221 | 3357 | removeAttachments(array('id_member' => $memID)); |
| 3222 | - } |
|
| 3223 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3358 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3224 | 3359 | { |
| 3225 | 3360 | // 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. |
| 3226 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
| 3227 | - $profile_vars['avatar'] = 'gravatar://'; |
|
| 3228 | - else |
|
| 3229 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3361 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
| 3362 | + $profile_vars['avatar'] = 'gravatar://'; |
|
| 3363 | + } else { |
|
| 3364 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3365 | + } |
|
| 3230 | 3366 | |
| 3231 | 3367 | // Get rid of their old avatar. (if uploaded.) |
| 3232 | 3368 | removeAttachments(array('id_member' => $memID)); |
| 3233 | - } |
|
| 3234 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3369 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3235 | 3370 | { |
| 3236 | 3371 | // We need these clean... |
| 3237 | 3372 | $cur_profile['id_attach'] = 0; |
@@ -3243,11 +3378,13 @@ discard block |
||
| 3243 | 3378 | |
| 3244 | 3379 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
| 3245 | 3380 | |
| 3246 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
| 3247 | - $profile_vars['avatar'] = ''; |
|
| 3381 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
| 3382 | + $profile_vars['avatar'] = ''; |
|
| 3383 | + } |
|
| 3248 | 3384 | // Trying to make us do something we'll regret? |
| 3249 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
| 3250 | - return 'bad_avatar_invalid_url'; |
|
| 3385 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
| 3386 | + return 'bad_avatar_invalid_url'; |
|
| 3387 | + } |
|
| 3251 | 3388 | // Should we check dimensions? |
| 3252 | 3389 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
| 3253 | 3390 | { |
@@ -3257,9 +3394,9 @@ discard block |
||
| 3257 | 3394 | 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'])))) |
| 3258 | 3395 | { |
| 3259 | 3396 | // Houston, we have a problem. The avatar is too large!! |
| 3260 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
| 3261 | - return 'bad_avatar_too_large'; |
|
| 3262 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3397 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
| 3398 | + return 'bad_avatar_too_large'; |
|
| 3399 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3263 | 3400 | { |
| 3264 | 3401 | // @todo remove this if appropriate |
| 3265 | 3402 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3269,26 +3406,27 @@ discard block |
||
| 3269 | 3406 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
| 3270 | 3407 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
| 3271 | 3408 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
| 3409 | + } else { |
|
| 3410 | + return 'bad_avatar'; |
|
| 3272 | 3411 | } |
| 3273 | - else |
|
| 3274 | - return 'bad_avatar'; |
|
| 3275 | 3412 | } |
| 3276 | 3413 | } |
| 3277 | 3414 | } |
| 3278 | - } |
|
| 3279 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3415 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3280 | 3416 | { |
| 3281 | 3417 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
| 3282 | 3418 | { |
| 3283 | 3419 | // Get the dimensions of the image. |
| 3284 | 3420 | if (!$downloadedExternalAvatar) |
| 3285 | 3421 | { |
| 3286 | - if (!is_writable($uploadDir)) |
|
| 3287 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3422 | + if (!is_writable($uploadDir)) { |
|
| 3423 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3424 | + } |
|
| 3288 | 3425 | |
| 3289 | 3426 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
| 3290 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
| 3291 | - fatal_lang_error('attach_timeout', 'critical'); |
|
| 3427 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
| 3428 | + fatal_lang_error('attach_timeout', 'critical'); |
|
| 3429 | + } |
|
| 3292 | 3430 | |
| 3293 | 3431 | $_FILES['attachment']['tmp_name'] = $new_filename; |
| 3294 | 3432 | } |
@@ -3401,17 +3539,19 @@ discard block |
||
| 3401 | 3539 | $profile_vars['avatar'] = ''; |
| 3402 | 3540 | |
| 3403 | 3541 | // Delete any temporary file. |
| 3404 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
| 3405 | - @unlink($_FILES['attachment']['tmp_name']); |
|
| 3542 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
| 3543 | + @unlink($_FILES['attachment']['tmp_name']); |
|
| 3544 | + } |
|
| 3406 | 3545 | } |
| 3407 | 3546 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
| 3408 | - else |
|
| 3547 | + else { |
|
| 3548 | + $profile_vars['avatar'] = ''; |
|
| 3549 | + } |
|
| 3550 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
| 3551 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3552 | + } else { |
|
| 3409 | 3553 | $profile_vars['avatar'] = ''; |
| 3410 | 3554 | } |
| 3411 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
| 3412 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3413 | - else |
|
| 3414 | - $profile_vars['avatar'] = ''; |
|
| 3415 | 3555 | |
| 3416 | 3556 | // Setup the profile variables so it shows things right on display! |
| 3417 | 3557 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3459,9 +3599,9 @@ discard block |
||
| 3459 | 3599 | $smiley_parsed = $unparsed_signature; |
| 3460 | 3600 | parsesmileys($smiley_parsed); |
| 3461 | 3601 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
| 3462 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
| 3463 | - return 'signature_allow_smileys'; |
|
| 3464 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3602 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
| 3603 | + return 'signature_allow_smileys'; |
|
| 3604 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3465 | 3605 | { |
| 3466 | 3606 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
| 3467 | 3607 | return 'signature_max_smileys'; |
@@ -3474,14 +3614,15 @@ discard block |
||
| 3474 | 3614 | { |
| 3475 | 3615 | $limit_broke = 0; |
| 3476 | 3616 | // Attempt to allow all sizes of abuse, so to speak. |
| 3477 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 3478 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 3479 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 3480 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3481 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 3482 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3483 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 3484 | - $limit_broke = 'large'; |
|
| 3617 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 3618 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 3619 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 3620 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3621 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 3622 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3623 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 3624 | + $limit_broke = 'large'; |
|
| 3625 | + } |
|
| 3485 | 3626 | |
| 3486 | 3627 | if ($limit_broke) |
| 3487 | 3628 | { |
@@ -3523,24 +3664,26 @@ discard block |
||
| 3523 | 3664 | $width = -1; $height = -1; |
| 3524 | 3665 | |
| 3525 | 3666 | // Does it have predefined restraints? Width first. |
| 3526 | - if ($matches[6][$key]) |
|
| 3527 | - $matches[2][$key] = $matches[6][$key]; |
|
| 3667 | + if ($matches[6][$key]) { |
|
| 3668 | + $matches[2][$key] = $matches[6][$key]; |
|
| 3669 | + } |
|
| 3528 | 3670 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 3529 | 3671 | { |
| 3530 | 3672 | $width = $sig_limits[5]; |
| 3531 | 3673 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 3674 | + } elseif ($matches[2][$key]) { |
|
| 3675 | + $width = $matches[2][$key]; |
|
| 3532 | 3676 | } |
| 3533 | - elseif ($matches[2][$key]) |
|
| 3534 | - $width = $matches[2][$key]; |
|
| 3535 | 3677 | // ... and height. |
| 3536 | 3678 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 3537 | 3679 | { |
| 3538 | 3680 | $height = $sig_limits[6]; |
| 3539 | - if ($width != -1) |
|
| 3540 | - $width = $width * ($height / $matches[4][$key]); |
|
| 3681 | + if ($width != -1) { |
|
| 3682 | + $width = $width * ($height / $matches[4][$key]); |
|
| 3683 | + } |
|
| 3684 | + } elseif ($matches[4][$key]) { |
|
| 3685 | + $height = $matches[4][$key]; |
|
| 3541 | 3686 | } |
| 3542 | - elseif ($matches[4][$key]) |
|
| 3543 | - $height = $matches[4][$key]; |
|
| 3544 | 3687 | |
| 3545 | 3688 | // If the dimensions are still not fixed - we need to check the actual image. |
| 3546 | 3689 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3558,21 +3701,24 @@ discard block |
||
| 3558 | 3701 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 3559 | 3702 | { |
| 3560 | 3703 | $height = $sig_limits[6]; |
| 3561 | - if ($width == -1) |
|
| 3562 | - $width = $sizes[0]; |
|
| 3704 | + if ($width == -1) { |
|
| 3705 | + $width = $sizes[0]; |
|
| 3706 | + } |
|
| 3563 | 3707 | $width = $width * ($height / $sizes[1]); |
| 3708 | + } elseif ($width != -1) { |
|
| 3709 | + $height = $sizes[1]; |
|
| 3564 | 3710 | } |
| 3565 | - elseif ($width != -1) |
|
| 3566 | - $height = $sizes[1]; |
|
| 3567 | 3711 | } |
| 3568 | 3712 | } |
| 3569 | 3713 | |
| 3570 | 3714 | // Did we come up with some changes? If so remake the string. |
| 3571 | - if ($width != -1 || $height != -1) |
|
| 3572 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3715 | + if ($width != -1 || $height != -1) { |
|
| 3716 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3717 | + } |
|
| 3718 | + } |
|
| 3719 | + if (!empty($replaces)) { |
|
| 3720 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3573 | 3721 | } |
| 3574 | - if (!empty($replaces)) |
|
| 3575 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3576 | 3722 | } |
| 3577 | 3723 | } |
| 3578 | 3724 | |
@@ -3616,10 +3762,12 @@ discard block |
||
| 3616 | 3762 | $email = strtr($email, array(''' => '\'')); |
| 3617 | 3763 | |
| 3618 | 3764 | // Check the name and email for validity. |
| 3619 | - if (trim($email) == '') |
|
| 3620 | - return 'no_email'; |
|
| 3621 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 3622 | - return 'bad_email'; |
|
| 3765 | + if (trim($email) == '') { |
|
| 3766 | + return 'no_email'; |
|
| 3767 | + } |
|
| 3768 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 3769 | + return 'bad_email'; |
|
| 3770 | + } |
|
| 3623 | 3771 | |
| 3624 | 3772 | // Email addresses should be and stay unique. |
| 3625 | 3773 | $request = $smcFunc['db_query']('', ' |
@@ -3634,8 +3782,9 @@ discard block |
||
| 3634 | 3782 | ) |
| 3635 | 3783 | ); |
| 3636 | 3784 | |
| 3637 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 3638 | - return 'email_taken'; |
|
| 3785 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 3786 | + return 'email_taken'; |
|
| 3787 | + } |
|
| 3639 | 3788 | $smcFunc['db_free_result']($request); |
| 3640 | 3789 | |
| 3641 | 3790 | return true; |
@@ -3648,8 +3797,9 @@ discard block |
||
| 3648 | 3797 | { |
| 3649 | 3798 | global $modSettings, $context, $cur_profile; |
| 3650 | 3799 | |
| 3651 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
| 3652 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3800 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
| 3801 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3802 | + } |
|
| 3653 | 3803 | |
| 3654 | 3804 | loadUserSettings(); |
| 3655 | 3805 | writeLog(); |
@@ -3665,8 +3815,9 @@ discard block |
||
| 3665 | 3815 | require_once($sourcedir . '/Subs-Post.php'); |
| 3666 | 3816 | |
| 3667 | 3817 | // Shouldn't happen but just in case. |
| 3668 | - if (empty($profile_vars['email_address'])) |
|
| 3669 | - return; |
|
| 3818 | + if (empty($profile_vars['email_address'])) { |
|
| 3819 | + return; |
|
| 3820 | + } |
|
| 3670 | 3821 | |
| 3671 | 3822 | $replacements = array( |
| 3672 | 3823 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3689,8 +3840,9 @@ discard block |
||
| 3689 | 3840 | $_SESSION['log_time'] = 0; |
| 3690 | 3841 | $_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0)); |
| 3691 | 3842 | |
| 3692 | - if (isset($_COOKIE[$cookiename])) |
|
| 3693 | - $_COOKIE[$cookiename] = ''; |
|
| 3843 | + if (isset($_COOKIE[$cookiename])) { |
|
| 3844 | + $_COOKIE[$cookiename] = ''; |
|
| 3845 | + } |
|
| 3694 | 3846 | |
| 3695 | 3847 | loadUserSettings(); |
| 3696 | 3848 | |
@@ -3723,11 +3875,13 @@ discard block |
||
| 3723 | 3875 | $groups[] = $curMember['id_group']; |
| 3724 | 3876 | |
| 3725 | 3877 | // Ensure the query doesn't croak! |
| 3726 | - if (empty($groups)) |
|
| 3727 | - $groups = array(0); |
|
| 3878 | + if (empty($groups)) { |
|
| 3879 | + $groups = array(0); |
|
| 3880 | + } |
|
| 3728 | 3881 | // Just to be sure... |
| 3729 | - foreach ($groups as $k => $v) |
|
| 3730 | - $groups[$k] = (int) $v; |
|
| 3882 | + foreach ($groups as $k => $v) { |
|
| 3883 | + $groups[$k] = (int) $v; |
|
| 3884 | + } |
|
| 3731 | 3885 | |
| 3732 | 3886 | // Get all the membergroups they can join. |
| 3733 | 3887 | $request = $smcFunc['db_query']('', ' |
@@ -3757,12 +3911,14 @@ discard block |
||
| 3757 | 3911 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3758 | 3912 | { |
| 3759 | 3913 | // Can they edit their primary group? |
| 3760 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
| 3761 | - $context['can_edit_primary'] = true; |
|
| 3914 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
| 3915 | + $context['can_edit_primary'] = true; |
|
| 3916 | + } |
|
| 3762 | 3917 | |
| 3763 | 3918 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
| 3764 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
| 3765 | - continue; |
|
| 3919 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
| 3920 | + continue; |
|
| 3921 | + } |
|
| 3766 | 3922 | |
| 3767 | 3923 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
| 3768 | 3924 | 'id' => $row['id_group'], |
@@ -3791,13 +3947,15 @@ discard block |
||
| 3791 | 3947 | ); |
| 3792 | 3948 | |
| 3793 | 3949 | // No changing primary one unless you have enough groups! |
| 3794 | - if (count($context['groups']['member']) < 2) |
|
| 3795 | - $context['can_edit_primary'] = false; |
|
| 3950 | + if (count($context['groups']['member']) < 2) { |
|
| 3951 | + $context['can_edit_primary'] = false; |
|
| 3952 | + } |
|
| 3796 | 3953 | |
| 3797 | 3954 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
| 3798 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
| 3799 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3800 | -} |
|
| 3955 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
| 3956 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3957 | + } |
|
| 3958 | + } |
|
| 3801 | 3959 | |
| 3802 | 3960 | /** |
| 3803 | 3961 | * This function actually makes all the group changes |
@@ -3812,10 +3970,12 @@ discard block |
||
| 3812 | 3970 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
| 3813 | 3971 | |
| 3814 | 3972 | // Let's be extra cautious... |
| 3815 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
| 3816 | - isAllowedTo('manage_membergroups'); |
|
| 3817 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
| 3818 | - fatal_lang_error('no_access', false); |
|
| 3973 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
| 3974 | + isAllowedTo('manage_membergroups'); |
|
| 3975 | + } |
|
| 3976 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
| 3977 | + fatal_lang_error('no_access', false); |
|
| 3978 | + } |
|
| 3819 | 3979 | |
| 3820 | 3980 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
| 3821 | 3981 | |
@@ -3834,8 +3994,9 @@ discard block |
||
| 3834 | 3994 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
| 3835 | 3995 | |
| 3836 | 3996 | // Sanity check!! |
| 3837 | - if ($group_id == 1) |
|
| 3838 | - isAllowedTo('admin_forum'); |
|
| 3997 | + if ($group_id == 1) { |
|
| 3998 | + isAllowedTo('admin_forum'); |
|
| 3999 | + } |
|
| 3839 | 4000 | // Protected groups too! |
| 3840 | 4001 | else |
| 3841 | 4002 | { |
@@ -3852,8 +4013,9 @@ discard block |
||
| 3852 | 4013 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
| 3853 | 4014 | $smcFunc['db_free_result']($request); |
| 3854 | 4015 | |
| 3855 | - if ($is_protected == 1) |
|
| 3856 | - isAllowedTo('admin_forum'); |
|
| 4016 | + if ($is_protected == 1) { |
|
| 4017 | + isAllowedTo('admin_forum'); |
|
| 4018 | + } |
|
| 3857 | 4019 | } |
| 3858 | 4020 | |
| 3859 | 4021 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3875,36 +4037,43 @@ discard block |
||
| 3875 | 4037 | $group_name = $row['group_name']; |
| 3876 | 4038 | |
| 3877 | 4039 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
| 3878 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
| 3879 | - fatal_lang_error('no_access', false); |
|
| 4040 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
| 4041 | + fatal_lang_error('no_access', false); |
|
| 4042 | + } |
|
| 3880 | 4043 | // What about leaving a requestable group we are not a member of? |
| 3881 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
| 3882 | - fatal_lang_error('no_access', false); |
|
| 3883 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
| 3884 | - fatal_lang_error('no_access', false); |
|
| 4044 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
| 4045 | + fatal_lang_error('no_access', false); |
|
| 4046 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
| 4047 | + fatal_lang_error('no_access', false); |
|
| 4048 | + } |
|
| 3885 | 4049 | |
| 3886 | 4050 | // We can't change the primary group if this is hidden! |
| 3887 | - if ($row['hidden'] == 2) |
|
| 3888 | - $canChangePrimary = false; |
|
| 4051 | + if ($row['hidden'] == 2) { |
|
| 4052 | + $canChangePrimary = false; |
|
| 4053 | + } |
|
| 3889 | 4054 | } |
| 3890 | 4055 | |
| 3891 | 4056 | // If this is their old primary, can we change it? |
| 3892 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
| 3893 | - $canChangePrimary = 1; |
|
| 4057 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
| 4058 | + $canChangePrimary = 1; |
|
| 4059 | + } |
|
| 3894 | 4060 | |
| 3895 | 4061 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
| 3896 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
| 3897 | - $canChangePrimary = false; |
|
| 4062 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
| 4063 | + $canChangePrimary = false; |
|
| 4064 | + } |
|
| 3898 | 4065 | |
| 3899 | 4066 | // If this is the one we are acting on, can we even act? |
| 3900 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
| 3901 | - $canChangePrimary = false; |
|
| 4067 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
| 4068 | + $canChangePrimary = false; |
|
| 4069 | + } |
|
| 3902 | 4070 | } |
| 3903 | 4071 | $smcFunc['db_free_result']($request); |
| 3904 | 4072 | |
| 3905 | 4073 | // Didn't find the target? |
| 3906 | - if (!$foundTarget) |
|
| 3907 | - fatal_lang_error('no_access', false); |
|
| 4074 | + if (!$foundTarget) { |
|
| 4075 | + fatal_lang_error('no_access', false); |
|
| 4076 | + } |
|
| 3908 | 4077 | |
| 3909 | 4078 | // Final security check, don't allow users to promote themselves to admin. |
| 3910 | 4079 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3924,8 +4093,9 @@ discard block |
||
| 3924 | 4093 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
| 3925 | 4094 | $smcFunc['db_free_result']($request); |
| 3926 | 4095 | |
| 3927 | - if ($disallow) |
|
| 3928 | - isAllowedTo('admin_forum'); |
|
| 4096 | + if ($disallow) { |
|
| 4097 | + isAllowedTo('admin_forum'); |
|
| 4098 | + } |
|
| 3929 | 4099 | } |
| 3930 | 4100 | |
| 3931 | 4101 | // If we're requesting, add the note then return. |
@@ -3943,8 +4113,9 @@ discard block |
||
| 3943 | 4113 | 'status_open' => 0, |
| 3944 | 4114 | ) |
| 3945 | 4115 | ); |
| 3946 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 3947 | - fatal_lang_error('profile_error_already_requested_group'); |
|
| 4116 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 4117 | + fatal_lang_error('profile_error_already_requested_group'); |
|
| 4118 | + } |
|
| 3948 | 4119 | $smcFunc['db_free_result']($request); |
| 3949 | 4120 | |
| 3950 | 4121 | // Log the request. |
@@ -3978,10 +4149,11 @@ discard block |
||
| 3978 | 4149 | // Are we leaving? |
| 3979 | 4150 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
| 3980 | 4151 | { |
| 3981 | - if ($old_profile['id_group'] == $group_id) |
|
| 3982 | - $newPrimary = 0; |
|
| 3983 | - else |
|
| 3984 | - unset($addGroups[$group_id]); |
|
| 4152 | + if ($old_profile['id_group'] == $group_id) { |
|
| 4153 | + $newPrimary = 0; |
|
| 4154 | + } else { |
|
| 4155 | + unset($addGroups[$group_id]); |
|
| 4156 | + } |
|
| 3985 | 4157 | } |
| 3986 | 4158 | // ... if not, must be joining. |
| 3987 | 4159 | else |
@@ -3989,36 +4161,42 @@ discard block |
||
| 3989 | 4161 | // Can we change the primary, and do we want to? |
| 3990 | 4162 | if ($canChangePrimary) |
| 3991 | 4163 | { |
| 3992 | - if ($old_profile['id_group'] != 0) |
|
| 3993 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4164 | + if ($old_profile['id_group'] != 0) { |
|
| 4165 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4166 | + } |
|
| 3994 | 4167 | $newPrimary = $group_id; |
| 3995 | 4168 | } |
| 3996 | 4169 | // Otherwise it's an additional group... |
| 3997 | - else |
|
| 3998 | - $addGroups[$group_id] = -1; |
|
| 4170 | + else { |
|
| 4171 | + $addGroups[$group_id] = -1; |
|
| 4172 | + } |
|
| 3999 | 4173 | } |
| 4000 | 4174 | } |
| 4001 | 4175 | // Finally, we must be setting the primary. |
| 4002 | 4176 | elseif ($canChangePrimary) |
| 4003 | 4177 | { |
| 4004 | - if ($old_profile['id_group'] != 0) |
|
| 4005 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4006 | - if (isset($addGroups[$group_id])) |
|
| 4007 | - unset($addGroups[$group_id]); |
|
| 4178 | + if ($old_profile['id_group'] != 0) { |
|
| 4179 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4180 | + } |
|
| 4181 | + if (isset($addGroups[$group_id])) { |
|
| 4182 | + unset($addGroups[$group_id]); |
|
| 4183 | + } |
|
| 4008 | 4184 | $newPrimary = $group_id; |
| 4009 | 4185 | } |
| 4010 | 4186 | |
| 4011 | 4187 | // Finally, we can make the changes! |
| 4012 | - foreach ($addGroups as $id => $dummy) |
|
| 4013 | - if (empty($id)) |
|
| 4188 | + foreach ($addGroups as $id => $dummy) { |
|
| 4189 | + if (empty($id)) |
|
| 4014 | 4190 | unset($addGroups[$id]); |
| 4191 | + } |
|
| 4015 | 4192 | $addGroups = implode(',', array_flip($addGroups)); |
| 4016 | 4193 | |
| 4017 | 4194 | // Ensure that we don't cache permissions if the group is changing. |
| 4018 | - if ($context['user']['is_owner']) |
|
| 4019 | - $_SESSION['mc']['time'] = 0; |
|
| 4020 | - else |
|
| 4021 | - updateSettings(array('settings_updated' => time())); |
|
| 4195 | + if ($context['user']['is_owner']) { |
|
| 4196 | + $_SESSION['mc']['time'] = 0; |
|
| 4197 | + } else { |
|
| 4198 | + updateSettings(array('settings_updated' => time())); |
|
| 4199 | + } |
|
| 4022 | 4200 | |
| 4023 | 4201 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
| 4024 | 4202 | |
@@ -4041,8 +4219,9 @@ discard block |
||
| 4041 | 4219 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
| 4042 | 4220 | { |
| 4043 | 4221 | // Check to ensure we're forcing SSL for authentication |
| 4044 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
| 4045 | - fatal_lang_error('login_ssl_required'); |
|
| 4222 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
| 4223 | + fatal_lang_error('login_ssl_required'); |
|
| 4224 | + } |
|
| 4046 | 4225 | |
| 4047 | 4226 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
| 4048 | 4227 | // we do not want too much AJAX to confuse them. |
@@ -4079,8 +4258,7 @@ discard block |
||
| 4079 | 4258 | $context['sub_template'] = 'tfasetup_backup'; |
| 4080 | 4259 | |
| 4081 | 4260 | return; |
| 4082 | - } |
|
| 4083 | - else |
|
| 4261 | + } else |
|
| 4084 | 4262 | { |
| 4085 | 4263 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
| 4086 | 4264 | $context['tfa_error'] = !$valid_code; |
@@ -4088,8 +4266,7 @@ discard block |
||
| 4088 | 4266 | $context['tfa_pass_value'] = $_POST['passwd']; |
| 4089 | 4267 | $context['tfa_value'] = $_POST['tfa_code']; |
| 4090 | 4268 | } |
| 4091 | - } |
|
| 4092 | - else |
|
| 4269 | + } else |
|
| 4093 | 4270 | { |
| 4094 | 4271 | $totp = new \TOTP\Auth(); |
| 4095 | 4272 | $secret = $totp->generateCode(); |
@@ -4099,17 +4276,16 @@ discard block |
||
| 4099 | 4276 | } |
| 4100 | 4277 | |
| 4101 | 4278 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
| 4102 | - } |
|
| 4103 | - elseif (isset($_REQUEST['disable'])) |
|
| 4279 | + } elseif (isset($_REQUEST['disable'])) |
|
| 4104 | 4280 | { |
| 4105 | 4281 | updateMemberData($memID, array( |
| 4106 | 4282 | 'tfa_secret' => '', |
| 4107 | 4283 | 'tfa_backup' => '', |
| 4108 | 4284 | )); |
| 4109 | 4285 | redirectexit('action=profile;area=account;u=' . $memID); |
| 4286 | + } else { |
|
| 4287 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4288 | + } |
|
| 4110 | 4289 | } |
| 4111 | - else |
|
| 4112 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4113 | -} |
|
| 4114 | 4290 | |
| 4115 | 4291 | ?> |
| 4116 | 4292 | \ No newline at end of file |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | * @param resource $socket Socket to send on |
| 1446 | 1446 | * @param string $code The expected response code |
| 1447 | 1447 | * @param string $response The response from the SMTP server |
| 1448 | - * @return bool Whether it responded as such. |
|
| 1448 | + * @return string|boolean Whether it responded as such. |
|
| 1449 | 1449 | */ |
| 1450 | 1450 | function server_parse($message, $socket, $code, &$response = null) |
| 1451 | 1451 | { |
@@ -2259,7 +2259,7 @@ discard block |
||
| 2259 | 2259 | * @param array $msgs Array of message ids |
| 2260 | 2260 | * @param bool $approve Whether to approve the posts (if false, posts are unapproved) |
| 2261 | 2261 | * @param bool $notify Whether to notify users |
| 2262 | - * @return bool Whether the operation was successful |
|
| 2262 | + * @return null|boolean Whether the operation was successful |
|
| 2263 | 2263 | */ |
| 2264 | 2264 | function approvePosts($msgs, $approve = true, $notify = true) |
| 2265 | 2265 | { |
@@ -2512,7 +2512,7 @@ discard block |
||
| 2512 | 2512 | * |
| 2513 | 2513 | * @param array $topics Array of topic ids |
| 2514 | 2514 | * @param bool $approve Whether to approve the topics. If false, unapproves them instead |
| 2515 | - * @return bool Whether the operation was successful |
|
| 2515 | + * @return null|boolean Whether the operation was successful |
|
| 2516 | 2516 | */ |
| 2517 | 2517 | function approveTopics($topics, $approve = true) |
| 2518 | 2518 | { |
@@ -2902,7 +2902,7 @@ discard block |
||
| 2902 | 2902 | * |
| 2903 | 2903 | * @param resource $dict An enchant or pspell dictionary resource set up by {@link spell_init()} |
| 2904 | 2904 | * @param string $word A word to check the spelling of |
| 2905 | - * @return bool Whether or not the specified word is spelled properly |
|
| 2905 | + * @return boolean|null Whether or not the specified word is spelled properly |
|
| 2906 | 2906 | */ |
| 2907 | 2907 | function spell_check($dict, $word) |
| 2908 | 2908 | { |
@@ -704,7 +704,7 @@ |
||
| 704 | 704 | $mail_result = false; |
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | - catch(ErrorException $e) |
|
| 707 | + catch (ErrorException $e) |
|
| 708 | 708 | { |
| 709 | 709 | log_error($e->getMessage(), 'general', $e->getFile(), $e->getLine()); |
| 710 | 710 | log_error(sprintf($txt['mail_send_unable'], $to)); |
@@ -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 | * Takes a message and parses it, returning nothing. |
@@ -31,8 +32,9 @@ discard block |
||
| 31 | 32 | global $user_info, $modSettings, $context, $sourcedir; |
| 32 | 33 | |
| 33 | 34 | // This line makes all languages *theoretically* work even with the wrong charset ;). |
| 34 | - if (empty($context['utf8'])) |
|
| 35 | - $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
| 35 | + if (empty($context['utf8'])) { |
|
| 36 | + $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | // Clean up after nobbc ;). |
| 38 | 40 | $message = preg_replace_callback('~\[nobbc\](.+?)\[/nobbc\]~is', function($a) |
@@ -47,17 +49,19 @@ discard block |
||
| 47 | 49 | $message = preg_replace('~\.{100,}~', '...', $message); |
| 48 | 50 | |
| 49 | 51 | // Trim off trailing quotes - these often happen by accident. |
| 50 | - while (substr($message, -7) == '[quote]') |
|
| 51 | - $message = substr($message, 0, -7); |
|
| 52 | - while (substr($message, 0, 8) == '[/quote]') |
|
| 53 | - $message = substr($message, 8); |
|
| 52 | + while (substr($message, -7) == '[quote]') { |
|
| 53 | + $message = substr($message, 0, -7); |
|
| 54 | + } |
|
| 55 | + while (substr($message, 0, 8) == '[/quote]') { |
|
| 56 | + $message = substr($message, 8); |
|
| 57 | + } |
|
| 54 | 58 | |
| 55 | 59 | // Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed. |
| 56 | 60 | $in_tag = false; |
| 57 | 61 | $had_tag = false; |
| 58 | 62 | $codeopen = 0; |
| 59 | - if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) |
|
| 60 | - foreach ($matches[0] as $index => $dummy) |
|
| 63 | + if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) { |
|
| 64 | + foreach ($matches[0] as $index => $dummy) |
|
| 61 | 65 | { |
| 62 | 66 | // Closing? |
| 63 | 67 | if (!empty($matches[2][$index])) |
@@ -65,6 +69,7 @@ discard block |
||
| 65 | 69 | // If it's closing and we're not in a tag we need to open it... |
| 66 | 70 | if (!$in_tag) |
| 67 | 71 | $codeopen = true; |
| 72 | + } |
|
| 68 | 73 | // Either way we ain't in one any more. |
| 69 | 74 | $in_tag = false; |
| 70 | 75 | } |
@@ -73,17 +78,20 @@ discard block |
||
| 73 | 78 | { |
| 74 | 79 | $had_tag = true; |
| 75 | 80 | // If we're in a tag don't do nought! |
| 76 | - if (!$in_tag) |
|
| 77 | - $in_tag = true; |
|
| 81 | + if (!$in_tag) { |
|
| 82 | + $in_tag = true; |
|
| 83 | + } |
|
| 78 | 84 | } |
| 79 | 85 | } |
| 80 | 86 | |
| 81 | 87 | // If we have an open tag, close it. |
| 82 | - if ($in_tag) |
|
| 83 | - $message .= '[/code]'; |
|
| 88 | + if ($in_tag) { |
|
| 89 | + $message .= '[/code]'; |
|
| 90 | + } |
|
| 84 | 91 | // Open any ones that need to be open, only if we've never had a tag. |
| 85 | - if ($codeopen && !$had_tag) |
|
| 86 | - $message = '[code]' . $message; |
|
| 92 | + if ($codeopen && !$had_tag) { |
|
| 93 | + $message = '[code]' . $message; |
|
| 94 | + } |
|
| 87 | 95 | |
| 88 | 96 | // Now that we've fixed all the code tags, let's fix the img and url tags... |
| 89 | 97 | $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); |
@@ -109,23 +117,26 @@ discard block |
||
| 109 | 117 | fixTags($message); |
| 110 | 118 | |
| 111 | 119 | // Replace /me.+?\n with [me=name]dsf[/me]\n. |
| 112 | - if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) |
|
| 113 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
| 114 | - else |
|
| 115 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
| 120 | + if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) { |
|
| 121 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
| 122 | + } else { |
|
| 123 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
| 124 | + } |
|
| 116 | 125 | |
| 117 | 126 | if (!$previewing && strpos($message, '[html]') !== false) |
| 118 | 127 | { |
| 119 | - if (allowedTo('admin_forum')) |
|
| 120 | - $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
| 128 | + if (allowedTo('admin_forum')) { |
|
| 129 | + $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
| 121 | 130 | return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => ' ', ' ' => '  ', '[' => '[', ']' => ']')) . '[/html]'; |
| 131 | + } |
|
| 122 | 132 | }, $message); |
| 123 | 133 | |
| 124 | 134 | // We should edit them out, or else if an admin edits the message they will get shown... |
| 125 | 135 | else |
| 126 | 136 | { |
| 127 | - while (strpos($message, '[html]') !== false) |
|
| 128 | - $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
| 137 | + while (strpos($message, '[html]') !== false) { |
|
| 138 | + $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
| 139 | + } |
|
| 129 | 140 | } |
| 130 | 141 | } |
| 131 | 142 | |
@@ -147,10 +158,12 @@ discard block |
||
| 147 | 158 | |
| 148 | 159 | $list_open = substr_count($message, '[list]') + substr_count($message, '[list '); |
| 149 | 160 | $list_close = substr_count($message, '[/list]'); |
| 150 | - if ($list_close - $list_open > 0) |
|
| 151 | - $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
| 152 | - if ($list_open - $list_close > 0) |
|
| 153 | - $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
| 161 | + if ($list_close - $list_open > 0) { |
|
| 162 | + $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
| 163 | + } |
|
| 164 | + if ($list_open - $list_close > 0) { |
|
| 165 | + $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
| 166 | + } |
|
| 154 | 167 | |
| 155 | 168 | $mistake_fixes = array( |
| 156 | 169 | // Find [table]s not followed by [tr]. |
@@ -199,8 +212,9 @@ discard block |
||
| 199 | 212 | ); |
| 200 | 213 | |
| 201 | 214 | // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) |
| 202 | - for ($j = 0; $j < 3; $j++) |
|
| 203 | - $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
| 215 | + for ($j = 0; $j < 3; $j++) { |
|
| 216 | + $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
| 217 | + } |
|
| 204 | 218 | |
| 205 | 219 | // Remove empty bbc from the sections outside the code tags |
| 206 | 220 | $allowedEmpty = array( |
@@ -211,24 +225,28 @@ discard block |
||
| 211 | 225 | require_once($sourcedir . '/Subs.php'); |
| 212 | 226 | |
| 213 | 227 | $alltags = array(); |
| 214 | - foreach (($codes = parse_bbc(false)) as $code) |
|
| 215 | - if (!in_array($code['tag'], $allowedEmpty)) |
|
| 228 | + foreach (($codes = parse_bbc(false)) as $code) { |
|
| 229 | + if (!in_array($code['tag'], $allowedEmpty)) |
|
| 216 | 230 | $alltags[] = $code['tag']; |
| 231 | + } |
|
| 217 | 232 | |
| 218 | 233 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
| 219 | 234 | |
| 220 | - while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) |
|
| 221 | - $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
| 235 | + while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) { |
|
| 236 | + $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
| 237 | + } |
|
| 222 | 238 | |
| 223 | 239 | // Restore code blocks |
| 224 | - if (!empty($code_tags)) |
|
| 225 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 240 | + if (!empty($code_tags)) { |
|
| 241 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 242 | + } |
|
| 226 | 243 | |
| 227 | 244 | // Restore white space entities |
| 228 | - if (!$previewing) |
|
| 229 | - $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 230 | - else |
|
| 231 | - $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 245 | + if (!$previewing) { |
|
| 246 | + $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 247 | + } else { |
|
| 248 | + $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 249 | + } |
|
| 232 | 250 | |
| 233 | 251 | // Now let's quickly clean up things that will slow our parser (which are common in posted code.) |
| 234 | 252 | $message = strtr($message, array('[]' => '[]', '['' => '['')); |
@@ -271,8 +289,9 @@ discard block |
||
| 271 | 289 | return "[time]" . timeformat("$m[1]", false) . "[/time]"; |
| 272 | 290 | }, $message); |
| 273 | 291 | |
| 274 | - if (!empty($code_tags)) |
|
| 275 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 292 | + if (!empty($code_tags)) { |
|
| 293 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 294 | + } |
|
| 276 | 295 | |
| 277 | 296 | // Change breaks back to \n's and &nsbp; back to spaces. |
| 278 | 297 | return preg_replace('~<br( /)?' . '>~', "\n", str_replace(' ', ' ', $message)); |
@@ -353,8 +372,9 @@ discard block |
||
| 353 | 372 | ); |
| 354 | 373 | |
| 355 | 374 | // Fix each type of tag. |
| 356 | - foreach ($fixArray as $param) |
|
| 357 | - fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
| 375 | + foreach ($fixArray as $param) { |
|
| 376 | + fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
| 377 | + } |
|
| 358 | 378 | |
| 359 | 379 | // Now fix possible security problems with images loading links automatically... |
| 360 | 380 | $message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m) |
@@ -390,16 +410,19 @@ discard block |
||
| 390 | 410 | $desired_height = $height; |
| 391 | 411 | } |
| 392 | 412 | // Scale it to the width... |
| 393 | - elseif (empty($desired_width) && !empty($height)) |
|
| 394 | - $desired_width = (int) (($desired_height * $width) / $height); |
|
| 413 | + elseif (empty($desired_width) && !empty($height)) { |
|
| 414 | + $desired_width = (int) (($desired_height * $width) / $height); |
|
| 415 | + } |
|
| 395 | 416 | // Scale if to the height. |
| 396 | - elseif (!empty($width)) |
|
| 397 | - $desired_height = (int) (($desired_width * $height) / $width); |
|
| 417 | + elseif (!empty($width)) { |
|
| 418 | + $desired_height = (int) (($desired_width * $height) / $width); |
|
| 419 | + } |
|
| 398 | 420 | } |
| 399 | 421 | |
| 400 | 422 | // If the width and height are fine, just continue along... |
| 401 | - if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) |
|
| 402 | - continue; |
|
| 423 | + if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) { |
|
| 424 | + continue; |
|
| 425 | + } |
|
| 403 | 426 | |
| 404 | 427 | // Too bad, it's too wide. Make it as wide as the maximum. |
| 405 | 428 | if ($desired_width > $modSettings['max_image_width'] && !empty($modSettings['max_image_width'])) |
@@ -419,8 +442,9 @@ discard block |
||
| 419 | 442 | } |
| 420 | 443 | |
| 421 | 444 | // If any img tags were actually changed... |
| 422 | - if (!empty($replaces)) |
|
| 423 | - $message = strtr($message, $replaces); |
|
| 445 | + if (!empty($replaces)) { |
|
| 446 | + $message = strtr($message, $replaces); |
|
| 447 | + } |
|
| 424 | 448 | } |
| 425 | 449 | } |
| 426 | 450 | |
@@ -439,10 +463,11 @@ discard block |
||
| 439 | 463 | { |
| 440 | 464 | global $boardurl, $scripturl; |
| 441 | 465 | |
| 442 | - if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) |
|
| 443 | - $domain_url = $match[1]; |
|
| 444 | - else |
|
| 445 | - $domain_url = $boardurl . '/'; |
|
| 466 | + if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) { |
|
| 467 | + $domain_url = $match[1]; |
|
| 468 | + } else { |
|
| 469 | + $domain_url = $boardurl . '/'; |
|
| 470 | + } |
|
| 446 | 471 | |
| 447 | 472 | $replaces = array(); |
| 448 | 473 | |
@@ -450,11 +475,11 @@ discard block |
||
| 450 | 475 | { |
| 451 | 476 | $quoted = preg_match('~\[(' . $myTag . ')="~', $message); |
| 452 | 477 | preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '"(.*?)"' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
| 478 | + } elseif ($hasEqualSign) { |
|
| 479 | + preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
| 480 | + } else { |
|
| 481 | + preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
| 453 | 482 | } |
| 454 | - elseif ($hasEqualSign) |
|
| 455 | - preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
| 456 | - else |
|
| 457 | - preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
| 458 | 483 | |
| 459 | 484 | foreach ($matches[0] as $k => $dummy) |
| 460 | 485 | { |
@@ -467,49 +492,53 @@ discard block |
||
| 467 | 492 | foreach ($protocols as $protocol) |
| 468 | 493 | { |
| 469 | 494 | $found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0; |
| 470 | - if ($found) |
|
| 471 | - break; |
|
| 495 | + if ($found) { |
|
| 496 | + break; |
|
| 497 | + } |
|
| 472 | 498 | } |
| 473 | 499 | |
| 474 | 500 | if (!$found && $protocols[0] == 'http') |
| 475 | 501 | { |
| 476 | - if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') |
|
| 477 | - $replace = $domain_url . $replace; |
|
| 478 | - elseif (substr($replace, 0, 1) == '?') |
|
| 479 | - $replace = $scripturl . $replace; |
|
| 480 | - elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
| 502 | + if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') { |
|
| 503 | + $replace = $domain_url . $replace; |
|
| 504 | + } elseif (substr($replace, 0, 1) == '?') { |
|
| 505 | + $replace = $scripturl . $replace; |
|
| 506 | + } elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
| 481 | 507 | { |
| 482 | 508 | $replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1)); |
| 483 | 509 | $this_tag = 'iurl'; |
| 484 | 510 | $this_close = 'iurl'; |
| 511 | + } elseif (substr($replace, 0, 2) != '//') { |
|
| 512 | + $replace = $protocols[0] . '://' . $replace; |
|
| 485 | 513 | } |
| 486 | - elseif (substr($replace, 0, 2) != '//') |
|
| 487 | - $replace = $protocols[0] . '://' . $replace; |
|
| 488 | - } |
|
| 489 | - elseif (!$found && $protocols[0] == 'ftp') |
|
| 490 | - $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
| 491 | - elseif (!$found) |
|
| 492 | - $replace = $protocols[0] . '://' . $replace; |
|
| 493 | - |
|
| 494 | - if ($hasEqualSign && $embeddedUrl) |
|
| 495 | - $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
| 496 | - elseif ($hasEqualSign) |
|
| 497 | - $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
| 498 | - elseif ($embeddedUrl) |
|
| 499 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
| 500 | - else |
|
| 501 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
| 514 | + } elseif (!$found && $protocols[0] == 'ftp') { |
|
| 515 | + $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
| 516 | + } elseif (!$found) { |
|
| 517 | + $replace = $protocols[0] . '://' . $replace; |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + if ($hasEqualSign && $embeddedUrl) { |
|
| 521 | + $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
| 522 | + } elseif ($hasEqualSign) { |
|
| 523 | + $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
| 524 | + } elseif ($embeddedUrl) { |
|
| 525 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
| 526 | + } else { |
|
| 527 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
| 528 | + } |
|
| 502 | 529 | } |
| 503 | 530 | |
| 504 | 531 | foreach ($replaces as $k => $v) |
| 505 | 532 | { |
| 506 | - if ($k == $v) |
|
| 507 | - unset($replaces[$k]); |
|
| 533 | + if ($k == $v) { |
|
| 534 | + unset($replaces[$k]); |
|
| 535 | + } |
|
| 508 | 536 | } |
| 509 | 537 | |
| 510 | - if (!empty($replaces)) |
|
| 511 | - $message = strtr($message, $replaces); |
|
| 512 | -} |
|
| 538 | + if (!empty($replaces)) { |
|
| 539 | + $message = strtr($message, $replaces); |
|
| 540 | + } |
|
| 541 | + } |
|
| 513 | 542 | |
| 514 | 543 | /** |
| 515 | 544 | * This function sends an email to the specified recipient(s). |
@@ -553,8 +582,9 @@ discard block |
||
| 553 | 582 | } |
| 554 | 583 | |
| 555 | 584 | // Nothing left? Nothing else to do |
| 556 | - if (empty($to_array)) |
|
| 557 | - return true; |
|
| 585 | + if (empty($to_array)) { |
|
| 586 | + return true; |
|
| 587 | + } |
|
| 558 | 588 | |
| 559 | 589 | // Once upon a time, Hotmail could not interpret non-ASCII mails. |
| 560 | 590 | // In honour of those days, it's still called the 'hotmail fix'. |
@@ -571,15 +601,17 @@ discard block |
||
| 571 | 601 | } |
| 572 | 602 | |
| 573 | 603 | // Call this function recursively for the hotmail addresses. |
| 574 | - if (!empty($hotmail_to)) |
|
| 575 | - $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
| 604 | + if (!empty($hotmail_to)) { |
|
| 605 | + $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
| 606 | + } |
|
| 576 | 607 | |
| 577 | 608 | // The remaining addresses no longer need the fix. |
| 578 | 609 | $hotmail_fix = false; |
| 579 | 610 | |
| 580 | 611 | // No other addresses left? Return instantly. |
| 581 | - if (empty($to_array)) |
|
| 582 | - return $mail_result; |
|
| 612 | + if (empty($to_array)) { |
|
| 613 | + return $mail_result; |
|
| 614 | + } |
|
| 583 | 615 | } |
| 584 | 616 | |
| 585 | 617 | // Get rid of entities. |
@@ -604,13 +636,15 @@ discard block |
||
| 604 | 636 | $headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break; |
| 605 | 637 | $headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break; |
| 606 | 638 | |
| 607 | - if ($message_id !== null && empty($modSettings['mail_no_message_id'])) |
|
| 608 | - $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
| 639 | + if ($message_id !== null && empty($modSettings['mail_no_message_id'])) { |
|
| 640 | + $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
| 641 | + } |
|
| 609 | 642 | $headers .= 'X-Mailer: SMF' . $line_break; |
| 610 | 643 | |
| 611 | 644 | // Pass this to the integration before we start modifying the output -- it'll make it easier later. |
| 612 | - if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) |
|
| 613 | - return false; |
|
| 645 | + if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) { |
|
| 646 | + return false; |
|
| 647 | + } |
|
| 614 | 648 | |
| 615 | 649 | // Save the original message... |
| 616 | 650 | $orig_message = $message; |
@@ -659,17 +693,19 @@ discard block |
||
| 659 | 693 | } |
| 660 | 694 | |
| 661 | 695 | // Are we using the mail queue, if so this is where we butt in... |
| 662 | - if ($priority != 0) |
|
| 663 | - return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
| 696 | + if ($priority != 0) { |
|
| 697 | + return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
| 698 | + } |
|
| 664 | 699 | |
| 665 | 700 | // If it's a priority mail, send it now - note though that this should NOT be used for sending many at once. |
| 666 | 701 | elseif (!empty($modSettings['mail_limit'])) |
| 667 | 702 | { |
| 668 | 703 | list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']); |
| 669 | - if (empty($mails_this_minute) || time() > $last_mail_time + 60) |
|
| 670 | - $new_queue_stat = time() . '|' . 1; |
|
| 671 | - else |
|
| 672 | - $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
| 704 | + if (empty($mails_this_minute) || time() > $last_mail_time + 60) { |
|
| 705 | + $new_queue_stat = time() . '|' . 1; |
|
| 706 | + } else { |
|
| 707 | + $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
| 708 | + } |
|
| 673 | 709 | |
| 674 | 710 | updateSettings(array('mail_recent' => $new_queue_stat)); |
| 675 | 711 | } |
@@ -703,8 +739,7 @@ discard block |
||
| 703 | 739 | log_error(sprintf($txt['mail_send_unable'], $to)); |
| 704 | 740 | $mail_result = false; |
| 705 | 741 | } |
| 706 | - } |
|
| 707 | - catch(ErrorException $e) |
|
| 742 | + } catch(ErrorException $e) |
|
| 708 | 743 | { |
| 709 | 744 | log_error($e->getMessage(), 'general', $e->getFile(), $e->getLine()); |
| 710 | 745 | log_error(sprintf($txt['mail_send_unable'], $to)); |
@@ -714,12 +749,13 @@ discard block |
||
| 714 | 749 | |
| 715 | 750 | // Wait, wait, I'm still sending here! |
| 716 | 751 | @set_time_limit(300); |
| 717 | - if (function_exists('apache_reset_timeout')) |
|
| 718 | - @apache_reset_timeout(); |
|
| 752 | + if (function_exists('apache_reset_timeout')) { |
|
| 753 | + @apache_reset_timeout(); |
|
| 754 | + } |
|
| 719 | 755 | } |
| 756 | + } else { |
|
| 757 | + $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
| 720 | 758 | } |
| 721 | - else |
|
| 722 | - $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
| 723 | 759 | |
| 724 | 760 | // Everything go smoothly? |
| 725 | 761 | return $mail_result; |
@@ -745,8 +781,9 @@ discard block |
||
| 745 | 781 | static $cur_insert = array(); |
| 746 | 782 | static $cur_insert_len = 0; |
| 747 | 783 | |
| 748 | - if ($cur_insert_len == 0) |
|
| 749 | - $cur_insert = array(); |
|
| 784 | + if ($cur_insert_len == 0) { |
|
| 785 | + $cur_insert = array(); |
|
| 786 | + } |
|
| 750 | 787 | |
| 751 | 788 | // If we're flushing, make the final inserts - also if we're near the MySQL length limit! |
| 752 | 789 | if (($flush || $cur_insert_len > 800000) && !empty($cur_insert)) |
@@ -821,8 +858,9 @@ discard block |
||
| 821 | 858 | } |
| 822 | 859 | |
| 823 | 860 | // If they are using SSI there is a good chance obExit will never be called. So lets be nice and flush it for them. |
| 824 | - if (SMF === 'SSI' || SMF === 'BACKGROUND') |
|
| 825 | - return AddMailQueue(true); |
|
| 861 | + if (SMF === 'SSI' || SMF === 'BACKGROUND') { |
|
| 862 | + return AddMailQueue(true); |
|
| 863 | + } |
|
| 826 | 864 | |
| 827 | 865 | return true; |
| 828 | 866 | } |
@@ -853,23 +891,26 @@ discard block |
||
| 853 | 891 | 'sent' => array() |
| 854 | 892 | ); |
| 855 | 893 | |
| 856 | - if ($from === null) |
|
| 857 | - $from = array( |
|
| 894 | + if ($from === null) { |
|
| 895 | + $from = array( |
|
| 858 | 896 | 'id' => $user_info['id'], |
| 859 | 897 | 'name' => $user_info['name'], |
| 860 | 898 | 'username' => $user_info['username'] |
| 861 | 899 | ); |
| 900 | + } |
|
| 862 | 901 | |
| 863 | 902 | // This is the one that will go in their inbox. |
| 864 | 903 | $htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES); |
| 865 | 904 | preparsecode($htmlmessage); |
| 866 | 905 | $htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => '')); |
| 867 | - if ($smcFunc['strlen']($htmlsubject) > 100) |
|
| 868 | - $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
| 906 | + if ($smcFunc['strlen']($htmlsubject) > 100) { |
|
| 907 | + $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
| 908 | + } |
|
| 869 | 909 | |
| 870 | 910 | // Make sure is an array |
| 871 | - if (!is_array($recipients)) |
|
| 872 | - $recipients = array($recipients); |
|
| 911 | + if (!is_array($recipients)) { |
|
| 912 | + $recipients = array($recipients); |
|
| 913 | + } |
|
| 873 | 914 | |
| 874 | 915 | // Integrated PMs |
| 875 | 916 | call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message)); |
@@ -897,21 +938,23 @@ discard block |
||
| 897 | 938 | 'usernames' => array_keys($usernames), |
| 898 | 939 | ) |
| 899 | 940 | ); |
| 900 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 901 | - if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
| 941 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 942 | + if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
| 902 | 943 | $usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member']; |
| 944 | + } |
|
| 903 | 945 | $smcFunc['db_free_result']($request); |
| 904 | 946 | |
| 905 | 947 | // Replace the usernames with IDs. Drop usernames that couldn't be found. |
| 906 | - foreach ($recipients as $rec_type => $rec) |
|
| 907 | - foreach ($rec as $id => $member) |
|
| 948 | + foreach ($recipients as $rec_type => $rec) { |
|
| 949 | + foreach ($rec as $id => $member) |
|
| 908 | 950 | { |
| 909 | 951 | if (is_numeric($recipients[$rec_type][$id])) |
| 910 | 952 | continue; |
| 953 | + } |
|
| 911 | 954 | |
| 912 | - if (!empty($usernames[$member])) |
|
| 913 | - $recipients[$rec_type][$id] = $usernames[$member]; |
|
| 914 | - else |
|
| 955 | + if (!empty($usernames[$member])) { |
|
| 956 | + $recipients[$rec_type][$id] = $usernames[$member]; |
|
| 957 | + } else |
|
| 915 | 958 | { |
| 916 | 959 | $log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]); |
| 917 | 960 | unset($recipients[$rec_type][$id]); |
@@ -949,8 +992,9 @@ discard block |
||
| 949 | 992 | $delete = false; |
| 950 | 993 | foreach ($criteria as $criterium) |
| 951 | 994 | { |
| 952 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) |
|
| 953 | - $delete = true; |
|
| 995 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) { |
|
| 996 | + $delete = true; |
|
| 997 | + } |
|
| 954 | 998 | // If we're adding and one criteria don't match then we stop! |
| 955 | 999 | elseif (!$row['is_or']) |
| 956 | 1000 | { |
@@ -958,8 +1002,9 @@ discard block |
||
| 958 | 1002 | break; |
| 959 | 1003 | } |
| 960 | 1004 | } |
| 961 | - if ($delete) |
|
| 962 | - $deletes[$row['id_member']] = 1; |
|
| 1005 | + if ($delete) { |
|
| 1006 | + $deletes[$row['id_member']] = 1; |
|
| 1007 | + } |
|
| 963 | 1008 | } |
| 964 | 1009 | $smcFunc['db_free_result']($request); |
| 965 | 1010 | |
@@ -974,8 +1019,9 @@ discard block |
||
| 974 | 1019 | array( |
| 975 | 1020 | ) |
| 976 | 1021 | ); |
| 977 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 978 | - $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
| 1022 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1023 | + $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
| 1024 | + } |
|
| 979 | 1025 | $smcFunc['db_free_result']($request); |
| 980 | 1026 | } |
| 981 | 1027 | |
@@ -983,8 +1029,9 @@ discard block |
||
| 983 | 1029 | require_once($sourcedir . '/Subs-Members.php'); |
| 984 | 1030 | $pmReadGroups = groupsAllowedTo('pm_read'); |
| 985 | 1031 | |
| 986 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 987 | - $pmReadGroups['denied'] = array(); |
|
| 1032 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 1033 | + $pmReadGroups['denied'] = array(); |
|
| 1034 | + } |
|
| 988 | 1035 | |
| 989 | 1036 | // Load their alert preferences |
| 990 | 1037 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -1016,8 +1063,9 @@ discard block |
||
| 1016 | 1063 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1017 | 1064 | { |
| 1018 | 1065 | // Don't do anything for members to be deleted! |
| 1019 | - if (isset($deletes[$row['id_member']])) |
|
| 1020 | - continue; |
|
| 1066 | + if (isset($deletes[$row['id_member']])) { |
|
| 1067 | + continue; |
|
| 1068 | + } |
|
| 1021 | 1069 | |
| 1022 | 1070 | // Load the preferences for this member (if any) |
| 1023 | 1071 | $prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array(); |
@@ -1038,8 +1086,9 @@ discard block |
||
| 1038 | 1086 | { |
| 1039 | 1087 | foreach ($groups as $id) |
| 1040 | 1088 | { |
| 1041 | - if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) |
|
| 1042 | - $message_limit = $message_limit_cache[$id]; |
|
| 1089 | + if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) { |
|
| 1090 | + $message_limit = $message_limit_cache[$id]; |
|
| 1091 | + } |
|
| 1043 | 1092 | } |
| 1044 | 1093 | |
| 1045 | 1094 | if ($message_limit > 0 && $message_limit <= $row['instant_messages']) |
@@ -1087,8 +1136,9 @@ discard block |
||
| 1087 | 1136 | $smcFunc['db_free_result']($request); |
| 1088 | 1137 | |
| 1089 | 1138 | // Only 'send' the message if there are any recipients left. |
| 1090 | - if (empty($all_to)) |
|
| 1091 | - return $log; |
|
| 1139 | + if (empty($all_to)) { |
|
| 1140 | + return $log; |
|
| 1141 | + } |
|
| 1092 | 1142 | |
| 1093 | 1143 | // Insert the message itself and then grab the last insert id. |
| 1094 | 1144 | $id_pm = $smcFunc['db_insert']('', |
@@ -1109,8 +1159,8 @@ discard block |
||
| 1109 | 1159 | if (!empty($id_pm)) |
| 1110 | 1160 | { |
| 1111 | 1161 | // If this is new we need to set it part of it's own conversation. |
| 1112 | - if (empty($pm_head)) |
|
| 1113 | - $smcFunc['db_query']('', ' |
|
| 1162 | + if (empty($pm_head)) { |
|
| 1163 | + $smcFunc['db_query']('', ' |
|
| 1114 | 1164 | UPDATE {db_prefix}personal_messages |
| 1115 | 1165 | SET id_pm_head = {int:id_pm_head} |
| 1116 | 1166 | WHERE id_pm = {int:id_pm_head}', |
@@ -1118,6 +1168,7 @@ discard block |
||
| 1118 | 1168 | 'id_pm_head' => $id_pm, |
| 1119 | 1169 | ) |
| 1120 | 1170 | ); |
| 1171 | + } |
|
| 1121 | 1172 | |
| 1122 | 1173 | // Some people think manually deleting personal_messages is fun... it's not. We protect against it though :) |
| 1123 | 1174 | $smcFunc['db_query']('', ' |
@@ -1133,8 +1184,9 @@ discard block |
||
| 1133 | 1184 | foreach ($all_to as $to) |
| 1134 | 1185 | { |
| 1135 | 1186 | $insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1); |
| 1136 | - if (!in_array($to, $recipients['bcc'])) |
|
| 1137 | - $to_list[] = $to; |
|
| 1187 | + if (!in_array($to, $recipients['bcc'])) { |
|
| 1188 | + $to_list[] = $to; |
|
| 1189 | + } |
|
| 1138 | 1190 | } |
| 1139 | 1191 | |
| 1140 | 1192 | $smcFunc['db_insert']('insert', |
@@ -1152,9 +1204,9 @@ discard block |
||
| 1152 | 1204 | { |
| 1153 | 1205 | censorText($message); |
| 1154 | 1206 | $message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']'))))); |
| 1207 | + } else { |
|
| 1208 | + $message = ''; |
|
| 1155 | 1209 | } |
| 1156 | - else |
|
| 1157 | - $message = ''; |
|
| 1158 | 1210 | |
| 1159 | 1211 | $to_names = array(); |
| 1160 | 1212 | if (count($to_list) > 1) |
@@ -1167,8 +1219,9 @@ discard block |
||
| 1167 | 1219 | 'to_members' => $to_list, |
| 1168 | 1220 | ) |
| 1169 | 1221 | ); |
| 1170 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1171 | - $to_names[] = un_htmlspecialchars($row['real_name']); |
|
| 1222 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1223 | + $to_names[] = un_htmlspecialchars($row['real_name']); |
|
| 1224 | + } |
|
| 1172 | 1225 | $smcFunc['db_free_result']($request); |
| 1173 | 1226 | } |
| 1174 | 1227 | $replacements = array( |
@@ -1196,11 +1249,13 @@ discard block |
||
| 1196 | 1249 | loadLanguage('index+PersonalMessage'); |
| 1197 | 1250 | |
| 1198 | 1251 | // Add one to their unread and read message counts. |
| 1199 | - foreach ($all_to as $k => $id) |
|
| 1200 | - if (isset($deletes[$id])) |
|
| 1252 | + foreach ($all_to as $k => $id) { |
|
| 1253 | + if (isset($deletes[$id])) |
|
| 1201 | 1254 | unset($all_to[$k]); |
| 1202 | - if (!empty($all_to)) |
|
| 1203 | - updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
| 1255 | + } |
|
| 1256 | + if (!empty($all_to)) { |
|
| 1257 | + updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
| 1258 | + } |
|
| 1204 | 1259 | |
| 1205 | 1260 | return $log; |
| 1206 | 1261 | } |
@@ -1230,15 +1285,17 @@ discard block |
||
| 1230 | 1285 | // Let's, for now, assume there are only 'ish characters. |
| 1231 | 1286 | $simple = true; |
| 1232 | 1287 | |
| 1233 | - foreach ($matches[1] as $entity) |
|
| 1234 | - if ($entity > 128) |
|
| 1288 | + foreach ($matches[1] as $entity) { |
|
| 1289 | + if ($entity > 128) |
|
| 1235 | 1290 | $simple = false; |
| 1291 | + } |
|
| 1236 | 1292 | unset($matches); |
| 1237 | 1293 | |
| 1238 | - if ($simple) |
|
| 1239 | - $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
| 1294 | + if ($simple) { |
|
| 1295 | + $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
| 1240 | 1296 | { |
| 1241 | 1297 | return chr("$m[1]"); |
| 1298 | + } |
|
| 1242 | 1299 | }, $string); |
| 1243 | 1300 | else |
| 1244 | 1301 | { |
@@ -1246,8 +1303,9 @@ discard block |
||
| 1246 | 1303 | if (!$context['utf8'] && function_exists('iconv')) |
| 1247 | 1304 | { |
| 1248 | 1305 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
| 1249 | - if ($newstring) |
|
| 1250 | - $string = $newstring; |
|
| 1306 | + if ($newstring) { |
|
| 1307 | + $string = $newstring; |
|
| 1308 | + } |
|
| 1251 | 1309 | } |
| 1252 | 1310 | |
| 1253 | 1311 | $string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string); |
@@ -1263,23 +1321,25 @@ discard block |
||
| 1263 | 1321 | if (!$context['utf8'] && function_exists('iconv')) |
| 1264 | 1322 | { |
| 1265 | 1323 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
| 1266 | - if ($newstring) |
|
| 1267 | - $string = $newstring; |
|
| 1324 | + if ($newstring) { |
|
| 1325 | + $string = $newstring; |
|
| 1326 | + } |
|
| 1268 | 1327 | } |
| 1269 | 1328 | |
| 1270 | 1329 | $entityConvert = function($m) |
| 1271 | 1330 | { |
| 1272 | 1331 | $c = $m[1]; |
| 1273 | - if (strlen($c) === 1 && ord($c[0]) <= 0x7F) |
|
| 1274 | - return $c; |
|
| 1275 | - elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) |
|
| 1276 | - return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
| 1277 | - elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) |
|
| 1278 | - return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
| 1279 | - elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) |
|
| 1280 | - return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
| 1281 | - else |
|
| 1282 | - return ""; |
|
| 1332 | + if (strlen($c) === 1 && ord($c[0]) <= 0x7F) { |
|
| 1333 | + return $c; |
|
| 1334 | + } elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) { |
|
| 1335 | + return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
| 1336 | + } elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) { |
|
| 1337 | + return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
| 1338 | + } elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) { |
|
| 1339 | + return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
| 1340 | + } else { |
|
| 1341 | + return ""; |
|
| 1342 | + } |
|
| 1283 | 1343 | }; |
| 1284 | 1344 | |
| 1285 | 1345 | // Convert all 'special' characters to HTML entities. |
@@ -1293,19 +1353,20 @@ discard block |
||
| 1293 | 1353 | $string = base64_encode($string); |
| 1294 | 1354 | |
| 1295 | 1355 | // Show the characterset and the transfer-encoding for header strings. |
| 1296 | - if ($with_charset) |
|
| 1297 | - $string = '=?' . $charset . '?B?' . $string . '?='; |
|
| 1356 | + if ($with_charset) { |
|
| 1357 | + $string = '=?' . $charset . '?B?' . $string . '?='; |
|
| 1358 | + } |
|
| 1298 | 1359 | |
| 1299 | 1360 | // Break it up in lines (mail body). |
| 1300 | - else |
|
| 1301 | - $string = chunk_split($string, 76, $line_break); |
|
| 1361 | + else { |
|
| 1362 | + $string = chunk_split($string, 76, $line_break); |
|
| 1363 | + } |
|
| 1302 | 1364 | |
| 1303 | 1365 | return array($charset, $string, 'base64'); |
| 1366 | + } else { |
|
| 1367 | + return array($charset, $string, '7bit'); |
|
| 1368 | + } |
|
| 1304 | 1369 | } |
| 1305 | - |
|
| 1306 | - else |
|
| 1307 | - return array($charset, $string, '7bit'); |
|
| 1308 | -} |
|
| 1309 | 1370 | |
| 1310 | 1371 | /** |
| 1311 | 1372 | * Sends mail, like mail() but over SMTP. |
@@ -1329,8 +1390,9 @@ discard block |
||
| 1329 | 1390 | if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
| 1330 | 1391 | { |
| 1331 | 1392 | $socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2); |
| 1332 | - if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) |
|
| 1333 | - $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
| 1393 | + if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) { |
|
| 1394 | + $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
| 1395 | + } |
|
| 1334 | 1396 | |
| 1335 | 1397 | if ($socket) |
| 1336 | 1398 | { |
@@ -1351,8 +1413,9 @@ discard block |
||
| 1351 | 1413 | // Maybe we can still save this? The port might be wrong. |
| 1352 | 1414 | if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25)) |
| 1353 | 1415 | { |
| 1354 | - if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) |
|
| 1355 | - log_error($txt['smtp_port_ssl']); |
|
| 1416 | + if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) { |
|
| 1417 | + log_error($txt['smtp_port_ssl']); |
|
| 1418 | + } |
|
| 1356 | 1419 | } |
| 1357 | 1420 | |
| 1358 | 1421 | // Unable to connect! Don't show any error message, but just log one and try to continue anyway. |
@@ -1364,20 +1427,23 @@ discard block |
||
| 1364 | 1427 | } |
| 1365 | 1428 | |
| 1366 | 1429 | // Wait for a response of 220, without "-" continuer. |
| 1367 | - if (!server_parse(null, $socket, '220')) |
|
| 1368 | - return false; |
|
| 1430 | + if (!server_parse(null, $socket, '220')) { |
|
| 1431 | + return false; |
|
| 1432 | + } |
|
| 1369 | 1433 | |
| 1370 | 1434 | // Try and determine the servers name, fall back to the mail servers if not found |
| 1371 | 1435 | $helo = false; |
| 1372 | - if (function_exists('gethostname') && gethostname() !== false) |
|
| 1373 | - $helo = gethostname(); |
|
| 1374 | - elseif (function_exists('php_uname')) |
|
| 1375 | - $helo = php_uname('n'); |
|
| 1376 | - elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME'])) |
|
| 1377 | - $helo = $_SERVER['SERVER_NAME']; |
|
| 1436 | + if (function_exists('gethostname') && gethostname() !== false) { |
|
| 1437 | + $helo = gethostname(); |
|
| 1438 | + } elseif (function_exists('php_uname')) { |
|
| 1439 | + $helo = php_uname('n'); |
|
| 1440 | + } elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME'])) { |
|
| 1441 | + $helo = $_SERVER['SERVER_NAME']; |
|
| 1442 | + } |
|
| 1378 | 1443 | |
| 1379 | - if (empty($helo)) |
|
| 1380 | - $helo = $modSettings['smtp_host']; |
|
| 1444 | + if (empty($helo)) { |
|
| 1445 | + $helo = $modSettings['smtp_host']; |
|
| 1446 | + } |
|
| 1381 | 1447 | |
| 1382 | 1448 | // SMTP = 1, SMTP - STARTTLS = 2 |
| 1383 | 1449 | if (in_array($modSettings['mail_type'], array(1, 2)) && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
@@ -1389,33 +1455,39 @@ discard block |
||
| 1389 | 1455 | if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response)) |
| 1390 | 1456 | { |
| 1391 | 1457 | // Send STARTTLS to enable encryption |
| 1392 | - if (!server_parse('STARTTLS', $socket, '220')) |
|
| 1393 | - return false; |
|
| 1458 | + if (!server_parse('STARTTLS', $socket, '220')) { |
|
| 1459 | + return false; |
|
| 1460 | + } |
|
| 1394 | 1461 | // Enable the encryption |
| 1395 | - if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) |
|
| 1396 | - return false; |
|
| 1462 | + if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
|
| 1463 | + return false; |
|
| 1464 | + } |
|
| 1397 | 1465 | // Send the EHLO command again |
| 1398 | - if (!server_parse('EHLO ' . $helo, $socket, null) == '250') |
|
| 1399 | - return false; |
|
| 1466 | + if (!server_parse('EHLO ' . $helo, $socket, null) == '250') { |
|
| 1467 | + return false; |
|
| 1468 | + } |
|
| 1400 | 1469 | } |
| 1401 | 1470 | |
| 1402 | - if (!server_parse('AUTH LOGIN', $socket, '334')) |
|
| 1403 | - return false; |
|
| 1471 | + if (!server_parse('AUTH LOGIN', $socket, '334')) { |
|
| 1472 | + return false; |
|
| 1473 | + } |
|
| 1404 | 1474 | // Send the username and password, encoded. |
| 1405 | - if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) |
|
| 1406 | - return false; |
|
| 1475 | + if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) { |
|
| 1476 | + return false; |
|
| 1477 | + } |
|
| 1407 | 1478 | // The password is already encoded ;) |
| 1408 | - if (!server_parse($modSettings['smtp_password'], $socket, '235')) |
|
| 1409 | - return false; |
|
| 1479 | + if (!server_parse($modSettings['smtp_password'], $socket, '235')) { |
|
| 1480 | + return false; |
|
| 1481 | + } |
|
| 1482 | + } elseif (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
| 1483 | + return false; |
|
| 1410 | 1484 | } |
| 1411 | - elseif (!server_parse('HELO ' . $helo, $socket, '250')) |
|
| 1412 | - return false; |
|
| 1413 | - } |
|
| 1414 | - else |
|
| 1485 | + } else |
|
| 1415 | 1486 | { |
| 1416 | 1487 | // Just say "helo". |
| 1417 | - if (!server_parse('HELO ' . $helo, $socket, '250')) |
|
| 1418 | - return false; |
|
| 1488 | + if (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
| 1489 | + return false; |
|
| 1490 | + } |
|
| 1419 | 1491 | } |
| 1420 | 1492 | |
| 1421 | 1493 | // Fix the message for any lines beginning with a period! (the first is ignored, you see.) |
@@ -1428,31 +1500,38 @@ discard block |
||
| 1428 | 1500 | // Reset the connection to send another email. |
| 1429 | 1501 | if ($i != 0) |
| 1430 | 1502 | { |
| 1431 | - if (!server_parse('RSET', $socket, '250')) |
|
| 1432 | - return false; |
|
| 1503 | + if (!server_parse('RSET', $socket, '250')) { |
|
| 1504 | + return false; |
|
| 1505 | + } |
|
| 1433 | 1506 | } |
| 1434 | 1507 | |
| 1435 | 1508 | // From, to, and then start the data... |
| 1436 | - if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) |
|
| 1437 | - return false; |
|
| 1438 | - if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) |
|
| 1439 | - return false; |
|
| 1440 | - if (!server_parse('DATA', $socket, '354')) |
|
| 1441 | - return false; |
|
| 1509 | + if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) { |
|
| 1510 | + return false; |
|
| 1511 | + } |
|
| 1512 | + if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) { |
|
| 1513 | + return false; |
|
| 1514 | + } |
|
| 1515 | + if (!server_parse('DATA', $socket, '354')) { |
|
| 1516 | + return false; |
|
| 1517 | + } |
|
| 1442 | 1518 | fputs($socket, 'Subject: ' . $subject . "\r\n"); |
| 1443 | - if (strlen($mail_to) > 0) |
|
| 1444 | - fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
| 1519 | + if (strlen($mail_to) > 0) { |
|
| 1520 | + fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
| 1521 | + } |
|
| 1445 | 1522 | fputs($socket, $headers . "\r\n\r\n"); |
| 1446 | 1523 | fputs($socket, $message . "\r\n"); |
| 1447 | 1524 | |
| 1448 | 1525 | // Send a ., or in other words "end of data". |
| 1449 | - if (!server_parse('.', $socket, '250')) |
|
| 1450 | - return false; |
|
| 1526 | + if (!server_parse('.', $socket, '250')) { |
|
| 1527 | + return false; |
|
| 1528 | + } |
|
| 1451 | 1529 | |
| 1452 | 1530 | // Almost done, almost done... don't stop me just yet! |
| 1453 | 1531 | @set_time_limit(300); |
| 1454 | - if (function_exists('apache_reset_timeout')) |
|
| 1455 | - @apache_reset_timeout(); |
|
| 1532 | + if (function_exists('apache_reset_timeout')) { |
|
| 1533 | + @apache_reset_timeout(); |
|
| 1534 | + } |
|
| 1456 | 1535 | } |
| 1457 | 1536 | fputs($socket, 'QUIT' . "\r\n"); |
| 1458 | 1537 | fclose($socket); |
@@ -1476,8 +1555,9 @@ discard block |
||
| 1476 | 1555 | { |
| 1477 | 1556 | global $txt; |
| 1478 | 1557 | |
| 1479 | - if ($message !== null) |
|
| 1480 | - fputs($socket, $message . "\r\n"); |
|
| 1558 | + if ($message !== null) { |
|
| 1559 | + fputs($socket, $message . "\r\n"); |
|
| 1560 | + } |
|
| 1481 | 1561 | |
| 1482 | 1562 | // No response yet. |
| 1483 | 1563 | $server_response = ''; |
@@ -1493,8 +1573,9 @@ discard block |
||
| 1493 | 1573 | $response .= $server_response; |
| 1494 | 1574 | } |
| 1495 | 1575 | |
| 1496 | - if ($code === null) |
|
| 1497 | - return substr($server_response, 0, 3); |
|
| 1576 | + if ($code === null) { |
|
| 1577 | + return substr($server_response, 0, 3); |
|
| 1578 | + } |
|
| 1498 | 1579 | |
| 1499 | 1580 | if (substr($server_response, 0, 3) != $code) |
| 1500 | 1581 | { |
@@ -1524,8 +1605,9 @@ discard block |
||
| 1524 | 1605 | // Create a pspell or enchant dictionary resource |
| 1525 | 1606 | $dict = spell_init(); |
| 1526 | 1607 | |
| 1527 | - if (!isset($_POST['spellstring']) || !$dict) |
|
| 1528 | - die; |
|
| 1608 | + if (!isset($_POST['spellstring']) || !$dict) { |
|
| 1609 | + die; |
|
| 1610 | + } |
|
| 1529 | 1611 | |
| 1530 | 1612 | // Construct a bit of Javascript code. |
| 1531 | 1613 | $context['spell_js'] = ' |
@@ -1543,8 +1625,9 @@ discard block |
||
| 1543 | 1625 | $check_word = explode('|', $alphas[$i]); |
| 1544 | 1626 | |
| 1545 | 1627 | // If the word is a known word, or spelled right... |
| 1546 | - if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) |
|
| 1547 | - continue; |
|
| 1628 | + if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) { |
|
| 1629 | + continue; |
|
| 1630 | + } |
|
| 1548 | 1631 | |
| 1549 | 1632 | // Find the word, and move up the "last occurrence" to here. |
| 1550 | 1633 | $found_words = true; |
@@ -1558,20 +1641,23 @@ discard block |
||
| 1558 | 1641 | if (!empty($suggestions)) |
| 1559 | 1642 | { |
| 1560 | 1643 | // But first check they aren't going to be censored - no naughty words! |
| 1561 | - foreach ($suggestions as $k => $word) |
|
| 1562 | - if ($suggestions[$k] != censorText($word)) |
|
| 1644 | + foreach ($suggestions as $k => $word) { |
|
| 1645 | + if ($suggestions[$k] != censorText($word)) |
|
| 1563 | 1646 | unset($suggestions[$k]); |
| 1647 | + } |
|
| 1564 | 1648 | |
| 1565 | - if (!empty($suggestions)) |
|
| 1566 | - $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
| 1649 | + if (!empty($suggestions)) { |
|
| 1650 | + $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
| 1651 | + } |
|
| 1567 | 1652 | } |
| 1568 | 1653 | |
| 1569 | 1654 | $context['spell_js'] .= ']),'; |
| 1570 | 1655 | } |
| 1571 | 1656 | |
| 1572 | 1657 | // If words were found, take off the last comma. |
| 1573 | - if ($found_words) |
|
| 1574 | - $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
| 1658 | + if ($found_words) { |
|
| 1659 | + $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
| 1660 | + } |
|
| 1575 | 1661 | |
| 1576 | 1662 | $context['spell_js'] .= ' |
| 1577 | 1663 | );'; |
@@ -1606,11 +1692,13 @@ discard block |
||
| 1606 | 1692 | global $user_info, $smcFunc; |
| 1607 | 1693 | |
| 1608 | 1694 | // Can't do it if there's no topics. |
| 1609 | - if (empty($topics)) |
|
| 1610 | - return; |
|
| 1695 | + if (empty($topics)) { |
|
| 1696 | + return; |
|
| 1697 | + } |
|
| 1611 | 1698 | // It must be an array - it must! |
| 1612 | - if (!is_array($topics)) |
|
| 1613 | - $topics = array($topics); |
|
| 1699 | + if (!is_array($topics)) { |
|
| 1700 | + $topics = array($topics); |
|
| 1701 | + } |
|
| 1614 | 1702 | |
| 1615 | 1703 | // Get the subject and body... |
| 1616 | 1704 | $result = $smcFunc['db_query']('', ' |
@@ -1658,14 +1746,15 @@ discard block |
||
| 1658 | 1746 | } |
| 1659 | 1747 | $smcFunc['db_free_result']($result); |
| 1660 | 1748 | |
| 1661 | - if (!empty($task_rows)) |
|
| 1662 | - $smcFunc['db_insert']('', |
|
| 1749 | + if (!empty($task_rows)) { |
|
| 1750 | + $smcFunc['db_insert']('', |
|
| 1663 | 1751 | '{db_prefix}background_tasks', |
| 1664 | 1752 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 1665 | 1753 | $task_rows, |
| 1666 | 1754 | array('id_task') |
| 1667 | 1755 | ); |
| 1668 | -} |
|
| 1756 | + } |
|
| 1757 | + } |
|
| 1669 | 1758 | |
| 1670 | 1759 | /** |
| 1671 | 1760 | * Create a post, either as new topic (id_topic = 0) or in an existing one. |
@@ -1703,9 +1792,9 @@ discard block |
||
| 1703 | 1792 | $msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true; |
| 1704 | 1793 | |
| 1705 | 1794 | // We need to know if the topic is approved. If we're told that's great - if not find out. |
| 1706 | - if (!$modSettings['postmod_active']) |
|
| 1707 | - $topicOptions['is_approved'] = true; |
|
| 1708 | - elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
| 1795 | + if (!$modSettings['postmod_active']) { |
|
| 1796 | + $topicOptions['is_approved'] = true; |
|
| 1797 | + } elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
| 1709 | 1798 | { |
| 1710 | 1799 | $request = $smcFunc['db_query']('', ' |
| 1711 | 1800 | SELECT approved |
@@ -1728,8 +1817,7 @@ discard block |
||
| 1728 | 1817 | $posterOptions['id'] = 0; |
| 1729 | 1818 | $posterOptions['name'] = $txt['guest_title']; |
| 1730 | 1819 | $posterOptions['email'] = ''; |
| 1731 | - } |
|
| 1732 | - elseif ($posterOptions['id'] != $user_info['id']) |
|
| 1820 | + } elseif ($posterOptions['id'] != $user_info['id']) |
|
| 1733 | 1821 | { |
| 1734 | 1822 | $request = $smcFunc['db_query']('', ' |
| 1735 | 1823 | SELECT member_name, email_address |
@@ -1747,12 +1835,11 @@ discard block |
||
| 1747 | 1835 | $posterOptions['id'] = 0; |
| 1748 | 1836 | $posterOptions['name'] = $txt['guest_title']; |
| 1749 | 1837 | $posterOptions['email'] = ''; |
| 1838 | + } else { |
|
| 1839 | + list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
| 1750 | 1840 | } |
| 1751 | - else |
|
| 1752 | - list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
| 1753 | 1841 | $smcFunc['db_free_result']($request); |
| 1754 | - } |
|
| 1755 | - else |
|
| 1842 | + } else |
|
| 1756 | 1843 | { |
| 1757 | 1844 | $posterOptions['name'] = $user_info['name']; |
| 1758 | 1845 | $posterOptions['email'] = $user_info['email']; |
@@ -1762,8 +1849,9 @@ discard block |
||
| 1762 | 1849 | if (!empty($modSettings['enable_mentions'])) |
| 1763 | 1850 | { |
| 1764 | 1851 | $msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']); |
| 1765 | - if (!empty($msgOptions['mentioned_members'])) |
|
| 1766 | - $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
| 1852 | + if (!empty($msgOptions['mentioned_members'])) { |
|
| 1853 | + $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
| 1854 | + } |
|
| 1767 | 1855 | } |
| 1768 | 1856 | |
| 1769 | 1857 | // It's do or die time: forget any user aborts! |
@@ -1796,12 +1884,13 @@ discard block |
||
| 1796 | 1884 | ); |
| 1797 | 1885 | |
| 1798 | 1886 | // Something went wrong creating the message... |
| 1799 | - if (empty($msgOptions['id'])) |
|
| 1800 | - return false; |
|
| 1887 | + if (empty($msgOptions['id'])) { |
|
| 1888 | + return false; |
|
| 1889 | + } |
|
| 1801 | 1890 | |
| 1802 | 1891 | // Fix the attachments. |
| 1803 | - if (!empty($msgOptions['attachments'])) |
|
| 1804 | - $smcFunc['db_query']('', ' |
|
| 1892 | + if (!empty($msgOptions['attachments'])) { |
|
| 1893 | + $smcFunc['db_query']('', ' |
|
| 1805 | 1894 | UPDATE {db_prefix}attachments |
| 1806 | 1895 | SET id_msg = {int:id_msg} |
| 1807 | 1896 | WHERE id_attach IN ({array_int:attachment_list})', |
@@ -1810,6 +1899,7 @@ discard block |
||
| 1810 | 1899 | 'id_msg' => $msgOptions['id'], |
| 1811 | 1900 | ) |
| 1812 | 1901 | ); |
| 1902 | + } |
|
| 1813 | 1903 | |
| 1814 | 1904 | // What if we want to export new posts out to a CMS? |
| 1815 | 1905 | call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); |
@@ -1886,20 +1976,23 @@ discard block |
||
| 1886 | 1976 | 'id_topic' => $topicOptions['id'], |
| 1887 | 1977 | 'counter_increment' => 1, |
| 1888 | 1978 | ); |
| 1889 | - if ($msgOptions['approved']) |
|
| 1890 | - $topics_columns = array( |
|
| 1979 | + if ($msgOptions['approved']) { |
|
| 1980 | + $topics_columns = array( |
|
| 1891 | 1981 | 'id_member_updated = {int:poster_id}', |
| 1892 | 1982 | 'id_last_msg = {int:id_msg}', |
| 1893 | 1983 | 'num_replies = num_replies + {int:counter_increment}', |
| 1894 | 1984 | ); |
| 1895 | - else |
|
| 1896 | - $topics_columns = array( |
|
| 1985 | + } else { |
|
| 1986 | + $topics_columns = array( |
|
| 1897 | 1987 | 'unapproved_posts = unapproved_posts + {int:counter_increment}', |
| 1898 | 1988 | ); |
| 1899 | - if ($topicOptions['lock_mode'] !== null) |
|
| 1900 | - $topics_columns[] = 'locked = {int:locked}'; |
|
| 1901 | - if ($topicOptions['sticky_mode'] !== null) |
|
| 1902 | - $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
| 1989 | + } |
|
| 1990 | + if ($topicOptions['lock_mode'] !== null) { |
|
| 1991 | + $topics_columns[] = 'locked = {int:locked}'; |
|
| 1992 | + } |
|
| 1993 | + if ($topicOptions['sticky_mode'] !== null) { |
|
| 1994 | + $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
| 1995 | + } |
|
| 1903 | 1996 | |
| 1904 | 1997 | call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); |
| 1905 | 1998 | |
@@ -1928,8 +2021,8 @@ discard block |
||
| 1928 | 2021 | ); |
| 1929 | 2022 | |
| 1930 | 2023 | // Increase the number of posts and topics on the board. |
| 1931 | - if ($msgOptions['approved']) |
|
| 1932 | - $smcFunc['db_query']('', ' |
|
| 2024 | + if ($msgOptions['approved']) { |
|
| 2025 | + $smcFunc['db_query']('', ' |
|
| 1933 | 2026 | UPDATE {db_prefix}boards |
| 1934 | 2027 | SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . ' |
| 1935 | 2028 | WHERE id_board = {int:id_board}', |
@@ -1937,7 +2030,7 @@ discard block |
||
| 1937 | 2030 | 'id_board' => $topicOptions['board'], |
| 1938 | 2031 | ) |
| 1939 | 2032 | ); |
| 1940 | - else |
|
| 2033 | + } else |
|
| 1941 | 2034 | { |
| 1942 | 2035 | $smcFunc['db_query']('', ' |
| 1943 | 2036 | UPDATE {db_prefix}boards |
@@ -2007,8 +2100,8 @@ discard block |
||
| 2007 | 2100 | } |
| 2008 | 2101 | } |
| 2009 | 2102 | |
| 2010 | - if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) |
|
| 2011 | - $smcFunc['db_insert']('', |
|
| 2103 | + if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) { |
|
| 2104 | + $smcFunc['db_insert']('', |
|
| 2012 | 2105 | '{db_prefix}background_tasks', |
| 2013 | 2106 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 2014 | 2107 | array( |
@@ -2020,19 +2113,22 @@ discard block |
||
| 2020 | 2113 | ), |
| 2021 | 2114 | array('id_task') |
| 2022 | 2115 | ); |
| 2116 | + } |
|
| 2023 | 2117 | |
| 2024 | 2118 | // If there's a custom search index, it may need updating... |
| 2025 | 2119 | require_once($sourcedir . '/Search.php'); |
| 2026 | 2120 | $searchAPI = findSearchAPI(); |
| 2027 | - if (is_callable(array($searchAPI, 'postCreated'))) |
|
| 2028 | - $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
| 2121 | + if (is_callable(array($searchAPI, 'postCreated'))) { |
|
| 2122 | + $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
| 2123 | + } |
|
| 2029 | 2124 | |
| 2030 | 2125 | // Increase the post counter for the user that created the post. |
| 2031 | 2126 | if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved']) |
| 2032 | 2127 | { |
| 2033 | 2128 | // Are you the one that happened to create this post? |
| 2034 | - if ($user_info['id'] == $posterOptions['id']) |
|
| 2035 | - $user_info['posts']++; |
|
| 2129 | + if ($user_info['id'] == $posterOptions['id']) { |
|
| 2130 | + $user_info['posts']++; |
|
| 2131 | + } |
|
| 2036 | 2132 | updateMemberData($posterOptions['id'], array('posts' => '+')); |
| 2037 | 2133 | } |
| 2038 | 2134 | |
@@ -2040,19 +2136,21 @@ discard block |
||
| 2040 | 2136 | $_SESSION['last_read_topic'] = 0; |
| 2041 | 2137 | |
| 2042 | 2138 | // Better safe than sorry. |
| 2043 | - if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) |
|
| 2044 | - $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
| 2139 | + if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) { |
|
| 2140 | + $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
| 2141 | + } |
|
| 2045 | 2142 | |
| 2046 | 2143 | // Update all the stats so everyone knows about this new topic and message. |
| 2047 | 2144 | updateStats('message', true, $msgOptions['id']); |
| 2048 | 2145 | |
| 2049 | 2146 | // Update the last message on the board assuming it's approved AND the topic is. |
| 2050 | - if ($msgOptions['approved']) |
|
| 2051 | - updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
| 2147 | + if ($msgOptions['approved']) { |
|
| 2148 | + updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
| 2149 | + } |
|
| 2052 | 2150 | |
| 2053 | 2151 | // Queue createPost background notification |
| 2054 | - if ($msgOptions['send_notifications'] && $msgOptions['approved']) |
|
| 2055 | - $smcFunc['db_insert']('', |
|
| 2152 | + if ($msgOptions['send_notifications'] && $msgOptions['approved']) { |
|
| 2153 | + $smcFunc['db_insert']('', |
|
| 2056 | 2154 | '{db_prefix}background_tasks', |
| 2057 | 2155 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 2058 | 2156 | array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
@@ -2063,6 +2161,7 @@ discard block |
||
| 2063 | 2161 | )), 0), |
| 2064 | 2162 | array('id_task') |
| 2065 | 2163 | ); |
| 2164 | + } |
|
| 2066 | 2165 | |
| 2067 | 2166 | // Alright, done now... we can abort now, I guess... at least this much is done. |
| 2068 | 2167 | ignore_user_abort($previous_ignore_user_abort); |
@@ -2089,14 +2188,18 @@ discard block |
||
| 2089 | 2188 | |
| 2090 | 2189 | // This is longer than it has to be, but makes it so we only set/change what we have to. |
| 2091 | 2190 | $messages_columns = array(); |
| 2092 | - if (isset($posterOptions['name'])) |
|
| 2093 | - $messages_columns['poster_name'] = $posterOptions['name']; |
|
| 2094 | - if (isset($posterOptions['email'])) |
|
| 2095 | - $messages_columns['poster_email'] = $posterOptions['email']; |
|
| 2096 | - if (isset($msgOptions['icon'])) |
|
| 2097 | - $messages_columns['icon'] = $msgOptions['icon']; |
|
| 2098 | - if (isset($msgOptions['subject'])) |
|
| 2099 | - $messages_columns['subject'] = $msgOptions['subject']; |
|
| 2191 | + if (isset($posterOptions['name'])) { |
|
| 2192 | + $messages_columns['poster_name'] = $posterOptions['name']; |
|
| 2193 | + } |
|
| 2194 | + if (isset($posterOptions['email'])) { |
|
| 2195 | + $messages_columns['poster_email'] = $posterOptions['email']; |
|
| 2196 | + } |
|
| 2197 | + if (isset($msgOptions['icon'])) { |
|
| 2198 | + $messages_columns['icon'] = $msgOptions['icon']; |
|
| 2199 | + } |
|
| 2200 | + if (isset($msgOptions['subject'])) { |
|
| 2201 | + $messages_columns['subject'] = $msgOptions['subject']; |
|
| 2202 | + } |
|
| 2100 | 2203 | if (isset($msgOptions['body'])) |
| 2101 | 2204 | { |
| 2102 | 2205 | $messages_columns['body'] = $msgOptions['body']; |
@@ -2123,8 +2226,9 @@ discard block |
||
| 2123 | 2226 | $messages_columns['modified_reason'] = $msgOptions['modify_reason']; |
| 2124 | 2227 | $messages_columns['id_msg_modified'] = $modSettings['maxMsgID']; |
| 2125 | 2228 | } |
| 2126 | - if (isset($msgOptions['smileys_enabled'])) |
|
| 2127 | - $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
| 2229 | + if (isset($msgOptions['smileys_enabled'])) { |
|
| 2230 | + $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
| 2231 | + } |
|
| 2128 | 2232 | |
| 2129 | 2233 | // Which columns need to be ints? |
| 2130 | 2234 | $messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled'); |
@@ -2142,23 +2246,27 @@ discard block |
||
| 2142 | 2246 | { |
| 2143 | 2247 | preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match); |
| 2144 | 2248 | |
| 2145 | - if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) |
|
| 2146 | - foreach ($match[1] as $i => $oldID) |
|
| 2249 | + if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) { |
|
| 2250 | + foreach ($match[1] as $i => $oldID) |
|
| 2147 | 2251 | $oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]); |
| 2252 | + } |
|
| 2148 | 2253 | |
| 2149 | - if (empty($modSettings['search_custom_index_config'])) |
|
| 2150 | - unset($msgOptions['old_body']); |
|
| 2254 | + if (empty($modSettings['search_custom_index_config'])) { |
|
| 2255 | + unset($msgOptions['old_body']); |
|
| 2256 | + } |
|
| 2151 | 2257 | } |
| 2152 | 2258 | |
| 2153 | 2259 | $mentions = Mentions::getMentionedMembers($msgOptions['body']); |
| 2154 | 2260 | $messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions); |
| 2155 | 2261 | |
| 2156 | 2262 | // Remove the poster. |
| 2157 | - if (isset($mentions[$user_info['id']])) |
|
| 2158 | - unset($mentions[$user_info['id']]); |
|
| 2263 | + if (isset($mentions[$user_info['id']])) { |
|
| 2264 | + unset($mentions[$user_info['id']]); |
|
| 2265 | + } |
|
| 2159 | 2266 | |
| 2160 | - if (isset($oldmentions[$user_info['id']])) |
|
| 2161 | - unset($oldmentions[$user_info['id']]); |
|
| 2267 | + if (isset($oldmentions[$user_info['id']])) { |
|
| 2268 | + unset($oldmentions[$user_info['id']]); |
|
| 2269 | + } |
|
| 2162 | 2270 | |
| 2163 | 2271 | if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions)) |
| 2164 | 2272 | { |
@@ -2188,8 +2296,9 @@ discard block |
||
| 2188 | 2296 | } |
| 2189 | 2297 | |
| 2190 | 2298 | // Nothing to do? |
| 2191 | - if (empty($messages_columns)) |
|
| 2192 | - return true; |
|
| 2299 | + if (empty($messages_columns)) { |
|
| 2300 | + return true; |
|
| 2301 | + } |
|
| 2193 | 2302 | |
| 2194 | 2303 | // Change the post. |
| 2195 | 2304 | $smcFunc['db_query']('', ' |
@@ -2250,8 +2359,9 @@ discard block |
||
| 2250 | 2359 | // If there's a custom search index, it needs to be modified... |
| 2251 | 2360 | require_once($sourcedir . '/Search.php'); |
| 2252 | 2361 | $searchAPI = findSearchAPI(); |
| 2253 | - if (is_callable(array($searchAPI, 'postModified'))) |
|
| 2254 | - $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
| 2362 | + if (is_callable(array($searchAPI, 'postModified'))) { |
|
| 2363 | + $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
| 2364 | + } |
|
| 2255 | 2365 | |
| 2256 | 2366 | if (isset($msgOptions['subject'])) |
| 2257 | 2367 | { |
@@ -2265,14 +2375,16 @@ discard block |
||
| 2265 | 2375 | 'id_first_msg' => $msgOptions['id'], |
| 2266 | 2376 | ) |
| 2267 | 2377 | ); |
| 2268 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 2269 | - updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
| 2378 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 2379 | + updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
| 2380 | + } |
|
| 2270 | 2381 | $smcFunc['db_free_result']($request); |
| 2271 | 2382 | } |
| 2272 | 2383 | |
| 2273 | 2384 | // Finally, if we are setting the approved state we need to do much more work :( |
| 2274 | - if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) |
|
| 2275 | - approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
| 2385 | + if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) { |
|
| 2386 | + approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
| 2387 | + } |
|
| 2276 | 2388 | |
| 2277 | 2389 | return true; |
| 2278 | 2390 | } |
@@ -2289,11 +2401,13 @@ discard block |
||
| 2289 | 2401 | { |
| 2290 | 2402 | global $smcFunc; |
| 2291 | 2403 | |
| 2292 | - if (!is_array($msgs)) |
|
| 2293 | - $msgs = array($msgs); |
|
| 2404 | + if (!is_array($msgs)) { |
|
| 2405 | + $msgs = array($msgs); |
|
| 2406 | + } |
|
| 2294 | 2407 | |
| 2295 | - if (empty($msgs)) |
|
| 2296 | - return false; |
|
| 2408 | + if (empty($msgs)) { |
|
| 2409 | + return false; |
|
| 2410 | + } |
|
| 2297 | 2411 | |
| 2298 | 2412 | // May as well start at the beginning, working out *what* we need to change. |
| 2299 | 2413 | $request = $smcFunc['db_query']('', ' |
@@ -2325,20 +2439,22 @@ discard block |
||
| 2325 | 2439 | $topics[] = $row['id_topic']; |
| 2326 | 2440 | |
| 2327 | 2441 | // Ensure our change array exists already. |
| 2328 | - if (!isset($topic_changes[$row['id_topic']])) |
|
| 2329 | - $topic_changes[$row['id_topic']] = array( |
|
| 2442 | + if (!isset($topic_changes[$row['id_topic']])) { |
|
| 2443 | + $topic_changes[$row['id_topic']] = array( |
|
| 2330 | 2444 | 'id_last_msg' => $row['id_last_msg'], |
| 2331 | 2445 | 'approved' => $row['topic_approved'], |
| 2332 | 2446 | 'replies' => 0, |
| 2333 | 2447 | 'unapproved_posts' => 0, |
| 2334 | 2448 | ); |
| 2335 | - if (!isset($board_changes[$row['id_board']])) |
|
| 2336 | - $board_changes[$row['id_board']] = array( |
|
| 2449 | + } |
|
| 2450 | + if (!isset($board_changes[$row['id_board']])) { |
|
| 2451 | + $board_changes[$row['id_board']] = array( |
|
| 2337 | 2452 | 'posts' => 0, |
| 2338 | 2453 | 'topics' => 0, |
| 2339 | 2454 | 'unapproved_posts' => 0, |
| 2340 | 2455 | 'unapproved_topics' => 0, |
| 2341 | 2456 | ); |
| 2457 | + } |
|
| 2342 | 2458 | |
| 2343 | 2459 | // If it's the first message then the topic state changes! |
| 2344 | 2460 | if ($row['id_msg'] == $row['id_first_msg']) |
@@ -2359,14 +2475,13 @@ discard block |
||
| 2359 | 2475 | 'poster' => $row['id_member'], |
| 2360 | 2476 | 'new_topic' => true, |
| 2361 | 2477 | ); |
| 2362 | - } |
|
| 2363 | - else |
|
| 2478 | + } else |
|
| 2364 | 2479 | { |
| 2365 | 2480 | $topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1; |
| 2366 | 2481 | |
| 2367 | 2482 | // This will be a post... but don't notify unless it's not followed by approved ones. |
| 2368 | - if ($row['id_msg'] > $row['id_last_msg']) |
|
| 2369 | - $notification_posts[$row['id_topic']] = array( |
|
| 2483 | + if ($row['id_msg'] > $row['id_last_msg']) { |
|
| 2484 | + $notification_posts[$row['id_topic']] = array( |
|
| 2370 | 2485 | 'id' => $row['id_msg'], |
| 2371 | 2486 | 'body' => $row['body'], |
| 2372 | 2487 | 'subject' => $row['subject'], |
@@ -2377,28 +2492,33 @@ discard block |
||
| 2377 | 2492 | 'new_topic' => false, |
| 2378 | 2493 | 'msg' => $row['id_msg'], |
| 2379 | 2494 | ); |
| 2495 | + } |
|
| 2380 | 2496 | } |
| 2381 | 2497 | |
| 2382 | 2498 | // If this is being approved and id_msg is higher than the current id_last_msg then it changes. |
| 2383 | - if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) |
|
| 2384 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
| 2499 | + if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) { |
|
| 2500 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
| 2501 | + } |
|
| 2385 | 2502 | // If this is being unapproved, and it's equal to the id_last_msg we need to find a new one! |
| 2386 | - elseif (!$approve) |
|
| 2387 | - // Default to the first message and then we'll override in a bit ;) |
|
| 2503 | + elseif (!$approve) { |
|
| 2504 | + // Default to the first message and then we'll override in a bit ;) |
|
| 2388 | 2505 | $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg']; |
| 2506 | + } |
|
| 2389 | 2507 | |
| 2390 | 2508 | $topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1; |
| 2391 | 2509 | $board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1; |
| 2392 | 2510 | $board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1; |
| 2393 | 2511 | |
| 2394 | 2512 | // Post count for the user? |
| 2395 | - if ($row['id_member'] && empty($row['count_posts'])) |
|
| 2396 | - $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
| 2513 | + if ($row['id_member'] && empty($row['count_posts'])) { |
|
| 2514 | + $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
| 2515 | + } |
|
| 2397 | 2516 | } |
| 2398 | 2517 | $smcFunc['db_free_result']($request); |
| 2399 | 2518 | |
| 2400 | - if (empty($msgs)) |
|
| 2401 | - return; |
|
| 2519 | + if (empty($msgs)) { |
|
| 2520 | + return; |
|
| 2521 | + } |
|
| 2402 | 2522 | |
| 2403 | 2523 | // Now we have the differences make the changes, first the easy one. |
| 2404 | 2524 | $smcFunc['db_query']('', ' |
@@ -2425,14 +2545,15 @@ discard block |
||
| 2425 | 2545 | 'approved' => 1, |
| 2426 | 2546 | ) |
| 2427 | 2547 | ); |
| 2428 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2429 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
| 2548 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2549 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
| 2550 | + } |
|
| 2430 | 2551 | $smcFunc['db_free_result']($request); |
| 2431 | 2552 | } |
| 2432 | 2553 | |
| 2433 | 2554 | // ... next the topics... |
| 2434 | - foreach ($topic_changes as $id => $changes) |
|
| 2435 | - $smcFunc['db_query']('', ' |
|
| 2555 | + foreach ($topic_changes as $id => $changes) { |
|
| 2556 | + $smcFunc['db_query']('', ' |
|
| 2436 | 2557 | UPDATE {db_prefix}topics |
| 2437 | 2558 | SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
| 2438 | 2559 | num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg} |
@@ -2445,10 +2566,11 @@ discard block |
||
| 2445 | 2566 | 'id_topic' => $id, |
| 2446 | 2567 | ) |
| 2447 | 2568 | ); |
| 2569 | + } |
|
| 2448 | 2570 | |
| 2449 | 2571 | // ... finally the boards... |
| 2450 | - foreach ($board_changes as $id => $changes) |
|
| 2451 | - $smcFunc['db_query']('', ' |
|
| 2572 | + foreach ($board_changes as $id => $changes) { |
|
| 2573 | + $smcFunc['db_query']('', ' |
|
| 2452 | 2574 | UPDATE {db_prefix}boards |
| 2453 | 2575 | SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
| 2454 | 2576 | num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics} |
@@ -2461,13 +2583,14 @@ discard block |
||
| 2461 | 2583 | 'id_board' => $id, |
| 2462 | 2584 | ) |
| 2463 | 2585 | ); |
| 2586 | + } |
|
| 2464 | 2587 | |
| 2465 | 2588 | // Finally, least importantly, notifications! |
| 2466 | 2589 | if ($approve) |
| 2467 | 2590 | { |
| 2468 | 2591 | $task_rows = array(); |
| 2469 | - foreach (array_merge($notification_topics, $notification_posts) as $topic) |
|
| 2470 | - $task_rows[] = array( |
|
| 2592 | + foreach (array_merge($notification_topics, $notification_posts) as $topic) { |
|
| 2593 | + $task_rows[] = array( |
|
| 2471 | 2594 | '$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
| 2472 | 2595 | 'msgOptions' => array( |
| 2473 | 2596 | 'id' => $topic['msg'], |
@@ -2485,14 +2608,16 @@ discard block |
||
| 2485 | 2608 | 'type' => $topic['new_topic'] ? 'topic' : 'reply', |
| 2486 | 2609 | )), 0 |
| 2487 | 2610 | ); |
| 2611 | + } |
|
| 2488 | 2612 | |
| 2489 | - if ($notify) |
|
| 2490 | - $smcFunc['db_insert']('', |
|
| 2613 | + if ($notify) { |
|
| 2614 | + $smcFunc['db_insert']('', |
|
| 2491 | 2615 | '{db_prefix}background_tasks', |
| 2492 | 2616 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 2493 | 2617 | $task_rows, |
| 2494 | 2618 | array('id_task') |
| 2495 | 2619 | ); |
| 2620 | + } |
|
| 2496 | 2621 | |
| 2497 | 2622 | $smcFunc['db_query']('', ' |
| 2498 | 2623 | DELETE FROM {db_prefix}approval_queue |
@@ -2508,8 +2633,9 @@ discard block |
||
| 2508 | 2633 | else |
| 2509 | 2634 | { |
| 2510 | 2635 | $msgInserts = array(); |
| 2511 | - foreach ($msgs as $msg) |
|
| 2512 | - $msgInserts[] = array($msg); |
|
| 2636 | + foreach ($msgs as $msg) { |
|
| 2637 | + $msgInserts[] = array($msg); |
|
| 2638 | + } |
|
| 2513 | 2639 | |
| 2514 | 2640 | $smcFunc['db_insert']('ignore', |
| 2515 | 2641 | '{db_prefix}approval_queue', |
@@ -2523,9 +2649,10 @@ discard block |
||
| 2523 | 2649 | updateLastMessages(array_keys($board_changes)); |
| 2524 | 2650 | |
| 2525 | 2651 | // Post count for the members? |
| 2526 | - if (!empty($member_post_changes)) |
|
| 2527 | - foreach ($member_post_changes as $id_member => $count_change) |
|
| 2652 | + if (!empty($member_post_changes)) { |
|
| 2653 | + foreach ($member_post_changes as $id_member => $count_change) |
|
| 2528 | 2654 | updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change)); |
| 2655 | + } |
|
| 2529 | 2656 | |
| 2530 | 2657 | return true; |
| 2531 | 2658 | } |
@@ -2542,11 +2669,13 @@ discard block |
||
| 2542 | 2669 | { |
| 2543 | 2670 | global $smcFunc; |
| 2544 | 2671 | |
| 2545 | - if (!is_array($topics)) |
|
| 2546 | - $topics = array($topics); |
|
| 2672 | + if (!is_array($topics)) { |
|
| 2673 | + $topics = array($topics); |
|
| 2674 | + } |
|
| 2547 | 2675 | |
| 2548 | - if (empty($topics)) |
|
| 2549 | - return false; |
|
| 2676 | + if (empty($topics)) { |
|
| 2677 | + return false; |
|
| 2678 | + } |
|
| 2550 | 2679 | |
| 2551 | 2680 | $approve_type = $approve ? 0 : 1; |
| 2552 | 2681 | |
@@ -2562,8 +2691,9 @@ discard block |
||
| 2562 | 2691 | ) |
| 2563 | 2692 | ); |
| 2564 | 2693 | $msgs = array(); |
| 2565 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2566 | - $msgs[] = $row['id_msg']; |
|
| 2694 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2695 | + $msgs[] = $row['id_msg']; |
|
| 2696 | + } |
|
| 2567 | 2697 | $smcFunc['db_free_result']($request); |
| 2568 | 2698 | |
| 2569 | 2699 | return approvePosts($msgs, $approve); |
@@ -2586,11 +2716,13 @@ discard block |
||
| 2586 | 2716 | global $board_info, $board, $smcFunc; |
| 2587 | 2717 | |
| 2588 | 2718 | // Please - let's be sane. |
| 2589 | - if (empty($setboards)) |
|
| 2590 | - return false; |
|
| 2719 | + if (empty($setboards)) { |
|
| 2720 | + return false; |
|
| 2721 | + } |
|
| 2591 | 2722 | |
| 2592 | - if (!is_array($setboards)) |
|
| 2593 | - $setboards = array($setboards); |
|
| 2723 | + if (!is_array($setboards)) { |
|
| 2724 | + $setboards = array($setboards); |
|
| 2725 | + } |
|
| 2594 | 2726 | |
| 2595 | 2727 | // If we don't know the id_msg we need to find it. |
| 2596 | 2728 | if (!$id_msg) |
@@ -2608,15 +2740,16 @@ discard block |
||
| 2608 | 2740 | ) |
| 2609 | 2741 | ); |
| 2610 | 2742 | $lastMsg = array(); |
| 2611 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2612 | - $lastMsg[$row['id_board']] = $row['id_msg']; |
|
| 2743 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2744 | + $lastMsg[$row['id_board']] = $row['id_msg']; |
|
| 2745 | + } |
|
| 2613 | 2746 | $smcFunc['db_free_result']($request); |
| 2614 | - } |
|
| 2615 | - else |
|
| 2747 | + } else |
|
| 2616 | 2748 | { |
| 2617 | 2749 | // Just to note - there should only be one board passed if we are doing this. |
| 2618 | - foreach ($setboards as $id_board) |
|
| 2619 | - $lastMsg[$id_board] = $id_msg; |
|
| 2750 | + foreach ($setboards as $id_board) { |
|
| 2751 | + $lastMsg[$id_board] = $id_msg; |
|
| 2752 | + } |
|
| 2620 | 2753 | } |
| 2621 | 2754 | |
| 2622 | 2755 | $parent_boards = array(); |
@@ -2631,10 +2764,11 @@ discard block |
||
| 2631 | 2764 | $lastModified[$id_board] = 0; |
| 2632 | 2765 | } |
| 2633 | 2766 | |
| 2634 | - if (!empty($board) && $id_board == $board) |
|
| 2635 | - $parents = $board_info['parent_boards']; |
|
| 2636 | - else |
|
| 2637 | - $parents = getBoardParents($id_board); |
|
| 2767 | + if (!empty($board) && $id_board == $board) { |
|
| 2768 | + $parents = $board_info['parent_boards']; |
|
| 2769 | + } else { |
|
| 2770 | + $parents = getBoardParents($id_board); |
|
| 2771 | + } |
|
| 2638 | 2772 | |
| 2639 | 2773 | // Ignore any parents on the top child level. |
| 2640 | 2774 | // @todo Why? |
@@ -2643,10 +2777,11 @@ discard block |
||
| 2643 | 2777 | if ($parent['level'] != 0) |
| 2644 | 2778 | { |
| 2645 | 2779 | // If we're already doing this one as a board, is this a higher last modified? |
| 2646 | - if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) |
|
| 2647 | - $lastModified[$id] = $lastModified[$id_board]; |
|
| 2648 | - elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) |
|
| 2649 | - $parent_boards[$id] = $lastModified[$id_board]; |
|
| 2780 | + if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) { |
|
| 2781 | + $lastModified[$id] = $lastModified[$id_board]; |
|
| 2782 | + } elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) { |
|
| 2783 | + $parent_boards[$id] = $lastModified[$id_board]; |
|
| 2784 | + } |
|
| 2650 | 2785 | } |
| 2651 | 2786 | } |
| 2652 | 2787 | } |
@@ -2659,23 +2794,24 @@ discard block |
||
| 2659 | 2794 | // Finally, to save on queries make the changes... |
| 2660 | 2795 | foreach ($parent_boards as $id => $msg) |
| 2661 | 2796 | { |
| 2662 | - if (!isset($parent_updates[$msg])) |
|
| 2663 | - $parent_updates[$msg] = array($id); |
|
| 2664 | - else |
|
| 2665 | - $parent_updates[$msg][] = $id; |
|
| 2797 | + if (!isset($parent_updates[$msg])) { |
|
| 2798 | + $parent_updates[$msg] = array($id); |
|
| 2799 | + } else { |
|
| 2800 | + $parent_updates[$msg][] = $id; |
|
| 2801 | + } |
|
| 2666 | 2802 | } |
| 2667 | 2803 | |
| 2668 | 2804 | foreach ($lastMsg as $id => $msg) |
| 2669 | 2805 | { |
| 2670 | - if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) |
|
| 2671 | - $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
| 2806 | + if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) { |
|
| 2807 | + $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
| 2672 | 2808 | 'id' => $msg, |
| 2673 | 2809 | 'updated' => $lastModified[$id], |
| 2674 | 2810 | 'boards' => array($id) |
| 2675 | 2811 | ); |
| 2676 | - |
|
| 2677 | - else |
|
| 2678 | - $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
| 2812 | + } else { |
|
| 2813 | + $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
| 2814 | + } |
|
| 2679 | 2815 | } |
| 2680 | 2816 | |
| 2681 | 2817 | // Now commit the changes! |
@@ -2767,11 +2903,13 @@ discard block |
||
| 2767 | 2903 | global $txt, $mbname, $scripturl, $settings; |
| 2768 | 2904 | |
| 2769 | 2905 | // First things first, load up the email templates language file, if we need to. |
| 2770 | - if ($loadLang) |
|
| 2771 | - loadLanguage('EmailTemplates', $lang); |
|
| 2906 | + if ($loadLang) { |
|
| 2907 | + loadLanguage('EmailTemplates', $lang); |
|
| 2908 | + } |
|
| 2772 | 2909 | |
| 2773 | - if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) |
|
| 2774 | - fatal_lang_error('email_no_template', 'template', array($template)); |
|
| 2910 | + if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) { |
|
| 2911 | + fatal_lang_error('email_no_template', 'template', array($template)); |
|
| 2912 | + } |
|
| 2775 | 2913 | |
| 2776 | 2914 | $ret = array( |
| 2777 | 2915 | 'subject' => $txt[$template . '_subject'], |
@@ -2821,17 +2959,18 @@ discard block |
||
| 2821 | 2959 | function user_info_callback($matches) |
| 2822 | 2960 | { |
| 2823 | 2961 | global $user_info; |
| 2824 | - if (empty($matches[1])) |
|
| 2825 | - return ''; |
|
| 2962 | + if (empty($matches[1])) { |
|
| 2963 | + return ''; |
|
| 2964 | + } |
|
| 2826 | 2965 | |
| 2827 | 2966 | $use_ref = true; |
| 2828 | 2967 | $ref = &$user_info; |
| 2829 | 2968 | |
| 2830 | 2969 | foreach (explode('.', $matches[1]) as $index) |
| 2831 | 2970 | { |
| 2832 | - if ($use_ref && isset($ref[$index])) |
|
| 2833 | - $ref = &$ref[$index]; |
|
| 2834 | - else |
|
| 2971 | + if ($use_ref && isset($ref[$index])) { |
|
| 2972 | + $ref = &$ref[$index]; |
|
| 2973 | + } else |
|
| 2835 | 2974 | { |
| 2836 | 2975 | $use_ref = false; |
| 2837 | 2976 | break; |
@@ -2868,8 +3007,7 @@ discard block |
||
| 2868 | 3007 | if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale)) |
| 2869 | 3008 | { |
| 2870 | 3009 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale); |
| 2871 | - } |
|
| 2872 | - elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
| 3010 | + } elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
| 2873 | 3011 | { |
| 2874 | 3012 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']); |
| 2875 | 3013 | } |
@@ -2879,8 +3017,7 @@ discard block |
||
| 2879 | 3017 | { |
| 2880 | 3018 | $context['provider'] = 'enchant'; |
| 2881 | 3019 | return $enchant_link; |
| 2882 | - } |
|
| 2883 | - else |
|
| 3020 | + } else |
|
| 2884 | 3021 | { |
| 2885 | 3022 | // Free up any resources used... |
| 2886 | 3023 | @enchant_broker_free($context['enchant_broker']); |
@@ -2901,8 +3038,9 @@ discard block |
||
| 2901 | 3038 | $pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER); |
| 2902 | 3039 | |
| 2903 | 3040 | // Most people don't have anything but English installed... So we use English as a last resort. |
| 2904 | - if (!$pspell_link) |
|
| 2905 | - $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
| 3041 | + if (!$pspell_link) { |
|
| 3042 | + $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
| 3043 | + } |
|
| 2906 | 3044 | |
| 2907 | 3045 | error_reporting($old); |
| 2908 | 3046 | ob_end_clean(); |
@@ -2942,8 +3080,7 @@ discard block |
||
| 2942 | 3080 | $word = iconv($txt['lang_character_set'], 'UTF-8', $word); |
| 2943 | 3081 | } |
| 2944 | 3082 | return enchant_dict_check($dict, $word); |
| 2945 | - } |
|
| 2946 | - elseif ($context['provider'] == 'pspell') |
|
| 3083 | + } elseif ($context['provider'] == 'pspell') |
|
| 2947 | 3084 | { |
| 2948 | 3085 | return pspell_check($dict, $word); |
| 2949 | 3086 | } |
@@ -2979,13 +3116,11 @@ discard block |
||
| 2979 | 3116 | } |
| 2980 | 3117 | |
| 2981 | 3118 | return $suggestions; |
| 2982 | - } |
|
| 2983 | - else |
|
| 3119 | + } else |
|
| 2984 | 3120 | { |
| 2985 | 3121 | return enchant_dict_suggest($dict, $word); |
| 2986 | 3122 | } |
| 2987 | - } |
|
| 2988 | - elseif ($context['provider'] == 'pspell') |
|
| 3123 | + } elseif ($context['provider'] == 'pspell') |
|
| 2989 | 3124 | { |
| 2990 | 3125 | return pspell_suggest($dict, $word); |
| 2991 | 3126 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Who's online, and what are they doing? |
@@ -35,8 +36,9 @@ discard block |
||
| 35 | 36 | isAllowedTo('who_view'); |
| 36 | 37 | |
| 37 | 38 | // You can't do anything if this is off. |
| 38 | - if (empty($modSettings['who_enabled'])) |
|
| 39 | - fatal_lang_error('who_off', false); |
|
| 39 | + if (empty($modSettings['who_enabled'])) { |
|
| 40 | + fatal_lang_error('who_off', false); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // Load the 'Who' template. |
| 42 | 44 | loadTemplate('Who'); |
@@ -71,9 +73,9 @@ discard block |
||
| 71 | 73 | $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; |
| 72 | 74 | $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; |
| 73 | 75 | $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; |
| 76 | + } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { |
|
| 77 | + unset($_SESSION['who_online_filter']); |
|
| 74 | 78 | } |
| 75 | - elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') |
|
| 76 | - unset($_SESSION['who_online_filter']); |
|
| 77 | 79 | |
| 78 | 80 | // Does the user prefer a different sort direction? |
| 79 | 81 | if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) |
@@ -97,20 +99,24 @@ discard block |
||
| 97 | 99 | $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down'; |
| 98 | 100 | |
| 99 | 101 | $conditions = array(); |
| 100 | - if (!allowedTo('moderate_forum')) |
|
| 101 | - $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 102 | + if (!allowedTo('moderate_forum')) { |
|
| 103 | + $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 104 | + } |
|
| 102 | 105 | |
| 103 | 106 | // Fallback to top filter? |
| 104 | - if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) |
|
| 105 | - $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 107 | + if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { |
|
| 108 | + $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 109 | + } |
|
| 106 | 110 | // Does the user wish to apply a filter? |
| 107 | - if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) |
|
| 108 | - $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 111 | + if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { |
|
| 112 | + $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 113 | + } |
|
| 109 | 114 | // Perhaps we saved a filter earlier in the session? |
| 110 | - elseif (isset($_SESSION['who_online_filter'])) |
|
| 111 | - $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 112 | - else |
|
| 113 | - $context['show_by'] = 'members'; |
|
| 115 | + elseif (isset($_SESSION['who_online_filter'])) { |
|
| 116 | + $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 117 | + } else { |
|
| 118 | + $context['show_by'] = 'members'; |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | $conditions[] = $show_methods[$context['show_by']]; |
| 116 | 122 | |
@@ -156,8 +162,9 @@ discard block |
||
| 156 | 162 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 157 | 163 | { |
| 158 | 164 | $actions = $smcFunc['json_decode']($row['url'], true); |
| 159 | - if ($actions === false) |
|
| 160 | - continue; |
|
| 165 | + if ($actions === false) { |
|
| 166 | + continue; |
|
| 167 | + } |
|
| 161 | 168 | |
| 162 | 169 | // Send the information to the template. |
| 163 | 170 | $context['members'][$row['session']] = array( |
@@ -195,8 +202,8 @@ discard block |
||
| 195 | 202 | $spiderContext = array(); |
| 196 | 203 | if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
| 197 | 204 | { |
| 198 | - foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) |
|
| 199 | - $spiderContext[$id] = array( |
|
| 205 | + foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) { |
|
| 206 | + $spiderContext[$id] = array( |
|
| 200 | 207 | 'id' => 0, |
| 201 | 208 | 'name' => $name, |
| 202 | 209 | 'group' => $txt['spiders'], |
@@ -205,6 +212,7 @@ discard block |
||
| 205 | 212 | 'email' => $name, |
| 206 | 213 | 'is_guest' => true |
| 207 | 214 | ); |
| 215 | + } |
|
| 208 | 216 | } |
| 209 | 217 | |
| 210 | 218 | $url_data = determineActions($url_data); |
@@ -219,16 +227,18 @@ discard block |
||
| 219 | 227 | // Put it in the context variables. |
| 220 | 228 | foreach ($context['members'] as $i => $member) |
| 221 | 229 | { |
| 222 | - if ($member['id'] != 0) |
|
| 223 | - $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 230 | + if ($member['id'] != 0) { |
|
| 231 | + $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 232 | + } |
|
| 224 | 233 | |
| 225 | 234 | // Keep the IP that came from the database. |
| 226 | 235 | $memberContext[$member['id']]['ip'] = $member['ip']; |
| 227 | 236 | $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; |
| 228 | - if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) |
|
| 229 | - $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 230 | - else |
|
| 231 | - $context['members'][$i] += $memberContext[$member['id']]; |
|
| 237 | + if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { |
|
| 238 | + $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 239 | + } else { |
|
| 240 | + $context['members'][$i] += $memberContext[$member['id']]; |
|
| 241 | + } |
|
| 232 | 242 | } |
| 233 | 243 | |
| 234 | 244 | // Some people can't send personal messages... |
@@ -263,8 +273,9 @@ discard block |
||
| 263 | 273 | { |
| 264 | 274 | global $txt, $user_info, $modSettings, $smcFunc; |
| 265 | 275 | |
| 266 | - if (!allowedTo('who_view')) |
|
| 267 | - return array(); |
|
| 276 | + if (!allowedTo('who_view')) { |
|
| 277 | + return array(); |
|
| 278 | + } |
|
| 268 | 279 | loadLanguage('Who'); |
| 269 | 280 | |
| 270 | 281 | // Actions that require a specific permission level. |
@@ -292,10 +303,11 @@ discard block |
||
| 292 | 303 | ); |
| 293 | 304 | call_integration_hook('who_allowed', array(&$allowedActions)); |
| 294 | 305 | |
| 295 | - if (!is_array($urls)) |
|
| 296 | - $url_list = array(array($urls, $user_info['id'])); |
|
| 297 | - else |
|
| 298 | - $url_list = $urls; |
|
| 306 | + if (!is_array($urls)) { |
|
| 307 | + $url_list = array(array($urls, $user_info['id'])); |
|
| 308 | + } else { |
|
| 309 | + $url_list = $urls; |
|
| 310 | + } |
|
| 299 | 311 | |
| 300 | 312 | // These are done to later query these in large chunks. (instead of one by one.) |
| 301 | 313 | $topic_ids = array(); |
@@ -307,12 +319,14 @@ discard block |
||
| 307 | 319 | { |
| 308 | 320 | // Get the request parameters.. |
| 309 | 321 | $actions = $smcFunc['json_decode']($url[0], true); |
| 310 | - if ($actions === false) |
|
| 311 | - continue; |
|
| 322 | + if ($actions === false) { |
|
| 323 | + continue; |
|
| 324 | + } |
|
| 312 | 325 | |
| 313 | 326 | // If it's the admin or moderation center, and there is an area set, use that instead. |
| 314 | - if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) |
|
| 315 | - $actions['action'] = $actions['area']; |
|
| 327 | + if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) { |
|
| 328 | + $actions['action'] = $actions['area']; |
|
| 329 | + } |
|
| 316 | 330 | |
| 317 | 331 | // Check if there was no action or the action is display. |
| 318 | 332 | if (!isset($actions['action']) || $actions['action'] == 'display') |
@@ -332,12 +346,14 @@ discard block |
||
| 332 | 346 | $board_ids[$actions['board']][$k] = $txt['who_board']; |
| 333 | 347 | } |
| 334 | 348 | // It's the board index!! It must be! |
| 335 | - else |
|
| 336 | - $data[$k] = $txt['who_index']; |
|
| 349 | + else { |
|
| 350 | + $data[$k] = $txt['who_index']; |
|
| 351 | + } |
|
| 337 | 352 | } |
| 338 | 353 | // Probably an error or some goon? |
| 339 | - elseif ($actions['action'] == '') |
|
| 340 | - $data[$k] = $txt['who_index']; |
|
| 354 | + elseif ($actions['action'] == '') { |
|
| 355 | + $data[$k] = $txt['who_index']; |
|
| 356 | + } |
|
| 341 | 357 | // Some other normal action...? |
| 342 | 358 | else |
| 343 | 359 | { |
@@ -345,23 +361,25 @@ discard block |
||
| 345 | 361 | if ($actions['action'] == 'profile') |
| 346 | 362 | { |
| 347 | 363 | // Whose? Their own? |
| 348 | - if (empty($actions['u'])) |
|
| 349 | - $actions['u'] = $url[1]; |
|
| 364 | + if (empty($actions['u'])) { |
|
| 365 | + $actions['u'] = $url[1]; |
|
| 366 | + } |
|
| 350 | 367 | |
| 351 | 368 | $data[$k] = $txt['who_hidden']; |
| 352 | 369 | $profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile']; |
| 353 | - } |
|
| 354 | - elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 370 | + } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 355 | 371 | { |
| 356 | 372 | $data[$k] = $txt['who_hidden']; |
| 357 | 373 | $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post']; |
| 358 | 374 | } |
| 359 | 375 | // A subaction anyone can view... if the language string is there, show it. |
| 360 | - elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) |
|
| 361 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 376 | + elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) { |
|
| 377 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 378 | + } |
|
| 362 | 379 | // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.) |
| 363 | - elseif (isset($txt['whoall_' . $actions['action']])) |
|
| 364 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 380 | + elseif (isset($txt['whoall_' . $actions['action']])) { |
|
| 381 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 382 | + } |
|
| 365 | 383 | // Viewable if and only if they can see the board... |
| 366 | 384 | elseif (isset($txt['whotopic_' . $actions['action']])) |
| 367 | 385 | { |
@@ -370,8 +388,7 @@ discard block |
||
| 370 | 388 | |
| 371 | 389 | $data[$k] = $txt['who_hidden']; |
| 372 | 390 | $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']]; |
| 373 | - } |
|
| 374 | - elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 391 | + } elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 375 | 392 | { |
| 376 | 393 | // Find out what message they are accessing. |
| 377 | 394 | $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0)); |
@@ -394,41 +411,46 @@ discard block |
||
| 394 | 411 | $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject); |
| 395 | 412 | $smcFunc['db_free_result']($result); |
| 396 | 413 | |
| 397 | - if (empty($id_topic)) |
|
| 398 | - $data[$k] = $txt['who_hidden']; |
|
| 414 | + if (empty($id_topic)) { |
|
| 415 | + $data[$k] = $txt['who_hidden']; |
|
| 416 | + } |
|
| 399 | 417 | } |
| 400 | 418 | // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!) |
| 401 | - elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) |
|
| 402 | - $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 419 | + elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) { |
|
| 420 | + $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 421 | + } |
|
| 403 | 422 | // Viewable by permission level. |
| 404 | 423 | elseif (isset($allowedActions[$actions['action']])) |
| 405 | 424 | { |
| 406 | - if (allowedTo($allowedActions[$actions['action']])) |
|
| 407 | - $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 408 | - elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) |
|
| 409 | - $data[$k] = $txt['who_moderate']; |
|
| 410 | - elseif (in_array('admin_forum', $allowedActions[$actions['action']])) |
|
| 411 | - $data[$k] = $txt['who_admin']; |
|
| 412 | - else |
|
| 413 | - $data[$k] = $txt['who_hidden']; |
|
| 425 | + if (allowedTo($allowedActions[$actions['action']])) { |
|
| 426 | + $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 427 | + } elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) { |
|
| 428 | + $data[$k] = $txt['who_moderate']; |
|
| 429 | + } elseif (in_array('admin_forum', $allowedActions[$actions['action']])) { |
|
| 430 | + $data[$k] = $txt['who_admin']; |
|
| 431 | + } else { |
|
| 432 | + $data[$k] = $txt['who_hidden']; |
|
| 433 | + } |
|
| 434 | + } elseif (!empty($actions['action'])) { |
|
| 435 | + $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 436 | + } else { |
|
| 437 | + $data[$k] = $txt['who_unknown']; |
|
| 414 | 438 | } |
| 415 | - elseif (!empty($actions['action'])) |
|
| 416 | - $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 417 | - else |
|
| 418 | - $data[$k] = $txt['who_unknown']; |
|
| 419 | 439 | } |
| 420 | 440 | |
| 421 | 441 | if (isset($actions['error'])) |
| 422 | 442 | { |
| 423 | - if (isset($txt[$actions['error']])) |
|
| 424 | - $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 425 | - elseif ($actions['error'] == 'guest_login') |
|
| 426 | - $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 427 | - else |
|
| 428 | - $error_message = str_replace('"', '"', $actions['error']); |
|
| 429 | - |
|
| 430 | - if (!empty($error_message)) |
|
| 431 | - $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 443 | + if (isset($txt[$actions['error']])) { |
|
| 444 | + $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 445 | + } elseif ($actions['error'] == 'guest_login') { |
|
| 446 | + $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 447 | + } else { |
|
| 448 | + $error_message = str_replace('"', '"', $actions['error']); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + if (!empty($error_message)) { |
|
| 452 | + $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 453 | + } |
|
| 432 | 454 | } |
| 433 | 455 | |
| 434 | 456 | // Maybe the action is integrated into another system? |
@@ -439,12 +461,15 @@ discard block |
||
| 439 | 461 | if (!empty($integrate_action)) |
| 440 | 462 | { |
| 441 | 463 | $data[$k] = $integrate_action; |
| 442 | - if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) |
|
| 443 | - $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 444 | - if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) |
|
| 445 | - $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 446 | - if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) |
|
| 447 | - $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 464 | + if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) { |
|
| 465 | + $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 466 | + } |
|
| 467 | + if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) { |
|
| 468 | + $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 469 | + } |
|
| 470 | + if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) { |
|
| 471 | + $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 472 | + } |
|
| 448 | 473 | break; |
| 449 | 474 | } |
| 450 | 475 | } |
@@ -472,8 +497,9 @@ discard block |
||
| 472 | 497 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 473 | 498 | { |
| 474 | 499 | // Show the topic's subject for each of the actions. |
| 475 | - foreach ($topic_ids[$row['id_topic']] as $k => $session_text) |
|
| 476 | - $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 500 | + foreach ($topic_ids[$row['id_topic']] as $k => $session_text) { |
|
| 501 | + $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 502 | + } |
|
| 477 | 503 | } |
| 478 | 504 | $smcFunc['db_free_result']($result); |
| 479 | 505 | } |
@@ -495,8 +521,9 @@ discard block |
||
| 495 | 521 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 496 | 522 | { |
| 497 | 523 | // Put the board name into the string for each member... |
| 498 | - foreach ($board_ids[$row['id_board']] as $k => $session_text) |
|
| 499 | - $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 524 | + foreach ($board_ids[$row['id_board']] as $k => $session_text) { |
|
| 525 | + $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 526 | + } |
|
| 500 | 527 | } |
| 501 | 528 | $smcFunc['db_free_result']($result); |
| 502 | 529 | } |
@@ -518,23 +545,26 @@ discard block |
||
| 518 | 545 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 519 | 546 | { |
| 520 | 547 | // If they aren't allowed to view this person's profile, skip it. |
| 521 | - if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) |
|
| 522 | - continue; |
|
| 548 | + if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) { |
|
| 549 | + continue; |
|
| 550 | + } |
|
| 523 | 551 | |
| 524 | 552 | // Set their action on each - session/text to sprintf. |
| 525 | - foreach ($profile_ids[$row['id_member']] as $k => $session_text) |
|
| 526 | - $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 553 | + foreach ($profile_ids[$row['id_member']] as $k => $session_text) { |
|
| 554 | + $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 555 | + } |
|
| 527 | 556 | } |
| 528 | 557 | $smcFunc['db_free_result']($result); |
| 529 | 558 | } |
| 530 | 559 | |
| 531 | 560 | call_integration_hook('whos_online_after', array(&$urls, &$data)); |
| 532 | 561 | |
| 533 | - if (!is_array($urls)) |
|
| 534 | - return isset($data[0]) ? $data[0] : false; |
|
| 535 | - else |
|
| 536 | - return $data; |
|
| 537 | -} |
|
| 562 | + if (!is_array($urls)) { |
|
| 563 | + return isset($data[0]) ? $data[0] : false; |
|
| 564 | + } else { |
|
| 565 | + return $data; |
|
| 566 | + } |
|
| 567 | + } |
|
| 538 | 568 | |
| 539 | 569 | /** |
| 540 | 570 | * It prepares credit and copyright information for the credits page or the admin page |
@@ -710,8 +740,8 @@ discard block |
||
| 710 | 740 | ); |
| 711 | 741 | |
| 712 | 742 | // Give the translators some credit for their hard work. |
| 713 | - if (!empty($txt['translation_credits'])) |
|
| 714 | - $context['credits'][] = array( |
|
| 743 | + if (!empty($txt['translation_credits'])) { |
|
| 744 | + $context['credits'][] = array( |
|
| 715 | 745 | 'title' => $txt['credits_groups_translation'], |
| 716 | 746 | 'groups' => array( |
| 717 | 747 | array( |
@@ -720,6 +750,7 @@ discard block |
||
| 720 | 750 | ), |
| 721 | 751 | ), |
| 722 | 752 | ); |
| 753 | + } |
|
| 723 | 754 | |
| 724 | 755 | $context['credits'][] = array( |
| 725 | 756 | 'title' => $txt['credits_special'], |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | 'Jessica "Suki" González', |
| 593 | 593 | 'Karl "RegularExpression" Benson', |
| 594 | 594 | 'Matthew "Labradoodle-360" Kerle', |
| 595 | - $user_info['is_admin'] ? 'Matt "Grudge" Wolf': 'Grudge', |
|
| 595 | + $user_info['is_admin'] ? 'Matt "Grudge" Wolf' : 'Grudge', |
|
| 596 | 596 | 'Michael "Thantos" Miller', |
| 597 | 597 | 'Norv', |
| 598 | 598 | 'Peter "Arantor" Spicer', |
@@ -824,13 +824,13 @@ discard block |
||
| 824 | 824 | $credit_info = $smcFunc['json_decode']($row['credits'], true); |
| 825 | 825 | |
| 826 | 826 | $copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' © ' . $smcFunc['htmlspecialchars']($credit_info['copyright']); |
| 827 | - $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="'. $smcFunc['htmlspecialchars']($credit_info['licenseurl']) .'">'. $smcFunc['htmlspecialchars']($credit_info['license']) .'</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
| 827 | + $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="' . $smcFunc['htmlspecialchars']($credit_info['licenseurl']) . '">' . $smcFunc['htmlspecialchars']($credit_info['license']) . '</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
| 828 | 828 | $version = $txt['credits_version'] . ' ' . $row['version']; |
| 829 | 829 | $title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version; |
| 830 | 830 | |
| 831 | 831 | // build this one out and stash it away |
| 832 | 832 | $mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>'; |
| 833 | - $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
| 833 | + $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
| 834 | 834 | } |
| 835 | 835 | cache_put_data('mods_credits', $mods, 86400); |
| 836 | 836 | } |