@@ -59,8 +59,9 @@ discard block |
||
| 59 | 59 | * @version 2.1 Beta 3 |
| 60 | 60 | */ |
| 61 | 61 | |
| 62 | -if (!defined('SMF')) |
|
| 62 | +if (!defined('SMF')) { |
|
| 63 | 63 | die('No direct access...'); |
| 64 | +} |
|
| 64 | 65 | |
| 65 | 66 | /** |
| 66 | 67 | * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects |
@@ -111,10 +112,11 @@ discard block |
||
| 111 | 112 | $settings_not_writable = !is_writable($boarddir . '/Settings.php'); |
| 112 | 113 | $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
| 113 | 114 | |
| 114 | - if ($settings_not_writable) |
|
| 115 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 116 | - elseif ($settings_backup_fail) |
|
| 117 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 115 | + if ($settings_not_writable) { |
|
| 116 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 117 | + } elseif ($settings_backup_fail) { |
|
| 118 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 119 | + } |
|
| 118 | 120 | |
| 119 | 121 | $context['settings_not_writable'] = $settings_not_writable; |
| 120 | 122 | |
@@ -166,8 +168,9 @@ discard block |
||
| 166 | 168 | |
| 167 | 169 | call_integration_hook('integrate_general_settings', array(&$config_vars)); |
| 168 | 170 | |
| 169 | - if ($return_config) |
|
| 170 | - return $config_vars; |
|
| 171 | + if ($return_config) { |
|
| 172 | + return $config_vars; |
|
| 173 | + } |
|
| 171 | 174 | |
| 172 | 175 | // Setup the template stuff. |
| 173 | 176 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save'; |
@@ -232,8 +235,9 @@ discard block |
||
| 232 | 235 | |
| 233 | 236 | call_integration_hook('integrate_database_settings', array(&$config_vars)); |
| 234 | 237 | |
| 235 | - if ($return_config) |
|
| 236 | - return $config_vars; |
|
| 238 | + if ($return_config) { |
|
| 239 | + return $config_vars; |
|
| 240 | + } |
|
| 237 | 241 | |
| 238 | 242 | // Setup the template stuff. |
| 239 | 243 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save'; |
@@ -308,13 +312,15 @@ discard block |
||
| 308 | 312 | hideGlobalCookies(); |
| 309 | 313 | });', true); |
| 310 | 314 | |
| 311 | - if (empty($user_settings['tfa_secret'])) |
|
| 312 | - addInlineJavaScript(''); |
|
| 315 | + if (empty($user_settings['tfa_secret'])) { |
|
| 316 | + addInlineJavaScript(''); |
|
| 317 | + } |
|
| 313 | 318 | |
| 314 | 319 | call_integration_hook('integrate_cookie_settings', array(&$config_vars)); |
| 315 | 320 | |
| 316 | - if ($return_config) |
|
| 317 | - return $config_vars; |
|
| 321 | + if ($return_config) { |
|
| 322 | + return $config_vars; |
|
| 323 | + } |
|
| 318 | 324 | |
| 319 | 325 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save'; |
| 320 | 326 | $context['settings_title'] = $txt['cookies_sessions_settings']; |
@@ -325,11 +331,13 @@ discard block |
||
| 325 | 331 | call_integration_hook('integrate_save_cookie_settings'); |
| 326 | 332 | |
| 327 | 333 | // Local and global do not play nicely together. |
| 328 | - if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) |
|
| 329 | - unset ($_POST['globalCookies']); |
|
| 334 | + if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) { |
|
| 335 | + unset ($_POST['globalCookies']); |
|
| 336 | + } |
|
| 330 | 337 | |
| 331 | - if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) |
|
| 332 | - fatal_lang_error('invalid_cookie_domain', false); |
|
| 338 | + if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) { |
|
| 339 | + fatal_lang_error('invalid_cookie_domain', false); |
|
| 340 | + } |
|
| 333 | 341 | |
| 334 | 342 | saveSettings($config_vars); |
| 335 | 343 | |
@@ -412,8 +420,9 @@ discard block |
||
| 412 | 420 | |
| 413 | 421 | call_integration_hook('integrate_general_security_settings', array(&$config_vars)); |
| 414 | 422 | |
| 415 | - if ($return_config) |
|
| 416 | - return $config_vars; |
|
| 423 | + if ($return_config) { |
|
| 424 | + return $config_vars; |
|
| 425 | + } |
|
| 417 | 426 | |
| 418 | 427 | // Saving? |
| 419 | 428 | if (isset($_GET['save'])) |
@@ -452,8 +461,7 @@ discard block |
||
| 452 | 461 | $txt['cache_settings_message'] = $txt['detected_no_caching']; |
| 453 | 462 | $cache_level = array($txt['cache_off']); |
| 454 | 463 | $detected['none'] = $txt['cache_off']; |
| 455 | - } |
|
| 456 | - else |
|
| 464 | + } else |
|
| 457 | 465 | { |
| 458 | 466 | $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected)); |
| 459 | 467 | $cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']); |
@@ -490,8 +498,9 @@ discard block |
||
| 490 | 498 | } |
| 491 | 499 | } |
| 492 | 500 | } |
| 493 | - if ($return_config) |
|
| 494 | - return $config_vars; |
|
| 501 | + if ($return_config) { |
|
| 502 | + return $config_vars; |
|
| 503 | + } |
|
| 495 | 504 | |
| 496 | 505 | // Saving again? |
| 497 | 506 | if (isset($_GET['save'])) |
@@ -519,8 +528,9 @@ discard block |
||
| 519 | 528 | $context['save_disabled'] = $context['settings_not_writable']; |
| 520 | 529 | |
| 521 | 530 | // Decide what message to show. |
| 522 | - if (!$context['save_disabled']) |
|
| 523 | - $context['settings_message'] = $txt['caching_information']; |
|
| 531 | + if (!$context['save_disabled']) { |
|
| 532 | + $context['settings_message'] = $txt['caching_information']; |
|
| 533 | + } |
|
| 524 | 534 | |
| 525 | 535 | // Prepare the template. |
| 526 | 536 | prepareServerSettingsContext($config_vars); |
@@ -543,24 +553,25 @@ discard block |
||
| 543 | 553 | if (stripos(PHP_OS, 'win') === 0) |
| 544 | 554 | { |
| 545 | 555 | $context['settings_message'] = $txt['loadavg_disabled_windows']; |
| 546 | - if (isset($_GET['save'])) |
|
| 547 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
| 548 | - } |
|
| 549 | - elseif (stripos(PHP_OS, 'darwin') === 0) |
|
| 556 | + if (isset($_GET['save'])) { |
|
| 557 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
| 558 | + } |
|
| 559 | + } elseif (stripos(PHP_OS, 'darwin') === 0) |
|
| 550 | 560 | { |
| 551 | 561 | $context['settings_message'] = $txt['loadavg_disabled_osx']; |
| 552 | - if (isset($_GET['save'])) |
|
| 553 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
| 554 | - } |
|
| 555 | - else |
|
| 562 | + if (isset($_GET['save'])) { |
|
| 563 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
| 564 | + } |
|
| 565 | + } else |
|
| 556 | 566 | { |
| 557 | 567 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 558 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) |
|
| 559 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 560 | - elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) |
|
| 561 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 562 | - else |
|
| 563 | - unset($modSettings['load_average']); |
|
| 568 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) { |
|
| 569 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 570 | + } elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) { |
|
| 571 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 572 | + } else { |
|
| 573 | + unset($modSettings['load_average']); |
|
| 574 | + } |
|
| 564 | 575 | |
| 565 | 576 | if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
| 566 | 577 | { |
@@ -596,8 +607,9 @@ discard block |
||
| 596 | 607 | |
| 597 | 608 | call_integration_hook('integrate_loadavg_settings', array(&$config_vars)); |
| 598 | 609 | |
| 599 | - if ($return_config) |
|
| 600 | - return $config_vars; |
|
| 610 | + if ($return_config) { |
|
| 611 | + return $config_vars; |
|
| 612 | + } |
|
| 601 | 613 | |
| 602 | 614 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save'; |
| 603 | 615 | $context['settings_title'] = $txt['load_balancing_settings']; |
@@ -608,24 +620,27 @@ discard block |
||
| 608 | 620 | // Stupidity is not allowed. |
| 609 | 621 | foreach ($_POST as $key => $value) |
| 610 | 622 | { |
| 611 | - if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) |
|
| 612 | - continue; |
|
| 613 | - else |
|
| 614 | - $_POST[$key] = (float) $value; |
|
| 615 | - |
|
| 616 | - if ($key == 'loadavg_auto_opt' && $value <= 1) |
|
| 617 | - $_POST['loadavg_auto_opt'] = 1.0; |
|
| 618 | - elseif ($key == 'loadavg_forum' && $value < 10) |
|
| 619 | - $_POST['loadavg_forum'] = 10.0; |
|
| 620 | - elseif ($value < 2) |
|
| 621 | - $_POST[$key] = 2.0; |
|
| 623 | + if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) { |
|
| 624 | + continue; |
|
| 625 | + } else { |
|
| 626 | + $_POST[$key] = (float) $value; |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + if ($key == 'loadavg_auto_opt' && $value <= 1) { |
|
| 630 | + $_POST['loadavg_auto_opt'] = 1.0; |
|
| 631 | + } elseif ($key == 'loadavg_forum' && $value < 10) { |
|
| 632 | + $_POST['loadavg_forum'] = 10.0; |
|
| 633 | + } elseif ($value < 2) { |
|
| 634 | + $_POST[$key] = 2.0; |
|
| 635 | + } |
|
| 622 | 636 | } |
| 623 | 637 | |
| 624 | 638 | call_integration_hook('integrate_save_loadavg_settings'); |
| 625 | 639 | |
| 626 | 640 | saveDBSettings($config_vars); |
| 627 | - if (!isset($_SESSION['adm-save'])) |
|
| 628 | - $_SESSION['adm-save'] = true; |
|
| 641 | + if (!isset($_SESSION['adm-save'])) { |
|
| 642 | + $_SESSION['adm-save'] = true; |
|
| 643 | + } |
|
| 629 | 644 | redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']); |
| 630 | 645 | } |
| 631 | 646 | |
@@ -661,10 +676,11 @@ discard block |
||
| 661 | 676 | |
| 662 | 677 | if (isset($_SESSION['adm-save'])) |
| 663 | 678 | { |
| 664 | - if ($_SESSION['adm-save'] === true) |
|
| 665 | - $context['saved_successful'] = true; |
|
| 666 | - else |
|
| 667 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 679 | + if ($_SESSION['adm-save'] === true) { |
|
| 680 | + $context['saved_successful'] = true; |
|
| 681 | + } else { |
|
| 682 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 683 | + } |
|
| 668 | 684 | |
| 669 | 685 | unset($_SESSION['adm-save']); |
| 670 | 686 | } |
@@ -672,9 +688,9 @@ discard block |
||
| 672 | 688 | $context['config_vars'] = array(); |
| 673 | 689 | foreach ($config_vars as $identifier => $config_var) |
| 674 | 690 | { |
| 675 | - if (!is_array($config_var) || !isset($config_var[1])) |
|
| 676 | - $context['config_vars'][] = $config_var; |
|
| 677 | - else |
|
| 691 | + if (!is_array($config_var) || !isset($config_var[1])) { |
|
| 692 | + $context['config_vars'][] = $config_var; |
|
| 693 | + } else |
|
| 678 | 694 | { |
| 679 | 695 | $varname = $config_var[0]; |
| 680 | 696 | global $$varname; |
@@ -709,16 +725,19 @@ discard block |
||
| 709 | 725 | if ($config_var[3] == 'int' || $config_var[3] == 'float') |
| 710 | 726 | { |
| 711 | 727 | // Default to a min of 0 if one isn't set |
| 712 | - if (isset($config_var['min'])) |
|
| 713 | - $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
| 714 | - else |
|
| 715 | - $context['config_vars'][$config_var[0]]['min'] = 0; |
|
| 728 | + if (isset($config_var['min'])) { |
|
| 729 | + $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
| 730 | + } else { |
|
| 731 | + $context['config_vars'][$config_var[0]]['min'] = 0; |
|
| 732 | + } |
|
| 716 | 733 | |
| 717 | - if (isset($config_var['max'])) |
|
| 718 | - $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
| 734 | + if (isset($config_var['max'])) { |
|
| 735 | + $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
| 736 | + } |
|
| 719 | 737 | |
| 720 | - if (isset($config_var['step'])) |
|
| 721 | - $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
| 738 | + if (isset($config_var['step'])) { |
|
| 739 | + $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
| 740 | + } |
|
| 722 | 741 | } |
| 723 | 742 | |
| 724 | 743 | // If this is a select box handle any data. |
@@ -726,12 +745,13 @@ discard block |
||
| 726 | 745 | { |
| 727 | 746 | // If it's associative |
| 728 | 747 | $config_values = array_values($config_var[4]); |
| 729 | - if (isset($config_values[0]) && is_array($config_values[0])) |
|
| 730 | - $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
| 731 | - else |
|
| 748 | + if (isset($config_values[0]) && is_array($config_values[0])) { |
|
| 749 | + $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
| 750 | + } else |
|
| 732 | 751 | { |
| 733 | - foreach ($config_var[4] as $key => $item) |
|
| 734 | - $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
| 752 | + foreach ($config_var[4] as $key => $item) { |
|
| 753 | + $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
| 754 | + } |
|
| 735 | 755 | } |
| 736 | 756 | } |
| 737 | 757 | } |
@@ -756,10 +776,11 @@ discard block |
||
| 756 | 776 | |
| 757 | 777 | if (isset($_SESSION['adm-save'])) |
| 758 | 778 | { |
| 759 | - if ($_SESSION['adm-save'] === true) |
|
| 760 | - $context['saved_successful'] = true; |
|
| 761 | - else |
|
| 762 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 779 | + if ($_SESSION['adm-save'] === true) { |
|
| 780 | + $context['saved_successful'] = true; |
|
| 781 | + } else { |
|
| 782 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 783 | + } |
|
| 763 | 784 | |
| 764 | 785 | unset($_SESSION['adm-save']); |
| 765 | 786 | } |
@@ -771,26 +792,30 @@ discard block |
||
| 771 | 792 | foreach ($config_vars as $config_var) |
| 772 | 793 | { |
| 773 | 794 | // HR? |
| 774 | - if (!is_array($config_var)) |
|
| 775 | - $context['config_vars'][] = $config_var; |
|
| 776 | - else |
|
| 795 | + if (!is_array($config_var)) { |
|
| 796 | + $context['config_vars'][] = $config_var; |
|
| 797 | + } else |
|
| 777 | 798 | { |
| 778 | 799 | // If it has no name it doesn't have any purpose! |
| 779 | - if (empty($config_var[1])) |
|
| 780 | - continue; |
|
| 800 | + if (empty($config_var[1])) { |
|
| 801 | + continue; |
|
| 802 | + } |
|
| 781 | 803 | |
| 782 | 804 | // Special case for inline permissions |
| 783 | - if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) |
|
| 784 | - $inlinePermissions[] = $config_var[1]; |
|
| 785 | - elseif ($config_var[0] == 'permissions') |
|
| 786 | - continue; |
|
| 805 | + if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) { |
|
| 806 | + $inlinePermissions[] = $config_var[1]; |
|
| 807 | + } elseif ($config_var[0] == 'permissions') { |
|
| 808 | + continue; |
|
| 809 | + } |
|
| 787 | 810 | |
| 788 | - if ($config_var[0] == 'boards') |
|
| 789 | - $board_list = true; |
|
| 811 | + if ($config_var[0] == 'boards') { |
|
| 812 | + $board_list = true; |
|
| 813 | + } |
|
| 790 | 814 | |
| 791 | 815 | // Are we showing the BBC selection box? |
| 792 | - if ($config_var[0] == 'bbc') |
|
| 793 | - $bbcChoice[] = $config_var[1]; |
|
| 816 | + if ($config_var[0] == 'bbc') { |
|
| 817 | + $bbcChoice[] = $config_var[1]; |
|
| 818 | + } |
|
| 794 | 819 | |
| 795 | 820 | // We need to do some parsing of the value before we pass it in. |
| 796 | 821 | if (isset($modSettings[$config_var[1]])) |
@@ -809,8 +834,7 @@ discard block |
||
| 809 | 834 | default: |
| 810 | 835 | $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]); |
| 811 | 836 | } |
| 812 | - } |
|
| 813 | - else |
|
| 837 | + } else |
|
| 814 | 838 | { |
| 815 | 839 | // Darn, it's empty. What type is expected? |
| 816 | 840 | switch ($config_var[0]) |
@@ -850,16 +874,19 @@ discard block |
||
| 850 | 874 | if ($config_var[0] == 'int' || $config_var[0] == 'float') |
| 851 | 875 | { |
| 852 | 876 | // Default to a min of 0 if one isn't set |
| 853 | - if (isset($config_var['min'])) |
|
| 854 | - $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
| 855 | - else |
|
| 856 | - $context['config_vars'][$config_var[1]]['min'] = 0; |
|
| 877 | + if (isset($config_var['min'])) { |
|
| 878 | + $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
| 879 | + } else { |
|
| 880 | + $context['config_vars'][$config_var[1]]['min'] = 0; |
|
| 881 | + } |
|
| 857 | 882 | |
| 858 | - if (isset($config_var['max'])) |
|
| 859 | - $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
| 883 | + if (isset($config_var['max'])) { |
|
| 884 | + $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
| 885 | + } |
|
| 860 | 886 | |
| 861 | - if (isset($config_var['step'])) |
|
| 862 | - $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
| 887 | + if (isset($config_var['step'])) { |
|
| 888 | + $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
| 889 | + } |
|
| 863 | 890 | } |
| 864 | 891 | |
| 865 | 892 | // If this is a select box handle any data. |
@@ -873,12 +900,13 @@ discard block |
||
| 873 | 900 | } |
| 874 | 901 | |
| 875 | 902 | // If it's associative |
| 876 | - if (isset($config_var[2][0]) && is_array($config_var[2][0])) |
|
| 877 | - $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
| 878 | - else |
|
| 903 | + if (isset($config_var[2][0]) && is_array($config_var[2][0])) { |
|
| 904 | + $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
| 905 | + } else |
|
| 879 | 906 | { |
| 880 | - foreach ($config_var[2] as $key => $item) |
|
| 881 | - $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
| 907 | + foreach ($config_var[2] as $key => $item) { |
|
| 908 | + $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
| 909 | + } |
|
| 882 | 910 | } |
| 883 | 911 | } |
| 884 | 912 | |
@@ -887,17 +915,19 @@ discard block |
||
| 887 | 915 | { |
| 888 | 916 | if (!is_numeric($k)) |
| 889 | 917 | { |
| 890 | - if (substr($k, 0, 2) == 'on') |
|
| 891 | - $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
| 892 | - else |
|
| 893 | - $context['config_vars'][$config_var[1]][$k] = $v; |
|
| 918 | + if (substr($k, 0, 2) == 'on') { |
|
| 919 | + $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
| 920 | + } else { |
|
| 921 | + $context['config_vars'][$config_var[1]][$k] = $v; |
|
| 922 | + } |
|
| 894 | 923 | } |
| 895 | 924 | |
| 896 | 925 | // See if there are any other labels that might fit? |
| 897 | - if (isset($txt['setting_' . $config_var[1]])) |
|
| 898 | - $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
| 899 | - elseif (isset($txt['groups_' . $config_var[1]])) |
|
| 900 | - $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
| 926 | + if (isset($txt['setting_' . $config_var[1]])) { |
|
| 927 | + $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
| 928 | + } elseif (isset($txt['groups_' . $config_var[1]])) { |
|
| 929 | + $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
| 930 | + } |
|
| 901 | 931 | } |
| 902 | 932 | |
| 903 | 933 | // Set the subtext in case it's part of the label. |
@@ -930,8 +960,9 @@ discard block |
||
| 930 | 960 | // What are the options, eh? |
| 931 | 961 | $temp = parse_bbc(false); |
| 932 | 962 | $bbcTags = array(); |
| 933 | - foreach ($temp as $tag) |
|
| 934 | - $bbcTags[] = $tag['tag']; |
|
| 963 | + foreach ($temp as $tag) { |
|
| 964 | + $bbcTags[] = $tag['tag']; |
|
| 965 | + } |
|
| 935 | 966 | |
| 936 | 967 | $bbcTags = array_unique($bbcTags); |
| 937 | 968 | $totalTags = count($bbcTags); |
@@ -946,8 +977,9 @@ discard block |
||
| 946 | 977 | $col = 0; $i = 0; |
| 947 | 978 | foreach ($bbcTags as $tag) |
| 948 | 979 | { |
| 949 | - if ($i % $tagsPerColumn == 0 && $i != 0) |
|
| 950 | - $col++; |
|
| 980 | + if ($i % $tagsPerColumn == 0 && $i != 0) { |
|
| 981 | + $col++; |
|
| 982 | + } |
|
| 951 | 983 | |
| 952 | 984 | $context['bbc_columns'][$col][] = array( |
| 953 | 985 | 'tag' => $tag, |
@@ -990,18 +1022,21 @@ discard block |
||
| 990 | 1022 | validateToken('admin-ssc'); |
| 991 | 1023 | |
| 992 | 1024 | // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!) |
| 993 | - if (isset($_POST['cookiename'])) |
|
| 994 | - $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
| 1025 | + if (isset($_POST['cookiename'])) { |
|
| 1026 | + $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
| 1027 | + } |
|
| 995 | 1028 | |
| 996 | 1029 | // Fix the forum's URL if necessary. |
| 997 | 1030 | if (isset($_POST['boardurl'])) |
| 998 | 1031 | { |
| 999 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 1000 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1001 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 1002 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1003 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 1004 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1032 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1033 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1034 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1035 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1036 | + } |
|
| 1037 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1038 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1039 | + } |
|
| 1005 | 1040 | } |
| 1006 | 1041 | |
| 1007 | 1042 | // Any passwords? |
@@ -1036,21 +1071,21 @@ discard block |
||
| 1036 | 1071 | // Figure out which config vars we're saving here... |
| 1037 | 1072 | foreach ($config_vars as $var) |
| 1038 | 1073 | { |
| 1039 | - if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) |
|
| 1040 | - continue; |
|
| 1074 | + if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) { |
|
| 1075 | + continue; |
|
| 1076 | + } |
|
| 1041 | 1077 | |
| 1042 | 1078 | $config_var = $var[0]; |
| 1043 | 1079 | |
| 1044 | 1080 | if (in_array($config_var, $config_passwords)) |
| 1045 | 1081 | { |
| 1046 | - if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) |
|
| 1047 | - $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
| 1048 | - } |
|
| 1049 | - elseif (in_array($config_var, $config_strs)) |
|
| 1082 | + if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) { |
|
| 1083 | + $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
| 1084 | + } |
|
| 1085 | + } elseif (in_array($config_var, $config_strs)) |
|
| 1050 | 1086 | { |
| 1051 | 1087 | $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\''; |
| 1052 | - } |
|
| 1053 | - elseif (in_array($config_var, $config_ints)) |
|
| 1088 | + } elseif (in_array($config_var, $config_ints)) |
|
| 1054 | 1089 | { |
| 1055 | 1090 | $new_settings[$config_var] = (int) $_POST[$config_var]; |
| 1056 | 1091 | |
@@ -1059,17 +1094,17 @@ discard block |
||
| 1059 | 1094 | $new_settings[$config_var] = max($min, $new_settings[$config_var]); |
| 1060 | 1095 | |
| 1061 | 1096 | // Is there a max value for this as well? |
| 1062 | - if (isset($var['max'])) |
|
| 1063 | - $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
| 1064 | - } |
|
| 1065 | - elseif (in_array($config_var, $config_bools)) |
|
| 1097 | + if (isset($var['max'])) { |
|
| 1098 | + $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
| 1099 | + } |
|
| 1100 | + } elseif (in_array($config_var, $config_bools)) |
|
| 1066 | 1101 | { |
| 1067 | - if (!empty($_POST[$config_var])) |
|
| 1068 | - $new_settings[$config_var] = '1'; |
|
| 1069 | - else |
|
| 1070 | - $new_settings[$config_var] = '0'; |
|
| 1071 | - } |
|
| 1072 | - else |
|
| 1102 | + if (!empty($_POST[$config_var])) { |
|
| 1103 | + $new_settings[$config_var] = '1'; |
|
| 1104 | + } else { |
|
| 1105 | + $new_settings[$config_var] = '0'; |
|
| 1106 | + } |
|
| 1107 | + } else |
|
| 1073 | 1108 | { |
| 1074 | 1109 | // This shouldn't happen, but it might... |
| 1075 | 1110 | fatal_error('Unknown config_var \'' . $config_var . '\''); |
@@ -1085,30 +1120,35 @@ discard block |
||
| 1085 | 1120 | foreach ($config_vars as $config_var) |
| 1086 | 1121 | { |
| 1087 | 1122 | // We just saved the file-based settings, so skip their definitions. |
| 1088 | - if (!is_array($config_var) || $config_var[2] == 'file') |
|
| 1089 | - continue; |
|
| 1123 | + if (!is_array($config_var) || $config_var[2] == 'file') { |
|
| 1124 | + continue; |
|
| 1125 | + } |
|
| 1090 | 1126 | |
| 1091 | 1127 | $new_setting = array($config_var[3], $config_var[0]); |
| 1092 | 1128 | |
| 1093 | 1129 | // Select options need carried over, too. |
| 1094 | - if (isset($config_var[4])) |
|
| 1095 | - $new_setting[] = $config_var[4]; |
|
| 1130 | + if (isset($config_var[4])) { |
|
| 1131 | + $new_setting[] = $config_var[4]; |
|
| 1132 | + } |
|
| 1096 | 1133 | |
| 1097 | 1134 | // Include min and max if necessary |
| 1098 | - if (isset($config_var['min'])) |
|
| 1099 | - $new_setting['min'] = $config_var['min']; |
|
| 1135 | + if (isset($config_var['min'])) { |
|
| 1136 | + $new_setting['min'] = $config_var['min']; |
|
| 1137 | + } |
|
| 1100 | 1138 | |
| 1101 | - if (isset($config_var['max'])) |
|
| 1102 | - $new_setting['max'] = $config_var['max']; |
|
| 1139 | + if (isset($config_var['max'])) { |
|
| 1140 | + $new_setting['max'] = $config_var['max']; |
|
| 1141 | + } |
|
| 1103 | 1142 | |
| 1104 | 1143 | // Rewrite the definition a bit. |
| 1105 | 1144 | $new_settings[] = $new_setting; |
| 1106 | 1145 | } |
| 1107 | 1146 | |
| 1108 | 1147 | // Save the new database-based settings, if any. |
| 1109 | - if (!empty($new_settings)) |
|
| 1110 | - saveDBSettings($new_settings); |
|
| 1111 | -} |
|
| 1148 | + if (!empty($new_settings)) { |
|
| 1149 | + saveDBSettings($new_settings); |
|
| 1150 | + } |
|
| 1151 | + } |
|
| 1112 | 1152 | |
| 1113 | 1153 | /** |
| 1114 | 1154 | * Helper function for saving database settings. |
@@ -1126,22 +1166,25 @@ discard block |
||
| 1126 | 1166 | $inlinePermissions = array(); |
| 1127 | 1167 | foreach ($config_vars as $var) |
| 1128 | 1168 | { |
| 1129 | - if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) |
|
| 1130 | - continue; |
|
| 1169 | + if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) { |
|
| 1170 | + continue; |
|
| 1171 | + } |
|
| 1131 | 1172 | |
| 1132 | 1173 | // Checkboxes! |
| 1133 | - elseif ($var[0] == 'check') |
|
| 1134 | - $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
| 1174 | + elseif ($var[0] == 'check') { |
|
| 1175 | + $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
| 1176 | + } |
|
| 1135 | 1177 | // Select boxes! |
| 1136 | - elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) |
|
| 1137 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1138 | - elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
| 1178 | + elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) { |
|
| 1179 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1180 | + } elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
| 1139 | 1181 | { |
| 1140 | 1182 | // For security purposes we validate this line by line. |
| 1141 | 1183 | $lOptions = array(); |
| 1142 | - foreach ($_POST[$var[1]] as $invar) |
|
| 1143 | - if (in_array($invar, array_keys($var[2]))) |
|
| 1184 | + foreach ($_POST[$var[1]] as $invar) { |
|
| 1185 | + if (in_array($invar, array_keys($var[2]))) |
|
| 1144 | 1186 | $lOptions[] = $invar; |
| 1187 | + } |
|
| 1145 | 1188 | |
| 1146 | 1189 | $setArray[$var[1]] = json_encode($lOptions); |
| 1147 | 1190 | } |
@@ -1155,18 +1198,20 @@ discard block |
||
| 1155 | 1198 | $request = $smcFunc['db_query']('', ' |
| 1156 | 1199 | SELECT id_board |
| 1157 | 1200 | FROM {db_prefix}boards'); |
| 1158 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1159 | - $board_list[$row[0]] = true; |
|
| 1201 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1202 | + $board_list[$row[0]] = true; |
|
| 1203 | + } |
|
| 1160 | 1204 | |
| 1161 | 1205 | $smcFunc['db_free_result']($request); |
| 1162 | 1206 | } |
| 1163 | 1207 | |
| 1164 | 1208 | $lOptions = array(); |
| 1165 | 1209 | |
| 1166 | - if (!empty($_POST[$var[1]])) |
|
| 1167 | - foreach ($_POST[$var[1]] as $invar => $dummy) |
|
| 1210 | + if (!empty($_POST[$var[1]])) { |
|
| 1211 | + foreach ($_POST[$var[1]] as $invar => $dummy) |
|
| 1168 | 1212 | if (isset($board_list[$invar])) |
| 1169 | 1213 | $lOptions[] = $invar; |
| 1214 | + } |
|
| 1170 | 1215 | |
| 1171 | 1216 | $setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : ''; |
| 1172 | 1217 | } |
@@ -1180,8 +1225,9 @@ discard block |
||
| 1180 | 1225 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
| 1181 | 1226 | |
| 1182 | 1227 | // Do we have a max value for this as well? |
| 1183 | - if (isset($var['max'])) |
|
| 1184 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1228 | + if (isset($var['max'])) { |
|
| 1229 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1230 | + } |
|
| 1185 | 1231 | } |
| 1186 | 1232 | // Floating point! |
| 1187 | 1233 | elseif ($var[0] == 'float') |
@@ -1193,40 +1239,47 @@ discard block |
||
| 1193 | 1239 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
| 1194 | 1240 | |
| 1195 | 1241 | // Do we have a max value for this as well? |
| 1196 | - if (isset($var['max'])) |
|
| 1197 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1242 | + if (isset($var['max'])) { |
|
| 1243 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1244 | + } |
|
| 1198 | 1245 | } |
| 1199 | 1246 | // Text! |
| 1200 | - elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) |
|
| 1201 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1247 | + elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) { |
|
| 1248 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1249 | + } |
|
| 1202 | 1250 | // Passwords! |
| 1203 | 1251 | elseif ($var[0] == 'password') |
| 1204 | 1252 | { |
| 1205 | - if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) |
|
| 1206 | - $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
| 1253 | + if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) { |
|
| 1254 | + $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
| 1255 | + } |
|
| 1207 | 1256 | } |
| 1208 | 1257 | // BBC. |
| 1209 | 1258 | elseif ($var[0] == 'bbc') |
| 1210 | 1259 | { |
| 1211 | 1260 | |
| 1212 | 1261 | $bbcTags = array(); |
| 1213 | - foreach (parse_bbc(false) as $tag) |
|
| 1214 | - $bbcTags[] = $tag['tag']; |
|
| 1262 | + foreach (parse_bbc(false) as $tag) { |
|
| 1263 | + $bbcTags[] = $tag['tag']; |
|
| 1264 | + } |
|
| 1215 | 1265 | |
| 1216 | - if (!isset($_POST[$var[1] . '_enabledTags'])) |
|
| 1217 | - $_POST[$var[1] . '_enabledTags'] = array(); |
|
| 1218 | - elseif (!is_array($_POST[$var[1] . '_enabledTags'])) |
|
| 1219 | - $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
| 1266 | + if (!isset($_POST[$var[1] . '_enabledTags'])) { |
|
| 1267 | + $_POST[$var[1] . '_enabledTags'] = array(); |
|
| 1268 | + } elseif (!is_array($_POST[$var[1] . '_enabledTags'])) { |
|
| 1269 | + $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
| 1270 | + } |
|
| 1220 | 1271 | |
| 1221 | 1272 | $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags'])); |
| 1222 | 1273 | } |
| 1223 | 1274 | // Permissions? |
| 1224 | - elseif ($var[0] == 'permissions') |
|
| 1225 | - $inlinePermissions[] = $var[1]; |
|
| 1275 | + elseif ($var[0] == 'permissions') { |
|
| 1276 | + $inlinePermissions[] = $var[1]; |
|
| 1277 | + } |
|
| 1226 | 1278 | } |
| 1227 | 1279 | |
| 1228 | - if (!empty($setArray)) |
|
| 1229 | - updateSettings($setArray); |
|
| 1280 | + if (!empty($setArray)) { |
|
| 1281 | + updateSettings($setArray); |
|
| 1282 | + } |
|
| 1230 | 1283 | |
| 1231 | 1284 | // If we have inline permissions we need to save them. |
| 1232 | 1285 | if (!empty($inlinePermissions) && allowedTo('manage_permissions')) |
@@ -1264,18 +1317,21 @@ discard block |
||
| 1264 | 1317 | // put all of it into an array |
| 1265 | 1318 | foreach ($info_lines as $line) |
| 1266 | 1319 | { |
| 1267 | - if (preg_match('~(' . $remove . ')~', $line)) |
|
| 1268 | - continue; |
|
| 1320 | + if (preg_match('~(' . $remove . ')~', $line)) { |
|
| 1321 | + continue; |
|
| 1322 | + } |
|
| 1269 | 1323 | |
| 1270 | 1324 | // new category? |
| 1271 | - if (strpos($line, '<h2>') !== false) |
|
| 1272 | - $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
| 1325 | + if (strpos($line, '<h2>') !== false) { |
|
| 1326 | + $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
| 1327 | + } |
|
| 1273 | 1328 | |
| 1274 | 1329 | // load it as setting => value or the old setting local master |
| 1275 | - if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
| 1276 | - $pinfo[$category][$val[1]] = $val[2]; |
|
| 1277 | - elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
| 1278 | - $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
| 1330 | + if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
| 1331 | + $pinfo[$category][$val[1]] = $val[2]; |
|
| 1332 | + } elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
| 1333 | + $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
| 1334 | + } |
|
| 1279 | 1335 | } |
| 1280 | 1336 | |
| 1281 | 1337 | // load it in to context and display it |
@@ -1310,8 +1366,9 @@ discard block |
||
| 1310 | 1366 | $testAPI = new $cache_class_name(); |
| 1311 | 1367 | |
| 1312 | 1368 | // No Support? NEXT! |
| 1313 | - if (!$testAPI->isSupported(true)) |
|
| 1314 | - continue; |
|
| 1369 | + if (!$testAPI->isSupported(true)) { |
|
| 1370 | + continue; |
|
| 1371 | + } |
|
| 1315 | 1372 | |
| 1316 | 1373 | $apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache; |
| 1317 | 1374 | } |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | * @version 2.1 Beta 3 |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if (!defined('SMF')) |
|
| 15 | +if (!defined('SMF')) { |
|
| 16 | 16 | die('No direct access...'); |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Create a new list |
@@ -41,21 +42,21 @@ discard block |
||
| 41 | 42 | { |
| 42 | 43 | $list_context['sort'] = array(); |
| 43 | 44 | $sort = '1=1'; |
| 44 | - } |
|
| 45 | - else |
|
| 45 | + } else |
|
| 46 | 46 | { |
| 47 | 47 | $request_var_sort = isset($listOptions['request_vars']['sort']) ? $listOptions['request_vars']['sort'] : 'sort'; |
| 48 | 48 | $request_var_desc = isset($listOptions['request_vars']['desc']) ? $listOptions['request_vars']['desc'] : 'desc'; |
| 49 | - if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) |
|
| 50 | - $list_context['sort'] = array( |
|
| 49 | + if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) { |
|
| 50 | + $list_context['sort'] = array( |
|
| 51 | 51 | 'id' => $_REQUEST[$request_var_sort], |
| 52 | 52 | 'desc' => isset($_REQUEST[$request_var_desc]) && isset($listOptions['columns'][$_REQUEST[$request_var_sort]]['sort']['reverse']), |
| 53 | 53 | ); |
| 54 | - else |
|
| 55 | - $list_context['sort'] = array( |
|
| 54 | + } else { |
|
| 55 | + $list_context['sort'] = array( |
|
| 56 | 56 | 'id' => $listOptions['default_sort_col'], |
| 57 | 57 | 'desc' => (!empty($listOptions['default_sort_dir']) && $listOptions['default_sort_dir'] == 'desc') || (!empty($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default']) && substr($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default'], -4, 4) == 'desc') ? true : false, |
| 58 | 58 | ); |
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | // Set the database column sort. |
| 61 | 62 | $sort = $listOptions['columns'][$list_context['sort']['id']]['sort'][$list_context['sort']['desc'] ? 'reverse' : 'default']; |
@@ -72,8 +73,9 @@ discard block |
||
| 72 | 73 | else |
| 73 | 74 | { |
| 74 | 75 | // First get an impression of how many items to expect. |
| 75 | - if (isset($listOptions['get_count']['file'])) |
|
| 76 | - require_once($listOptions['get_count']['file']); |
|
| 76 | + if (isset($listOptions['get_count']['file'])) { |
|
| 77 | + require_once($listOptions['get_count']['file']); |
|
| 78 | + } |
|
| 77 | 79 | |
| 78 | 80 | $call = call_helper($listOptions['get_count']['function'], true); |
| 79 | 81 | $list_context['total_num_items'] = call_user_func_array($call, empty($listOptions['get_count']['params']) ? array() : $listOptions['get_count']['params']); |
@@ -83,14 +85,15 @@ discard block |
||
| 83 | 85 | $list_context['items_per_page'] = $listOptions['items_per_page']; |
| 84 | 86 | |
| 85 | 87 | // Then create a page index. |
| 86 | - if ($list_context['total_num_items'] > $list_context['items_per_page']) |
|
| 87 | - $list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start'); |
|
| 88 | + if ($list_context['total_num_items'] > $list_context['items_per_page']) { |
|
| 89 | + $list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start'); |
|
| 90 | + } |
|
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | // Prepare the headers of the table. |
| 91 | 94 | $list_context['headers'] = array(); |
| 92 | - foreach ($listOptions['columns'] as $column_id => $column) |
|
| 93 | - $list_context['headers'][] = array( |
|
| 95 | + foreach ($listOptions['columns'] as $column_id => $column) { |
|
| 96 | + $list_context['headers'][] = array( |
|
| 94 | 97 | 'id' => $column_id, |
| 95 | 98 | 'label' => isset($column['header']['eval']) ? eval($column['header']['eval']) : (isset($column['header']['value']) ? $column['header']['value'] : ''), |
| 96 | 99 | 'href' => empty($listOptions['default_sort_col']) || empty($column['sort']) ? '' : $listOptions['base_href'] . ';' . $request_var_sort . '=' . $column_id . ($column_id === $list_context['sort']['id'] && !$list_context['sort']['desc'] && isset($column['sort']['reverse']) ? ';' . $request_var_desc : '') . (empty($list_context['start']) ? '' : ';' . $list_context['start_var_name'] . '=' . $list_context['start']), |
@@ -99,14 +102,16 @@ discard block |
||
| 99 | 102 | 'style' => isset($column['header']['style']) ? $column['header']['style'] : '', |
| 100 | 103 | 'colspan' => isset($column['header']['colspan']) ? $column['header']['colspan'] : '', |
| 101 | 104 | ); |
| 105 | + } |
|
| 102 | 106 | |
| 103 | 107 | // We know the amount of columns, might be useful for the template. |
| 104 | 108 | $list_context['num_columns'] = count($listOptions['columns']); |
| 105 | 109 | $list_context['width'] = isset($listOptions['width']) ? $listOptions['width'] : '0'; |
| 106 | 110 | |
| 107 | 111 | // Get the file with the function for the item list. |
| 108 | - if (isset($listOptions['get_items']['file'])) |
|
| 109 | - require_once($listOptions['get_items']['file']); |
|
| 112 | + if (isset($listOptions['get_items']['file'])) { |
|
| 113 | + require_once($listOptions['get_items']['file']); |
|
| 114 | + } |
|
| 110 | 115 | |
| 111 | 116 | // Call the function and include which items we want and in what order. |
| 112 | 117 | $call = call_helper($listOptions['get_items']['function'], true); |
@@ -123,51 +128,61 @@ discard block |
||
| 123 | 128 | $cur_data = array(); |
| 124 | 129 | |
| 125 | 130 | // A value straight from the database? |
| 126 | - if (isset($column['data']['db'])) |
|
| 127 | - $cur_data['value'] = $list_item[$column['data']['db']]; |
|
| 131 | + if (isset($column['data']['db'])) { |
|
| 132 | + $cur_data['value'] = $list_item[$column['data']['db']]; |
|
| 133 | + } |
|
| 128 | 134 | |
| 129 | 135 | // Take the value from the database and make it HTML safe. |
| 130 | - elseif (isset($column['data']['db_htmlsafe'])) |
|
| 131 | - $cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]); |
|
| 136 | + elseif (isset($column['data']['db_htmlsafe'])) { |
|
| 137 | + $cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]); |
|
| 138 | + } |
|
| 132 | 139 | |
| 133 | 140 | // Using sprintf is probably the most readable way of injecting data. |
| 134 | 141 | elseif (isset($column['data']['sprintf'])) |
| 135 | 142 | { |
| 136 | 143 | $params = array(); |
| 137 | - foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) |
|
| 138 | - $params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param]; |
|
| 144 | + foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) { |
|
| 145 | + $params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param]; |
|
| 146 | + } |
|
| 139 | 147 | $cur_data['value'] = vsprintf($column['data']['sprintf']['format'], $params); |
| 140 | 148 | } |
| 141 | 149 | |
| 142 | 150 | // The most flexible way probably is applying a custom function. |
| 143 | - elseif (isset($column['data']['function'])) |
|
| 144 | - $cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item)); |
|
| 151 | + elseif (isset($column['data']['function'])) { |
|
| 152 | + $cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item)); |
|
| 153 | + } |
|
| 145 | 154 | |
| 146 | 155 | // A modified value (inject the database values). |
| 147 | - elseif (isset($column['data']['eval'])) |
|
| 148 | - $cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval'])); |
|
| 156 | + elseif (isset($column['data']['eval'])) { |
|
| 157 | + $cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval'])); |
|
| 158 | + } |
|
| 149 | 159 | |
| 150 | 160 | // A literal value. |
| 151 | - elseif (isset($column['data']['value'])) |
|
| 152 | - $cur_data['value'] = $column['data']['value']; |
|
| 161 | + elseif (isset($column['data']['value'])) { |
|
| 162 | + $cur_data['value'] = $column['data']['value']; |
|
| 163 | + } |
|
| 153 | 164 | |
| 154 | 165 | // Empty value. |
| 155 | - else |
|
| 156 | - $cur_data['value'] = ''; |
|
| 166 | + else { |
|
| 167 | + $cur_data['value'] = ''; |
|
| 168 | + } |
|
| 157 | 169 | |
| 158 | 170 | // Allow for basic formatting. |
| 159 | - if (!empty($column['data']['comma_format'])) |
|
| 160 | - $cur_data['value'] = comma_format($cur_data['value']); |
|
| 161 | - elseif (!empty($column['data']['timeformat'])) |
|
| 162 | - $cur_data['value'] = timeformat($cur_data['value']); |
|
| 171 | + if (!empty($column['data']['comma_format'])) { |
|
| 172 | + $cur_data['value'] = comma_format($cur_data['value']); |
|
| 173 | + } elseif (!empty($column['data']['timeformat'])) { |
|
| 174 | + $cur_data['value'] = timeformat($cur_data['value']); |
|
| 175 | + } |
|
| 163 | 176 | |
| 164 | 177 | // Set a style class for this column? |
| 165 | - if (isset($column['data']['class'])) |
|
| 166 | - $cur_data['class'] = $column['data']['class']; |
|
| 178 | + if (isset($column['data']['class'])) { |
|
| 179 | + $cur_data['class'] = $column['data']['class']; |
|
| 180 | + } |
|
| 167 | 181 | |
| 168 | 182 | // Fully customized styling for the cells in this column only. |
| 169 | - if (isset($column['data']['style'])) |
|
| 170 | - $cur_data['style'] = $column['data']['style']; |
|
| 183 | + if (isset($column['data']['style'])) { |
|
| 184 | + $cur_data['style'] = $column['data']['style']; |
|
| 185 | + } |
|
| 171 | 186 | |
| 172 | 187 | // Add the data cell properties to the current row. |
| 173 | 188 | $cur_row[$column_id] = $cur_data; |
@@ -176,10 +191,12 @@ discard block |
||
| 176 | 191 | // Maybe we wat set a custom class for the row based on the data in the row itself |
| 177 | 192 | if (isset($listOptions['data_check'])) |
| 178 | 193 | { |
| 179 | - if (isset($listOptions['data_check']['class'])) |
|
| 180 | - $list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item); |
|
| 181 | - if (isset($listOptions['data_check']['style'])) |
|
| 182 | - $list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item); |
|
| 194 | + if (isset($listOptions['data_check']['class'])) { |
|
| 195 | + $list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item); |
|
| 196 | + } |
|
| 197 | + if (isset($listOptions['data_check']['style'])) { |
|
| 198 | + $list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item); |
|
| 199 | + } |
|
| 183 | 200 | } |
| 184 | 201 | |
| 185 | 202 | // Insert the row into the list. |
@@ -187,34 +204,39 @@ discard block |
||
| 187 | 204 | } |
| 188 | 205 | |
| 189 | 206 | // The title is currently optional. |
| 190 | - if (isset($listOptions['title'])) |
|
| 191 | - $list_context['title'] = $listOptions['title']; |
|
| 207 | + if (isset($listOptions['title'])) { |
|
| 208 | + $list_context['title'] = $listOptions['title']; |
|
| 209 | + } |
|
| 192 | 210 | |
| 193 | 211 | // In case there's a form, share it with the template context. |
| 194 | 212 | if (isset($listOptions['form'])) |
| 195 | 213 | { |
| 196 | 214 | $list_context['form'] = $listOptions['form']; |
| 197 | 215 | |
| 198 | - if (!isset($list_context['form']['hidden_fields'])) |
|
| 199 | - $list_context['form']['hidden_fields'] = array(); |
|
| 216 | + if (!isset($list_context['form']['hidden_fields'])) { |
|
| 217 | + $list_context['form']['hidden_fields'] = array(); |
|
| 218 | + } |
|
| 200 | 219 | |
| 201 | 220 | // Always add a session check field. |
| 202 | 221 | $list_context['form']['hidden_fields'][$context['session_var']] = $context['session_id']; |
| 203 | 222 | |
| 204 | 223 | // Will this do a token check? |
| 205 | - if (isset($listOptions['form']['token'])) |
|
| 206 | - $list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token']; |
|
| 224 | + if (isset($listOptions['form']['token'])) { |
|
| 225 | + $list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token']; |
|
| 226 | + } |
|
| 207 | 227 | |
| 208 | 228 | // Include the starting page as hidden field? |
| 209 | - if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) |
|
| 210 | - $list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start']; |
|
| 229 | + if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) { |
|
| 230 | + $list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start']; |
|
| 231 | + } |
|
| 211 | 232 | |
| 212 | 233 | // If sorting needs to be the same after submitting, add the parameter. |
| 213 | 234 | if (!empty($list_context['form']['include_sort']) && !empty($list_context['sort'])) |
| 214 | 235 | { |
| 215 | 236 | $list_context['form']['hidden_fields']['sort'] = $list_context['sort']['id']; |
| 216 | - if ($list_context['sort']['desc']) |
|
| 217 | - $list_context['form']['hidden_fields']['desc'] = 1; |
|
| 237 | + if ($list_context['sort']['desc']) { |
|
| 238 | + $list_context['form']['hidden_fields']['desc'] = 1; |
|
| 239 | + } |
|
| 218 | 240 | } |
| 219 | 241 | } |
| 220 | 242 | |
@@ -231,24 +253,28 @@ discard block |
||
| 231 | 253 | $list_context['additional_rows'] = array(); |
| 232 | 254 | foreach ($listOptions['additional_rows'] as $row) |
| 233 | 255 | { |
| 234 | - if (empty($row)) |
|
| 235 | - continue; |
|
| 256 | + if (empty($row)) { |
|
| 257 | + continue; |
|
| 258 | + } |
|
| 236 | 259 | |
| 237 | 260 | // Supported row positions: top_of_list, after_title, |
| 238 | 261 | // above_column_headers, below_table_data, bottom_of_list. |
| 239 | - if (!isset($list_context['additional_rows'][$row['position']])) |
|
| 240 | - $list_context['additional_rows'][$row['position']] = array(); |
|
| 262 | + if (!isset($list_context['additional_rows'][$row['position']])) { |
|
| 263 | + $list_context['additional_rows'][$row['position']] = array(); |
|
| 264 | + } |
|
| 241 | 265 | $list_context['additional_rows'][$row['position']][] = $row; |
| 242 | 266 | } |
| 243 | 267 | } |
| 244 | 268 | |
| 245 | 269 | // Add an option for inline JavaScript. |
| 246 | - if (isset($listOptions['javascript'])) |
|
| 247 | - $list_context['javascript'] = $listOptions['javascript']; |
|
| 270 | + if (isset($listOptions['javascript'])) { |
|
| 271 | + $list_context['javascript'] = $listOptions['javascript']; |
|
| 272 | + } |
|
| 248 | 273 | |
| 249 | 274 | // We want a menu. |
| 250 | - if (isset($listOptions['list_menu'])) |
|
| 251 | - $list_context['list_menu'] = $listOptions['list_menu']; |
|
| 275 | + if (isset($listOptions['list_menu'])) { |
|
| 276 | + $list_context['list_menu'] = $listOptions['list_menu']; |
|
| 277 | + } |
|
| 252 | 278 | |
| 253 | 279 | // Make sure the template is loaded. |
| 254 | 280 | loadTemplate('GenericList'); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Redirect to the user help ;). |
@@ -95,12 +96,13 @@ discard block |
||
| 95 | 96 | ); |
| 96 | 97 | |
| 97 | 98 | // Have we got a localized one? |
| 98 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
| 99 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 100 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
| 101 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 102 | - else |
|
| 103 | - $context['agreement'] = ''; |
|
| 99 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
| 100 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 101 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
| 102 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 103 | + } else { |
|
| 104 | + $context['agreement'] = ''; |
|
| 105 | + } |
|
| 104 | 106 | |
| 105 | 107 | // Nothing to show, so let's get out of here |
| 106 | 108 | if (empty($context['agreement'])) |
@@ -128,18 +130,21 @@ discard block |
||
| 128 | 130 | { |
| 129 | 131 | global $txt, $helptxt, $context, $scripturl; |
| 130 | 132 | |
| 131 | - if (!isset($_GET['help']) || !is_string($_GET['help'])) |
|
| 132 | - fatal_lang_error('no_access', false); |
|
| 133 | + if (!isset($_GET['help']) || !is_string($_GET['help'])) { |
|
| 134 | + fatal_lang_error('no_access', false); |
|
| 135 | + } |
|
| 133 | 136 | |
| 134 | - if (!isset($helptxt)) |
|
| 135 | - $helptxt = array(); |
|
| 137 | + if (!isset($helptxt)) { |
|
| 138 | + $helptxt = array(); |
|
| 139 | + } |
|
| 136 | 140 | |
| 137 | 141 | // Load the admin help language file and template. |
| 138 | 142 | loadLanguage('Help'); |
| 139 | 143 | |
| 140 | 144 | // Permission specific help? |
| 141 | - if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') |
|
| 142 | - loadLanguage('ManagePermissions'); |
|
| 145 | + if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') { |
|
| 146 | + loadLanguage('ManagePermissions'); |
|
| 147 | + } |
|
| 143 | 148 | |
| 144 | 149 | loadTemplate('Help'); |
| 145 | 150 | |
@@ -154,16 +159,18 @@ discard block |
||
| 154 | 159 | $context['sub_template'] = 'popup'; |
| 155 | 160 | |
| 156 | 161 | // What help string should be used? |
| 157 | - if (isset($helptxt[$_GET['help']])) |
|
| 158 | - $context['help_text'] = $helptxt[$_GET['help']]; |
|
| 159 | - elseif (isset($txt[$_GET['help']])) |
|
| 160 | - $context['help_text'] = $txt[$_GET['help']]; |
|
| 161 | - else |
|
| 162 | - $context['help_text'] = $_GET['help']; |
|
| 162 | + if (isset($helptxt[$_GET['help']])) { |
|
| 163 | + $context['help_text'] = $helptxt[$_GET['help']]; |
|
| 164 | + } elseif (isset($txt[$_GET['help']])) { |
|
| 165 | + $context['help_text'] = $txt[$_GET['help']]; |
|
| 166 | + } else { |
|
| 167 | + $context['help_text'] = $_GET['help']; |
|
| 168 | + } |
|
| 163 | 169 | |
| 164 | 170 | // Does this text contain a link that we should fill in? |
| 165 | - if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) |
|
| 166 | - $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
| 167 | -} |
|
| 171 | + if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) { |
|
| 172 | + $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
| 173 | + } |
|
| 174 | + } |
|
| 168 | 175 | |
| 169 | 176 | ?> |
| 170 | 177 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -43,8 +44,9 @@ discard block |
||
| 43 | 44 | { |
| 44 | 45 | $supported = is_writable($this->cachedir); |
| 45 | 46 | |
| 46 | - if ($test) |
|
| 47 | - return $supported; |
|
| 47 | + if ($test) { |
|
| 48 | + return $supported; |
|
| 49 | + } |
|
| 48 | 50 | return parent::isSupported() && $supported; |
| 49 | 51 | } |
| 50 | 52 | |
@@ -61,11 +63,13 @@ discard block |
||
| 61 | 63 | { |
| 62 | 64 | // Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds |
| 63 | 65 | // causing newer files to take effect a while later. |
| 64 | - if (function_exists('opcache_invalidate')) |
|
| 65 | - opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
| 66 | + if (function_exists('opcache_invalidate')) { |
|
| 67 | + opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
| 68 | + } |
|
| 66 | 69 | |
| 67 | - if (function_exists('apc_delete_file')) |
|
| 68 | - @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
| 70 | + if (function_exists('apc_delete_file')) { |
|
| 71 | + @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
| 72 | + } |
|
| 69 | 73 | |
| 70 | 74 | // php will cache file_exists et all, we can't 100% depend on its results so proceed with caution |
| 71 | 75 | @include($cachedir . '/data_' . $key . '.php'); |
@@ -89,16 +93,18 @@ discard block |
||
| 89 | 93 | |
| 90 | 94 | // Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds |
| 91 | 95 | // causing newer files to take effect a while later. |
| 92 | - if (function_exists('opcache_invalidate')) |
|
| 93 | - opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
| 96 | + if (function_exists('opcache_invalidate')) { |
|
| 97 | + opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
| 98 | + } |
|
| 94 | 99 | |
| 95 | - if (function_exists('apc_delete_file')) |
|
| 96 | - @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
| 100 | + if (function_exists('apc_delete_file')) { |
|
| 101 | + @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
| 102 | + } |
|
| 97 | 103 | |
| 98 | 104 | // Otherwise custom cache? |
| 99 | - if ($value === null) |
|
| 100 | - @unlink($cachedir . '/data_' . $key . '.php'); |
|
| 101 | - else |
|
| 105 | + if ($value === null) { |
|
| 106 | + @unlink($cachedir . '/data_' . $key . '.php'); |
|
| 107 | + } else |
|
| 102 | 108 | { |
| 103 | 109 | $cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>'; |
| 104 | 110 | |
@@ -109,9 +115,9 @@ discard block |
||
| 109 | 115 | { |
| 110 | 116 | @unlink($cachedir . '/data_' . $key . '.php'); |
| 111 | 117 | return false; |
| 118 | + } else { |
|
| 119 | + return true; |
|
| 112 | 120 | } |
| 113 | - else |
|
| 114 | - return true; |
|
| 115 | 121 | } |
| 116 | 122 | } |
| 117 | 123 | |
@@ -123,15 +129,17 @@ discard block |
||
| 123 | 129 | $cachedir = $this->cachedir; |
| 124 | 130 | |
| 125 | 131 | // No directory = no game. |
| 126 | - if (!is_dir($cachedir)) |
|
| 127 | - return; |
|
| 132 | + if (!is_dir($cachedir)) { |
|
| 133 | + return; |
|
| 134 | + } |
|
| 128 | 135 | |
| 129 | 136 | // Remove the files in SMF's own disk cache, if any |
| 130 | 137 | $dh = opendir($cachedir); |
| 131 | 138 | while ($file = readdir($dh)) |
| 132 | 139 | { |
| 133 | - if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) |
|
| 134 | - @unlink($cachedir . '/' . $file); |
|
| 140 | + if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) { |
|
| 141 | + @unlink($cachedir . '/' . $file); |
|
| 142 | + } |
|
| 135 | 143 | } |
| 136 | 144 | closedir($dh); |
| 137 | 145 | |
@@ -165,8 +173,9 @@ discard block |
||
| 165 | 173 | $config_vars[] = $txt['cache_smf_settings']; |
| 166 | 174 | $config_vars[] = array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir'); |
| 167 | 175 | |
| 168 | - if (!isset($context['settings_post_javascript'])) |
|
| 169 | - $context['settings_post_javascript'] = ''; |
|
| 176 | + if (!isset($context['settings_post_javascript'])) { |
|
| 177 | + $context['settings_post_javascript'] = ''; |
|
| 178 | + } |
|
| 170 | 179 | |
| 171 | 180 | $context['settings_post_javascript'] .= ' |
| 172 | 181 | $("#cache_accelerator").change(function (e) { |
@@ -187,10 +196,11 @@ discard block |
||
| 187 | 196 | global $cachedir; |
| 188 | 197 | |
| 189 | 198 | // If its invalid, use SMF's. |
| 190 | - if (is_null($dir) || !is_writable($dir)) |
|
| 191 | - $this->cachedir = $cachedir; |
|
| 192 | - else |
|
| 193 | - $this->cachedir = $dir; |
|
| 199 | + if (is_null($dir) || !is_writable($dir)) { |
|
| 200 | + $this->cachedir = $cachedir; |
|
| 201 | + } else { |
|
| 202 | + $this->cachedir = $dir; |
|
| 203 | + } |
|
| 194 | 204 | } |
| 195 | 205 | |
| 196 | 206 | /** |
@@ -21,8 +21,9 @@ discard block |
||
| 21 | 21 | * @version 2.1 Beta 3 |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -if (!defined('SMF')) |
|
| 24 | +if (!defined('SMF')) { |
|
| 25 | 25 | die('No direct access...'); |
| 26 | +} |
|
| 26 | 27 | |
| 27 | 28 | /** |
| 28 | 29 | * Handling function for generating reports. |
@@ -69,14 +70,15 @@ discard block |
||
| 69 | 70 | ); |
| 70 | 71 | |
| 71 | 72 | $is_first = 0; |
| 72 | - foreach ($context['report_types'] as $k => $temp) |
|
| 73 | - $context['report_types'][$k] = array( |
|
| 73 | + foreach ($context['report_types'] as $k => $temp) { |
|
| 74 | + $context['report_types'][$k] = array( |
|
| 74 | 75 | 'id' => $k, |
| 75 | 76 | 'title' => isset($txt['gr_type_' . $k]) ? $txt['gr_type_' . $k] : $k, |
| 76 | 77 | 'description' => isset($txt['gr_type_desc_' . $k]) ? $txt['gr_type_desc_' . $k] : null, |
| 77 | 78 | 'function' => $temp, |
| 78 | 79 | 'is_first' => $is_first++ == 0, |
| 79 | 80 | ); |
| 81 | + } |
|
| 80 | 82 | |
| 81 | 83 | // If they haven't chosen a report type which is valid, send them off to the report type chooser! |
| 82 | 84 | if (empty($_REQUEST['rt']) || !isset($context['report_types'][$_REQUEST['rt']])) |
@@ -102,8 +104,9 @@ discard block |
||
| 102 | 104 | $context['sub_template'] = $_REQUEST['st']; |
| 103 | 105 | |
| 104 | 106 | // Are we disabling the other layers - print friendly for example? |
| 105 | - if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) |
|
| 106 | - $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
| 107 | + if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) { |
|
| 108 | + $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
| 109 | + } |
|
| 107 | 110 | } |
| 108 | 111 | |
| 109 | 112 | // Make the page title more descriptive. |
@@ -151,8 +154,9 @@ discard block |
||
| 151 | 154 | ) |
| 152 | 155 | ); |
| 153 | 156 | $moderators = array(); |
| 154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 155 | - $moderators[$row['id_board']][] = $row['real_name']; |
|
| 157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 158 | + $moderators[$row['id_board']][] = $row['real_name']; |
|
| 159 | + } |
|
| 156 | 160 | $smcFunc['db_free_result']($request); |
| 157 | 161 | |
| 158 | 162 | // Get every moderator gruop. |
@@ -164,8 +168,9 @@ discard block |
||
| 164 | 168 | ) |
| 165 | 169 | ); |
| 166 | 170 | $moderator_groups = array(); |
| 167 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 168 | - $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
| 171 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 172 | + $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
| 173 | + } |
|
| 169 | 174 | $smcFunc['db_free_result']($request); |
| 170 | 175 | |
| 171 | 176 | // Get all the possible membergroups! |
@@ -176,8 +181,9 @@ discard block |
||
| 176 | 181 | ) |
| 177 | 182 | ); |
| 178 | 183 | $groups = array(-1 => $txt['guest_title'], 0 => $txt['full_member']); |
| 179 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 180 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 185 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 186 | + } |
|
| 181 | 187 | $smcFunc['db_free_result']($request); |
| 182 | 188 | |
| 183 | 189 | // All the fields we'll show. |
@@ -195,8 +201,9 @@ discard block |
||
| 195 | 201 | 'moderator_groups' => $txt['board_moderator_groups'], |
| 196 | 202 | 'groups' => $txt['board_groups'], |
| 197 | 203 | ); |
| 198 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 199 | - $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
| 204 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 205 | + $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
| 206 | + } |
|
| 200 | 207 | |
| 201 | 208 | // Do it in columns, it's just easier. |
| 202 | 209 | setKeys('cols'); |
@@ -222,8 +229,9 @@ discard block |
||
| 222 | 229 | newTable($row['name'], '', 'left', 'auto', 'left', 200, 'left'); |
| 223 | 230 | |
| 224 | 231 | $this_boardSettings = $boardSettings; |
| 225 | - if (empty($row['redirect'])) |
|
| 226 | - unset($this_boardSettings['redirect']); |
|
| 232 | + if (empty($row['redirect'])) { |
|
| 233 | + unset($this_boardSettings['redirect']); |
|
| 234 | + } |
|
| 227 | 235 | |
| 228 | 236 | // First off, add in the side key. |
| 229 | 237 | addData($this_boardSettings); |
@@ -250,10 +258,11 @@ discard block |
||
| 250 | 258 | $allowedGroups = explode(',', $row['member_groups']); |
| 251 | 259 | foreach ($allowedGroups as $key => $group) |
| 252 | 260 | { |
| 253 | - if (isset($groups[$group])) |
|
| 254 | - $allowedGroups[$key] = $groups[$group]; |
|
| 255 | - else |
|
| 256 | - unset($allowedGroups[$key]); |
|
| 261 | + if (isset($groups[$group])) { |
|
| 262 | + $allowedGroups[$key] = $groups[$group]; |
|
| 263 | + } else { |
|
| 264 | + unset($allowedGroups[$key]); |
|
| 265 | + } |
|
| 257 | 266 | } |
| 258 | 267 | $boardData['groups'] = implode(', ', $allowedGroups); |
| 259 | 268 | if (!empty($modSettings['deny_boards_access'])) |
@@ -261,16 +270,18 @@ discard block |
||
| 261 | 270 | $disallowedGroups = explode(',', $row['deny_member_groups']); |
| 262 | 271 | foreach ($disallowedGroups as $key => $group) |
| 263 | 272 | { |
| 264 | - if (isset($groups[$group])) |
|
| 265 | - $disallowedGroups[$key] = $groups[$group]; |
|
| 266 | - else |
|
| 267 | - unset($disallowedGroups[$key]); |
|
| 273 | + if (isset($groups[$group])) { |
|
| 274 | + $disallowedGroups[$key] = $groups[$group]; |
|
| 275 | + } else { |
|
| 276 | + unset($disallowedGroups[$key]); |
|
| 277 | + } |
|
| 268 | 278 | } |
| 269 | 279 | $boardData['disallowed_groups'] = implode(', ', $disallowedGroups); |
| 270 | 280 | } |
| 271 | 281 | |
| 272 | - if (empty($row['redirect'])) |
|
| 273 | - unset ($boardData['redirect']); |
|
| 282 | + if (empty($row['redirect'])) { |
|
| 283 | + unset ($boardData['redirect']); |
|
| 284 | + } |
|
| 274 | 285 | |
| 275 | 286 | // Next add the main data. |
| 276 | 287 | addData($boardData); |
@@ -295,27 +306,31 @@ discard block |
||
| 295 | 306 | |
| 296 | 307 | if (isset($_REQUEST['boards'])) |
| 297 | 308 | { |
| 298 | - if (!is_array($_REQUEST['boards'])) |
|
| 299 | - $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
| 300 | - foreach ($_REQUEST['boards'] as $k => $dummy) |
|
| 301 | - $_REQUEST['boards'][$k] = (int) $dummy; |
|
| 309 | + if (!is_array($_REQUEST['boards'])) { |
|
| 310 | + $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
| 311 | + } |
|
| 312 | + foreach ($_REQUEST['boards'] as $k => $dummy) { |
|
| 313 | + $_REQUEST['boards'][$k] = (int) $dummy; |
|
| 314 | + } |
|
| 302 | 315 | |
| 303 | 316 | $board_clause = 'id_board IN ({array_int:boards})'; |
| 317 | + } else { |
|
| 318 | + $board_clause = '1=1'; |
|
| 304 | 319 | } |
| 305 | - else |
|
| 306 | - $board_clause = '1=1'; |
|
| 307 | 320 | |
| 308 | 321 | if (isset($_REQUEST['groups'])) |
| 309 | 322 | { |
| 310 | - if (!is_array($_REQUEST['groups'])) |
|
| 311 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 312 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
| 313 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 323 | + if (!is_array($_REQUEST['groups'])) { |
|
| 324 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 325 | + } |
|
| 326 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
| 327 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 328 | + } |
|
| 314 | 329 | |
| 315 | 330 | $group_clause = 'id_group IN ({array_int:groups})'; |
| 331 | + } else { |
|
| 332 | + $group_clause = '1=1'; |
|
| 316 | 333 | } |
| 317 | - else |
|
| 318 | - $group_clause = '1=1'; |
|
| 319 | 334 | |
| 320 | 335 | // Fetch all the board names. |
| 321 | 336 | $request = $smcFunc['db_query']('', ' |
@@ -369,12 +384,14 @@ discard block |
||
| 369 | 384 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
| 370 | 385 | ) |
| 371 | 386 | ); |
| 372 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
| 373 | - $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 374 | - else |
|
| 375 | - $member_groups = array('col' => ''); |
|
| 376 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 377 | - $member_groups[$row['id_group']] = $row['group_name']; |
|
| 387 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
| 388 | + $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 389 | + } else { |
|
| 390 | + $member_groups = array('col' => ''); |
|
| 391 | + } |
|
| 392 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 393 | + $member_groups[$row['id_group']] = $row['group_name']; |
|
| 394 | + } |
|
| 378 | 395 | $smcFunc['db_free_result']($request); |
| 379 | 396 | |
| 380 | 397 | // Make sure that every group is represented - plus in rows! |
@@ -411,12 +428,14 @@ discard block |
||
| 411 | 428 | ); |
| 412 | 429 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 413 | 430 | { |
| 414 | - if (in_array($row['permission'], $disabled_permissions)) |
|
| 415 | - continue; |
|
| 431 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
| 432 | + continue; |
|
| 433 | + } |
|
| 416 | 434 | |
| 417 | - foreach ($boards as $id => $board) |
|
| 418 | - if ($board['profile'] == $row['id_profile']) |
|
| 435 | + foreach ($boards as $id => $board) { |
|
| 436 | + if ($board['profile'] == $row['id_profile']) |
|
| 419 | 437 | $board_permissions[$id][$row['id_group']][$row['permission']] = $row['add_deny']; |
| 438 | + } |
|
| 420 | 439 | |
| 421 | 440 | // Make sure we get every permission. |
| 422 | 441 | if (!isset($permissions[$row['permission']])) |
@@ -454,8 +473,9 @@ discard block |
||
| 454 | 473 | foreach ($member_groups as $id_group => $name) |
| 455 | 474 | { |
| 456 | 475 | // Don't overwrite the key column! |
| 457 | - if ($id_group === 'col') |
|
| 458 | - continue; |
|
| 476 | + if ($id_group === 'col') { |
|
| 477 | + continue; |
|
| 478 | + } |
|
| 459 | 479 | |
| 460 | 480 | $group_permissions = isset($groups[$id_group]) ? $groups[$id_group] : array(); |
| 461 | 481 | |
@@ -477,16 +497,18 @@ discard block |
||
| 477 | 497 | } |
| 478 | 498 | |
| 479 | 499 | // Now actually make the data for the group look right. |
| 480 | - if (empty($curData[$id_group])) |
|
| 481 | - $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 482 | - elseif ($curData[$id_group] == 1) |
|
| 483 | - $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 484 | - else |
|
| 485 | - $curData[$id_group] = 'x'; |
|
| 500 | + if (empty($curData[$id_group])) { |
|
| 501 | + $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 502 | + } elseif ($curData[$id_group] == 1) { |
|
| 503 | + $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 504 | + } else { |
|
| 505 | + $curData[$id_group] = 'x'; |
|
| 506 | + } |
|
| 486 | 507 | |
| 487 | 508 | // Embolden those permissions different from global (makes it a lot easier!) |
| 488 | - if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) |
|
| 489 | - $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
| 509 | + if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) { |
|
| 510 | + $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
| 511 | + } |
|
| 490 | 512 | } |
| 491 | 513 | |
| 492 | 514 | // Now add the data for this permission. |
@@ -516,15 +538,17 @@ discard block |
||
| 516 | 538 | ); |
| 517 | 539 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 518 | 540 | { |
| 519 | - if (trim($row['member_groups']) == '') |
|
| 520 | - $groups = array(1); |
|
| 521 | - else |
|
| 522 | - $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
| 541 | + if (trim($row['member_groups']) == '') { |
|
| 542 | + $groups = array(1); |
|
| 543 | + } else { |
|
| 544 | + $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
| 545 | + } |
|
| 523 | 546 | |
| 524 | - if (trim($row['deny_member_groups']) == '') |
|
| 525 | - $denyGroups = array(); |
|
| 526 | - else |
|
| 527 | - $denyGroups = explode(',', $row['deny_member_groups']); |
|
| 547 | + if (trim($row['deny_member_groups']) == '') { |
|
| 548 | + $denyGroups = array(); |
|
| 549 | + } else { |
|
| 550 | + $denyGroups = explode(',', $row['deny_member_groups']); |
|
| 551 | + } |
|
| 528 | 552 | |
| 529 | 553 | $boards[$row['id_board']] = array( |
| 530 | 554 | 'id' => $row['id_board'], |
@@ -548,8 +572,9 @@ discard block |
||
| 548 | 572 | ); |
| 549 | 573 | |
| 550 | 574 | // Add on the boards! |
| 551 | - foreach ($boards as $board) |
|
| 552 | - $mgSettings['board_' . $board['id']] = $board['name']; |
|
| 575 | + foreach ($boards as $board) { |
|
| 576 | + $mgSettings['board_' . $board['id']] = $board['name']; |
|
| 577 | + } |
|
| 553 | 578 | |
| 554 | 579 | // Add all the membergroup settings, plus we'll be adding in columns! |
| 555 | 580 | setKeys('cols', $mgSettings); |
@@ -594,8 +619,9 @@ discard block |
||
| 594 | 619 | 'icons' => '' |
| 595 | 620 | ), |
| 596 | 621 | ); |
| 597 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 598 | - $rows[] = $row; |
|
| 622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 623 | + $rows[] = $row; |
|
| 624 | + } |
|
| 599 | 625 | $smcFunc['db_free_result']($request); |
| 600 | 626 | |
| 601 | 627 | foreach ($rows as $row) |
@@ -611,8 +637,9 @@ discard block |
||
| 611 | 637 | ); |
| 612 | 638 | |
| 613 | 639 | // Board permissions. |
| 614 | - foreach ($boards as $board) |
|
| 615 | - $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
| 640 | + foreach ($boards as $board) { |
|
| 641 | + $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
| 642 | + } |
|
| 616 | 643 | |
| 617 | 644 | addData($group); |
| 618 | 645 | } |
@@ -632,16 +659,18 @@ discard block |
||
| 632 | 659 | |
| 633 | 660 | if (isset($_REQUEST['groups'])) |
| 634 | 661 | { |
| 635 | - if (!is_array($_REQUEST['groups'])) |
|
| 636 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 637 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
| 638 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 662 | + if (!is_array($_REQUEST['groups'])) { |
|
| 663 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 664 | + } |
|
| 665 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
| 666 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 667 | + } |
|
| 639 | 668 | $_REQUEST['groups'] = array_diff($_REQUEST['groups'], array(3)); |
| 640 | 669 | |
| 641 | 670 | $clause = 'id_group IN ({array_int:groups})'; |
| 671 | + } else { |
|
| 672 | + $clause = 'id_group != {int:moderator_group}'; |
|
| 642 | 673 | } |
| 643 | - else |
|
| 644 | - $clause = 'id_group != {int:moderator_group}'; |
|
| 645 | 674 | |
| 646 | 675 | // Get all the possible membergroups, except admin! |
| 647 | 676 | $request = $smcFunc['db_query']('', ' |
@@ -659,12 +688,14 @@ discard block |
||
| 659 | 688 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
| 660 | 689 | ) |
| 661 | 690 | ); |
| 662 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
| 663 | - $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 664 | - else |
|
| 665 | - $groups = array('col' => ''); |
|
| 666 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 667 | - $groups[$row['id_group']] = $row['group_name']; |
|
| 691 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
| 692 | + $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 693 | + } else { |
|
| 694 | + $groups = array('col' => ''); |
|
| 695 | + } |
|
| 696 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 697 | + $groups[$row['id_group']] = $row['group_name']; |
|
| 698 | + } |
|
| 668 | 699 | $smcFunc['db_free_result']($request); |
| 669 | 700 | |
| 670 | 701 | // Make sure that every group is represented! |
@@ -688,8 +719,9 @@ discard block |
||
| 688 | 719 | $disabled_permissions[] = 'calendar_edit_own'; |
| 689 | 720 | $disabled_permissions[] = 'calendar_edit_any'; |
| 690 | 721 | } |
| 691 | - if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) |
|
| 692 | - $disabled_permissions[] = 'issue_warning'; |
|
| 722 | + if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) { |
|
| 723 | + $disabled_permissions[] = 'issue_warning'; |
|
| 724 | + } |
|
| 693 | 725 | |
| 694 | 726 | call_integration_hook('integrate_reports_groupperm', array(&$disabled_permissions)); |
| 695 | 727 | |
@@ -710,15 +742,17 @@ discard block |
||
| 710 | 742 | $curData = array(); |
| 711 | 743 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 712 | 744 | { |
| 713 | - if (in_array($row['permission'], $disabled_permissions)) |
|
| 714 | - continue; |
|
| 745 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
| 746 | + continue; |
|
| 747 | + } |
|
| 715 | 748 | |
| 716 | 749 | // If this is a new permission flush the last row. |
| 717 | 750 | if ($row['permission'] != $lastPermission) |
| 718 | 751 | { |
| 719 | 752 | // Send the data! |
| 720 | - if ($lastPermission !== null) |
|
| 721 | - addData($curData); |
|
| 753 | + if ($lastPermission !== null) { |
|
| 754 | + addData($curData); |
|
| 755 | + } |
|
| 722 | 756 | |
| 723 | 757 | // Add the permission name in the left column. |
| 724 | 758 | $curData = array('col' => isset($txt['group_perms_name_' . $row['permission']]) ? $txt['group_perms_name_' . $row['permission']] : $row['permission']); |
@@ -727,10 +761,11 @@ discard block |
||
| 727 | 761 | } |
| 728 | 762 | |
| 729 | 763 | // Good stuff - add the permission to the list! |
| 730 | - if ($row['add_deny']) |
|
| 731 | - $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 732 | - else |
|
| 733 | - $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 764 | + if ($row['add_deny']) { |
|
| 765 | + $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 766 | + } else { |
|
| 767 | + $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 768 | + } |
|
| 734 | 769 | } |
| 735 | 770 | $smcFunc['db_free_result']($request); |
| 736 | 771 | |
@@ -760,8 +795,9 @@ discard block |
||
| 760 | 795 | ) |
| 761 | 796 | ); |
| 762 | 797 | $boards = array(); |
| 763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 764 | - $boards[$row['id_board']] = $row['name']; |
|
| 798 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 799 | + $boards[$row['id_board']] = $row['name']; |
|
| 800 | + } |
|
| 765 | 801 | $smcFunc['db_free_result']($request); |
| 766 | 802 | |
| 767 | 803 | // Get every moderator. |
@@ -793,12 +829,14 @@ discard block |
||
| 793 | 829 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 794 | 830 | { |
| 795 | 831 | // Either we don't have them as a moderator at all or at least not as a moderator of this board |
| 796 | - if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) |
|
| 797 | - $moderators[$row['id_member']][] = $row['id_board']; |
|
| 832 | + if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) { |
|
| 833 | + $moderators[$row['id_member']][] = $row['id_board']; |
|
| 834 | + } |
|
| 798 | 835 | |
| 799 | 836 | // We don't have them listed as a moderator yet |
| 800 | - if (!array_key_exists($row['id_member'], $local_mods)) |
|
| 801 | - $local_mods[$row['id_member']] = $row['id_member']; |
|
| 837 | + if (!array_key_exists($row['id_member'], $local_mods)) { |
|
| 838 | + $local_mods[$row['id_member']] = $row['id_member']; |
|
| 839 | + } |
|
| 802 | 840 | } |
| 803 | 841 | |
| 804 | 842 | // Get a list of global moderators (i.e. members with moderation powers). |
@@ -811,8 +849,9 @@ discard block |
||
| 811 | 849 | $allStaff = array_unique($allStaff); |
| 812 | 850 | |
| 813 | 851 | // This is a bit of a cop out - but we're protecting their forum, really! |
| 814 | - if (count($allStaff) > 300) |
|
| 815 | - fatal_lang_error('report_error_too_many_staff'); |
|
| 852 | + if (count($allStaff) > 300) { |
|
| 853 | + fatal_lang_error('report_error_too_many_staff'); |
|
| 854 | + } |
|
| 816 | 855 | |
| 817 | 856 | // Get all the possible membergroups! |
| 818 | 857 | $request = $smcFunc['db_query']('', ' |
@@ -822,8 +861,9 @@ discard block |
||
| 822 | 861 | ) |
| 823 | 862 | ); |
| 824 | 863 | $groups = array(0 => $txt['full_member']); |
| 825 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 826 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 864 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 865 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 866 | + } |
|
| 827 | 867 | $smcFunc['db_free_result']($request); |
| 828 | 868 | |
| 829 | 869 | // All the fields we'll show. |
@@ -864,19 +904,20 @@ discard block |
||
| 864 | 904 | ); |
| 865 | 905 | |
| 866 | 906 | // What do they moderate? |
| 867 | - if (in_array($row['id_member'], $global_mods)) |
|
| 868 | - $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
| 869 | - elseif (isset($moderators[$row['id_member']])) |
|
| 907 | + if (in_array($row['id_member'], $global_mods)) { |
|
| 908 | + $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
| 909 | + } elseif (isset($moderators[$row['id_member']])) |
|
| 870 | 910 | { |
| 871 | 911 | // Get the names |
| 872 | - foreach ($moderators[$row['id_member']] as $board) |
|
| 873 | - if (isset($boards[$board])) |
|
| 912 | + foreach ($moderators[$row['id_member']] as $board) { |
|
| 913 | + if (isset($boards[$board])) |
|
| 874 | 914 | $staffData['moderates'][] = $boards[$board]; |
| 915 | + } |
|
| 875 | 916 | |
| 876 | 917 | $staffData['moderates'] = implode(', ', $staffData['moderates']); |
| 918 | + } else { |
|
| 919 | + $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
| 877 | 920 | } |
| 878 | - else |
|
| 879 | - $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
| 880 | 921 | |
| 881 | 922 | // Next add the main data. |
| 882 | 923 | addData($staffData); |
@@ -904,8 +945,9 @@ discard block |
||
| 904 | 945 | global $context; |
| 905 | 946 | |
| 906 | 947 | // Set the table count if needed. |
| 907 | - if (empty($context['table_count'])) |
|
| 908 | - $context['table_count'] = 0; |
|
| 948 | + if (empty($context['table_count'])) { |
|
| 949 | + $context['table_count'] = 0; |
|
| 950 | + } |
|
| 909 | 951 | |
| 910 | 952 | // Create the table! |
| 911 | 953 | $context['tables'][$context['table_count']] = array( |
@@ -955,16 +997,18 @@ discard block |
||
| 955 | 997 | global $context; |
| 956 | 998 | |
| 957 | 999 | // No tables? Create one even though we are probably already in a bad state! |
| 958 | - if (empty($context['table_count'])) |
|
| 959 | - newTable(); |
|
| 1000 | + if (empty($context['table_count'])) { |
|
| 1001 | + newTable(); |
|
| 1002 | + } |
|
| 960 | 1003 | |
| 961 | 1004 | // Specific table? |
| 962 | - if ($custom_table !== null && !isset($context['tables'][$custom_table])) |
|
| 963 | - return false; |
|
| 964 | - elseif ($custom_table !== null) |
|
| 965 | - $table = $custom_table; |
|
| 966 | - else |
|
| 967 | - $table = $context['current_table']; |
|
| 1005 | + if ($custom_table !== null && !isset($context['tables'][$custom_table])) { |
|
| 1006 | + return false; |
|
| 1007 | + } elseif ($custom_table !== null) { |
|
| 1008 | + $table = $custom_table; |
|
| 1009 | + } else { |
|
| 1010 | + $table = $context['current_table']; |
|
| 1011 | + } |
|
| 968 | 1012 | |
| 969 | 1013 | // If we have keys, sanitise the data... |
| 970 | 1014 | if (!empty($context['keys'])) |
@@ -976,11 +1020,11 @@ discard block |
||
| 976 | 1020 | 'v' => empty($inc_data[$key]) ? $context['tables'][$table]['default_value'] : $inc_data[$key], |
| 977 | 1021 | ); |
| 978 | 1022 | // Special "hack" the adding separators when doing data by column. |
| 979 | - if (substr($key, 0, 5) == '#sep#') |
|
| 980 | - $data[$key]['separator'] = true; |
|
| 1023 | + if (substr($key, 0, 5) == '#sep#') { |
|
| 1024 | + $data[$key]['separator'] = true; |
|
| 1025 | + } |
|
| 981 | 1026 | } |
| 982 | - } |
|
| 983 | - else |
|
| 1027 | + } else |
|
| 984 | 1028 | { |
| 985 | 1029 | $data = $inc_data; |
| 986 | 1030 | foreach ($data as $key => $value) |
@@ -988,8 +1032,9 @@ discard block |
||
| 988 | 1032 | $data[$key] = array( |
| 989 | 1033 | 'v' => $value, |
| 990 | 1034 | ); |
| 991 | - if (substr($key, 0, 5) == '#sep#') |
|
| 992 | - $data[$key]['separator'] = true; |
|
| 1035 | + if (substr($key, 0, 5) == '#sep#') { |
|
| 1036 | + $data[$key]['separator'] = true; |
|
| 1037 | + } |
|
| 993 | 1038 | } |
| 994 | 1039 | } |
| 995 | 1040 | |
@@ -1002,8 +1047,9 @@ discard block |
||
| 1002 | 1047 | // Otherwise, tricky! |
| 1003 | 1048 | else |
| 1004 | 1049 | { |
| 1005 | - foreach ($data as $key => $item) |
|
| 1006 | - $context['tables'][$table]['data'][$key][] = $item; |
|
| 1050 | + foreach ($data as $key => $item) { |
|
| 1051 | + $context['tables'][$table]['data'][$key][] = $item; |
|
| 1052 | + } |
|
| 1007 | 1053 | } |
| 1008 | 1054 | } |
| 1009 | 1055 | |
@@ -1020,16 +1066,18 @@ discard block |
||
| 1020 | 1066 | global $context; |
| 1021 | 1067 | |
| 1022 | 1068 | // No tables - return? |
| 1023 | - if (empty($context['table_count'])) |
|
| 1024 | - return; |
|
| 1069 | + if (empty($context['table_count'])) { |
|
| 1070 | + return; |
|
| 1071 | + } |
|
| 1025 | 1072 | |
| 1026 | 1073 | // Specific table? |
| 1027 | - if ($custom_table !== null && !isset($context['tables'][$table])) |
|
| 1028 | - return false; |
|
| 1029 | - elseif ($custom_table !== null) |
|
| 1030 | - $table = $custom_table; |
|
| 1031 | - else |
|
| 1032 | - $table = $context['current_table']; |
|
| 1074 | + if ($custom_table !== null && !isset($context['tables'][$table])) { |
|
| 1075 | + return false; |
|
| 1076 | + } elseif ($custom_table !== null) { |
|
| 1077 | + $table = $custom_table; |
|
| 1078 | + } else { |
|
| 1079 | + $table = $context['current_table']; |
|
| 1080 | + } |
|
| 1033 | 1081 | |
| 1034 | 1082 | // Plumb in the separator |
| 1035 | 1083 | $context['tables'][$table]['data'][] = array(0 => array( |
@@ -1050,8 +1098,9 @@ discard block |
||
| 1050 | 1098 | { |
| 1051 | 1099 | global $context; |
| 1052 | 1100 | |
| 1053 | - if (empty($context['tables'])) |
|
| 1054 | - return; |
|
| 1101 | + if (empty($context['tables'])) { |
|
| 1102 | + return; |
|
| 1103 | + } |
|
| 1055 | 1104 | |
| 1056 | 1105 | // Loop through each table counting up some basic values, to help with the templating. |
| 1057 | 1106 | foreach ($context['tables'] as $id => $table) |
@@ -1062,12 +1111,13 @@ discard block |
||
| 1062 | 1111 | $context['tables'][$id]['column_count'] = count($curElement); |
| 1063 | 1112 | |
| 1064 | 1113 | // Work out the rough width - for templates like the print template. Without this we might get funny tables. |
| 1065 | - if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') |
|
| 1066 | - $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
| 1067 | - elseif ($table['width']['normal'] != 'auto') |
|
| 1068 | - $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
| 1069 | - else |
|
| 1070 | - $context['tables'][$id]['max_width'] = 'auto'; |
|
| 1114 | + if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') { |
|
| 1115 | + $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
| 1116 | + } elseif ($table['width']['normal'] != 'auto') { |
|
| 1117 | + $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
| 1118 | + } else { |
|
| 1119 | + $context['tables'][$id]['max_width'] = 'auto'; |
|
| 1120 | + } |
|
| 1071 | 1121 | } |
| 1072 | 1122 | } |
| 1073 | 1123 | |
@@ -1092,10 +1142,11 @@ discard block |
||
| 1092 | 1142 | global $context; |
| 1093 | 1143 | |
| 1094 | 1144 | // Do we want to use the keys of the keys as the keys? :P |
| 1095 | - if ($reverse) |
|
| 1096 | - $context['keys'] = array_flip($keys); |
|
| 1097 | - else |
|
| 1098 | - $context['keys'] = $keys; |
|
| 1145 | + if ($reverse) { |
|
| 1146 | + $context['keys'] = array_flip($keys); |
|
| 1147 | + } else { |
|
| 1148 | + $context['keys'] = $keys; |
|
| 1149 | + } |
|
| 1099 | 1150 | |
| 1100 | 1151 | // Rows or columns? |
| 1101 | 1152 | $context['key_method'] = $method == 'rows' ? 'rows' : 'cols'; |
@@ -11,8 +11,9 @@ |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 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 | * Standard non full index, non custom index search |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Add the file functions to the $smcFunc array. |
@@ -52,8 +53,9 @@ discard block |
||
| 52 | 53 | 'messages', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
| 53 | 54 | 'pm_recipients', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
| 54 | 55 | 'themes', 'topics'); |
| 55 | - foreach ($reservedTables as $k => $table_name) |
|
| 56 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
| 56 | + foreach ($reservedTables as $k => $table_name) { |
|
| 57 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
| 58 | + } |
|
| 57 | 59 | |
| 58 | 60 | // We in turn may need the extra stuff. |
| 59 | 61 | db_extend('extra'); |
@@ -102,8 +104,9 @@ discard block |
||
| 102 | 104 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 103 | 105 | |
| 104 | 106 | // First - no way do we touch SMF tables. |
| 105 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
| 106 | - return false; |
|
| 107 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 107 | 110 | |
| 108 | 111 | // Log that we'll want to remove this on uninstall. |
| 109 | 112 | $db_package_log[] = array('remove_table', $table_name); |
@@ -113,10 +116,11 @@ discard block |
||
| 113 | 116 | if (in_array($full_table_name, $tables)) |
| 114 | 117 | { |
| 115 | 118 | // This is a sad day... drop the table? If not, return false (error) by default. |
| 116 | - if ($if_exists == 'overwrite') |
|
| 117 | - $smcFunc['db_drop_table']($table_name); |
|
| 118 | - else |
|
| 119 | - return $if_exists == 'ignore'; |
|
| 119 | + if ($if_exists == 'overwrite') { |
|
| 120 | + $smcFunc['db_drop_table']($table_name); |
|
| 121 | + } else { |
|
| 122 | + return $if_exists == 'ignore'; |
|
| 123 | + } |
|
| 120 | 124 | } |
| 121 | 125 | |
| 122 | 126 | // If we've got this far - good news - no table exists. We can build our own! |
@@ -134,17 +138,18 @@ discard block |
||
| 134 | 138 | ) |
| 135 | 139 | ); |
| 136 | 140 | $default = 'default nextval(\'' . $table_name . '_seq\')'; |
| 141 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
| 142 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
| 143 | + } else { |
|
| 144 | + $default = ''; |
|
| 137 | 145 | } |
| 138 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
| 139 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
| 140 | - else |
|
| 141 | - $default = ''; |
|
| 142 | 146 | |
| 143 | 147 | // Sort out the size... |
| 144 | 148 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
| 145 | 149 | list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']); |
| 146 | - if ($size !== null) |
|
| 147 | - $type = $type . '(' . $size . ')'; |
|
| 150 | + if ($size !== null) { |
|
| 151 | + $type = $type . '(' . $size . ')'; |
|
| 152 | + } |
|
| 148 | 153 | |
| 149 | 154 | // Now just put it together! |
| 150 | 155 | $table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ','; |
@@ -157,19 +162,21 @@ discard block |
||
| 157 | 162 | $columns = implode(',', $index['columns']); |
| 158 | 163 | |
| 159 | 164 | // Primary goes in the table... |
| 160 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
| 161 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
| 162 | - else |
|
| 165 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
| 166 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
| 167 | + } else |
|
| 163 | 168 | { |
| 164 | - if (empty($index['name'])) |
|
| 165 | - $index['name'] = implode('_', $index['columns']); |
|
| 169 | + if (empty($index['name'])) { |
|
| 170 | + $index['name'] = implode('_', $index['columns']); |
|
| 171 | + } |
|
| 166 | 172 | $index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')'; |
| 167 | 173 | } |
| 168 | 174 | } |
| 169 | 175 | |
| 170 | 176 | // No trailing commas! |
| 171 | - if (substr($table_query, -1) == ',') |
|
| 172 | - $table_query = substr($table_query, 0, -1); |
|
| 177 | + if (substr($table_query, -1) == ',') { |
|
| 178 | + $table_query = substr($table_query, 0, -1); |
|
| 179 | + } |
|
| 173 | 180 | |
| 174 | 181 | $table_query .= ')'; |
| 175 | 182 | |
@@ -180,12 +187,13 @@ discard block |
||
| 180 | 187 | ) |
| 181 | 188 | ); |
| 182 | 189 | // And the indexes... |
| 183 | - foreach ($index_queries as $query) |
|
| 184 | - $smcFunc['db_query']('', $query, |
|
| 190 | + foreach ($index_queries as $query) { |
|
| 191 | + $smcFunc['db_query']('', $query, |
|
| 185 | 192 | array( |
| 186 | 193 | 'security_override' => true, |
| 187 | 194 | ) |
| 188 | 195 | ); |
| 196 | + } |
|
| 189 | 197 | |
| 190 | 198 | // Go, go power rangers! |
| 191 | 199 | $smcFunc['db_transaction']('commit'); |
@@ -213,8 +221,9 @@ discard block |
||
| 213 | 221 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 214 | 222 | |
| 215 | 223 | // God no - dropping one of these = bad. |
| 216 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
| 217 | - return false; |
|
| 224 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
| 225 | + return false; |
|
| 226 | + } |
|
| 218 | 227 | |
| 219 | 228 | // Does it exist? |
| 220 | 229 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -272,21 +281,24 @@ discard block |
||
| 272 | 281 | |
| 273 | 282 | // Does it exist - if so don't add it again! |
| 274 | 283 | $columns = $smcFunc['db_list_columns']($table_name, false); |
| 275 | - foreach ($columns as $column) |
|
| 276 | - if ($column == $column_info['name']) |
|
| 284 | + foreach ($columns as $column) { |
|
| 285 | + if ($column == $column_info['name']) |
|
| 277 | 286 | { |
| 278 | 287 | // If we're going to overwrite then use change column. |
| 279 | 288 | if ($if_exists == 'update') |
| 280 | 289 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
| 281 | - else |
|
| 282 | - return false; |
|
| 290 | + } |
|
| 291 | + else { |
|
| 292 | + return false; |
|
| 293 | + } |
|
| 283 | 294 | } |
| 284 | 295 | |
| 285 | 296 | // Get the specifics... |
| 286 | 297 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
| 287 | 298 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
| 288 | - if ($size !== null) |
|
| 289 | - $type = $type . '(' . $size . ')'; |
|
| 299 | + if ($size !== null) { |
|
| 300 | + $type = $type . '(' . $size . ')'; |
|
| 301 | + } |
|
| 290 | 302 | |
| 291 | 303 | // Now add the thing! |
| 292 | 304 | $query = ' |
@@ -301,11 +313,12 @@ discard block |
||
| 301 | 313 | // If there's more attributes they need to be done via a change on PostgreSQL. |
| 302 | 314 | unset($column_info['type'], $column_info['size']); |
| 303 | 315 | |
| 304 | - if (count($column_info) != 1) |
|
| 305 | - return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
| 306 | - else |
|
| 307 | - return true; |
|
| 308 | -} |
|
| 316 | + if (count($column_info) != 1) { |
|
| 317 | + return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
| 318 | + } else { |
|
| 319 | + return true; |
|
| 320 | + } |
|
| 321 | + } |
|
| 309 | 322 | |
| 310 | 323 | /** |
| 311 | 324 | * Removes a column. |
@@ -324,8 +337,8 @@ discard block |
||
| 324 | 337 | |
| 325 | 338 | // Does it exist? |
| 326 | 339 | $columns = $smcFunc['db_list_columns']($table_name, true); |
| 327 | - foreach ($columns as $column) |
|
| 328 | - if ($column['name'] == $column_name) |
|
| 340 | + foreach ($columns as $column) { |
|
| 341 | + if ($column['name'] == $column_name) |
|
| 329 | 342 | { |
| 330 | 343 | // If there is an auto we need remove it! |
| 331 | 344 | if ($column['auto']) |
@@ -335,6 +348,7 @@ discard block |
||
| 335 | 348 | 'security_override' => true, |
| 336 | 349 | ) |
| 337 | 350 | ); |
| 351 | + } |
|
| 338 | 352 | |
| 339 | 353 | $smcFunc['db_query']('', ' |
| 340 | 354 | ALTER TABLE ' . $table_name . ' |
@@ -369,13 +383,15 @@ discard block |
||
| 369 | 383 | // Check it does exist! |
| 370 | 384 | $columns = $smcFunc['db_list_columns']($table_name, true); |
| 371 | 385 | $old_info = null; |
| 372 | - foreach ($columns as $column) |
|
| 373 | - if ($column['name'] == $old_column) |
|
| 386 | + foreach ($columns as $column) { |
|
| 387 | + if ($column['name'] == $old_column) |
|
| 374 | 388 | $old_info = $column; |
| 389 | + } |
|
| 375 | 390 | |
| 376 | 391 | // Nothing? |
| 377 | - if ($old_info == null) |
|
| 378 | - return false; |
|
| 392 | + if ($old_info == null) { |
|
| 393 | + return false; |
|
| 394 | + } |
|
| 379 | 395 | |
| 380 | 396 | // Now we check each bit individually and ALTER as required. |
| 381 | 397 | if (isset($column_info['name']) && $column_info['name'] != $old_column) |
@@ -432,8 +448,9 @@ discard block |
||
| 432 | 448 | { |
| 433 | 449 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
| 434 | 450 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
| 435 | - if ($size !== null) |
|
| 436 | - $type = $type . '(' . $size . ')'; |
|
| 451 | + if ($size !== null) { |
|
| 452 | + $type = $type . '(' . $size . ')'; |
|
| 453 | + } |
|
| 437 | 454 | |
| 438 | 455 | // The alter is a pain. |
| 439 | 456 | $smcFunc['db_transaction']('begin'); |
@@ -527,21 +544,23 @@ discard block |
||
| 527 | 544 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 528 | 545 | |
| 529 | 546 | // No columns = no index. |
| 530 | - if (empty($index_info['columns'])) |
|
| 531 | - return false; |
|
| 547 | + if (empty($index_info['columns'])) { |
|
| 548 | + return false; |
|
| 549 | + } |
|
| 532 | 550 | $columns = implode(',', $index_info['columns']); |
| 533 | 551 | |
| 534 | 552 | // No name - make it up! |
| 535 | 553 | if (empty($index_info['name'])) |
| 536 | 554 | { |
| 537 | 555 | // No need for primary. |
| 538 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
| 539 | - $index_info['name'] = ''; |
|
| 540 | - else |
|
| 541 | - $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
| 556 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
| 557 | + $index_info['name'] = ''; |
|
| 558 | + } else { |
|
| 559 | + $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
| 560 | + } |
|
| 561 | + } else { |
|
| 562 | + $index_info['name'] = $table_name . $index_info['name']; |
|
| 542 | 563 | } |
| 543 | - else |
|
| 544 | - $index_info['name'] = $table_name . $index_info['name']; |
|
| 545 | 564 | |
| 546 | 565 | // Log that we are going to want to remove this! |
| 547 | 566 | $db_package_log[] = array('remove_index', $table_name, $index_info['name']); |
@@ -554,10 +573,11 @@ discard block |
||
| 554 | 573 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
| 555 | 574 | { |
| 556 | 575 | // If we want to overwrite simply remove the current one then continue. |
| 557 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
| 558 | - return false; |
|
| 559 | - else |
|
| 560 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
| 576 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
| 577 | + return false; |
|
| 578 | + } else { |
|
| 579 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
| 580 | + } |
|
| 561 | 581 | } |
| 562 | 582 | } |
| 563 | 583 | |
@@ -571,8 +591,7 @@ discard block |
||
| 571 | 591 | 'security_override' => true, |
| 572 | 592 | ) |
| 573 | 593 | ); |
| 574 | - } |
|
| 575 | - else |
|
| 594 | + } else |
|
| 576 | 595 | { |
| 577 | 596 | $smcFunc['db_query']('', ' |
| 578 | 597 | CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')', |
@@ -600,8 +619,9 @@ discard block |
||
| 600 | 619 | |
| 601 | 620 | // Better exist! |
| 602 | 621 | $indexes = $smcFunc['db_list_indexes']($table_name, true); |
| 603 | - if ($index_name != 'primary') |
|
| 604 | - $index_name = $table_name . '_' . $index_name; |
|
| 622 | + if ($index_name != 'primary') { |
|
| 623 | + $index_name = $table_name . '_' . $index_name; |
|
| 624 | + } |
|
| 605 | 625 | |
| 606 | 626 | foreach ($indexes as $index) |
| 607 | 627 | { |
@@ -665,8 +685,7 @@ discard block |
||
| 665 | 685 | 'datetime' => 'timestamp without time zone', |
| 666 | 686 | 'timestamp' => 'timestamp without time zone', |
| 667 | 687 | ); |
| 668 | - } |
|
| 669 | - else |
|
| 688 | + } else |
|
| 670 | 689 | { |
| 671 | 690 | $types = array( |
| 672 | 691 | 'character varying' => 'varchar', |
@@ -682,14 +701,16 @@ discard block |
||
| 682 | 701 | // Got it? Change it! |
| 683 | 702 | if (isset($types[$type_name])) |
| 684 | 703 | { |
| 685 | - if ($type_name == 'tinytext') |
|
| 686 | - $type_size = 255; |
|
| 704 | + if ($type_name == 'tinytext') { |
|
| 705 | + $type_size = 255; |
|
| 706 | + } |
|
| 687 | 707 | $type_name = $types[$type_name]; |
| 688 | 708 | } |
| 689 | 709 | |
| 690 | 710 | // Only char fields got size |
| 691 | - if (strpos($type_name, 'char') === false) |
|
| 692 | - $type_size = null; |
|
| 711 | + if (strpos($type_name, 'char') === false) { |
|
| 712 | + $type_size = null; |
|
| 713 | + } |
|
| 693 | 714 | |
| 694 | 715 | |
| 695 | 716 | return array($type_name, $type_size); |
@@ -744,8 +765,7 @@ discard block |
||
| 744 | 765 | if (!$detail) |
| 745 | 766 | { |
| 746 | 767 | $columns[] = $row['column_name']; |
| 747 | - } |
|
| 748 | - else |
|
| 768 | + } else |
|
| 749 | 769 | { |
| 750 | 770 | $auto = false; |
| 751 | 771 | // What is the default? |
@@ -753,11 +773,11 @@ discard block |
||
| 753 | 773 | { |
| 754 | 774 | $default = null; |
| 755 | 775 | $auto = true; |
| 776 | + } elseif (trim($row['column_default']) != '') { |
|
| 777 | + $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
| 778 | + } else { |
|
| 779 | + $default = null; |
|
| 756 | 780 | } |
| 757 | - elseif (trim($row['column_default']) != '') |
|
| 758 | - $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
| 759 | - else |
|
| 760 | - $default = null; |
|
| 761 | 781 | |
| 762 | 782 | // Make the type generic. |
| 763 | 783 | list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true); |
@@ -808,26 +828,30 @@ discard block |
||
| 808 | 828 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 809 | 829 | { |
| 810 | 830 | // Try get the columns that make it up. |
| 811 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
| 812 | - continue; |
|
| 831 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
| 832 | + continue; |
|
| 833 | + } |
|
| 813 | 834 | |
| 814 | 835 | $columns = explode(',', $matches[1]); |
| 815 | 836 | |
| 816 | - if (empty($columns)) |
|
| 817 | - continue; |
|
| 837 | + if (empty($columns)) { |
|
| 838 | + continue; |
|
| 839 | + } |
|
| 818 | 840 | |
| 819 | - foreach ($columns as $k => $v) |
|
| 820 | - $columns[$k] = trim($v); |
|
| 841 | + foreach ($columns as $k => $v) { |
|
| 842 | + $columns[$k] = trim($v); |
|
| 843 | + } |
|
| 821 | 844 | |
| 822 | 845 | // Fix up the name to be consistent cross databases |
| 823 | - if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) |
|
| 824 | - $row['name'] = 'PRIMARY'; |
|
| 825 | - else |
|
| 826 | - $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
| 846 | + if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) { |
|
| 847 | + $row['name'] = 'PRIMARY'; |
|
| 848 | + } else { |
|
| 849 | + $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
| 850 | + } |
|
| 827 | 851 | |
| 828 | - if (!$detail) |
|
| 829 | - $indexes[] = $row['name']; |
|
| 830 | - else |
|
| 852 | + if (!$detail) { |
|
| 853 | + $indexes[] = $row['name']; |
|
| 854 | + } else |
|
| 831 | 855 | { |
| 832 | 856 | $indexes[$row['name']] = array( |
| 833 | 857 | 'name' => $row['name'], |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Put this user in the online log. |
@@ -33,8 +34,9 @@ discard block |
||
| 33 | 34 | // Don't update for every page - this isn't wholly accurate but who cares. |
| 34 | 35 | if ($topic) |
| 35 | 36 | { |
| 36 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
| 37 | - $force = false; |
|
| 37 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
| 38 | + $force = false; |
|
| 39 | + } |
|
| 38 | 40 | $_SESSION['last_topic_id'] = $topic; |
| 39 | 41 | } |
| 40 | 42 | } |
@@ -47,22 +49,24 @@ discard block |
||
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | // Don't mark them as online more than every so often. |
| 50 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
| 51 | - return; |
|
| 52 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | if (!empty($modSettings['who_enabled'])) |
| 54 | 57 | { |
| 55 | 58 | $serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
| 56 | 59 | |
| 57 | 60 | // In the case of a dlattach action, session_var may not be set. |
| 58 | - if (!isset($context['session_var'])) |
|
| 59 | - $context['session_var'] = $_SESSION['session_var']; |
|
| 61 | + if (!isset($context['session_var'])) { |
|
| 62 | + $context['session_var'] = $_SESSION['session_var']; |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | unset($serialized['sesc'], $serialized[$context['session_var']]); |
| 62 | 66 | $serialized = json_encode($serialized); |
| 67 | + } else { |
|
| 68 | + $serialized = ''; |
|
| 63 | 69 | } |
| 64 | - else |
|
| 65 | - $serialized = ''; |
|
| 66 | 70 | |
| 67 | 71 | // Guests use 0, members use their session ID. |
| 68 | 72 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -102,17 +106,18 @@ discard block |
||
| 102 | 106 | ); |
| 103 | 107 | |
| 104 | 108 | // Guess it got deleted. |
| 105 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 109 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 110 | + $_SESSION['log_time'] = 0; |
|
| 111 | + } |
|
| 112 | + } else { |
|
| 106 | 113 | $_SESSION['log_time'] = 0; |
| 107 | 114 | } |
| 108 | - else |
|
| 109 | - $_SESSION['log_time'] = 0; |
|
| 110 | 115 | |
| 111 | 116 | // Otherwise, we have to delete and insert. |
| 112 | 117 | if (empty($_SESSION['log_time'])) |
| 113 | 118 | { |
| 114 | - if ($do_delete || !empty($user_info['id'])) |
|
| 115 | - $smcFunc['db_query']('', ' |
|
| 119 | + if ($do_delete || !empty($user_info['id'])) { |
|
| 120 | + $smcFunc['db_query']('', ' |
|
| 116 | 121 | DELETE FROM {db_prefix}log_online |
| 117 | 122 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
| 118 | 123 | array( |
@@ -120,6 +125,7 @@ discard block |
||
| 120 | 125 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
| 121 | 126 | ) |
| 122 | 127 | ); |
| 128 | + } |
|
| 123 | 129 | |
| 124 | 130 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
| 125 | 131 | '{db_prefix}log_online', |
@@ -133,21 +139,24 @@ discard block |
||
| 133 | 139 | $_SESSION['log_time'] = time(); |
| 134 | 140 | |
| 135 | 141 | // Well, they are online now. |
| 136 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
| 137 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 142 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
| 143 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 144 | + } |
|
| 138 | 145 | |
| 139 | 146 | // Set their login time, if not already done within the last minute. |
| 140 | 147 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
| 141 | 148 | { |
| 142 | 149 | // Don't count longer than 15 minutes. |
| 143 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
| 144 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 150 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
| 151 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 152 | + } |
|
| 145 | 153 | |
| 146 | 154 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 147 | 155 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
| 148 | 156 | |
| 149 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 150 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 157 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 158 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 159 | + } |
|
| 151 | 160 | |
| 152 | 161 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 153 | 162 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -184,8 +193,7 @@ discard block |
||
| 184 | 193 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
| 185 | 194 | // Copy the file back and run for your life! |
| 186 | 195 | @copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php'); |
| 187 | - } |
|
| 188 | - else |
|
| 196 | + } else |
|
| 189 | 197 | { |
| 190 | 198 | @touch($boarddir . '/' . 'Settings.php'); |
| 191 | 199 | return true; |
@@ -205,22 +213,27 @@ discard block |
||
| 205 | 213 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
| 206 | 214 | |
| 207 | 215 | // Add to Settings.php if you want to show the debugging information. |
| 208 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
| 209 | - return; |
|
| 216 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
| 217 | + return; |
|
| 218 | + } |
|
| 210 | 219 | |
| 211 | - if (empty($_SESSION['view_queries'])) |
|
| 212 | - $_SESSION['view_queries'] = 0; |
|
| 213 | - if (empty($context['debug']['language_files'])) |
|
| 214 | - $context['debug']['language_files'] = array(); |
|
| 215 | - if (empty($context['debug']['sheets'])) |
|
| 216 | - $context['debug']['sheets'] = array(); |
|
| 220 | + if (empty($_SESSION['view_queries'])) { |
|
| 221 | + $_SESSION['view_queries'] = 0; |
|
| 222 | + } |
|
| 223 | + if (empty($context['debug']['language_files'])) { |
|
| 224 | + $context['debug']['language_files'] = array(); |
|
| 225 | + } |
|
| 226 | + if (empty($context['debug']['sheets'])) { |
|
| 227 | + $context['debug']['sheets'] = array(); |
|
| 228 | + } |
|
| 217 | 229 | |
| 218 | 230 | $files = get_included_files(); |
| 219 | 231 | $total_size = 0; |
| 220 | 232 | for ($i = 0, $n = count($files); $i < $n; $i++) |
| 221 | 233 | { |
| 222 | - if (file_exists($files[$i])) |
|
| 223 | - $total_size += filesize($files[$i]); |
|
| 234 | + if (file_exists($files[$i])) { |
|
| 235 | + $total_size += filesize($files[$i]); |
|
| 236 | + } |
|
| 224 | 237 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
| 225 | 238 | } |
| 226 | 239 | |
@@ -229,8 +242,9 @@ discard block |
||
| 229 | 242 | { |
| 230 | 243 | foreach ($db_cache as $q => $qq) |
| 231 | 244 | { |
| 232 | - if (!empty($qq['w'])) |
|
| 233 | - $warnings += count($qq['w']); |
|
| 245 | + if (!empty($qq['w'])) { |
|
| 246 | + $warnings += count($qq['w']); |
|
| 247 | + } |
|
| 234 | 248 | } |
| 235 | 249 | |
| 236 | 250 | $_SESSION['debug'] = &$db_cache; |
@@ -251,12 +265,14 @@ discard block |
||
| 251 | 265 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
| 252 | 266 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 253 | 267 | |
| 254 | - if (function_exists('memory_get_peak_usage')) |
|
| 255 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 268 | + if (function_exists('memory_get_peak_usage')) { |
|
| 269 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 270 | + } |
|
| 256 | 271 | |
| 257 | 272 | // What tokens are active? |
| 258 | - if (isset($_SESSION['token'])) |
|
| 259 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 273 | + if (isset($_SESSION['token'])) { |
|
| 274 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 275 | + } |
|
| 260 | 276 | |
| 261 | 277 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
| 262 | 278 | { |
@@ -269,10 +285,12 @@ discard block |
||
| 269 | 285 | $total_t += $cache_hit['t']; |
| 270 | 286 | $total_s += $cache_hit['s']; |
| 271 | 287 | } |
| 272 | - if (!isset($cache_misses)) |
|
| 273 | - $cache_misses = array(); |
|
| 274 | - foreach ($cache_misses as $missed) |
|
| 275 | - $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
| 288 | + if (!isset($cache_misses)) { |
|
| 289 | + $cache_misses = array(); |
|
| 290 | + } |
|
| 291 | + foreach ($cache_misses as $missed) { |
|
| 292 | + $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
| 293 | + } |
|
| 276 | 294 | |
| 277 | 295 | echo ' |
| 278 | 296 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -283,38 +301,44 @@ discard block |
||
| 283 | 301 | <a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
| 284 | 302 | <br>'; |
| 285 | 303 | |
| 286 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
| 287 | - foreach ($db_cache as $q => $qq) |
|
| 304 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
| 305 | + foreach ($db_cache as $q => $qq) |
|
| 288 | 306 | { |
| 289 | 307 | $is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0; |
| 308 | + } |
|
| 290 | 309 | // Temporary tables created in earlier queries are not explainable. |
| 291 | 310 | if ($is_select) |
| 292 | 311 | { |
| 293 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
| 294 | - if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 312 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
| 313 | + if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 295 | 314 | { |
| 296 | 315 | $is_select = false; |
| 316 | + } |
|
| 297 | 317 | break; |
| 298 | 318 | } |
| 299 | 319 | } |
| 300 | 320 | // But actual creation of the temporary tables are. |
| 301 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) |
|
| 302 | - $is_select = true; |
|
| 321 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) { |
|
| 322 | + $is_select = true; |
|
| 323 | + } |
|
| 303 | 324 | |
| 304 | 325 | // Make the filenames look a bit better. |
| 305 | - if (isset($qq['f'])) |
|
| 306 | - $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 326 | + if (isset($qq['f'])) { |
|
| 327 | + $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 328 | + } |
|
| 307 | 329 | |
| 308 | 330 | echo ' |
| 309 | 331 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
| 310 | 332 | '; |
| 311 | - if (!empty($qq['f']) && !empty($qq['l'])) |
|
| 312 | - echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 333 | + if (!empty($qq['f']) && !empty($qq['l'])) { |
|
| 334 | + echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 335 | + } |
|
| 313 | 336 | |
| 314 | - if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) |
|
| 315 | - echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 316 | - elseif (isset($qq['t'])) |
|
| 317 | - echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 337 | + if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) { |
|
| 338 | + echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 339 | + } elseif (isset($qq['t'])) { |
|
| 340 | + echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 341 | + } |
|
| 318 | 342 | echo ' |
| 319 | 343 | <br>'; |
| 320 | 344 | } |
@@ -339,12 +363,14 @@ discard block |
||
| 339 | 363 | global $modSettings, $smcFunc; |
| 340 | 364 | static $cache_stats = array(); |
| 341 | 365 | |
| 342 | - if (empty($modSettings['trackStats'])) |
|
| 343 | - return false; |
|
| 344 | - if (!empty($stats)) |
|
| 345 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
| 346 | - elseif (empty($cache_stats)) |
|
| 347 | - return false; |
|
| 366 | + if (empty($modSettings['trackStats'])) { |
|
| 367 | + return false; |
|
| 368 | + } |
|
| 369 | + if (!empty($stats)) { |
|
| 370 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
| 371 | + } elseif (empty($cache_stats)) { |
|
| 372 | + return false; |
|
| 373 | + } |
|
| 348 | 374 | |
| 349 | 375 | $setStringUpdate = ''; |
| 350 | 376 | $insert_keys = array(); |
@@ -357,10 +383,11 @@ discard block |
||
| 357 | 383 | $setStringUpdate .= ' |
| 358 | 384 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
| 359 | 385 | |
| 360 | - if ($change === '+') |
|
| 361 | - $cache_stats[$field] = 1; |
|
| 362 | - else |
|
| 363 | - $update_parameters[$field] = $change; |
|
| 386 | + if ($change === '+') { |
|
| 387 | + $cache_stats[$field] = 1; |
|
| 388 | + } else { |
|
| 389 | + $update_parameters[$field] = $change; |
|
| 390 | + } |
|
| 364 | 391 | $insert_keys[$field] = 'int'; |
| 365 | 392 | } |
| 366 | 393 | |
@@ -424,43 +451,50 @@ discard block |
||
| 424 | 451 | ); |
| 425 | 452 | |
| 426 | 453 | // Make sure this particular log is enabled first... |
| 427 | - if (empty($modSettings['modlog_enabled'])) |
|
| 428 | - unset ($log_types['moderate']); |
|
| 429 | - if (empty($modSettings['userlog_enabled'])) |
|
| 430 | - unset ($log_types['user']); |
|
| 431 | - if (empty($modSettings['adminlog_enabled'])) |
|
| 432 | - unset ($log_types['admin']); |
|
| 454 | + if (empty($modSettings['modlog_enabled'])) { |
|
| 455 | + unset ($log_types['moderate']); |
|
| 456 | + } |
|
| 457 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 458 | + unset ($log_types['user']); |
|
| 459 | + } |
|
| 460 | + if (empty($modSettings['adminlog_enabled'])) { |
|
| 461 | + unset ($log_types['admin']); |
|
| 462 | + } |
|
| 433 | 463 | |
| 434 | 464 | call_integration_hook('integrate_log_types', array(&$log_types)); |
| 435 | 465 | |
| 436 | 466 | foreach ($logs as $log) |
| 437 | 467 | { |
| 438 | - if (!isset($log_types[$log['log_type']])) |
|
| 439 | - return false; |
|
| 468 | + if (!isset($log_types[$log['log_type']])) { |
|
| 469 | + return false; |
|
| 470 | + } |
|
| 440 | 471 | |
| 441 | - if (!is_array($log['extra'])) |
|
| 442 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 472 | + if (!is_array($log['extra'])) { |
|
| 473 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 474 | + } |
|
| 443 | 475 | |
| 444 | 476 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
| 445 | 477 | if (isset($log['extra']['topic'])) |
| 446 | 478 | { |
| 447 | - if (!is_numeric($log['extra']['topic'])) |
|
| 448 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 479 | + if (!is_numeric($log['extra']['topic'])) { |
|
| 480 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 481 | + } |
|
| 449 | 482 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
| 450 | 483 | unset($log['extra']['topic']); |
| 484 | + } else { |
|
| 485 | + $topic_id = 0; |
|
| 451 | 486 | } |
| 452 | - else |
|
| 453 | - $topic_id = 0; |
|
| 454 | 487 | |
| 455 | 488 | if (isset($log['extra']['message'])) |
| 456 | 489 | { |
| 457 | - if (!is_numeric($log['extra']['message'])) |
|
| 458 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 490 | + if (!is_numeric($log['extra']['message'])) { |
|
| 491 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 492 | + } |
|
| 459 | 493 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
| 460 | 494 | unset($log['extra']['message']); |
| 495 | + } else { |
|
| 496 | + $msg_id = 0; |
|
| 461 | 497 | } |
| 462 | - else |
|
| 463 | - $msg_id = 0; |
|
| 464 | 498 | |
| 465 | 499 | // @todo cache this? |
| 466 | 500 | // Is there an associated report on this? |
@@ -487,23 +521,26 @@ discard block |
||
| 487 | 521 | $smcFunc['db_free_result']($request); |
| 488 | 522 | } |
| 489 | 523 | |
| 490 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
| 491 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 524 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
| 525 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 526 | + } |
|
| 492 | 527 | |
| 493 | 528 | if (isset($log['extra']['board'])) |
| 494 | 529 | { |
| 495 | - if (!is_numeric($log['extra']['board'])) |
|
| 496 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 530 | + if (!is_numeric($log['extra']['board'])) { |
|
| 531 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 532 | + } |
|
| 497 | 533 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
| 498 | 534 | unset($log['extra']['board']); |
| 535 | + } else { |
|
| 536 | + $board_id = 0; |
|
| 499 | 537 | } |
| 500 | - else |
|
| 501 | - $board_id = 0; |
|
| 502 | 538 | |
| 503 | 539 | if (isset($log['extra']['board_to'])) |
| 504 | 540 | { |
| 505 | - if (!is_numeric($log['extra']['board_to'])) |
|
| 506 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 541 | + if (!is_numeric($log['extra']['board_to'])) { |
|
| 542 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 543 | + } |
|
| 507 | 544 | if (empty($board_id)) |
| 508 | 545 | { |
| 509 | 546 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -511,10 +548,11 @@ discard block |
||
| 511 | 548 | } |
| 512 | 549 | } |
| 513 | 550 | |
| 514 | - if (isset($log['extra']['member_affected'])) |
|
| 515 | - $memID = $log['extra']['member_affected']; |
|
| 516 | - else |
|
| 517 | - $memID = $user_info['id']; |
|
| 551 | + if (isset($log['extra']['member_affected'])) { |
|
| 552 | + $memID = $log['extra']['member_affected']; |
|
| 553 | + } else { |
|
| 554 | + $memID = $user_info['id']; |
|
| 555 | + } |
|
| 518 | 556 | |
| 519 | 557 | $inserts[] = array( |
| 520 | 558 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Delete one of more membergroups. |
@@ -31,15 +32,16 @@ discard block |
||
| 31 | 32 | global $smcFunc, $modSettings, $txt; |
| 32 | 33 | |
| 33 | 34 | // Make sure it's an array. |
| 34 | - if (!is_array($groups)) |
|
| 35 | - $groups = array((int) $groups); |
|
| 36 | - else |
|
| 35 | + if (!is_array($groups)) { |
|
| 36 | + $groups = array((int) $groups); |
|
| 37 | + } else |
|
| 37 | 38 | { |
| 38 | 39 | $groups = array_unique($groups); |
| 39 | 40 | |
| 40 | 41 | // Make sure all groups are integer. |
| 41 | - foreach ($groups as $key => $value) |
|
| 42 | - $groups[$key] = (int) $value; |
|
| 42 | + foreach ($groups as $key => $value) { |
|
| 43 | + $groups[$key] = (int) $value; |
|
| 44 | + } |
|
| 43 | 45 | } |
| 44 | 46 | |
| 45 | 47 | // Some groups are protected (guests, administrators, moderators, newbies). |
@@ -56,15 +58,17 @@ discard block |
||
| 56 | 58 | 'is_protected' => 1, |
| 57 | 59 | ) |
| 58 | 60 | ); |
| 59 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 60 | - $protected_groups[] = $row['id_group']; |
|
| 61 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 62 | + $protected_groups[] = $row['id_group']; |
|
| 63 | + } |
|
| 61 | 64 | $smcFunc['db_free_result']($request); |
| 62 | 65 | } |
| 63 | 66 | |
| 64 | 67 | // Make sure they don't delete protected groups! |
| 65 | 68 | $groups = array_diff($groups, array_unique($protected_groups)); |
| 66 | - if (empty($groups)) |
|
| 67 | - return 'no_group_found'; |
|
| 69 | + if (empty($groups)) { |
|
| 70 | + return 'no_group_found'; |
|
| 71 | + } |
|
| 68 | 72 | |
| 69 | 73 | // Make sure they don't try to delete a group attached to a paid subscription. |
| 70 | 74 | $subscriptions = array(); |
@@ -74,13 +78,14 @@ discard block |
||
| 74 | 78 | ORDER BY name'); |
| 75 | 79 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 76 | 80 | { |
| 77 | - if (in_array($row['id_group'], $groups)) |
|
| 78 | - $subscriptions[] = $row['name']; |
|
| 79 | - else |
|
| 81 | + if (in_array($row['id_group'], $groups)) { |
|
| 82 | + $subscriptions[] = $row['name']; |
|
| 83 | + } else |
|
| 80 | 84 | { |
| 81 | 85 | $add_groups = explode(',', $row['add_groups']); |
| 82 | - if (count(array_intersect($add_groups, $groups)) != 0) |
|
| 83 | - $subscriptions[] = $row['name']; |
|
| 86 | + if (count(array_intersect($add_groups, $groups)) != 0) { |
|
| 87 | + $subscriptions[] = $row['name']; |
|
| 88 | + } |
|
| 84 | 89 | } |
| 85 | 90 | } |
| 86 | 91 | $smcFunc['db_free_result']($request); |
@@ -101,8 +106,9 @@ discard block |
||
| 101 | 106 | 'group_list' => $groups, |
| 102 | 107 | ) |
| 103 | 108 | ); |
| 104 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 105 | - logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
| 109 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 110 | + logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
| 111 | + } |
|
| 106 | 112 | $smcFunc['db_free_result']($request); |
| 107 | 113 | |
| 108 | 114 | call_integration_hook('integrate_delete_membergroups', array($groups)); |
@@ -187,12 +193,14 @@ discard block |
||
| 187 | 193 | ) |
| 188 | 194 | ); |
| 189 | 195 | $updates = array(); |
| 190 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 191 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 196 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 197 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 198 | + } |
|
| 192 | 199 | $smcFunc['db_free_result']($request); |
| 193 | 200 | |
| 194 | - foreach ($updates as $additional_groups => $memberArray) |
|
| 195 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
| 201 | + foreach ($updates as $additional_groups => $memberArray) { |
|
| 202 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
| 203 | + } |
|
| 196 | 204 | |
| 197 | 205 | // No boards can provide access to these membergroups anymore. |
| 198 | 206 | $request = $smcFunc['db_query']('', ' |
@@ -204,12 +212,13 @@ discard block |
||
| 204 | 212 | ) |
| 205 | 213 | ); |
| 206 | 214 | $updates = array(); |
| 207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 208 | - $updates[$row['member_groups']][] = $row['id_board']; |
|
| 215 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 216 | + $updates[$row['member_groups']][] = $row['id_board']; |
|
| 217 | + } |
|
| 209 | 218 | $smcFunc['db_free_result']($request); |
| 210 | 219 | |
| 211 | - foreach ($updates as $member_groups => $boardArray) |
|
| 212 | - $smcFunc['db_query']('', ' |
|
| 220 | + foreach ($updates as $member_groups => $boardArray) { |
|
| 221 | + $smcFunc['db_query']('', ' |
|
| 213 | 222 | UPDATE {db_prefix}boards |
| 214 | 223 | SET member_groups = {string:member_groups} |
| 215 | 224 | WHERE id_board IN ({array_int:board_lists})', |
@@ -218,6 +227,7 @@ discard block |
||
| 218 | 227 | 'member_groups' => implode(',', array_diff(explode(',', $member_groups), $groups)), |
| 219 | 228 | ) |
| 220 | 229 | ); |
| 230 | + } |
|
| 221 | 231 | |
| 222 | 232 | // Recalculate the post groups, as they likely changed. |
| 223 | 233 | updateStats('postgroups'); |
@@ -225,8 +235,9 @@ discard block |
||
| 225 | 235 | // Make a note of the fact that the cache may be wrong. |
| 226 | 236 | $settings_update = array('settings_updated' => time()); |
| 227 | 237 | // Have we deleted the spider group? |
| 228 | - if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) |
|
| 229 | - $settings_update['spider_group'] = 0; |
|
| 238 | + if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) { |
|
| 239 | + $settings_update['spider_group'] = 0; |
|
| 240 | + } |
|
| 230 | 241 | |
| 231 | 242 | updateSettings($settings_update); |
| 232 | 243 | |
@@ -250,22 +261,24 @@ discard block |
||
| 250 | 261 | global $smcFunc, $modSettings, $sourcedir; |
| 251 | 262 | |
| 252 | 263 | // You're getting nowhere without this permission, unless of course you are the group's moderator. |
| 253 | - if (!$permissionCheckDone) |
|
| 254 | - isAllowedTo('manage_membergroups'); |
|
| 264 | + if (!$permissionCheckDone) { |
|
| 265 | + isAllowedTo('manage_membergroups'); |
|
| 266 | + } |
|
| 255 | 267 | |
| 256 | 268 | // Assume something will happen. |
| 257 | 269 | updateSettings(array('settings_updated' => time())); |
| 258 | 270 | |
| 259 | 271 | // Cleaning the input. |
| 260 | - if (!is_array($members)) |
|
| 261 | - $members = array((int) $members); |
|
| 262 | - else |
|
| 272 | + if (!is_array($members)) { |
|
| 273 | + $members = array((int) $members); |
|
| 274 | + } else |
|
| 263 | 275 | { |
| 264 | 276 | $members = array_unique($members); |
| 265 | 277 | |
| 266 | 278 | // Cast the members to integer. |
| 267 | - foreach ($members as $key => $value) |
|
| 268 | - $members[$key] = (int) $value; |
|
| 279 | + foreach ($members as $key => $value) { |
|
| 280 | + $members[$key] = (int) $value; |
|
| 281 | + } |
|
| 269 | 282 | } |
| 270 | 283 | |
| 271 | 284 | // Before we get started, let's check we won't leave the admin group empty! |
@@ -277,14 +290,15 @@ discard block |
||
| 277 | 290 | // Remove any admins if there are too many. |
| 278 | 291 | $non_changing_admins = array_diff(array_keys($admins), $members); |
| 279 | 292 | |
| 280 | - if (empty($non_changing_admins)) |
|
| 281 | - $members = array_diff($members, array_keys($admins)); |
|
| 293 | + if (empty($non_changing_admins)) { |
|
| 294 | + $members = array_diff($members, array_keys($admins)); |
|
| 295 | + } |
|
| 282 | 296 | } |
| 283 | 297 | |
| 284 | 298 | // Just in case. |
| 285 | - if (empty($members)) |
|
| 286 | - return false; |
|
| 287 | - elseif ($groups === null) |
|
| 299 | + if (empty($members)) { |
|
| 300 | + return false; |
|
| 301 | + } elseif ($groups === null) |
|
| 288 | 302 | { |
| 289 | 303 | // Wanna remove all groups from these members? That's easy. |
| 290 | 304 | $smcFunc['db_query']('', ' |
@@ -306,20 +320,21 @@ discard block |
||
| 306 | 320 | updateStats('postgroups', $members); |
| 307 | 321 | |
| 308 | 322 | // Log what just happened. |
| 309 | - foreach ($members as $member) |
|
| 310 | - logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
| 323 | + foreach ($members as $member) { |
|
| 324 | + logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
| 325 | + } |
|
| 311 | 326 | |
| 312 | 327 | return true; |
| 313 | - } |
|
| 314 | - elseif (!is_array($groups)) |
|
| 315 | - $groups = array((int) $groups); |
|
| 316 | - else |
|
| 328 | + } elseif (!is_array($groups)) { |
|
| 329 | + $groups = array((int) $groups); |
|
| 330 | + } else |
|
| 317 | 331 | { |
| 318 | 332 | $groups = array_unique($groups); |
| 319 | 333 | |
| 320 | 334 | // Make sure all groups are integer. |
| 321 | - foreach ($groups as $key => $value) |
|
| 322 | - $groups[$key] = (int) $value; |
|
| 335 | + foreach ($groups as $key => $value) { |
|
| 336 | + $groups[$key] = (int) $value; |
|
| 337 | + } |
|
| 323 | 338 | } |
| 324 | 339 | |
| 325 | 340 | // Fetch a list of groups members cannot be assigned to explicitly, and the group names of the ones we want. |
@@ -335,10 +350,11 @@ discard block |
||
| 335 | 350 | $group_names = array(); |
| 336 | 351 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 337 | 352 | { |
| 338 | - if ($row['min_posts'] != -1) |
|
| 339 | - $implicitGroups[] = $row['id_group']; |
|
| 340 | - else |
|
| 341 | - $group_names[$row['id_group']] = $row['group_name']; |
|
| 353 | + if ($row['min_posts'] != -1) { |
|
| 354 | + $implicitGroups[] = $row['id_group']; |
|
| 355 | + } else { |
|
| 356 | + $group_names[$row['id_group']] = $row['group_name']; |
|
| 357 | + } |
|
| 342 | 358 | } |
| 343 | 359 | $smcFunc['db_free_result']($request); |
| 344 | 360 | |
@@ -357,8 +373,9 @@ discard block |
||
| 357 | 373 | ) |
| 358 | 374 | ); |
| 359 | 375 | $protected_groups = array(1); |
| 360 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 361 | - $protected_groups[] = $row['id_group']; |
|
| 376 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 377 | + $protected_groups[] = $row['id_group']; |
|
| 378 | + } |
|
| 362 | 379 | $smcFunc['db_free_result']($request); |
| 363 | 380 | |
| 364 | 381 | // If you're not an admin yourself, you can't touch protected groups! |
@@ -366,8 +383,9 @@ discard block |
||
| 366 | 383 | } |
| 367 | 384 | |
| 368 | 385 | // Only continue if there are still groups and members left. |
| 369 | - if (empty($groups) || empty($members)) |
|
| 370 | - return false; |
|
| 386 | + if (empty($groups) || empty($members)) { |
|
| 387 | + return false; |
|
| 388 | + } |
|
| 371 | 389 | |
| 372 | 390 | // First, reset those who have this as their primary group - this is the easy one. |
| 373 | 391 | $log_inserts = array(); |
@@ -381,8 +399,9 @@ discard block |
||
| 381 | 399 | 'member_list' => $members, |
| 382 | 400 | ) |
| 383 | 401 | ); |
| 384 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 385 | - $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
| 402 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 403 | + $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
| 404 | + } |
|
| 386 | 405 | $smcFunc['db_free_result']($request); |
| 387 | 406 | |
| 388 | 407 | $smcFunc['db_query']('', ' |
@@ -414,16 +433,17 @@ discard block |
||
| 414 | 433 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 415 | 434 | { |
| 416 | 435 | // What log entries must we make for this one, eh? |
| 417 | - foreach (explode(',', $row['additional_groups']) as $group) |
|
| 418 | - if (in_array($group, $groups)) |
|
| 436 | + foreach (explode(',', $row['additional_groups']) as $group) { |
|
| 437 | + if (in_array($group, $groups)) |
|
| 419 | 438 | $log_inserts[] = array('group' => $group_names[$group], 'member' => $row['id_member']); |
| 439 | + } |
|
| 420 | 440 | |
| 421 | 441 | $updates[$row['additional_groups']][] = $row['id_member']; |
| 422 | 442 | } |
| 423 | 443 | $smcFunc['db_free_result']($request); |
| 424 | 444 | |
| 425 | - foreach ($updates as $additional_groups => $memberArray) |
|
| 426 | - $smcFunc['db_query']('', ' |
|
| 445 | + foreach ($updates as $additional_groups => $memberArray) { |
|
| 446 | + $smcFunc['db_query']('', ' |
|
| 427 | 447 | UPDATE {db_prefix}members |
| 428 | 448 | SET additional_groups = {string:additional_groups} |
| 429 | 449 | WHERE id_member IN ({array_int:member_list})', |
@@ -432,6 +452,7 @@ discard block |
||
| 432 | 452 | 'additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)), |
| 433 | 453 | ) |
| 434 | 454 | ); |
| 455 | + } |
|
| 435 | 456 | |
| 436 | 457 | // Their post groups may have changed now... |
| 437 | 458 | updateStats('postgroups', $members); |
@@ -440,8 +461,9 @@ discard block |
||
| 440 | 461 | if (!empty($log_inserts) && !empty($modSettings['modlog_enabled'])) |
| 441 | 462 | { |
| 442 | 463 | require_once($sourcedir . '/Logging.php'); |
| 443 | - foreach ($log_inserts as $extra) |
|
| 444 | - logAction('removed_from_group', $extra, 'admin'); |
|
| 464 | + foreach ($log_inserts as $extra) { |
|
| 465 | + logAction('removed_from_group', $extra, 'admin'); |
|
| 466 | + } |
|
| 445 | 467 | } |
| 446 | 468 | |
| 447 | 469 | // Mission successful. |
@@ -477,21 +499,23 @@ discard block |
||
| 477 | 499 | global $smcFunc, $sourcedir; |
| 478 | 500 | |
| 479 | 501 | // Show your licence, but only if it hasn't been done yet. |
| 480 | - if (!$permissionCheckDone) |
|
| 481 | - isAllowedTo('manage_membergroups'); |
|
| 502 | + if (!$permissionCheckDone) { |
|
| 503 | + isAllowedTo('manage_membergroups'); |
|
| 504 | + } |
|
| 482 | 505 | |
| 483 | 506 | // Make sure we don't keep old stuff cached. |
| 484 | 507 | updateSettings(array('settings_updated' => time())); |
| 485 | 508 | |
| 486 | - if (!is_array($members)) |
|
| 487 | - $members = array((int) $members); |
|
| 488 | - else |
|
| 509 | + if (!is_array($members)) { |
|
| 510 | + $members = array((int) $members); |
|
| 511 | + } else |
|
| 489 | 512 | { |
| 490 | 513 | $members = array_unique($members); |
| 491 | 514 | |
| 492 | 515 | // Make sure all members are integer. |
| 493 | - foreach ($members as $key => $value) |
|
| 494 | - $members[$key] = (int) $value; |
|
| 516 | + foreach ($members as $key => $value) { |
|
| 517 | + $members[$key] = (int) $value; |
|
| 518 | + } |
|
| 495 | 519 | } |
| 496 | 520 | $group = (int) $group; |
| 497 | 521 | |
@@ -508,20 +532,23 @@ discard block |
||
| 508 | 532 | $group_names = array(); |
| 509 | 533 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 510 | 534 | { |
| 511 | - if ($row['min_posts'] != -1) |
|
| 512 | - $implicitGroups[] = $row['id_group']; |
|
| 513 | - else |
|
| 514 | - $group_names[$row['id_group']] = $row['group_name']; |
|
| 535 | + if ($row['min_posts'] != -1) { |
|
| 536 | + $implicitGroups[] = $row['id_group']; |
|
| 537 | + } else { |
|
| 538 | + $group_names[$row['id_group']] = $row['group_name']; |
|
| 539 | + } |
|
| 515 | 540 | } |
| 516 | 541 | $smcFunc['db_free_result']($request); |
| 517 | 542 | |
| 518 | 543 | // Sorry, you can't join an implicit group. |
| 519 | - if (in_array($group, $implicitGroups) || empty($members)) |
|
| 520 | - return false; |
|
| 544 | + if (in_array($group, $implicitGroups) || empty($members)) { |
|
| 545 | + return false; |
|
| 546 | + } |
|
| 521 | 547 | |
| 522 | 548 | // Only admins can add admins... |
| 523 | - if (!allowedTo('admin_forum') && $group == 1) |
|
| 524 | - return false; |
|
| 549 | + if (!allowedTo('admin_forum') && $group == 1) { |
|
| 550 | + return false; |
|
| 551 | + } |
|
| 525 | 552 | // ... and assign protected groups! |
| 526 | 553 | elseif (!allowedTo('admin_forum') && !$ignoreProtected) |
| 527 | 554 | { |
@@ -539,13 +566,14 @@ discard block |
||
| 539 | 566 | $smcFunc['db_free_result']($request); |
| 540 | 567 | |
| 541 | 568 | // Is it protected? |
| 542 | - if ($is_protected == 1) |
|
| 543 | - return false; |
|
| 569 | + if ($is_protected == 1) { |
|
| 570 | + return false; |
|
| 571 | + } |
|
| 544 | 572 | } |
| 545 | 573 | |
| 546 | 574 | // Do the actual updates. |
| 547 | - if ($type == 'only_additional') |
|
| 548 | - $smcFunc['db_query']('', ' |
|
| 575 | + if ($type == 'only_additional') { |
|
| 576 | + $smcFunc['db_query']('', ' |
|
| 549 | 577 | UPDATE {db_prefix}members |
| 550 | 578 | SET additional_groups = CASE WHEN additional_groups = {string:blank_string} THEN {string:id_group_string} ELSE CONCAT(additional_groups, {string:id_group_string_extend}) END |
| 551 | 579 | WHERE id_member IN ({array_int:member_list}) |
@@ -559,8 +587,8 @@ discard block |
||
| 559 | 587 | 'blank_string' => '', |
| 560 | 588 | ) |
| 561 | 589 | ); |
| 562 | - elseif ($type == 'only_primary' || $type == 'force_primary') |
|
| 563 | - $smcFunc['db_query']('', ' |
|
| 590 | + } elseif ($type == 'only_primary' || $type == 'force_primary') { |
|
| 591 | + $smcFunc['db_query']('', ' |
|
| 564 | 592 | UPDATE {db_prefix}members |
| 565 | 593 | SET id_group = {int:id_group} |
| 566 | 594 | WHERE id_member IN ({array_int:member_list})' . ($type == 'force_primary' ? '' : ' |
@@ -572,8 +600,8 @@ discard block |
||
| 572 | 600 | 'regular_group' => 0, |
| 573 | 601 | ) |
| 574 | 602 | ); |
| 575 | - elseif ($type == 'auto') |
|
| 576 | - $smcFunc['db_query']('', ' |
|
| 603 | + } elseif ($type == 'auto') { |
|
| 604 | + $smcFunc['db_query']('', ' |
|
| 577 | 605 | UPDATE {db_prefix}members |
| 578 | 606 | SET |
| 579 | 607 | id_group = CASE WHEN id_group = {int:regular_group} THEN {int:id_group} ELSE id_group END, |
@@ -592,9 +620,11 @@ discard block |
||
| 592 | 620 | 'id_group_string_extend' => ',' . $group, |
| 593 | 621 | ) |
| 594 | 622 | ); |
| 623 | + } |
|
| 595 | 624 | // Ack!!? What happened? |
| 596 | - else |
|
| 597 | - trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
| 625 | + else { |
|
| 626 | + trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
| 627 | + } |
|
| 598 | 628 | |
| 599 | 629 | call_integration_hook('integrate_add_members_to_group', array($members, $group, &$group_names)); |
| 600 | 630 | |
@@ -603,8 +633,9 @@ discard block |
||
| 603 | 633 | |
| 604 | 634 | // Log the data. |
| 605 | 635 | require_once($sourcedir . '/Logging.php'); |
| 606 | - foreach ($members as $member) |
|
| 607 | - logAction('added_to_group', array('group' => $group_names[$group], 'member' => $member), 'admin'); |
|
| 636 | + foreach ($members as $member) { |
|
| 637 | + logAction('added_to_group', array('group' => $group_names[$group], 'member' => $member), 'admin'); |
|
| 638 | + } |
|
| 608 | 639 | |
| 609 | 640 | return true; |
| 610 | 641 | } |
@@ -632,8 +663,9 @@ discard block |
||
| 632 | 663 | ) |
| 633 | 664 | ); |
| 634 | 665 | $members = array(); |
| 635 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 636 | - $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 666 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 667 | + $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 668 | + } |
|
| 637 | 669 | $smcFunc['db_free_result']($request); |
| 638 | 670 | |
| 639 | 671 | // If there are more than $limit members, add a 'more' link. |
@@ -641,10 +673,10 @@ discard block |
||
| 641 | 673 | { |
| 642 | 674 | array_pop($members); |
| 643 | 675 | return true; |
| 676 | + } else { |
|
| 677 | + return false; |
|
| 678 | + } |
|
| 644 | 679 | } |
| 645 | - else |
|
| 646 | - return false; |
|
| 647 | -} |
|
| 648 | 680 | |
| 649 | 681 | /** |
| 650 | 682 | * Retrieve a list of (visible) membergroups used by the cache. |
@@ -669,8 +701,9 @@ discard block |
||
| 669 | 701 | ) |
| 670 | 702 | ); |
| 671 | 703 | $groupCache = array(); |
| 672 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 673 | - $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
| 704 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 705 | + $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
| 706 | + } |
|
| 674 | 707 | $smcFunc['db_free_result']($request); |
| 675 | 708 | |
| 676 | 709 | return array( |
@@ -718,8 +751,9 @@ discard block |
||
| 718 | 751 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 719 | 752 | { |
| 720 | 753 | // We only list the groups they can see. |
| 721 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
| 722 | - continue; |
|
| 754 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
| 755 | + continue; |
|
| 756 | + } |
|
| 723 | 757 | |
| 724 | 758 | $row['icons'] = explode('#', $row['icons']); |
| 725 | 759 | |
@@ -754,12 +788,11 @@ discard block |
||
| 754 | 788 | 'group_list' => $group_ids, |
| 755 | 789 | ) |
| 756 | 790 | ); |
| 757 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 758 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
| 791 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 792 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
| 793 | + } |
|
| 759 | 794 | $smcFunc['db_free_result']($query); |
| 760 | - } |
|
| 761 | - |
|
| 762 | - else |
|
| 795 | + } else |
|
| 763 | 796 | { |
| 764 | 797 | $query = $smcFunc['db_query']('', ' |
| 765 | 798 | SELECT id_group, COUNT(*) AS num_members |
@@ -770,8 +803,9 @@ discard block |
||
| 770 | 803 | 'group_list' => $group_ids, |
| 771 | 804 | ) |
| 772 | 805 | ); |
| 773 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 774 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
| 806 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 807 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
| 808 | + } |
|
| 775 | 809 | $smcFunc['db_free_result']($query); |
| 776 | 810 | |
| 777 | 811 | // Only do additional groups if we can moderate... |
@@ -790,8 +824,9 @@ discard block |
||
| 790 | 824 | 'blank_string' => '', |
| 791 | 825 | ) |
| 792 | 826 | ); |
| 793 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 794 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
| 827 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 828 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
| 829 | + } |
|
| 795 | 830 | $smcFunc['db_free_result']($query); |
| 796 | 831 | } |
| 797 | 832 | } |
@@ -805,8 +840,9 @@ discard block |
||
| 805 | 840 | 'group_list' => $group_ids, |
| 806 | 841 | ) |
| 807 | 842 | ); |
| 808 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 809 | - $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 843 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 844 | + $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 845 | + } |
|
| 810 | 846 | $smcFunc['db_free_result']($query); |
| 811 | 847 | } |
| 812 | 848 | |
@@ -815,8 +851,9 @@ discard block |
||
| 815 | 851 | { |
| 816 | 852 | $sort_ascending = strpos($sort, 'DESC') === false; |
| 817 | 853 | |
| 818 | - foreach ($groups as $group) |
|
| 819 | - $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
| 854 | + foreach ($groups as $group) { |
|
| 855 | + $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
| 856 | + } |
|
| 820 | 857 | |
| 821 | 858 | array_multisort($sort_array, $sort_ascending ? SORT_ASC : SORT_DESC, SORT_REGULAR, $groups); |
| 822 | 859 | } |