@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | 'class' => 'centercol', |
| 1335 | 1335 | ), |
| 1336 | 1336 | 'data' => array( |
| 1337 | - 'function' => function ($rowData) |
|
| 1337 | + 'function' => function($rowData) |
|
| 1338 | 1338 | { |
| 1339 | 1339 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
| 1340 | 1340 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1350,7 +1350,7 @@ discard block |
||
| 1350 | 1350 | 'class' => 'centercol', |
| 1351 | 1351 | ), |
| 1352 | 1352 | 'data' => array( |
| 1353 | - 'function' => function ($rowData) |
|
| 1353 | + 'function' => function($rowData) |
|
| 1354 | 1354 | { |
| 1355 | 1355 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
| 1356 | 1356 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1397,15 +1397,15 @@ discard block |
||
| 1397 | 1397 | 'value' => $txt['custom_profile_fieldorder'], |
| 1398 | 1398 | ), |
| 1399 | 1399 | 'data' => array( |
| 1400 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
| 1400 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
| 1401 | 1401 | { |
| 1402 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
|
| 1402 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br>'; |
|
| 1403 | 1403 | |
| 1404 | 1404 | if ($rowData['field_order'] > 1) |
| 1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1405 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
| 1406 | 1406 | |
| 1407 | 1407 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
| 1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1408 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
| 1409 | 1409 | |
| 1410 | 1410 | $return .= '</p>'; |
| 1411 | 1411 | |
@@ -1423,7 +1423,7 @@ discard block |
||
| 1423 | 1423 | 'value' => $txt['custom_profile_fieldname'], |
| 1424 | 1424 | ), |
| 1425 | 1425 | 'data' => array( |
| 1426 | - 'function' => function ($rowData) use ($scripturl) |
|
| 1426 | + 'function' => function($rowData) use ($scripturl) |
|
| 1427 | 1427 | { |
| 1428 | 1428 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
| 1429 | 1429 | }, |
@@ -1439,7 +1439,7 @@ discard block |
||
| 1439 | 1439 | 'value' => $txt['custom_profile_fieldtype'], |
| 1440 | 1440 | ), |
| 1441 | 1441 | 'data' => array( |
| 1442 | - 'function' => function ($rowData) use ($txt) |
|
| 1442 | + 'function' => function($rowData) use ($txt) |
|
| 1443 | 1443 | { |
| 1444 | 1444 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
| 1445 | 1445 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1457,7 +1457,7 @@ discard block |
||
| 1457 | 1457 | 'value' => $txt['custom_profile_active'], |
| 1458 | 1458 | ), |
| 1459 | 1459 | 'data' => array( |
| 1460 | - 'function' => function ($rowData) use ($txt) |
|
| 1460 | + 'function' => function($rowData) use ($txt) |
|
| 1461 | 1461 | { |
| 1462 | 1462 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
| 1463 | 1463 | }, |
@@ -1474,7 +1474,7 @@ discard block |
||
| 1474 | 1474 | 'value' => $txt['custom_profile_placement'], |
| 1475 | 1475 | ), |
| 1476 | 1476 | 'data' => array( |
| 1477 | - 'function' => function ($rowData) |
|
| 1477 | + 'function' => function($rowData) |
|
| 1478 | 1478 | { |
| 1479 | 1479 | global $txt, $context; |
| 1480 | 1480 | |
@@ -1709,7 +1709,7 @@ discard block |
||
| 1709 | 1709 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
| 1710 | 1710 | |
| 1711 | 1711 | // All good, proceed. |
| 1712 | - $smcFunc['db_query']('',' |
|
| 1712 | + $smcFunc['db_query']('', ' |
|
| 1713 | 1713 | UPDATE {db_prefix}custom_fields |
| 1714 | 1714 | SET field_order = {int:old_order} |
| 1715 | 1715 | WHERE field_order = {int:new_order}', |
@@ -1718,7 +1718,7 @@ discard block |
||
| 1718 | 1718 | 'old_order' => $context['field']['order'], |
| 1719 | 1719 | ) |
| 1720 | 1720 | ); |
| 1721 | - $smcFunc['db_query']('',' |
|
| 1721 | + $smcFunc['db_query']('', ' |
|
| 1722 | 1722 | UPDATE {db_prefix}custom_fields |
| 1723 | 1723 | SET field_order = {int:new_order} |
| 1724 | 1724 | WHERE id_field = {int:id_field}', |
@@ -1820,7 +1820,7 @@ discard block |
||
| 1820 | 1820 | $smcFunc['db_free_result']($request); |
| 1821 | 1821 | |
| 1822 | 1822 | $unique = false; |
| 1823 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
| 1823 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
| 1824 | 1824 | { |
| 1825 | 1825 | if (!in_array($col_name, $current_fields)) |
| 1826 | 1826 | $unique = true; |
@@ -1993,7 +1993,7 @@ discard block |
||
| 1993 | 1993 | ); |
| 1994 | 1994 | |
| 1995 | 1995 | // Re-arrange the order. |
| 1996 | - $smcFunc['db_query']('',' |
|
| 1996 | + $smcFunc['db_query']('', ' |
|
| 1997 | 1997 | UPDATE {db_prefix}custom_fields |
| 1998 | 1998 | SET field_order = field_order - 1 |
| 1999 | 1999 | WHERE field_order > {int:current_order}', |
@@ -2257,7 +2257,7 @@ discard block |
||
| 2257 | 2257 | $context['token_check'] = 'noti-admin'; |
| 2258 | 2258 | |
| 2259 | 2259 | // Specify our action since we'll want to post back here instead of the profile |
| 2260 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
| 2260 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
| 2261 | 2261 | |
| 2262 | 2262 | loadTemplate('Profile'); |
| 2263 | 2263 | loadLanguage('Profile'); |
@@ -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 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
| 206 | 207 | { |
| 207 | 208 | $all_zones = timezone_identifiers_list(); |
| 208 | 209 | // Make sure we set the value to the same as the printed value. |
| 209 | - foreach ($all_zones as $zone) |
|
| 210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 210 | + foreach ($all_zones as $zone) { |
|
| 211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 212 | + } |
|
| 213 | + } else { |
|
| 214 | + unset($config_vars['default_timezone']); |
|
| 211 | 215 | } |
| 212 | - else |
|
| 213 | - unset($config_vars['default_timezone']); |
|
| 214 | 216 | |
| 215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
| 216 | 218 | |
| 217 | - if ($return_config) |
|
| 218 | - return $config_vars; |
|
| 219 | + if ($return_config) { |
|
| 220 | + return $config_vars; |
|
| 221 | + } |
|
| 219 | 222 | |
| 220 | 223 | // Saving? |
| 221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
| 223 | 226 | checkSession(); |
| 224 | 227 | |
| 225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
| 226 | - if (isset($_POST['lastActive'])) |
|
| 227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
| 229 | + if (isset($_POST['lastActive'])) { |
|
| 230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
| 231 | + } |
|
| 228 | 232 | |
| 229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
| 230 | 234 | |
@@ -269,8 +273,9 @@ discard block |
||
| 269 | 273 | |
| 270 | 274 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
| 271 | 275 | |
| 272 | - if ($return_config) |
|
| 273 | - return $config_vars; |
|
| 276 | + if ($return_config) { |
|
| 277 | + return $config_vars; |
|
| 278 | + } |
|
| 274 | 279 | |
| 275 | 280 | // Setup the template. |
| 276 | 281 | require_once($sourcedir . '/ManageServer.php'); |
@@ -287,13 +292,15 @@ discard block |
||
| 287 | 292 | |
| 288 | 293 | // Clean up the tags. |
| 289 | 294 | $bbcTags = array(); |
| 290 | - foreach (parse_bbc(false) as $tag) |
|
| 291 | - $bbcTags[] = $tag['tag']; |
|
| 295 | + foreach (parse_bbc(false) as $tag) { |
|
| 296 | + $bbcTags[] = $tag['tag']; |
|
| 297 | + } |
|
| 292 | 298 | |
| 293 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
| 294 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
| 295 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
| 296 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
| 299 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
| 300 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
| 301 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
| 302 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
| 303 | + } |
|
| 297 | 304 | // Work out what is actually disabled! |
| 298 | 305 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
| 299 | 306 | |
@@ -337,8 +344,9 @@ discard block |
||
| 337 | 344 | |
| 338 | 345 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
| 339 | 346 | |
| 340 | - if ($return_config) |
|
| 341 | - return $config_vars; |
|
| 347 | + if ($return_config) { |
|
| 348 | + return $config_vars; |
|
| 349 | + } |
|
| 342 | 350 | |
| 343 | 351 | // Saving? |
| 344 | 352 | if (isset($_GET['save'])) |
@@ -379,8 +387,9 @@ discard block |
||
| 379 | 387 | |
| 380 | 388 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
| 381 | 389 | |
| 382 | - if ($return_config) |
|
| 383 | - return $config_vars; |
|
| 390 | + if ($return_config) { |
|
| 391 | + return $config_vars; |
|
| 392 | + } |
|
| 384 | 393 | |
| 385 | 394 | // Saving? |
| 386 | 395 | if (isset($_GET['save'])) |
@@ -418,8 +427,9 @@ discard block |
||
| 418 | 427 | |
| 419 | 428 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
| 420 | 429 | |
| 421 | - if ($return_config) |
|
| 422 | - return $config_vars; |
|
| 430 | + if ($return_config) { |
|
| 431 | + return $config_vars; |
|
| 432 | + } |
|
| 423 | 433 | |
| 424 | 434 | // Saving? |
| 425 | 435 | if (isset($_GET['save'])) |
@@ -463,8 +473,8 @@ discard block |
||
| 463 | 473 | 'enable' => array('check', 'warning_enable'), |
| 464 | 474 | ); |
| 465 | 475 | |
| 466 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
| 467 | - $config_vars += array( |
|
| 476 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
| 477 | + $config_vars += array( |
|
| 468 | 478 | '', |
| 469 | 479 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
| 470 | 480 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -473,15 +483,18 @@ discard block |
||
| 473 | 483 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
| 474 | 484 | array('permissions', 'view_warning'), |
| 475 | 485 | ); |
| 486 | + } |
|
| 476 | 487 | |
| 477 | 488 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
| 478 | 489 | |
| 479 | - if ($return_config) |
|
| 480 | - return $config_vars; |
|
| 490 | + if ($return_config) { |
|
| 491 | + return $config_vars; |
|
| 492 | + } |
|
| 481 | 493 | |
| 482 | 494 | // Cannot use moderation if post moderation is not enabled. |
| 483 | - if (!$modSettings['postmod_active']) |
|
| 484 | - unset($config_vars['moderate']); |
|
| 495 | + if (!$modSettings['postmod_active']) { |
|
| 496 | + unset($config_vars['moderate']); |
|
| 497 | + } |
|
| 485 | 498 | |
| 486 | 499 | // Will need the utility functions from here. |
| 487 | 500 | require_once($sourcedir . '/ManageServer.php'); |
@@ -506,16 +519,16 @@ discard block |
||
| 506 | 519 | 'warning_watch' => 10, |
| 507 | 520 | 'warning_mute' => 60, |
| 508 | 521 | ); |
| 509 | - if ($modSettings['postmod_active']) |
|
| 510 | - $vars['warning_moderate'] = 35; |
|
| 522 | + if ($modSettings['postmod_active']) { |
|
| 523 | + $vars['warning_moderate'] = 35; |
|
| 524 | + } |
|
| 511 | 525 | |
| 512 | 526 | foreach ($vars as $var => $value) |
| 513 | 527 | { |
| 514 | 528 | $config_vars[] = array('int', $var); |
| 515 | 529 | $_POST[$var] = $value; |
| 516 | 530 | } |
| 517 | - } |
|
| 518 | - else |
|
| 531 | + } else |
|
| 519 | 532 | { |
| 520 | 533 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
| 521 | 534 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -603,8 +616,9 @@ discard block |
||
| 603 | 616 | |
| 604 | 617 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
| 605 | 618 | |
| 606 | - if ($return_config) |
|
| 607 | - return $config_vars; |
|
| 619 | + if ($return_config) { |
|
| 620 | + return $config_vars; |
|
| 621 | + } |
|
| 608 | 622 | |
| 609 | 623 | // You need to be an admin to edit settings! |
| 610 | 624 | isAllowedTo('admin_forum'); |
@@ -638,8 +652,9 @@ discard block |
||
| 638 | 652 | |
| 639 | 653 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
| 640 | 654 | { |
| 641 | - if (empty($context['settings_insert_above'])) |
|
| 642 | - $context['settings_insert_above'] = ''; |
|
| 655 | + if (empty($context['settings_insert_above'])) { |
|
| 656 | + $context['settings_insert_above'] = ''; |
|
| 657 | + } |
|
| 643 | 658 | |
| 644 | 659 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
| 645 | 660 | } |
@@ -682,8 +697,9 @@ discard block |
||
| 682 | 697 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
| 683 | 698 | |
| 684 | 699 | // Hack in guest requiring verification! |
| 685 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
| 686 | - $_POST['posts_require_captcha'] = -1; |
|
| 700 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
| 701 | + $_POST['posts_require_captcha'] = -1; |
|
| 702 | + } |
|
| 687 | 703 | |
| 688 | 704 | $save_vars = $config_vars; |
| 689 | 705 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -700,14 +716,16 @@ discard block |
||
| 700 | 716 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
| 701 | 717 | { |
| 702 | 718 | // If we had some questions for this language before, but don't now, delete everything from that language. |
| 703 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
| 704 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
| 719 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
| 720 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
| 721 | + } |
|
| 705 | 722 | |
| 706 | 723 | // Now step through and see if any existing questions no longer exist. |
| 707 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
| 708 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 724 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
| 725 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 709 | 726 | if (empty($_POST['question'][$lang_id][$q_id])) |
| 710 | 727 | $changes['delete'][] = $q_id; |
| 728 | + } |
|
| 711 | 729 | |
| 712 | 730 | // Now let's see if there are new questions or ones that need updating. |
| 713 | 731 | if (isset($_POST['question'][$lang_id])) |
@@ -716,14 +734,16 @@ discard block |
||
| 716 | 734 | { |
| 717 | 735 | // Ignore junky ids. |
| 718 | 736 | $q_id = (int) $q_id; |
| 719 | - if ($q_id <= 0) |
|
| 720 | - continue; |
|
| 737 | + if ($q_id <= 0) { |
|
| 738 | + continue; |
|
| 739 | + } |
|
| 721 | 740 | |
| 722 | 741 | // Check the question isn't empty (because they want to delete it?) |
| 723 | 742 | if (empty($question) || trim($question) == '') |
| 724 | 743 | { |
| 725 | - if (isset($context['question_answers'][$q_id])) |
|
| 726 | - $changes['delete'][] = $q_id; |
|
| 744 | + if (isset($context['question_answers'][$q_id])) { |
|
| 745 | + $changes['delete'][] = $q_id; |
|
| 746 | + } |
|
| 727 | 747 | continue; |
| 728 | 748 | } |
| 729 | 749 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -731,19 +751,22 @@ discard block |
||
| 731 | 751 | // Get the answers. Firstly check there actually might be some. |
| 732 | 752 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
| 733 | 753 | { |
| 734 | - if (isset($context['question_answers'][$q_id])) |
|
| 735 | - $changes['delete'][] = $q_id; |
|
| 754 | + if (isset($context['question_answers'][$q_id])) { |
|
| 755 | + $changes['delete'][] = $q_id; |
|
| 756 | + } |
|
| 736 | 757 | continue; |
| 737 | 758 | } |
| 738 | 759 | // Now get them and check that they might be viable. |
| 739 | 760 | $answers = array(); |
| 740 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
| 741 | - if (!empty($answer) && trim($answer) !== '') |
|
| 761 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
| 762 | + if (!empty($answer) && trim($answer) !== '') |
|
| 742 | 763 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
| 764 | + } |
|
| 743 | 765 | if (empty($answers)) |
| 744 | 766 | { |
| 745 | - if (isset($context['question_answers'][$q_id])) |
|
| 746 | - $changes['delete'][] = $q_id; |
|
| 767 | + if (isset($context['question_answers'][$q_id])) { |
|
| 768 | + $changes['delete'][] = $q_id; |
|
| 769 | + } |
|
| 747 | 770 | continue; |
| 748 | 771 | } |
| 749 | 772 | $answers = $smcFunc['json_encode']($answers); |
@@ -753,16 +776,17 @@ discard block |
||
| 753 | 776 | { |
| 754 | 777 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
| 755 | 778 | $changes['insert'][] = array($lang_id, $question, $answers); |
| 756 | - } |
|
| 757 | - else |
|
| 779 | + } else |
|
| 758 | 780 | { |
| 759 | 781 | // It's an existing question. Let's see what's changed, if anything. |
| 760 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
| 761 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
| 782 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
| 783 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
| 784 | + } |
|
| 762 | 785 | } |
| 763 | 786 | |
| 764 | - if (!isset($qs_per_lang[$lang_id])) |
|
| 765 | - $qs_per_lang[$lang_id] = 0; |
|
| 787 | + if (!isset($qs_per_lang[$lang_id])) { |
|
| 788 | + $qs_per_lang[$lang_id] = 0; |
|
| 789 | + } |
|
| 766 | 790 | $qs_per_lang[$lang_id]++; |
| 767 | 791 | } |
| 768 | 792 | } |
@@ -812,8 +836,9 @@ discard block |
||
| 812 | 836 | |
| 813 | 837 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
| 814 | 838 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
| 815 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
| 816 | - $_POST['qa_verification_number'] = $count_questions; |
|
| 839 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
| 840 | + $_POST['qa_verification_number'] = $count_questions; |
|
| 841 | + } |
|
| 817 | 842 | |
| 818 | 843 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
| 819 | 844 | |
@@ -828,24 +853,27 @@ discard block |
||
| 828 | 853 | |
| 829 | 854 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
| 830 | 855 | $_SESSION['visual_verification_code'] = ''; |
| 831 | - for ($i = 0; $i < 6; $i++) |
|
| 832 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
| 856 | + for ($i = 0; $i < 6; $i++) { |
|
| 857 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
| 858 | + } |
|
| 833 | 859 | |
| 834 | 860 | // Some javascript for CAPTCHA. |
| 835 | 861 | $context['settings_post_javascript'] = ''; |
| 836 | - if ($context['use_graphic_library']) |
|
| 837 | - $context['settings_post_javascript'] .= ' |
|
| 862 | + if ($context['use_graphic_library']) { |
|
| 863 | + $context['settings_post_javascript'] .= ' |
|
| 838 | 864 | function refreshImages() |
| 839 | 865 | { |
| 840 | 866 | var imageType = document.getElementById(\'visual_verification_type\').value; |
| 841 | 867 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
| 842 | 868 | }'; |
| 869 | + } |
|
| 843 | 870 | |
| 844 | 871 | // Show the image itself, or text saying we can't. |
| 845 | - if ($context['use_graphic_library']) |
|
| 846 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
| 847 | - else |
|
| 848 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
| 872 | + if ($context['use_graphic_library']) { |
|
| 873 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
| 874 | + } else { |
|
| 875 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
| 876 | + } |
|
| 849 | 877 | |
| 850 | 878 | // Hack for PM spam settings. |
| 851 | 879 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -855,9 +883,10 @@ discard block |
||
| 855 | 883 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
| 856 | 884 | |
| 857 | 885 | // Some minor javascript for the guest post setting. |
| 858 | - if ($modSettings['posts_require_captcha']) |
|
| 859 | - $context['settings_post_javascript'] .= ' |
|
| 886 | + if ($modSettings['posts_require_captcha']) { |
|
| 887 | + $context['settings_post_javascript'] .= ' |
|
| 860 | 888 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
| 889 | + } |
|
| 861 | 890 | |
| 862 | 891 | // And everything else. |
| 863 | 892 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -904,8 +933,9 @@ discard block |
||
| 904 | 933 | |
| 905 | 934 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
| 906 | 935 | |
| 907 | - if ($return_config) |
|
| 908 | - return $config_vars; |
|
| 936 | + if ($return_config) { |
|
| 937 | + return $config_vars; |
|
| 938 | + } |
|
| 909 | 939 | |
| 910 | 940 | // Setup the template. |
| 911 | 941 | $context['page_title'] = $txt['signature_settings']; |
@@ -960,8 +990,9 @@ discard block |
||
| 960 | 990 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
| 961 | 991 | |
| 962 | 992 | // Max characters... |
| 963 | - if (!empty($sig_limits[1])) |
|
| 964 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
| 993 | + if (!empty($sig_limits[1])) { |
|
| 994 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
| 995 | + } |
|
| 965 | 996 | // Max lines... |
| 966 | 997 | if (!empty($sig_limits[2])) |
| 967 | 998 | { |
@@ -971,8 +1002,9 @@ discard block |
||
| 971 | 1002 | if ($sig[$i] == "\n") |
| 972 | 1003 | { |
| 973 | 1004 | $count++; |
| 974 | - if ($count >= $sig_limits[2]) |
|
| 975 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
| 1005 | + if ($count >= $sig_limits[2]) { |
|
| 1006 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
| 1007 | + } |
|
| 976 | 1008 | } |
| 977 | 1009 | } |
| 978 | 1010 | } |
@@ -983,17 +1015,19 @@ discard block |
||
| 983 | 1015 | { |
| 984 | 1016 | $limit_broke = 0; |
| 985 | 1017 | // Attempt to allow all sizes of abuse, so to speak. |
| 986 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 987 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 988 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 989 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 990 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 991 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 992 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 993 | - $limit_broke = 'large'; |
|
| 994 | - |
|
| 995 | - if ($limit_broke) |
|
| 996 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
| 1018 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 1019 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 1020 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 1021 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 1022 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 1023 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 1024 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 1025 | + $limit_broke = 'large'; |
|
| 1026 | + } |
|
| 1027 | + |
|
| 1028 | + if ($limit_broke) { |
|
| 1029 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
| 1030 | + } |
|
| 997 | 1031 | } |
| 998 | 1032 | } |
| 999 | 1033 | |
@@ -1049,32 +1083,34 @@ discard block |
||
| 1049 | 1083 | $img_offset = false; |
| 1050 | 1084 | } |
| 1051 | 1085 | } |
| 1086 | + } else { |
|
| 1087 | + $replaces[$image] = ''; |
|
| 1052 | 1088 | } |
| 1053 | - else |
|
| 1054 | - $replaces[$image] = ''; |
|
| 1055 | 1089 | |
| 1056 | 1090 | continue; |
| 1057 | 1091 | } |
| 1058 | 1092 | |
| 1059 | 1093 | // Does it have predefined restraints? Width first. |
| 1060 | - if ($matches[6][$key]) |
|
| 1061 | - $matches[2][$key] = $matches[6][$key]; |
|
| 1094 | + if ($matches[6][$key]) { |
|
| 1095 | + $matches[2][$key] = $matches[6][$key]; |
|
| 1096 | + } |
|
| 1062 | 1097 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 1063 | 1098 | { |
| 1064 | 1099 | $width = $sig_limits[5]; |
| 1065 | 1100 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 1101 | + } elseif ($matches[2][$key]) { |
|
| 1102 | + $width = $matches[2][$key]; |
|
| 1066 | 1103 | } |
| 1067 | - elseif ($matches[2][$key]) |
|
| 1068 | - $width = $matches[2][$key]; |
|
| 1069 | 1104 | // ... and height. |
| 1070 | 1105 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 1071 | 1106 | { |
| 1072 | 1107 | $height = $sig_limits[6]; |
| 1073 | - if ($width != -1) |
|
| 1074 | - $width = $width * ($height / $matches[4][$key]); |
|
| 1108 | + if ($width != -1) { |
|
| 1109 | + $width = $width * ($height / $matches[4][$key]); |
|
| 1110 | + } |
|
| 1111 | + } elseif ($matches[4][$key]) { |
|
| 1112 | + $height = $matches[4][$key]; |
|
| 1075 | 1113 | } |
| 1076 | - elseif ($matches[4][$key]) |
|
| 1077 | - $height = $matches[4][$key]; |
|
| 1078 | 1114 | |
| 1079 | 1115 | // If the dimensions are still not fixed - we need to check the actual image. |
| 1080 | 1116 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1092,12 +1128,13 @@ discard block |
||
| 1092 | 1128 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 1093 | 1129 | { |
| 1094 | 1130 | $height = $sig_limits[6]; |
| 1095 | - if ($width == -1) |
|
| 1096 | - $width = $sizes[0]; |
|
| 1131 | + if ($width == -1) { |
|
| 1132 | + $width = $sizes[0]; |
|
| 1133 | + } |
|
| 1097 | 1134 | $width = $width * ($height / $sizes[1]); |
| 1135 | + } elseif ($width != -1) { |
|
| 1136 | + $height = $sizes[1]; |
|
| 1098 | 1137 | } |
| 1099 | - elseif ($width != -1) |
|
| 1100 | - $height = $sizes[1]; |
|
| 1101 | 1138 | } |
| 1102 | 1139 | } |
| 1103 | 1140 | |
@@ -1110,8 +1147,9 @@ discard block |
||
| 1110 | 1147 | // Record that we got one. |
| 1111 | 1148 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
| 1112 | 1149 | } |
| 1113 | - if (!empty($replaces)) |
|
| 1114 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
| 1150 | + if (!empty($replaces)) { |
|
| 1151 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
| 1152 | + } |
|
| 1115 | 1153 | } |
| 1116 | 1154 | } |
| 1117 | 1155 | // Try to fix disabled tags. |
@@ -1123,18 +1161,20 @@ discard block |
||
| 1123 | 1161 | |
| 1124 | 1162 | $sig = strtr($sig, array("\n" => '<br>')); |
| 1125 | 1163 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
| 1126 | - if ($sig != $row['signature']) |
|
| 1127 | - $changes[$row['id_member']] = $sig; |
|
| 1164 | + if ($sig != $row['signature']) { |
|
| 1165 | + $changes[$row['id_member']] = $sig; |
|
| 1166 | + } |
|
| 1167 | + } |
|
| 1168 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1169 | + $done = true; |
|
| 1128 | 1170 | } |
| 1129 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1130 | - $done = true; |
|
| 1131 | 1171 | $smcFunc['db_free_result']($request); |
| 1132 | 1172 | |
| 1133 | 1173 | // Do we need to delete what we have? |
| 1134 | 1174 | if (!empty($changes)) |
| 1135 | 1175 | { |
| 1136 | - foreach ($changes as $id => $sig) |
|
| 1137 | - $smcFunc['db_query']('', ' |
|
| 1176 | + foreach ($changes as $id => $sig) { |
|
| 1177 | + $smcFunc['db_query']('', ' |
|
| 1138 | 1178 | UPDATE {db_prefix}members |
| 1139 | 1179 | SET signature = {string:signature} |
| 1140 | 1180 | WHERE id_member = {int:id_member}', |
@@ -1143,11 +1183,13 @@ discard block |
||
| 1143 | 1183 | 'signature' => $sig, |
| 1144 | 1184 | ) |
| 1145 | 1185 | ); |
| 1186 | + } |
|
| 1146 | 1187 | } |
| 1147 | 1188 | |
| 1148 | 1189 | $_GET['step'] += 50; |
| 1149 | - if (!$done) |
|
| 1150 | - pauseSignatureApplySettings(); |
|
| 1190 | + if (!$done) { |
|
| 1191 | + pauseSignatureApplySettings(); |
|
| 1192 | + } |
|
| 1151 | 1193 | } |
| 1152 | 1194 | $settings_applied = true; |
| 1153 | 1195 | } |
@@ -1165,8 +1207,9 @@ discard block |
||
| 1165 | 1207 | ); |
| 1166 | 1208 | |
| 1167 | 1209 | // Temporarily make each setting a modSetting! |
| 1168 | - foreach ($context['signature_settings'] as $key => $value) |
|
| 1169 | - $modSettings['signature_' . $key] = $value; |
|
| 1210 | + foreach ($context['signature_settings'] as $key => $value) { |
|
| 1211 | + $modSettings['signature_' . $key] = $value; |
|
| 1212 | + } |
|
| 1170 | 1213 | |
| 1171 | 1214 | // Make sure we check the right tags! |
| 1172 | 1215 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1178,23 +1221,26 @@ discard block |
||
| 1178 | 1221 | |
| 1179 | 1222 | // Clean up the tag stuff! |
| 1180 | 1223 | $bbcTags = array(); |
| 1181 | - foreach (parse_bbc(false) as $tag) |
|
| 1182 | - $bbcTags[] = $tag['tag']; |
|
| 1224 | + foreach (parse_bbc(false) as $tag) { |
|
| 1225 | + $bbcTags[] = $tag['tag']; |
|
| 1226 | + } |
|
| 1183 | 1227 | |
| 1184 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
| 1185 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
| 1186 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
| 1187 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
| 1228 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
| 1229 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
| 1230 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
| 1231 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
| 1232 | + } |
|
| 1188 | 1233 | |
| 1189 | 1234 | $sig_limits = array(); |
| 1190 | 1235 | foreach ($context['signature_settings'] as $key => $value) |
| 1191 | 1236 | { |
| 1192 | - if ($key == 'allow_smileys') |
|
| 1193 | - continue; |
|
| 1194 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
| 1195 | - $sig_limits[] = -1; |
|
| 1196 | - else |
|
| 1197 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
| 1237 | + if ($key == 'allow_smileys') { |
|
| 1238 | + continue; |
|
| 1239 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
| 1240 | + $sig_limits[] = -1; |
|
| 1241 | + } else { |
|
| 1242 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
| 1243 | + } |
|
| 1198 | 1244 | } |
| 1199 | 1245 | |
| 1200 | 1246 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1227,12 +1273,14 @@ discard block |
||
| 1227 | 1273 | |
| 1228 | 1274 | // Try get more time... |
| 1229 | 1275 | @set_time_limit(600); |
| 1230 | - if (function_exists('apache_reset_timeout')) |
|
| 1231 | - @apache_reset_timeout(); |
|
| 1276 | + if (function_exists('apache_reset_timeout')) { |
|
| 1277 | + @apache_reset_timeout(); |
|
| 1278 | + } |
|
| 1232 | 1279 | |
| 1233 | 1280 | // Have we exhausted all the time we allowed? |
| 1234 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
| 1235 | - return; |
|
| 1281 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
| 1282 | + return; |
|
| 1283 | + } |
|
| 1236 | 1284 | |
| 1237 | 1285 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1238 | 1286 | $context['page_title'] = $txt['not_done_title']; |
@@ -1278,9 +1326,10 @@ discard block |
||
| 1278 | 1326 | $disable_fields = array_flip($standard_fields); |
| 1279 | 1327 | if (!empty($_POST['active'])) |
| 1280 | 1328 | { |
| 1281 | - foreach ($_POST['active'] as $value) |
|
| 1282 | - if (isset($disable_fields[$value])) |
|
| 1329 | + foreach ($_POST['active'] as $value) { |
|
| 1330 | + if (isset($disable_fields[$value])) |
|
| 1283 | 1331 | unset($disable_fields[$value]); |
| 1332 | + } |
|
| 1284 | 1333 | } |
| 1285 | 1334 | // What we have left! |
| 1286 | 1335 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1289,16 +1338,18 @@ discard block |
||
| 1289 | 1338 | $reg_fields = array(); |
| 1290 | 1339 | if (!empty($_POST['reg'])) |
| 1291 | 1340 | { |
| 1292 | - foreach ($_POST['reg'] as $value) |
|
| 1293 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
| 1341 | + foreach ($_POST['reg'] as $value) { |
|
| 1342 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
| 1294 | 1343 | $reg_fields[] = $value; |
| 1344 | + } |
|
| 1295 | 1345 | } |
| 1296 | 1346 | // What we have left! |
| 1297 | 1347 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
| 1298 | 1348 | |
| 1299 | 1349 | $_SESSION['adm-save'] = true; |
| 1300 | - if (!empty($changes)) |
|
| 1301 | - updateSettings($changes); |
|
| 1350 | + if (!empty($changes)) { |
|
| 1351 | + updateSettings($changes); |
|
| 1352 | + } |
|
| 1302 | 1353 | } |
| 1303 | 1354 | |
| 1304 | 1355 | createToken('admin-scp'); |
@@ -1401,11 +1452,13 @@ discard block |
||
| 1401 | 1452 | { |
| 1402 | 1453 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
| 1403 | 1454 | |
| 1404 | - if ($rowData['field_order'] > 1) |
|
| 1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1455 | + if ($rowData['field_order'] > 1) { |
|
| 1456 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1457 | + } |
|
| 1406 | 1458 | |
| 1407 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
| 1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1459 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
| 1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1461 | + } |
|
| 1409 | 1462 | |
| 1410 | 1463 | $return .= '</p>'; |
| 1411 | 1464 | |
@@ -1543,16 +1596,16 @@ discard block |
||
| 1543 | 1596 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
| 1544 | 1597 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
| 1545 | 1598 | |
| 1546 | - foreach ($standard_fields as $field) |
|
| 1547 | - $list[] = array( |
|
| 1599 | + foreach ($standard_fields as $field) { |
|
| 1600 | + $list[] = array( |
|
| 1548 | 1601 | 'id' => $field, |
| 1549 | 1602 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
| 1550 | 1603 | 'disabled' => in_array($field, $disabled_fields), |
| 1551 | 1604 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
| 1552 | 1605 | 'can_show_register' => !in_array($field, $fields_no_registration), |
| 1553 | 1606 | ); |
| 1554 | - } |
|
| 1555 | - else |
|
| 1607 | + } |
|
| 1608 | + } else |
|
| 1556 | 1609 | { |
| 1557 | 1610 | // Load all the fields. |
| 1558 | 1611 | $request = $smcFunc['db_query']('', ' |
@@ -1566,8 +1619,9 @@ discard block |
||
| 1566 | 1619 | 'items_per_page' => $items_per_page, |
| 1567 | 1620 | ) |
| 1568 | 1621 | ); |
| 1569 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1570 | - $list[] = $row; |
|
| 1622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1623 | + $list[] = $row; |
|
| 1624 | + } |
|
| 1571 | 1625 | $smcFunc['db_free_result']($request); |
| 1572 | 1626 | } |
| 1573 | 1627 | |
@@ -1633,9 +1687,9 @@ discard block |
||
| 1633 | 1687 | $context['field'] = array(); |
| 1634 | 1688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1635 | 1689 | { |
| 1636 | - if ($row['field_type'] == 'textarea') |
|
| 1637 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
| 1638 | - else |
|
| 1690 | + if ($row['field_type'] == 'textarea') { |
|
| 1691 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
| 1692 | + } else |
|
| 1639 | 1693 | { |
| 1640 | 1694 | $rows = 3; |
| 1641 | 1695 | $cols = 30; |
@@ -1671,8 +1725,8 @@ discard block |
||
| 1671 | 1725 | } |
| 1672 | 1726 | |
| 1673 | 1727 | // Setup the default values as needed. |
| 1674 | - if (empty($context['field'])) |
|
| 1675 | - $context['field'] = array( |
|
| 1728 | + if (empty($context['field'])) { |
|
| 1729 | + $context['field'] = array( |
|
| 1676 | 1730 | 'name' => '', |
| 1677 | 1731 | 'col_name' => '???', |
| 1678 | 1732 | 'desc' => '', |
@@ -1697,6 +1751,7 @@ discard block |
||
| 1697 | 1751 | 'enclose' => '', |
| 1698 | 1752 | 'placement' => 0, |
| 1699 | 1753 | ); |
| 1754 | + } |
|
| 1700 | 1755 | |
| 1701 | 1756 | // Are we moving it? |
| 1702 | 1757 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1705,8 +1760,10 @@ discard block |
||
| 1705 | 1760 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
| 1706 | 1761 | |
| 1707 | 1762 | // Is this a valid position? |
| 1708 | - if ($new_order <= 0 || $new_order > $order_count) |
|
| 1709 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
| 1763 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
| 1764 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
| 1765 | + } |
|
| 1766 | + // @todo implement an error handler |
|
| 1710 | 1767 | |
| 1711 | 1768 | // All good, proceed. |
| 1712 | 1769 | $smcFunc['db_query']('',' |
@@ -1737,12 +1794,14 @@ discard block |
||
| 1737 | 1794 | validateToken('admin-ecp'); |
| 1738 | 1795 | |
| 1739 | 1796 | // Everyone needs a name - even the (bracket) unknown... |
| 1740 | - if (trim($_POST['field_name']) == '') |
|
| 1741 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
| 1797 | + if (trim($_POST['field_name']) == '') { |
|
| 1798 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
| 1799 | + } |
|
| 1742 | 1800 | |
| 1743 | 1801 | // Regex you say? Do a very basic test to see if the pattern is valid |
| 1744 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
| 1745 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
| 1802 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
| 1803 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
| 1804 | + } |
|
| 1746 | 1805 | |
| 1747 | 1806 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
| 1748 | 1807 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1759,8 +1818,9 @@ discard block |
||
| 1759 | 1818 | |
| 1760 | 1819 | // Some masking stuff... |
| 1761 | 1820 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
| 1762 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
| 1763 | - $mask .= $_POST['regex']; |
|
| 1821 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
| 1822 | + $mask .= $_POST['regex']; |
|
| 1823 | + } |
|
| 1764 | 1824 | |
| 1765 | 1825 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
| 1766 | 1826 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1779,8 +1839,9 @@ discard block |
||
| 1779 | 1839 | $v = strtr($v, array(',' => '')); |
| 1780 | 1840 | |
| 1781 | 1841 | // Nada, zip, etc... |
| 1782 | - if (trim($v) == '') |
|
| 1783 | - continue; |
|
| 1842 | + if (trim($v) == '') { |
|
| 1843 | + continue; |
|
| 1844 | + } |
|
| 1784 | 1845 | |
| 1785 | 1846 | // Otherwise, save it boy. |
| 1786 | 1847 | $field_options .= $v . ','; |
@@ -1788,15 +1849,17 @@ discard block |
||
| 1788 | 1849 | $newOptions[$k] = $v; |
| 1789 | 1850 | |
| 1790 | 1851 | // Is it default? |
| 1791 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
| 1792 | - $default = $v; |
|
| 1852 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
| 1853 | + $default = $v; |
|
| 1854 | + } |
|
| 1793 | 1855 | } |
| 1794 | 1856 | $field_options = substr($field_options, 0, -1); |
| 1795 | 1857 | } |
| 1796 | 1858 | |
| 1797 | 1859 | // Text area has default has dimensions |
| 1798 | - if ($_POST['field_type'] == 'textarea') |
|
| 1799 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
| 1860 | + if ($_POST['field_type'] == 'textarea') { |
|
| 1861 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
| 1862 | + } |
|
| 1800 | 1863 | |
| 1801 | 1864 | // Come up with the unique name? |
| 1802 | 1865 | if (empty($context['fid'])) |
@@ -1805,32 +1868,36 @@ discard block |
||
| 1805 | 1868 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
| 1806 | 1869 | |
| 1807 | 1870 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
| 1808 | - if (isset($matches[1])) |
|
| 1809 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
| 1810 | - else |
|
| 1811 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
| 1871 | + if (isset($matches[1])) { |
|
| 1872 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
| 1873 | + } else { |
|
| 1874 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
| 1875 | + } |
|
| 1812 | 1876 | |
| 1813 | 1877 | // Make sure this is unique. |
| 1814 | 1878 | $current_fields = array(); |
| 1815 | 1879 | $request = $smcFunc['db_query']('', ' |
| 1816 | 1880 | SELECT id_field, col_name |
| 1817 | 1881 | FROM {db_prefix}custom_fields'); |
| 1818 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1819 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
| 1882 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1883 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
| 1884 | + } |
|
| 1820 | 1885 | $smcFunc['db_free_result']($request); |
| 1821 | 1886 | |
| 1822 | 1887 | $unique = false; |
| 1823 | 1888 | for ($i = 0; !$unique && $i < 9; $i ++) |
| 1824 | 1889 | { |
| 1825 | - if (!in_array($col_name, $current_fields)) |
|
| 1826 | - $unique = true; |
|
| 1827 | - else |
|
| 1828 | - $col_name = $initial_col_name . $i; |
|
| 1890 | + if (!in_array($col_name, $current_fields)) { |
|
| 1891 | + $unique = true; |
|
| 1892 | + } else { |
|
| 1893 | + $col_name = $initial_col_name . $i; |
|
| 1894 | + } |
|
| 1829 | 1895 | } |
| 1830 | 1896 | |
| 1831 | 1897 | // Still not a unique column name? Leave it up to the user, then. |
| 1832 | - if (!$unique) |
|
| 1833 | - fatal_lang_error('custom_option_not_unique'); |
|
| 1898 | + if (!$unique) { |
|
| 1899 | + fatal_lang_error('custom_option_not_unique'); |
|
| 1900 | + } |
|
| 1834 | 1901 | } |
| 1835 | 1902 | // Work out what to do with the user data otherwise... |
| 1836 | 1903 | else |
@@ -1858,8 +1925,9 @@ discard block |
||
| 1858 | 1925 | // Work out what's changed! |
| 1859 | 1926 | foreach ($context['field']['options'] as $k => $option) |
| 1860 | 1927 | { |
| 1861 | - if (trim($option) == '') |
|
| 1862 | - continue; |
|
| 1928 | + if (trim($option) == '') { |
|
| 1929 | + continue; |
|
| 1930 | + } |
|
| 1863 | 1931 | |
| 1864 | 1932 | // Still exists? |
| 1865 | 1933 | if (in_array($option, $newOptions)) |
@@ -1873,8 +1941,8 @@ discard block |
||
| 1873 | 1941 | foreach ($optionChanges as $k => $option) |
| 1874 | 1942 | { |
| 1875 | 1943 | // Just been renamed? |
| 1876 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
| 1877 | - $smcFunc['db_query']('', ' |
|
| 1944 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
| 1945 | + $smcFunc['db_query']('', ' |
|
| 1878 | 1946 | UPDATE {db_prefix}themes |
| 1879 | 1947 | SET value = {string:new_value} |
| 1880 | 1948 | WHERE variable = {string:current_column} |
@@ -1887,6 +1955,7 @@ discard block |
||
| 1887 | 1955 | 'old_value' => $option, |
| 1888 | 1956 | ) |
| 1889 | 1957 | ); |
| 1958 | + } |
|
| 1890 | 1959 | } |
| 1891 | 1960 | } |
| 1892 | 1961 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1929,8 +1998,8 @@ discard block |
||
| 1929 | 1998 | ); |
| 1930 | 1999 | |
| 1931 | 2000 | // Just clean up any old selects - these are a pain! |
| 1932 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
| 1933 | - $smcFunc['db_query']('', ' |
|
| 2001 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
| 2002 | + $smcFunc['db_query']('', ' |
|
| 1934 | 2003 | DELETE FROM {db_prefix}themes |
| 1935 | 2004 | WHERE variable = {string:current_column} |
| 1936 | 2005 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1941,8 +2010,8 @@ discard block |
||
| 1941 | 2010 | 'current_column' => $context['field']['col_name'], |
| 1942 | 2011 | ) |
| 1943 | 2012 | ); |
| 1944 | - } |
|
| 1945 | - else |
|
| 2013 | + } |
|
| 2014 | + } else |
|
| 1946 | 2015 | { |
| 1947 | 2016 | // Gotta figure it out the order. |
| 1948 | 2017 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2116,11 +2185,13 @@ discard block |
||
| 2116 | 2185 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
| 2117 | 2186 | |
| 2118 | 2187 | $prune_toggle_dt = array(); |
| 2119 | - foreach ($prune_toggle as $item) |
|
| 2120 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
| 2188 | + foreach ($prune_toggle as $item) { |
|
| 2189 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
| 2190 | + } |
|
| 2121 | 2191 | |
| 2122 | - if ($return_config) |
|
| 2123 | - return $config_vars; |
|
| 2192 | + if ($return_config) { |
|
| 2193 | + return $config_vars; |
|
| 2194 | + } |
|
| 2124 | 2195 | |
| 2125 | 2196 | addInlineJavaScript(' |
| 2126 | 2197 | function togglePruned() |
@@ -2158,15 +2229,16 @@ discard block |
||
| 2158 | 2229 | $vals = array(); |
| 2159 | 2230 | foreach ($config_vars as $index => $dummy) |
| 2160 | 2231 | { |
| 2161 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
| 2162 | - continue; |
|
| 2232 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
| 2233 | + continue; |
|
| 2234 | + } |
|
| 2163 | 2235 | |
| 2164 | 2236 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
| 2165 | 2237 | } |
| 2166 | 2238 | $_POST['pruningOptions'] = implode(',', $vals); |
| 2239 | + } else { |
|
| 2240 | + $_POST['pruningOptions'] = ''; |
|
| 2167 | 2241 | } |
| 2168 | - else |
|
| 2169 | - $_POST['pruningOptions'] = ''; |
|
| 2170 | 2242 | |
| 2171 | 2243 | saveDBSettings($savevar); |
| 2172 | 2244 | $_SESSION['adm-save'] = true; |
@@ -2178,10 +2250,11 @@ discard block |
||
| 2178 | 2250 | $context['sub_template'] = 'show_settings'; |
| 2179 | 2251 | |
| 2180 | 2252 | // Get the actual values |
| 2181 | - if (!empty($modSettings['pruningOptions'])) |
|
| 2182 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 2183 | - else |
|
| 2184 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
| 2253 | + if (!empty($modSettings['pruningOptions'])) { |
|
| 2254 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 2255 | + } else { |
|
| 2256 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
| 2257 | + } |
|
| 2185 | 2258 | |
| 2186 | 2259 | prepareDBSettingContext($config_vars); |
| 2187 | 2260 | } |
@@ -2203,8 +2276,9 @@ discard block |
||
| 2203 | 2276 | // Make it even easier to add new settings. |
| 2204 | 2277 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
| 2205 | 2278 | |
| 2206 | - if ($return_config) |
|
| 2207 | - return $config_vars; |
|
| 2279 | + if ($return_config) { |
|
| 2280 | + return $config_vars; |
|
| 2281 | + } |
|
| 2208 | 2282 | |
| 2209 | 2283 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
| 2210 | 2284 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $query_where = array(); |
| 167 | 167 | $query_params = $search_data['params']; |
| 168 | 168 | |
| 169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
| 169 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
| 170 | 170 | $modSettings['search_simple_fulltext'] = true; |
| 171 | 171 | |
| 172 | 172 | if ($query_params['id_search']) |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | if (!empty($modSettings['search_simple_fulltext'])) |
| 211 | 211 | { |
| 212 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
| 212 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
| 213 | 213 | { |
| 214 | 214 | $language_ftx = $smcFunc['db_search_language'](); |
| 215 | 215 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | // remove any indexed words that are used in the complex body search terms |
| 228 | 228 | $words['indexed_words'] = array_diff($words['indexed_words'], $words['complex_words']); |
| 229 | 229 | |
| 230 | - if($smcFunc['db_title'] == "PostgreSQL"){ |
|
| 230 | + if ($smcFunc['db_title'] == "PostgreSQL") { |
|
| 231 | 231 | $row = 0; |
| 232 | 232 | foreach ($words['indexed_words'] as $fulltextWord) { |
| 233 | 233 | $query_params['boolean_match'] .= ($row <> 0 ? '&' : ''); |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | // if we have bool terms to search, add them in |
| 245 | 245 | if ($query_params['boolean_match']) { |
| 246 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
| 246 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
| 247 | 247 | { |
| 248 | 248 | $language_ftx = $smcFunc['db_search_language'](); |
| 249 | 249 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
| 259 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
| 260 | 260 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
| 261 | 261 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
| 262 | 262 | SELECT ' . implode(', ', $query_select) . ' |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Class fulltext_search |
@@ -98,8 +99,9 @@ discard block |
||
| 98 | 99 | $smcFunc['db_free_result']($request); |
| 99 | 100 | } |
| 100 | 101 | // 4 is the MySQL default... |
| 101 | - else |
|
| 102 | - $min_word_length = 4; |
|
| 102 | + else { |
|
| 103 | + $min_word_length = 4; |
|
| 104 | + } |
|
| 103 | 105 | |
| 104 | 106 | return $min_word_length; |
| 105 | 107 | } |
@@ -138,8 +140,7 @@ discard block |
||
| 138 | 140 | $wordsSearch['words'][] = trim($word, "/*- "); |
| 139 | 141 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
| 140 | 142 | } |
| 141 | - } |
|
| 142 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
| 143 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
| 143 | 144 | { |
| 144 | 145 | // short words have feelings too |
| 145 | 146 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -149,8 +150,9 @@ discard block |
||
| 149 | 150 | |
| 150 | 151 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
| 151 | 152 | $wordsSearch['indexed_words'][] = $fulltextWord; |
| 152 | - if ($isExcluded) |
|
| 153 | - $wordsExclude[] = $fulltextWord; |
|
| 153 | + if ($isExcluded) { |
|
| 154 | + $wordsExclude[] = $fulltextWord; |
|
| 155 | + } |
|
| 154 | 156 | } |
| 155 | 157 | |
| 156 | 158 | /** |
@@ -166,44 +168,54 @@ discard block |
||
| 166 | 168 | $query_where = array(); |
| 167 | 169 | $query_params = $search_data['params']; |
| 168 | 170 | |
| 169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
| 170 | - $modSettings['search_simple_fulltext'] = true; |
|
| 171 | + if( $smcFunc['db_title'] == "PostgreSQL") { |
|
| 172 | + $modSettings['search_simple_fulltext'] = true; |
|
| 173 | + } |
|
| 171 | 174 | |
| 172 | - if ($query_params['id_search']) |
|
| 173 | - $query_select['id_search'] = '{int:id_search}'; |
|
| 175 | + if ($query_params['id_search']) { |
|
| 176 | + $query_select['id_search'] = '{int:id_search}'; |
|
| 177 | + } |
|
| 174 | 178 | |
| 175 | 179 | $count = 0; |
| 176 | - if (empty($modSettings['search_simple_fulltext'])) |
|
| 177 | - foreach ($words['words'] as $regularWord) |
|
| 180 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
| 181 | + foreach ($words['words'] as $regularWord) |
|
| 178 | 182 | { |
| 179 | 183 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
| 184 | + } |
|
| 180 | 185 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 181 | 186 | } |
| 182 | 187 | |
| 183 | - if ($query_params['user_query']) |
|
| 184 | - $query_where[] = '{raw:user_query}'; |
|
| 185 | - if ($query_params['board_query']) |
|
| 186 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 188 | + if ($query_params['user_query']) { |
|
| 189 | + $query_where[] = '{raw:user_query}'; |
|
| 190 | + } |
|
| 191 | + if ($query_params['board_query']) { |
|
| 192 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 193 | + } |
|
| 187 | 194 | |
| 188 | - if ($query_params['topic']) |
|
| 189 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 190 | - if ($query_params['min_msg_id']) |
|
| 191 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 192 | - if ($query_params['max_msg_id']) |
|
| 193 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 195 | + if ($query_params['topic']) { |
|
| 196 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 197 | + } |
|
| 198 | + if ($query_params['min_msg_id']) { |
|
| 199 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 200 | + } |
|
| 201 | + if ($query_params['max_msg_id']) { |
|
| 202 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 203 | + } |
|
| 194 | 204 | |
| 195 | 205 | $count = 0; |
| 196 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
| 197 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 206 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
| 207 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 198 | 208 | { |
| 199 | 209 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
| 210 | + } |
|
| 200 | 211 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
| 201 | 212 | } |
| 202 | 213 | $count = 0; |
| 203 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
| 204 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 214 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
| 215 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 205 | 216 | { |
| 206 | 217 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
| 218 | + } |
|
| 207 | 219 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
| 208 | 220 | } |
| 209 | 221 | |
@@ -215,12 +227,11 @@ discard block |
||
| 215 | 227 | |
| 216 | 228 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:body_match})'; |
| 217 | 229 | $query_params['language_ftx'] = $language_ftx; |
| 230 | + } else { |
|
| 231 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
| 218 | 232 | } |
| 219 | - else |
|
| 220 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
| 221 | 233 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
| 222 | - } |
|
| 223 | - else |
|
| 234 | + } else |
|
| 224 | 235 | { |
| 225 | 236 | $query_params['boolean_match'] = ''; |
| 226 | 237 | |
@@ -234,10 +245,10 @@ discard block |
||
| 234 | 245 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
| 235 | 246 | $row++; |
| 236 | 247 | } |
| 237 | - } |
|
| 238 | - else |
|
| 239 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
| 248 | + } else { |
|
| 249 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
| 240 | 250 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
| 251 | + } |
|
| 241 | 252 | |
| 242 | 253 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
| 243 | 254 | |
@@ -249,9 +260,9 @@ discard block |
||
| 249 | 260 | |
| 250 | 261 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:boolean_match})'; |
| 251 | 262 | $query_params['language_ftx'] = $language_ftx; |
| 263 | + } else { |
|
| 264 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
| 252 | 265 | } |
| 253 | - else |
|
| 254 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
| 255 | 266 | } |
| 256 | 267 | |
| 257 | 268 | } |
@@ -29,9 +29,10 @@ discard block |
||
| 29 | 29 | // Go through each type of report they can run. |
| 30 | 30 | foreach ($context['report_types'] as $type) |
| 31 | 31 | { |
| 32 | - if (isset($type['description'])) |
|
| 33 | - echo ' |
|
| 32 | + if (isset($type['description'])) { |
|
| 33 | + echo ' |
|
| 34 | 34 | <dt>', $type['description'], '</dt>'; |
| 35 | + } |
|
| 35 | 36 | echo ' |
| 36 | 37 | <dd> |
| 37 | 38 | <input type="radio" id="rt_', $type['id'], '" name="rt" value="', $type['id'], '"', $type['is_first'] ? ' checked' : '', '> |
@@ -61,8 +62,9 @@ discard block |
||
| 61 | 62 | </div> |
| 62 | 63 | <div id="report_buttons">'; |
| 63 | 64 | |
| 64 | - if (!empty($context['report_buttons'])) |
|
| 65 | - template_button_strip($context['report_buttons'], 'right'); |
|
| 65 | + if (!empty($context['report_buttons'])) { |
|
| 66 | + template_button_strip($context['report_buttons'], 'right'); |
|
| 67 | + } |
|
| 66 | 68 | |
| 67 | 69 | echo ' |
| 68 | 70 | </div>'; |
@@ -73,25 +75,27 @@ discard block |
||
| 73 | 75 | echo ' |
| 74 | 76 | <table class="table_grid report_results">'; |
| 75 | 77 | |
| 76 | - if (!empty($table['title'])) |
|
| 77 | - echo ' |
|
| 78 | + if (!empty($table['title'])) { |
|
| 79 | + echo ' |
|
| 78 | 80 | <thead> |
| 79 | 81 | <tr class="title_bar"> |
| 80 | 82 | <th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th> |
| 81 | 83 | </tr> |
| 82 | 84 | </thead> |
| 83 | 85 | <tbody>'; |
| 86 | + } |
|
| 84 | 87 | |
| 85 | 88 | // Now do each row! |
| 86 | 89 | $row_number = 0; |
| 87 | 90 | foreach ($table['data'] as $row) |
| 88 | 91 | { |
| 89 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
| 90 | - echo ' |
|
| 92 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
| 93 | + echo ' |
|
| 91 | 94 | <tr class="windowbg table_caption">'; |
| 92 | - else |
|
| 93 | - echo ' |
|
| 95 | + } else { |
|
| 96 | + echo ' |
|
| 94 | 97 | <tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">'; |
| 98 | + } |
|
| 95 | 99 | |
| 96 | 100 | // Now do each column. |
| 97 | 101 | $column_number = 0; |
@@ -109,16 +113,17 @@ discard block |
||
| 109 | 113 | } |
| 110 | 114 | |
| 111 | 115 | // Shaded? |
| 112 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
| 113 | - echo ' |
|
| 116 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
| 117 | + echo ' |
|
| 114 | 118 | <td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
| 115 | 119 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
| 116 | 120 | </td>'; |
| 117 | - else |
|
| 118 | - echo ' |
|
| 121 | + } else { |
|
| 122 | + echo ' |
|
| 119 | 123 | <td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
| 120 | 124 | ', $data['v'], ' |
| 121 | 125 | </td>'; |
| 126 | + } |
|
| 122 | 127 | |
| 123 | 128 | $column_number++; |
| 124 | 129 | } |
@@ -167,24 +172,26 @@ discard block |
||
| 167 | 172 | <div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '"> |
| 168 | 173 | <table class="bordercolor">'; |
| 169 | 174 | |
| 170 | - if (!empty($table['title'])) |
|
| 171 | - echo ' |
|
| 175 | + if (!empty($table['title'])) { |
|
| 176 | + echo ' |
|
| 172 | 177 | <tr class="title_bar"> |
| 173 | 178 | <td colspan="', $table['column_count'], '"> |
| 174 | 179 | ', $table['title'], ' |
| 175 | 180 | </td> |
| 176 | 181 | </tr>'; |
| 182 | + } |
|
| 177 | 183 | |
| 178 | 184 | // Now do each row! |
| 179 | 185 | $row_number = 0; |
| 180 | 186 | foreach ($table['data'] as $row) |
| 181 | 187 | { |
| 182 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
| 183 | - echo ' |
|
| 188 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
| 189 | + echo ' |
|
| 184 | 190 | <tr class="titlebg">'; |
| 185 | - else |
|
| 186 | - echo ' |
|
| 191 | + } else { |
|
| 192 | + echo ' |
|
| 187 | 193 | <tr class="windowbg">'; |
| 194 | + } |
|
| 188 | 195 | |
| 189 | 196 | // Now do each column!! |
| 190 | 197 | $column_number = 0; |
@@ -201,16 +208,17 @@ discard block |
||
| 201 | 208 | } |
| 202 | 209 | |
| 203 | 210 | // Shaded? |
| 204 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
| 205 | - echo ' |
|
| 211 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
| 212 | + echo ' |
|
| 206 | 213 | <td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
| 207 | 214 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
| 208 | 215 | </td>'; |
| 209 | - else |
|
| 210 | - echo ' |
|
| 216 | + } else { |
|
| 217 | + echo ' |
|
| 211 | 218 | <td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
| 212 | 219 | ', $data['v'], ' |
| 213 | 220 | </td>'; |
| 221 | + } |
|
| 214 | 222 | |
| 215 | 223 | $column_number++; |
| 216 | 224 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
| 67 | 68 | ); |
| 68 | 69 | |
| 69 | 70 | // Force the right area... |
| 70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
| 71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
| 71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
| 72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
| 73 | + } |
|
| 72 | 74 | |
| 73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
| 74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
| 99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
| 100 | 102 | |
| 101 | 103 | // Remove the items that were selected. |
| 102 | - foreach ($temp_news as $i => $news) |
|
| 103 | - if (in_array($i, $_POST['remove'])) |
|
| 104 | + foreach ($temp_news as $i => $news) { |
|
| 105 | + if (in_array($i, $_POST['remove'])) |
|
| 104 | 106 | unset($temp_news[$i]); |
| 107 | + } |
|
| 105 | 108 | |
| 106 | 109 | // Update the database. |
| 107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
| 117 | 120 | |
| 118 | 121 | foreach ($_POST['news'] as $i => $news) |
| 119 | 122 | { |
| 120 | - if (trim($news) == '') |
|
| 121 | - unset($_POST['news'][$i]); |
|
| 122 | - else |
|
| 123 | + if (trim($news) == '') { |
|
| 124 | + unset($_POST['news'][$i]); |
|
| 125 | + } else |
|
| 123 | 126 | { |
| 124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
| 125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -154,11 +157,12 @@ discard block |
||
| 154 | 157 | 'data' => array( |
| 155 | 158 | 'function' => function($news) |
| 156 | 159 | { |
| 157 | - if (is_numeric($news['id'])) |
|
| 158 | - return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
| 160 | + if (is_numeric($news['id'])) { |
|
| 161 | + return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
| 159 | 162 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
| 160 | - else |
|
| 161 | - return $news['unparsed']; |
|
| 163 | + } else { |
|
| 164 | + return $news['unparsed']; |
|
| 165 | + } |
|
| 162 | 166 | }, |
| 163 | 167 | 'style' => 'width: 50%;', |
| 164 | 168 | ), |
@@ -183,10 +187,11 @@ discard block |
||
| 183 | 187 | 'data' => array( |
| 184 | 188 | 'function' => function($news) |
| 185 | 189 | { |
| 186 | - if (is_numeric($news['id'])) |
|
| 187 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
| 188 | - else |
|
| 189 | - return ''; |
|
| 190 | + if (is_numeric($news['id'])) { |
|
| 191 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
| 192 | + } else { |
|
| 193 | + return ''; |
|
| 194 | + } |
|
| 190 | 195 | }, |
| 191 | 196 | 'class' => 'centercol', |
| 192 | 197 | ), |
@@ -280,12 +285,13 @@ discard block |
||
| 280 | 285 | |
| 281 | 286 | $admin_current_news = array(); |
| 282 | 287 | // Ready the current news. |
| 283 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
| 284 | - $admin_current_news[$id] = array( |
|
| 288 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
| 289 | + $admin_current_news[$id] = array( |
|
| 285 | 290 | 'id' => $id, |
| 286 | 291 | 'unparsed' => un_preparsecode($line), |
| 287 | 292 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
| 288 | 293 | ); |
| 294 | + } |
|
| 289 | 295 | |
| 290 | 296 | $admin_current_news['last'] = array( |
| 291 | 297 | 'id' => 'last', |
@@ -352,10 +358,11 @@ discard block |
||
| 352 | 358 | 'member_count' => 0, |
| 353 | 359 | ); |
| 354 | 360 | |
| 355 | - if ($row['min_posts'] == -1) |
|
| 356 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
| 357 | - else |
|
| 358 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
| 361 | + if ($row['min_posts'] == -1) { |
|
| 362 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
| 363 | + } else { |
|
| 364 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
| 365 | + } |
|
| 359 | 366 | } |
| 360 | 367 | $smcFunc['db_free_result']($request); |
| 361 | 368 | |
@@ -371,8 +378,9 @@ discard block |
||
| 371 | 378 | 'post_group_list' => $postGroups, |
| 372 | 379 | ) |
| 373 | 380 | ); |
| 374 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 375 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 381 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 382 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 383 | + } |
|
| 376 | 384 | $smcFunc['db_free_result']($query); |
| 377 | 385 | } |
| 378 | 386 | |
@@ -388,8 +396,9 @@ discard block |
||
| 388 | 396 | 'normal_group_list' => $normalGroups, |
| 389 | 397 | ) |
| 390 | 398 | ); |
| 391 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 392 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 399 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 400 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 401 | + } |
|
| 393 | 402 | $smcFunc['db_free_result']($query); |
| 394 | 403 | |
| 395 | 404 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -406,8 +415,9 @@ discard block |
||
| 406 | 415 | 'blank_string' => '', |
| 407 | 416 | ) |
| 408 | 417 | ); |
| 409 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 410 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 418 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 419 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 420 | + } |
|
| 411 | 421 | $smcFunc['db_free_result']($query); |
| 412 | 422 | } |
| 413 | 423 | |
@@ -458,10 +468,11 @@ discard block |
||
| 458 | 468 | { |
| 459 | 469 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
| 460 | 470 | |
| 461 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
| 462 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
| 463 | - elseif (!empty($_REQUEST['xml'])) |
|
| 464 | - continue; |
|
| 471 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
| 472 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
| 473 | + } elseif (!empty($_REQUEST['xml'])) { |
|
| 474 | + continue; |
|
| 475 | + } |
|
| 465 | 476 | |
| 466 | 477 | preparsecode($context[$key]); |
| 467 | 478 | if ($html) |
@@ -540,10 +551,12 @@ discard block |
||
| 540 | 551 | |
| 541 | 552 | // Start by finding any members! |
| 542 | 553 | $toClean = array(); |
| 543 | - if (!empty($_POST['members'])) |
|
| 544 | - $toClean[] = 'members'; |
|
| 545 | - if (!empty($_POST['exclude_members'])) |
|
| 546 | - $toClean[] = 'exclude_members'; |
|
| 554 | + if (!empty($_POST['members'])) { |
|
| 555 | + $toClean[] = 'members'; |
|
| 556 | + } |
|
| 557 | + if (!empty($_POST['exclude_members'])) { |
|
| 558 | + $toClean[] = 'exclude_members'; |
|
| 559 | + } |
|
| 547 | 560 | if (!empty($toClean)) |
| 548 | 561 | { |
| 549 | 562 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -555,11 +568,13 @@ discard block |
||
| 555 | 568 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
| 556 | 569 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
| 557 | 570 | |
| 558 | - foreach ($_POST[$type] as $index => $member) |
|
| 559 | - if (strlen(trim($member)) > 0) |
|
| 571 | + foreach ($_POST[$type] as $index => $member) { |
|
| 572 | + if (strlen(trim($member)) > 0) |
|
| 560 | 573 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
| 561 | - else |
|
| 562 | - unset($_POST[$type][$index]); |
|
| 574 | + } |
|
| 575 | + else { |
|
| 576 | + unset($_POST[$type][$index]); |
|
| 577 | + } |
|
| 563 | 578 | |
| 564 | 579 | // Find the members |
| 565 | 580 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -569,16 +584,18 @@ discard block |
||
| 569 | 584 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
| 570 | 585 | { |
| 571 | 586 | $members = array(); |
| 572 | - foreach ($_POST['member_list'] as $member_id) |
|
| 573 | - $members[] = (int) $member_id; |
|
| 587 | + foreach ($_POST['member_list'] as $member_id) { |
|
| 588 | + $members[] = (int) $member_id; |
|
| 589 | + } |
|
| 574 | 590 | $_POST['members'] = implode(',', $members); |
| 575 | 591 | } |
| 576 | 592 | |
| 577 | 593 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
| 578 | 594 | { |
| 579 | 595 | $members = array(); |
| 580 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
| 581 | - $members[] = (int) $member_id; |
|
| 596 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
| 597 | + $members[] = (int) $member_id; |
|
| 598 | + } |
|
| 582 | 599 | $_POST['exclude_members'] = implode(',', $members); |
| 583 | 600 | } |
| 584 | 601 | |
@@ -602,8 +619,9 @@ discard block |
||
| 602 | 619 | 'current_time' => time(), |
| 603 | 620 | ) |
| 604 | 621 | ); |
| 605 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 606 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 623 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 624 | + } |
|
| 607 | 625 | $smcFunc['db_free_result']($request); |
| 608 | 626 | |
| 609 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -638,8 +656,9 @@ discard block |
||
| 638 | 656 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
| 639 | 657 | $condition_array_params |
| 640 | 658 | ); |
| 641 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 642 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 659 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 660 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 661 | + } |
|
| 643 | 662 | $smcFunc['db_free_result']($request); |
| 644 | 663 | } |
| 645 | 664 | |
@@ -657,10 +676,11 @@ discard block |
||
| 657 | 676 | ); |
| 658 | 677 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 659 | 678 | { |
| 660 | - if (in_array(3, $context['recipients'])) |
|
| 661 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
| 662 | - else |
|
| 663 | - $context['recipients']['members'][] = $row['identifier']; |
|
| 679 | + if (in_array(3, $context['recipients'])) { |
|
| 680 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
| 681 | + } else { |
|
| 682 | + $context['recipients']['members'][] = $row['identifier']; |
|
| 683 | + } |
|
| 664 | 684 | } |
| 665 | 685 | $smcFunc['db_free_result']($request); |
| 666 | 686 | } |
@@ -707,8 +727,9 @@ discard block |
||
| 707 | 727 | $num_at_once = 1000; |
| 708 | 728 | |
| 709 | 729 | // If by PM's I suggest we half the above number. |
| 710 | - if (!empty($_POST['send_pm'])) |
|
| 711 | - $num_at_once /= 2; |
|
| 730 | + if (!empty($_POST['send_pm'])) { |
|
| 731 | + $num_at_once /= 2; |
|
| 732 | + } |
|
| 712 | 733 | |
| 713 | 734 | checkSession(); |
| 714 | 735 | |
@@ -731,8 +752,7 @@ discard block |
||
| 731 | 752 | ); |
| 732 | 753 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
| 733 | 754 | $smcFunc['db_free_result']($request); |
| 734 | - } |
|
| 735 | - else |
|
| 755 | + } else |
|
| 736 | 756 | { |
| 737 | 757 | $context['total_members'] = (int) $_REQUEST['total_members']; |
| 738 | 758 | } |
@@ -750,32 +770,35 @@ discard block |
||
| 750 | 770 | if (!empty($_POST['exclude_members'])) |
| 751 | 771 | { |
| 752 | 772 | $members = explode(',', $_POST['exclude_members']); |
| 753 | - foreach ($members as $member) |
|
| 754 | - if ($member >= $context['start']) |
|
| 773 | + foreach ($members as $member) { |
|
| 774 | + if ($member >= $context['start']) |
|
| 755 | 775 | $context['recipients']['exclude_members'][] = (int) $member; |
| 776 | + } |
|
| 756 | 777 | } |
| 757 | 778 | |
| 758 | 779 | // What about members we *must* do? |
| 759 | 780 | if (!empty($_POST['members'])) |
| 760 | 781 | { |
| 761 | 782 | $members = explode(',', $_POST['members']); |
| 762 | - foreach ($members as $member) |
|
| 763 | - if ($member >= $context['start']) |
|
| 783 | + foreach ($members as $member) { |
|
| 784 | + if ($member >= $context['start']) |
|
| 764 | 785 | $context['recipients']['members'][] = (int) $member; |
| 786 | + } |
|
| 765 | 787 | } |
| 766 | 788 | // Cleaning groups is simple - although deal with both checkbox and commas. |
| 767 | 789 | if (isset($_POST['groups'])) |
| 768 | 790 | { |
| 769 | 791 | if (is_array($_POST['groups'])) |
| 770 | 792 | { |
| 771 | - foreach ($_POST['groups'] as $group => $dummy) |
|
| 772 | - $context['recipients']['groups'][] = (int) $group; |
|
| 773 | - } |
|
| 774 | - else |
|
| 793 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
| 794 | + $context['recipients']['groups'][] = (int) $group; |
|
| 795 | + } |
|
| 796 | + } else |
|
| 775 | 797 | { |
| 776 | 798 | $groups = explode(',', $_POST['groups']); |
| 777 | - foreach ($groups as $group) |
|
| 778 | - $context['recipients']['groups'][] = (int) $group; |
|
| 799 | + foreach ($groups as $group) { |
|
| 800 | + $context['recipients']['groups'][] = (int) $group; |
|
| 801 | + } |
|
| 779 | 802 | } |
| 780 | 803 | } |
| 781 | 804 | // Same for excluded groups |
@@ -783,15 +806,17 @@ discard block |
||
| 783 | 806 | { |
| 784 | 807 | if (is_array($_POST['exclude_groups'])) |
| 785 | 808 | { |
| 786 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
| 787 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 809 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
| 810 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 811 | + } |
|
| 788 | 812 | } |
| 789 | 813 | // Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected |
| 790 | 814 | elseif ($_POST['exclude_groups'] != '') |
| 791 | 815 | { |
| 792 | 816 | $groups = explode(',', $_POST['exclude_groups']); |
| 793 | - foreach ($groups as $group) |
|
| 794 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 817 | + foreach ($groups as $group) { |
|
| 818 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 819 | + } |
|
| 795 | 820 | } |
| 796 | 821 | } |
| 797 | 822 | // Finally - emails! |
@@ -801,14 +826,16 @@ discard block |
||
| 801 | 826 | foreach ($addressed as $curmem) |
| 802 | 827 | { |
| 803 | 828 | $curmem = trim($curmem); |
| 804 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
| 805 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
| 829 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
| 830 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
| 831 | + } |
|
| 806 | 832 | } |
| 807 | 833 | } |
| 808 | 834 | |
| 809 | 835 | // If we're only cleaning drop out here. |
| 810 | - if ($clean_only) |
|
| 811 | - return; |
|
| 836 | + if ($clean_only) { |
|
| 837 | + return; |
|
| 838 | + } |
|
| 812 | 839 | |
| 813 | 840 | require_once($sourcedir . '/Subs-Post.php'); |
| 814 | 841 | |
@@ -824,16 +851,18 @@ discard block |
||
| 824 | 851 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
| 825 | 852 | { |
| 826 | 853 | // Prepare the message for HTML. |
| 827 | - if (!empty($_POST['parse_html'])) |
|
| 828 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
| 854 | + if (!empty($_POST['parse_html'])) { |
|
| 855 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
| 856 | + } |
|
| 829 | 857 | |
| 830 | 858 | // This is here to prevent spam filters from tagging this as spam. |
| 831 | 859 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
| 832 | 860 | { |
| 833 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
| 834 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
| 835 | - else |
|
| 836 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
| 861 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
| 862 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
| 863 | + } else { |
|
| 864 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
| 865 | + } |
|
| 837 | 866 | } |
| 838 | 867 | } |
| 839 | 868 | |
@@ -887,15 +916,17 @@ discard block |
||
| 887 | 916 | foreach ($context['recipients']['emails'] as $k => $email) |
| 888 | 917 | { |
| 889 | 918 | // Done as many as we can? |
| 890 | - if ($i >= $num_at_once) |
|
| 891 | - break; |
|
| 919 | + if ($i >= $num_at_once) { |
|
| 920 | + break; |
|
| 921 | + } |
|
| 892 | 922 | |
| 893 | 923 | // Don't sent it twice! |
| 894 | 924 | unset($context['recipients']['emails'][$k]); |
| 895 | 925 | |
| 896 | 926 | // Dammit - can't PM emails! |
| 897 | - if ($context['send_pm']) |
|
| 898 | - continue; |
|
| 927 | + if ($context['send_pm']) { |
|
| 928 | + continue; |
|
| 929 | + } |
|
| 899 | 930 | |
| 900 | 931 | $to_member = array( |
| 901 | 932 | $email, |
@@ -929,8 +960,9 @@ discard block |
||
| 929 | 960 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
| 930 | 961 | } |
| 931 | 962 | } |
| 932 | - if (!empty($queryBuild)) |
|
| 933 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
| 963 | + if (!empty($queryBuild)) { |
|
| 964 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
| 965 | + } |
|
| 934 | 966 | } |
| 935 | 967 | if (!empty($context['recipients']['members'])) |
| 936 | 968 | { |
@@ -949,8 +981,9 @@ discard block |
||
| 949 | 981 | } |
| 950 | 982 | |
| 951 | 983 | // Anything to exclude? |
| 952 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
| 953 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
| 984 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
| 985 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
| 986 | + } |
|
| 954 | 987 | if (!empty($context['recipients']['exclude_members'])) |
| 955 | 988 | { |
| 956 | 989 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -986,21 +1019,24 @@ discard block |
||
| 986 | 1019 | foreach ($rows as $row) |
| 987 | 1020 | { |
| 988 | 1021 | // Force them to have it? |
| 989 | - if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) |
|
| 990 | - continue; |
|
| 1022 | + if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) { |
|
| 1023 | + continue; |
|
| 1024 | + } |
|
| 991 | 1025 | |
| 992 | 1026 | // What groups are we looking at here? |
| 993 | - if (empty($row['additional_groups'])) |
|
| 994 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
| 995 | - else |
|
| 996 | - $groups = array_merge( |
|
| 1027 | + if (empty($row['additional_groups'])) { |
|
| 1028 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
| 1029 | + } else { |
|
| 1030 | + $groups = array_merge( |
|
| 997 | 1031 | array($row['id_group'], $row['id_post_group']), |
| 998 | 1032 | explode(',', $row['additional_groups']) |
| 999 | 1033 | ); |
| 1034 | + } |
|
| 1000 | 1035 | |
| 1001 | 1036 | // Excluded groups? |
| 1002 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
| 1003 | - continue; |
|
| 1037 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
| 1038 | + continue; |
|
| 1039 | + } |
|
| 1004 | 1040 | |
| 1005 | 1041 | // We might need this |
| 1006 | 1042 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1023,10 +1059,11 @@ discard block |
||
| 1023 | 1059 | ), $_POST['subject']); |
| 1024 | 1060 | |
| 1025 | 1061 | // Send the actual email - or a PM! |
| 1026 | - if (!$context['send_pm']) |
|
| 1027 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
| 1028 | - else |
|
| 1029 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
| 1062 | + if (!$context['send_pm']) { |
|
| 1063 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
| 1064 | + } else { |
|
| 1065 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
| 1066 | + } |
|
| 1030 | 1067 | } |
| 1031 | 1068 | } |
| 1032 | 1069 | |
@@ -1076,8 +1113,9 @@ discard block |
||
| 1076 | 1113 | |
| 1077 | 1114 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
| 1078 | 1115 | |
| 1079 | - if ($return_config) |
|
| 1080 | - return $config_vars; |
|
| 1116 | + if ($return_config) { |
|
| 1117 | + return $config_vars; |
|
| 1118 | + } |
|
| 1081 | 1119 | |
| 1082 | 1120 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
| 1083 | 1121 | $context['sub_template'] = 'show_settings'; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | 'class' => 'centercol', |
| 257 | 257 | ), |
| 258 | 258 | 'data' => array( |
| 259 | - 'function' => function ($entry) |
|
| 259 | + 'function' => function($entry) |
|
| 260 | 260 | { |
| 261 | 261 | return '<input type="checkbox" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>'; |
| 262 | 262 | }, |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | if (empty($entries[$k]['action_text'])) |
| 639 | 639 | $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
| 640 | 640 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
| 641 | - function ($matches) use ($entries, $k) |
|
| 641 | + function($matches) use ($entries, $k) |
|
| 642 | 642 | { |
| 643 | 643 | return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : ''; |
| 644 | 644 | }, $entries[$k]['action_text']); |
@@ -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 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
| 32 | 33 | |
| 33 | 34 | // Are we looking at the moderation log or the administration log. |
| 34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
| 35 | - if ($context['log_type'] == 3) |
|
| 36 | - isAllowedTo('admin_forum'); |
|
| 36 | + if ($context['log_type'] == 3) { |
|
| 37 | + isAllowedTo('admin_forum'); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
| 39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
| 40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 41 | - else |
|
| 42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
| 42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 43 | + } else { |
|
| 44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 45 | + } |
|
| 43 | 46 | |
| 44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
| 45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
| 67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
| 68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
| 69 | 72 | |
| 70 | - } |
|
| 71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 72 | 74 | { |
| 73 | 75 | checkSession(); |
| 74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
| 114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
| 115 | 117 | ); |
| 116 | 118 | |
| 117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
| 118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 119 | - else |
|
| 120 | - $search_params_string = $search_params['string']; |
|
| 119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
| 120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 121 | + } else { |
|
| 122 | + $search_params_string = $search_params['string']; |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
| 123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 124 | - else |
|
| 125 | - $search_params_type = $search_params['type']; |
|
| 125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
| 126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 127 | + } else { |
|
| 128 | + $search_params_type = $search_params['type']; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
| 128 | 132 | $search_params = array( |
@@ -301,15 +305,16 @@ discard block |
||
| 301 | 305 | $context['default_list'] = 'moderation_log_list'; |
| 302 | 306 | |
| 303 | 307 | // If a hook has changed this, respect it. |
| 304 | - if (!empty($moderation_menu_name)) |
|
| 305 | - $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
| 306 | - elseif (isset($context['moderation_menu_name'])) |
|
| 307 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 308 | + if (!empty($moderation_menu_name)) { |
|
| 309 | + $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
| 310 | + } elseif (isset($context['moderation_menu_name'])) { |
|
| 311 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 308 | 312 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
| 309 | 313 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
| 310 | 314 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
| 311 | 315 | ); |
| 312 | -} |
|
| 316 | + } |
|
| 317 | + } |
|
| 313 | 318 | |
| 314 | 319 | /** |
| 315 | 320 | * Get the number of mod log entries. |
@@ -413,30 +418,35 @@ discard block |
||
| 413 | 418 | // Add on some of the column stuff info |
| 414 | 419 | if (!empty($row['id_board'])) |
| 415 | 420 | { |
| 416 | - if ($row['action'] == 'move') |
|
| 417 | - $row['extra']['board_to'] = $row['id_board']; |
|
| 418 | - else |
|
| 419 | - $row['extra']['board'] = $row['id_board']; |
|
| 421 | + if ($row['action'] == 'move') { |
|
| 422 | + $row['extra']['board_to'] = $row['id_board']; |
|
| 423 | + } else { |
|
| 424 | + $row['extra']['board'] = $row['id_board']; |
|
| 425 | + } |
|
| 420 | 426 | } |
| 421 | 427 | |
| 422 | - if (!empty($row['id_topic'])) |
|
| 423 | - $row['extra']['topic'] = $row['id_topic']; |
|
| 424 | - if (!empty($row['id_msg'])) |
|
| 425 | - $row['extra']['message'] = $row['id_msg']; |
|
| 428 | + if (!empty($row['id_topic'])) { |
|
| 429 | + $row['extra']['topic'] = $row['id_topic']; |
|
| 430 | + } |
|
| 431 | + if (!empty($row['id_msg'])) { |
|
| 432 | + $row['extra']['message'] = $row['id_msg']; |
|
| 433 | + } |
|
| 426 | 434 | |
| 427 | 435 | // Is this associated with a topic? |
| 428 | - if (isset($row['extra']['topic'])) |
|
| 429 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 430 | - if (isset($row['extra']['new_topic'])) |
|
| 431 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 436 | + if (isset($row['extra']['topic'])) { |
|
| 437 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 438 | + } |
|
| 439 | + if (isset($row['extra']['new_topic'])) { |
|
| 440 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 441 | + } |
|
| 432 | 442 | |
| 433 | 443 | // How about a member? |
| 434 | 444 | if (isset($row['extra']['member'])) |
| 435 | 445 | { |
| 436 | 446 | // Guests don't have names! |
| 437 | - if (empty($row['extra']['member'])) |
|
| 438 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 439 | - else |
|
| 447 | + if (empty($row['extra']['member'])) { |
|
| 448 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 449 | + } else |
|
| 440 | 450 | { |
| 441 | 451 | // Try to find it... |
| 442 | 452 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -444,35 +454,42 @@ discard block |
||
| 444 | 454 | } |
| 445 | 455 | |
| 446 | 456 | // Associated with a board? |
| 447 | - if (isset($row['extra']['board_to'])) |
|
| 448 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 449 | - if (isset($row['extra']['board_from'])) |
|
| 450 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 451 | - if (isset($row['extra']['board'])) |
|
| 452 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 457 | + if (isset($row['extra']['board_to'])) { |
|
| 458 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 459 | + } |
|
| 460 | + if (isset($row['extra']['board_from'])) { |
|
| 461 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 462 | + } |
|
| 463 | + if (isset($row['extra']['board'])) { |
|
| 464 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 465 | + } |
|
| 453 | 466 | |
| 454 | 467 | // A message? |
| 455 | - if (isset($row['extra']['message'])) |
|
| 456 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 468 | + if (isset($row['extra']['message'])) { |
|
| 469 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 470 | + } |
|
| 457 | 471 | |
| 458 | 472 | // IP Info? |
| 459 | - if (isset($row['extra']['ip_range'])) |
|
| 460 | - if ($seeIP) |
|
| 473 | + if (isset($row['extra']['ip_range'])) { |
|
| 474 | + if ($seeIP) |
|
| 461 | 475 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
| 462 | - else |
|
| 463 | - $row['extra']['ip_range'] = $txt['logged']; |
|
| 476 | + } else { |
|
| 477 | + $row['extra']['ip_range'] = $txt['logged']; |
|
| 478 | + } |
|
| 464 | 479 | |
| 465 | 480 | // Email? |
| 466 | - if (isset($row['extra']['email'])) |
|
| 467 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 481 | + if (isset($row['extra']['email'])) { |
|
| 482 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 483 | + } |
|
| 468 | 484 | |
| 469 | 485 | // Bans are complex. |
| 470 | 486 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
| 471 | 487 | { |
| 472 | 488 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
| 473 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
| 474 | - if (isset($row['extra'][$type])) |
|
| 489 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
| 490 | + if (isset($row['extra'][$type])) |
|
| 475 | 491 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
| 492 | + } |
|
| 476 | 493 | } |
| 477 | 494 | |
| 478 | 495 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -508,12 +525,13 @@ discard block |
||
| 508 | 525 | foreach ($boards[$row['id_board']] as $action) |
| 509 | 526 | { |
| 510 | 527 | // Make the board number into a link - dealing with moving too. |
| 511 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
| 512 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 513 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
| 514 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 515 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
| 516 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 528 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
| 529 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 530 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
| 531 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 532 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
| 533 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 534 | + } |
|
| 517 | 535 | } |
| 518 | 536 | } |
| 519 | 537 | $smcFunc['db_free_result']($request); |
@@ -547,10 +565,11 @@ discard block |
||
| 547 | 565 | ); |
| 548 | 566 | |
| 549 | 567 | // Make the topic number into a link - dealing with splitting too. |
| 550 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
| 551 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 552 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
| 553 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 568 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
| 569 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 570 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
| 571 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 572 | + } |
|
| 554 | 573 | } |
| 555 | 574 | } |
| 556 | 575 | $smcFunc['db_free_result']($request); |
@@ -583,8 +602,9 @@ discard block |
||
| 583 | 602 | ); |
| 584 | 603 | |
| 585 | 604 | // Make the message number into a link. |
| 586 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
| 587 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 605 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
| 606 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 607 | + } |
|
| 588 | 608 | } |
| 589 | 609 | } |
| 590 | 610 | $smcFunc['db_free_result']($request); |
@@ -624,25 +644,29 @@ discard block |
||
| 624 | 644 | foreach ($entries as $k => $entry) |
| 625 | 645 | { |
| 626 | 646 | // Make any message info links so its easier to go find that message. |
| 627 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
| 628 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 647 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
| 648 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 649 | + } |
|
| 629 | 650 | |
| 630 | 651 | // Mark up any deleted members, topics and boards. |
| 631 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
| 632 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 652 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
| 653 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 633 | 654 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
| 655 | + } |
|
| 634 | 656 | |
| 635 | 657 | if (isset($entry['extra']['report'])) |
| 636 | 658 | { |
| 637 | 659 | // Member profile reports go in a different area |
| 638 | - if (stristr($entry['action'], 'user_report')) |
|
| 639 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 640 | - else |
|
| 641 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 660 | + if (stristr($entry['action'], 'user_report')) { |
|
| 661 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 662 | + } else { |
|
| 663 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 664 | + } |
|
| 642 | 665 | } |
| 643 | 666 | |
| 644 | - if (empty($entries[$k]['action_text'])) |
|
| 645 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 667 | + if (empty($entries[$k]['action_text'])) { |
|
| 668 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 669 | + } |
|
| 646 | 670 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
| 647 | 671 | function ($matches) use ($entries, $k) |
| 648 | 672 | { |
@@ -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 | * The main designating function for modifying profiles. Loads up info, determins what to do, etc. |
@@ -29,18 +30,21 @@ discard block |
||
| 29 | 30 | global $modSettings, $memberContext, $profile_vars, $post_errors, $smcFunc; |
| 30 | 31 | |
| 31 | 32 | // Don't reload this as we may have processed error strings. |
| 32 | - if (empty($post_errors)) |
|
| 33 | - loadLanguage('Profile+Drafts'); |
|
| 33 | + if (empty($post_errors)) { |
|
| 34 | + loadLanguage('Profile+Drafts'); |
|
| 35 | + } |
|
| 34 | 36 | loadTemplate('Profile'); |
| 35 | 37 | |
| 36 | 38 | require_once($sourcedir . '/Subs-Menu.php'); |
| 37 | 39 | |
| 38 | 40 | // Did we get the user by name... |
| 39 | - if (isset($_REQUEST['user'])) |
|
| 40 | - $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
| 41 | + if (isset($_REQUEST['user'])) { |
|
| 42 | + $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
| 43 | + } |
|
| 41 | 44 | // ... or by id_member? |
| 42 | - elseif (!empty($_REQUEST['u'])) |
|
| 43 | - $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
| 45 | + elseif (!empty($_REQUEST['u'])) { |
|
| 46 | + $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
| 47 | + } |
|
| 44 | 48 | // If it was just ?action=profile, edit your own profile, but only if you're not a guest. |
| 45 | 49 | else |
| 46 | 50 | { |
@@ -50,8 +54,9 @@ discard block |
||
| 50 | 54 | } |
| 51 | 55 | |
| 52 | 56 | // Check if loadMemberData() has returned a valid result. |
| 53 | - if (!$memberResult) |
|
| 54 | - fatal_lang_error('not_a_user', false, 404); |
|
| 57 | + if (!$memberResult) { |
|
| 58 | + fatal_lang_error('not_a_user', false, 404); |
|
| 59 | + } |
|
| 55 | 60 | |
| 56 | 61 | // If all went well, we have a valid member ID! |
| 57 | 62 | list ($memID) = $memberResult; |
@@ -67,8 +72,9 @@ discard block |
||
| 67 | 72 | |
| 68 | 73 | // Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission. |
| 69 | 74 | // And we care about what the current user can do, not what the user whose profile it is. |
| 70 | - if ($user_info['mod_cache']['gq'] != '0=1') |
|
| 71 | - $user_info['permissions'][] = 'approve_group_requests'; |
|
| 75 | + if ($user_info['mod_cache']['gq'] != '0=1') { |
|
| 76 | + $user_info['permissions'][] = 'approve_group_requests'; |
|
| 77 | + } |
|
| 72 | 78 | |
| 73 | 79 | // If paid subscriptions are enabled, make sure we actually have at least one subscription available... |
| 74 | 80 | $context['subs_available'] = false; |
@@ -436,21 +442,25 @@ discard block |
||
| 436 | 442 | foreach ($section['areas'] as $area_id => $area) |
| 437 | 443 | { |
| 438 | 444 | // If it said no permissions that meant it wasn't valid! |
| 439 | - if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) |
|
| 440 | - $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
| 445 | + if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) { |
|
| 446 | + $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
| 447 | + } |
|
| 441 | 448 | // Otherwise pick the right set. |
| 442 | - else |
|
| 443 | - $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
| 449 | + else { |
|
| 450 | + $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
| 451 | + } |
|
| 444 | 452 | |
| 445 | 453 | // Password required in most cases |
| 446 | - if (!empty($area['password'])) |
|
| 447 | - $context['password_areas'][] = $area_id; |
|
| 454 | + if (!empty($area['password'])) { |
|
| 455 | + $context['password_areas'][] = $area_id; |
|
| 456 | + } |
|
| 448 | 457 | } |
| 449 | 458 | } |
| 450 | 459 | |
| 451 | 460 | // Is there an updated message to show? |
| 452 | - if (isset($_GET['updated'])) |
|
| 453 | - $context['profile_updated'] = $txt['profile_updated_own']; |
|
| 461 | + if (isset($_GET['updated'])) { |
|
| 462 | + $context['profile_updated'] = $txt['profile_updated_own']; |
|
| 463 | + } |
|
| 454 | 464 | |
| 455 | 465 | // Set a few options for the menu. |
| 456 | 466 | $menuOptions = array( |
@@ -465,8 +475,9 @@ discard block |
||
| 465 | 475 | $profile_include_data = createMenu($profile_areas, $menuOptions); |
| 466 | 476 | |
| 467 | 477 | // No menu means no access. |
| 468 | - if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) |
|
| 469 | - fatal_lang_error('no_access', false); |
|
| 478 | + if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
| 479 | + fatal_lang_error('no_access', false); |
|
| 480 | + } |
|
| 470 | 481 | |
| 471 | 482 | // Make a note of the Unique ID for this menu. |
| 472 | 483 | $context['profile_menu_id'] = $context['max_menu_id']; |
@@ -492,8 +503,9 @@ discard block |
||
| 492 | 503 | if ($current_area == $area_id) |
| 493 | 504 | { |
| 494 | 505 | // This can't happen - but is a security check. |
| 495 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) |
|
| 496 | - fatal_lang_error('no_access', false); |
|
| 506 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) { |
|
| 507 | + fatal_lang_error('no_access', false); |
|
| 508 | + } |
|
| 497 | 509 | |
| 498 | 510 | // Are we saving data in a valid area? |
| 499 | 511 | if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview'])) |
@@ -512,12 +524,14 @@ discard block |
||
| 512 | 524 | } |
| 513 | 525 | |
| 514 | 526 | // Does this require session validating? |
| 515 | - if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) |
|
| 516 | - $security_checks['validate'] = true; |
|
| 527 | + if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) { |
|
| 528 | + $security_checks['validate'] = true; |
|
| 529 | + } |
|
| 517 | 530 | |
| 518 | 531 | // Permissions for good measure. |
| 519 | - if (!empty($profile_include_data['permission'])) |
|
| 520 | - $security_checks['permission'] = $profile_include_data['permission']; |
|
| 532 | + if (!empty($profile_include_data['permission'])) { |
|
| 533 | + $security_checks['permission'] = $profile_include_data['permission']; |
|
| 534 | + } |
|
| 521 | 535 | |
| 522 | 536 | // Either way got something. |
| 523 | 537 | $found_area = true; |
@@ -526,21 +540,26 @@ discard block |
||
| 526 | 540 | } |
| 527 | 541 | |
| 528 | 542 | // Oh dear, some serious security lapse is going on here... we'll put a stop to that! |
| 529 | - if (!$found_area) |
|
| 530 | - fatal_lang_error('no_access', false); |
|
| 543 | + if (!$found_area) { |
|
| 544 | + fatal_lang_error('no_access', false); |
|
| 545 | + } |
|
| 531 | 546 | |
| 532 | 547 | // Release this now. |
| 533 | 548 | unset($profile_areas); |
| 534 | 549 | |
| 535 | 550 | // Now the context is setup have we got any security checks to carry out additional to that above? |
| 536 | - if (isset($security_checks['session'])) |
|
| 537 | - checkSession($security_checks['session']); |
|
| 538 | - if (isset($security_checks['validate'])) |
|
| 539 | - validateSession(); |
|
| 540 | - if (isset($security_checks['validateToken'])) |
|
| 541 | - validateToken($token_name, $token_type); |
|
| 542 | - if (isset($security_checks['permission'])) |
|
| 543 | - isAllowedTo($security_checks['permission']); |
|
| 551 | + if (isset($security_checks['session'])) { |
|
| 552 | + checkSession($security_checks['session']); |
|
| 553 | + } |
|
| 554 | + if (isset($security_checks['validate'])) { |
|
| 555 | + validateSession(); |
|
| 556 | + } |
|
| 557 | + if (isset($security_checks['validateToken'])) { |
|
| 558 | + validateToken($token_name, $token_type); |
|
| 559 | + } |
|
| 560 | + if (isset($security_checks['permission'])) { |
|
| 561 | + isAllowedTo($security_checks['permission']); |
|
| 562 | + } |
|
| 544 | 563 | |
| 545 | 564 | // Create a token if needed. |
| 546 | 565 | if (isset($security_checks['needsToken']) || isset($security_checks['validateToken'])) |
@@ -550,8 +569,9 @@ discard block |
||
| 550 | 569 | } |
| 551 | 570 | |
| 552 | 571 | // File to include? |
| 553 | - if (isset($profile_include_data['file'])) |
|
| 554 | - require_once($sourcedir . '/' . $profile_include_data['file']); |
|
| 572 | + if (isset($profile_include_data['file'])) { |
|
| 573 | + require_once($sourcedir . '/' . $profile_include_data['file']); |
|
| 574 | + } |
|
| 555 | 575 | |
| 556 | 576 | // Build the link tree. |
| 557 | 577 | $context['linktree'][] = array( |
@@ -559,17 +579,19 @@ discard block |
||
| 559 | 579 | 'name' => sprintf($txt['profile_of_username'], $context['member']['name']), |
| 560 | 580 | ); |
| 561 | 581 | |
| 562 | - if (!empty($profile_include_data['label'])) |
|
| 563 | - $context['linktree'][] = array( |
|
| 582 | + if (!empty($profile_include_data['label'])) { |
|
| 583 | + $context['linktree'][] = array( |
|
| 564 | 584 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'], |
| 565 | 585 | 'name' => $profile_include_data['label'], |
| 566 | 586 | ); |
| 587 | + } |
|
| 567 | 588 | |
| 568 | - if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) |
|
| 569 | - $context['linktree'][] = array( |
|
| 589 | + if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) { |
|
| 590 | + $context['linktree'][] = array( |
|
| 570 | 591 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'], |
| 571 | 592 | 'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0], |
| 572 | 593 | ); |
| 594 | + } |
|
| 573 | 595 | |
| 574 | 596 | // Set the template for this area and add the profile layer. |
| 575 | 597 | $context['sub_template'] = $profile_include_data['function']; |
@@ -595,12 +617,14 @@ discard block |
||
| 595 | 617 | if ($check_password) |
| 596 | 618 | { |
| 597 | 619 | // Check to ensure we're forcing SSL for authentication |
| 598 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 599 | - fatal_lang_error('login_ssl_required'); |
|
| 620 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 621 | + fatal_lang_error('login_ssl_required'); |
|
| 622 | + } |
|
| 600 | 623 | |
| 601 | 624 | // You didn't even enter a password! |
| 602 | - if (trim($_POST['oldpasswrd']) == '') |
|
| 603 | - $post_errors[] = 'no_password'; |
|
| 625 | + if (trim($_POST['oldpasswrd']) == '') { |
|
| 626 | + $post_errors[] = 'no_password'; |
|
| 627 | + } |
|
| 604 | 628 | |
| 605 | 629 | // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password |
| 606 | 630 | $_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']); |
@@ -609,42 +633,43 @@ discard block |
||
| 609 | 633 | $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true); |
| 610 | 634 | |
| 611 | 635 | // Bad password!!! |
| 612 | - if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) |
|
| 613 | - $post_errors[] = 'bad_password'; |
|
| 636 | + if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) { |
|
| 637 | + $post_errors[] = 'bad_password'; |
|
| 638 | + } |
|
| 614 | 639 | |
| 615 | 640 | // Warn other elements not to jump the gun and do custom changes! |
| 616 | - if (in_array('bad_password', $post_errors)) |
|
| 617 | - $context['password_auth_failed'] = true; |
|
| 641 | + if (in_array('bad_password', $post_errors)) { |
|
| 642 | + $context['password_auth_failed'] = true; |
|
| 643 | + } |
|
| 618 | 644 | } |
| 619 | 645 | |
| 620 | 646 | // Change the IP address in the database. |
| 621 | - if ($context['user']['is_owner']) |
|
| 622 | - $profile_vars['member_ip'] = $user_info['ip']; |
|
| 647 | + if ($context['user']['is_owner']) { |
|
| 648 | + $profile_vars['member_ip'] = $user_info['ip']; |
|
| 649 | + } |
|
| 623 | 650 | |
| 624 | 651 | // Now call the sub-action function... |
| 625 | 652 | if ($current_area == 'activateaccount') |
| 626 | 653 | { |
| 627 | - if (empty($post_errors)) |
|
| 628 | - activateAccount($memID); |
|
| 629 | - } |
|
| 630 | - elseif ($current_area == 'deleteaccount') |
|
| 654 | + if (empty($post_errors)) { |
|
| 655 | + activateAccount($memID); |
|
| 656 | + } |
|
| 657 | + } elseif ($current_area == 'deleteaccount') |
|
| 631 | 658 | { |
| 632 | 659 | if (empty($post_errors)) |
| 633 | 660 | { |
| 634 | 661 | deleteAccount2($memID); |
| 635 | 662 | redirectexit(); |
| 636 | 663 | } |
| 637 | - } |
|
| 638 | - elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
| 664 | + } elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
| 639 | 665 | { |
| 640 | 666 | $msg = groupMembership2($profile_vars, $post_errors, $memID); |
| 641 | 667 | |
| 642 | 668 | // Whatever we've done, we have nothing else to do here... |
| 643 | 669 | redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=groupmembership' . (!empty($msg) ? ';msg=' . $msg : '')); |
| 644 | - } |
|
| 645 | - elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) |
|
| 646 | - saveProfileFields(); |
|
| 647 | - else |
|
| 670 | + } elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) { |
|
| 671 | + saveProfileFields(); |
|
| 672 | + } else |
|
| 648 | 673 | { |
| 649 | 674 | $force_redirect = true; |
| 650 | 675 | // Ensure we include this. |
@@ -660,34 +685,36 @@ discard block |
||
| 660 | 685 | // Load the language file so we can give a nice explanation of the errors. |
| 661 | 686 | loadLanguage('Errors'); |
| 662 | 687 | $context['post_errors'] = $post_errors; |
| 663 | - } |
|
| 664 | - elseif (!empty($profile_vars)) |
|
| 688 | + } elseif (!empty($profile_vars)) |
|
| 665 | 689 | { |
| 666 | 690 | // If we've changed the password, notify any integration that may be listening in. |
| 667 | - if (isset($profile_vars['passwd'])) |
|
| 668 | - call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
| 691 | + if (isset($profile_vars['passwd'])) { |
|
| 692 | + call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
| 693 | + } |
|
| 669 | 694 | |
| 670 | 695 | updateMemberData($memID, $profile_vars); |
| 671 | 696 | |
| 672 | 697 | // What if this is the newest member? |
| 673 | - if ($modSettings['latestMember'] == $memID) |
|
| 674 | - updateStats('member'); |
|
| 675 | - elseif (isset($profile_vars['real_name'])) |
|
| 676 | - updateSettings(array('memberlist_updated' => time())); |
|
| 698 | + if ($modSettings['latestMember'] == $memID) { |
|
| 699 | + updateStats('member'); |
|
| 700 | + } elseif (isset($profile_vars['real_name'])) { |
|
| 701 | + updateSettings(array('memberlist_updated' => time())); |
|
| 702 | + } |
|
| 677 | 703 | |
| 678 | 704 | // If the member changed his/her birthdate, update calendar statistics. |
| 679 | - if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) |
|
| 680 | - updateSettings(array( |
|
| 705 | + if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) { |
|
| 706 | + updateSettings(array( |
|
| 681 | 707 | 'calendar_updated' => time(), |
| 682 | 708 | )); |
| 709 | + } |
|
| 683 | 710 | |
| 684 | 711 | // Anything worth logging? |
| 685 | 712 | if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled'])) |
| 686 | 713 | { |
| 687 | 714 | $log_changes = array(); |
| 688 | 715 | require_once($sourcedir . '/Logging.php'); |
| 689 | - foreach ($context['log_changes'] as $k => $v) |
|
| 690 | - $log_changes[] = array( |
|
| 716 | + foreach ($context['log_changes'] as $k => $v) { |
|
| 717 | + $log_changes[] = array( |
|
| 691 | 718 | 'action' => $k, |
| 692 | 719 | 'log_type' => 'user', |
| 693 | 720 | 'extra' => array_merge($v, array( |
@@ -695,14 +722,16 @@ discard block |
||
| 695 | 722 | 'member_affected' => $memID, |
| 696 | 723 | )), |
| 697 | 724 | ); |
| 725 | + } |
|
| 698 | 726 | |
| 699 | 727 | logActions($log_changes); |
| 700 | 728 | } |
| 701 | 729 | |
| 702 | 730 | // Have we got any post save functions to execute? |
| 703 | - if (!empty($context['profile_execute_on_save'])) |
|
| 704 | - foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
| 731 | + if (!empty($context['profile_execute_on_save'])) { |
|
| 732 | + foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
| 705 | 733 | $saveFunc(); |
| 734 | + } |
|
| 706 | 735 | |
| 707 | 736 | // Let them know it worked! |
| 708 | 737 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']); |
@@ -716,27 +745,31 @@ discard block |
||
| 716 | 745 | if (!empty($post_errors)) |
| 717 | 746 | { |
| 718 | 747 | // Set all the errors so the template knows what went wrong. |
| 719 | - foreach ($post_errors as $error_type) |
|
| 720 | - $context['modify_error'][$error_type] = true; |
|
| 748 | + foreach ($post_errors as $error_type) { |
|
| 749 | + $context['modify_error'][$error_type] = true; |
|
| 750 | + } |
|
| 721 | 751 | } |
| 722 | 752 | // If it's you then we should redirect upon save. |
| 723 | - elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) |
|
| 724 | - redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
| 725 | - elseif (!empty($force_redirect)) |
|
| 726 | - redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
| 753 | + elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) { |
|
| 754 | + redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
| 755 | + } elseif (!empty($force_redirect)) { |
|
| 756 | + redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
| 757 | + } |
|
| 727 | 758 | |
| 728 | 759 | |
| 729 | 760 | // Get the right callable. |
| 730 | 761 | $call = call_helper($profile_include_data['function'], true); |
| 731 | 762 | |
| 732 | 763 | // Is it valid? |
| 733 | - if (!empty($call)) |
|
| 734 | - call_user_func($call, $memID); |
|
| 764 | + if (!empty($call)) { |
|
| 765 | + call_user_func($call, $memID); |
|
| 766 | + } |
|
| 735 | 767 | |
| 736 | 768 | // Set the page title if it's not already set... |
| 737 | - if (!isset($context['page_title'])) |
|
| 738 | - $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
| 739 | -} |
|
| 769 | + if (!isset($context['page_title'])) { |
|
| 770 | + $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
| 771 | + } |
|
| 772 | + } |
|
| 740 | 773 | |
| 741 | 774 | /** |
| 742 | 775 | * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user. |
@@ -859,16 +892,18 @@ discard block |
||
| 859 | 892 | if (!allowedTo('admin_forum') && $area != 'register') |
| 860 | 893 | { |
| 861 | 894 | // If it's the owner they can see two types of private fields, regardless. |
| 862 | - if ($memID == $user_info['id']) |
|
| 863 | - $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
| 864 | - else |
|
| 865 | - $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
| 895 | + if ($memID == $user_info['id']) { |
|
| 896 | + $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
| 897 | + } else { |
|
| 898 | + $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
| 899 | + } |
|
| 866 | 900 | } |
| 867 | 901 | |
| 868 | - if ($area == 'register') |
|
| 869 | - $where .= ' AND show_reg != 0'; |
|
| 870 | - elseif ($area != 'summary') |
|
| 871 | - $where .= ' AND show_profile = {string:area}'; |
|
| 902 | + if ($area == 'register') { |
|
| 903 | + $where .= ' AND show_reg != 0'; |
|
| 904 | + } elseif ($area != 'summary') { |
|
| 905 | + $where .= ' AND show_profile = {string:area}'; |
|
| 906 | + } |
|
| 872 | 907 | |
| 873 | 908 | // Load all the relevant fields - and data. |
| 874 | 909 | $request = $smcFunc['db_query']('', ' |
@@ -894,13 +929,15 @@ discard block |
||
| 894 | 929 | if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']])) |
| 895 | 930 | { |
| 896 | 931 | $value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]); |
| 897 | - if (in_array($row['field_type'], array('select', 'radio'))) |
|
| 898 | - $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
| 932 | + if (in_array($row['field_type'], array('select', 'radio'))) { |
|
| 933 | + $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
| 934 | + } |
|
| 899 | 935 | } |
| 900 | 936 | |
| 901 | 937 | // Don't show the "disabled" option for the "gender" field if we are on the "summary" area. |
| 902 | - if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
| 903 | - continue; |
|
| 938 | + if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
| 939 | + continue; |
|
| 940 | + } |
|
| 904 | 941 | |
| 905 | 942 | // HTML for the input form. |
| 906 | 943 | $output_html = $value; |
@@ -909,8 +946,7 @@ discard block |
||
| 909 | 946 | $true = (!$exists && $row['default_value']) || $value; |
| 910 | 947 | $input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>'; |
| 911 | 948 | $output_html = $true ? $txt['yes'] : $txt['no']; |
| 912 | - } |
|
| 913 | - elseif ($row['field_type'] == 'select') |
|
| 949 | + } elseif ($row['field_type'] == 'select') |
|
| 914 | 950 | { |
| 915 | 951 | $input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>'; |
| 916 | 952 | $options = explode(',', $row['field_options']); |
@@ -918,13 +954,13 @@ discard block |
||
| 918 | 954 | { |
| 919 | 955 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
| 920 | 956 | $input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>'; |
| 921 | - if ($true) |
|
| 922 | - $output_html = $v; |
|
| 957 | + if ($true) { |
|
| 958 | + $output_html = $v; |
|
| 959 | + } |
|
| 923 | 960 | } |
| 924 | 961 | |
| 925 | 962 | $input_html .= '</select>'; |
| 926 | - } |
|
| 927 | - elseif ($row['field_type'] == 'radio') |
|
| 963 | + } elseif ($row['field_type'] == 'radio') |
|
| 928 | 964 | { |
| 929 | 965 | $input_html = '<fieldset>'; |
| 930 | 966 | $options = explode(',', $row['field_options']); |
@@ -932,36 +968,37 @@ discard block |
||
| 932 | 968 | { |
| 933 | 969 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
| 934 | 970 | $input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>'; |
| 935 | - if ($true) |
|
| 936 | - $output_html = $v; |
|
| 971 | + if ($true) { |
|
| 972 | + $output_html = $v; |
|
| 973 | + } |
|
| 937 | 974 | } |
| 938 | 975 | $input_html .= '</fieldset>'; |
| 939 | - } |
|
| 940 | - elseif ($row['field_type'] == 'text') |
|
| 976 | + } elseif ($row['field_type'] == 'text') |
|
| 941 | 977 | { |
| 942 | 978 | $input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '"' . ($row['show_reg'] == 2 ? ' required' : '') . '>'; |
| 943 | - } |
|
| 944 | - else |
|
| 979 | + } else |
|
| 945 | 980 | { |
| 946 | 981 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
| 947 | 982 | $input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '') . '>' . un_htmlspecialchars($value) . '</textarea>'; |
| 948 | 983 | } |
| 949 | 984 | |
| 950 | 985 | // Parse BBCode |
| 951 | - if ($row['bbc']) |
|
| 952 | - $output_html = parse_bbc($output_html); |
|
| 953 | - elseif ($row['field_type'] == 'textarea') |
|
| 954 | - // Allow for newlines at least |
|
| 986 | + if ($row['bbc']) { |
|
| 987 | + $output_html = parse_bbc($output_html); |
|
| 988 | + } elseif ($row['field_type'] == 'textarea') { |
|
| 989 | + // Allow for newlines at least |
|
| 955 | 990 | $output_html = strtr($output_html, array("\n" => '<br>')); |
| 991 | + } |
|
| 956 | 992 | |
| 957 | 993 | // Enclosing the user input within some other text? |
| 958 | - if (!empty($row['enclose']) && !empty($output_html)) |
|
| 959 | - $output_html = strtr($row['enclose'], array( |
|
| 994 | + if (!empty($row['enclose']) && !empty($output_html)) { |
|
| 995 | + $output_html = strtr($row['enclose'], array( |
|
| 960 | 996 | '{SCRIPTURL}' => $scripturl, |
| 961 | 997 | '{IMAGES_URL}' => $settings['images_url'], |
| 962 | 998 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 963 | 999 | '{INPUT}' => un_htmlspecialchars($output_html), |
| 964 | 1000 | )); |
| 1001 | + } |
|
| 965 | 1002 | |
| 966 | 1003 | $context['custom_fields'][] = array( |
| 967 | 1004 | 'name' => $row['field_name'], |
@@ -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 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | global $txt, $context, $scripturl, $user_info; |
| 30 | 31 | |
| 31 | 32 | // You are already logged in, go take a tour of the boards |
| 32 | - if (!empty($user_info['id'])) |
|
| 33 | - redirectexit(); |
|
| 33 | + if (!empty($user_info['id'])) { |
|
| 34 | + redirectexit(); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | // We need to load the Login template/language file. |
| 36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
| 57 | 59 | ); |
| 58 | 60 | |
| 59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
| 60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
| 61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
| 63 | - unset($_SESSION['login_url']); |
|
| 62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
| 63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
| 65 | + unset($_SESSION['login_url']); |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | // Create a one time token. |
| 66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
| 83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
| 84 | 87 | |
| 85 | 88 | // Check to ensure we're forcing SSL for authentication |
| 86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 87 | - fatal_lang_error('login_ssl_required'); |
|
| 89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 90 | + fatal_lang_error('login_ssl_required'); |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | 93 | // Load cookie authentication stuff. |
| 90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -102,19 +106,20 @@ discard block |
||
| 102 | 106 | list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
| 103 | 107 | |
| 104 | 108 | // That didn't work... Maybe it's using serialize? |
| 105 | - if (is_null($timeout)) |
|
| 106 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
| 107 | - } |
|
| 108 | - elseif (isset($_SESSION['login_' . $cookiename])) |
|
| 109 | + if (is_null($timeout)) { |
|
| 110 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
| 111 | + } |
|
| 112 | + } elseif (isset($_SESSION['login_' . $cookiename])) |
|
| 109 | 113 | { |
| 110 | 114 | list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
| 111 | 115 | |
| 112 | 116 | // Try for old format |
| 113 | - if (is_null($timeout)) |
|
| 114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 117 | + if (is_null($timeout)) { |
|
| 118 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 119 | + } |
|
| 120 | + } else { |
|
| 121 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
| 115 | 122 | } |
| 116 | - else |
|
| 117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
| 118 | 123 | |
| 119 | 124 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
| 120 | 125 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -127,10 +132,11 @@ discard block |
||
| 127 | 132 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
| 128 | 133 | |
| 129 | 134 | // If we're preserving the cookie, reset it with updated salt |
| 130 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
| 131 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
| 132 | - else |
|
| 133 | - setTFACookie(-3600, 0, ''); |
|
| 135 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
| 136 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
| 137 | + } else { |
|
| 138 | + setTFACookie(-3600, 0, ''); |
|
| 139 | + } |
|
| 134 | 140 | } |
| 135 | 141 | |
| 136 | 142 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -141,20 +147,20 @@ discard block |
||
| 141 | 147 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
| 142 | 148 | { |
| 143 | 149 | // Strike! You're outta there! |
| 144 | - if ($_GET['member'] != $user_info['id']) |
|
| 145 | - fatal_lang_error('login_cookie_error', false); |
|
| 150 | + if ($_GET['member'] != $user_info['id']) { |
|
| 151 | + fatal_lang_error('login_cookie_error', false); |
|
| 152 | + } |
|
| 146 | 153 | |
| 147 | 154 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
| 148 | 155 | |
| 149 | 156 | // Some whitelisting for login_url... |
| 150 | - if (empty($_SESSION['login_url'])) |
|
| 151 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
| 152 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
| 157 | + if (empty($_SESSION['login_url'])) { |
|
| 158 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
| 159 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
| 153 | 160 | { |
| 154 | 161 | unset ($_SESSION['login_url']); |
| 155 | 162 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
| 156 | - } |
|
| 157 | - else |
|
| 163 | + } else |
|
| 158 | 164 | { |
| 159 | 165 | // Best not to clutter the session data too much... |
| 160 | 166 | $temp = $_SESSION['login_url']; |
@@ -165,8 +171,9 @@ discard block |
||
| 165 | 171 | } |
| 166 | 172 | |
| 167 | 173 | // Beyond this point you are assumed to be a guest trying to login. |
| 168 | - if (!$user_info['is_guest']) |
|
| 169 | - redirectexit(); |
|
| 174 | + if (!$user_info['is_guest']) { |
|
| 175 | + redirectexit(); |
|
| 176 | + } |
|
| 170 | 177 | |
| 171 | 178 | // Are you guessing with a script? |
| 172 | 179 | checkSession(); |
@@ -174,18 +181,21 @@ discard block |
||
| 174 | 181 | spamProtection('login'); |
| 175 | 182 | |
| 176 | 183 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
| 177 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
| 178 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 184 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
| 185 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 186 | + } |
|
| 179 | 187 | |
| 180 | 188 | // Been guessing a lot, haven't we? |
| 181 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
| 182 | - fatal_lang_error('login_threshold_fail', 'login'); |
|
| 189 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
| 190 | + fatal_lang_error('login_threshold_fail', 'login'); |
|
| 191 | + } |
|
| 183 | 192 | |
| 184 | 193 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
| 185 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
| 186 | - $modSettings['cookieTime'] = 3153600; |
|
| 187 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
| 188 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
| 194 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
| 195 | + $modSettings['cookieTime'] = 3153600; |
|
| 196 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
| 197 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
| 198 | + } |
|
| 189 | 199 | |
| 190 | 200 | loadLanguage('Login'); |
| 191 | 201 | // Load the template stuff. |
@@ -305,8 +315,9 @@ discard block |
||
| 305 | 315 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
| 306 | 316 | |
| 307 | 317 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
| 308 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
| 309 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
| 318 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
| 319 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
| 320 | + } |
|
| 310 | 321 | |
| 311 | 322 | // phpBB3 users new hashing. We now support it as well ;). |
| 312 | 323 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -326,27 +337,29 @@ discard block |
||
| 326 | 337 | // Some common md5 ones. |
| 327 | 338 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
| 328 | 339 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
| 329 | - } |
|
| 330 | - elseif (strlen($user_settings['passwd']) == 40) |
|
| 340 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
| 331 | 341 | { |
| 332 | 342 | // Maybe they are using a hash from before the password fix. |
| 333 | 343 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
| 334 | 344 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
| 335 | 345 | |
| 336 | 346 | // BurningBoard3 style of hashing. |
| 337 | - if (!empty($modSettings['enable_password_conversion'])) |
|
| 338 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
| 347 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
| 348 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
| 349 | + } |
|
| 339 | 350 | |
| 340 | 351 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
| 341 | 352 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
| 342 | 353 | { |
| 343 | 354 | // Try iconv first, for no particular reason. |
| 344 | - if (function_exists('iconv')) |
|
| 345 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
| 355 | + if (function_exists('iconv')) { |
|
| 356 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
| 357 | + } |
|
| 346 | 358 | |
| 347 | 359 | // Say it aint so, iconv failed! |
| 348 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
| 349 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
| 360 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
| 361 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
| 362 | + } |
|
| 350 | 363 | } |
| 351 | 364 | } |
| 352 | 365 | |
@@ -376,8 +389,9 @@ discard block |
||
| 376 | 389 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
| 377 | 390 | |
| 378 | 391 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
| 379 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
| 380 | - redirectexit('action=reminder'); |
|
| 392 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
| 393 | + redirectexit('action=reminder'); |
|
| 394 | + } |
|
| 381 | 395 | // We'll give you another chance... |
| 382 | 396 | else |
| 383 | 397 | { |
@@ -388,8 +402,7 @@ discard block |
||
| 388 | 402 | return; |
| 389 | 403 | } |
| 390 | 404 | } |
| 391 | - } |
|
| 392 | - elseif (!empty($user_settings['passwd_flood'])) |
|
| 405 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
| 393 | 406 | { |
| 394 | 407 | // Let's be sure they weren't a little hacker. |
| 395 | 408 | validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true); |
@@ -406,8 +419,9 @@ discard block |
||
| 406 | 419 | } |
| 407 | 420 | |
| 408 | 421 | // Check their activation status. |
| 409 | - if (!checkActivation()) |
|
| 410 | - return; |
|
| 422 | + if (!checkActivation()) { |
|
| 423 | + return; |
|
| 424 | + } |
|
| 411 | 425 | |
| 412 | 426 | DoLogin(); |
| 413 | 427 | } |
@@ -419,8 +433,9 @@ discard block |
||
| 419 | 433 | { |
| 420 | 434 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
| 421 | 435 | |
| 422 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
| 423 | - fatal_lang_error('no_access', false); |
|
| 436 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
| 437 | + fatal_lang_error('no_access', false); |
|
| 438 | + } |
|
| 424 | 439 | |
| 425 | 440 | loadLanguage('Profile'); |
| 426 | 441 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -428,8 +443,9 @@ discard block |
||
| 428 | 443 | $member = $context['tfa_member']; |
| 429 | 444 | |
| 430 | 445 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
| 431 | - if (time() - $member['last_login'] < 120) |
|
| 432 | - fatal_lang_error('tfa_wait', false); |
|
| 446 | + if (time() - $member['last_login'] < 120) { |
|
| 447 | + fatal_lang_error('tfa_wait', false); |
|
| 448 | + } |
|
| 433 | 449 | |
| 434 | 450 | $totp = new \TOTP\Auth($member['tfa_secret']); |
| 435 | 451 | $totp->setRange(1); |
@@ -443,8 +459,9 @@ discard block |
||
| 443 | 459 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
| 444 | 460 | { |
| 445 | 461 | // Check to ensure we're forcing SSL for authentication |
| 446 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 447 | - fatal_lang_error('login_ssl_required'); |
|
| 462 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 463 | + fatal_lang_error('login_ssl_required'); |
|
| 464 | + } |
|
| 448 | 465 | |
| 449 | 466 | $code = $_POST['tfa_code']; |
| 450 | 467 | |
@@ -454,20 +471,19 @@ discard block |
||
| 454 | 471 | |
| 455 | 472 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
| 456 | 473 | redirectexit(); |
| 457 | - } |
|
| 458 | - else |
|
| 474 | + } else |
|
| 459 | 475 | { |
| 460 | 476 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
| 461 | 477 | |
| 462 | 478 | $context['tfa_error'] = true; |
| 463 | 479 | $context['tfa_value'] = $_POST['tfa_code']; |
| 464 | 480 | } |
| 465 | - } |
|
| 466 | - elseif (!empty($_POST['tfa_backup'])) |
|
| 481 | + } elseif (!empty($_POST['tfa_backup'])) |
|
| 467 | 482 | { |
| 468 | 483 | // Check to ensure we're forcing SSL for authentication |
| 469 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 470 | - fatal_lang_error('login_ssl_required'); |
|
| 484 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 485 | + fatal_lang_error('login_ssl_required'); |
|
| 486 | + } |
|
| 471 | 487 | |
| 472 | 488 | $backup = $_POST['tfa_backup']; |
| 473 | 489 | |
@@ -481,8 +497,7 @@ discard block |
||
| 481 | 497 | )); |
| 482 | 498 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
| 483 | 499 | redirectexit('action=profile;area=tfasetup;backup'); |
| 484 | - } |
|
| 485 | - else |
|
| 500 | + } else |
|
| 486 | 501 | { |
| 487 | 502 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
| 488 | 503 | |
@@ -505,8 +520,9 @@ discard block |
||
| 505 | 520 | { |
| 506 | 521 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
| 507 | 522 | |
| 508 | - if (!isset($context['login_errors'])) |
|
| 509 | - $context['login_errors'] = array(); |
|
| 523 | + if (!isset($context['login_errors'])) { |
|
| 524 | + $context['login_errors'] = array(); |
|
| 525 | + } |
|
| 510 | 526 | |
| 511 | 527 | // What is the true activation status of this account? |
| 512 | 528 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -518,8 +534,9 @@ discard block |
||
| 518 | 534 | return false; |
| 519 | 535 | } |
| 520 | 536 | // Awaiting approval still? |
| 521 | - elseif ($activation_status == 3) |
|
| 522 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
| 537 | + elseif ($activation_status == 3) { |
|
| 538 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
| 539 | + } |
|
| 523 | 540 | // Awaiting deletion, changed their mind? |
| 524 | 541 | elseif ($activation_status == 4) |
| 525 | 542 | { |
@@ -527,8 +544,7 @@ discard block |
||
| 527 | 544 | { |
| 528 | 545 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
| 529 | 546 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
| 530 | - } |
|
| 531 | - else |
|
| 547 | + } else |
|
| 532 | 548 | { |
| 533 | 549 | $context['disable_login_hashing'] = true; |
| 534 | 550 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -568,8 +584,9 @@ discard block |
||
| 568 | 584 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
| 569 | 585 | |
| 570 | 586 | // Reset the login threshold. |
| 571 | - if (isset($_SESSION['failed_login'])) |
|
| 572 | - unset($_SESSION['failed_login']); |
|
| 587 | + if (isset($_SESSION['failed_login'])) { |
|
| 588 | + unset($_SESSION['failed_login']); |
|
| 589 | + } |
|
| 573 | 590 | |
| 574 | 591 | $user_info['is_guest'] = false; |
| 575 | 592 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -591,16 +608,18 @@ discard block |
||
| 591 | 608 | 'id_member' => $user_info['id'], |
| 592 | 609 | ) |
| 593 | 610 | ); |
| 594 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 595 | - $_SESSION['first_login'] = true; |
|
| 596 | - else |
|
| 597 | - unset($_SESSION['first_login']); |
|
| 611 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 612 | + $_SESSION['first_login'] = true; |
|
| 613 | + } else { |
|
| 614 | + unset($_SESSION['first_login']); |
|
| 615 | + } |
|
| 598 | 616 | $smcFunc['db_free_result']($request); |
| 599 | 617 | |
| 600 | 618 | // You've logged in, haven't you? |
| 601 | 619 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
| 602 | - if (empty($user_settings['tfa_secret'])) |
|
| 603 | - $update['last_login'] = time(); |
|
| 620 | + if (empty($user_settings['tfa_secret'])) { |
|
| 621 | + $update['last_login'] = time(); |
|
| 622 | + } |
|
| 604 | 623 | updateMemberData($user_info['id'], $update); |
| 605 | 624 | |
| 606 | 625 | // Get rid of the online entry for that old guest.... |
@@ -614,8 +633,8 @@ discard block |
||
| 614 | 633 | $_SESSION['log_time'] = 0; |
| 615 | 634 | |
| 616 | 635 | // Log this entry, only if we have it enabled. |
| 617 | - if (!empty($modSettings['loginHistoryDays'])) |
|
| 618 | - $smcFunc['db_insert']('insert', |
|
| 636 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
| 637 | + $smcFunc['db_insert']('insert', |
|
| 619 | 638 | '{db_prefix}member_logins', |
| 620 | 639 | array( |
| 621 | 640 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -627,13 +646,15 @@ discard block |
||
| 627 | 646 | 'id_member', 'time' |
| 628 | 647 | ) |
| 629 | 648 | ); |
| 649 | + } |
|
| 630 | 650 | |
| 631 | 651 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
| 632 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
| 633 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
| 634 | - else |
|
| 635 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
| 636 | -} |
|
| 652 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
| 653 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
| 654 | + } else { |
|
| 655 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
| 656 | + } |
|
| 657 | + } |
|
| 637 | 658 | |
| 638 | 659 | /** |
| 639 | 660 | * Logs the current user out of their account. |
@@ -649,13 +670,15 @@ discard block |
||
| 649 | 670 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
| 650 | 671 | |
| 651 | 672 | // Make sure they aren't being auto-logged out. |
| 652 | - if (!$internal) |
|
| 653 | - checkSession('get'); |
|
| 673 | + if (!$internal) { |
|
| 674 | + checkSession('get'); |
|
| 675 | + } |
|
| 654 | 676 | |
| 655 | 677 | require_once($sourcedir . '/Subs-Auth.php'); |
| 656 | 678 | |
| 657 | - if (isset($_SESSION['pack_ftp'])) |
|
| 658 | - $_SESSION['pack_ftp'] = null; |
|
| 679 | + if (isset($_SESSION['pack_ftp'])) { |
|
| 680 | + $_SESSION['pack_ftp'] = null; |
|
| 681 | + } |
|
| 659 | 682 | |
| 660 | 683 | // It won't be first login anymore. |
| 661 | 684 | unset($_SESSION['first_login']); |
@@ -683,8 +706,9 @@ discard block |
||
| 683 | 706 | |
| 684 | 707 | // And some other housekeeping while we're at it. |
| 685 | 708 | $salt = substr(md5(mt_rand()), 0, 4); |
| 686 | - if (!empty($user_info['id'])) |
|
| 687 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
| 709 | + if (!empty($user_info['id'])) { |
|
| 710 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
| 711 | + } |
|
| 688 | 712 | |
| 689 | 713 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
| 690 | 714 | { |
@@ -693,10 +717,11 @@ discard block |
||
| 693 | 717 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
| 694 | 718 | |
| 695 | 719 | // If we're preserving the cookie, reset it with updated salt |
| 696 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
| 697 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
| 698 | - else |
|
| 699 | - setTFACookie(-3600, 0, ''); |
|
| 720 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
| 721 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
| 722 | + } else { |
|
| 723 | + setTFACookie(-3600, 0, ''); |
|
| 724 | + } |
|
| 700 | 725 | } |
| 701 | 726 | |
| 702 | 727 | session_destroy(); |
@@ -704,14 +729,13 @@ discard block |
||
| 704 | 729 | // Off to the merry board index we go! |
| 705 | 730 | if ($redirect) |
| 706 | 731 | { |
| 707 | - if (empty($_SESSION['logout_url'])) |
|
| 708 | - redirectexit('', $context['server']['needs_login_fix']); |
|
| 709 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
| 732 | + if (empty($_SESSION['logout_url'])) { |
|
| 733 | + redirectexit('', $context['server']['needs_login_fix']); |
|
| 734 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
| 710 | 735 | { |
| 711 | 736 | unset ($_SESSION['logout_url']); |
| 712 | 737 | redirectexit(); |
| 713 | - } |
|
| 714 | - else |
|
| 738 | + } else |
|
| 715 | 739 | { |
| 716 | 740 | $temp = $_SESSION['logout_url']; |
| 717 | 741 | unset($_SESSION['logout_url']); |
@@ -744,8 +768,9 @@ discard block |
||
| 744 | 768 | function phpBB3_password_check($passwd, $passwd_hash) |
| 745 | 769 | { |
| 746 | 770 | // Too long or too short? |
| 747 | - if (strlen($passwd_hash) != 34) |
|
| 748 | - return; |
|
| 771 | + if (strlen($passwd_hash) != 34) { |
|
| 772 | + return; |
|
| 773 | + } |
|
| 749 | 774 | |
| 750 | 775 | // Range of characters allowed. |
| 751 | 776 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -756,8 +781,9 @@ discard block |
||
| 756 | 781 | $salt = substr($passwd_hash, 4, 8); |
| 757 | 782 | |
| 758 | 783 | $hash = md5($salt . $passwd, true); |
| 759 | - for (; $count != 0; --$count) |
|
| 760 | - $hash = md5($hash . $passwd, true); |
|
| 784 | + for (; $count != 0; --$count) { |
|
| 785 | + $hash = md5($hash . $passwd, true); |
|
| 786 | + } |
|
| 761 | 787 | |
| 762 | 788 | $output = substr($passwd_hash, 0, 12); |
| 763 | 789 | $i = 0; |
@@ -766,21 +792,25 @@ discard block |
||
| 766 | 792 | $value = ord($hash[$i++]); |
| 767 | 793 | $output .= $range[$value & 0x3f]; |
| 768 | 794 | |
| 769 | - if ($i < 16) |
|
| 770 | - $value |= ord($hash[$i]) << 8; |
|
| 795 | + if ($i < 16) { |
|
| 796 | + $value |= ord($hash[$i]) << 8; |
|
| 797 | + } |
|
| 771 | 798 | |
| 772 | 799 | $output .= $range[($value >> 6) & 0x3f]; |
| 773 | 800 | |
| 774 | - if ($i++ >= 16) |
|
| 775 | - break; |
|
| 801 | + if ($i++ >= 16) { |
|
| 802 | + break; |
|
| 803 | + } |
|
| 776 | 804 | |
| 777 | - if ($i < 16) |
|
| 778 | - $value |= ord($hash[$i]) << 16; |
|
| 805 | + if ($i < 16) { |
|
| 806 | + $value |= ord($hash[$i]) << 16; |
|
| 807 | + } |
|
| 779 | 808 | |
| 780 | 809 | $output .= $range[($value >> 12) & 0x3f]; |
| 781 | 810 | |
| 782 | - if ($i++ >= 16) |
|
| 783 | - break; |
|
| 811 | + if ($i++ >= 16) { |
|
| 812 | + break; |
|
| 813 | + } |
|
| 784 | 814 | |
| 785 | 815 | $output .= $range[($value >> 18) & 0x3f]; |
| 786 | 816 | } |
@@ -812,8 +842,9 @@ discard block |
||
| 812 | 842 | require_once($sourcedir . '/Subs-Auth.php'); |
| 813 | 843 | setLoginCookie(-3600, 0); |
| 814 | 844 | |
| 815 | - if (isset($_SESSION['login_' . $cookiename])) |
|
| 816 | - unset($_SESSION['login_' . $cookiename]); |
|
| 845 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
| 846 | + unset($_SESSION['login_' . $cookiename]); |
|
| 847 | + } |
|
| 817 | 848 | } |
| 818 | 849 | |
| 819 | 850 | // We need a member! |
@@ -827,8 +858,9 @@ discard block |
||
| 827 | 858 | } |
| 828 | 859 | |
| 829 | 860 | // Right, have we got a flood value? |
| 830 | - if ($password_flood_value !== false) |
|
| 831 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
| 861 | + if ($password_flood_value !== false) { |
|
| 862 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
| 863 | + } |
|
| 832 | 864 | |
| 833 | 865 | // Timestamp or number of tries invalid? |
| 834 | 866 | if (empty($number_tries) || empty($time_stamp)) |
@@ -844,15 +876,17 @@ discard block |
||
| 844 | 876 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
| 845 | 877 | |
| 846 | 878 | // They are trying too fast, make them wait longer |
| 847 | - if ($time_stamp < time() - 10) |
|
| 848 | - $time_stamp = time(); |
|
| 879 | + if ($time_stamp < time() - 10) { |
|
| 880 | + $time_stamp = time(); |
|
| 881 | + } |
|
| 849 | 882 | } |
| 850 | 883 | |
| 851 | 884 | $number_tries++; |
| 852 | 885 | |
| 853 | 886 | // Broken the law? |
| 854 | - if ($number_tries > 5) |
|
| 855 | - fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
| 887 | + if ($number_tries > 5) { |
|
| 888 | + fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
| 889 | + } |
|
| 856 | 890 | |
| 857 | 891 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
| 858 | 892 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Activate an account. |
@@ -48,8 +49,9 @@ discard block |
||
| 48 | 49 | logAction('approve_member', array('member' => $memID), 'admin'); |
| 49 | 50 | |
| 50 | 51 | // If we are doing approval, update the stats for the member just in case. |
| 51 | - if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) |
|
| 52 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
| 52 | + if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) { |
|
| 53 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
| 54 | + } |
|
| 53 | 55 | |
| 54 | 56 | // Make sure we update the stats too. |
| 55 | 57 | updateStats('member', false); |
@@ -76,8 +78,9 @@ discard block |
||
| 76 | 78 | $issueErrors = array(); |
| 77 | 79 | |
| 78 | 80 | // Doesn't hurt to be overly cautious. |
| 79 | - if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) |
|
| 80 | - fatal_lang_error('no_access', false); |
|
| 81 | + if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) { |
|
| 82 | + fatal_lang_error('no_access', false); |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Get the base (errors related) stuff done. |
| 83 | 86 | loadLanguage('Errors'); |
@@ -135,16 +138,18 @@ discard block |
||
| 135 | 138 | |
| 136 | 139 | // This cannot be empty! |
| 137 | 140 | $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; |
| 138 | - if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) |
|
| 139 | - $issueErrors[] = 'warning_no_reason'; |
|
| 141 | + if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { |
|
| 142 | + $issueErrors[] = 'warning_no_reason'; |
|
| 143 | + } |
|
| 140 | 144 | $_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']); |
| 141 | 145 | |
| 142 | 146 | $_POST['warning_level'] = (int) $_POST['warning_level']; |
| 143 | 147 | $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); |
| 144 | - if ($_POST['warning_level'] < $context['min_allowed']) |
|
| 145 | - $_POST['warning_level'] = $context['min_allowed']; |
|
| 146 | - elseif ($_POST['warning_level'] > $context['max_allowed']) |
|
| 147 | - $_POST['warning_level'] = $context['max_allowed']; |
|
| 148 | + if ($_POST['warning_level'] < $context['min_allowed']) { |
|
| 149 | + $_POST['warning_level'] = $context['min_allowed']; |
|
| 150 | + } elseif ($_POST['warning_level'] > $context['max_allowed']) { |
|
| 151 | + $_POST['warning_level'] = $context['max_allowed']; |
|
| 152 | + } |
|
| 148 | 153 | |
| 149 | 154 | // Do we actually have to issue them with a PM? |
| 150 | 155 | $id_notice = 0; |
@@ -152,8 +157,9 @@ discard block |
||
| 152 | 157 | { |
| 153 | 158 | $_POST['warn_sub'] = trim($_POST['warn_sub']); |
| 154 | 159 | $_POST['warn_body'] = trim($_POST['warn_body']); |
| 155 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
| 156 | - $issueErrors[] = 'warning_notify_blank'; |
|
| 160 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
| 161 | + $issueErrors[] = 'warning_notify_blank'; |
|
| 162 | + } |
|
| 157 | 163 | // Send the PM? |
| 158 | 164 | else |
| 159 | 165 | { |
@@ -190,8 +196,8 @@ discard block |
||
| 190 | 196 | if (empty($issueErrors)) |
| 191 | 197 | { |
| 192 | 198 | // Log what we've done! |
| 193 | - if (!$context['user']['is_owner']) |
|
| 194 | - $smcFunc['db_insert']('', |
|
| 199 | + if (!$context['user']['is_owner']) { |
|
| 200 | + $smcFunc['db_insert']('', |
|
| 195 | 201 | '{db_prefix}log_comments', |
| 196 | 202 | array( |
| 197 | 203 | 'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255', |
@@ -203,14 +209,14 @@ discard block |
||
| 203 | 209 | ), |
| 204 | 210 | array('id_comment') |
| 205 | 211 | ); |
| 212 | + } |
|
| 206 | 213 | |
| 207 | 214 | // Make the change. |
| 208 | 215 | updateMemberData($memID, array('warning' => $_POST['warning_level'])); |
| 209 | 216 | |
| 210 | 217 | // Leave a lovely message. |
| 211 | 218 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; |
| 212 | - } |
|
| 213 | - else |
|
| 219 | + } else |
|
| 214 | 220 | { |
| 215 | 221 | // Try to remember some bits. |
| 216 | 222 | $context['warning_data'] = array( |
@@ -229,8 +235,9 @@ discard block |
||
| 229 | 235 | { |
| 230 | 236 | $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; |
| 231 | 237 | $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : ''; |
| 232 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
| 233 | - $issueErrors[] = 'warning_notify_blank'; |
|
| 238 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
| 239 | + $issueErrors[] = 'warning_notify_blank'; |
|
| 240 | + } |
|
| 234 | 241 | |
| 235 | 242 | if (!empty($_POST['warn_body'])) |
| 236 | 243 | { |
@@ -254,8 +261,9 @@ discard block |
||
| 254 | 261 | { |
| 255 | 262 | // Fill in the suite of errors. |
| 256 | 263 | $context['post_errors'] = array(); |
| 257 | - foreach ($issueErrors as $error) |
|
| 258 | - $context['post_errors'][] = $txt[$error]; |
|
| 264 | + foreach ($issueErrors as $error) { |
|
| 265 | + $context['post_errors'][] = $txt[$error]; |
|
| 266 | + } |
|
| 259 | 267 | } |
| 260 | 268 | |
| 261 | 269 | |
@@ -272,9 +280,10 @@ discard block |
||
| 272 | 280 | $modSettings['warning_mute'] => $txt['profile_warning_effect_mute'], |
| 273 | 281 | ); |
| 274 | 282 | $context['current_level'] = 0; |
| 275 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
| 276 | - if ($context['member']['warning'] >= $limit) |
|
| 283 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
| 284 | + if ($context['member']['warning'] >= $limit) |
|
| 277 | 285 | $context['current_level'] = $limit; |
| 286 | + } |
|
| 278 | 287 | |
| 279 | 288 | $listOptions = array( |
| 280 | 289 | 'id' => 'view_warnings', |
@@ -337,11 +346,12 @@ discard block |
||
| 337 | 346 | ' . $warning['reason'] . ' |
| 338 | 347 | </div>'; |
| 339 | 348 | |
| 340 | - if (!empty($warning['id_notice'])) |
|
| 341 | - $ret .= ' |
|
| 349 | + if (!empty($warning['id_notice'])) { |
|
| 350 | + $ret .= ' |
|
| 342 | 351 | <div class="floatright"> |
| 343 | 352 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a> |
| 344 | 353 | </div>'; |
| 354 | + } |
|
| 345 | 355 | |
| 346 | 356 | return $ret; |
| 347 | 357 | }, |
@@ -413,8 +423,9 @@ discard block |
||
| 413 | 423 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 414 | 424 | { |
| 415 | 425 | // If we're not warning for a message skip any that are. |
| 416 | - if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) |
|
| 417 | - continue; |
|
| 426 | + if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) { |
|
| 427 | + continue; |
|
| 428 | + } |
|
| 418 | 429 | |
| 419 | 430 | $context['notification_templates'][] = array( |
| 420 | 431 | 'title' => $row['template_title'], |
@@ -424,16 +435,18 @@ discard block |
||
| 424 | 435 | $smcFunc['db_free_result']($request); |
| 425 | 436 | |
| 426 | 437 | // Setup the "default" templates. |
| 427 | - foreach (array('spamming', 'offence', 'insulting') as $type) |
|
| 428 | - $context['notification_templates'][] = array( |
|
| 438 | + foreach (array('spamming', 'offence', 'insulting') as $type) { |
|
| 439 | + $context['notification_templates'][] = array( |
|
| 429 | 440 | 'title' => $txt['profile_warning_notify_title_' . $type], |
| 430 | 441 | 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]), |
| 431 | 442 | ); |
| 443 | + } |
|
| 432 | 444 | |
| 433 | 445 | // Replace all the common variables in the templates. |
| 434 | - foreach ($context['notification_templates'] as $k => $name) |
|
| 435 | - $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
| 436 | -} |
|
| 446 | + foreach ($context['notification_templates'] as $k => $name) { |
|
| 447 | + $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
| 448 | + } |
|
| 449 | + } |
|
| 437 | 450 | |
| 438 | 451 | /** |
| 439 | 452 | * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning() |
@@ -517,10 +530,11 @@ discard block |
||
| 517 | 530 | { |
| 518 | 531 | global $txt, $context, $modSettings, $cur_profile; |
| 519 | 532 | |
| 520 | - if (!$context['user']['is_owner']) |
|
| 521 | - isAllowedTo('profile_remove_any'); |
|
| 522 | - elseif (!allowedTo('profile_remove_any')) |
|
| 523 | - isAllowedTo('profile_remove_own'); |
|
| 533 | + if (!$context['user']['is_owner']) { |
|
| 534 | + isAllowedTo('profile_remove_any'); |
|
| 535 | + } elseif (!allowedTo('profile_remove_any')) { |
|
| 536 | + isAllowedTo('profile_remove_own'); |
|
| 537 | + } |
|
| 524 | 538 | |
| 525 | 539 | // Permissions for removing stuff... |
| 526 | 540 | $context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum'); |
@@ -547,10 +561,11 @@ discard block |
||
| 547 | 561 | |
| 548 | 562 | // @todo Add a way to delete pms as well? |
| 549 | 563 | |
| 550 | - if (!$context['user']['is_owner']) |
|
| 551 | - isAllowedTo('profile_remove_any'); |
|
| 552 | - elseif (!allowedTo('profile_remove_any')) |
|
| 553 | - isAllowedTo('profile_remove_own'); |
|
| 564 | + if (!$context['user']['is_owner']) { |
|
| 565 | + isAllowedTo('profile_remove_any'); |
|
| 566 | + } elseif (!allowedTo('profile_remove_any')) { |
|
| 567 | + isAllowedTo('profile_remove_own'); |
|
| 568 | + } |
|
| 554 | 569 | |
| 555 | 570 | checkSession(); |
| 556 | 571 | |
@@ -576,8 +591,9 @@ discard block |
||
| 576 | 591 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 577 | 592 | $smcFunc['db_free_result']($request); |
| 578 | 593 | |
| 579 | - if (empty($another)) |
|
| 580 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 594 | + if (empty($another)) { |
|
| 595 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 596 | + } |
|
| 581 | 597 | } |
| 582 | 598 | |
| 583 | 599 | // This file is needed for the deleteMembers function. |
@@ -656,8 +672,9 @@ discard block |
||
| 656 | 672 | ) |
| 657 | 673 | ); |
| 658 | 674 | $topicIDs = array(); |
| 659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 660 | - $topicIDs[] = $row['id_topic']; |
|
| 675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 676 | + $topicIDs[] = $row['id_topic']; |
|
| 677 | + } |
|
| 661 | 678 | $smcFunc['db_free_result']($request); |
| 662 | 679 | |
| 663 | 680 | // Actually remove the topics. Ignore recycling if we want to perma-delete things... |
@@ -680,8 +697,9 @@ discard block |
||
| 680 | 697 | // This could take a while... but ya know it's gonna be worth it in the end. |
| 681 | 698 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 682 | 699 | { |
| 683 | - if (function_exists('apache_reset_timeout')) |
|
| 684 | - @apache_reset_timeout(); |
|
| 700 | + if (function_exists('apache_reset_timeout')) { |
|
| 701 | + @apache_reset_timeout(); |
|
| 702 | + } |
|
| 685 | 703 | |
| 686 | 704 | removeMessage($row['id_msg']); |
| 687 | 705 | } |
@@ -689,8 +707,9 @@ discard block |
||
| 689 | 707 | } |
| 690 | 708 | |
| 691 | 709 | // Only delete this poor members account if they are actually being booted out of camp. |
| 692 | - if (isset($_POST['deleteAccount'])) |
|
| 693 | - deleteMembers($memID); |
|
| 710 | + if (isset($_POST['deleteAccount'])) { |
|
| 711 | + deleteMembers($memID); |
|
| 712 | + } |
|
| 694 | 713 | } |
| 695 | 714 | // Do they need approval to delete? |
| 696 | 715 | elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) |
@@ -741,18 +760,18 @@ discard block |
||
| 741 | 760 | { |
| 742 | 761 | foreach ($costs as $duration => $cost) |
| 743 | 762 | { |
| 744 | - if ($cost != 0) |
|
| 745 | - $cost_array[$duration] = $cost; |
|
| 763 | + if ($cost != 0) { |
|
| 764 | + $cost_array[$duration] = $cost; |
|
| 765 | + } |
|
| 746 | 766 | } |
| 747 | - } |
|
| 748 | - else |
|
| 767 | + } else |
|
| 749 | 768 | { |
| 750 | 769 | $cost_array['fixed'] = $costs['fixed']; |
| 751 | 770 | } |
| 752 | 771 | |
| 753 | - if (empty($cost_array)) |
|
| 754 | - unset($context['subscriptions'][$id]); |
|
| 755 | - else |
|
| 772 | + if (empty($cost_array)) { |
|
| 773 | + unset($context['subscriptions'][$id]); |
|
| 774 | + } else |
|
| 756 | 775 | { |
| 757 | 776 | $context['subscriptions'][$id]['member'] = 0; |
| 758 | 777 | $context['subscriptions'][$id]['subscribed'] = false; |
@@ -765,13 +784,15 @@ discard block |
||
| 765 | 784 | foreach ($gateways as $id => $gateway) |
| 766 | 785 | { |
| 767 | 786 | $gateways[$id] = new $gateway['display_class'](); |
| 768 | - if (!$gateways[$id]->gatewayEnabled()) |
|
| 769 | - unset($gateways[$id]); |
|
| 787 | + if (!$gateways[$id]->gatewayEnabled()) { |
|
| 788 | + unset($gateways[$id]); |
|
| 789 | + } |
|
| 770 | 790 | } |
| 771 | 791 | |
| 772 | 792 | // No gateways yet? |
| 773 | - if (empty($gateways)) |
|
| 774 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 793 | + if (empty($gateways)) { |
|
| 794 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 795 | + } |
|
| 775 | 796 | |
| 776 | 797 | // Get the current subscriptions. |
| 777 | 798 | $request = $smcFunc['db_query']('', ' |
@@ -786,8 +807,9 @@ discard block |
||
| 786 | 807 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 787 | 808 | { |
| 788 | 809 | // The subscription must exist! |
| 789 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 790 | - continue; |
|
| 810 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 811 | + continue; |
|
| 812 | + } |
|
| 791 | 813 | |
| 792 | 814 | $context['current'][$row['id_subscribe']] = array( |
| 793 | 815 | 'id' => $row['id_sublog'], |
@@ -801,8 +823,9 @@ discard block |
||
| 801 | 823 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'], |
| 802 | 824 | ); |
| 803 | 825 | |
| 804 | - if ($row['status'] == 1) |
|
| 805 | - $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
| 826 | + if ($row['status'] == 1) { |
|
| 827 | + $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
| 828 | + } |
|
| 806 | 829 | } |
| 807 | 830 | $smcFunc['db_free_result']($request); |
| 808 | 831 | |
@@ -853,21 +876,25 @@ discard block |
||
| 853 | 876 | if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id'])) |
| 854 | 877 | { |
| 855 | 878 | // Hopefully just one. |
| 856 | - foreach ($_POST['sub_id'] as $k => $v) |
|
| 857 | - $ID_SUB = (int) $k; |
|
| 879 | + foreach ($_POST['sub_id'] as $k => $v) { |
|
| 880 | + $ID_SUB = (int) $k; |
|
| 881 | + } |
|
| 858 | 882 | |
| 859 | - if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) |
|
| 860 | - fatal_lang_error('paid_sub_not_active'); |
|
| 883 | + if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) { |
|
| 884 | + fatal_lang_error('paid_sub_not_active'); |
|
| 885 | + } |
|
| 861 | 886 | |
| 862 | 887 | // Simplify... |
| 863 | 888 | $context['sub'] = $context['subscriptions'][$ID_SUB]; |
| 864 | 889 | $period = 'xx'; |
| 865 | - if ($context['sub']['flexible']) |
|
| 866 | - $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
| 890 | + if ($context['sub']['flexible']) { |
|
| 891 | + $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
| 892 | + } |
|
| 867 | 893 | |
| 868 | 894 | // Check we have a valid cost. |
| 869 | - if ($context['sub']['flexible'] && $period == 'xx') |
|
| 870 | - fatal_lang_error('paid_sub_not_active'); |
|
| 895 | + if ($context['sub']['flexible'] && $period == 'xx') { |
|
| 896 | + fatal_lang_error('paid_sub_not_active'); |
|
| 897 | + } |
|
| 871 | 898 | |
| 872 | 899 | // Sort out the cost/currency. |
| 873 | 900 | $context['currency'] = $modSettings['paid_currency_code']; |
@@ -880,8 +907,7 @@ discard block |
||
| 880 | 907 | $context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]]; |
| 881 | 908 | // The period value for paypal. |
| 882 | 909 | $context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1)); |
| 883 | - } |
|
| 884 | - else |
|
| 910 | + } else |
|
| 885 | 911 | { |
| 886 | 912 | // Real cost... |
| 887 | 913 | $context['value'] = $context['sub']['costs']['fixed']; |
@@ -898,13 +924,15 @@ discard block |
||
| 898 | 924 | foreach ($gateways as $id => $gateway) |
| 899 | 925 | { |
| 900 | 926 | $fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done'); |
| 901 | - if (!empty($fields['form'])) |
|
| 902 | - $context['gateways'][] = $fields; |
|
| 927 | + if (!empty($fields['form'])) { |
|
| 928 | + $context['gateways'][] = $fields; |
|
| 929 | + } |
|
| 903 | 930 | } |
| 904 | 931 | |
| 905 | 932 | // Bugger?! |
| 906 | - if (empty($context['gateways'])) |
|
| 907 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 933 | + if (empty($context['gateways'])) { |
|
| 934 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 935 | + } |
|
| 908 | 936 | |
| 909 | 937 | // Now we are going to assume they want to take this out ;) |
| 910 | 938 | $new_data = array($context['sub']['id'], $context['value'], $period, 'prepay'); |
@@ -912,16 +940,19 @@ discard block |
||
| 912 | 940 | { |
| 913 | 941 | // What are the details like? |
| 914 | 942 | $current_pending = array(); |
| 915 | - if ($context['current'][$context['sub']['id']]['pending_details'] != '') |
|
| 916 | - $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
| 943 | + if ($context['current'][$context['sub']['id']]['pending_details'] != '') { |
|
| 944 | + $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
| 945 | + } |
|
| 917 | 946 | // Don't get silly. |
| 918 | - if (count($current_pending) > 9) |
|
| 919 | - $current_pending = array(); |
|
| 947 | + if (count($current_pending) > 9) { |
|
| 948 | + $current_pending = array(); |
|
| 949 | + } |
|
| 920 | 950 | $pending_count = 0; |
| 921 | 951 | // Only record real pending payments as will otherwise confuse the admin! |
| 922 | - foreach ($current_pending as $pending) |
|
| 923 | - if ($pending[3] == 'payback') |
|
| 952 | + foreach ($current_pending as $pending) { |
|
| 953 | + if ($pending[3] == 'payback') |
|
| 924 | 954 | $pending_count++; |
| 955 | + } |
|
| 925 | 956 | |
| 926 | 957 | if (!in_array($new_data, $current_pending)) |
| 927 | 958 | { |
@@ -966,9 +997,9 @@ discard block |
||
| 966 | 997 | |
| 967 | 998 | // Quit. |
| 968 | 999 | return; |
| 1000 | + } else { |
|
| 1001 | + $context['sub_template'] = 'user_subscription'; |
|
| 1002 | + } |
|
| 969 | 1003 | } |
| 970 | - else |
|
| 971 | - $context['sub_template'] = 'user_subscription'; |
|
| 972 | -} |
|
| 973 | 1004 | |
| 974 | 1005 | ?> |
| 975 | 1006 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main entrance point for the Manage Members screen. |
@@ -62,16 +63,18 @@ discard block |
||
| 62 | 63 | $context['activation_numbers'] = array(); |
| 63 | 64 | $context['awaiting_activation'] = 0; |
| 64 | 65 | $context['awaiting_approval'] = 0; |
| 65 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 66 | - $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
| 66 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 67 | + $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
| 68 | + } |
|
| 67 | 69 | $smcFunc['db_free_result']($request); |
| 68 | 70 | |
| 69 | 71 | foreach ($context['activation_numbers'] as $activation_type => $total_members) |
| 70 | 72 | { |
| 71 | - if (in_array($activation_type, array(0, 2))) |
|
| 72 | - $context['awaiting_activation'] += $total_members; |
|
| 73 | - elseif (in_array($activation_type, array(3, 4, 5))) |
|
| 74 | - $context['awaiting_approval'] += $total_members; |
|
| 73 | + if (in_array($activation_type, array(0, 2))) { |
|
| 74 | + $context['awaiting_activation'] += $total_members; |
|
| 75 | + } elseif (in_array($activation_type, array(3, 4, 5))) { |
|
| 76 | + $context['awaiting_approval'] += $total_members; |
|
| 77 | + } |
|
| 75 | 78 | } |
| 76 | 79 | |
| 77 | 80 | // For the page header... do we show activation? |
@@ -124,8 +127,9 @@ discard block |
||
| 124 | 127 | } |
| 125 | 128 | if (!$context['show_approve'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'approve')) |
| 126 | 129 | { |
| 127 | - if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) |
|
| 128 | - $context['tabs']['search']['is_last'] = true; |
|
| 130 | + if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) { |
|
| 131 | + $context['tabs']['search']['is_last'] = true; |
|
| 132 | + } |
|
| 129 | 133 | unset($context['tabs']['approve']); |
| 130 | 134 | } |
| 131 | 135 | |
@@ -157,8 +161,9 @@ discard block |
||
| 157 | 161 | foreach ($_POST['delete'] as $key => $value) |
| 158 | 162 | { |
| 159 | 163 | // Don't delete yourself, idiot. |
| 160 | - if ($value != $user_info['id']) |
|
| 161 | - $delete[$key] = (int) $value; |
|
| 164 | + if ($value != $user_info['id']) { |
|
| 165 | + $delete[$key] = (int) $value; |
|
| 166 | + } |
|
| 162 | 167 | } |
| 163 | 168 | |
| 164 | 169 | if (!empty($delete)) |
@@ -194,17 +199,18 @@ discard block |
||
| 194 | 199 | ); |
| 195 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 196 | 201 | { |
| 197 | - if ($row['min_posts'] == -1) |
|
| 198 | - $context['membergroups'][] = array( |
|
| 202 | + if ($row['min_posts'] == -1) { |
|
| 203 | + $context['membergroups'][] = array( |
|
| 199 | 204 | 'id' => $row['id_group'], |
| 200 | 205 | 'name' => $row['group_name'], |
| 201 | 206 | 'can_be_additional' => true |
| 202 | 207 | ); |
| 203 | - else |
|
| 204 | - $context['postgroups'][] = array( |
|
| 208 | + } else { |
|
| 209 | + $context['postgroups'][] = array( |
|
| 205 | 210 | 'id' => $row['id_group'], |
| 206 | 211 | 'name' => $row['group_name'] |
| 207 | 212 | ); |
| 213 | + } |
|
| 208 | 214 | } |
| 209 | 215 | $smcFunc['db_free_result']($request); |
| 210 | 216 | |
@@ -268,14 +274,15 @@ discard block |
||
| 268 | 274 | call_integration_hook('integrate_view_members_params', array(&$params)); |
| 269 | 275 | |
| 270 | 276 | $search_params = array(); |
| 271 | - if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) |
|
| 272 | - $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
| 273 | - elseif (!empty($_POST)) |
|
| 277 | + if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) { |
|
| 278 | + $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
| 279 | + } elseif (!empty($_POST)) |
|
| 274 | 280 | { |
| 275 | 281 | $search_params['types'] = $_POST['types']; |
| 276 | - foreach ($params as $param_name => $param_info) |
|
| 277 | - if (isset($_POST[$param_name])) |
|
| 282 | + foreach ($params as $param_name => $param_info) { |
|
| 283 | + if (isset($_POST[$param_name])) |
|
| 278 | 284 | $search_params[$param_name] = $_POST[$param_name]; |
| 285 | + } |
|
| 279 | 286 | } |
| 280 | 287 | |
| 281 | 288 | $search_url_params = isset($search_params) ? base64_encode($smcFunc['json_encode']($search_params)) : null; |
@@ -288,18 +295,21 @@ discard block |
||
| 288 | 295 | foreach ($params as $param_name => $param_info) |
| 289 | 296 | { |
| 290 | 297 | // Not filled in? |
| 291 | - if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') |
|
| 292 | - continue; |
|
| 298 | + if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') { |
|
| 299 | + continue; |
|
| 300 | + } |
|
| 293 | 301 | |
| 294 | 302 | // Make sure numeric values are really numeric. |
| 295 | - if (in_array($param_info['type'], array('int', 'age'))) |
|
| 296 | - $search_params[$param_name] = (int) $search_params[$param_name]; |
|
| 303 | + if (in_array($param_info['type'], array('int', 'age'))) { |
|
| 304 | + $search_params[$param_name] = (int) $search_params[$param_name]; |
|
| 305 | + } |
|
| 297 | 306 | // Date values have to match the specified format. |
| 298 | 307 | elseif ($param_info['type'] == 'date') |
| 299 | 308 | { |
| 300 | 309 | // Check if this date format is valid. |
| 301 | - if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) |
|
| 302 | - continue; |
|
| 310 | + if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) { |
|
| 311 | + continue; |
|
| 312 | + } |
|
| 303 | 313 | |
| 304 | 314 | $search_params[$param_name] = strtotime($search_params[$param_name]); |
| 305 | 315 | } |
@@ -308,8 +318,9 @@ discard block |
||
| 308 | 318 | if (!empty($param_info['range'])) |
| 309 | 319 | { |
| 310 | 320 | // Default to '=', just in case... |
| 311 | - if (empty($range_trans[$search_params['types'][$param_name]])) |
|
| 312 | - $search_params['types'][$param_name] = '='; |
|
| 321 | + if (empty($range_trans[$search_params['types'][$param_name]])) { |
|
| 322 | + $search_params['types'][$param_name] = '='; |
|
| 323 | + } |
|
| 313 | 324 | |
| 314 | 325 | // Handle special case 'age'. |
| 315 | 326 | if ($param_info['type'] == 'age') |
@@ -337,29 +348,30 @@ discard block |
||
| 337 | 348 | elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=') |
| 338 | 349 | { |
| 339 | 350 | $query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400); |
| 351 | + } else { |
|
| 352 | + $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
| 340 | 353 | } |
| 341 | - else |
|
| 342 | - $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
| 343 | 354 | } |
| 344 | 355 | // Checkboxes. |
| 345 | 356 | elseif ($param_info['type'] == 'checkbox') |
| 346 | 357 | { |
| 347 | 358 | // Each checkbox or no checkbox at all is checked -> ignore. |
| 348 | - if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) |
|
| 349 | - continue; |
|
| 359 | + if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) { |
|
| 360 | + continue; |
|
| 361 | + } |
|
| 350 | 362 | |
| 351 | 363 | $query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})'; |
| 352 | 364 | $where_params[$param_name . '_check'] = $search_params[$param_name]; |
| 353 | - } |
|
| 354 | - else |
|
| 365 | + } else |
|
| 355 | 366 | { |
| 356 | 367 | // Replace the wildcard characters ('*' and '?') into MySQL ones. |
| 357 | 368 | $parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'))); |
| 358 | 369 | |
| 359 | - if ($smcFunc['db_case_sensitive']) |
|
| 360 | - $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
| 361 | - else |
|
| 362 | - $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
| 370 | + if ($smcFunc['db_case_sensitive']) { |
|
| 371 | + $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
| 372 | + } else { |
|
| 373 | + $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
| 374 | + } |
|
| 363 | 375 | $where_params[$param_name . '_normal'] = '%' . $parameter . '%'; |
| 364 | 376 | } |
| 365 | 377 | } |
@@ -375,16 +387,18 @@ discard block |
||
| 375 | 387 | } |
| 376 | 388 | |
| 377 | 389 | // Additional membergroups (these are only relevant if not all primary groups where selected!). |
| 378 | - if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) |
|
| 379 | - foreach ($search_params['membergroups'][2] as $mg) |
|
| 390 | + if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) { |
|
| 391 | + foreach ($search_params['membergroups'][2] as $mg) |
|
| 380 | 392 | { |
| 381 | 393 | $mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0'; |
| 394 | + } |
|
| 382 | 395 | $where_params['add_group_' . $mg] = $mg; |
| 383 | 396 | } |
| 384 | 397 | |
| 385 | 398 | // Combine the one or two membergroup parts into one query part linked with an OR. |
| 386 | - if (!empty($mg_query_parts)) |
|
| 387 | - $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
| 399 | + if (!empty($mg_query_parts)) { |
|
| 400 | + $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
| 401 | + } |
|
| 388 | 402 | |
| 389 | 403 | // Get all selected post count related membergroups. |
| 390 | 404 | if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups'])) |
@@ -396,9 +410,9 @@ discard block |
||
| 396 | 410 | // Construct the where part of the query. |
| 397 | 411 | $where = empty($query_parts) ? '1=1' : implode(' |
| 398 | 412 | AND ', $query_parts); |
| 413 | + } else { |
|
| 414 | + $search_url_params = null; |
|
| 399 | 415 | } |
| 400 | - else |
|
| 401 | - $search_url_params = null; |
|
| 402 | 416 | |
| 403 | 417 | // Construct the additional URL part with the query info in it. |
| 404 | 418 | $context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : ''; |
@@ -521,28 +535,32 @@ discard block |
||
| 521 | 535 | 'function' => function($rowData) use ($txt) |
| 522 | 536 | { |
| 523 | 537 | // Calculate number of days since last online. |
| 524 | - if (empty($rowData['last_login'])) |
|
| 525 | - $difference = $txt['never']; |
|
| 526 | - else |
|
| 538 | + if (empty($rowData['last_login'])) { |
|
| 539 | + $difference = $txt['never']; |
|
| 540 | + } else |
|
| 527 | 541 | { |
| 528 | 542 | $num_days_difference = jeffsdatediff($rowData['last_login']); |
| 529 | 543 | |
| 530 | 544 | // Today. |
| 531 | - if (empty($num_days_difference)) |
|
| 532 | - $difference = $txt['viewmembers_today']; |
|
| 545 | + if (empty($num_days_difference)) { |
|
| 546 | + $difference = $txt['viewmembers_today']; |
|
| 547 | + } |
|
| 533 | 548 | |
| 534 | 549 | // Yesterday. |
| 535 | - elseif ($num_days_difference == 1) |
|
| 536 | - $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
| 550 | + elseif ($num_days_difference == 1) { |
|
| 551 | + $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
| 552 | + } |
|
| 537 | 553 | |
| 538 | 554 | // X days ago. |
| 539 | - else |
|
| 540 | - $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
| 555 | + else { |
|
| 556 | + $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
| 557 | + } |
|
| 541 | 558 | } |
| 542 | 559 | |
| 543 | 560 | // Show it in italics if they're not activated... |
| 544 | - if ($rowData['is_activated'] % 10 != 1) |
|
| 545 | - $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
| 561 | + if ($rowData['is_activated'] % 10 != 1) { |
|
| 562 | + $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
| 563 | + } |
|
| 546 | 564 | |
| 547 | 565 | return $difference; |
| 548 | 566 | }, |
@@ -594,8 +612,9 @@ discard block |
||
| 594 | 612 | ); |
| 595 | 613 | |
| 596 | 614 | // Without enough permissions, don't show 'delete members' checkboxes. |
| 597 | - if (!allowedTo('profile_remove_any')) |
|
| 598 | - unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
| 615 | + if (!allowedTo('profile_remove_any')) { |
|
| 616 | + unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
| 617 | + } |
|
| 599 | 618 | |
| 600 | 619 | require_once($sourcedir . '/Subs-List.php'); |
| 601 | 620 | createList($listOptions); |
@@ -638,17 +657,18 @@ discard block |
||
| 638 | 657 | ); |
| 639 | 658 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 640 | 659 | { |
| 641 | - if ($row['min_posts'] == -1) |
|
| 642 | - $context['membergroups'][] = array( |
|
| 660 | + if ($row['min_posts'] == -1) { |
|
| 661 | + $context['membergroups'][] = array( |
|
| 643 | 662 | 'id' => $row['id_group'], |
| 644 | 663 | 'name' => $row['group_name'], |
| 645 | 664 | 'can_be_additional' => true |
| 646 | 665 | ); |
| 647 | - else |
|
| 648 | - $context['postgroups'][] = array( |
|
| 666 | + } else { |
|
| 667 | + $context['postgroups'][] = array( |
|
| 649 | 668 | 'id' => $row['id_group'], |
| 650 | 669 | 'name' => $row['group_name'] |
| 651 | 670 | ); |
| 671 | + } |
|
| 652 | 672 | } |
| 653 | 673 | $smcFunc['db_free_result']($request); |
| 654 | 674 | |
@@ -675,8 +695,9 @@ discard block |
||
| 675 | 695 | $context['page_title'] = $txt['admin_members']; |
| 676 | 696 | $context['sub_template'] = 'admin_browse'; |
| 677 | 697 | $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve'); |
| 678 | - if (isset($context['tabs'][$context['browse_type']])) |
|
| 679 | - $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
| 698 | + if (isset($context['tabs'][$context['browse_type']])) { |
|
| 699 | + $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
| 700 | + } |
|
| 680 | 701 | |
| 681 | 702 | // Allowed filters are those we can have, in theory. |
| 682 | 703 | $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2); |
@@ -687,18 +708,20 @@ discard block |
||
| 687 | 708 | foreach ($context['activation_numbers'] as $type => $amount) |
| 688 | 709 | { |
| 689 | 710 | // We have some of these... |
| 690 | - if (in_array($type, $context['allowed_filters']) && $amount > 0) |
|
| 691 | - $context['available_filters'][] = array( |
|
| 711 | + if (in_array($type, $context['allowed_filters']) && $amount > 0) { |
|
| 712 | + $context['available_filters'][] = array( |
|
| 692 | 713 | 'type' => $type, |
| 693 | 714 | 'amount' => $amount, |
| 694 | 715 | 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', |
| 695 | 716 | 'selected' => $type == $context['current_filter'] |
| 696 | 717 | ); |
| 718 | + } |
|
| 697 | 719 | } |
| 698 | 720 | |
| 699 | 721 | // If the filter was not sent, set it to whatever has people in it! |
| 700 | - if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) |
|
| 701 | - $context['current_filter'] = $context['available_filters'][0]['type']; |
|
| 722 | + if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) { |
|
| 723 | + $context['current_filter'] = $context['available_filters'][0]['type']; |
|
| 724 | + } |
|
| 702 | 725 | |
| 703 | 726 | // This little variable is used to determine if we should flag where we are looking. |
| 704 | 727 | $context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1; |
@@ -713,44 +736,47 @@ discard block |
||
| 713 | 736 | ); |
| 714 | 737 | |
| 715 | 738 | // Are we showing duplicate information? |
| 716 | - if (isset($_GET['showdupes'])) |
|
| 717 | - $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
| 739 | + if (isset($_GET['showdupes'])) { |
|
| 740 | + $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
| 741 | + } |
|
| 718 | 742 | $context['show_duplicates'] = !empty($_SESSION['showdupes']); |
| 719 | 743 | |
| 720 | 744 | // Determine which actions we should allow on this page. |
| 721 | 745 | if ($context['browse_type'] == 'approve') |
| 722 | 746 | { |
| 723 | 747 | // If we are approving deleted accounts we have a slightly different list... actually a mirror ;) |
| 724 | - if ($context['current_filter'] == 4) |
|
| 725 | - $context['allowed_actions'] = array( |
|
| 748 | + if ($context['current_filter'] == 4) { |
|
| 749 | + $context['allowed_actions'] = array( |
|
| 726 | 750 | 'reject' => $txt['admin_browse_w_approve_deletion'], |
| 727 | 751 | 'ok' => $txt['admin_browse_w_reject'], |
| 728 | 752 | ); |
| 729 | - else |
|
| 730 | - $context['allowed_actions'] = array( |
|
| 753 | + } else { |
|
| 754 | + $context['allowed_actions'] = array( |
|
| 731 | 755 | 'ok' => $txt['admin_browse_w_approve'], |
| 732 | 756 | 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], |
| 733 | 757 | 'require_activation' => $txt['admin_browse_w_approve_require_activate'], |
| 734 | 758 | 'reject' => $txt['admin_browse_w_reject'], |
| 735 | 759 | 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'], |
| 736 | 760 | ); |
| 737 | - } |
|
| 738 | - elseif ($context['browse_type'] == 'activate') |
|
| 739 | - $context['allowed_actions'] = array( |
|
| 761 | + } |
|
| 762 | + } elseif ($context['browse_type'] == 'activate') { |
|
| 763 | + $context['allowed_actions'] = array( |
|
| 740 | 764 | 'ok' => $txt['admin_browse_w_activate'], |
| 741 | 765 | 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], |
| 742 | 766 | 'delete' => $txt['admin_browse_w_delete'], |
| 743 | 767 | 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], |
| 744 | 768 | 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'], |
| 745 | 769 | ); |
| 770 | + } |
|
| 746 | 771 | |
| 747 | 772 | // Create an option list for actions allowed to be done with selected members. |
| 748 | 773 | $allowed_actions = ' |
| 749 | 774 | <option selected value="">' . $txt['admin_browse_with_selected'] . ':</option> |
| 750 | 775 | <option value="" disabled>-----------------------------</option>'; |
| 751 | - foreach ($context['allowed_actions'] as $key => $desc) |
|
| 752 | - $allowed_actions .= ' |
|
| 776 | + foreach ($context['allowed_actions'] as $key => $desc) { |
|
| 777 | + $allowed_actions .= ' |
|
| 753 | 778 | <option value="' . $key . '">' . $desc . '</option>'; |
| 779 | + } |
|
| 754 | 780 | |
| 755 | 781 | // Setup the Javascript function for selecting an action for the list. |
| 756 | 782 | $javascript = ' |
@@ -762,15 +788,16 @@ discard block |
||
| 762 | 788 | var message = "";'; |
| 763 | 789 | |
| 764 | 790 | // We have special messages for approving deletion of accounts - it's surprisingly logical - honest. |
| 765 | - if ($context['current_filter'] == 4) |
|
| 766 | - $javascript .= ' |
|
| 791 | + if ($context['current_filter'] == 4) { |
|
| 792 | + $javascript .= ' |
|
| 767 | 793 | if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
| 768 | 794 | message = "' . $txt['admin_browse_w_delete'] . '"; |
| 769 | 795 | else |
| 770 | 796 | message = "' . $txt['admin_browse_w_reject'] . '";'; |
| 797 | + } |
|
| 771 | 798 | // Otherwise a nice standard message. |
| 772 | - else |
|
| 773 | - $javascript .= ' |
|
| 799 | + else { |
|
| 800 | + $javascript .= ' |
|
| 774 | 801 | if (document.forms.postForm.todo.value.indexOf("delete") != -1) |
| 775 | 802 | message = "' . $txt['admin_browse_w_delete'] . '"; |
| 776 | 803 | else if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
@@ -779,6 +806,7 @@ discard block |
||
| 779 | 806 | message = "' . $txt['admin_browse_w_remind'] . '"; |
| 780 | 807 | else |
| 781 | 808 | message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";'; |
| 809 | + } |
|
| 782 | 810 | $javascript .= ' |
| 783 | 811 | if (confirm(message + " ' . $txt['admin_browse_warn'] . '")) |
| 784 | 812 | document.forms.postForm.submit(); |
@@ -911,10 +939,11 @@ discard block |
||
| 911 | 939 | $member_links = array(); |
| 912 | 940 | foreach ($rowData['duplicate_members'] as $member) |
| 913 | 941 | { |
| 914 | - if ($member['id']) |
|
| 915 | - $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
| 916 | - else |
|
| 917 | - $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
| 942 | + if ($member['id']) { |
|
| 943 | + $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
| 944 | + } else { |
|
| 945 | + $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
| 946 | + } |
|
| 918 | 947 | } |
| 919 | 948 | return implode(', ', $member_links); |
| 920 | 949 | }, |
@@ -963,14 +992,16 @@ discard block |
||
| 963 | 992 | ); |
| 964 | 993 | |
| 965 | 994 | // Pick what column to actually include if we're showing duplicates. |
| 966 | - if ($context['show_duplicates']) |
|
| 967 | - unset($listOptions['columns']['email']); |
|
| 968 | - else |
|
| 969 | - unset($listOptions['columns']['duplicates']); |
|
| 995 | + if ($context['show_duplicates']) { |
|
| 996 | + unset($listOptions['columns']['email']); |
|
| 997 | + } else { |
|
| 998 | + unset($listOptions['columns']['duplicates']); |
|
| 999 | + } |
|
| 970 | 1000 | |
| 971 | 1001 | // Only show hostname on duplicates as it takes a lot of time. |
| 972 | - if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) |
|
| 973 | - unset($listOptions['columns']['hostname']); |
|
| 1002 | + if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) { |
|
| 1003 | + unset($listOptions['columns']['hostname']); |
|
| 1004 | + } |
|
| 974 | 1005 | |
| 975 | 1006 | // Is there any need to show filters? |
| 976 | 1007 | if (isset($context['available_filters']) && count($context['available_filters']) > 1) |
@@ -978,9 +1009,10 @@ discard block |
||
| 978 | 1009 | $filterOptions = ' |
| 979 | 1010 | <strong>' . $txt['admin_browse_filter_by'] . ':</strong> |
| 980 | 1011 | <select name="filter" onchange="this.form.submit();">'; |
| 981 | - foreach ($context['available_filters'] as $filter) |
|
| 982 | - $filterOptions .= ' |
|
| 1012 | + foreach ($context['available_filters'] as $filter) { |
|
| 1013 | + $filterOptions .= ' |
|
| 983 | 1014 | <option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>'; |
| 1015 | + } |
|
| 984 | 1016 | $filterOptions .= ' |
| 985 | 1017 | </select> |
| 986 | 1018 | <noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button"></noscript>'; |
@@ -992,12 +1024,13 @@ discard block |
||
| 992 | 1024 | } |
| 993 | 1025 | |
| 994 | 1026 | // What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at. |
| 995 | - if (!empty($context['show_filter']) && !empty($context['available_filters'])) |
|
| 996 | - $listOptions['additional_rows'][] = array( |
|
| 1027 | + if (!empty($context['show_filter']) && !empty($context['available_filters'])) { |
|
| 1028 | + $listOptions['additional_rows'][] = array( |
|
| 997 | 1029 | 'position' => 'above_column_headers', |
| 998 | 1030 | 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'], |
| 999 | 1031 | 'class' => 'smalltext floatright', |
| 1000 | 1032 | ); |
| 1033 | + } |
|
| 1001 | 1034 | |
| 1002 | 1035 | // Now that we have all the options, create the list. |
| 1003 | 1036 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1027,12 +1060,14 @@ discard block |
||
| 1027 | 1060 | $current_filter = (int) $_REQUEST['orig_filter']; |
| 1028 | 1061 | |
| 1029 | 1062 | // If we are applying a filter do just that - then redirect. |
| 1030 | - if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) |
|
| 1031 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
| 1063 | + if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) { |
|
| 1064 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
| 1065 | + } |
|
| 1032 | 1066 | |
| 1033 | 1067 | // Nothing to do? |
| 1034 | - if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) |
|
| 1035 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1068 | + if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) { |
|
| 1069 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1070 | + } |
|
| 1036 | 1071 | |
| 1037 | 1072 | // Are we dealing with members who have been waiting for > set amount of time? |
| 1038 | 1073 | if (isset($_POST['time_passed'])) |
@@ -1045,8 +1080,9 @@ discard block |
||
| 1045 | 1080 | else |
| 1046 | 1081 | { |
| 1047 | 1082 | $members = array(); |
| 1048 | - foreach ($_POST['todoAction'] as $id) |
|
| 1049 | - $members[] = (int) $id; |
|
| 1083 | + foreach ($_POST['todoAction'] as $id) { |
|
| 1084 | + $members[] = (int) $id; |
|
| 1085 | + } |
|
| 1050 | 1086 | $condition = ' |
| 1051 | 1087 | AND id_member IN ({array_int:members})'; |
| 1052 | 1088 | } |
@@ -1067,8 +1103,9 @@ discard block |
||
| 1067 | 1103 | $member_count = $smcFunc['db_num_rows']($request); |
| 1068 | 1104 | |
| 1069 | 1105 | // If no results then just return! |
| 1070 | - if ($member_count == 0) |
|
| 1071 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1106 | + if ($member_count == 0) { |
|
| 1107 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1108 | + } |
|
| 1072 | 1109 | |
| 1073 | 1110 | $member_info = array(); |
| 1074 | 1111 | $members = array(); |
@@ -1107,8 +1144,9 @@ discard block |
||
| 1107 | 1144 | // Do we have to let the integration code know about the activations? |
| 1108 | 1145 | if (!empty($modSettings['integrate_activate'])) |
| 1109 | 1146 | { |
| 1110 | - foreach ($member_info as $member) |
|
| 1111 | - call_integration_hook('integrate_activate', array($member['username'])); |
|
| 1147 | + foreach ($member_info as $member) { |
|
| 1148 | + call_integration_hook('integrate_activate', array($member['username'])); |
|
| 1149 | + } |
|
| 1112 | 1150 | } |
| 1113 | 1151 | |
| 1114 | 1152 | // Check for email. |
@@ -1238,20 +1276,23 @@ discard block |
||
| 1238 | 1276 | $log_action = $_POST['todo'] == 'remind' ? 'remind_member' : 'approve_member'; |
| 1239 | 1277 | |
| 1240 | 1278 | require_once($sourcedir . '/Logging.php'); |
| 1241 | - foreach ($member_info as $member) |
|
| 1242 | - logAction($log_action, array('member' => $member['id']), 'admin'); |
|
| 1279 | + foreach ($member_info as $member) { |
|
| 1280 | + logAction($log_action, array('member' => $member['id']), 'admin'); |
|
| 1281 | + } |
|
| 1243 | 1282 | } |
| 1244 | 1283 | |
| 1245 | 1284 | // Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers). |
| 1246 | - if (in_array($current_filter, array(3, 4, 5))) |
|
| 1247 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
| 1285 | + if (in_array($current_filter, array(3, 4, 5))) { |
|
| 1286 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
| 1287 | + } |
|
| 1248 | 1288 | |
| 1249 | 1289 | // Update the member's stats. (but, we know the member didn't change their name.) |
| 1250 | 1290 | updateStats('member', false); |
| 1251 | 1291 | |
| 1252 | 1292 | // If they haven't been deleted, update the post group statistics on them... |
| 1253 | - if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) |
|
| 1254 | - updateStats('postgroups', $members); |
|
| 1293 | + if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) { |
|
| 1294 | + updateStats('postgroups', $members); |
|
| 1295 | + } |
|
| 1255 | 1296 | |
| 1256 | 1297 | redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
| 1257 | 1298 | } |
@@ -1276,10 +1317,11 @@ discard block |
||
| 1276 | 1317 | $dis = time() - $old; |
| 1277 | 1318 | |
| 1278 | 1319 | // Before midnight? |
| 1279 | - if ($dis < $sinceMidnight) |
|
| 1280 | - return 0; |
|
| 1281 | - else |
|
| 1282 | - $dis -= $sinceMidnight; |
|
| 1320 | + if ($dis < $sinceMidnight) { |
|
| 1321 | + return 0; |
|
| 1322 | + } else { |
|
| 1323 | + $dis -= $sinceMidnight; |
|
| 1324 | + } |
|
| 1283 | 1325 | |
| 1284 | 1326 | // Divide out the seconds in a day to get the number of days. |
| 1285 | 1327 | return ceil($dis / (24 * 60 * 60)); |