@@ -59,8 +59,9 @@ discard block |
||
| 59 | 59 | * @version 2.1 Beta 4 |
| 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 | |
@@ -168,8 +170,9 @@ discard block |
||
| 168 | 170 | |
| 169 | 171 | call_integration_hook('integrate_general_settings', array(&$config_vars)); |
| 170 | 172 | |
| 171 | - if ($return_config) |
|
| 172 | - return $config_vars; |
|
| 173 | + if ($return_config) { |
|
| 174 | + return $config_vars; |
|
| 175 | + } |
|
| 173 | 176 | |
| 174 | 177 | // Setup the template stuff. |
| 175 | 178 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save'; |
@@ -186,8 +189,9 @@ discard block |
||
| 186 | 189 | $registerSMStats = registerSMStats(); |
| 187 | 190 | |
| 188 | 191 | // Failed to register, disable it again. |
| 189 | - if (empty($registerSMStats)) |
|
| 190 | - $_POST['enable_sm_stats'] = 0; |
|
| 192 | + if (empty($registerSMStats)) { |
|
| 193 | + $_POST['enable_sm_stats'] = 0; |
|
| 194 | + } |
|
| 191 | 195 | } |
| 192 | 196 | |
| 193 | 197 | saveSettings($config_vars); |
@@ -248,8 +252,9 @@ discard block |
||
| 248 | 252 | $request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array()); |
| 249 | 253 | $fts_language = array(); |
| 250 | 254 | |
| 251 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 252 | - $fts_language[$row['cfgname']] = $row['cfgname']; |
|
| 255 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 256 | + $fts_language[$row['cfgname']] = $row['cfgname']; |
|
| 257 | + } |
|
| 253 | 258 | |
| 254 | 259 | $config_vars = array_merge ($config_vars, array( |
| 255 | 260 | '', |
@@ -261,8 +266,9 @@ discard block |
||
| 261 | 266 | |
| 262 | 267 | call_integration_hook('integrate_database_settings', array(&$config_vars)); |
| 263 | 268 | |
| 264 | - if ($return_config) |
|
| 265 | - return $config_vars; |
|
| 269 | + if ($return_config) { |
|
| 270 | + return $config_vars; |
|
| 271 | + } |
|
| 266 | 272 | |
| 267 | 273 | // Setup the template stuff. |
| 268 | 274 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save'; |
@@ -337,13 +343,15 @@ discard block |
||
| 337 | 343 | hideGlobalCookies(); |
| 338 | 344 | });', true); |
| 339 | 345 | |
| 340 | - if (empty($user_settings['tfa_secret'])) |
|
| 341 | - addInlineJavaScript(''); |
|
| 346 | + if (empty($user_settings['tfa_secret'])) { |
|
| 347 | + addInlineJavaScript(''); |
|
| 348 | + } |
|
| 342 | 349 | |
| 343 | 350 | call_integration_hook('integrate_cookie_settings', array(&$config_vars)); |
| 344 | 351 | |
| 345 | - if ($return_config) |
|
| 346 | - return $config_vars; |
|
| 352 | + if ($return_config) { |
|
| 353 | + return $config_vars; |
|
| 354 | + } |
|
| 347 | 355 | |
| 348 | 356 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save'; |
| 349 | 357 | $context['settings_title'] = $txt['cookies_sessions_settings']; |
@@ -354,11 +362,13 @@ discard block |
||
| 354 | 362 | call_integration_hook('integrate_save_cookie_settings'); |
| 355 | 363 | |
| 356 | 364 | // Local and global do not play nicely together. |
| 357 | - if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) |
|
| 358 | - unset ($_POST['globalCookies']); |
|
| 365 | + if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) { |
|
| 366 | + unset ($_POST['globalCookies']); |
|
| 367 | + } |
|
| 359 | 368 | |
| 360 | - if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) |
|
| 361 | - fatal_lang_error('invalid_cookie_domain', false); |
|
| 369 | + if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) { |
|
| 370 | + fatal_lang_error('invalid_cookie_domain', false); |
|
| 371 | + } |
|
| 362 | 372 | |
| 363 | 373 | saveSettings($config_vars); |
| 364 | 374 | |
@@ -441,8 +451,9 @@ discard block |
||
| 441 | 451 | |
| 442 | 452 | call_integration_hook('integrate_general_security_settings', array(&$config_vars)); |
| 443 | 453 | |
| 444 | - if ($return_config) |
|
| 445 | - return $config_vars; |
|
| 454 | + if ($return_config) { |
|
| 455 | + return $config_vars; |
|
| 456 | + } |
|
| 446 | 457 | |
| 447 | 458 | // Saving? |
| 448 | 459 | if (isset($_GET['save'])) |
@@ -481,8 +492,7 @@ discard block |
||
| 481 | 492 | $txt['cache_settings_message'] = $txt['detected_no_caching']; |
| 482 | 493 | $cache_level = array($txt['cache_off']); |
| 483 | 494 | $detected['none'] = $txt['cache_off']; |
| 484 | - } |
|
| 485 | - else |
|
| 495 | + } else |
|
| 486 | 496 | { |
| 487 | 497 | $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected)); |
| 488 | 498 | $cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']); |
@@ -519,8 +529,9 @@ discard block |
||
| 519 | 529 | } |
| 520 | 530 | } |
| 521 | 531 | } |
| 522 | - if ($return_config) |
|
| 523 | - return $config_vars; |
|
| 532 | + if ($return_config) { |
|
| 533 | + return $config_vars; |
|
| 534 | + } |
|
| 524 | 535 | |
| 525 | 536 | // Saving again? |
| 526 | 537 | if (isset($_GET['save'])) |
@@ -548,8 +559,9 @@ discard block |
||
| 548 | 559 | $context['save_disabled'] = $context['settings_not_writable']; |
| 549 | 560 | |
| 550 | 561 | // Decide what message to show. |
| 551 | - if (!$context['save_disabled']) |
|
| 552 | - $context['settings_message'] = $txt['caching_information']; |
|
| 562 | + if (!$context['save_disabled']) { |
|
| 563 | + $context['settings_message'] = $txt['caching_information']; |
|
| 564 | + } |
|
| 553 | 565 | |
| 554 | 566 | // Prepare the template. |
| 555 | 567 | prepareServerSettingsContext($config_vars); |
@@ -572,24 +584,25 @@ discard block |
||
| 572 | 584 | if (stripos(PHP_OS, 'win') === 0) |
| 573 | 585 | { |
| 574 | 586 | $context['settings_message'] = $txt['loadavg_disabled_windows']; |
| 575 | - if (isset($_GET['save'])) |
|
| 576 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
| 577 | - } |
|
| 578 | - elseif (stripos(PHP_OS, 'darwin') === 0) |
|
| 587 | + if (isset($_GET['save'])) { |
|
| 588 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
| 589 | + } |
|
| 590 | + } elseif (stripos(PHP_OS, 'darwin') === 0) |
|
| 579 | 591 | { |
| 580 | 592 | $context['settings_message'] = $txt['loadavg_disabled_osx']; |
| 581 | - if (isset($_GET['save'])) |
|
| 582 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
| 583 | - } |
|
| 584 | - else |
|
| 593 | + if (isset($_GET['save'])) { |
|
| 594 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
| 595 | + } |
|
| 596 | + } else |
|
| 585 | 597 | { |
| 586 | 598 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 587 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) |
|
| 588 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 589 | - elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) |
|
| 590 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 591 | - else |
|
| 592 | - unset($modSettings['load_average']); |
|
| 599 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) { |
|
| 600 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 601 | + } elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) { |
|
| 602 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 603 | + } else { |
|
| 604 | + unset($modSettings['load_average']); |
|
| 605 | + } |
|
| 593 | 606 | |
| 594 | 607 | if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
| 595 | 608 | { |
@@ -625,8 +638,9 @@ discard block |
||
| 625 | 638 | |
| 626 | 639 | call_integration_hook('integrate_loadavg_settings', array(&$config_vars)); |
| 627 | 640 | |
| 628 | - if ($return_config) |
|
| 629 | - return $config_vars; |
|
| 641 | + if ($return_config) { |
|
| 642 | + return $config_vars; |
|
| 643 | + } |
|
| 630 | 644 | |
| 631 | 645 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save'; |
| 632 | 646 | $context['settings_title'] = $txt['load_balancing_settings']; |
@@ -637,24 +651,27 @@ discard block |
||
| 637 | 651 | // Stupidity is not allowed. |
| 638 | 652 | foreach ($_POST as $key => $value) |
| 639 | 653 | { |
| 640 | - if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) |
|
| 641 | - continue; |
|
| 642 | - else |
|
| 643 | - $_POST[$key] = (float) $value; |
|
| 644 | - |
|
| 645 | - if ($key == 'loadavg_auto_opt' && $value <= 1) |
|
| 646 | - $_POST['loadavg_auto_opt'] = 1.0; |
|
| 647 | - elseif ($key == 'loadavg_forum' && $value < 10) |
|
| 648 | - $_POST['loadavg_forum'] = 10.0; |
|
| 649 | - elseif ($value < 2) |
|
| 650 | - $_POST[$key] = 2.0; |
|
| 654 | + if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) { |
|
| 655 | + continue; |
|
| 656 | + } else { |
|
| 657 | + $_POST[$key] = (float) $value; |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + if ($key == 'loadavg_auto_opt' && $value <= 1) { |
|
| 661 | + $_POST['loadavg_auto_opt'] = 1.0; |
|
| 662 | + } elseif ($key == 'loadavg_forum' && $value < 10) { |
|
| 663 | + $_POST['loadavg_forum'] = 10.0; |
|
| 664 | + } elseif ($value < 2) { |
|
| 665 | + $_POST[$key] = 2.0; |
|
| 666 | + } |
|
| 651 | 667 | } |
| 652 | 668 | |
| 653 | 669 | call_integration_hook('integrate_save_loadavg_settings'); |
| 654 | 670 | |
| 655 | 671 | saveDBSettings($config_vars); |
| 656 | - if (!isset($_SESSION['adm-save'])) |
|
| 657 | - $_SESSION['adm-save'] = true; |
|
| 672 | + if (!isset($_SESSION['adm-save'])) { |
|
| 673 | + $_SESSION['adm-save'] = true; |
|
| 674 | + } |
|
| 658 | 675 | redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']); |
| 659 | 676 | } |
| 660 | 677 | |
@@ -690,10 +707,11 @@ discard block |
||
| 690 | 707 | |
| 691 | 708 | if (isset($_SESSION['adm-save'])) |
| 692 | 709 | { |
| 693 | - if ($_SESSION['adm-save'] === true) |
|
| 694 | - $context['saved_successful'] = true; |
|
| 695 | - else |
|
| 696 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 710 | + if ($_SESSION['adm-save'] === true) { |
|
| 711 | + $context['saved_successful'] = true; |
|
| 712 | + } else { |
|
| 713 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 714 | + } |
|
| 697 | 715 | |
| 698 | 716 | unset($_SESSION['adm-save']); |
| 699 | 717 | } |
@@ -701,9 +719,9 @@ discard block |
||
| 701 | 719 | $context['config_vars'] = array(); |
| 702 | 720 | foreach ($config_vars as $identifier => $config_var) |
| 703 | 721 | { |
| 704 | - if (!is_array($config_var) || !isset($config_var[1])) |
|
| 705 | - $context['config_vars'][] = $config_var; |
|
| 706 | - else |
|
| 722 | + if (!is_array($config_var) || !isset($config_var[1])) { |
|
| 723 | + $context['config_vars'][] = $config_var; |
|
| 724 | + } else |
|
| 707 | 725 | { |
| 708 | 726 | $varname = $config_var[0]; |
| 709 | 727 | global $$varname; |
@@ -738,16 +756,19 @@ discard block |
||
| 738 | 756 | if ($config_var[3] == 'int' || $config_var[3] == 'float') |
| 739 | 757 | { |
| 740 | 758 | // Default to a min of 0 if one isn't set |
| 741 | - if (isset($config_var['min'])) |
|
| 742 | - $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
| 743 | - else |
|
| 744 | - $context['config_vars'][$config_var[0]]['min'] = 0; |
|
| 759 | + if (isset($config_var['min'])) { |
|
| 760 | + $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
| 761 | + } else { |
|
| 762 | + $context['config_vars'][$config_var[0]]['min'] = 0; |
|
| 763 | + } |
|
| 745 | 764 | |
| 746 | - if (isset($config_var['max'])) |
|
| 747 | - $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
| 765 | + if (isset($config_var['max'])) { |
|
| 766 | + $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
| 767 | + } |
|
| 748 | 768 | |
| 749 | - if (isset($config_var['step'])) |
|
| 750 | - $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
| 769 | + if (isset($config_var['step'])) { |
|
| 770 | + $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
| 771 | + } |
|
| 751 | 772 | } |
| 752 | 773 | |
| 753 | 774 | // If this is a select box handle any data. |
@@ -755,12 +776,13 @@ discard block |
||
| 755 | 776 | { |
| 756 | 777 | // If it's associative |
| 757 | 778 | $config_values = array_values($config_var[4]); |
| 758 | - if (isset($config_values[0]) && is_array($config_values[0])) |
|
| 759 | - $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
| 760 | - else |
|
| 779 | + if (isset($config_values[0]) && is_array($config_values[0])) { |
|
| 780 | + $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
| 781 | + } else |
|
| 761 | 782 | { |
| 762 | - foreach ($config_var[4] as $key => $item) |
|
| 763 | - $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
| 783 | + foreach ($config_var[4] as $key => $item) { |
|
| 784 | + $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
| 785 | + } |
|
| 764 | 786 | } |
| 765 | 787 | } |
| 766 | 788 | } |
@@ -785,10 +807,11 @@ discard block |
||
| 785 | 807 | |
| 786 | 808 | if (isset($_SESSION['adm-save'])) |
| 787 | 809 | { |
| 788 | - if ($_SESSION['adm-save'] === true) |
|
| 789 | - $context['saved_successful'] = true; |
|
| 790 | - else |
|
| 791 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 810 | + if ($_SESSION['adm-save'] === true) { |
|
| 811 | + $context['saved_successful'] = true; |
|
| 812 | + } else { |
|
| 813 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 814 | + } |
|
| 792 | 815 | |
| 793 | 816 | unset($_SESSION['adm-save']); |
| 794 | 817 | } |
@@ -800,26 +823,30 @@ discard block |
||
| 800 | 823 | foreach ($config_vars as $config_var) |
| 801 | 824 | { |
| 802 | 825 | // HR? |
| 803 | - if (!is_array($config_var)) |
|
| 804 | - $context['config_vars'][] = $config_var; |
|
| 805 | - else |
|
| 826 | + if (!is_array($config_var)) { |
|
| 827 | + $context['config_vars'][] = $config_var; |
|
| 828 | + } else |
|
| 806 | 829 | { |
| 807 | 830 | // If it has no name it doesn't have any purpose! |
| 808 | - if (empty($config_var[1])) |
|
| 809 | - continue; |
|
| 831 | + if (empty($config_var[1])) { |
|
| 832 | + continue; |
|
| 833 | + } |
|
| 810 | 834 | |
| 811 | 835 | // Special case for inline permissions |
| 812 | - if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) |
|
| 813 | - $inlinePermissions[] = $config_var[1]; |
|
| 814 | - elseif ($config_var[0] == 'permissions') |
|
| 815 | - continue; |
|
| 836 | + if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) { |
|
| 837 | + $inlinePermissions[] = $config_var[1]; |
|
| 838 | + } elseif ($config_var[0] == 'permissions') { |
|
| 839 | + continue; |
|
| 840 | + } |
|
| 816 | 841 | |
| 817 | - if ($config_var[0] == 'boards') |
|
| 818 | - $board_list = true; |
|
| 842 | + if ($config_var[0] == 'boards') { |
|
| 843 | + $board_list = true; |
|
| 844 | + } |
|
| 819 | 845 | |
| 820 | 846 | // Are we showing the BBC selection box? |
| 821 | - if ($config_var[0] == 'bbc') |
|
| 822 | - $bbcChoice[] = $config_var[1]; |
|
| 847 | + if ($config_var[0] == 'bbc') { |
|
| 848 | + $bbcChoice[] = $config_var[1]; |
|
| 849 | + } |
|
| 823 | 850 | |
| 824 | 851 | // We need to do some parsing of the value before we pass it in. |
| 825 | 852 | if (isset($modSettings[$config_var[1]])) |
@@ -838,8 +865,7 @@ discard block |
||
| 838 | 865 | default: |
| 839 | 866 | $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]); |
| 840 | 867 | } |
| 841 | - } |
|
| 842 | - else |
|
| 868 | + } else |
|
| 843 | 869 | { |
| 844 | 870 | // Darn, it's empty. What type is expected? |
| 845 | 871 | switch ($config_var[0]) |
@@ -879,16 +905,19 @@ discard block |
||
| 879 | 905 | if ($config_var[0] == 'int' || $config_var[0] == 'float') |
| 880 | 906 | { |
| 881 | 907 | // Default to a min of 0 if one isn't set |
| 882 | - if (isset($config_var['min'])) |
|
| 883 | - $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
| 884 | - else |
|
| 885 | - $context['config_vars'][$config_var[1]]['min'] = 0; |
|
| 908 | + if (isset($config_var['min'])) { |
|
| 909 | + $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
| 910 | + } else { |
|
| 911 | + $context['config_vars'][$config_var[1]]['min'] = 0; |
|
| 912 | + } |
|
| 886 | 913 | |
| 887 | - if (isset($config_var['max'])) |
|
| 888 | - $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
| 914 | + if (isset($config_var['max'])) { |
|
| 915 | + $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
| 916 | + } |
|
| 889 | 917 | |
| 890 | - if (isset($config_var['step'])) |
|
| 891 | - $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
| 918 | + if (isset($config_var['step'])) { |
|
| 919 | + $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
| 920 | + } |
|
| 892 | 921 | } |
| 893 | 922 | |
| 894 | 923 | // If this is a select box handle any data. |
@@ -902,12 +931,13 @@ discard block |
||
| 902 | 931 | } |
| 903 | 932 | |
| 904 | 933 | // If it's associative |
| 905 | - if (isset($config_var[2][0]) && is_array($config_var[2][0])) |
|
| 906 | - $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
| 907 | - else |
|
| 934 | + if (isset($config_var[2][0]) && is_array($config_var[2][0])) { |
|
| 935 | + $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
| 936 | + } else |
|
| 908 | 937 | { |
| 909 | - foreach ($config_var[2] as $key => $item) |
|
| 910 | - $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
| 938 | + foreach ($config_var[2] as $key => $item) { |
|
| 939 | + $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
| 940 | + } |
|
| 911 | 941 | } |
| 912 | 942 | } |
| 913 | 943 | |
@@ -916,17 +946,19 @@ discard block |
||
| 916 | 946 | { |
| 917 | 947 | if (!is_numeric($k)) |
| 918 | 948 | { |
| 919 | - if (substr($k, 0, 2) == 'on') |
|
| 920 | - $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
| 921 | - else |
|
| 922 | - $context['config_vars'][$config_var[1]][$k] = $v; |
|
| 949 | + if (substr($k, 0, 2) == 'on') { |
|
| 950 | + $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
| 951 | + } else { |
|
| 952 | + $context['config_vars'][$config_var[1]][$k] = $v; |
|
| 953 | + } |
|
| 923 | 954 | } |
| 924 | 955 | |
| 925 | 956 | // See if there are any other labels that might fit? |
| 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]]; |
|
| 957 | + if (isset($txt['setting_' . $config_var[1]])) { |
|
| 958 | + $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
| 959 | + } elseif (isset($txt['groups_' . $config_var[1]])) { |
|
| 960 | + $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
| 961 | + } |
|
| 930 | 962 | } |
| 931 | 963 | |
| 932 | 964 | // Set the subtext in case it's part of the label. |
@@ -959,8 +991,9 @@ discard block |
||
| 959 | 991 | // What are the options, eh? |
| 960 | 992 | $temp = parse_bbc(false); |
| 961 | 993 | $bbcTags = array(); |
| 962 | - foreach ($temp as $tag) |
|
| 963 | - $bbcTags[] = $tag['tag']; |
|
| 994 | + foreach ($temp as $tag) { |
|
| 995 | + $bbcTags[] = $tag['tag']; |
|
| 996 | + } |
|
| 964 | 997 | |
| 965 | 998 | $bbcTags = array_unique($bbcTags); |
| 966 | 999 | $totalTags = count($bbcTags); |
@@ -975,8 +1008,9 @@ discard block |
||
| 975 | 1008 | $col = 0; $i = 0; |
| 976 | 1009 | foreach ($bbcTags as $tag) |
| 977 | 1010 | { |
| 978 | - if ($i % $tagsPerColumn == 0 && $i != 0) |
|
| 979 | - $col++; |
|
| 1011 | + if ($i % $tagsPerColumn == 0 && $i != 0) { |
|
| 1012 | + $col++; |
|
| 1013 | + } |
|
| 980 | 1014 | |
| 981 | 1015 | $context['bbc_columns'][$col][] = array( |
| 982 | 1016 | 'tag' => $tag, |
@@ -1019,18 +1053,21 @@ discard block |
||
| 1019 | 1053 | validateToken('admin-ssc'); |
| 1020 | 1054 | |
| 1021 | 1055 | // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!) |
| 1022 | - if (isset($_POST['cookiename'])) |
|
| 1023 | - $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
| 1056 | + if (isset($_POST['cookiename'])) { |
|
| 1057 | + $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
| 1058 | + } |
|
| 1024 | 1059 | |
| 1025 | 1060 | // Fix the forum's URL if necessary. |
| 1026 | 1061 | if (isset($_POST['boardurl'])) |
| 1027 | 1062 | { |
| 1028 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 1029 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1030 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 1031 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1032 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 1033 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1063 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1064 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1065 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1066 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1067 | + } |
|
| 1068 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1069 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1070 | + } |
|
| 1034 | 1071 | } |
| 1035 | 1072 | |
| 1036 | 1073 | // Any passwords? |
@@ -1065,21 +1102,21 @@ discard block |
||
| 1065 | 1102 | // Figure out which config vars we're saving here... |
| 1066 | 1103 | foreach ($config_vars as $var) |
| 1067 | 1104 | { |
| 1068 | - if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) |
|
| 1069 | - continue; |
|
| 1105 | + if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) { |
|
| 1106 | + continue; |
|
| 1107 | + } |
|
| 1070 | 1108 | |
| 1071 | 1109 | $config_var = $var[0]; |
| 1072 | 1110 | |
| 1073 | 1111 | if (in_array($config_var, $config_passwords)) |
| 1074 | 1112 | { |
| 1075 | - if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) |
|
| 1076 | - $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
| 1077 | - } |
|
| 1078 | - elseif (in_array($config_var, $config_strs)) |
|
| 1113 | + if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) { |
|
| 1114 | + $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
| 1115 | + } |
|
| 1116 | + } elseif (in_array($config_var, $config_strs)) |
|
| 1079 | 1117 | { |
| 1080 | 1118 | $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\''; |
| 1081 | - } |
|
| 1082 | - elseif (in_array($config_var, $config_ints)) |
|
| 1119 | + } elseif (in_array($config_var, $config_ints)) |
|
| 1083 | 1120 | { |
| 1084 | 1121 | $new_settings[$config_var] = (int) $_POST[$config_var]; |
| 1085 | 1122 | |
@@ -1088,17 +1125,17 @@ discard block |
||
| 1088 | 1125 | $new_settings[$config_var] = max($min, $new_settings[$config_var]); |
| 1089 | 1126 | |
| 1090 | 1127 | // Is there a max value for this as well? |
| 1091 | - if (isset($var['max'])) |
|
| 1092 | - $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
| 1093 | - } |
|
| 1094 | - elseif (in_array($config_var, $config_bools)) |
|
| 1128 | + if (isset($var['max'])) { |
|
| 1129 | + $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
| 1130 | + } |
|
| 1131 | + } elseif (in_array($config_var, $config_bools)) |
|
| 1095 | 1132 | { |
| 1096 | - if (!empty($_POST[$config_var])) |
|
| 1097 | - $new_settings[$config_var] = '1'; |
|
| 1098 | - else |
|
| 1099 | - $new_settings[$config_var] = '0'; |
|
| 1100 | - } |
|
| 1101 | - else |
|
| 1133 | + if (!empty($_POST[$config_var])) { |
|
| 1134 | + $new_settings[$config_var] = '1'; |
|
| 1135 | + } else { |
|
| 1136 | + $new_settings[$config_var] = '0'; |
|
| 1137 | + } |
|
| 1138 | + } else |
|
| 1102 | 1139 | { |
| 1103 | 1140 | // This shouldn't happen, but it might... |
| 1104 | 1141 | fatal_error('Unknown config_var \'' . $config_var . '\''); |
@@ -1114,30 +1151,35 @@ discard block |
||
| 1114 | 1151 | foreach ($config_vars as $config_var) |
| 1115 | 1152 | { |
| 1116 | 1153 | // We just saved the file-based settings, so skip their definitions. |
| 1117 | - if (!is_array($config_var) || $config_var[2] == 'file') |
|
| 1118 | - continue; |
|
| 1154 | + if (!is_array($config_var) || $config_var[2] == 'file') { |
|
| 1155 | + continue; |
|
| 1156 | + } |
|
| 1119 | 1157 | |
| 1120 | 1158 | $new_setting = array($config_var[3], $config_var[0]); |
| 1121 | 1159 | |
| 1122 | 1160 | // Select options need carried over, too. |
| 1123 | - if (isset($config_var[4])) |
|
| 1124 | - $new_setting[] = $config_var[4]; |
|
| 1161 | + if (isset($config_var[4])) { |
|
| 1162 | + $new_setting[] = $config_var[4]; |
|
| 1163 | + } |
|
| 1125 | 1164 | |
| 1126 | 1165 | // Include min and max if necessary |
| 1127 | - if (isset($config_var['min'])) |
|
| 1128 | - $new_setting['min'] = $config_var['min']; |
|
| 1166 | + if (isset($config_var['min'])) { |
|
| 1167 | + $new_setting['min'] = $config_var['min']; |
|
| 1168 | + } |
|
| 1129 | 1169 | |
| 1130 | - if (isset($config_var['max'])) |
|
| 1131 | - $new_setting['max'] = $config_var['max']; |
|
| 1170 | + if (isset($config_var['max'])) { |
|
| 1171 | + $new_setting['max'] = $config_var['max']; |
|
| 1172 | + } |
|
| 1132 | 1173 | |
| 1133 | 1174 | // Rewrite the definition a bit. |
| 1134 | 1175 | $new_settings[] = $new_setting; |
| 1135 | 1176 | } |
| 1136 | 1177 | |
| 1137 | 1178 | // Save the new database-based settings, if any. |
| 1138 | - if (!empty($new_settings)) |
|
| 1139 | - saveDBSettings($new_settings); |
|
| 1140 | -} |
|
| 1179 | + if (!empty($new_settings)) { |
|
| 1180 | + saveDBSettings($new_settings); |
|
| 1181 | + } |
|
| 1182 | + } |
|
| 1141 | 1183 | |
| 1142 | 1184 | /** |
| 1143 | 1185 | * Helper function for saving database settings. |
@@ -1155,22 +1197,25 @@ discard block |
||
| 1155 | 1197 | $inlinePermissions = array(); |
| 1156 | 1198 | foreach ($config_vars as $var) |
| 1157 | 1199 | { |
| 1158 | - 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'])))) |
|
| 1159 | - continue; |
|
| 1200 | + 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'])))) { |
|
| 1201 | + continue; |
|
| 1202 | + } |
|
| 1160 | 1203 | |
| 1161 | 1204 | // Checkboxes! |
| 1162 | - elseif ($var[0] == 'check') |
|
| 1163 | - $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
| 1205 | + elseif ($var[0] == 'check') { |
|
| 1206 | + $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
| 1207 | + } |
|
| 1164 | 1208 | // Select boxes! |
| 1165 | - elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) |
|
| 1166 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1167 | - elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
| 1209 | + elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) { |
|
| 1210 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1211 | + } elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
| 1168 | 1212 | { |
| 1169 | 1213 | // For security purposes we validate this line by line. |
| 1170 | 1214 | $lOptions = array(); |
| 1171 | - foreach ($_POST[$var[1]] as $invar) |
|
| 1172 | - if (in_array($invar, array_keys($var[2]))) |
|
| 1215 | + foreach ($_POST[$var[1]] as $invar) { |
|
| 1216 | + if (in_array($invar, array_keys($var[2]))) |
|
| 1173 | 1217 | $lOptions[] = $invar; |
| 1218 | + } |
|
| 1174 | 1219 | |
| 1175 | 1220 | $setArray[$var[1]] = $smcFunc['json_encode']($lOptions); |
| 1176 | 1221 | } |
@@ -1184,18 +1229,20 @@ discard block |
||
| 1184 | 1229 | $request = $smcFunc['db_query']('', ' |
| 1185 | 1230 | SELECT id_board |
| 1186 | 1231 | FROM {db_prefix}boards'); |
| 1187 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1188 | - $board_list[$row[0]] = true; |
|
| 1232 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1233 | + $board_list[$row[0]] = true; |
|
| 1234 | + } |
|
| 1189 | 1235 | |
| 1190 | 1236 | $smcFunc['db_free_result']($request); |
| 1191 | 1237 | } |
| 1192 | 1238 | |
| 1193 | 1239 | $lOptions = array(); |
| 1194 | 1240 | |
| 1195 | - if (!empty($_POST[$var[1]])) |
|
| 1196 | - foreach ($_POST[$var[1]] as $invar => $dummy) |
|
| 1241 | + if (!empty($_POST[$var[1]])) { |
|
| 1242 | + foreach ($_POST[$var[1]] as $invar => $dummy) |
|
| 1197 | 1243 | if (isset($board_list[$invar])) |
| 1198 | 1244 | $lOptions[] = $invar; |
| 1245 | + } |
|
| 1199 | 1246 | |
| 1200 | 1247 | $setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : ''; |
| 1201 | 1248 | } |
@@ -1209,8 +1256,9 @@ discard block |
||
| 1209 | 1256 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
| 1210 | 1257 | |
| 1211 | 1258 | // Do we have a max value for this as well? |
| 1212 | - if (isset($var['max'])) |
|
| 1213 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1259 | + if (isset($var['max'])) { |
|
| 1260 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1261 | + } |
|
| 1214 | 1262 | } |
| 1215 | 1263 | // Floating point! |
| 1216 | 1264 | elseif ($var[0] == 'float') |
@@ -1222,40 +1270,47 @@ discard block |
||
| 1222 | 1270 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
| 1223 | 1271 | |
| 1224 | 1272 | // Do we have a max value for this as well? |
| 1225 | - if (isset($var['max'])) |
|
| 1226 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1273 | + if (isset($var['max'])) { |
|
| 1274 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1275 | + } |
|
| 1227 | 1276 | } |
| 1228 | 1277 | // Text! |
| 1229 | - elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) |
|
| 1230 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1278 | + elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) { |
|
| 1279 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1280 | + } |
|
| 1231 | 1281 | // Passwords! |
| 1232 | 1282 | elseif ($var[0] == 'password') |
| 1233 | 1283 | { |
| 1234 | - if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) |
|
| 1235 | - $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
| 1284 | + if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) { |
|
| 1285 | + $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
| 1286 | + } |
|
| 1236 | 1287 | } |
| 1237 | 1288 | // BBC. |
| 1238 | 1289 | elseif ($var[0] == 'bbc') |
| 1239 | 1290 | { |
| 1240 | 1291 | |
| 1241 | 1292 | $bbcTags = array(); |
| 1242 | - foreach (parse_bbc(false) as $tag) |
|
| 1243 | - $bbcTags[] = $tag['tag']; |
|
| 1293 | + foreach (parse_bbc(false) as $tag) { |
|
| 1294 | + $bbcTags[] = $tag['tag']; |
|
| 1295 | + } |
|
| 1244 | 1296 | |
| 1245 | - if (!isset($_POST[$var[1] . '_enabledTags'])) |
|
| 1246 | - $_POST[$var[1] . '_enabledTags'] = array(); |
|
| 1247 | - elseif (!is_array($_POST[$var[1] . '_enabledTags'])) |
|
| 1248 | - $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
| 1297 | + if (!isset($_POST[$var[1] . '_enabledTags'])) { |
|
| 1298 | + $_POST[$var[1] . '_enabledTags'] = array(); |
|
| 1299 | + } elseif (!is_array($_POST[$var[1] . '_enabledTags'])) { |
|
| 1300 | + $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
| 1301 | + } |
|
| 1249 | 1302 | |
| 1250 | 1303 | $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags'])); |
| 1251 | 1304 | } |
| 1252 | 1305 | // Permissions? |
| 1253 | - elseif ($var[0] == 'permissions') |
|
| 1254 | - $inlinePermissions[] = $var[1]; |
|
| 1306 | + elseif ($var[0] == 'permissions') { |
|
| 1307 | + $inlinePermissions[] = $var[1]; |
|
| 1308 | + } |
|
| 1255 | 1309 | } |
| 1256 | 1310 | |
| 1257 | - if (!empty($setArray)) |
|
| 1258 | - updateSettings($setArray); |
|
| 1311 | + if (!empty($setArray)) { |
|
| 1312 | + updateSettings($setArray); |
|
| 1313 | + } |
|
| 1259 | 1314 | |
| 1260 | 1315 | // If we have inline permissions we need to save them. |
| 1261 | 1316 | if (!empty($inlinePermissions) && allowedTo('manage_permissions')) |
@@ -1292,18 +1347,21 @@ discard block |
||
| 1292 | 1347 | // put all of it into an array |
| 1293 | 1348 | foreach ($info_lines as $line) |
| 1294 | 1349 | { |
| 1295 | - if (preg_match('~(' . $remove . ')~', $line)) |
|
| 1296 | - continue; |
|
| 1350 | + if (preg_match('~(' . $remove . ')~', $line)) { |
|
| 1351 | + continue; |
|
| 1352 | + } |
|
| 1297 | 1353 | |
| 1298 | 1354 | // new category? |
| 1299 | - if (strpos($line, '<h2>') !== false) |
|
| 1300 | - $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
| 1355 | + if (strpos($line, '<h2>') !== false) { |
|
| 1356 | + $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
| 1357 | + } |
|
| 1301 | 1358 | |
| 1302 | 1359 | // load it as setting => value or the old setting local master |
| 1303 | - if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
| 1304 | - $pinfo[$category][$val[1]] = $val[2]; |
|
| 1305 | - elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
| 1306 | - $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
| 1360 | + if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
| 1361 | + $pinfo[$category][$val[1]] = $val[2]; |
|
| 1362 | + } elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
| 1363 | + $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
| 1364 | + } |
|
| 1307 | 1365 | } |
| 1308 | 1366 | |
| 1309 | 1367 | // load it in to context and display it |
@@ -1338,8 +1396,9 @@ discard block |
||
| 1338 | 1396 | $testAPI = new $cache_class_name(); |
| 1339 | 1397 | |
| 1340 | 1398 | // No Support? NEXT! |
| 1341 | - if (!$testAPI->isSupported(true)) |
|
| 1342 | - continue; |
|
| 1399 | + if (!$testAPI->isSupported(true)) { |
|
| 1400 | + continue; |
|
| 1401 | + } |
|
| 1343 | 1402 | |
| 1344 | 1403 | $apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache; |
| 1345 | 1404 | } |
@@ -1364,8 +1423,9 @@ discard block |
||
| 1364 | 1423 | global $modSettings, $boardurl, $smcFunc; |
| 1365 | 1424 | |
| 1366 | 1425 | // Already have a key? Can't register again. |
| 1367 | - if (!empty($modSettings['sm_stats_key'])) |
|
| 1368 | - return true; |
|
| 1426 | + if (!empty($modSettings['sm_stats_key'])) { |
|
| 1427 | + return true; |
|
| 1428 | + } |
|
| 1369 | 1429 | |
| 1370 | 1430 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
| 1371 | 1431 | if ($fp) |
@@ -1376,8 +1436,9 @@ discard block |
||
| 1376 | 1436 | fwrite($fp, $out); |
| 1377 | 1437 | |
| 1378 | 1438 | $return_data = ''; |
| 1379 | - while (!feof($fp)) |
|
| 1380 | - $return_data .= fgets($fp, 128); |
|
| 1439 | + while (!feof($fp)) { |
|
| 1440 | + $return_data .= fgets($fp, 128); |
|
| 1441 | + } |
|
| 1381 | 1442 | |
| 1382 | 1443 | fclose($fp); |
| 1383 | 1444 | |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Gets a single theme's info. |
@@ -27,8 +28,9 @@ discard block |
||
| 27 | 28 | global $smcFunc, $modSettings; |
| 28 | 29 | |
| 29 | 30 | // No data, no fun! |
| 30 | - if (empty($id)) |
|
| 31 | - return false; |
|
| 31 | + if (empty($id)) { |
|
| 32 | + return false; |
|
| 33 | + } |
|
| 32 | 34 | |
| 33 | 35 | // Make sure $id is an int. |
| 34 | 36 | $id = (int) $id; |
@@ -171,8 +173,9 @@ discard block |
||
| 171 | 173 | global $smcFunc, $sourcedir, $forum_version, $txt, $scripturl, $context; |
| 172 | 174 | global $explicit_images; |
| 173 | 175 | |
| 174 | - if (empty($path)) |
|
| 175 | - return false; |
|
| 176 | + if (empty($path)) { |
|
| 177 | + return false; |
|
| 178 | + } |
|
| 176 | 179 | |
| 177 | 180 | $xml_data = array(); |
| 178 | 181 | $explicit_images = false; |
@@ -229,9 +232,10 @@ discard block |
||
| 229 | 232 | ); |
| 230 | 233 | |
| 231 | 234 | // Assign the values to be stored. |
| 232 | - foreach ($xml_elements as $var => $name) |
|
| 233 | - if (!empty($theme_info_xml[$name])) |
|
| 235 | + foreach ($xml_elements as $var => $name) { |
|
| 236 | + if (!empty($theme_info_xml[$name])) |
|
| 234 | 237 | $xml_data[$var] = $theme_info_xml[$name]; |
| 238 | + } |
|
| 235 | 239 | |
| 236 | 240 | // Add the supported versions. |
| 237 | 241 | $xml_data['install_for'] = $install_versions; |
@@ -243,8 +247,9 @@ discard block |
||
| 243 | 247 | $explicit_images = true; |
| 244 | 248 | } |
| 245 | 249 | |
| 246 | - if (!empty($theme_info_xml['extra'])) |
|
| 247 | - $xml_data += $smcFunc['json_decode']($theme_info_xml['extra'], true); |
|
| 250 | + if (!empty($theme_info_xml['extra'])) { |
|
| 251 | + $xml_data += $smcFunc['json_decode']($theme_info_xml['extra'], true); |
|
| 252 | + } |
|
| 248 | 253 | |
| 249 | 254 | return $xml_data; |
| 250 | 255 | } |
@@ -262,12 +267,14 @@ discard block |
||
| 262 | 267 | global $settings, $explicit_images; |
| 263 | 268 | |
| 264 | 269 | // External use? no problem! |
| 265 | - if ($to_install) |
|
| 266 | - $context['to_install'] = $to_install; |
|
| 270 | + if ($to_install) { |
|
| 271 | + $context['to_install'] = $to_install; |
|
| 272 | + } |
|
| 267 | 273 | |
| 268 | 274 | // One last check. |
| 269 | - if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') |
|
| 270 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
| 275 | + if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') { |
|
| 276 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
| 277 | + } |
|
| 271 | 278 | |
| 272 | 279 | // OK, is this a newer version of an already installed theme? |
| 273 | 280 | if (!empty($context['to_install']['version'])) |
@@ -291,8 +298,8 @@ discard block |
||
| 291 | 298 | $smcFunc['db_free_result']($request); |
| 292 | 299 | |
| 293 | 300 | // Got something, lets figure it out what to do next. |
| 294 | - if (!empty($to_update) && !empty($to_update['version'])) |
|
| 295 | - switch (compareVersions($context['to_install']['version'], $to_update['version'])) |
|
| 301 | + if (!empty($to_update) && !empty($to_update['version'])) { |
|
| 302 | + switch (compareVersions($context['to_install']['version'], $to_update['version'])) |
|
| 296 | 303 | { |
| 297 | 304 | case 1: // Got a newer version, update the old entry. |
| 298 | 305 | $smcFunc['db_query']('', ' |
@@ -306,6 +313,7 @@ discard block |
||
| 306 | 313 | 'id_theme' => $to_update['id_theme'], |
| 307 | 314 | ) |
| 308 | 315 | ); |
| 316 | + } |
|
| 309 | 317 | |
| 310 | 318 | // Done with the update, tell the user about it. |
| 311 | 319 | $context['to_install']['updated'] = true; |
@@ -371,13 +379,15 @@ discard block |
||
| 371 | 379 | $context['to_install']['base_theme_url'] = $temp['theme_url']; |
| 372 | 380 | $context['to_install']['base_theme_dir'] = $temp['theme_dir']; |
| 373 | 381 | |
| 374 | - if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) |
|
| 375 | - $context['to_install']['theme_url'] = $context['to_install']['base_theme_url']; |
|
| 382 | + if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) { |
|
| 383 | + $context['to_install']['theme_url'] = $context['to_install']['base_theme_url']; |
|
| 384 | + } |
|
| 376 | 385 | } |
| 377 | 386 | |
| 378 | 387 | // Nope, sorry, couldn't find any theme already installed. |
| 379 | - else |
|
| 380 | - fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']); |
|
| 388 | + else { |
|
| 389 | + fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']); |
|
| 390 | + } |
|
| 381 | 391 | } |
| 382 | 392 | |
| 383 | 393 | unset($context['to_install']['based_on']); |
@@ -400,16 +410,18 @@ discard block |
||
| 400 | 410 | call_integration_hook('integrate_theme_install', array(&$context['to_install'], $id_theme)); |
| 401 | 411 | |
| 402 | 412 | $inserts = array(); |
| 403 | - foreach ($context['to_install'] as $var => $val) |
|
| 404 | - $inserts[] = array($id_theme, $var, $val); |
|
| 413 | + foreach ($context['to_install'] as $var => $val) { |
|
| 414 | + $inserts[] = array($id_theme, $var, $val); |
|
| 415 | + } |
|
| 405 | 416 | |
| 406 | - if (!empty($inserts)) |
|
| 407 | - $smcFunc['db_insert']('insert', |
|
| 417 | + if (!empty($inserts)) { |
|
| 418 | + $smcFunc['db_insert']('insert', |
|
| 408 | 419 | '{db_prefix}themes', |
| 409 | 420 | array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), |
| 410 | 421 | $inserts, |
| 411 | 422 | array('id_theme', 'variable') |
| 412 | 423 | ); |
| 424 | + } |
|
| 413 | 425 | |
| 414 | 426 | // Update the known and enable Theme's settings. |
| 415 | 427 | $known = strtr($modSettings['knownThemes'] . ',' . $id_theme, array(',,' => ',')); |
@@ -428,21 +440,24 @@ discard block |
||
| 428 | 440 | */ |
| 429 | 441 | function remove_dir($path) |
| 430 | 442 | { |
| 431 | - if (empty($path)) |
|
| 432 | - return false; |
|
| 443 | + if (empty($path)) { |
|
| 444 | + return false; |
|
| 445 | + } |
|
| 433 | 446 | |
| 434 | 447 | if (is_dir($path)) |
| 435 | 448 | { |
| 436 | 449 | $objects = scandir($path); |
| 437 | 450 | |
| 438 | - foreach ($objects as $object) |
|
| 439 | - if ($object != '.' && $object != '..') |
|
| 451 | + foreach ($objects as $object) { |
|
| 452 | + if ($object != '.' && $object != '..') |
|
| 440 | 453 | { |
| 441 | 454 | if (filetype($path . '/' . $object) == 'dir') |
| 442 | 455 | remove_dir($path . '/' . $object); |
| 456 | + } |
|
| 443 | 457 | |
| 444 | - else |
|
| 445 | - unlink($path . '/' . $object); |
|
| 458 | + else { |
|
| 459 | + unlink($path . '/' . $object); |
|
| 460 | + } |
|
| 446 | 461 | } |
| 447 | 462 | } |
| 448 | 463 | |
@@ -461,8 +476,9 @@ discard block |
||
| 461 | 476 | global $smcFunc, $modSettings; |
| 462 | 477 | |
| 463 | 478 | // Can't delete the default theme, sorry! |
| 464 | - if (empty($themeID) || $themeID == 1) |
|
| 465 | - return false; |
|
| 479 | + if (empty($themeID) || $themeID == 1) { |
|
| 480 | + return false; |
|
| 481 | + } |
|
| 466 | 482 | |
| 467 | 483 | $known = explode(',', $modSettings['knownThemes']); |
| 468 | 484 | $enable = explode(',', $modSettings['enableThemes']); |
@@ -512,8 +528,9 @@ discard block |
||
| 512 | 528 | updateSettings(array('enableThemes' => $enable, 'knownThemes' => $known)); |
| 513 | 529 | |
| 514 | 530 | // Fix it if the theme was the overall default theme. |
| 515 | - if ($modSettings['theme_guests'] == $themeID) |
|
| 516 | - updateSettings(array('theme_guests' => '1')); |
|
| 531 | + if ($modSettings['theme_guests'] == $themeID) { |
|
| 532 | + updateSettings(array('theme_guests' => '1')); |
|
| 533 | + } |
|
| 517 | 534 | |
| 518 | 535 | return true; |
| 519 | 536 | } |
@@ -530,13 +547,15 @@ discard block |
||
| 530 | 547 | global $scripturl, $txt, $context; |
| 531 | 548 | |
| 532 | 549 | // Is it even a directory? |
| 533 | - if (!is_dir($path)) |
|
| 534 | - fatal_lang_error('error_invalid_dir', 'critical'); |
|
| 550 | + if (!is_dir($path)) { |
|
| 551 | + fatal_lang_error('error_invalid_dir', 'critical'); |
|
| 552 | + } |
|
| 535 | 553 | |
| 536 | 554 | $dir = dir($path); |
| 537 | 555 | $entries = array(); |
| 538 | - while ($entry = $dir->read()) |
|
| 539 | - $entries[] = $entry; |
|
| 556 | + while ($entry = $dir->read()) { |
|
| 557 | + $entries[] = $entry; |
|
| 558 | + } |
|
| 540 | 559 | $dir->close(); |
| 541 | 560 | |
| 542 | 561 | natcasesort($entries); |
@@ -547,11 +566,12 @@ discard block |
||
| 547 | 566 | foreach ($entries as $entry) |
| 548 | 567 | { |
| 549 | 568 | // Skip all dot files, including .htaccess. |
| 550 | - if (substr($entry, 0, 1) == '.' || $entry == 'CVS') |
|
| 551 | - continue; |
|
| 569 | + if (substr($entry, 0, 1) == '.' || $entry == 'CVS') { |
|
| 570 | + continue; |
|
| 571 | + } |
|
| 552 | 572 | |
| 553 | - if (is_dir($path . '/' . $entry)) |
|
| 554 | - $listing1[] = array( |
|
| 573 | + if (is_dir($path . '/' . $entry)) { |
|
| 574 | + $listing1[] = array( |
|
| 555 | 575 | 'filename' => $entry, |
| 556 | 576 | 'is_writable' => is_writable($path . '/' . $entry), |
| 557 | 577 | 'is_directory' => true, |
@@ -561,13 +581,14 @@ discard block |
||
| 561 | 581 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $relative . $entry, |
| 562 | 582 | 'size' => '', |
| 563 | 583 | ); |
| 564 | - else |
|
| 584 | + } else |
|
| 565 | 585 | { |
| 566 | 586 | $size = filesize($path . '/' . $entry); |
| 567 | - if ($size > 2048 || $size == 1024) |
|
| 568 | - $size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes']; |
|
| 569 | - else |
|
| 570 | - $size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes']; |
|
| 587 | + if ($size > 2048 || $size == 1024) { |
|
| 588 | + $size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes']; |
|
| 589 | + } else { |
|
| 590 | + $size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes']; |
|
| 591 | + } |
|
| 571 | 592 | |
| 572 | 593 | $listing2[] = array( |
| 573 | 594 | 'filename' => $entry, |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * This is the notoriously defunct package manager..... :/. |
@@ -57,10 +58,11 @@ discard block |
||
| 57 | 58 | ); |
| 58 | 59 | |
| 59 | 60 | // Work out exactly who it is we are calling. |
| 60 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 61 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 62 | - else |
|
| 63 | - $context['sub_action'] = 'browse'; |
|
| 61 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 62 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 63 | + } else { |
|
| 64 | + $context['sub_action'] = 'browse'; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // Set up some tabs... |
| 66 | 68 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -82,8 +84,9 @@ discard block |
||
| 82 | 84 | ), |
| 83 | 85 | ); |
| 84 | 86 | |
| 85 | - if ($context['sub_action'] == 'browse') |
|
| 86 | - loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
| 87 | + if ($context['sub_action'] == 'browse') { |
|
| 88 | + loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
| 89 | + } |
|
| 87 | 90 | |
| 88 | 91 | call_integration_hook('integrate_manage_packages', array(&$subActions)); |
| 89 | 92 | |
@@ -99,8 +102,9 @@ discard block |
||
| 99 | 102 | global $boarddir, $txt, $context, $scripturl, $sourcedir, $packagesdir, $modSettings, $smcFunc, $settings; |
| 100 | 103 | |
| 101 | 104 | // You have to specify a file!! |
| 102 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 103 | - redirectexit('action=admin;area=packages'); |
|
| 105 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 106 | + redirectexit('action=admin;area=packages'); |
|
| 107 | + } |
|
| 104 | 108 | $context['filename'] = preg_replace('~[\.]+~', '.', $_REQUEST['package']); |
| 105 | 109 | |
| 106 | 110 | // Do we have an existing id, for uninstalls and the like. |
@@ -112,8 +116,9 @@ discard block |
||
| 112 | 116 | create_chmod_control(); |
| 113 | 117 | |
| 114 | 118 | // Make sure temp directory exists and is empty. |
| 115 | - if (file_exists($packagesdir . '/temp')) |
|
| 116 | - deltree($packagesdir . '/temp', false); |
|
| 119 | + if (file_exists($packagesdir . '/temp')) { |
|
| 120 | + deltree($packagesdir . '/temp', false); |
|
| 121 | + } |
|
| 117 | 122 | |
| 118 | 123 | if (!mktree($packagesdir . '/temp', 0755)) |
| 119 | 124 | { |
@@ -124,8 +129,9 @@ discard block |
||
| 124 | 129 | create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=' . $_REQUEST['sa'] . ';package=' . $_REQUEST['package'], 'crash_on_error' => true)); |
| 125 | 130 | |
| 126 | 131 | deltree($packagesdir . '/temp', false); |
| 127 | - if (!mktree($packagesdir . '/temp', 0777)) |
|
| 128 | - fatal_lang_error('package_cant_download', false); |
|
| 132 | + if (!mktree($packagesdir . '/temp', 0777)) { |
|
| 133 | + fatal_lang_error('package_cant_download', false); |
|
| 134 | + } |
|
| 129 | 135 | } |
| 130 | 136 | } |
| 131 | 137 | |
@@ -151,25 +157,26 @@ discard block |
||
| 151 | 157 | { |
| 152 | 158 | $context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 153 | 159 | |
| 154 | - if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 155 | - foreach ($context['extracted_files'] as $file) |
|
| 160 | + if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 161 | + foreach ($context['extracted_files'] as $file) |
|
| 156 | 162 | if (basename($file['filename']) == 'package-info.xml') |
| 157 | 163 | { |
| 158 | 164 | $context['base_path'] = dirname($file['filename']) . '/'; |
| 165 | + } |
|
| 159 | 166 | break; |
| 160 | 167 | } |
| 161 | 168 | |
| 162 | - if (!isset($context['base_path'])) |
|
| 163 | - $context['base_path'] = ''; |
|
| 164 | - } |
|
| 165 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 169 | + if (!isset($context['base_path'])) { |
|
| 170 | + $context['base_path'] = ''; |
|
| 171 | + } |
|
| 172 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 166 | 173 | { |
| 167 | 174 | copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 168 | 175 | $context['extracted_files'] = listtree($packagesdir . '/temp'); |
| 169 | 176 | $context['base_path'] = ''; |
| 177 | + } else { |
|
| 178 | + fatal_lang_error('no_access', false); |
|
| 170 | 179 | } |
| 171 | - else |
|
| 172 | - fatal_lang_error('no_access', false); |
|
| 173 | 180 | |
| 174 | 181 | // Load up any custom themes we may want to install into... |
| 175 | 182 | $request = $smcFunc['db_query']('', ' |
@@ -185,15 +192,17 @@ discard block |
||
| 185 | 192 | ) |
| 186 | 193 | ); |
| 187 | 194 | $theme_paths = array(); |
| 188 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 189 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 195 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 196 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 197 | + } |
|
| 190 | 198 | $smcFunc['db_free_result']($request); |
| 191 | 199 | |
| 192 | 200 | // Get the package info... |
| 193 | 201 | $packageInfo = getPackageInfo($context['filename']); |
| 194 | 202 | |
| 195 | - if (!is_array($packageInfo)) |
|
| 196 | - fatal_lang_error($packageInfo); |
|
| 203 | + if (!is_array($packageInfo)) { |
|
| 204 | + fatal_lang_error($packageInfo); |
|
| 205 | + } |
|
| 197 | 206 | |
| 198 | 207 | $packageInfo['filename'] = $context['filename']; |
| 199 | 208 | $context['package_name'] = isset($packageInfo['name']) ? $packageInfo['name'] : $context['filename']; |
@@ -227,18 +236,19 @@ discard block |
||
| 227 | 236 | $smcFunc['db_free_result']($request); |
| 228 | 237 | |
| 229 | 238 | $context['database_changes'] = array(); |
| 230 | - if (isset($packageInfo['uninstall']['database'])) |
|
| 231 | - $context['database_changes'][] = $txt['execute_database_changes'] . ' - ' . $packageInfo['uninstall']['database']; |
|
| 232 | - elseif (!empty($db_changes)) |
|
| 239 | + if (isset($packageInfo['uninstall']['database'])) { |
|
| 240 | + $context['database_changes'][] = $txt['execute_database_changes'] . ' - ' . $packageInfo['uninstall']['database']; |
|
| 241 | + } elseif (!empty($db_changes)) |
|
| 233 | 242 | { |
| 234 | 243 | foreach ($db_changes as $change) |
| 235 | 244 | { |
| 236 | - if (isset($change[2]) && isset($txt['package_db_' . $change[0]])) |
|
| 237 | - $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1], $change[2]); |
|
| 238 | - elseif (isset($txt['package_db_' . $change[0]])) |
|
| 239 | - $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1]); |
|
| 240 | - else |
|
| 241 | - $context['database_changes'][] = $change[0] . '-' . $change[1] . (isset($change[2]) ? '-' . $change[2] : ''); |
|
| 245 | + if (isset($change[2]) && isset($txt['package_db_' . $change[0]])) { |
|
| 246 | + $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1], $change[2]); |
|
| 247 | + } elseif (isset($txt['package_db_' . $change[0]])) { |
|
| 248 | + $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1]); |
|
| 249 | + } else { |
|
| 250 | + $context['database_changes'][] = $change[0] . '-' . $change[1] . (isset($change[2]) ? '-' . $change[2] : ''); |
|
| 251 | + } |
|
| 242 | 252 | } |
| 243 | 253 | } |
| 244 | 254 | |
@@ -265,31 +275,33 @@ discard block |
||
| 265 | 275 | $context['themes_locked'] = true; |
| 266 | 276 | |
| 267 | 277 | // Only let them uninstall themes it was installed into. |
| 268 | - foreach ($theme_paths as $id => $data) |
|
| 269 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 278 | + foreach ($theme_paths as $id => $data) { |
|
| 279 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 270 | 280 | unset($theme_paths[$id]); |
| 271 | - } |
|
| 272 | - elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 281 | + } |
|
| 282 | + } elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 273 | 283 | { |
| 274 | 284 | // Look for an upgrade... |
| 275 | 285 | $actions = parsePackageInfo($packageInfo['xml'], true, 'upgrade', $old_version); |
| 276 | 286 | |
| 277 | 287 | // There was no upgrade.... |
| 278 | - if (empty($actions)) |
|
| 279 | - $context['is_installed'] = true; |
|
| 280 | - else |
|
| 288 | + if (empty($actions)) { |
|
| 289 | + $context['is_installed'] = true; |
|
| 290 | + } else |
|
| 281 | 291 | { |
| 282 | 292 | // Otherwise they can only upgrade themes from the first time around. |
| 283 | - foreach ($theme_paths as $id => $data) |
|
| 284 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 293 | + foreach ($theme_paths as $id => $data) { |
|
| 294 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 285 | 295 | unset($theme_paths[$id]); |
| 296 | + } |
|
| 286 | 297 | } |
| 298 | + } elseif (isset($old_version) && $old_version == $packageInfo['version']) { |
|
| 299 | + $context['is_installed'] = true; |
|
| 287 | 300 | } |
| 288 | - elseif (isset($old_version) && $old_version == $packageInfo['version']) |
|
| 289 | - $context['is_installed'] = true; |
|
| 290 | 301 | |
| 291 | - if (!isset($old_version) || $context['is_installed']) |
|
| 292 | - $actions = parsePackageInfo($packageInfo['xml'], true, 'install'); |
|
| 302 | + if (!isset($old_version) || $context['is_installed']) { |
|
| 303 | + $actions = parsePackageInfo($packageInfo['xml'], true, 'install'); |
|
| 304 | + } |
|
| 293 | 305 | |
| 294 | 306 | $context['actions'] = array(); |
| 295 | 307 | $context['ftp_needed'] = false; |
@@ -297,8 +309,9 @@ discard block |
||
| 297 | 309 | $chmod_files = array(); |
| 298 | 310 | |
| 299 | 311 | // no actions found, return so we can display an error |
| 300 | - if (empty($actions)) |
|
| 301 | - return; |
|
| 312 | + if (empty($actions)) { |
|
| 313 | + return; |
|
| 314 | + } |
|
| 302 | 315 | |
| 303 | 316 | // This will hold data about anything that can be installed in other themes. |
| 304 | 317 | $themeFinds = array( |
@@ -317,14 +330,14 @@ discard block |
||
| 317 | 330 | { |
| 318 | 331 | $chmod_files[] = $action['filename']; |
| 319 | 332 | continue; |
| 320 | - } |
|
| 321 | - elseif ($action['type'] == 'readme' || $action['type'] == 'license') |
|
| 333 | + } elseif ($action['type'] == 'readme' || $action['type'] == 'license') |
|
| 322 | 334 | { |
| 323 | 335 | $type = 'package_' . $action['type']; |
| 324 | - if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
|
| 325 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), "\n\r")); |
|
| 326 | - elseif (file_exists($action['filename'])) |
|
| 327 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 336 | + if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) { |
|
| 337 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), "\n\r")); |
|
| 338 | + } elseif (file_exists($action['filename'])) { |
|
| 339 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 340 | + } |
|
| 328 | 341 | |
| 329 | 342 | if (!empty($action['parse_bbc'])) |
| 330 | 343 | { |
@@ -332,24 +345,24 @@ discard block |
||
| 332 | 345 | $context[$type] = preg_replace('~\[[/]?html\]~i', '', $context[$type]); |
| 333 | 346 | preparsecode($context[$type]); |
| 334 | 347 | $context[$type] = parse_bbc($context[$type]); |
| 348 | + } else { |
|
| 349 | + $context[$type] = nl2br($context[$type]); |
|
| 335 | 350 | } |
| 336 | - else |
|
| 337 | - $context[$type] = nl2br($context[$type]); |
|
| 338 | 351 | |
| 339 | 352 | continue; |
| 340 | 353 | } |
| 341 | 354 | // Don't show redirects. |
| 342 | - elseif ($action['type'] == 'redirect') |
|
| 343 | - continue; |
|
| 344 | - elseif ($action['type'] == 'error') |
|
| 355 | + elseif ($action['type'] == 'redirect') { |
|
| 356 | + continue; |
|
| 357 | + } elseif ($action['type'] == 'error') |
|
| 345 | 358 | { |
| 346 | 359 | $context['has_failure'] = true; |
| 347 | - if (isset($action['error_msg']) && isset($action['error_var'])) |
|
| 348 | - $context['failure_details'] = sprintf($txt['package_will_fail_' . $action['error_msg']], $action['error_var']); |
|
| 349 | - elseif (isset($action['error_msg'])) |
|
| 350 | - $context['failure_details'] = isset($txt['package_will_fail_' . $action['error_msg']]) ? $txt['package_will_fail_' . $action['error_msg']] : $action['error_msg']; |
|
| 351 | - } |
|
| 352 | - elseif ($action['type'] == 'modification') |
|
| 360 | + if (isset($action['error_msg']) && isset($action['error_var'])) { |
|
| 361 | + $context['failure_details'] = sprintf($txt['package_will_fail_' . $action['error_msg']], $action['error_var']); |
|
| 362 | + } elseif (isset($action['error_msg'])) { |
|
| 363 | + $context['failure_details'] = isset($txt['package_will_fail_' . $action['error_msg']]) ? $txt['package_will_fail_' . $action['error_msg']] : $action['error_msg']; |
|
| 364 | + } |
|
| 365 | + } elseif ($action['type'] == 'modification') |
|
| 353 | 366 | { |
| 354 | 367 | if (!file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
| 355 | 368 | { |
@@ -361,52 +374,54 @@ discard block |
||
| 361 | 374 | 'description' => $txt['package_action_missing'], |
| 362 | 375 | 'failed' => true, |
| 363 | 376 | ); |
| 364 | - } |
|
| 365 | - else |
|
| 377 | + } else |
|
| 366 | 378 | { |
| 367 | 379 | |
| 368 | - if ($action['boardmod']) |
|
| 369 | - $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 370 | - else |
|
| 371 | - $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 380 | + if ($action['boardmod']) { |
|
| 381 | + $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 382 | + } else { |
|
| 383 | + $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 384 | + } |
|
| 372 | 385 | |
| 373 | - if (count($mod_actions) == 1 && isset($mod_actions[0]) && $mod_actions[0]['type'] == 'error' && $mod_actions[0]['filename'] == '-') |
|
| 374 | - $mod_actions[0]['filename'] = $action['filename']; |
|
| 386 | + if (count($mod_actions) == 1 && isset($mod_actions[0]) && $mod_actions[0]['type'] == 'error' && $mod_actions[0]['filename'] == '-') { |
|
| 387 | + $mod_actions[0]['filename'] = $action['filename']; |
|
| 388 | + } |
|
| 375 | 389 | |
| 376 | 390 | foreach ($mod_actions as $key => $mod_action) |
| 377 | 391 | { |
| 378 | 392 | // Lets get the last section of the file name. |
| 379 | - if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') |
|
| 380 | - $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 381 | - elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) |
|
| 382 | - $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 383 | - else |
|
| 384 | - $actual_filename = $key; |
|
| 385 | - |
|
| 386 | - if ($mod_action['type'] == 'opened') |
|
| 387 | - $failed = false; |
|
| 388 | - elseif ($mod_action['type'] == 'failure') |
|
| 393 | + if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') { |
|
| 394 | + $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 395 | + } elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) { |
|
| 396 | + $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 397 | + } else { |
|
| 398 | + $actual_filename = $key; |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + if ($mod_action['type'] == 'opened') { |
|
| 402 | + $failed = false; |
|
| 403 | + } elseif ($mod_action['type'] == 'failure') |
|
| 389 | 404 | { |
| 390 | - if (empty($mod_action['is_custom'])) |
|
| 391 | - $context['has_failure'] = true; |
|
| 405 | + if (empty($mod_action['is_custom'])) { |
|
| 406 | + $context['has_failure'] = true; |
|
| 407 | + } |
|
| 392 | 408 | $failed = true; |
| 393 | - } |
|
| 394 | - elseif ($mod_action['type'] == 'chmod') |
|
| 409 | + } elseif ($mod_action['type'] == 'chmod') |
|
| 395 | 410 | { |
| 396 | 411 | $chmod_files[] = $mod_action['filename']; |
| 397 | - } |
|
| 398 | - elseif ($mod_action['type'] == 'saved') |
|
| 412 | + } elseif ($mod_action['type'] == 'saved') |
|
| 399 | 413 | { |
| 400 | 414 | if (!empty($mod_action['is_custom'])) |
| 401 | 415 | { |
| 402 | - if (!isset($context['theme_actions'][$mod_action['is_custom']])) |
|
| 403 | - $context['theme_actions'][$mod_action['is_custom']] = array( |
|
| 416 | + if (!isset($context['theme_actions'][$mod_action['is_custom']])) { |
|
| 417 | + $context['theme_actions'][$mod_action['is_custom']] = array( |
|
| 404 | 418 | 'name' => $theme_paths[$mod_action['is_custom']]['name'], |
| 405 | 419 | 'actions' => array(), |
| 406 | 420 | 'has_failure' => $failed, |
| 407 | 421 | ); |
| 408 | - else |
|
| 409 | - $context['theme_actions'][$mod_action['is_custom']]['has_failure'] |= $failed; |
|
| 422 | + } else { |
|
| 423 | + $context['theme_actions'][$mod_action['is_custom']]['has_failure'] |= $failed; |
|
| 424 | + } |
|
| 410 | 425 | |
| 411 | 426 | $context['theme_actions'][$mod_action['is_custom']]['actions'][$actual_filename] = array( |
| 412 | 427 | 'type' => $txt['execute_modification'], |
@@ -414,8 +429,7 @@ discard block |
||
| 414 | 429 | 'description' => $failed ? $txt['package_action_failure'] : $txt['package_action_success'], |
| 415 | 430 | 'failed' => $failed, |
| 416 | 431 | ); |
| 417 | - } |
|
| 418 | - elseif (!isset($context['actions'][$actual_filename])) |
|
| 432 | + } elseif (!isset($context['actions'][$actual_filename])) |
|
| 419 | 433 | { |
| 420 | 434 | $context['actions'][$actual_filename] = array( |
| 421 | 435 | 'type' => $txt['execute_modification'], |
@@ -423,22 +437,19 @@ discard block |
||
| 423 | 437 | 'description' => $failed ? $txt['package_action_failure'] : $txt['package_action_success'], |
| 424 | 438 | 'failed' => $failed, |
| 425 | 439 | ); |
| 426 | - } |
|
| 427 | - else |
|
| 440 | + } else |
|
| 428 | 441 | { |
| 429 | 442 | $context['actions'][$actual_filename]['failed'] |= $failed; |
| 430 | 443 | $context['actions'][$actual_filename]['description'] = $context['actions'][$actual_filename]['failed'] ? $txt['package_action_failure'] : $txt['package_action_success']; |
| 431 | 444 | } |
| 432 | - } |
|
| 433 | - elseif ($mod_action['type'] == 'skipping') |
|
| 445 | + } elseif ($mod_action['type'] == 'skipping') |
|
| 434 | 446 | { |
| 435 | 447 | $context['actions'][$actual_filename] = array( |
| 436 | 448 | 'type' => $txt['execute_modification'], |
| 437 | 449 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 438 | 450 | 'description' => $txt['package_action_skipping'] |
| 439 | 451 | ); |
| 440 | - } |
|
| 441 | - elseif ($mod_action['type'] == 'missing' && empty($mod_action['is_custom'])) |
|
| 452 | + } elseif ($mod_action['type'] == 'missing' && empty($mod_action['is_custom'])) |
|
| 442 | 453 | { |
| 443 | 454 | $context['has_failure'] = true; |
| 444 | 455 | $context['actions'][$actual_filename] = array( |
@@ -447,32 +458,33 @@ discard block |
||
| 447 | 458 | 'description' => $txt['package_action_missing'], |
| 448 | 459 | 'failed' => true, |
| 449 | 460 | ); |
| 450 | - } |
|
| 451 | - elseif ($mod_action['type'] == 'error') |
|
| 452 | - $context['actions'][$actual_filename] = array( |
|
| 461 | + } elseif ($mod_action['type'] == 'error') { |
|
| 462 | + $context['actions'][$actual_filename] = array( |
|
| 453 | 463 | 'type' => $txt['execute_modification'], |
| 454 | 464 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 455 | 465 | 'description' => $txt['package_action_error'], |
| 456 | 466 | 'failed' => true, |
| 457 | 467 | ); |
| 468 | + } |
|
| 458 | 469 | } |
| 459 | 470 | |
| 460 | 471 | // We need to loop again just to get the operations down correctly. |
| 461 | 472 | foreach ($mod_actions as $operation_key => $mod_action) |
| 462 | 473 | { |
| 463 | 474 | // Lets get the last section of the file name. |
| 464 | - if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') |
|
| 465 | - $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 466 | - elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) |
|
| 467 | - $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 468 | - else |
|
| 469 | - $actual_filename = $key; |
|
| 475 | + if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') { |
|
| 476 | + $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 477 | + } elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) { |
|
| 478 | + $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 479 | + } else { |
|
| 480 | + $actual_filename = $key; |
|
| 481 | + } |
|
| 470 | 482 | |
| 471 | 483 | // We just need it for actual parse changes. |
| 472 | 484 | if (!in_array($mod_action['type'], array('error', 'result', 'opened', 'saved', 'end', 'missing', 'skipping', 'chmod'))) |
| 473 | 485 | { |
| 474 | - if (empty($mod_action['is_custom'])) |
|
| 475 | - $context['actions'][$actual_filename]['operations'][] = array( |
|
| 486 | + if (empty($mod_action['is_custom'])) { |
|
| 487 | + $context['actions'][$actual_filename]['operations'][] = array( |
|
| 476 | 488 | 'type' => $txt['execute_modification'], |
| 477 | 489 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 478 | 490 | 'description' => $mod_action['failed'] ? $txt['package_action_failure'] : $txt['package_action_success'], |
@@ -483,10 +495,11 @@ discard block |
||
| 483 | 495 | 'failed' => $mod_action['failed'], |
| 484 | 496 | 'ignore_failure' => !empty($mod_action['ignore_failure']), |
| 485 | 497 | ); |
| 498 | + } |
|
| 486 | 499 | |
| 487 | 500 | // Themes are under the saved type. |
| 488 | - if (isset($mod_action['is_custom']) && isset($context['theme_actions'][$mod_action['is_custom']])) |
|
| 489 | - $context['theme_actions'][$mod_action['is_custom']]['actions'][$actual_filename]['operations'][] = array( |
|
| 501 | + if (isset($mod_action['is_custom']) && isset($context['theme_actions'][$mod_action['is_custom']])) { |
|
| 502 | + $context['theme_actions'][$mod_action['is_custom']]['actions'][$actual_filename]['operations'][] = array( |
|
| 490 | 503 | 'type' => $txt['execute_modification'], |
| 491 | 504 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 492 | 505 | 'description' => $mod_action['failed'] ? $txt['package_action_failure'] : $txt['package_action_success'], |
@@ -497,59 +510,55 @@ discard block |
||
| 497 | 510 | 'failed' => $mod_action['failed'], |
| 498 | 511 | 'ignore_failure' => !empty($mod_action['ignore_failure']), |
| 499 | 512 | ); |
| 513 | + } |
|
| 500 | 514 | } |
| 501 | 515 | } |
| 502 | 516 | } |
| 503 | - } |
|
| 504 | - elseif ($action['type'] == 'code') |
|
| 517 | + } elseif ($action['type'] == 'code') |
|
| 505 | 518 | { |
| 506 | 519 | $thisAction = array( |
| 507 | 520 | 'type' => $txt['execute_code'], |
| 508 | 521 | 'action' => $smcFunc['htmlspecialchars']($action['filename']), |
| 509 | 522 | ); |
| 510 | - } |
|
| 511 | - elseif ($action['type'] == 'database') |
|
| 523 | + } elseif ($action['type'] == 'database') |
|
| 512 | 524 | { |
| 513 | 525 | $thisAction = array( |
| 514 | 526 | 'type' => $txt['execute_database_changes'], |
| 515 | 527 | 'action' => $smcFunc['htmlspecialchars']($action['filename']), |
| 516 | 528 | ); |
| 517 | - } |
|
| 518 | - elseif (in_array($action['type'], array('create-dir', 'create-file'))) |
|
| 529 | + } elseif (in_array($action['type'], array('create-dir', 'create-file'))) |
|
| 519 | 530 | { |
| 520 | 531 | $thisAction = array( |
| 521 | 532 | 'type' => $txt['package_create'] . ' ' . ($action['type'] == 'create-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 522 | 533 | 'action' => $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.'))) |
| 523 | 534 | ); |
| 524 | - } |
|
| 525 | - elseif ($action['type'] == 'hook') |
|
| 535 | + } elseif ($action['type'] == 'hook') |
|
| 526 | 536 | { |
| 527 | 537 | $action['description'] = !isset($action['hook'], $action['function']) ? $txt['package_action_failure'] : $txt['package_action_success']; |
| 528 | 538 | |
| 529 | - if (!isset($action['hook'], $action['function'])) |
|
| 530 | - $context['has_failure'] = true; |
|
| 539 | + if (!isset($action['hook'], $action['function'])) { |
|
| 540 | + $context['has_failure'] = true; |
|
| 541 | + } |
|
| 531 | 542 | |
| 532 | 543 | $thisAction = array( |
| 533 | 544 | 'type' => $action['reverse'] ? $txt['execute_hook_remove'] : $txt['execute_hook_add'], |
| 534 | 545 | 'action' => sprintf($txt['execute_hook_action' . ($action['reverse'] ? '_inverse' : '')], $smcFunc['htmlspecialchars']($action['hook'])), |
| 535 | 546 | ); |
| 536 | - } |
|
| 537 | - elseif ($action['type'] == 'credits') |
|
| 547 | + } elseif ($action['type'] == 'credits') |
|
| 538 | 548 | { |
| 539 | 549 | $thisAction = array( |
| 540 | 550 | 'type' => $txt['execute_credits_add'], |
| 541 | 551 | 'action' => sprintf($txt['execute_credits_action'], $smcFunc['htmlspecialchars']($action['title'])), |
| 542 | 552 | ); |
| 543 | - } |
|
| 544 | - elseif ($action['type'] == 'requires') |
|
| 553 | + } elseif ($action['type'] == 'requires') |
|
| 545 | 554 | { |
| 546 | 555 | $installed = false; |
| 547 | 556 | $version = true; |
| 548 | 557 | |
| 549 | 558 | // package missing required values? |
| 550 | - if (!isset($action['id'])) |
|
| 551 | - $context['has_failure'] = true; |
|
| 552 | - else |
|
| 559 | + if (!isset($action['id'])) { |
|
| 560 | + $context['has_failure'] = true; |
|
| 561 | + } else |
|
| 553 | 562 | { |
| 554 | 563 | // See if this dependancy is installed |
| 555 | 564 | $request = $smcFunc['db_query']('', ' |
@@ -565,8 +574,9 @@ discard block |
||
| 565 | 574 | ) |
| 566 | 575 | ); |
| 567 | 576 | $installed = ($smcFunc['db_num_rows']($request) !== 0); |
| 568 | - if ($installed) |
|
| 569 | - list ($version) = $smcFunc['db_fetch_row']($request); |
|
| 577 | + if ($installed) { |
|
| 578 | + list ($version) = $smcFunc['db_fetch_row']($request); |
|
| 579 | + } |
|
| 570 | 580 | $smcFunc['db_free_result']($request); |
| 571 | 581 | |
| 572 | 582 | // do a version level check (if requested) in the most basic way |
@@ -581,8 +591,7 @@ discard block |
||
| 581 | 591 | 'type' => $txt['package_requires'], |
| 582 | 592 | 'action' => $txt['package_check_for'] . ' ' . $action['id'] . (isset($action['version']) ? (' / ' . ($version ? $action['version'] : '<span class="error">' . $action['version'] . '</span>')) : ''), |
| 583 | 593 | ); |
| 584 | - } |
|
| 585 | - elseif (in_array($action['type'], array('require-dir', 'require-file'))) |
|
| 594 | + } elseif (in_array($action['type'], array('require-dir', 'require-file'))) |
|
| 586 | 595 | { |
| 587 | 596 | // Do this one... |
| 588 | 597 | $thisAction = array( |
@@ -596,26 +605,29 @@ discard block |
||
| 596 | 605 | // Is the action already stated? |
| 597 | 606 | $theme_action = !empty($action['theme_action']) && in_array($action['theme_action'], array('no', 'yes', 'auto')) ? $action['theme_action'] : 'auto'; |
| 598 | 607 | // If it's not auto do we think we have something we can act upon? |
| 599 | - if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) |
|
| 600 | - $theme_action = ''; |
|
| 608 | + if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) { |
|
| 609 | + $theme_action = ''; |
|
| 610 | + } |
|
| 601 | 611 | // ... or if it's auto do we even want to do anything? |
| 602 | - elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') |
|
| 603 | - $theme_action = ''; |
|
| 612 | + elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') { |
|
| 613 | + $theme_action = ''; |
|
| 614 | + } |
|
| 604 | 615 | |
| 605 | 616 | // So, we still want to do something? |
| 606 | - if ($theme_action != '') |
|
| 607 | - $themeFinds['candidates'][] = $action; |
|
| 617 | + if ($theme_action != '') { |
|
| 618 | + $themeFinds['candidates'][] = $action; |
|
| 619 | + } |
|
| 608 | 620 | // Otherwise is this is going into another theme record it. |
| 609 | - elseif ($matches[1] == 'themes_dir') |
|
| 610 | - $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_destination']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 621 | + elseif ($matches[1] == 'themes_dir') { |
|
| 622 | + $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_destination']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 623 | + } |
|
| 611 | 624 | } |
| 612 | - } |
|
| 613 | - elseif (in_array($action['type'], array('move-dir', 'move-file'))) |
|
| 614 | - $thisAction = array( |
|
| 625 | + } elseif (in_array($action['type'], array('move-dir', 'move-file'))) { |
|
| 626 | + $thisAction = array( |
|
| 615 | 627 | 'type' => $txt['package_move'] . ' ' . ($action['type'] == 'move-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 616 | 628 | 'action' => $smcFunc['htmlspecialchars'](strtr($action['source'], array($boarddir => '.'))) . ' => ' . $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.'))) |
| 617 | 629 | ); |
| 618 | - elseif (in_array($action['type'], array('remove-dir', 'remove-file'))) |
|
| 630 | + } elseif (in_array($action['type'], array('remove-dir', 'remove-file'))) |
|
| 619 | 631 | { |
| 620 | 632 | $thisAction = array( |
| 621 | 633 | 'type' => $txt['package_delete'] . ' ' . ($action['type'] == 'remove-dir' ? $txt['package_tree'] : $txt['package_file']), |
@@ -631,30 +643,36 @@ discard block |
||
| 631 | 643 | $action['unparsed_destination'] = $action['unparsed_filename']; |
| 632 | 644 | |
| 633 | 645 | // If it's not auto do we think we have something we can act upon? |
| 634 | - if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) |
|
| 635 | - $theme_action = ''; |
|
| 646 | + if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) { |
|
| 647 | + $theme_action = ''; |
|
| 648 | + } |
|
| 636 | 649 | // ... or if it's auto do we even want to do anything? |
| 637 | - elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') |
|
| 638 | - $theme_action = ''; |
|
| 650 | + elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') { |
|
| 651 | + $theme_action = ''; |
|
| 652 | + } |
|
| 639 | 653 | |
| 640 | 654 | // So, we still want to do something? |
| 641 | - if ($theme_action != '') |
|
| 642 | - $themeFinds['candidates'][] = $action; |
|
| 655 | + if ($theme_action != '') { |
|
| 656 | + $themeFinds['candidates'][] = $action; |
|
| 657 | + } |
|
| 643 | 658 | // Otherwise is this is going into another theme record it. |
| 644 | - elseif ($matches[1] == 'themes_dir') |
|
| 645 | - $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_filename']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 659 | + elseif ($matches[1] == 'themes_dir') { |
|
| 660 | + $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_filename']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 661 | + } |
|
| 646 | 662 | } |
| 647 | 663 | } |
| 648 | 664 | |
| 649 | - if (empty($thisAction)) |
|
| 650 | - continue; |
|
| 665 | + if (empty($thisAction)) { |
|
| 666 | + continue; |
|
| 667 | + } |
|
| 651 | 668 | |
| 652 | 669 | if (!in_array($action['type'], array('hook', 'credits'))) |
| 653 | 670 | { |
| 654 | - if ($context['uninstalling']) |
|
| 655 | - $file = in_array($action['type'], array('remove-dir', 'remove-file')) ? $action['filename'] : $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 656 | - else |
|
| 657 | - $file = $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 671 | + if ($context['uninstalling']) { |
|
| 672 | + $file = in_array($action['type'], array('remove-dir', 'remove-file')) ? $action['filename'] : $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 673 | + } else { |
|
| 674 | + $file = $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 675 | + } |
|
| 658 | 676 | } |
| 659 | 677 | |
| 660 | 678 | // Don't fail if a file/directory we're trying to create doesn't exist... |
@@ -669,8 +687,9 @@ discard block |
||
| 669 | 687 | } |
| 670 | 688 | |
| 671 | 689 | // @todo None given? |
| 672 | - if (empty($thisAction['description'])) |
|
| 673 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 690 | + if (empty($thisAction['description'])) { |
|
| 691 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 692 | + } |
|
| 674 | 693 | |
| 675 | 694 | $context['actions'][] = $thisAction; |
| 676 | 695 | } |
@@ -683,18 +702,21 @@ discard block |
||
| 683 | 702 | // Get the part of the file we'll be dealing with. |
| 684 | 703 | preg_match('~^\$(languagedir|languages_dir|imagesdir|themedir)(\\|/)*(.+)*~i', $action_data['unparsed_destination'], $matches); |
| 685 | 704 | |
| 686 | - if ($matches[1] == 'imagesdir') |
|
| 687 | - $path = '/' . basename($settings['default_images_url']); |
|
| 688 | - elseif ($matches[1] == 'languagedir' || $matches[1] == 'languages_dir') |
|
| 689 | - $path = '/languages'; |
|
| 690 | - else |
|
| 691 | - $path = ''; |
|
| 705 | + if ($matches[1] == 'imagesdir') { |
|
| 706 | + $path = '/' . basename($settings['default_images_url']); |
|
| 707 | + } elseif ($matches[1] == 'languagedir' || $matches[1] == 'languages_dir') { |
|
| 708 | + $path = '/languages'; |
|
| 709 | + } else { |
|
| 710 | + $path = ''; |
|
| 711 | + } |
|
| 692 | 712 | |
| 693 | - if (!empty($matches[3])) |
|
| 694 | - $path .= $matches[3]; |
|
| 713 | + if (!empty($matches[3])) { |
|
| 714 | + $path .= $matches[3]; |
|
| 715 | + } |
|
| 695 | 716 | |
| 696 | - if (!$context['uninstalling']) |
|
| 697 | - $path .= '/' . basename($action_data['filename']); |
|
| 717 | + if (!$context['uninstalling']) { |
|
| 718 | + $path .= '/' . basename($action_data['filename']); |
|
| 719 | + } |
|
| 698 | 720 | |
| 699 | 721 | // Loop through each custom theme to note it's candidacy! |
| 700 | 722 | foreach ($theme_paths as $id => $theme_data) |
@@ -710,36 +732,40 @@ discard block |
||
| 710 | 732 | if (!mktree(dirname($real_path), false)) |
| 711 | 733 | { |
| 712 | 734 | $temp = dirname($real_path); |
| 713 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
| 714 | - $temp = dirname($temp); |
|
| 735 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
| 736 | + $temp = dirname($temp); |
|
| 737 | + } |
|
| 715 | 738 | $chmod_files[] = $temp; |
| 716 | 739 | } |
| 717 | 740 | |
| 718 | - if ($action_data['type'] == 'require-dir' && !is_writable($real_path) && (file_exists($real_path) || !is_writable(dirname($real_path)))) |
|
| 719 | - $chmod_files[] = $real_path; |
|
| 741 | + if ($action_data['type'] == 'require-dir' && !is_writable($real_path) && (file_exists($real_path) || !is_writable(dirname($real_path)))) { |
|
| 742 | + $chmod_files[] = $real_path; |
|
| 743 | + } |
|
| 720 | 744 | |
| 721 | - if (!isset($context['theme_actions'][$id])) |
|
| 722 | - $context['theme_actions'][$id] = array( |
|
| 745 | + if (!isset($context['theme_actions'][$id])) { |
|
| 746 | + $context['theme_actions'][$id] = array( |
|
| 723 | 747 | 'name' => $theme_data['name'], |
| 724 | 748 | 'actions' => array(), |
| 725 | 749 | ); |
| 750 | + } |
|
| 726 | 751 | |
| 727 | - if ($context['uninstalling']) |
|
| 728 | - $context['theme_actions'][$id]['actions'][] = array( |
|
| 752 | + if ($context['uninstalling']) { |
|
| 753 | + $context['theme_actions'][$id]['actions'][] = array( |
|
| 729 | 754 | 'type' => $txt['package_delete'] . ' ' . ($action_data['type'] == 'require-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 730 | 755 | 'action' => strtr($real_path, array('\\' => '/', $boarddir => '.')), |
| 731 | 756 | 'description' => '', |
| 732 | 757 | 'value' => base64_encode($smcFunc['json_encode'](array('type' => $action_data['type'], 'orig' => $action_data['filename'], 'future' => $real_path, 'id' => $id))), |
| 733 | 758 | 'not_mod' => true, |
| 734 | 759 | ); |
| 735 | - else |
|
| 736 | - $context['theme_actions'][$id]['actions'][] = array( |
|
| 760 | + } else { |
|
| 761 | + $context['theme_actions'][$id]['actions'][] = array( |
|
| 737 | 762 | 'type' => $txt['package_extract'] . ' ' . ($action_data['type'] == 'require-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 738 | 763 | 'action' => strtr($real_path, array('\\' => '/', $boarddir => '.')), |
| 739 | 764 | 'description' => '', |
| 740 | 765 | 'value' => base64_encode($smcFunc['json_encode'](array('type' => $action_data['type'], 'orig' => $action_data['destination'], 'future' => $real_path, 'id' => $id))), |
| 741 | 766 | 'not_mod' => true, |
| 742 | 767 | ); |
| 768 | + } |
|
| 743 | 769 | } |
| 744 | 770 | } |
| 745 | 771 | } |
@@ -749,8 +775,9 @@ discard block |
||
| 749 | 775 | // Trash the cache... which will also check permissions for us! |
| 750 | 776 | package_flush_cache(true); |
| 751 | 777 | |
| 752 | - if (file_exists($packagesdir . '/temp')) |
|
| 753 | - deltree($packagesdir . '/temp'); |
|
| 778 | + if (file_exists($packagesdir . '/temp')) { |
|
| 779 | + deltree($packagesdir . '/temp'); |
|
| 780 | + } |
|
| 754 | 781 | |
| 755 | 782 | if (!empty($chmod_files)) |
| 756 | 783 | { |
@@ -775,8 +802,9 @@ discard block |
||
| 775 | 802 | checkSession(); |
| 776 | 803 | |
| 777 | 804 | // If there's no file, what are we installing? |
| 778 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 779 | - redirectexit('action=admin;area=packages'); |
|
| 805 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 806 | + redirectexit('action=admin;area=packages'); |
|
| 807 | + } |
|
| 780 | 808 | $context['filename'] = $_REQUEST['package']; |
| 781 | 809 | |
| 782 | 810 | // If this is an uninstall, we'll have an id. |
@@ -797,51 +825,55 @@ discard block |
||
| 797 | 825 | |
| 798 | 826 | $context['sub_template'] = 'extract_package'; |
| 799 | 827 | |
| 800 | - if (!file_exists($packagesdir . '/' . $context['filename'])) |
|
| 801 | - fatal_lang_error('package_no_file', false); |
|
| 828 | + if (!file_exists($packagesdir . '/' . $context['filename'])) { |
|
| 829 | + fatal_lang_error('package_no_file', false); |
|
| 830 | + } |
|
| 802 | 831 | |
| 803 | 832 | // Load up the package FTP information? |
| 804 | 833 | create_chmod_control(array(), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=' . $_REQUEST['sa'] . ';package=' . $_REQUEST['package'])); |
| 805 | 834 | |
| 806 | 835 | // Make sure temp directory exists and is empty! |
| 807 | - if (file_exists($packagesdir . '/temp')) |
|
| 808 | - deltree($packagesdir . '/temp', false); |
|
| 809 | - else |
|
| 810 | - mktree($packagesdir . '/temp', 0777); |
|
| 836 | + if (file_exists($packagesdir . '/temp')) { |
|
| 837 | + deltree($packagesdir . '/temp', false); |
|
| 838 | + } else { |
|
| 839 | + mktree($packagesdir . '/temp', 0777); |
|
| 840 | + } |
|
| 811 | 841 | |
| 812 | 842 | // Let the unpacker do the work. |
| 813 | 843 | if (is_file($packagesdir . '/' . $context['filename'])) |
| 814 | 844 | { |
| 815 | 845 | $context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 816 | 846 | |
| 817 | - if (!file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 818 | - foreach ($context['extracted_files'] as $file) |
|
| 847 | + if (!file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 848 | + foreach ($context['extracted_files'] as $file) |
|
| 819 | 849 | if (basename($file['filename']) == 'package-info.xml') |
| 820 | 850 | { |
| 821 | 851 | $context['base_path'] = dirname($file['filename']) . '/'; |
| 852 | + } |
|
| 822 | 853 | break; |
| 823 | 854 | } |
| 824 | 855 | |
| 825 | - if (!isset($context['base_path'])) |
|
| 826 | - $context['base_path'] = ''; |
|
| 827 | - } |
|
| 828 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 856 | + if (!isset($context['base_path'])) { |
|
| 857 | + $context['base_path'] = ''; |
|
| 858 | + } |
|
| 859 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 829 | 860 | { |
| 830 | 861 | copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 831 | 862 | $context['extracted_files'] = listtree($packagesdir . '/temp'); |
| 832 | 863 | $context['base_path'] = ''; |
| 864 | + } else { |
|
| 865 | + fatal_lang_error('no_access', false); |
|
| 833 | 866 | } |
| 834 | - else |
|
| 835 | - fatal_lang_error('no_access', false); |
|
| 836 | 867 | |
| 837 | 868 | // Are we installing this into any custom themes? |
| 838 | 869 | $custom_themes = array(1); |
| 839 | 870 | $known_themes = explode(',', $modSettings['knownThemes']); |
| 840 | 871 | if (!empty($_POST['custom_theme'])) |
| 841 | 872 | { |
| 842 | - foreach ($_POST['custom_theme'] as $tid) |
|
| 843 | - if (in_array($tid, $known_themes)) |
|
| 873 | + foreach ($_POST['custom_theme'] as $tid) { |
|
| 874 | + if (in_array($tid, $known_themes)) |
|
| 844 | 875 | $custom_themes[] = (int) $tid; |
| 876 | + } |
|
| 845 | 877 | } |
| 846 | 878 | |
| 847 | 879 | // Now load up the paths of the themes that we need to know about. |
@@ -858,8 +890,9 @@ discard block |
||
| 858 | 890 | ); |
| 859 | 891 | $theme_paths = array(); |
| 860 | 892 | $themes_installed = array(1); |
| 861 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 862 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 893 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 894 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 895 | + } |
|
| 863 | 896 | $smcFunc['db_free_result']($request); |
| 864 | 897 | |
| 865 | 898 | // Are there any theme copying that we want to take place? |
@@ -871,11 +904,13 @@ discard block |
||
| 871 | 904 | { |
| 872 | 905 | foreach ($_POST['theme_changes'] as $change) |
| 873 | 906 | { |
| 874 | - if (empty($change)) |
|
| 875 | - continue; |
|
| 907 | + if (empty($change)) { |
|
| 908 | + continue; |
|
| 909 | + } |
|
| 876 | 910 | $theme_data = $smcFunc['json_decode'](base64_decode($change), true); |
| 877 | - if (empty($theme_data['type'])) |
|
| 878 | - continue; |
|
| 911 | + if (empty($theme_data['type'])) { |
|
| 912 | + continue; |
|
| 913 | + } |
|
| 879 | 914 | |
| 880 | 915 | $themes_installed[] = $theme_data['id']; |
| 881 | 916 | $context['theme_copies'][$theme_data['type']][$theme_data['orig']][] = $theme_data['future']; |
@@ -884,8 +919,9 @@ discard block |
||
| 884 | 919 | |
| 885 | 920 | // Get the package info... |
| 886 | 921 | $packageInfo = getPackageInfo($context['filename']); |
| 887 | - if (!is_array($packageInfo)) |
|
| 888 | - fatal_lang_error($packageInfo); |
|
| 922 | + if (!is_array($packageInfo)) { |
|
| 923 | + fatal_lang_error($packageInfo); |
|
| 924 | + } |
|
| 889 | 925 | |
| 890 | 926 | $packageInfo['filename'] = $context['filename']; |
| 891 | 927 | |
@@ -897,8 +933,9 @@ discard block |
||
| 897 | 933 | { |
| 898 | 934 | $_SESSION['last_backup_for'] = $context['filename'] . ($context['uninstalling'] ? '$$' : '$'); |
| 899 | 935 | $result = package_create_backup(($context['uninstalling'] ? 'backup_' : 'before_') . strtok($context['filename'], '.')); |
| 900 | - if (!$result) |
|
| 901 | - fatal_lang_error('could_not_package_backup', false); |
|
| 936 | + if (!$result) { |
|
| 937 | + fatal_lang_error('could_not_package_backup', false); |
|
| 938 | + } |
|
| 902 | 939 | } |
| 903 | 940 | |
| 904 | 941 | // The mod isn't installed.... unless proven otherwise. |
@@ -938,35 +975,38 @@ discard block |
||
| 938 | 975 | $install_log = parsePackageInfo($packageInfo['xml'], false, 'uninstall'); |
| 939 | 976 | |
| 940 | 977 | // Gadzooks! There's no uninstaller at all!? |
| 941 | - if (empty($install_log)) |
|
| 942 | - fatal_lang_error('package_uninstall_cannot', false); |
|
| 978 | + if (empty($install_log)) { |
|
| 979 | + fatal_lang_error('package_uninstall_cannot', false); |
|
| 980 | + } |
|
| 943 | 981 | |
| 944 | 982 | // They can only uninstall from what it was originally installed into. |
| 945 | - foreach ($theme_paths as $id => $data) |
|
| 946 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 983 | + foreach ($theme_paths as $id => $data) { |
|
| 984 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 947 | 985 | unset($theme_paths[$id]); |
| 948 | - } |
|
| 949 | - elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 986 | + } |
|
| 987 | + } elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 950 | 988 | { |
| 951 | 989 | // Look for an upgrade... |
| 952 | 990 | $install_log = parsePackageInfo($packageInfo['xml'], false, 'upgrade', $old_version); |
| 953 | 991 | |
| 954 | 992 | // There was no upgrade.... |
| 955 | - if (empty($install_log)) |
|
| 956 | - $context['is_installed'] = true; |
|
| 957 | - else |
|
| 993 | + if (empty($install_log)) { |
|
| 994 | + $context['is_installed'] = true; |
|
| 995 | + } else |
|
| 958 | 996 | { |
| 959 | 997 | // Upgrade previous themes only! |
| 960 | - foreach ($theme_paths as $id => $data) |
|
| 961 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 998 | + foreach ($theme_paths as $id => $data) { |
|
| 999 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 962 | 1000 | unset($theme_paths[$id]); |
| 1001 | + } |
|
| 963 | 1002 | } |
| 1003 | + } elseif (isset($old_version) && $old_version == $packageInfo['version']) { |
|
| 1004 | + $context['is_installed'] = true; |
|
| 964 | 1005 | } |
| 965 | - elseif (isset($old_version) && $old_version == $packageInfo['version']) |
|
| 966 | - $context['is_installed'] = true; |
|
| 967 | 1006 | |
| 968 | - if (!isset($old_version) || $context['is_installed']) |
|
| 969 | - $install_log = parsePackageInfo($packageInfo['xml'], false, 'install'); |
|
| 1007 | + if (!isset($old_version) || $context['is_installed']) { |
|
| 1008 | + $install_log = parsePackageInfo($packageInfo['xml'], false, 'install'); |
|
| 1009 | + } |
|
| 970 | 1010 | |
| 971 | 1011 | $context['install_finished'] = false; |
| 972 | 1012 | |
@@ -983,37 +1023,39 @@ discard block |
||
| 983 | 1023 | |
| 984 | 1024 | if ($action['type'] == 'modification' && !empty($action['filename'])) |
| 985 | 1025 | { |
| 986 | - if ($action['boardmod']) |
|
| 987 | - $mod_actions = parseBoardMod(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 988 | - else |
|
| 989 | - $mod_actions = parseModification(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 1026 | + if ($action['boardmod']) { |
|
| 1027 | + $mod_actions = parseBoardMod(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 1028 | + } else { |
|
| 1029 | + $mod_actions = parseModification(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 1030 | + } |
|
| 990 | 1031 | |
| 991 | 1032 | // Any errors worth noting? |
| 992 | 1033 | foreach ($mod_actions as $key => $modAction) |
| 993 | 1034 | { |
| 994 | - if ($modAction['type'] == 'failure') |
|
| 995 | - $failed_steps[] = array( |
|
| 1035 | + if ($modAction['type'] == 'failure') { |
|
| 1036 | + $failed_steps[] = array( |
|
| 996 | 1037 | 'file' => $modAction['filename'], |
| 997 | 1038 | 'large_step' => $failed_count, |
| 998 | 1039 | 'sub_step' => $key, |
| 999 | 1040 | 'theme' => 1, |
| 1000 | 1041 | ); |
| 1042 | + } |
|
| 1001 | 1043 | |
| 1002 | 1044 | // Gather the themes we installed into. |
| 1003 | - if (!empty($modAction['is_custom'])) |
|
| 1004 | - $themes_installed[] = $modAction['is_custom']; |
|
| 1045 | + if (!empty($modAction['is_custom'])) { |
|
| 1046 | + $themes_installed[] = $modAction['is_custom']; |
|
| 1047 | + } |
|
| 1005 | 1048 | } |
| 1006 | - } |
|
| 1007 | - elseif ($action['type'] == 'code' && !empty($action['filename'])) |
|
| 1049 | + } elseif ($action['type'] == 'code' && !empty($action['filename'])) |
|
| 1008 | 1050 | { |
| 1009 | 1051 | // This is just here as reference for what is available. |
| 1010 | 1052 | global $txt, $boarddir, $sourcedir, $modSettings, $context, $settings, $forum_version, $smcFunc; |
| 1011 | 1053 | |
| 1012 | 1054 | // Now include the file and be done with it ;). |
| 1013 | - if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
|
| 1014 | - require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1015 | - } |
|
| 1016 | - elseif ($action['type'] == 'credits') |
|
| 1055 | + if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) { |
|
| 1056 | + require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1057 | + } |
|
| 1058 | + } elseif ($action['type'] == 'credits') |
|
| 1017 | 1059 | { |
| 1018 | 1060 | // Time to build the billboard |
| 1019 | 1061 | $credits_tag = array( |
@@ -1023,13 +1065,13 @@ discard block |
||
| 1023 | 1065 | 'copyright' => $action['copyright'], |
| 1024 | 1066 | 'title' => $action['title'], |
| 1025 | 1067 | ); |
| 1026 | - } |
|
| 1027 | - elseif ($action['type'] == 'hook' && isset($action['hook'], $action['function'])) |
|
| 1068 | + } elseif ($action['type'] == 'hook' && isset($action['hook'], $action['function'])) |
|
| 1028 | 1069 | { |
| 1029 | - if ($action['reverse']) |
|
| 1030 | - remove_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1031 | - else |
|
| 1032 | - add_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1070 | + if ($action['reverse']) { |
|
| 1071 | + remove_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1072 | + } else { |
|
| 1073 | + add_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1074 | + } |
|
| 1033 | 1075 | } |
| 1034 | 1076 | // Only do the database changes on uninstall if requested. |
| 1035 | 1077 | elseif ($action['type'] == 'database' && !empty($action['filename']) && (!$context['uninstalling'] || !empty($_POST['do_db_changes']))) |
@@ -1042,8 +1084,9 @@ discard block |
||
| 1042 | 1084 | db_extend('packages'); |
| 1043 | 1085 | |
| 1044 | 1086 | // Let the file work its magic ;) |
| 1045 | - if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
|
| 1046 | - require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1087 | + if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) { |
|
| 1088 | + require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1089 | + } |
|
| 1047 | 1090 | } |
| 1048 | 1091 | // Handle a redirect... |
| 1049 | 1092 | elseif ($action['type'] == 'redirect' && !empty($action['redirect_url'])) |
@@ -1125,8 +1168,9 @@ discard block |
||
| 1125 | 1168 | reloadSettings(); |
| 1126 | 1169 | |
| 1127 | 1170 | // Any db changes from older version? |
| 1128 | - if (!empty($old_db_changes)) |
|
| 1129 | - $db_package_log = empty($db_package_log) ? $old_db_changes : array_merge($old_db_changes, $db_package_log); |
|
| 1171 | + if (!empty($old_db_changes)) { |
|
| 1172 | + $db_package_log = empty($db_package_log) ? $old_db_changes : array_merge($old_db_changes, $db_package_log); |
|
| 1173 | + } |
|
| 1130 | 1174 | |
| 1131 | 1175 | // If there are some database changes we might want to remove then filter them out. |
| 1132 | 1176 | if (!empty($db_package_log)) |
@@ -1142,22 +1186,24 @@ discard block |
||
| 1142 | 1186 | */ |
| 1143 | 1187 | function sort_table_first($a, $b) |
| 1144 | 1188 | { |
| 1145 | - if ($a[0] == $b[0]) |
|
| 1146 | - return 0; |
|
| 1189 | + if ($a[0] == $b[0]) { |
|
| 1190 | + return 0; |
|
| 1191 | + } |
|
| 1147 | 1192 | return $a[0] == 'remove_table' ? -1 : 1; |
| 1148 | 1193 | } |
| 1149 | 1194 | usort($db_package_log, 'sort_table_first'); |
| 1150 | 1195 | foreach ($db_package_log as $k => $log) |
| 1151 | 1196 | { |
| 1152 | - if ($log[0] == 'remove_table') |
|
| 1153 | - $tables[] = $log[1]; |
|
| 1154 | - elseif (in_array($log[1], $tables)) |
|
| 1155 | - unset($db_package_log[$k]); |
|
| 1197 | + if ($log[0] == 'remove_table') { |
|
| 1198 | + $tables[] = $log[1]; |
|
| 1199 | + } elseif (in_array($log[1], $tables)) { |
|
| 1200 | + unset($db_package_log[$k]); |
|
| 1201 | + } |
|
| 1156 | 1202 | } |
| 1157 | 1203 | $db_changes = $smcFunc['json_encode']($db_package_log); |
| 1204 | + } else { |
|
| 1205 | + $db_changes = ''; |
|
| 1158 | 1206 | } |
| 1159 | - else |
|
| 1160 | - $db_changes = ''; |
|
| 1161 | 1207 | |
| 1162 | 1208 | // What themes did we actually install? |
| 1163 | 1209 | $themes_installed = array_unique($themes_installed); |
@@ -1206,18 +1252,20 @@ discard block |
||
| 1206 | 1252 | |
| 1207 | 1253 | foreach ($db_changes as $change) |
| 1208 | 1254 | { |
| 1209 | - if ($change[0] == 'remove_table' && isset($change[1])) |
|
| 1210 | - $smcFunc['db_drop_table']($change[1]); |
|
| 1211 | - elseif ($change[0] == 'remove_column' && isset($change[2])) |
|
| 1212 | - $smcFunc['db_remove_column']($change[1], $change[2]); |
|
| 1213 | - elseif ($change[0] == 'remove_index' && isset($change[2])) |
|
| 1214 | - $smcFunc['db_remove_index']($change[1], $change[2]); |
|
| 1255 | + if ($change[0] == 'remove_table' && isset($change[1])) { |
|
| 1256 | + $smcFunc['db_drop_table']($change[1]); |
|
| 1257 | + } elseif ($change[0] == 'remove_column' && isset($change[2])) { |
|
| 1258 | + $smcFunc['db_remove_column']($change[1], $change[2]); |
|
| 1259 | + } elseif ($change[0] == 'remove_index' && isset($change[2])) { |
|
| 1260 | + $smcFunc['db_remove_index']($change[1], $change[2]); |
|
| 1261 | + } |
|
| 1215 | 1262 | } |
| 1216 | 1263 | } |
| 1217 | 1264 | |
| 1218 | 1265 | // Clean house... get rid of the evidence ;). |
| 1219 | - if (file_exists($packagesdir . '/temp')) |
|
| 1220 | - deltree($packagesdir . '/temp'); |
|
| 1266 | + if (file_exists($packagesdir . '/temp')) { |
|
| 1267 | + deltree($packagesdir . '/temp'); |
|
| 1268 | + } |
|
| 1221 | 1269 | |
| 1222 | 1270 | // Log what we just did. |
| 1223 | 1271 | logAction($context['uninstalling'] ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => $smcFunc['htmlspecialchars']($packageInfo['name']), 'version' => $smcFunc['htmlspecialchars']($packageInfo['version'])), 'admin'); |
@@ -1239,8 +1287,9 @@ discard block |
||
| 1239 | 1287 | require_once($sourcedir . '/Subs-Package.php'); |
| 1240 | 1288 | |
| 1241 | 1289 | // No package? Show him or her the door. |
| 1242 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 1243 | - redirectexit('action=admin;area=packages'); |
|
| 1290 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 1291 | + redirectexit('action=admin;area=packages'); |
|
| 1292 | + } |
|
| 1244 | 1293 | |
| 1245 | 1294 | $context['linktree'][] = array( |
| 1246 | 1295 | 'url' => $scripturl . '?action=admin;area=packages;sa=list;package=' . $_REQUEST['package'], |
@@ -1253,11 +1302,12 @@ discard block |
||
| 1253 | 1302 | $context['filename'] = $_REQUEST['package']; |
| 1254 | 1303 | |
| 1255 | 1304 | // Let the unpacker do the work. |
| 1256 | - if (is_file($packagesdir . '/' . $context['filename'])) |
|
| 1257 | - $context['files'] = read_tgz_file($packagesdir . '/' . $context['filename'], null); |
|
| 1258 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 1259 | - $context['files'] = listtree($packagesdir . '/' . $context['filename']); |
|
| 1260 | -} |
|
| 1305 | + if (is_file($packagesdir . '/' . $context['filename'])) { |
|
| 1306 | + $context['files'] = read_tgz_file($packagesdir . '/' . $context['filename'], null); |
|
| 1307 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) { |
|
| 1308 | + $context['files'] = listtree($packagesdir . '/' . $context['filename']); |
|
| 1309 | + } |
|
| 1310 | + } |
|
| 1261 | 1311 | |
| 1262 | 1312 | /** |
| 1263 | 1313 | * Display one of the files in a package. |
@@ -1269,22 +1319,25 @@ discard block |
||
| 1269 | 1319 | require_once($sourcedir . '/Subs-Package.php'); |
| 1270 | 1320 | |
| 1271 | 1321 | // No package? Show him or her the door. |
| 1272 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 1273 | - redirectexit('action=admin;area=packages'); |
|
| 1322 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 1323 | + redirectexit('action=admin;area=packages'); |
|
| 1324 | + } |
|
| 1274 | 1325 | |
| 1275 | 1326 | // No file? Show him or her the door. |
| 1276 | - if (!isset($_REQUEST['file']) || $_REQUEST['file'] == '') |
|
| 1277 | - redirectexit('action=admin;area=packages'); |
|
| 1327 | + if (!isset($_REQUEST['file']) || $_REQUEST['file'] == '') { |
|
| 1328 | + redirectexit('action=admin;area=packages'); |
|
| 1329 | + } |
|
| 1278 | 1330 | |
| 1279 | 1331 | $_REQUEST['package'] = preg_replace('~[\.]+~', '.', strtr($_REQUEST['package'], array('/' => '_', '\\' => '_'))); |
| 1280 | 1332 | $_REQUEST['file'] = preg_replace('~[\.]+~', '.', $_REQUEST['file']); |
| 1281 | 1333 | |
| 1282 | 1334 | if (isset($_REQUEST['raw'])) |
| 1283 | 1335 | { |
| 1284 | - if (is_file($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1285 | - echo read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true); |
|
| 1286 | - elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1287 | - echo file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file']); |
|
| 1336 | + if (is_file($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1337 | + echo read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true); |
|
| 1338 | + } elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1339 | + echo file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file']); |
|
| 1340 | + } |
|
| 1288 | 1341 | |
| 1289 | 1342 | obExit(false); |
| 1290 | 1343 | } |
@@ -1301,17 +1354,19 @@ discard block |
||
| 1301 | 1354 | $context['filename'] = $_REQUEST['file']; |
| 1302 | 1355 | |
| 1303 | 1356 | // Let the unpacker do the work.... but make sure we handle images properly. |
| 1304 | - if (in_array(strtolower(strrchr($_REQUEST['file'], '.')), array('.bmp', '.gif', '.jpeg', '.jpg', '.png'))) |
|
| 1305 | - $context['filedata'] = '<img src="' . $scripturl . '?action=admin;area=packages;sa=examine;package=' . $_REQUEST['package'] . ';file=' . $_REQUEST['file'] . ';raw" alt="' . $_REQUEST['file'] . '">'; |
|
| 1306 | - else |
|
| 1357 | + if (in_array(strtolower(strrchr($_REQUEST['file'], '.')), array('.bmp', '.gif', '.jpeg', '.jpg', '.png'))) { |
|
| 1358 | + $context['filedata'] = '<img src="' . $scripturl . '?action=admin;area=packages;sa=examine;package=' . $_REQUEST['package'] . ';file=' . $_REQUEST['file'] . ';raw" alt="' . $_REQUEST['file'] . '">'; |
|
| 1359 | + } else |
|
| 1307 | 1360 | { |
| 1308 | - if (is_file($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1309 | - $context['filedata'] = $smcFunc['htmlspecialchars'](read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true)); |
|
| 1310 | - elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1311 | - $context['filedata'] = $smcFunc['htmlspecialchars'](file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file'])); |
|
| 1361 | + if (is_file($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1362 | + $context['filedata'] = $smcFunc['htmlspecialchars'](read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true)); |
|
| 1363 | + } elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1364 | + $context['filedata'] = $smcFunc['htmlspecialchars'](file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file'])); |
|
| 1365 | + } |
|
| 1312 | 1366 | |
| 1313 | - if (strtolower(strrchr($_REQUEST['file'], '.')) == '.php') |
|
| 1314 | - $context['filedata'] = highlight_php_code($context['filedata']); |
|
| 1367 | + if (strtolower(strrchr($_REQUEST['file'], '.')) == '.php') { |
|
| 1368 | + $context['filedata'] = highlight_php_code($context['filedata']); |
|
| 1369 | + } |
|
| 1315 | 1370 | } |
| 1316 | 1371 | } |
| 1317 | 1372 | |
@@ -1326,8 +1381,9 @@ discard block |
||
| 1326 | 1381 | checkSession('get'); |
| 1327 | 1382 | |
| 1328 | 1383 | // Ack, don't allow deletion of arbitrary files here, could become a security hole somehow! |
| 1329 | - if (!isset($_GET['package']) || $_GET['package'] == 'index.php' || $_GET['package'] == 'backups') |
|
| 1330 | - redirectexit('action=admin;area=packages;sa=browse'); |
|
| 1384 | + if (!isset($_GET['package']) || $_GET['package'] == 'index.php' || $_GET['package'] == 'backups') { |
|
| 1385 | + redirectexit('action=admin;area=packages;sa=browse'); |
|
| 1386 | + } |
|
| 1331 | 1387 | $_GET['package'] = preg_replace('~[\.]+~', '.', strtr($_GET['package'], array('/' => '_', '\\' => '_'))); |
| 1332 | 1388 | |
| 1333 | 1389 | // Can't delete what's not there. |
@@ -1335,9 +1391,9 @@ discard block |
||
| 1335 | 1391 | { |
| 1336 | 1392 | create_chmod_control(array($packagesdir . '/' . $_GET['package']), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=remove;package=' . $_GET['package'], 'crash_on_error' => true)); |
| 1337 | 1393 | |
| 1338 | - if (is_dir($packagesdir . '/' . $_GET['package'])) |
|
| 1339 | - deltree($packagesdir . '/' . $_GET['package']); |
|
| 1340 | - else |
|
| 1394 | + if (is_dir($packagesdir . '/' . $_GET['package'])) { |
|
| 1395 | + deltree($packagesdir . '/' . $_GET['package']); |
|
| 1396 | + } else |
|
| 1341 | 1397 | { |
| 1342 | 1398 | smf_chmod($packagesdir . '/' . $_GET['package'], 0777); |
| 1343 | 1399 | unlink($packagesdir . '/' . $_GET['package']); |
@@ -1385,8 +1441,9 @@ discard block |
||
| 1385 | 1441 | 'data' => array( |
| 1386 | 1442 | 'function' => function($package_md5) use ($type, &$context) |
| 1387 | 1443 | { |
| 1388 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1389 | - return $context['available_' . $type . ''][$package_md5]['sort_id']; |
|
| 1444 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1445 | + return $context['available_' . $type . ''][$package_md5]['sort_id']; |
|
| 1446 | + } |
|
| 1390 | 1447 | }, |
| 1391 | 1448 | ), |
| 1392 | 1449 | 'sort' => array( |
@@ -1402,8 +1459,9 @@ discard block |
||
| 1402 | 1459 | 'data' => array( |
| 1403 | 1460 | 'function' => function($package_md5) use ($type, &$context) |
| 1404 | 1461 | { |
| 1405 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1406 | - return $context['available_' . $type . ''][$package_md5]['name']; |
|
| 1462 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1463 | + return $context['available_' . $type . ''][$package_md5]['name']; |
|
| 1464 | + } |
|
| 1407 | 1465 | }, |
| 1408 | 1466 | ), |
| 1409 | 1467 | 'sort' => array( |
@@ -1418,8 +1476,9 @@ discard block |
||
| 1418 | 1476 | 'data' => array( |
| 1419 | 1477 | 'function' => function($package_md5) use ($type, &$context) |
| 1420 | 1478 | { |
| 1421 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1422 | - return $context['available_' . $type . ''][$package_md5]['version']; |
|
| 1479 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1480 | + return $context['available_' . $type . ''][$package_md5]['version']; |
|
| 1481 | + } |
|
| 1423 | 1482 | }, |
| 1424 | 1483 | ), |
| 1425 | 1484 | 'sort' => array( |
@@ -1434,8 +1493,9 @@ discard block |
||
| 1434 | 1493 | 'data' => array( |
| 1435 | 1494 | 'function' => function($package_md5) use ($type, $txt, &$context) |
| 1436 | 1495 | { |
| 1437 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1438 | - return !empty($context['available_' . $type . ''][$package_md5]['time_installed']) ? timeformat($context['available_' . $type . ''][$package_md5]['time_installed']) : $txt['not_applicable']; |
|
| 1496 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1497 | + return !empty($context['available_' . $type . ''][$package_md5]['time_installed']) ? timeformat($context['available_' . $type . ''][$package_md5]['time_installed']) : $txt['not_applicable']; |
|
| 1498 | + } |
|
| 1439 | 1499 | }, |
| 1440 | 1500 | 'class' => 'smalltext', |
| 1441 | 1501 | ), |
@@ -1451,28 +1511,30 @@ discard block |
||
| 1451 | 1511 | 'data' => array( |
| 1452 | 1512 | 'function' => function($package_md5) use ($type, &$context, $scripturl, $txt) |
| 1453 | 1513 | { |
| 1454 | - if (!isset($context['available_' . $type . ''][$package_md5])) |
|
| 1455 | - return ''; |
|
| 1514 | + if (!isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1515 | + return ''; |
|
| 1516 | + } |
|
| 1456 | 1517 | |
| 1457 | 1518 | // Rewrite shortcut |
| 1458 | 1519 | $package = $context['available_' . $type . ''][$package_md5]; |
| 1459 | 1520 | $return = ''; |
| 1460 | 1521 | |
| 1461 | - if ($package['can_uninstall']) |
|
| 1462 | - $return = ' |
|
| 1522 | + if ($package['can_uninstall']) { |
|
| 1523 | + $return = ' |
|
| 1463 | 1524 | <a href="' . $scripturl . '?action=admin;area=packages;sa=uninstall;package=' . $package['filename'] . ';pid=' . $package['installed_id'] . '" class="button">' . $txt['uninstall'] . '</a>'; |
| 1464 | - elseif ($package['can_emulate_uninstall']) |
|
| 1465 | - $return = ' |
|
| 1525 | + } elseif ($package['can_emulate_uninstall']) { |
|
| 1526 | + $return = ' |
|
| 1466 | 1527 | <a href="' . $scripturl . '?action=admin;area=packages;sa=uninstall;ve=' . $package['can_emulate_uninstall'] . ';package=' . $package['filename'] . ';pid=' . $package['installed_id'] . '" class="button">' . $txt['package_emulate_uninstall'] . ' ' . $package['can_emulate_uninstall'] . '</a>'; |
| 1467 | - elseif ($package['can_upgrade']) |
|
| 1468 | - $return = ' |
|
| 1528 | + } elseif ($package['can_upgrade']) { |
|
| 1529 | + $return = ' |
|
| 1469 | 1530 | <a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $package['filename'] . '" class="button">' . $txt['package_upgrade'] . '</a>'; |
| 1470 | - elseif ($package['can_install']) |
|
| 1471 | - $return = ' |
|
| 1531 | + } elseif ($package['can_install']) { |
|
| 1532 | + $return = ' |
|
| 1472 | 1533 | <a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $package['filename'] . '" class="button">' . $txt['install_mod'] . '</a>'; |
| 1473 | - elseif ($package['can_emulate_install']) |
|
| 1474 | - $return = ' |
|
| 1534 | + } elseif ($package['can_emulate_install']) { |
|
| 1535 | + $return = ' |
|
| 1475 | 1536 | <a href="' . $scripturl . '?action=admin;area=packages;sa=install;ve=' . $package['can_emulate_install'] . ';package=' . $package['filename'] . '" class="button">' . $txt['package_emulate_install'] . ' ' . $package['can_emulate_install'] . '</a>'; |
| 1537 | + } |
|
| 1476 | 1538 | |
| 1477 | 1539 | return $return . ' |
| 1478 | 1540 | <a href="' . $scripturl . '?action=admin;area=packages;sa=list;package=' . $package['filename'] . '" class="button">' . $txt['list_files'] . '</a> |
@@ -1537,12 +1599,14 @@ discard block |
||
| 1537 | 1599 | static $packages, $installed_mods; |
| 1538 | 1600 | |
| 1539 | 1601 | // Start things up |
| 1540 | - if (!isset($packages[$params])) |
|
| 1541 | - $packages[$params] = array(); |
|
| 1602 | + if (!isset($packages[$params])) { |
|
| 1603 | + $packages[$params] = array(); |
|
| 1604 | + } |
|
| 1542 | 1605 | |
| 1543 | 1606 | // We need the packages directory to be writable for this. |
| 1544 | - if (!@is_writable($packagesdir)) |
|
| 1545 | - create_chmod_control(array($packagesdir), array('destination_url' => $scripturl . '?action=admin;area=packages', 'crash_on_error' => true)); |
|
| 1607 | + if (!@is_writable($packagesdir)) { |
|
| 1608 | + create_chmod_control(array($packagesdir), array('destination_url' => $scripturl . '?action=admin;area=packages', 'crash_on_error' => true)); |
|
| 1609 | + } |
|
| 1546 | 1610 | |
| 1547 | 1611 | $the_version = strtr($forum_version, array('SMF ' => '')); |
| 1548 | 1612 | |
@@ -1550,41 +1614,44 @@ discard block |
||
| 1550 | 1614 | if (isset($_GET['version_emulate']) && strtr($_GET['version_emulate'], array('SMF ' => '')) == $the_version) |
| 1551 | 1615 | { |
| 1552 | 1616 | unset($_SESSION['version_emulate']); |
| 1553 | - } |
|
| 1554 | - elseif (isset($_GET['version_emulate'])) |
|
| 1617 | + } elseif (isset($_GET['version_emulate'])) |
|
| 1555 | 1618 | { |
| 1556 | - if (($_GET['version_emulate'] === 0 || $_GET['version_emulate'] === $forum_version) && isset($_SESSION['version_emulate'])) |
|
| 1557 | - unset($_SESSION['version_emulate']); |
|
| 1558 | - elseif ($_GET['version_emulate'] !== 0) |
|
| 1559 | - $_SESSION['version_emulate'] = strtr($_GET['version_emulate'], array('-' => ' ', '+' => ' ', 'SMF ' => '')); |
|
| 1619 | + if (($_GET['version_emulate'] === 0 || $_GET['version_emulate'] === $forum_version) && isset($_SESSION['version_emulate'])) { |
|
| 1620 | + unset($_SESSION['version_emulate']); |
|
| 1621 | + } elseif ($_GET['version_emulate'] !== 0) { |
|
| 1622 | + $_SESSION['version_emulate'] = strtr($_GET['version_emulate'], array('-' => ' ', '+' => ' ', 'SMF ' => '')); |
|
| 1623 | + } |
|
| 1560 | 1624 | } |
| 1561 | 1625 | if (!empty($_SESSION['version_emulate'])) |
| 1562 | 1626 | { |
| 1563 | 1627 | $context['forum_version'] = 'SMF ' . $_SESSION['version_emulate']; |
| 1564 | 1628 | $the_version = $_SESSION['version_emulate']; |
| 1565 | 1629 | } |
| 1566 | - if (isset($_SESSION['single_version_emulate'])) |
|
| 1567 | - unset($_SESSION['single_version_emulate']); |
|
| 1630 | + if (isset($_SESSION['single_version_emulate'])) { |
|
| 1631 | + unset($_SESSION['single_version_emulate']); |
|
| 1632 | + } |
|
| 1568 | 1633 | |
| 1569 | 1634 | if (empty($installed_mods)) |
| 1570 | 1635 | { |
| 1571 | 1636 | $instmods = loadInstalledPackages(); |
| 1572 | 1637 | $installed_mods = array(); |
| 1573 | 1638 | // Look through the list of installed mods... |
| 1574 | - foreach ($instmods as $installed_mod) |
|
| 1575 | - $installed_mods[$installed_mod['package_id']] = array( |
|
| 1639 | + foreach ($instmods as $installed_mod) { |
|
| 1640 | + $installed_mods[$installed_mod['package_id']] = array( |
|
| 1576 | 1641 | 'id' => $installed_mod['id'], |
| 1577 | 1642 | 'version' => $installed_mod['version'], |
| 1578 | 1643 | 'time_installed' => $installed_mod['time_installed'], |
| 1579 | 1644 | ); |
| 1645 | + } |
|
| 1580 | 1646 | |
| 1581 | 1647 | // Get a list of all the ids installed, so the latest packages won't include already installed ones. |
| 1582 | 1648 | $context['installed_mods'] = array_keys($installed_mods); |
| 1583 | 1649 | } |
| 1584 | 1650 | |
| 1585 | - if (empty($packages)) |
|
| 1586 | - foreach ($context['modification_types'] as $type) |
|
| 1651 | + if (empty($packages)) { |
|
| 1652 | + foreach ($context['modification_types'] as $type) |
|
| 1587 | 1653 | $packages[$type] = array(); |
| 1654 | + } |
|
| 1588 | 1655 | |
| 1589 | 1656 | if ($dir = @opendir($packagesdir)) |
| 1590 | 1657 | { |
@@ -1600,50 +1667,56 @@ discard block |
||
| 1600 | 1667 | |
| 1601 | 1668 | while ($package = readdir($dir)) |
| 1602 | 1669 | { |
| 1603 | - if ($package == '.' || $package == '..' || $package == 'temp' || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) |
|
| 1604 | - continue; |
|
| 1670 | + if ($package == '.' || $package == '..' || $package == 'temp' || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) { |
|
| 1671 | + continue; |
|
| 1672 | + } |
|
| 1605 | 1673 | |
| 1606 | 1674 | $skip = false; |
| 1607 | - foreach ($context['modification_types'] as $type) |
|
| 1608 | - if (isset($context['available_' . $type][md5($package)])) |
|
| 1675 | + foreach ($context['modification_types'] as $type) { |
|
| 1676 | + if (isset($context['available_' . $type][md5($package)])) |
|
| 1609 | 1677 | $skip = true; |
| 1678 | + } |
|
| 1610 | 1679 | |
| 1611 | - if ($skip) |
|
| 1612 | - continue; |
|
| 1680 | + if ($skip) { |
|
| 1681 | + continue; |
|
| 1682 | + } |
|
| 1613 | 1683 | |
| 1614 | 1684 | // Skip directories or files that are named the same. |
| 1615 | 1685 | if (is_dir($packagesdir . '/' . $package)) |
| 1616 | 1686 | { |
| 1617 | - if (in_array($package, $dirs)) |
|
| 1618 | - continue; |
|
| 1687 | + if (in_array($package, $dirs)) { |
|
| 1688 | + continue; |
|
| 1689 | + } |
|
| 1619 | 1690 | $dirs[] = $package; |
| 1620 | - } |
|
| 1621 | - elseif (substr(strtolower($package), -7) == '.tar.gz') |
|
| 1691 | + } elseif (substr(strtolower($package), -7) == '.tar.gz') |
|
| 1622 | 1692 | { |
| 1623 | - if (in_array(substr($package, 0, -7), $dirs)) |
|
| 1624 | - continue; |
|
| 1693 | + if (in_array(substr($package, 0, -7), $dirs)) { |
|
| 1694 | + continue; |
|
| 1695 | + } |
|
| 1625 | 1696 | $dirs[] = substr($package, 0, -7); |
| 1626 | - } |
|
| 1627 | - elseif (substr(strtolower($package), -4) == '.zip' || substr(strtolower($package), -4) == '.tgz') |
|
| 1697 | + } elseif (substr(strtolower($package), -4) == '.zip' || substr(strtolower($package), -4) == '.tgz') |
|
| 1628 | 1698 | { |
| 1629 | - if (in_array(substr($package, 0, -4), $dirs)) |
|
| 1630 | - continue; |
|
| 1699 | + if (in_array(substr($package, 0, -4), $dirs)) { |
|
| 1700 | + continue; |
|
| 1701 | + } |
|
| 1631 | 1702 | $dirs[] = substr($package, 0, -4); |
| 1632 | 1703 | } |
| 1633 | 1704 | |
| 1634 | 1705 | $packageInfo = getPackageInfo($package); |
| 1635 | - if (!is_array($packageInfo)) |
|
| 1636 | - continue; |
|
| 1706 | + if (!is_array($packageInfo)) { |
|
| 1707 | + continue; |
|
| 1708 | + } |
|
| 1637 | 1709 | |
| 1638 | 1710 | if (!empty($packageInfo)) |
| 1639 | 1711 | { |
| 1640 | 1712 | $packageInfo['installed_id'] = isset($installed_mods[$packageInfo['id']]) ? $installed_mods[$packageInfo['id']]['id'] : 0; |
| 1641 | 1713 | $packageInfo['time_installed'] = isset($installed_mods[$packageInfo['id']]) ? $installed_mods[$packageInfo['id']]['time_installed'] : 0; |
| 1642 | 1714 | |
| 1643 | - if (!isset($sort_id[$packageInfo['type']])) |
|
| 1644 | - $packageInfo['sort_id'] = $sort_id['unknown']; |
|
| 1645 | - else |
|
| 1646 | - $packageInfo['sort_id'] = $sort_id[$packageInfo['type']]; |
|
| 1715 | + if (!isset($sort_id[$packageInfo['type']])) { |
|
| 1716 | + $packageInfo['sort_id'] = $sort_id['unknown']; |
|
| 1717 | + } else { |
|
| 1718 | + $packageInfo['sort_id'] = $sort_id[$packageInfo['type']]; |
|
| 1719 | + } |
|
| 1647 | 1720 | |
| 1648 | 1721 | $packageInfo['is_installed'] = isset($installed_mods[$packageInfo['id']]); |
| 1649 | 1722 | $packageInfo['is_current'] = $packageInfo['is_installed'] && ($installed_mods[$packageInfo['id']]['version'] == $packageInfo['version']); |
@@ -1692,10 +1765,11 @@ discard block |
||
| 1692 | 1765 | foreach ($upgrades as $upgrade) |
| 1693 | 1766 | { |
| 1694 | 1767 | // Even if it is for this SMF, is it for the installed version of the mod? |
| 1695 | - if (!$upgrade->exists('@for') || matchPackageVersion($the_version, $upgrade->fetch('@for'))) |
|
| 1696 | - if (!$upgrade->exists('@from') || matchPackageVersion($installed_mods[$packageInfo['id']]['version'], $upgrade->fetch('@from'))) |
|
| 1768 | + if (!$upgrade->exists('@for') || matchPackageVersion($the_version, $upgrade->fetch('@for'))) { |
|
| 1769 | + if (!$upgrade->exists('@from') || matchPackageVersion($installed_mods[$packageInfo['id']]['version'], $upgrade->fetch('@from'))) |
|
| 1697 | 1770 | { |
| 1698 | 1771 | $packageInfo['can_upgrade'] = true; |
| 1772 | + } |
|
| 1699 | 1773 | break; |
| 1700 | 1774 | } |
| 1701 | 1775 | } |
@@ -1772,10 +1846,11 @@ discard block |
||
| 1772 | 1846 | |
| 1773 | 1847 | if (isset($_GET['type']) && $_GET['type'] == $params) |
| 1774 | 1848 | { |
| 1775 | - if (isset($_GET['desc'])) |
|
| 1776 | - krsort($packages[$params]); |
|
| 1777 | - else |
|
| 1778 | - ksort($packages[$params]); |
|
| 1849 | + if (isset($_GET['desc'])) { |
|
| 1850 | + krsort($packages[$params]); |
|
| 1851 | + } else { |
|
| 1852 | + ksort($packages[$params]); |
|
| 1853 | + } |
|
| 1779 | 1854 | } |
| 1780 | 1855 | |
| 1781 | 1856 | return $packages[$params]; |
@@ -1804,10 +1879,11 @@ discard block |
||
| 1804 | 1879 | redirectexit('action=admin;area=packages;sa=options'); |
| 1805 | 1880 | } |
| 1806 | 1881 | |
| 1807 | - if (preg_match('~^/home\d*/([^/]+?)/public_html~', $_SERVER['DOCUMENT_ROOT'], $match)) |
|
| 1808 | - $default_username = $match[1]; |
|
| 1809 | - else |
|
| 1810 | - $default_username = ''; |
|
| 1882 | + if (preg_match('~^/home\d*/([^/]+?)/public_html~', $_SERVER['DOCUMENT_ROOT'], $match)) { |
|
| 1883 | + $default_username = $match[1]; |
|
| 1884 | + } else { |
|
| 1885 | + $default_username = ''; |
|
| 1886 | + } |
|
| 1811 | 1887 | |
| 1812 | 1888 | $context['page_title'] = $txt['package_settings']; |
| 1813 | 1889 | $context['sub_template'] = 'install_options'; |
@@ -1836,8 +1912,9 @@ discard block |
||
| 1836 | 1912 | isAllowedTo('admin_forum'); |
| 1837 | 1913 | |
| 1838 | 1914 | // We need to know the operation key for the search and replace, mod file looking at, is it a board mod? |
| 1839 | - if (!isset($_REQUEST['operation_key'], $_REQUEST['filename']) && !is_numeric($_REQUEST['operation_key'])) |
|
| 1840 | - fatal_lang_error('operation_invalid', 'general'); |
|
| 1915 | + if (!isset($_REQUEST['operation_key'], $_REQUEST['filename']) && !is_numeric($_REQUEST['operation_key'])) { |
|
| 1916 | + fatal_lang_error('operation_invalid', 'general'); |
|
| 1917 | + } |
|
| 1841 | 1918 | |
| 1842 | 1919 | // Load the required file. |
| 1843 | 1920 | require_once($sourcedir . '/Subs-Package.php'); |
@@ -1853,18 +1930,19 @@ discard block |
||
| 1853 | 1930 | { |
| 1854 | 1931 | $context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 1855 | 1932 | |
| 1856 | - if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 1857 | - foreach ($context['extracted_files'] as $file) |
|
| 1933 | + if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 1934 | + foreach ($context['extracted_files'] as $file) |
|
| 1858 | 1935 | if (basename($file['filename']) == 'package-info.xml') |
| 1859 | 1936 | { |
| 1860 | 1937 | $context['base_path'] = dirname($file['filename']) . '/'; |
| 1938 | + } |
|
| 1861 | 1939 | break; |
| 1862 | 1940 | } |
| 1863 | 1941 | |
| 1864 | - if (!isset($context['base_path'])) |
|
| 1865 | - $context['base_path'] = ''; |
|
| 1866 | - } |
|
| 1867 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 1942 | + if (!isset($context['base_path'])) { |
|
| 1943 | + $context['base_path'] = ''; |
|
| 1944 | + } |
|
| 1945 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 1868 | 1946 | { |
| 1869 | 1947 | copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 1870 | 1948 | $context['extracted_files'] = listtree($packagesdir . '/temp'); |
@@ -1885,8 +1963,9 @@ discard block |
||
| 1885 | 1963 | ) |
| 1886 | 1964 | ); |
| 1887 | 1965 | $theme_paths = array(); |
| 1888 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1889 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 1966 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1967 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 1968 | + } |
|
| 1890 | 1969 | $smcFunc['db_free_result']($request); |
| 1891 | 1970 | |
| 1892 | 1971 | // If we're viewing uninstall operations, only consider themes that |
@@ -1911,19 +1990,21 @@ discard block |
||
| 1911 | 1990 | list ($old_themes) = $smcFunc['db_fetch_row']($request); |
| 1912 | 1991 | $old_themes = explode(',', $old_themes); |
| 1913 | 1992 | |
| 1914 | - foreach ($theme_paths as $id => $data) |
|
| 1915 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 1993 | + foreach ($theme_paths as $id => $data) { |
|
| 1994 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 1916 | 1995 | unset($theme_paths[$id]); |
| 1996 | + } |
|
| 1917 | 1997 | } |
| 1918 | 1998 | $smcFunc['db_free_result']($request); |
| 1919 | 1999 | } |
| 1920 | 2000 | } |
| 1921 | 2001 | |
| 1922 | 2002 | // Boardmod? |
| 1923 | - if (isset($_REQUEST['boardmod'])) |
|
| 1924 | - $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 1925 | - else |
|
| 1926 | - $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 2003 | + if (isset($_REQUEST['boardmod'])) { |
|
| 2004 | + $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 2005 | + } else { |
|
| 2006 | + $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 2007 | + } |
|
| 1927 | 2008 | |
| 1928 | 2009 | // Ok lets get the content of the file. |
| 1929 | 2010 | $context['operations'] = array( |
@@ -1979,9 +2060,9 @@ discard block |
||
| 1979 | 2060 | 'path' => $detect_path, |
| 1980 | 2061 | 'form_elements_only' => true, |
| 1981 | 2062 | ); |
| 2063 | + } else { |
|
| 2064 | + $context['ftp_connected'] = true; |
|
| 1982 | 2065 | } |
| 1983 | - else |
|
| 1984 | - $context['ftp_connected'] = true; |
|
| 1985 | 2066 | |
| 1986 | 2067 | // Define the template. |
| 1987 | 2068 | $context['page_title'] = $txt['package_file_perms']; |
@@ -2094,18 +2175,19 @@ discard block |
||
| 2094 | 2175 | { |
| 2095 | 2176 | unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']); |
| 2096 | 2177 | |
| 2097 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 2098 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
| 2178 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 2179 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
| 2180 | + } |
|
| 2099 | 2181 | |
| 2100 | 2182 | // @todo Should we suggest non-current directories be read only? |
| 2101 | - foreach ($modSettings['attachmentUploadDir'] as $dir) |
|
| 2102 | - $context['file_tree'][strtr($dir, array('\\' => '/'))] = array( |
|
| 2183 | + foreach ($modSettings['attachmentUploadDir'] as $dir) { |
|
| 2184 | + $context['file_tree'][strtr($dir, array('\\' => '/'))] = array( |
|
| 2103 | 2185 | 'type' => 'dir', |
| 2104 | 2186 | 'writable_on' => 'restrictive', |
| 2105 | 2187 | ); |
| 2188 | + } |
|
| 2106 | 2189 | |
| 2107 | - } |
|
| 2108 | - elseif (substr($modSettings['attachmentUploadDir'], 0, strlen($boarddir)) != $boarddir) |
|
| 2190 | + } elseif (substr($modSettings['attachmentUploadDir'], 0, strlen($boarddir)) != $boarddir) |
|
| 2109 | 2191 | { |
| 2110 | 2192 | unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']); |
| 2111 | 2193 | $context['file_tree'][strtr($modSettings['attachmentUploadDir'], array('\\' => '/'))] = array( |
@@ -2155,8 +2237,8 @@ discard block |
||
| 2155 | 2237 | ); |
| 2156 | 2238 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2157 | 2239 | { |
| 2158 | - if (substr(strtolower(strtr($row['value'], array('\\' => '/'))), 0, strlen($boarddir) + 7) == strtolower(strtr($boarddir, array('\\' => '/')) . '/Themes')) |
|
| 2159 | - $context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Themes']['contents'][substr($row['value'], strlen($boarddir) + 8)] = array( |
|
| 2240 | + if (substr(strtolower(strtr($row['value'], array('\\' => '/'))), 0, strlen($boarddir) + 7) == strtolower(strtr($boarddir, array('\\' => '/')) . '/Themes')) { |
|
| 2241 | + $context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Themes']['contents'][substr($row['value'], strlen($boarddir) + 8)] = array( |
|
| 2160 | 2242 | 'type' => 'dir_recursive', |
| 2161 | 2243 | 'list_contents' => true, |
| 2162 | 2244 | 'contents' => array( |
@@ -2166,7 +2248,7 @@ discard block |
||
| 2166 | 2248 | ), |
| 2167 | 2249 | ), |
| 2168 | 2250 | ); |
| 2169 | - else |
|
| 2251 | + } else |
|
| 2170 | 2252 | { |
| 2171 | 2253 | $context['file_tree'][strtr($row['value'], array('\\' => '/'))] = array( |
| 2172 | 2254 | 'type' => 'dir_recursive', |
@@ -2183,28 +2265,33 @@ discard block |
||
| 2183 | 2265 | $smcFunc['db_free_result']($request); |
| 2184 | 2266 | |
| 2185 | 2267 | // If we're submitting then let's move on to another function to keep things cleaner.. |
| 2186 | - if (isset($_POST['action_changes'])) |
|
| 2187 | - return PackagePermissionsAction(); |
|
| 2268 | + if (isset($_POST['action_changes'])) { |
|
| 2269 | + return PackagePermissionsAction(); |
|
| 2270 | + } |
|
| 2188 | 2271 | |
| 2189 | 2272 | $context['look_for'] = array(); |
| 2190 | 2273 | // Are we looking for a particular tree - normally an expansion? |
| 2191 | - if (!empty($_REQUEST['find'])) |
|
| 2192 | - $context['look_for'][] = base64_decode($_REQUEST['find']); |
|
| 2274 | + if (!empty($_REQUEST['find'])) { |
|
| 2275 | + $context['look_for'][] = base64_decode($_REQUEST['find']); |
|
| 2276 | + } |
|
| 2193 | 2277 | // Only that tree? |
| 2194 | 2278 | $context['only_find'] = isset($_GET['xml']) && !empty($_REQUEST['onlyfind']) ? $_REQUEST['onlyfind'] : ''; |
| 2195 | - if ($context['only_find']) |
|
| 2196 | - $context['look_for'][] = $context['only_find']; |
|
| 2279 | + if ($context['only_find']) { |
|
| 2280 | + $context['look_for'][] = $context['only_find']; |
|
| 2281 | + } |
|
| 2197 | 2282 | |
| 2198 | 2283 | // Have we got a load of back-catalogue trees to expand from a submit etc? |
| 2199 | 2284 | if (!empty($_GET['back_look'])) |
| 2200 | 2285 | { |
| 2201 | 2286 | $potententialTrees = $smcFunc['json_decode'](base64_decode($_GET['back_look']), true); |
| 2202 | - foreach ($potententialTrees as $tree) |
|
| 2203 | - $context['look_for'][] = $tree; |
|
| 2287 | + foreach ($potententialTrees as $tree) { |
|
| 2288 | + $context['look_for'][] = $tree; |
|
| 2289 | + } |
|
| 2204 | 2290 | } |
| 2205 | 2291 | // ... maybe posted? |
| 2206 | - if (!empty($_POST['back_look'])) |
|
| 2207 | - $context['only_find'] = array_merge($context['only_find'], $_POST['back_look']); |
|
| 2292 | + if (!empty($_POST['back_look'])) { |
|
| 2293 | + $context['only_find'] = array_merge($context['only_find'], $_POST['back_look']); |
|
| 2294 | + } |
|
| 2208 | 2295 | |
| 2209 | 2296 | $context['back_look_data'] = base64_encode($smcFunc['json_encode'](array_slice($context['look_for'], 0, 15))); |
| 2210 | 2297 | |
@@ -2243,9 +2330,9 @@ discard block |
||
| 2243 | 2330 | 'chmod' => @is_writable($path), |
| 2244 | 2331 | 'perms' => @fileperms($path), |
| 2245 | 2332 | ); |
| 2333 | + } else { |
|
| 2334 | + unset($context['file_tree'][$path]); |
|
| 2246 | 2335 | } |
| 2247 | - else |
|
| 2248 | - unset($context['file_tree'][$path]); |
|
| 2249 | 2336 | } |
| 2250 | 2337 | |
| 2251 | 2338 | // Is this actually xml? |
@@ -2269,22 +2356,25 @@ discard block |
||
| 2269 | 2356 | global $context; |
| 2270 | 2357 | |
| 2271 | 2358 | $isLikelyPath = false; |
| 2272 | - foreach ($context['look_for'] as $possiblePath) |
|
| 2273 | - if (substr($possiblePath, 0, strlen($path)) == $path) |
|
| 2359 | + foreach ($context['look_for'] as $possiblePath) { |
|
| 2360 | + if (substr($possiblePath, 0, strlen($path)) == $path) |
|
| 2274 | 2361 | $isLikelyPath = true; |
| 2362 | + } |
|
| 2275 | 2363 | |
| 2276 | 2364 | // Is this where we stop? |
| 2277 | - if (isset($_GET['xml']) && !empty($context['look_for']) && !$isLikelyPath) |
|
| 2278 | - return; |
|
| 2279 | - elseif ($level > $context['default_level'] && !$isLikelyPath) |
|
| 2280 | - return; |
|
| 2365 | + if (isset($_GET['xml']) && !empty($context['look_for']) && !$isLikelyPath) { |
|
| 2366 | + return; |
|
| 2367 | + } elseif ($level > $context['default_level'] && !$isLikelyPath) { |
|
| 2368 | + return; |
|
| 2369 | + } |
|
| 2281 | 2370 | |
| 2282 | 2371 | // Are we actually interested in saving this data? |
| 2283 | 2372 | $save_data = empty($context['only_find']) || $context['only_find'] == $path; |
| 2284 | 2373 | |
| 2285 | 2374 | // @todo Shouldn't happen - but better error message? |
| 2286 | - if (!is_dir($path)) |
|
| 2287 | - fatal_lang_error('no_access', false); |
|
| 2375 | + if (!is_dir($path)) { |
|
| 2376 | + fatal_lang_error('no_access', false); |
|
| 2377 | + } |
|
| 2288 | 2378 | |
| 2289 | 2379 | // This is where we put stuff we've found for sorting. |
| 2290 | 2380 | $foundData = array( |
@@ -2299,11 +2389,13 @@ discard block |
||
| 2299 | 2389 | if (is_file($path . '/' . $entry)) |
| 2300 | 2390 | { |
| 2301 | 2391 | // Are we listing PHP files in this directory? |
| 2302 | - if ($save_data && !empty($data['list_contents']) && substr($entry, -4) == '.php') |
|
| 2303 | - $foundData['files'][$entry] = true; |
|
| 2392 | + if ($save_data && !empty($data['list_contents']) && substr($entry, -4) == '.php') { |
|
| 2393 | + $foundData['files'][$entry] = true; |
|
| 2394 | + } |
|
| 2304 | 2395 | // A file we were looking for. |
| 2305 | - elseif ($save_data && isset($data['contents'][$entry])) |
|
| 2306 | - $foundData['files'][$entry] = true; |
|
| 2396 | + elseif ($save_data && isset($data['contents'][$entry])) { |
|
| 2397 | + $foundData['files'][$entry] = true; |
|
| 2398 | + } |
|
| 2307 | 2399 | } |
| 2308 | 2400 | // It's a directory - we're interested one way or another, probably... |
| 2309 | 2401 | elseif ($entry != '.' && $entry != '..') |
@@ -2311,32 +2403,36 @@ discard block |
||
| 2311 | 2403 | // Going further? |
| 2312 | 2404 | if ((!empty($data['type']) && $data['type'] == 'dir_recursive') || (isset($data['contents'][$entry]) && (!empty($data['contents'][$entry]['list_contents']) || (!empty($data['contents'][$entry]['type']) && $data['contents'][$entry]['type'] == 'dir_recursive')))) |
| 2313 | 2405 | { |
| 2314 | - if (!isset($data['contents'][$entry])) |
|
| 2315 | - $foundData['folders'][$entry] = 'dir_recursive'; |
|
| 2316 | - else |
|
| 2317 | - $foundData['folders'][$entry] = true; |
|
| 2406 | + if (!isset($data['contents'][$entry])) { |
|
| 2407 | + $foundData['folders'][$entry] = 'dir_recursive'; |
|
| 2408 | + } else { |
|
| 2409 | + $foundData['folders'][$entry] = true; |
|
| 2410 | + } |
|
| 2318 | 2411 | |
| 2319 | 2412 | // If this wasn't expected inherit the recusiveness... |
| 2320 | - if (!isset($data['contents'][$entry])) |
|
| 2321 | - // We need to do this as we will be going all recursive. |
|
| 2413 | + if (!isset($data['contents'][$entry])) { |
|
| 2414 | + // We need to do this as we will be going all recursive. |
|
| 2322 | 2415 | $data['contents'][$entry] = array( |
| 2323 | 2416 | 'type' => 'dir_recursive', |
| 2324 | 2417 | ); |
| 2418 | + } |
|
| 2325 | 2419 | |
| 2326 | 2420 | // Actually do the recursive stuff... |
| 2327 | 2421 | fetchPerms__recursive($path . '/' . $entry, $data['contents'][$entry], $level + 1); |
| 2328 | 2422 | } |
| 2329 | 2423 | // Maybe it is a folder we are not descending into. |
| 2330 | - elseif (isset($data['contents'][$entry])) |
|
| 2331 | - $foundData['folders'][$entry] = true; |
|
| 2424 | + elseif (isset($data['contents'][$entry])) { |
|
| 2425 | + $foundData['folders'][$entry] = true; |
|
| 2426 | + } |
|
| 2332 | 2427 | // Otherwise we stop here. |
| 2333 | 2428 | } |
| 2334 | 2429 | } |
| 2335 | 2430 | closedir($dh); |
| 2336 | 2431 | |
| 2337 | 2432 | // Nothing to see here? |
| 2338 | - if (!$save_data) |
|
| 2339 | - return; |
|
| 2433 | + if (!$save_data) { |
|
| 2434 | + return; |
|
| 2435 | + } |
|
| 2340 | 2436 | |
| 2341 | 2437 | // Now actually add the data, starting with the folders. |
| 2342 | 2438 | ksort($foundData['folders']); |
@@ -2348,8 +2444,9 @@ discard block |
||
| 2348 | 2444 | 'perms' => @fileperms($path . '/' . $folder), |
| 2349 | 2445 | ), |
| 2350 | 2446 | ); |
| 2351 | - if ($type !== true) |
|
| 2352 | - $additional_data['type'] = $type; |
|
| 2447 | + if ($type !== true) { |
|
| 2448 | + $additional_data['type'] = $type; |
|
| 2449 | + } |
|
| 2353 | 2450 | |
| 2354 | 2451 | // If there's an offset ignore any folders in XML mode. |
| 2355 | 2452 | if (isset($_GET['xml']) && $context['file_offset'] == 0) |
@@ -2368,13 +2465,13 @@ discard block |
||
| 2368 | 2465 | ), |
| 2369 | 2466 | 'value' => $folder, |
| 2370 | 2467 | ); |
| 2371 | - } |
|
| 2372 | - elseif (!isset($_GET['xml'])) |
|
| 2468 | + } elseif (!isset($_GET['xml'])) |
|
| 2373 | 2469 | { |
| 2374 | - if (isset($data['contents'][$folder])) |
|
| 2375 | - $data['contents'][$folder] = array_merge($data['contents'][$folder], $additional_data); |
|
| 2376 | - else |
|
| 2377 | - $data['contents'][$folder] = $additional_data; |
|
| 2470 | + if (isset($data['contents'][$folder])) { |
|
| 2471 | + $data['contents'][$folder] = array_merge($data['contents'][$folder], $additional_data); |
|
| 2472 | + } else { |
|
| 2473 | + $data['contents'][$folder] = $additional_data; |
|
| 2474 | + } |
|
| 2378 | 2475 | } |
| 2379 | 2476 | } |
| 2380 | 2477 | |
@@ -2386,11 +2483,13 @@ discard block |
||
| 2386 | 2483 | $counter++; |
| 2387 | 2484 | |
| 2388 | 2485 | // Have we reached our offset? |
| 2389 | - if ($context['file_offset'] > $counter) |
|
| 2390 | - continue; |
|
| 2486 | + if ($context['file_offset'] > $counter) { |
|
| 2487 | + continue; |
|
| 2488 | + } |
|
| 2391 | 2489 | // Gone too far? |
| 2392 | - if ($counter > ($context['file_offset'] + $context['file_limit'])) |
|
| 2393 | - continue; |
|
| 2490 | + if ($counter > ($context['file_offset'] + $context['file_limit'])) { |
|
| 2491 | + continue; |
|
| 2492 | + } |
|
| 2394 | 2493 | |
| 2395 | 2494 | $additional_data = array( |
| 2396 | 2495 | 'perms' => array( |
@@ -2416,13 +2515,13 @@ discard block |
||
| 2416 | 2515 | ), |
| 2417 | 2516 | 'value' => $file, |
| 2418 | 2517 | ); |
| 2419 | - } |
|
| 2420 | - elseif ($counter != ($context['file_offset'] + $context['file_limit'])) |
|
| 2518 | + } elseif ($counter != ($context['file_offset'] + $context['file_limit'])) |
|
| 2421 | 2519 | { |
| 2422 | - if (isset($data['contents'][$file])) |
|
| 2423 | - $data['contents'][$file] = array_merge($data['contents'][$file], $additional_data); |
|
| 2424 | - else |
|
| 2425 | - $data['contents'][$file] = $additional_data; |
|
| 2520 | + if (isset($data['contents'][$file])) { |
|
| 2521 | + $data['contents'][$file] = array_merge($data['contents'][$file], $additional_data); |
|
| 2522 | + } else { |
|
| 2523 | + $data['contents'][$file] = $additional_data; |
|
| 2524 | + } |
|
| 2426 | 2525 | } |
| 2427 | 2526 | } |
| 2428 | 2527 | } |
@@ -2444,8 +2543,9 @@ discard block |
||
| 2444 | 2543 | $context['back_look_data'] = isset($_POST['back_look']) ? $_POST['back_look'] : array(); |
| 2445 | 2544 | |
| 2446 | 2545 | // Skipping use of FTP? |
| 2447 | - if (empty($package_ftp)) |
|
| 2448 | - $context['skip_ftp'] = true; |
|
| 2546 | + if (empty($package_ftp)) { |
|
| 2547 | + $context['skip_ftp'] = true; |
|
| 2548 | + } |
|
| 2449 | 2549 | |
| 2450 | 2550 | // We'll start off in a good place, security. Make sure that if we're dealing with individual files that they seem in the right place. |
| 2451 | 2551 | if ($context['method'] == 'individual') |
@@ -2455,8 +2555,9 @@ discard block |
||
| 2455 | 2555 | $context['custom_value'] = (int) $_POST['custom_value']; |
| 2456 | 2556 | |
| 2457 | 2557 | // Continuing? |
| 2458 | - if (isset($_POST['toProcess'])) |
|
| 2459 | - $_POST['permStatus'] = $smcFunc['json_decode'](base64_decode($_POST['toProcess']), true); |
|
| 2558 | + if (isset($_POST['toProcess'])) { |
|
| 2559 | + $_POST['permStatus'] = $smcFunc['json_decode'](base64_decode($_POST['toProcess']), true); |
|
| 2560 | + } |
|
| 2460 | 2561 | |
| 2461 | 2562 | if (isset($_POST['permStatus'])) |
| 2462 | 2563 | { |
@@ -2465,22 +2566,27 @@ discard block |
||
| 2465 | 2566 | foreach ($_POST['permStatus'] as $path => $status) |
| 2466 | 2567 | { |
| 2467 | 2568 | // Nothing to see here? |
| 2468 | - if ($status == 'no_change') |
|
| 2469 | - continue; |
|
| 2569 | + if ($status == 'no_change') { |
|
| 2570 | + continue; |
|
| 2571 | + } |
|
| 2470 | 2572 | $legal = false; |
| 2471 | - foreach ($legal_roots as $root) |
|
| 2472 | - if (substr($path, 0, strlen($root)) == $root) |
|
| 2573 | + foreach ($legal_roots as $root) { |
|
| 2574 | + if (substr($path, 0, strlen($root)) == $root) |
|
| 2473 | 2575 | $legal = true; |
| 2576 | + } |
|
| 2474 | 2577 | |
| 2475 | - if (!$legal) |
|
| 2476 | - continue; |
|
| 2578 | + if (!$legal) { |
|
| 2579 | + continue; |
|
| 2580 | + } |
|
| 2477 | 2581 | |
| 2478 | 2582 | // Check it exists. |
| 2479 | - if (!file_exists($path)) |
|
| 2480 | - continue; |
|
| 2583 | + if (!file_exists($path)) { |
|
| 2584 | + continue; |
|
| 2585 | + } |
|
| 2481 | 2586 | |
| 2482 | - if ($status == 'custom') |
|
| 2483 | - $validate_custom = true; |
|
| 2587 | + if ($status == 'custom') { |
|
| 2588 | + $validate_custom = true; |
|
| 2589 | + } |
|
| 2484 | 2590 | |
| 2485 | 2591 | // Now add it. |
| 2486 | 2592 | $context['to_process'][$path] = $status; |
@@ -2490,17 +2596,20 @@ discard block |
||
| 2490 | 2596 | // Make sure the chmod status is valid? |
| 2491 | 2597 | if ($validate_custom) |
| 2492 | 2598 | { |
| 2493 | - if (preg_match('~^[4567][4567][4567]$~', $context['custom_value']) == false) |
|
| 2494 | - fatal_error($txt['chmod_value_invalid']); |
|
| 2599 | + if (preg_match('~^[4567][4567][4567]$~', $context['custom_value']) == false) { |
|
| 2600 | + fatal_error($txt['chmod_value_invalid']); |
|
| 2601 | + } |
|
| 2495 | 2602 | } |
| 2496 | 2603 | |
| 2497 | 2604 | // Nothing to do? |
| 2498 | - if (empty($context['to_process'])) |
|
| 2499 | - redirectexit('action=admin;area=packages;sa=perms' . (!empty($context['back_look_data']) ? ';back_look=' . base64_encode($smcFunc['json_encode']($context['back_look_data'])) : '') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 2605 | + if (empty($context['to_process'])) { |
|
| 2606 | + redirectexit('action=admin;area=packages;sa=perms' . (!empty($context['back_look_data']) ? ';back_look=' . base64_encode($smcFunc['json_encode']($context['back_look_data'])) : '') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 2607 | + } |
|
| 2500 | 2608 | } |
| 2501 | 2609 | // Should never get here, |
| 2502 | - else |
|
| 2503 | - fatal_lang_error('no_access', false); |
|
| 2610 | + else { |
|
| 2611 | + fatal_lang_error('no_access', false); |
|
| 2612 | + } |
|
| 2504 | 2613 | |
| 2505 | 2614 | // Setup the custom value. |
| 2506 | 2615 | $custom_value = octdec('0' . $context['custom_value']); |
@@ -2508,18 +2617,18 @@ discard block |
||
| 2508 | 2617 | // Start processing items. |
| 2509 | 2618 | foreach ($context['to_process'] as $path => $status) |
| 2510 | 2619 | { |
| 2511 | - if (in_array($status, array('execute', 'writable', 'read'))) |
|
| 2512 | - package_chmod($path, $status); |
|
| 2513 | - elseif ($status == 'custom' && !empty($custom_value)) |
|
| 2620 | + if (in_array($status, array('execute', 'writable', 'read'))) { |
|
| 2621 | + package_chmod($path, $status); |
|
| 2622 | + } elseif ($status == 'custom' && !empty($custom_value)) |
|
| 2514 | 2623 | { |
| 2515 | 2624 | // Use FTP if we have it. |
| 2516 | 2625 | if (!empty($package_ftp) && !empty($_SESSION['pack_ftp'])) |
| 2517 | 2626 | { |
| 2518 | 2627 | $ftp_file = strtr($path, array($_SESSION['pack_ftp']['root'] => '')); |
| 2519 | 2628 | $package_ftp->chmod($ftp_file, $custom_value); |
| 2629 | + } else { |
|
| 2630 | + smf_chmod($path, $custom_value); |
|
| 2520 | 2631 | } |
| 2521 | - else |
|
| 2522 | - smf_chmod($path, $custom_value); |
|
| 2523 | 2632 | } |
| 2524 | 2633 | |
| 2525 | 2634 | // This fish is fried... |
@@ -2603,23 +2712,27 @@ discard block |
||
| 2603 | 2712 | { |
| 2604 | 2713 | global $context; |
| 2605 | 2714 | |
| 2606 | - if (!empty($data['writable_on'])) |
|
| 2607 | - if ($context['predefined_type'] == 'standard' || $data['writable_on'] == 'restrictive') |
|
| 2715 | + if (!empty($data['writable_on'])) { |
|
| 2716 | + if ($context['predefined_type'] == 'standard' || $data['writable_on'] == 'restrictive') |
|
| 2608 | 2717 | $context['special_files'][$path] = 1; |
| 2718 | + } |
|
| 2609 | 2719 | |
| 2610 | - if (!empty($data['contents'])) |
|
| 2611 | - foreach ($data['contents'] as $name => $contents) |
|
| 2720 | + if (!empty($data['contents'])) { |
|
| 2721 | + foreach ($data['contents'] as $name => $contents) |
|
| 2612 | 2722 | build_special_files__recursive($path . '/' . $name, $contents); |
| 2723 | + } |
|
| 2613 | 2724 | } |
| 2614 | 2725 | |
| 2615 | - foreach ($context['file_tree'] as $path => $data) |
|
| 2616 | - build_special_files__recursive($path, $data); |
|
| 2726 | + foreach ($context['file_tree'] as $path => $data) { |
|
| 2727 | + build_special_files__recursive($path, $data); |
|
| 2728 | + } |
|
| 2617 | 2729 | } |
| 2618 | 2730 | // Free doesn't need special files. |
| 2619 | - elseif ($context['predefined_type'] == 'free') |
|
| 2620 | - $context['special_files'] = array(); |
|
| 2621 | - else |
|
| 2622 | - $context['special_files'] = $smcFunc['json_decode'](base64_decode($_POST['specialFiles']), true); |
|
| 2731 | + elseif ($context['predefined_type'] == 'free') { |
|
| 2732 | + $context['special_files'] = array(); |
|
| 2733 | + } else { |
|
| 2734 | + $context['special_files'] = $smcFunc['json_decode'](base64_decode($_POST['specialFiles']), true); |
|
| 2735 | + } |
|
| 2623 | 2736 | |
| 2624 | 2737 | // Now we definitely know where we are, we need to go through again doing the chmod! |
| 2625 | 2738 | foreach ($context['directory_list'] as $path => $dummy) |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | global $sourcedir, $profile_vars; |
| 30 | 31 | |
| 31 | 32 | // Don't load this twice! |
| 32 | - if (!empty($profile_fields) && !$force_reload) |
|
| 33 | - return; |
|
| 33 | + if (!empty($profile_fields) && !$force_reload) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
| 36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
| 103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
| 104 | 106 | { |
| 105 | 107 | // Set to blank? |
| 106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
| 107 | - $value = '1004-01-01'; |
|
| 108 | - else |
|
| 109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
| 108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
| 109 | + $value = '1004-01-01'; |
|
| 110 | + } else { |
|
| 111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + $value = '1004-01-01'; |
|
| 110 | 115 | } |
| 111 | - else |
|
| 112 | - $value = '1004-01-01'; |
|
| 113 | 116 | |
| 114 | 117 | $profile_vars['birthdate'] = $value; |
| 115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
| 127 | 130 | { |
| 128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01'; |
| 129 | 132 | return true; |
| 130 | - } |
|
| 131 | - else |
|
| 133 | + } else |
|
| 132 | 134 | { |
| 133 | 135 | $value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate']; |
| 134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
| 150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
| 151 | 153 | } |
| 152 | 154 | // As long as it doesn't equal "N/A"... |
| 153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
| 154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 155 | - else |
|
| 156 | - $value = $cur_profile['date_registered']; |
|
| 155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
| 156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 157 | + } else { |
|
| 158 | + $value = $cur_profile['date_registered']; |
|
| 159 | + } |
|
| 157 | 160 | |
| 158 | 161 | return true; |
| 159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
| 177 | 180 | { |
| 178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
| 179 | 182 | |
| 180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
| 181 | - return false; |
|
| 183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 182 | 186 | |
| 183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
| 184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
| 254 | 258 | |
| 255 | 259 | if (isset($context['profile_languages'][$value])) |
| 256 | 260 | { |
| 257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
| 258 | - $_SESSION['language'] = $value; |
|
| 261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
| 262 | + $_SESSION['language'] = $value; |
|
| 263 | + } |
|
| 259 | 264 | return true; |
| 260 | - } |
|
| 261 | - else |
|
| 265 | + } else |
|
| 262 | 266 | { |
| 263 | 267 | $value = $cur_profile['lngfile']; |
| 264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
| 282 | 286 | |
| 283 | 287 | // Maybe they are trying to change their password as well? |
| 284 | 288 | $resetPassword = true; |
| 285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
| 286 | - $resetPassword = false; |
|
| 289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
| 290 | + $resetPassword = false; |
|
| 291 | + } |
|
| 287 | 292 | |
| 288 | 293 | // Do the reset... this will send them an email too. |
| 289 | - if ($resetPassword) |
|
| 290 | - resetPassword($context['id_member'], $value); |
|
| 291 | - elseif ($value !== null) |
|
| 294 | + if ($resetPassword) { |
|
| 295 | + resetPassword($context['id_member'], $value); |
|
| 296 | + } elseif ($value !== null) |
|
| 292 | 297 | { |
| 293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
| 294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
| 312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
| 313 | 318 | { |
| 314 | 319 | // If we didn't try it then ignore it! |
| 315 | - if ($value == '') |
|
| 316 | - return false; |
|
| 320 | + if ($value == '') { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 317 | 323 | |
| 318 | 324 | // Do the two entries for the password even match? |
| 319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
| 320 | - return 'bad_new_password'; |
|
| 325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
| 326 | + return 'bad_new_password'; |
|
| 327 | + } |
|
| 321 | 328 | |
| 322 | 329 | // Let's get the validation function into play... |
| 323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
| 324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
| 325 | 332 | |
| 326 | 333 | // Were there errors? |
| 327 | - if ($passwordErrors != null) |
|
| 328 | - return 'password_' . $passwordErrors; |
|
| 334 | + if ($passwordErrors != null) { |
|
| 335 | + return 'password_' . $passwordErrors; |
|
| 336 | + } |
|
| 329 | 337 | |
| 330 | 338 | // Set up the new password variable... ready for storage. |
| 331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
| 350 | 358 | 'permission' => 'profile_blurb', |
| 351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
| 352 | 360 | { |
| 353 | - if ($smcFunc['strlen']($value) > 50) |
|
| 354 | - return 'personal_text_too_long'; |
|
| 361 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 362 | + return 'personal_text_too_long'; |
|
| 363 | + } |
|
| 355 | 364 | |
| 356 | 365 | return true; |
| 357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
| 386 | 395 | 'permission' => 'moderate_forum', |
| 387 | 396 | 'input_validate' => function(&$value) |
| 388 | 397 | { |
| 389 | - if (!is_numeric($value)) |
|
| 390 | - return 'digits_only'; |
|
| 391 | - else |
|
| 392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 398 | + if (!is_numeric($value)) { |
|
| 399 | + return 'digits_only'; |
|
| 400 | + } else { |
|
| 401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 402 | + } |
|
| 393 | 403 | return true; |
| 394 | 404 | }, |
| 395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
| 405 | 415 | { |
| 406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
| 407 | 417 | |
| 408 | - if (trim($value) == '') |
|
| 409 | - return 'no_name'; |
|
| 410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
| 411 | - return 'name_too_long'; |
|
| 412 | - elseif ($cur_profile['real_name'] != $value) |
|
| 418 | + if (trim($value) == '') { |
|
| 419 | + return 'no_name'; |
|
| 420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
| 421 | + return 'name_too_long'; |
|
| 422 | + } elseif ($cur_profile['real_name'] != $value) |
|
| 413 | 423 | { |
| 414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
| 415 | - if (isReservedName($value, $context['id_member'])) |
|
| 416 | - return 'name_taken'; |
|
| 425 | + if (isReservedName($value, $context['id_member'])) { |
|
| 426 | + return 'name_taken'; |
|
| 427 | + } |
|
| 417 | 428 | } |
| 418 | 429 | return true; |
| 419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
| 471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
| 472 | 483 | ); |
| 473 | 484 | |
| 474 | - if ($context['smiley_sets'][$i]['selected']) |
|
| 475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
| 486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 487 | + } |
|
| 476 | 488 | } |
| 477 | 489 | return true; |
| 478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
| 481 | 493 | global $modSettings; |
| 482 | 494 | |
| 483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
| 484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
| 485 | - $value = ''; |
|
| 496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
| 497 | + $value = ''; |
|
| 498 | + } |
|
| 486 | 499 | return true; |
| 487 | 500 | }, |
| 488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
| 497 | 510 | loadLanguage('Settings'); |
| 498 | 511 | |
| 499 | 512 | $context['allow_no_censored'] = false; |
| 500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
| 501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
| 514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 515 | + } |
|
| 502 | 516 | |
| 503 | 517 | return true; |
| 504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
| 545 | 559 | 'input_validate' => function($value) |
| 546 | 560 | { |
| 547 | 561 | $tz = smf_list_timezones(); |
| 548 | - if (!isset($tz[$value])) |
|
| 549 | - return 'bad_timezone'; |
|
| 562 | + if (!isset($tz[$value])) { |
|
| 563 | + return 'bad_timezone'; |
|
| 564 | + } |
|
| 550 | 565 | |
| 551 | 566 | return true; |
| 552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
| 561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
| 562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
| 563 | 578 | { |
| 564 | - if ($smcFunc['strlen']($value) > 50) |
|
| 565 | - return 'user_title_too_long'; |
|
| 579 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 580 | + return 'user_title_too_long'; |
|
| 581 | + } |
|
| 566 | 582 | |
| 567 | 583 | return true; |
| 568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
| 584 | 600 | // Fix the URL... |
| 585 | 601 | 'input_validate' => function(&$value) |
| 586 | 602 | { |
| 587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
| 588 | - $value = 'http://' . $value; |
|
| 589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
| 590 | - $value = ''; |
|
| 603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
| 604 | + $value = 'http://' . $value; |
|
| 605 | + } |
|
| 606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
| 607 | + $value = ''; |
|
| 608 | + } |
|
| 591 | 609 | return true; |
| 592 | 610 | }, |
| 593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
| 601 | 619 | foreach ($profile_fields as $key => $field) |
| 602 | 620 | { |
| 603 | 621 | // Do we have permission to do this? |
| 604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
| 605 | - unset($profile_fields[$key]); |
|
| 622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
| 623 | + unset($profile_fields[$key]); |
|
| 624 | + } |
|
| 606 | 625 | |
| 607 | 626 | // Is it enabled? |
| 608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
| 609 | - unset($profile_fields[$key]); |
|
| 627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
| 628 | + unset($profile_fields[$key]); |
|
| 629 | + } |
|
| 610 | 630 | |
| 611 | 631 | // Is it specifically disabled? |
| 612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
| 613 | - unset($profile_fields[$key]); |
|
| 632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
| 633 | + unset($profile_fields[$key]); |
|
| 634 | + } |
|
| 614 | 635 | } |
| 615 | 636 | } |
| 616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
| 635 | 656 | loadProfileFields(true); |
| 636 | 657 | |
| 637 | 658 | // First check for any linked sets. |
| 638 | - foreach ($profile_fields as $key => $field) |
|
| 639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 659 | + foreach ($profile_fields as $key => $field) { |
|
| 660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 640 | 661 | $fields[] = $key; |
| 662 | + } |
|
| 641 | 663 | |
| 642 | 664 | $i = 0; |
| 643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
| 649 | 671 | $cur_field = &$profile_fields[$field]; |
| 650 | 672 | |
| 651 | 673 | // Does it have a preload and does that preload succeed? |
| 652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
| 653 | - continue; |
|
| 674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 654 | 677 | |
| 655 | 678 | // If this is anything but complex we need to do more cleaning! |
| 656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
| 657 | 680 | { |
| 658 | - if (!isset($cur_field['label'])) |
|
| 659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 681 | + if (!isset($cur_field['label'])) { |
|
| 682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 683 | + } |
|
| 660 | 684 | |
| 661 | 685 | // Everything has a value! |
| 662 | - if (!isset($cur_field['value'])) |
|
| 663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 686 | + if (!isset($cur_field['value'])) { |
|
| 687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 688 | + } |
|
| 664 | 689 | |
| 665 | 690 | // Any input attributes? |
| 666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
| 667 | 692 | } |
| 668 | 693 | |
| 669 | 694 | // Was there an error with this field on posting? |
| 670 | - if (isset($context['profile_errors'][$field])) |
|
| 671 | - $cur_field['is_error'] = true; |
|
| 695 | + if (isset($context['profile_errors'][$field])) { |
|
| 696 | + $cur_field['is_error'] = true; |
|
| 697 | + } |
|
| 672 | 698 | |
| 673 | 699 | // Any javascript stuff? |
| 674 | - if (!empty($cur_field['js_submit'])) |
|
| 675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 676 | - if (!empty($cur_field['js'])) |
|
| 677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
| 700 | + if (!empty($cur_field['js_submit'])) { |
|
| 701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 702 | + } |
|
| 703 | + if (!empty($cur_field['js'])) { |
|
| 704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
| 705 | + } |
|
| 678 | 706 | |
| 679 | 707 | // Any template stuff? |
| 680 | - if (!empty($cur_field['prehtml'])) |
|
| 681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 682 | - if (!empty($cur_field['posthtml'])) |
|
| 683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 708 | + if (!empty($cur_field['prehtml'])) { |
|
| 709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 710 | + } |
|
| 711 | + if (!empty($cur_field['posthtml'])) { |
|
| 712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 713 | + } |
|
| 684 | 714 | |
| 685 | 715 | // Finally put it into context? |
| 686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
| 713 | 743 | }, false);' : ''), true); |
| 714 | 744 | |
| 715 | 745 | // Any onsubmit javascript? |
| 716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
| 717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
| 747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 748 | + } |
|
| 718 | 749 | |
| 719 | 750 | // Any totally custom stuff? |
| 720 | - if (!empty($context['profile_javascript'])) |
|
| 721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
| 751 | + if (!empty($context['profile_javascript'])) { |
|
| 752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
| 753 | + } |
|
| 722 | 754 | |
| 723 | 755 | // Free up some memory. |
| 724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
| 739 | 771 | |
| 740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
| 741 | 773 | $context['profile_execute_on_save'] = array(); |
| 742 | - if ($context['user']['is_owner']) |
|
| 743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 774 | + if ($context['user']['is_owner']) { |
|
| 775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 776 | + } |
|
| 744 | 777 | |
| 745 | 778 | // Assume we log nothing. |
| 746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
| 748 | 781 | // Cycle through the profile fields working out what to do! |
| 749 | 782 | foreach ($profile_fields as $key => $field) |
| 750 | 783 | { |
| 751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
| 752 | - continue; |
|
| 784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
| 785 | + continue; |
|
| 786 | + } |
|
| 753 | 787 | |
| 754 | 788 | // What gets updated? |
| 755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
| 777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
| 778 | 812 | |
| 779 | 813 | // Finally, clean up certain types. |
| 780 | - if ($field['cast_type'] == 'int') |
|
| 781 | - $_POST[$key] = (int) $_POST[$key]; |
|
| 782 | - elseif ($field['cast_type'] == 'float') |
|
| 783 | - $_POST[$key] = (float) $_POST[$key]; |
|
| 784 | - elseif ($field['cast_type'] == 'check') |
|
| 785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 814 | + if ($field['cast_type'] == 'int') { |
|
| 815 | + $_POST[$key] = (int) $_POST[$key]; |
|
| 816 | + } elseif ($field['cast_type'] == 'float') { |
|
| 817 | + $_POST[$key] = (float) $_POST[$key]; |
|
| 818 | + } elseif ($field['cast_type'] == 'check') { |
|
| 819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 820 | + } |
|
| 786 | 821 | |
| 787 | 822 | // If we got here we're doing OK. |
| 788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
| 793 | 828 | $cur_profile[$key] = $_POST[$key]; |
| 794 | 829 | |
| 795 | 830 | // Are we logging it? |
| 796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
| 797 | - $context['log_changes'][$key] = array( |
|
| 831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
| 832 | + $context['log_changes'][$key] = array( |
|
| 798 | 833 | 'previous' => $old_profile[$key], |
| 799 | 834 | 'new' => $_POST[$key], |
| 800 | 835 | ); |
| 836 | + } |
|
| 801 | 837 | } |
| 802 | 838 | |
| 803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
| 830 | 866 | { |
| 831 | 867 | foreach ($groups as $id => $group) |
| 832 | 868 | { |
| 833 | - if (isset($context['member_groups'][$group])) |
|
| 834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 835 | - else |
|
| 836 | - unset($additional_groups[$type][$id]); |
|
| 869 | + if (isset($context['member_groups'][$group])) { |
|
| 870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 871 | + } else { |
|
| 872 | + unset($additional_groups[$type][$id]); |
|
| 873 | + } |
|
| 837 | 874 | } |
| 838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
| 839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
| 844 | 881 | } |
| 845 | 882 | |
| 846 | 883 | // @todo Temporary |
| 847 | - if ($context['user']['is_owner']) |
|
| 848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 849 | - else |
|
| 850 | - $changeOther = allowedTo('profile_extra_any'); |
|
| 884 | + if ($context['user']['is_owner']) { |
|
| 885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 886 | + } else { |
|
| 887 | + $changeOther = allowedTo('profile_extra_any'); |
|
| 888 | + } |
|
| 851 | 889 | if ($changeOther && empty($post_errors)) |
| 852 | 890 | { |
| 853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
| 855 | 893 | { |
| 856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
| 857 | 895 | |
| 858 | - if (!empty($custom_fields_errors)) |
|
| 859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 896 | + if (!empty($custom_fields_errors)) { |
|
| 897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 898 | + } |
|
| 860 | 899 | } |
| 861 | 900 | } |
| 862 | 901 | |
@@ -882,9 +921,9 @@ discard block |
||
| 882 | 921 | if ($context['user']['is_owner']) |
| 883 | 922 | { |
| 884 | 923 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
| 924 | + } else { |
|
| 925 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 885 | 926 | } |
| 886 | - else |
|
| 887 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 888 | 927 | |
| 889 | 928 | // Arrays of all the changes - makes things easier. |
| 890 | 929 | $profile_bools = array(); |
@@ -895,22 +934,25 @@ discard block |
||
| 895 | 934 | 'ignore_boards', |
| 896 | 935 | ); |
| 897 | 936 | |
| 898 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
| 899 | - $_POST['ignore_brd'] = array(); |
|
| 937 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
| 938 | + $_POST['ignore_brd'] = array(); |
|
| 939 | + } |
|
| 900 | 940 | |
| 901 | 941 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
| 902 | 942 | if (isset($_POST['ignore_brd'])) |
| 903 | 943 | { |
| 904 | - if (!is_array($_POST['ignore_brd'])) |
|
| 905 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 944 | + if (!is_array($_POST['ignore_brd'])) { |
|
| 945 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 946 | + } |
|
| 906 | 947 | |
| 907 | 948 | foreach ($_POST['ignore_brd'] as $k => $d) |
| 908 | 949 | { |
| 909 | 950 | $d = (int) $d; |
| 910 | - if ($d != 0) |
|
| 911 | - $_POST['ignore_brd'][$k] = $d; |
|
| 912 | - else |
|
| 913 | - unset($_POST['ignore_brd'][$k]); |
|
| 951 | + if ($d != 0) { |
|
| 952 | + $_POST['ignore_brd'][$k] = $d; |
|
| 953 | + } else { |
|
| 954 | + unset($_POST['ignore_brd'][$k]); |
|
| 955 | + } |
|
| 914 | 956 | } |
| 915 | 957 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
| 916 | 958 | unset($_POST['ignore_brd']); |
@@ -923,21 +965,26 @@ discard block |
||
| 923 | 965 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
| 924 | 966 | //makeAvatarChanges($memID, $post_errors); |
| 925 | 967 | |
| 926 | - if (!empty($_REQUEST['sa'])) |
|
| 927 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 968 | + if (!empty($_REQUEST['sa'])) { |
|
| 969 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 970 | + } |
|
| 928 | 971 | |
| 929 | - foreach ($profile_bools as $var) |
|
| 930 | - if (isset($_POST[$var])) |
|
| 972 | + foreach ($profile_bools as $var) { |
|
| 973 | + if (isset($_POST[$var])) |
|
| 931 | 974 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
| 932 | - foreach ($profile_ints as $var) |
|
| 933 | - if (isset($_POST[$var])) |
|
| 975 | + } |
|
| 976 | + foreach ($profile_ints as $var) { |
|
| 977 | + if (isset($_POST[$var])) |
|
| 934 | 978 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
| 935 | - foreach ($profile_floats as $var) |
|
| 936 | - if (isset($_POST[$var])) |
|
| 979 | + } |
|
| 980 | + foreach ($profile_floats as $var) { |
|
| 981 | + if (isset($_POST[$var])) |
|
| 937 | 982 | $profile_vars[$var] = (float) $_POST[$var]; |
| 938 | - foreach ($profile_strings as $var) |
|
| 939 | - if (isset($_POST[$var])) |
|
| 983 | + } |
|
| 984 | + foreach ($profile_strings as $var) { |
|
| 985 | + if (isset($_POST[$var])) |
|
| 940 | 986 | $profile_vars[$var] = $_POST[$var]; |
| 987 | + } |
|
| 941 | 988 | } |
| 942 | 989 | } |
| 943 | 990 | |
@@ -971,8 +1018,9 @@ discard block |
||
| 971 | 1018 | ); |
| 972 | 1019 | |
| 973 | 1020 | // Can't change reserved vars. |
| 974 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
| 975 | - fatal_lang_error('no_access', false); |
|
| 1021 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
| 1022 | + fatal_lang_error('no_access', false); |
|
| 1023 | + } |
|
| 976 | 1024 | |
| 977 | 1025 | // Don't allow any overriding of custom fields with default or non-default options. |
| 978 | 1026 | $request = $smcFunc['db_query']('', ' |
@@ -984,8 +1032,9 @@ discard block |
||
| 984 | 1032 | ) |
| 985 | 1033 | ); |
| 986 | 1034 | $custom_fields = array(); |
| 987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 988 | - $custom_fields[] = $row['col_name']; |
|
| 1035 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1036 | + $custom_fields[] = $row['col_name']; |
|
| 1037 | + } |
|
| 989 | 1038 | $smcFunc['db_free_result']($request); |
| 990 | 1039 | |
| 991 | 1040 | // These are the theme changes... |
@@ -994,33 +1043,39 @@ discard block |
||
| 994 | 1043 | { |
| 995 | 1044 | foreach ($_POST['options'] as $opt => $val) |
| 996 | 1045 | { |
| 997 | - if (in_array($opt, $custom_fields)) |
|
| 998 | - continue; |
|
| 1046 | + if (in_array($opt, $custom_fields)) { |
|
| 1047 | + continue; |
|
| 1048 | + } |
|
| 999 | 1049 | |
| 1000 | 1050 | // These need to be controlled. |
| 1001 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1002 | - $val = max(0, min($val, 50)); |
|
| 1051 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1052 | + $val = max(0, min($val, 50)); |
|
| 1053 | + } |
|
| 1003 | 1054 | // We don't set this per theme anymore. |
| 1004 | - elseif ($opt == 'allow_no_censored') |
|
| 1005 | - continue; |
|
| 1055 | + elseif ($opt == 'allow_no_censored') { |
|
| 1056 | + continue; |
|
| 1057 | + } |
|
| 1006 | 1058 | |
| 1007 | 1059 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1008 | 1060 | } |
| 1009 | 1061 | } |
| 1010 | 1062 | |
| 1011 | 1063 | $erase_options = array(); |
| 1012 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
| 1013 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 1064 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
| 1065 | + foreach ($_POST['default_options'] as $opt => $val) |
|
| 1014 | 1066 | { |
| 1015 | 1067 | if (in_array($opt, $custom_fields)) |
| 1016 | 1068 | continue; |
| 1069 | + } |
|
| 1017 | 1070 | |
| 1018 | 1071 | // These need to be controlled. |
| 1019 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1020 | - $val = max(0, min($val, 50)); |
|
| 1072 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1073 | + $val = max(0, min($val, 50)); |
|
| 1074 | + } |
|
| 1021 | 1075 | // Only let admins and owners change the censor. |
| 1022 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
| 1023 | - continue; |
|
| 1076 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
| 1077 | + continue; |
|
| 1078 | + } |
|
| 1024 | 1079 | |
| 1025 | 1080 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1026 | 1081 | $erase_options[] = $opt; |
@@ -1056,8 +1111,9 @@ discard block |
||
| 1056 | 1111 | |
| 1057 | 1112 | // Admins can choose any theme, even if it's not enabled... |
| 1058 | 1113 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
| 1059 | - foreach ($themes as $t) |
|
| 1060 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1114 | + foreach ($themes as $t) { |
|
| 1115 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1116 | + } |
|
| 1061 | 1117 | } |
| 1062 | 1118 | } |
| 1063 | 1119 | |
@@ -1076,8 +1132,9 @@ discard block |
||
| 1076 | 1132 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
| 1077 | 1133 | { |
| 1078 | 1134 | // Make sure only integers are deleted. |
| 1079 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
| 1080 | - $_POST['notify_boards'][$index] = (int) $id; |
|
| 1135 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
| 1136 | + $_POST['notify_boards'][$index] = (int) $id; |
|
| 1137 | + } |
|
| 1081 | 1138 | |
| 1082 | 1139 | // id_board = 0 is reserved for topic notifications. |
| 1083 | 1140 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1096,8 +1153,9 @@ discard block |
||
| 1096 | 1153 | // We are editing topic notifications...... |
| 1097 | 1154 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1098 | 1155 | { |
| 1099 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
| 1100 | - $_POST['notify_topics'][$index] = (int) $id; |
|
| 1156 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
| 1157 | + $_POST['notify_topics'][$index] = (int) $id; |
|
| 1158 | + } |
|
| 1101 | 1159 | |
| 1102 | 1160 | // Make sure there are no zeros left. |
| 1103 | 1161 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1111,16 +1169,18 @@ discard block |
||
| 1111 | 1169 | 'selected_member' => $memID, |
| 1112 | 1170 | ) |
| 1113 | 1171 | ); |
| 1114 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1115 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1172 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1173 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1174 | + } |
|
| 1116 | 1175 | } |
| 1117 | 1176 | |
| 1118 | 1177 | // We are removing topic preferences |
| 1119 | 1178 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1120 | 1179 | { |
| 1121 | 1180 | $prefs = array(); |
| 1122 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1123 | - $prefs[] = 'topic_notify_' . $topic; |
|
| 1181 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1182 | + $prefs[] = 'topic_notify_' . $topic; |
|
| 1183 | + } |
|
| 1124 | 1184 | deleteNotifyPrefs($memID, $prefs); |
| 1125 | 1185 | } |
| 1126 | 1186 | |
@@ -1128,8 +1188,9 @@ discard block |
||
| 1128 | 1188 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
| 1129 | 1189 | { |
| 1130 | 1190 | $prefs = array(); |
| 1131 | - foreach ($_POST['notify_boards'] as $board) |
|
| 1132 | - $prefs[] = 'board_notify_' . $board; |
|
| 1191 | + foreach ($_POST['notify_boards'] as $board) { |
|
| 1192 | + $prefs[] = 'board_notify_' . $board; |
|
| 1193 | + } |
|
| 1133 | 1194 | deleteNotifyPrefs($memID, $prefs); |
| 1134 | 1195 | } |
| 1135 | 1196 | } |
@@ -1150,8 +1211,9 @@ discard block |
||
| 1150 | 1211 | |
| 1151 | 1212 | $errors = array(); |
| 1152 | 1213 | |
| 1153 | - if ($sanitize && isset($_POST['customfield'])) |
|
| 1154 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1214 | + if ($sanitize && isset($_POST['customfield'])) { |
|
| 1215 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1216 | + } |
|
| 1155 | 1217 | |
| 1156 | 1218 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
| 1157 | 1219 | |
@@ -1176,48 +1238,49 @@ discard block |
||
| 1176 | 1238 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
| 1177 | 1239 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
| 1178 | 1240 | */ |
| 1179 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
| 1180 | - continue; |
|
| 1241 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
| 1242 | + continue; |
|
| 1243 | + } |
|
| 1181 | 1244 | |
| 1182 | 1245 | // Validate the user data. |
| 1183 | - if ($row['field_type'] == 'check') |
|
| 1184 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1185 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1246 | + if ($row['field_type'] == 'check') { |
|
| 1247 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1248 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1186 | 1249 | { |
| 1187 | 1250 | $value = $row['default_value']; |
| 1188 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1189 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1251 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
| 1252 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1190 | 1253 | $value = $v; |
| 1254 | + } |
|
| 1191 | 1255 | } |
| 1192 | 1256 | // Otherwise some form of text! |
| 1193 | 1257 | else |
| 1194 | 1258 | { |
| 1195 | 1259 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
| 1196 | - if ($row['field_length']) |
|
| 1197 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1260 | + if ($row['field_length']) { |
|
| 1261 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1262 | + } |
|
| 1198 | 1263 | |
| 1199 | 1264 | // Any masks? |
| 1200 | 1265 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
| 1201 | 1266 | { |
| 1202 | 1267 | if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
| 1203 | 1268 | { |
| 1204 | - if ($returnErrors) |
|
| 1205 | - $errors[] = 'custom_field_mail_fail'; |
|
| 1206 | - |
|
| 1207 | - else |
|
| 1208 | - $value = ''; |
|
| 1209 | - } |
|
| 1210 | - elseif ($row['mask'] == 'number') |
|
| 1269 | + if ($returnErrors) { |
|
| 1270 | + $errors[] = 'custom_field_mail_fail'; |
|
| 1271 | + } else { |
|
| 1272 | + $value = ''; |
|
| 1273 | + } |
|
| 1274 | + } elseif ($row['mask'] == 'number') |
|
| 1211 | 1275 | { |
| 1212 | 1276 | $value = (int) $value; |
| 1213 | - } |
|
| 1214 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1277 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1215 | 1278 | { |
| 1216 | - if ($returnErrors) |
|
| 1217 | - $errors[] = 'custom_field_regex_fail'; |
|
| 1218 | - |
|
| 1219 | - else |
|
| 1220 | - $value = ''; |
|
| 1279 | + if ($returnErrors) { |
|
| 1280 | + $errors[] = 'custom_field_regex_fail'; |
|
| 1281 | + } else { |
|
| 1282 | + $value = ''; |
|
| 1283 | + } |
|
| 1221 | 1284 | } |
| 1222 | 1285 | } |
| 1223 | 1286 | } |
@@ -1243,8 +1306,9 @@ discard block |
||
| 1243 | 1306 | |
| 1244 | 1307 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
| 1245 | 1308 | |
| 1246 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
| 1247 | - $errors = array_merge($errors, $hook_errors); |
|
| 1309 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
| 1310 | + $errors = array_merge($errors, $hook_errors); |
|
| 1311 | + } |
|
| 1248 | 1312 | |
| 1249 | 1313 | // Make those changes! |
| 1250 | 1314 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1262,9 +1326,10 @@ discard block |
||
| 1262 | 1326 | } |
| 1263 | 1327 | } |
| 1264 | 1328 | |
| 1265 | - if ($returnErrors) |
|
| 1266 | - return $errors; |
|
| 1267 | -} |
|
| 1329 | + if ($returnErrors) { |
|
| 1330 | + return $errors; |
|
| 1331 | + } |
|
| 1332 | + } |
|
| 1268 | 1333 | |
| 1269 | 1334 | /** |
| 1270 | 1335 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1276,8 +1341,9 @@ discard block |
||
| 1276 | 1341 | global $context, $txt, $modSettings; |
| 1277 | 1342 | |
| 1278 | 1343 | // Do a quick check to ensure people aren't getting here illegally! |
| 1279 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
| 1280 | - fatal_lang_error('no_access', false); |
|
| 1344 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
| 1345 | + fatal_lang_error('no_access', false); |
|
| 1346 | + } |
|
| 1281 | 1347 | |
| 1282 | 1348 | // Can we email the user direct? |
| 1283 | 1349 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1307,9 +1373,10 @@ discard block |
||
| 1307 | 1373 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
| 1308 | 1374 | $call = call_helper($subActions[$context['list_area']][0], true); |
| 1309 | 1375 | |
| 1310 | - if (!empty($call)) |
|
| 1311 | - call_user_func($call, $memID); |
|
| 1312 | -} |
|
| 1376 | + if (!empty($call)) { |
|
| 1377 | + call_user_func($call, $memID); |
|
| 1378 | + } |
|
| 1379 | + } |
|
| 1313 | 1380 | |
| 1314 | 1381 | /** |
| 1315 | 1382 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1323,9 +1390,10 @@ discard block |
||
| 1323 | 1390 | |
| 1324 | 1391 | // For making changes! |
| 1325 | 1392 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
| 1326 | - foreach ($buddiesArray as $k => $dummy) |
|
| 1327 | - if ($dummy == '') |
|
| 1393 | + foreach ($buddiesArray as $k => $dummy) { |
|
| 1394 | + if ($dummy == '') |
|
| 1328 | 1395 | unset($buddiesArray[$k]); |
| 1396 | + } |
|
| 1329 | 1397 | |
| 1330 | 1398 | // Removing a buddy? |
| 1331 | 1399 | if (isset($_GET['remove'])) |
@@ -1337,10 +1405,11 @@ discard block |
||
| 1337 | 1405 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1338 | 1406 | |
| 1339 | 1407 | // Heh, I'm lazy, do it the easy way... |
| 1340 | - foreach ($buddiesArray as $key => $buddy) |
|
| 1341 | - if ($buddy == (int) $_GET['remove']) |
|
| 1408 | + foreach ($buddiesArray as $key => $buddy) { |
|
| 1409 | + if ($buddy == (int) $_GET['remove']) |
|
| 1342 | 1410 | { |
| 1343 | 1411 | unset($buddiesArray[$key]); |
| 1412 | + } |
|
| 1344 | 1413 | $_SESSION['prf-save'] = true; |
| 1345 | 1414 | } |
| 1346 | 1415 | |
@@ -1350,8 +1419,7 @@ discard block |
||
| 1350 | 1419 | |
| 1351 | 1420 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1352 | 1421 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
| 1353 | - } |
|
| 1354 | - elseif (isset($_POST['new_buddy'])) |
|
| 1422 | + } elseif (isset($_POST['new_buddy'])) |
|
| 1355 | 1423 | { |
| 1356 | 1424 | checkSession(); |
| 1357 | 1425 | |
@@ -1364,8 +1432,9 @@ discard block |
||
| 1364 | 1432 | { |
| 1365 | 1433 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
| 1366 | 1434 | |
| 1367 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1368 | - unset($new_buddies[$k]); |
|
| 1435 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1436 | + unset($new_buddies[$k]); |
|
| 1437 | + } |
|
| 1369 | 1438 | } |
| 1370 | 1439 | |
| 1371 | 1440 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1385,16 +1454,18 @@ discard block |
||
| 1385 | 1454 | ) |
| 1386 | 1455 | ); |
| 1387 | 1456 | |
| 1388 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1389 | - $_SESSION['prf-save'] = true; |
|
| 1457 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1458 | + $_SESSION['prf-save'] = true; |
|
| 1459 | + } |
|
| 1390 | 1460 | |
| 1391 | 1461 | // Add the new member to the buddies array. |
| 1392 | 1462 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1393 | 1463 | { |
| 1394 | - if (in_array($row['id_member'], $buddiesArray)) |
|
| 1395 | - continue; |
|
| 1396 | - else |
|
| 1397 | - $buddiesArray[] = (int) $row['id_member']; |
|
| 1464 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
| 1465 | + continue; |
|
| 1466 | + } else { |
|
| 1467 | + $buddiesArray[] = (int) $row['id_member']; |
|
| 1468 | + } |
|
| 1398 | 1469 | } |
| 1399 | 1470 | $smcFunc['db_free_result']($request); |
| 1400 | 1471 | |
@@ -1424,18 +1495,20 @@ discard block |
||
| 1424 | 1495 | |
| 1425 | 1496 | $context['custom_pf'] = array(); |
| 1426 | 1497 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
| 1427 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1428 | - if (!isset($disabled_fields[$row['col_name']])) |
|
| 1498 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1499 | + if (!isset($disabled_fields[$row['col_name']])) |
|
| 1429 | 1500 | $context['custom_pf'][$row['col_name']] = array( |
| 1430 | 1501 | 'label' => $row['field_name'], |
| 1431 | 1502 | 'type' => $row['field_type'], |
| 1432 | 1503 | 'bbc' => !empty($row['bbc']), |
| 1433 | 1504 | 'enclose' => $row['enclose'], |
| 1434 | 1505 | ); |
| 1506 | + } |
|
| 1435 | 1507 | |
| 1436 | 1508 | // Gotta disable the gender option. |
| 1437 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
| 1438 | - unset($context['custom_pf']['cust_gender']); |
|
| 1509 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
| 1510 | + unset($context['custom_pf']['cust_gender']); |
|
| 1511 | + } |
|
| 1439 | 1512 | |
| 1440 | 1513 | $smcFunc['db_free_result']($request); |
| 1441 | 1514 | |
@@ -1452,8 +1525,9 @@ discard block |
||
| 1452 | 1525 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
| 1453 | 1526 | ) |
| 1454 | 1527 | ); |
| 1455 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1456 | - $buddies[] = $row['id_member']; |
|
| 1528 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1529 | + $buddies[] = $row['id_member']; |
|
| 1530 | + } |
|
| 1457 | 1531 | $smcFunc['db_free_result']($result); |
| 1458 | 1532 | } |
| 1459 | 1533 | |
@@ -1481,30 +1555,32 @@ discard block |
||
| 1481 | 1555 | continue; |
| 1482 | 1556 | } |
| 1483 | 1557 | |
| 1484 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1485 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1486 | - |
|
| 1487 | - elseif ($column['type'] == 'check') |
|
| 1488 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1558 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1559 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1560 | + } elseif ($column['type'] == 'check') { |
|
| 1561 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1562 | + } |
|
| 1489 | 1563 | |
| 1490 | 1564 | // Enclosing the user input within some other text? |
| 1491 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1492 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1565 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1566 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1493 | 1567 | '{SCRIPTURL}' => $scripturl, |
| 1494 | 1568 | '{IMAGES_URL}' => $settings['images_url'], |
| 1495 | 1569 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1496 | 1570 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
| 1497 | 1571 | )); |
| 1572 | + } |
|
| 1498 | 1573 | } |
| 1499 | 1574 | } |
| 1500 | 1575 | } |
| 1501 | 1576 | |
| 1502 | 1577 | if (isset($_SESSION['prf-save'])) |
| 1503 | 1578 | { |
| 1504 | - if ($_SESSION['prf-save'] === true) |
|
| 1505 | - $context['saved_successful'] = true; |
|
| 1506 | - else |
|
| 1507 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1579 | + if ($_SESSION['prf-save'] === true) { |
|
| 1580 | + $context['saved_successful'] = true; |
|
| 1581 | + } else { |
|
| 1582 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1583 | + } |
|
| 1508 | 1584 | |
| 1509 | 1585 | unset($_SESSION['prf-save']); |
| 1510 | 1586 | } |
@@ -1524,9 +1600,10 @@ discard block |
||
| 1524 | 1600 | |
| 1525 | 1601 | // For making changes! |
| 1526 | 1602 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
| 1527 | - foreach ($ignoreArray as $k => $dummy) |
|
| 1528 | - if ($dummy == '') |
|
| 1603 | + foreach ($ignoreArray as $k => $dummy) { |
|
| 1604 | + if ($dummy == '') |
|
| 1529 | 1605 | unset($ignoreArray[$k]); |
| 1606 | + } |
|
| 1530 | 1607 | |
| 1531 | 1608 | // Removing a member from the ignore list? |
| 1532 | 1609 | if (isset($_GET['remove'])) |
@@ -1536,10 +1613,11 @@ discard block |
||
| 1536 | 1613 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1537 | 1614 | |
| 1538 | 1615 | // Heh, I'm lazy, do it the easy way... |
| 1539 | - foreach ($ignoreArray as $key => $id_remove) |
|
| 1540 | - if ($id_remove == (int) $_GET['remove']) |
|
| 1616 | + foreach ($ignoreArray as $key => $id_remove) { |
|
| 1617 | + if ($id_remove == (int) $_GET['remove']) |
|
| 1541 | 1618 | { |
| 1542 | 1619 | unset($ignoreArray[$key]); |
| 1620 | + } |
|
| 1543 | 1621 | $_SESSION['prf-save'] = true; |
| 1544 | 1622 | } |
| 1545 | 1623 | |
@@ -1549,8 +1627,7 @@ discard block |
||
| 1549 | 1627 | |
| 1550 | 1628 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1551 | 1629 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
| 1552 | - } |
|
| 1553 | - elseif (isset($_POST['new_ignore'])) |
|
| 1630 | + } elseif (isset($_POST['new_ignore'])) |
|
| 1554 | 1631 | { |
| 1555 | 1632 | checkSession(); |
| 1556 | 1633 | // Prepare the string for extraction... |
@@ -1562,8 +1639,9 @@ discard block |
||
| 1562 | 1639 | { |
| 1563 | 1640 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
| 1564 | 1641 | |
| 1565 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1566 | - unset($new_entries[$k]); |
|
| 1642 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1643 | + unset($new_entries[$k]); |
|
| 1644 | + } |
|
| 1567 | 1645 | } |
| 1568 | 1646 | |
| 1569 | 1647 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1581,16 +1659,18 @@ discard block |
||
| 1581 | 1659 | ) |
| 1582 | 1660 | ); |
| 1583 | 1661 | |
| 1584 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1585 | - $_SESSION['prf-save'] = true; |
|
| 1662 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1663 | + $_SESSION['prf-save'] = true; |
|
| 1664 | + } |
|
| 1586 | 1665 | |
| 1587 | 1666 | // Add the new member to the buddies array. |
| 1588 | 1667 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1589 | 1668 | { |
| 1590 | - if (in_array($row['id_member'], $ignoreArray)) |
|
| 1591 | - continue; |
|
| 1592 | - else |
|
| 1593 | - $ignoreArray[] = (int) $row['id_member']; |
|
| 1669 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
| 1670 | + continue; |
|
| 1671 | + } else { |
|
| 1672 | + $ignoreArray[] = (int) $row['id_member']; |
|
| 1673 | + } |
|
| 1594 | 1674 | } |
| 1595 | 1675 | $smcFunc['db_free_result']($request); |
| 1596 | 1676 | |
@@ -1619,8 +1699,9 @@ discard block |
||
| 1619 | 1699 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
| 1620 | 1700 | ) |
| 1621 | 1701 | ); |
| 1622 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1623 | - $ignored[] = $row['id_member']; |
|
| 1702 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1703 | + $ignored[] = $row['id_member']; |
|
| 1704 | + } |
|
| 1624 | 1705 | $smcFunc['db_free_result']($result); |
| 1625 | 1706 | } |
| 1626 | 1707 | |
@@ -1639,10 +1720,11 @@ discard block |
||
| 1639 | 1720 | |
| 1640 | 1721 | if (isset($_SESSION['prf-save'])) |
| 1641 | 1722 | { |
| 1642 | - if ($_SESSION['prf-save'] === true) |
|
| 1643 | - $context['saved_successful'] = true; |
|
| 1644 | - else |
|
| 1645 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1723 | + if ($_SESSION['prf-save'] === true) { |
|
| 1724 | + $context['saved_successful'] = true; |
|
| 1725 | + } else { |
|
| 1726 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1727 | + } |
|
| 1646 | 1728 | |
| 1647 | 1729 | unset($_SESSION['prf-save']); |
| 1648 | 1730 | } |
@@ -1658,8 +1740,9 @@ discard block |
||
| 1658 | 1740 | global $context, $txt; |
| 1659 | 1741 | |
| 1660 | 1742 | loadThemeOptions($memID); |
| 1661 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
| 1662 | - loadCustomFields($memID, 'account'); |
|
| 1743 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
| 1744 | + loadCustomFields($memID, 'account'); |
|
| 1745 | + } |
|
| 1663 | 1746 | |
| 1664 | 1747 | $context['sub_template'] = 'edit_options'; |
| 1665 | 1748 | $context['page_desc'] = $txt['account_info']; |
@@ -1686,8 +1769,9 @@ discard block |
||
| 1686 | 1769 | global $context, $txt; |
| 1687 | 1770 | |
| 1688 | 1771 | loadThemeOptions($memID); |
| 1689 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
| 1690 | - loadCustomFields($memID, 'forumprofile'); |
|
| 1772 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
| 1773 | + loadCustomFields($memID, 'forumprofile'); |
|
| 1774 | + } |
|
| 1691 | 1775 | |
| 1692 | 1776 | $context['sub_template'] = 'edit_options'; |
| 1693 | 1777 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1720,18 +1804,21 @@ discard block |
||
| 1720 | 1804 | $dirs = array(); |
| 1721 | 1805 | $files = array(); |
| 1722 | 1806 | |
| 1723 | - if (!$dir) |
|
| 1724 | - return array(); |
|
| 1807 | + if (!$dir) { |
|
| 1808 | + return array(); |
|
| 1809 | + } |
|
| 1725 | 1810 | |
| 1726 | 1811 | while ($line = $dir->read()) |
| 1727 | 1812 | { |
| 1728 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
| 1729 | - continue; |
|
| 1813 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
| 1814 | + continue; |
|
| 1815 | + } |
|
| 1730 | 1816 | |
| 1731 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
| 1732 | - $dirs[] = $line; |
|
| 1733 | - else |
|
| 1734 | - $files[] = $line; |
|
| 1817 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
| 1818 | + $dirs[] = $line; |
|
| 1819 | + } else { |
|
| 1820 | + $files[] = $line; |
|
| 1821 | + } |
|
| 1735 | 1822 | } |
| 1736 | 1823 | $dir->close(); |
| 1737 | 1824 | |
@@ -1752,14 +1839,15 @@ discard block |
||
| 1752 | 1839 | foreach ($dirs as $line) |
| 1753 | 1840 | { |
| 1754 | 1841 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
| 1755 | - if (!empty($tmp)) |
|
| 1756 | - $result[] = array( |
|
| 1842 | + if (!empty($tmp)) { |
|
| 1843 | + $result[] = array( |
|
| 1757 | 1844 | 'filename' => $smcFunc['htmlspecialchars']($line), |
| 1758 | 1845 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
| 1759 | 1846 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
| 1760 | 1847 | 'is_dir' => true, |
| 1761 | 1848 | 'files' => $tmp |
| 1762 | 1849 | ); |
| 1850 | + } |
|
| 1763 | 1851 | unset($tmp); |
| 1764 | 1852 | } |
| 1765 | 1853 | |
@@ -1769,8 +1857,9 @@ discard block |
||
| 1769 | 1857 | $extension = substr(strrchr($line, '.'), 1); |
| 1770 | 1858 | |
| 1771 | 1859 | // Make sure it is an image. |
| 1772 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
| 1773 | - continue; |
|
| 1860 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
| 1861 | + continue; |
|
| 1862 | + } |
|
| 1774 | 1863 | |
| 1775 | 1864 | $result[] = array( |
| 1776 | 1865 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1778,8 +1867,9 @@ discard block |
||
| 1778 | 1867 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
| 1779 | 1868 | 'is_dir' => false |
| 1780 | 1869 | ); |
| 1781 | - if ($level == 1) |
|
| 1782 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1870 | + if ($level == 1) { |
|
| 1871 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1872 | + } |
|
| 1783 | 1873 | } |
| 1784 | 1874 | |
| 1785 | 1875 | return $result; |
@@ -1798,8 +1888,9 @@ discard block |
||
| 1798 | 1888 | loadSubTemplate('options'); |
| 1799 | 1889 | |
| 1800 | 1890 | loadThemeOptions($memID); |
| 1801 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
| 1802 | - loadCustomFields($memID, 'theme'); |
|
| 1891 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
| 1892 | + loadCustomFields($memID, 'theme'); |
|
| 1893 | + } |
|
| 1803 | 1894 | |
| 1804 | 1895 | $context['sub_template'] = 'edit_options'; |
| 1805 | 1896 | $context['page_desc'] = $txt['theme_info']; |
@@ -1853,16 +1944,19 @@ discard block |
||
| 1853 | 1944 | { |
| 1854 | 1945 | global $txt, $context, $modSettings, $smcFunc, $sourcedir; |
| 1855 | 1946 | |
| 1856 | - if (!isset($context['token_check'])) |
|
| 1857 | - $context['token_check'] = 'profile-nt' . $memID; |
|
| 1947 | + if (!isset($context['token_check'])) { |
|
| 1948 | + $context['token_check'] = 'profile-nt' . $memID; |
|
| 1949 | + } |
|
| 1858 | 1950 | |
| 1859 | 1951 | is_not_guest(); |
| 1860 | - if (!$context['user']['is_owner']) |
|
| 1861 | - isAllowedTo('profile_extra_any'); |
|
| 1952 | + if (!$context['user']['is_owner']) { |
|
| 1953 | + isAllowedTo('profile_extra_any'); |
|
| 1954 | + } |
|
| 1862 | 1955 | |
| 1863 | 1956 | // Set the post action if we're coming from the profile... |
| 1864 | - if (!isset($context['action'])) |
|
| 1865 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1957 | + if (!isset($context['action'])) { |
|
| 1958 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1959 | + } |
|
| 1866 | 1960 | |
| 1867 | 1961 | // What options are set |
| 1868 | 1962 | loadThemeOptions($memID); |
@@ -1949,28 +2043,34 @@ discard block |
||
| 1949 | 2043 | ); |
| 1950 | 2044 | |
| 1951 | 2045 | // There are certain things that are disabled at the group level. |
| 1952 | - if (empty($modSettings['cal_enabled'])) |
|
| 1953 | - unset($alert_types['calendar']); |
|
| 2046 | + if (empty($modSettings['cal_enabled'])) { |
|
| 2047 | + unset($alert_types['calendar']); |
|
| 2048 | + } |
|
| 1954 | 2049 | |
| 1955 | 2050 | // Disable paid subscriptions at group level if they're disabled |
| 1956 | - if (empty($modSettings['paid_enabled'])) |
|
| 1957 | - unset($alert_types['paidsubs']); |
|
| 2051 | + if (empty($modSettings['paid_enabled'])) { |
|
| 2052 | + unset($alert_types['paidsubs']); |
|
| 2053 | + } |
|
| 1958 | 2054 | |
| 1959 | 2055 | // Disable membergroup requests at group level if they're disabled |
| 1960 | - if (empty($modSettings['show_group_membership'])) |
|
| 1961 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2056 | + if (empty($modSettings['show_group_membership'])) { |
|
| 2057 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2058 | + } |
|
| 1962 | 2059 | |
| 1963 | 2060 | // Disable mentions if they're disabled |
| 1964 | - if (empty($modSettings['enable_mentions'])) |
|
| 1965 | - unset($alert_types['msg']['msg_mention']); |
|
| 2061 | + if (empty($modSettings['enable_mentions'])) { |
|
| 2062 | + unset($alert_types['msg']['msg_mention']); |
|
| 2063 | + } |
|
| 1966 | 2064 | |
| 1967 | 2065 | // Disable likes if they're disabled |
| 1968 | - if (empty($modSettings['enable_likes'])) |
|
| 1969 | - unset($alert_types['msg']['msg_like']); |
|
| 2066 | + if (empty($modSettings['enable_likes'])) { |
|
| 2067 | + unset($alert_types['msg']['msg_like']); |
|
| 2068 | + } |
|
| 1970 | 2069 | |
| 1971 | 2070 | // Disable buddy requests if they're disabled |
| 1972 | - if (empty($modSettings['enable_buddylist'])) |
|
| 1973 | - unset($alert_types['members']['buddy_request']); |
|
| 2071 | + if (empty($modSettings['enable_buddylist'])) { |
|
| 2072 | + unset($alert_types['members']['buddy_request']); |
|
| 2073 | + } |
|
| 1974 | 2074 | |
| 1975 | 2075 | // Now, now, we could pass this through global but we should really get into the habit of |
| 1976 | 2076 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -1998,15 +2098,17 @@ discard block |
||
| 1998 | 2098 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
| 1999 | 2099 | } |
| 2000 | 2100 | |
| 2001 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
| 2002 | - unset($alert_types['members']['request_group']); |
|
| 2101 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
| 2102 | + unset($alert_types['members']['request_group']); |
|
| 2103 | + } |
|
| 2003 | 2104 | |
| 2004 | 2105 | foreach ($alert_types as $group => $items) |
| 2005 | 2106 | { |
| 2006 | 2107 | foreach ($items as $alert_key => $alert_value) |
| 2007 | 2108 | { |
| 2008 | - if (!isset($alert_value['permission'])) |
|
| 2009 | - continue; |
|
| 2109 | + if (!isset($alert_value['permission'])) { |
|
| 2110 | + continue; |
|
| 2111 | + } |
|
| 2010 | 2112 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
| 2011 | 2113 | { |
| 2012 | 2114 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2014,12 +2116,14 @@ discard block |
||
| 2014 | 2116 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
| 2015 | 2117 | } |
| 2016 | 2118 | |
| 2017 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
| 2018 | - unset ($alert_types[$group][$alert_key]); |
|
| 2119 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
| 2120 | + unset ($alert_types[$group][$alert_key]); |
|
| 2121 | + } |
|
| 2019 | 2122 | } |
| 2020 | 2123 | |
| 2021 | - if (empty($alert_types[$group])) |
|
| 2022 | - unset ($alert_types[$group]); |
|
| 2124 | + if (empty($alert_types[$group])) { |
|
| 2125 | + unset ($alert_types[$group]); |
|
| 2126 | + } |
|
| 2023 | 2127 | } |
| 2024 | 2128 | } |
| 2025 | 2129 | |
@@ -2051,9 +2155,9 @@ discard block |
||
| 2051 | 2155 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
| 2052 | 2156 | break; |
| 2053 | 2157 | case 'select': |
| 2054 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
| 2055 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2056 | - else |
|
| 2158 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
| 2159 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2160 | + } else |
|
| 2057 | 2161 | { |
| 2058 | 2162 | // We didn't have a sane value. Let's grab the first item from the possibles. |
| 2059 | 2163 | $keys = array_keys($this_option['opts']); |
@@ -2073,23 +2177,28 @@ discard block |
||
| 2073 | 2177 | $this_value = 0; |
| 2074 | 2178 | foreach ($context['alert_bits'] as $type => $bitvalue) |
| 2075 | 2179 | { |
| 2076 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
| 2077 | - $this_value |= $bitvalue; |
|
| 2180 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
| 2181 | + $this_value |= $bitvalue; |
|
| 2182 | + } |
|
| 2183 | + } |
|
| 2184 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
| 2185 | + $update_prefs[$item_key] = $this_value; |
|
| 2078 | 2186 | } |
| 2079 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
| 2080 | - $update_prefs[$item_key] = $this_value; |
|
| 2081 | 2187 | } |
| 2082 | 2188 | } |
| 2083 | 2189 | |
| 2084 | - if (!empty($_POST['opt_alert_timeout'])) |
|
| 2085 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2190 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
| 2191 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2192 | + } |
|
| 2086 | 2193 | |
| 2087 | - if (!empty($_POST['notify_announcements'])) |
|
| 2088 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2194 | + if (!empty($_POST['notify_announcements'])) { |
|
| 2195 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2196 | + } |
|
| 2089 | 2197 | |
| 2090 | 2198 | setNotifyPrefs((int) $memID, $update_prefs); |
| 2091 | - foreach ($update_prefs as $pref => $value) |
|
| 2092 | - $context['alert_prefs'][$pref] = $value; |
|
| 2199 | + foreach ($update_prefs as $pref => $value) { |
|
| 2200 | + $context['alert_prefs'][$pref] = $value; |
|
| 2201 | + } |
|
| 2093 | 2202 | |
| 2094 | 2203 | makeNotificationChanges($memID); |
| 2095 | 2204 | |
@@ -2119,8 +2228,9 @@ discard block |
||
| 2119 | 2228 | |
| 2120 | 2229 | // Now we're all set up. |
| 2121 | 2230 | is_not_guest(); |
| 2122 | - if (!$context['user']['is_owner']) |
|
| 2123 | - fatal_error('no_access'); |
|
| 2231 | + if (!$context['user']['is_owner']) { |
|
| 2232 | + fatal_error('no_access'); |
|
| 2233 | + } |
|
| 2124 | 2234 | |
| 2125 | 2235 | checkSession('get'); |
| 2126 | 2236 | |
@@ -2152,8 +2262,9 @@ discard block |
||
| 2152 | 2262 | { |
| 2153 | 2263 | global $smcFunc; |
| 2154 | 2264 | |
| 2155 | - if (empty($toMark) || empty($memID)) |
|
| 2156 | - return false; |
|
| 2265 | + if (empty($toMark) || empty($memID)) { |
|
| 2266 | + return false; |
|
| 2267 | + } |
|
| 2157 | 2268 | |
| 2158 | 2269 | $toMark = (array) $toMark; |
| 2159 | 2270 | |
@@ -2187,8 +2298,9 @@ discard block |
||
| 2187 | 2298 | { |
| 2188 | 2299 | global $smcFunc; |
| 2189 | 2300 | |
| 2190 | - if (empty($toDelete)) |
|
| 2191 | - return false; |
|
| 2301 | + if (empty($toDelete)) { |
|
| 2302 | + return false; |
|
| 2303 | + } |
|
| 2192 | 2304 | |
| 2193 | 2305 | $toDelete = (array) $toDelete; |
| 2194 | 2306 | |
@@ -2223,8 +2335,9 @@ discard block |
||
| 2223 | 2335 | { |
| 2224 | 2336 | global $smcFunc; |
| 2225 | 2337 | |
| 2226 | - if (empty($memID)) |
|
| 2227 | - return false; |
|
| 2338 | + if (empty($memID)) { |
|
| 2339 | + return false; |
|
| 2340 | + } |
|
| 2228 | 2341 | |
| 2229 | 2342 | $request = $smcFunc['db_query']('', ' |
| 2230 | 2343 | SELECT id_alert |
@@ -2301,8 +2414,9 @@ discard block |
||
| 2301 | 2414 | { |
| 2302 | 2415 | $link = $topic['link']; |
| 2303 | 2416 | |
| 2304 | - if ($topic['new']) |
|
| 2305 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2417 | + if ($topic['new']) { |
|
| 2418 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2419 | + } |
|
| 2306 | 2420 | |
| 2307 | 2421 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
| 2308 | 2422 | |
@@ -2453,8 +2567,9 @@ discard block |
||
| 2453 | 2567 | { |
| 2454 | 2568 | $link = $board['link']; |
| 2455 | 2569 | |
| 2456 | - if ($board['new']) |
|
| 2457 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2570 | + if ($board['new']) { |
|
| 2571 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2572 | + } |
|
| 2458 | 2573 | |
| 2459 | 2574 | return $link; |
| 2460 | 2575 | }, |
@@ -2654,8 +2769,8 @@ discard block |
||
| 2654 | 2769 | ) |
| 2655 | 2770 | ); |
| 2656 | 2771 | $notification_boards = array(); |
| 2657 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2658 | - $notification_boards[] = array( |
|
| 2772 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2773 | + $notification_boards[] = array( |
|
| 2659 | 2774 | 'id' => $row['id_board'], |
| 2660 | 2775 | 'name' => $row['name'], |
| 2661 | 2776 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2663,6 +2778,7 @@ discard block |
||
| 2663 | 2778 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
| 2664 | 2779 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
| 2665 | 2780 | ); |
| 2781 | + } |
|
| 2666 | 2782 | $smcFunc['db_free_result']($request); |
| 2667 | 2783 | |
| 2668 | 2784 | return $notification_boards; |
@@ -2677,17 +2793,18 @@ discard block |
||
| 2677 | 2793 | { |
| 2678 | 2794 | global $context, $options, $cur_profile, $smcFunc; |
| 2679 | 2795 | |
| 2680 | - if (isset($_POST['default_options'])) |
|
| 2681 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2796 | + if (isset($_POST['default_options'])) { |
|
| 2797 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2798 | + } |
|
| 2682 | 2799 | |
| 2683 | 2800 | if ($context['user']['is_owner']) |
| 2684 | 2801 | { |
| 2685 | 2802 | $context['member']['options'] = $options; |
| 2686 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
| 2687 | - foreach ($_POST['options'] as $k => $v) |
|
| 2803 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
| 2804 | + foreach ($_POST['options'] as $k => $v) |
|
| 2688 | 2805 | $context['member']['options'][$k] = $v; |
| 2689 | - } |
|
| 2690 | - else |
|
| 2806 | + } |
|
| 2807 | + } else |
|
| 2691 | 2808 | { |
| 2692 | 2809 | $request = $smcFunc['db_query']('', ' |
| 2693 | 2810 | SELECT id_member, variable, value |
@@ -2708,8 +2825,9 @@ discard block |
||
| 2708 | 2825 | continue; |
| 2709 | 2826 | } |
| 2710 | 2827 | |
| 2711 | - if (isset($_POST['options'][$row['variable']])) |
|
| 2712 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2828 | + if (isset($_POST['options'][$row['variable']])) { |
|
| 2829 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2830 | + } |
|
| 2713 | 2831 | $context['member']['options'][$row['variable']] = $row['value']; |
| 2714 | 2832 | } |
| 2715 | 2833 | $smcFunc['db_free_result']($request); |
@@ -2717,8 +2835,9 @@ discard block |
||
| 2717 | 2835 | // Load up the default theme options for any missing. |
| 2718 | 2836 | foreach ($temp as $k => $v) |
| 2719 | 2837 | { |
| 2720 | - if (!isset($context['member']['options'][$k])) |
|
| 2721 | - $context['member']['options'][$k] = $v; |
|
| 2838 | + if (!isset($context['member']['options'][$k])) { |
|
| 2839 | + $context['member']['options'][$k] = $v; |
|
| 2840 | + } |
|
| 2722 | 2841 | } |
| 2723 | 2842 | } |
| 2724 | 2843 | } |
@@ -2733,8 +2852,9 @@ discard block |
||
| 2733 | 2852 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
| 2734 | 2853 | |
| 2735 | 2854 | // Have the admins enabled this option? |
| 2736 | - if (empty($modSettings['allow_ignore_boards'])) |
|
| 2737 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2855 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
| 2856 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2857 | + } |
|
| 2738 | 2858 | |
| 2739 | 2859 | // Find all the boards this user is allowed to see. |
| 2740 | 2860 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2754,12 +2874,13 @@ discard block |
||
| 2754 | 2874 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2755 | 2875 | { |
| 2756 | 2876 | // This category hasn't been set up yet.. |
| 2757 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 2758 | - $context['categories'][$row['id_cat']] = array( |
|
| 2877 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 2878 | + $context['categories'][$row['id_cat']] = array( |
|
| 2759 | 2879 | 'id' => $row['id_cat'], |
| 2760 | 2880 | 'name' => $row['cat_name'], |
| 2761 | 2881 | 'boards' => array() |
| 2762 | 2882 | ); |
| 2883 | + } |
|
| 2763 | 2884 | |
| 2764 | 2885 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 2765 | 2886 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2789,18 +2910,20 @@ discard block |
||
| 2789 | 2910 | } |
| 2790 | 2911 | |
| 2791 | 2912 | $max_boards = ceil(count($temp_boards) / 2); |
| 2792 | - if ($max_boards == 1) |
|
| 2793 | - $max_boards = 2; |
|
| 2913 | + if ($max_boards == 1) { |
|
| 2914 | + $max_boards = 2; |
|
| 2915 | + } |
|
| 2794 | 2916 | |
| 2795 | 2917 | // Now, alternate them so they can be shown left and right ;). |
| 2796 | 2918 | $context['board_columns'] = array(); |
| 2797 | 2919 | for ($i = 0; $i < $max_boards; $i++) |
| 2798 | 2920 | { |
| 2799 | 2921 | $context['board_columns'][] = $temp_boards[$i]; |
| 2800 | - if (isset($temp_boards[$i + $max_boards])) |
|
| 2801 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2802 | - else |
|
| 2803 | - $context['board_columns'][] = array(); |
|
| 2922 | + if (isset($temp_boards[$i + $max_boards])) { |
|
| 2923 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2924 | + } else { |
|
| 2925 | + $context['board_columns'][] = array(); |
|
| 2926 | + } |
|
| 2804 | 2927 | } |
| 2805 | 2928 | |
| 2806 | 2929 | loadThemeOptions($memID); |
@@ -2869,8 +2992,9 @@ discard block |
||
| 2869 | 2992 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2870 | 2993 | { |
| 2871 | 2994 | // We should skip the administrator group if they don't have the admin_forum permission! |
| 2872 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
| 2873 | - continue; |
|
| 2995 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
| 2996 | + continue; |
|
| 2997 | + } |
|
| 2874 | 2998 | |
| 2875 | 2999 | $context['member_groups'][$row['id_group']] = array( |
| 2876 | 3000 | 'id' => $row['id_group'], |
@@ -2916,16 +3040,17 @@ discard block |
||
| 2916 | 3040 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
| 2917 | 3041 | // Warning message for signature image limits? |
| 2918 | 3042 | $context['signature_warning'] = ''; |
| 2919 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
| 2920 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 2921 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
| 2922 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3043 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
| 3044 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 3045 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
| 3046 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3047 | + } |
|
| 2923 | 3048 | |
| 2924 | 3049 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
| 2925 | 3050 | |
| 2926 | - if (empty($context['do_preview'])) |
|
| 2927 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 2928 | - else |
|
| 3051 | + if (empty($context['do_preview'])) { |
|
| 3052 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 3053 | + } else |
|
| 2929 | 3054 | { |
| 2930 | 3055 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
| 2931 | 3056 | $validation = profileValidateSignature($signature); |
@@ -2935,8 +3060,9 @@ discard block |
||
| 2935 | 3060 | $context['post_errors'] = array(); |
| 2936 | 3061 | } |
| 2937 | 3062 | $context['post_errors'][] = 'signature_not_yet_saved'; |
| 2938 | - if ($validation !== true && $validation !== false) |
|
| 2939 | - $context['post_errors'][] = $validation; |
|
| 3063 | + if ($validation !== true && $validation !== false) { |
|
| 3064 | + $context['post_errors'][] = $validation; |
|
| 3065 | + } |
|
| 2940 | 3066 | |
| 2941 | 3067 | censorText($context['member']['signature']); |
| 2942 | 3068 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2946,8 +3072,9 @@ discard block |
||
| 2946 | 3072 | } |
| 2947 | 3073 | |
| 2948 | 3074 | // Load the spell checker? |
| 2949 | - if ($context['show_spellchecking']) |
|
| 2950 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3075 | + if ($context['show_spellchecking']) { |
|
| 3076 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3077 | + } |
|
| 2951 | 3078 | |
| 2952 | 3079 | return true; |
| 2953 | 3080 | } |
@@ -2981,8 +3108,7 @@ discard block |
||
| 2981 | 3108 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
| 2982 | 3109 | ); |
| 2983 | 3110 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
| 2984 | - } |
|
| 2985 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3111 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 2986 | 3112 | { |
| 2987 | 3113 | $context['member']['avatar'] += array( |
| 2988 | 3114 | 'choice' => 'upload', |
@@ -2992,33 +3118,34 @@ discard block |
||
| 2992 | 3118 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
| 2993 | 3119 | } |
| 2994 | 3120 | // Use "avatar_original" here so we show what the user entered even if the image proxy is enabled |
| 2995 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
| 2996 | - $context['member']['avatar'] += array( |
|
| 3121 | + elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
| 3122 | + $context['member']['avatar'] += array( |
|
| 2997 | 3123 | 'choice' => 'external', |
| 2998 | 3124 | 'server_pic' => 'blank.png', |
| 2999 | 3125 | 'external' => $cur_profile['avatar_original'] |
| 3000 | 3126 | ); |
| 3001 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
| 3002 | - $context['member']['avatar'] += array( |
|
| 3127 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
| 3128 | + $context['member']['avatar'] += array( |
|
| 3003 | 3129 | 'choice' => 'server_stored', |
| 3004 | 3130 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
| 3005 | 3131 | 'external' => 'http://' |
| 3006 | 3132 | ); |
| 3007 | - else |
|
| 3008 | - $context['member']['avatar'] += array( |
|
| 3133 | + } else { |
|
| 3134 | + $context['member']['avatar'] += array( |
|
| 3009 | 3135 | 'choice' => 'none', |
| 3010 | 3136 | 'server_pic' => 'blank.png', |
| 3011 | 3137 | 'external' => 'http://' |
| 3012 | 3138 | ); |
| 3139 | + } |
|
| 3013 | 3140 | |
| 3014 | 3141 | // Get a list of all the avatars. |
| 3015 | 3142 | if ($context['member']['avatar']['allow_server_stored']) |
| 3016 | 3143 | { |
| 3017 | 3144 | $context['avatar_list'] = array(); |
| 3018 | 3145 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
| 3146 | + } else { |
|
| 3147 | + $context['avatars'] = array(); |
|
| 3019 | 3148 | } |
| 3020 | - else |
|
| 3021 | - $context['avatars'] = array(); |
|
| 3022 | 3149 | |
| 3023 | 3150 | // Second level selected avatar... |
| 3024 | 3151 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3047,19 +3174,22 @@ discard block |
||
| 3047 | 3174 | ) |
| 3048 | 3175 | ); |
| 3049 | 3176 | $protected_groups = array(1); |
| 3050 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3051 | - $protected_groups[] = $row['id_group']; |
|
| 3177 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3178 | + $protected_groups[] = $row['id_group']; |
|
| 3179 | + } |
|
| 3052 | 3180 | $smcFunc['db_free_result']($request); |
| 3053 | 3181 | |
| 3054 | 3182 | $protected_groups = array_unique($protected_groups); |
| 3055 | 3183 | } |
| 3056 | 3184 | |
| 3057 | 3185 | // The account page allows the change of your id_group - but not to a protected group! |
| 3058 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
| 3059 | - $value = (int) $value; |
|
| 3186 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
| 3187 | + $value = (int) $value; |
|
| 3188 | + } |
|
| 3060 | 3189 | // ... otherwise it's the old group sir. |
| 3061 | - else |
|
| 3062 | - $value = $old_profile['id_group']; |
|
| 3190 | + else { |
|
| 3191 | + $value = $old_profile['id_group']; |
|
| 3192 | + } |
|
| 3063 | 3193 | |
| 3064 | 3194 | // Find the additional membergroups (if any) |
| 3065 | 3195 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3068,16 +3198,18 @@ discard block |
||
| 3068 | 3198 | foreach ($_POST['additional_groups'] as $group_id) |
| 3069 | 3199 | { |
| 3070 | 3200 | $group_id = (int) $group_id; |
| 3071 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
| 3072 | - $additional_groups[] = $group_id; |
|
| 3201 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
| 3202 | + $additional_groups[] = $group_id; |
|
| 3203 | + } |
|
| 3073 | 3204 | } |
| 3074 | 3205 | |
| 3075 | 3206 | // Put the protected groups back in there if you don't have permission to take them away. |
| 3076 | 3207 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
| 3077 | 3208 | foreach ($old_additional_groups as $group_id) |
| 3078 | 3209 | { |
| 3079 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
| 3080 | - $additional_groups[] = $group_id; |
|
| 3210 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
| 3211 | + $additional_groups[] = $group_id; |
|
| 3212 | + } |
|
| 3081 | 3213 | } |
| 3082 | 3214 | |
| 3083 | 3215 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3109,18 +3241,20 @@ discard block |
||
| 3109 | 3241 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 3110 | 3242 | $smcFunc['db_free_result']($request); |
| 3111 | 3243 | |
| 3112 | - if (empty($another)) |
|
| 3113 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3244 | + if (empty($another)) { |
|
| 3245 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3246 | + } |
|
| 3114 | 3247 | } |
| 3115 | 3248 | } |
| 3116 | 3249 | |
| 3117 | 3250 | // If we are changing group status, update permission cache as necessary. |
| 3118 | 3251 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
| 3119 | 3252 | { |
| 3120 | - if ($context['user']['is_owner']) |
|
| 3121 | - $_SESSION['mc']['time'] = 0; |
|
| 3122 | - else |
|
| 3123 | - updateSettings(array('settings_updated' => time())); |
|
| 3253 | + if ($context['user']['is_owner']) { |
|
| 3254 | + $_SESSION['mc']['time'] = 0; |
|
| 3255 | + } else { |
|
| 3256 | + updateSettings(array('settings_updated' => time())); |
|
| 3257 | + } |
|
| 3124 | 3258 | } |
| 3125 | 3259 | |
| 3126 | 3260 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3141,8 +3275,9 @@ discard block |
||
| 3141 | 3275 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
| 3142 | 3276 | |
| 3143 | 3277 | $memID = $context['id_member']; |
| 3144 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
| 3145 | - return false; |
|
| 3278 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
| 3279 | + return false; |
|
| 3280 | + } |
|
| 3146 | 3281 | |
| 3147 | 3282 | require_once($sourcedir . '/ManageAttachments.php'); |
| 3148 | 3283 | |
@@ -3153,8 +3288,9 @@ discard block |
||
| 3153 | 3288 | $downloadedExternalAvatar = false; |
| 3154 | 3289 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
| 3155 | 3290 | { |
| 3156 | - if (!is_writable($uploadDir)) |
|
| 3157 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3291 | + if (!is_writable($uploadDir)) { |
|
| 3292 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3293 | + } |
|
| 3158 | 3294 | |
| 3159 | 3295 | require_once($sourcedir . '/Subs-Package.php'); |
| 3160 | 3296 | |
@@ -3198,19 +3334,18 @@ discard block |
||
| 3198 | 3334 | |
| 3199 | 3335 | // Get rid of their old avatar. (if uploaded.) |
| 3200 | 3336 | removeAttachments(array('id_member' => $memID)); |
| 3201 | - } |
|
| 3202 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3337 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3203 | 3338 | { |
| 3204 | 3339 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
| 3205 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
| 3206 | - $profile_vars['avatar'] = 'gravatar://'; |
|
| 3207 | - else |
|
| 3208 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3340 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
| 3341 | + $profile_vars['avatar'] = 'gravatar://'; |
|
| 3342 | + } else { |
|
| 3343 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3344 | + } |
|
| 3209 | 3345 | |
| 3210 | 3346 | // Get rid of their old avatar. (if uploaded.) |
| 3211 | 3347 | removeAttachments(array('id_member' => $memID)); |
| 3212 | - } |
|
| 3213 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3348 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3214 | 3349 | { |
| 3215 | 3350 | // We need these clean... |
| 3216 | 3351 | $cur_profile['id_attach'] = 0; |
@@ -3222,11 +3357,13 @@ discard block |
||
| 3222 | 3357 | |
| 3223 | 3358 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
| 3224 | 3359 | |
| 3225 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
| 3226 | - $profile_vars['avatar'] = ''; |
|
| 3360 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
| 3361 | + $profile_vars['avatar'] = ''; |
|
| 3362 | + } |
|
| 3227 | 3363 | // Trying to make us do something we'll regret? |
| 3228 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
| 3229 | - return 'bad_avatar_invalid_url'; |
|
| 3364 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
| 3365 | + return 'bad_avatar_invalid_url'; |
|
| 3366 | + } |
|
| 3230 | 3367 | // Should we check dimensions? |
| 3231 | 3368 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
| 3232 | 3369 | { |
@@ -3236,9 +3373,9 @@ discard block |
||
| 3236 | 3373 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
| 3237 | 3374 | { |
| 3238 | 3375 | // Houston, we have a problem. The avatar is too large!! |
| 3239 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
| 3240 | - return 'bad_avatar_too_large'; |
|
| 3241 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3376 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
| 3377 | + return 'bad_avatar_too_large'; |
|
| 3378 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3242 | 3379 | { |
| 3243 | 3380 | // @todo remove this if appropriate |
| 3244 | 3381 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3248,26 +3385,27 @@ discard block |
||
| 3248 | 3385 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
| 3249 | 3386 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
| 3250 | 3387 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
| 3388 | + } else { |
|
| 3389 | + return 'bad_avatar'; |
|
| 3251 | 3390 | } |
| 3252 | - else |
|
| 3253 | - return 'bad_avatar'; |
|
| 3254 | 3391 | } |
| 3255 | 3392 | } |
| 3256 | 3393 | } |
| 3257 | - } |
|
| 3258 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3394 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3259 | 3395 | { |
| 3260 | 3396 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
| 3261 | 3397 | { |
| 3262 | 3398 | // Get the dimensions of the image. |
| 3263 | 3399 | if (!$downloadedExternalAvatar) |
| 3264 | 3400 | { |
| 3265 | - if (!is_writable($uploadDir)) |
|
| 3266 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3401 | + if (!is_writable($uploadDir)) { |
|
| 3402 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3403 | + } |
|
| 3267 | 3404 | |
| 3268 | 3405 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
| 3269 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
| 3270 | - fatal_lang_error('attach_timeout', 'critical'); |
|
| 3406 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
| 3407 | + fatal_lang_error('attach_timeout', 'critical'); |
|
| 3408 | + } |
|
| 3271 | 3409 | |
| 3272 | 3410 | $_FILES['attachment']['tmp_name'] = $new_filename; |
| 3273 | 3411 | } |
@@ -3380,17 +3518,19 @@ discard block |
||
| 3380 | 3518 | $profile_vars['avatar'] = ''; |
| 3381 | 3519 | |
| 3382 | 3520 | // Delete any temporary file. |
| 3383 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
| 3384 | - @unlink($_FILES['attachment']['tmp_name']); |
|
| 3521 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
| 3522 | + @unlink($_FILES['attachment']['tmp_name']); |
|
| 3523 | + } |
|
| 3385 | 3524 | } |
| 3386 | 3525 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
| 3387 | - else |
|
| 3526 | + else { |
|
| 3527 | + $profile_vars['avatar'] = ''; |
|
| 3528 | + } |
|
| 3529 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
| 3530 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3531 | + } else { |
|
| 3388 | 3532 | $profile_vars['avatar'] = ''; |
| 3389 | 3533 | } |
| 3390 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
| 3391 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3392 | - else |
|
| 3393 | - $profile_vars['avatar'] = ''; |
|
| 3394 | 3534 | |
| 3395 | 3535 | // Setup the profile variables so it shows things right on display! |
| 3396 | 3536 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3438,9 +3578,9 @@ discard block |
||
| 3438 | 3578 | $smiley_parsed = $unparsed_signature; |
| 3439 | 3579 | parsesmileys($smiley_parsed); |
| 3440 | 3580 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
| 3441 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
| 3442 | - return 'signature_allow_smileys'; |
|
| 3443 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3581 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
| 3582 | + return 'signature_allow_smileys'; |
|
| 3583 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3444 | 3584 | { |
| 3445 | 3585 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
| 3446 | 3586 | return 'signature_max_smileys'; |
@@ -3453,14 +3593,15 @@ discard block |
||
| 3453 | 3593 | { |
| 3454 | 3594 | $limit_broke = 0; |
| 3455 | 3595 | // Attempt to allow all sizes of abuse, so to speak. |
| 3456 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 3457 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 3458 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 3459 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3460 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 3461 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3462 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 3463 | - $limit_broke = 'large'; |
|
| 3596 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 3597 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 3598 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 3599 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3600 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 3601 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3602 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 3603 | + $limit_broke = 'large'; |
|
| 3604 | + } |
|
| 3464 | 3605 | |
| 3465 | 3606 | if ($limit_broke) |
| 3466 | 3607 | { |
@@ -3502,24 +3643,26 @@ discard block |
||
| 3502 | 3643 | $width = -1; $height = -1; |
| 3503 | 3644 | |
| 3504 | 3645 | // Does it have predefined restraints? Width first. |
| 3505 | - if ($matches[6][$key]) |
|
| 3506 | - $matches[2][$key] = $matches[6][$key]; |
|
| 3646 | + if ($matches[6][$key]) { |
|
| 3647 | + $matches[2][$key] = $matches[6][$key]; |
|
| 3648 | + } |
|
| 3507 | 3649 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 3508 | 3650 | { |
| 3509 | 3651 | $width = $sig_limits[5]; |
| 3510 | 3652 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 3653 | + } elseif ($matches[2][$key]) { |
|
| 3654 | + $width = $matches[2][$key]; |
|
| 3511 | 3655 | } |
| 3512 | - elseif ($matches[2][$key]) |
|
| 3513 | - $width = $matches[2][$key]; |
|
| 3514 | 3656 | // ... and height. |
| 3515 | 3657 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 3516 | 3658 | { |
| 3517 | 3659 | $height = $sig_limits[6]; |
| 3518 | - if ($width != -1) |
|
| 3519 | - $width = $width * ($height / $matches[4][$key]); |
|
| 3660 | + if ($width != -1) { |
|
| 3661 | + $width = $width * ($height / $matches[4][$key]); |
|
| 3662 | + } |
|
| 3663 | + } elseif ($matches[4][$key]) { |
|
| 3664 | + $height = $matches[4][$key]; |
|
| 3520 | 3665 | } |
| 3521 | - elseif ($matches[4][$key]) |
|
| 3522 | - $height = $matches[4][$key]; |
|
| 3523 | 3666 | |
| 3524 | 3667 | // If the dimensions are still not fixed - we need to check the actual image. |
| 3525 | 3668 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3537,21 +3680,24 @@ discard block |
||
| 3537 | 3680 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 3538 | 3681 | { |
| 3539 | 3682 | $height = $sig_limits[6]; |
| 3540 | - if ($width == -1) |
|
| 3541 | - $width = $sizes[0]; |
|
| 3683 | + if ($width == -1) { |
|
| 3684 | + $width = $sizes[0]; |
|
| 3685 | + } |
|
| 3542 | 3686 | $width = $width * ($height / $sizes[1]); |
| 3687 | + } elseif ($width != -1) { |
|
| 3688 | + $height = $sizes[1]; |
|
| 3543 | 3689 | } |
| 3544 | - elseif ($width != -1) |
|
| 3545 | - $height = $sizes[1]; |
|
| 3546 | 3690 | } |
| 3547 | 3691 | } |
| 3548 | 3692 | |
| 3549 | 3693 | // Did we come up with some changes? If so remake the string. |
| 3550 | - if ($width != -1 || $height != -1) |
|
| 3551 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3694 | + if ($width != -1 || $height != -1) { |
|
| 3695 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3696 | + } |
|
| 3697 | + } |
|
| 3698 | + if (!empty($replaces)) { |
|
| 3699 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3552 | 3700 | } |
| 3553 | - if (!empty($replaces)) |
|
| 3554 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3555 | 3701 | } |
| 3556 | 3702 | } |
| 3557 | 3703 | |
@@ -3595,10 +3741,12 @@ discard block |
||
| 3595 | 3741 | $email = strtr($email, array(''' => '\'')); |
| 3596 | 3742 | |
| 3597 | 3743 | // Check the name and email for validity. |
| 3598 | - if (trim($email) == '') |
|
| 3599 | - return 'no_email'; |
|
| 3600 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 3601 | - return 'bad_email'; |
|
| 3744 | + if (trim($email) == '') { |
|
| 3745 | + return 'no_email'; |
|
| 3746 | + } |
|
| 3747 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 3748 | + return 'bad_email'; |
|
| 3749 | + } |
|
| 3602 | 3750 | |
| 3603 | 3751 | // Email addresses should be and stay unique. |
| 3604 | 3752 | $request = $smcFunc['db_query']('', ' |
@@ -3613,8 +3761,9 @@ discard block |
||
| 3613 | 3761 | ) |
| 3614 | 3762 | ); |
| 3615 | 3763 | |
| 3616 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 3617 | - return 'email_taken'; |
|
| 3764 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 3765 | + return 'email_taken'; |
|
| 3766 | + } |
|
| 3618 | 3767 | $smcFunc['db_free_result']($request); |
| 3619 | 3768 | |
| 3620 | 3769 | return true; |
@@ -3627,8 +3776,9 @@ discard block |
||
| 3627 | 3776 | { |
| 3628 | 3777 | global $modSettings, $context, $cur_profile; |
| 3629 | 3778 | |
| 3630 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
| 3631 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3779 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
| 3780 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3781 | + } |
|
| 3632 | 3782 | |
| 3633 | 3783 | loadUserSettings(); |
| 3634 | 3784 | writeLog(); |
@@ -3644,8 +3794,9 @@ discard block |
||
| 3644 | 3794 | require_once($sourcedir . '/Subs-Post.php'); |
| 3645 | 3795 | |
| 3646 | 3796 | // Shouldn't happen but just in case. |
| 3647 | - if (empty($profile_vars['email_address'])) |
|
| 3648 | - return; |
|
| 3797 | + if (empty($profile_vars['email_address'])) { |
|
| 3798 | + return; |
|
| 3799 | + } |
|
| 3649 | 3800 | |
| 3650 | 3801 | $replacements = array( |
| 3651 | 3802 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3668,8 +3819,9 @@ discard block |
||
| 3668 | 3819 | $_SESSION['log_time'] = 0; |
| 3669 | 3820 | $_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0)); |
| 3670 | 3821 | |
| 3671 | - if (isset($_COOKIE[$cookiename])) |
|
| 3672 | - $_COOKIE[$cookiename] = ''; |
|
| 3822 | + if (isset($_COOKIE[$cookiename])) { |
|
| 3823 | + $_COOKIE[$cookiename] = ''; |
|
| 3824 | + } |
|
| 3673 | 3825 | |
| 3674 | 3826 | loadUserSettings(); |
| 3675 | 3827 | |
@@ -3702,11 +3854,13 @@ discard block |
||
| 3702 | 3854 | $groups[] = $curMember['id_group']; |
| 3703 | 3855 | |
| 3704 | 3856 | // Ensure the query doesn't croak! |
| 3705 | - if (empty($groups)) |
|
| 3706 | - $groups = array(0); |
|
| 3857 | + if (empty($groups)) { |
|
| 3858 | + $groups = array(0); |
|
| 3859 | + } |
|
| 3707 | 3860 | // Just to be sure... |
| 3708 | - foreach ($groups as $k => $v) |
|
| 3709 | - $groups[$k] = (int) $v; |
|
| 3861 | + foreach ($groups as $k => $v) { |
|
| 3862 | + $groups[$k] = (int) $v; |
|
| 3863 | + } |
|
| 3710 | 3864 | |
| 3711 | 3865 | // Get all the membergroups they can join. |
| 3712 | 3866 | $request = $smcFunc['db_query']('', ' |
@@ -3736,12 +3890,14 @@ discard block |
||
| 3736 | 3890 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3737 | 3891 | { |
| 3738 | 3892 | // Can they edit their primary group? |
| 3739 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
| 3740 | - $context['can_edit_primary'] = true; |
|
| 3893 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
| 3894 | + $context['can_edit_primary'] = true; |
|
| 3895 | + } |
|
| 3741 | 3896 | |
| 3742 | 3897 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
| 3743 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
| 3744 | - continue; |
|
| 3898 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
| 3899 | + continue; |
|
| 3900 | + } |
|
| 3745 | 3901 | |
| 3746 | 3902 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
| 3747 | 3903 | 'id' => $row['id_group'], |
@@ -3770,13 +3926,15 @@ discard block |
||
| 3770 | 3926 | ); |
| 3771 | 3927 | |
| 3772 | 3928 | // No changing primary one unless you have enough groups! |
| 3773 | - if (count($context['groups']['member']) < 2) |
|
| 3774 | - $context['can_edit_primary'] = false; |
|
| 3929 | + if (count($context['groups']['member']) < 2) { |
|
| 3930 | + $context['can_edit_primary'] = false; |
|
| 3931 | + } |
|
| 3775 | 3932 | |
| 3776 | 3933 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
| 3777 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
| 3778 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3779 | -} |
|
| 3934 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
| 3935 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3936 | + } |
|
| 3937 | + } |
|
| 3780 | 3938 | |
| 3781 | 3939 | /** |
| 3782 | 3940 | * This function actually makes all the group changes |
@@ -3791,10 +3949,12 @@ discard block |
||
| 3791 | 3949 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
| 3792 | 3950 | |
| 3793 | 3951 | // Let's be extra cautious... |
| 3794 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
| 3795 | - isAllowedTo('manage_membergroups'); |
|
| 3796 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
| 3797 | - fatal_lang_error('no_access', false); |
|
| 3952 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
| 3953 | + isAllowedTo('manage_membergroups'); |
|
| 3954 | + } |
|
| 3955 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
| 3956 | + fatal_lang_error('no_access', false); |
|
| 3957 | + } |
|
| 3798 | 3958 | |
| 3799 | 3959 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
| 3800 | 3960 | |
@@ -3813,8 +3973,9 @@ discard block |
||
| 3813 | 3973 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
| 3814 | 3974 | |
| 3815 | 3975 | // Sanity check!! |
| 3816 | - if ($group_id == 1) |
|
| 3817 | - isAllowedTo('admin_forum'); |
|
| 3976 | + if ($group_id == 1) { |
|
| 3977 | + isAllowedTo('admin_forum'); |
|
| 3978 | + } |
|
| 3818 | 3979 | // Protected groups too! |
| 3819 | 3980 | else |
| 3820 | 3981 | { |
@@ -3831,8 +3992,9 @@ discard block |
||
| 3831 | 3992 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
| 3832 | 3993 | $smcFunc['db_free_result']($request); |
| 3833 | 3994 | |
| 3834 | - if ($is_protected == 1) |
|
| 3835 | - isAllowedTo('admin_forum'); |
|
| 3995 | + if ($is_protected == 1) { |
|
| 3996 | + isAllowedTo('admin_forum'); |
|
| 3997 | + } |
|
| 3836 | 3998 | } |
| 3837 | 3999 | |
| 3838 | 4000 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3854,36 +4016,43 @@ discard block |
||
| 3854 | 4016 | $group_name = $row['group_name']; |
| 3855 | 4017 | |
| 3856 | 4018 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
| 3857 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
| 3858 | - fatal_lang_error('no_access', false); |
|
| 4019 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
| 4020 | + fatal_lang_error('no_access', false); |
|
| 4021 | + } |
|
| 3859 | 4022 | // What about leaving a requestable group we are not a member of? |
| 3860 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
| 3861 | - fatal_lang_error('no_access', false); |
|
| 3862 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
| 3863 | - fatal_lang_error('no_access', false); |
|
| 4023 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
| 4024 | + fatal_lang_error('no_access', false); |
|
| 4025 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
| 4026 | + fatal_lang_error('no_access', false); |
|
| 4027 | + } |
|
| 3864 | 4028 | |
| 3865 | 4029 | // We can't change the primary group if this is hidden! |
| 3866 | - if ($row['hidden'] == 2) |
|
| 3867 | - $canChangePrimary = false; |
|
| 4030 | + if ($row['hidden'] == 2) { |
|
| 4031 | + $canChangePrimary = false; |
|
| 4032 | + } |
|
| 3868 | 4033 | } |
| 3869 | 4034 | |
| 3870 | 4035 | // If this is their old primary, can we change it? |
| 3871 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
| 3872 | - $canChangePrimary = 1; |
|
| 4036 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
| 4037 | + $canChangePrimary = 1; |
|
| 4038 | + } |
|
| 3873 | 4039 | |
| 3874 | 4040 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
| 3875 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
| 3876 | - $canChangePrimary = false; |
|
| 4041 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
| 4042 | + $canChangePrimary = false; |
|
| 4043 | + } |
|
| 3877 | 4044 | |
| 3878 | 4045 | // If this is the one we are acting on, can we even act? |
| 3879 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
| 3880 | - $canChangePrimary = false; |
|
| 4046 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
| 4047 | + $canChangePrimary = false; |
|
| 4048 | + } |
|
| 3881 | 4049 | } |
| 3882 | 4050 | $smcFunc['db_free_result']($request); |
| 3883 | 4051 | |
| 3884 | 4052 | // Didn't find the target? |
| 3885 | - if (!$foundTarget) |
|
| 3886 | - fatal_lang_error('no_access', false); |
|
| 4053 | + if (!$foundTarget) { |
|
| 4054 | + fatal_lang_error('no_access', false); |
|
| 4055 | + } |
|
| 3887 | 4056 | |
| 3888 | 4057 | // Final security check, don't allow users to promote themselves to admin. |
| 3889 | 4058 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3903,8 +4072,9 @@ discard block |
||
| 3903 | 4072 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
| 3904 | 4073 | $smcFunc['db_free_result']($request); |
| 3905 | 4074 | |
| 3906 | - if ($disallow) |
|
| 3907 | - isAllowedTo('admin_forum'); |
|
| 4075 | + if ($disallow) { |
|
| 4076 | + isAllowedTo('admin_forum'); |
|
| 4077 | + } |
|
| 3908 | 4078 | } |
| 3909 | 4079 | |
| 3910 | 4080 | // If we're requesting, add the note then return. |
@@ -3922,8 +4092,9 @@ discard block |
||
| 3922 | 4092 | 'status_open' => 0, |
| 3923 | 4093 | ) |
| 3924 | 4094 | ); |
| 3925 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 3926 | - fatal_lang_error('profile_error_already_requested_group'); |
|
| 4095 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 4096 | + fatal_lang_error('profile_error_already_requested_group'); |
|
| 4097 | + } |
|
| 3927 | 4098 | $smcFunc['db_free_result']($request); |
| 3928 | 4099 | |
| 3929 | 4100 | // Log the request. |
@@ -3957,10 +4128,11 @@ discard block |
||
| 3957 | 4128 | // Are we leaving? |
| 3958 | 4129 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
| 3959 | 4130 | { |
| 3960 | - if ($old_profile['id_group'] == $group_id) |
|
| 3961 | - $newPrimary = 0; |
|
| 3962 | - else |
|
| 3963 | - unset($addGroups[$group_id]); |
|
| 4131 | + if ($old_profile['id_group'] == $group_id) { |
|
| 4132 | + $newPrimary = 0; |
|
| 4133 | + } else { |
|
| 4134 | + unset($addGroups[$group_id]); |
|
| 4135 | + } |
|
| 3964 | 4136 | } |
| 3965 | 4137 | // ... if not, must be joining. |
| 3966 | 4138 | else |
@@ -3968,36 +4140,42 @@ discard block |
||
| 3968 | 4140 | // Can we change the primary, and do we want to? |
| 3969 | 4141 | if ($canChangePrimary) |
| 3970 | 4142 | { |
| 3971 | - if ($old_profile['id_group'] != 0) |
|
| 3972 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4143 | + if ($old_profile['id_group'] != 0) { |
|
| 4144 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4145 | + } |
|
| 3973 | 4146 | $newPrimary = $group_id; |
| 3974 | 4147 | } |
| 3975 | 4148 | // Otherwise it's an additional group... |
| 3976 | - else |
|
| 3977 | - $addGroups[$group_id] = -1; |
|
| 4149 | + else { |
|
| 4150 | + $addGroups[$group_id] = -1; |
|
| 4151 | + } |
|
| 3978 | 4152 | } |
| 3979 | 4153 | } |
| 3980 | 4154 | // Finally, we must be setting the primary. |
| 3981 | 4155 | elseif ($canChangePrimary) |
| 3982 | 4156 | { |
| 3983 | - if ($old_profile['id_group'] != 0) |
|
| 3984 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 3985 | - if (isset($addGroups[$group_id])) |
|
| 3986 | - unset($addGroups[$group_id]); |
|
| 4157 | + if ($old_profile['id_group'] != 0) { |
|
| 4158 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4159 | + } |
|
| 4160 | + if (isset($addGroups[$group_id])) { |
|
| 4161 | + unset($addGroups[$group_id]); |
|
| 4162 | + } |
|
| 3987 | 4163 | $newPrimary = $group_id; |
| 3988 | 4164 | } |
| 3989 | 4165 | |
| 3990 | 4166 | // Finally, we can make the changes! |
| 3991 | - foreach ($addGroups as $id => $dummy) |
|
| 3992 | - if (empty($id)) |
|
| 4167 | + foreach ($addGroups as $id => $dummy) { |
|
| 4168 | + if (empty($id)) |
|
| 3993 | 4169 | unset($addGroups[$id]); |
| 4170 | + } |
|
| 3994 | 4171 | $addGroups = implode(',', array_flip($addGroups)); |
| 3995 | 4172 | |
| 3996 | 4173 | // Ensure that we don't cache permissions if the group is changing. |
| 3997 | - if ($context['user']['is_owner']) |
|
| 3998 | - $_SESSION['mc']['time'] = 0; |
|
| 3999 | - else |
|
| 4000 | - updateSettings(array('settings_updated' => time())); |
|
| 4174 | + if ($context['user']['is_owner']) { |
|
| 4175 | + $_SESSION['mc']['time'] = 0; |
|
| 4176 | + } else { |
|
| 4177 | + updateSettings(array('settings_updated' => time())); |
|
| 4178 | + } |
|
| 4001 | 4179 | |
| 4002 | 4180 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
| 4003 | 4181 | |
@@ -4020,8 +4198,9 @@ discard block |
||
| 4020 | 4198 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
| 4021 | 4199 | { |
| 4022 | 4200 | // Check to ensure we're forcing SSL for authentication |
| 4023 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 4024 | - fatal_lang_error('login_ssl_required'); |
|
| 4201 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 4202 | + fatal_lang_error('login_ssl_required'); |
|
| 4203 | + } |
|
| 4025 | 4204 | |
| 4026 | 4205 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
| 4027 | 4206 | // we do not want too much AJAX to confuse them. |
@@ -4058,8 +4237,7 @@ discard block |
||
| 4058 | 4237 | $context['sub_template'] = 'tfasetup_backup'; |
| 4059 | 4238 | |
| 4060 | 4239 | return; |
| 4061 | - } |
|
| 4062 | - else |
|
| 4240 | + } else |
|
| 4063 | 4241 | { |
| 4064 | 4242 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
| 4065 | 4243 | $context['tfa_error'] = !$valid_code; |
@@ -4067,8 +4245,7 @@ discard block |
||
| 4067 | 4245 | $context['tfa_pass_value'] = $_POST['passwd']; |
| 4068 | 4246 | $context['tfa_value'] = $_POST['tfa_code']; |
| 4069 | 4247 | } |
| 4070 | - } |
|
| 4071 | - else |
|
| 4248 | + } else |
|
| 4072 | 4249 | { |
| 4073 | 4250 | $totp = new \TOTP\Auth(); |
| 4074 | 4251 | $secret = $totp->generateCode(); |
@@ -4078,17 +4255,16 @@ discard block |
||
| 4078 | 4255 | } |
| 4079 | 4256 | |
| 4080 | 4257 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
| 4081 | - } |
|
| 4082 | - elseif (isset($_REQUEST['disable'])) |
|
| 4258 | + } elseif (isset($_REQUEST['disable'])) |
|
| 4083 | 4259 | { |
| 4084 | 4260 | updateMemberData($memID, array( |
| 4085 | 4261 | 'tfa_secret' => '', |
| 4086 | 4262 | 'tfa_backup' => '', |
| 4087 | 4263 | )); |
| 4088 | 4264 | redirectexit('action=profile;area=account;u=' . $memID); |
| 4265 | + } else { |
|
| 4266 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4267 | + } |
|
| 4089 | 4268 | } |
| 4090 | - else |
|
| 4091 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4092 | -} |
|
| 4093 | 4269 | |
| 4094 | 4270 | ?> |
| 4095 | 4271 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Sets the SMF-style login cookie and session based on the id_member and password passed. |
@@ -43,8 +44,9 @@ discard block |
||
| 43 | 44 | $array = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
| 44 | 45 | |
| 45 | 46 | // Legacy format |
| 46 | - if (is_null($array)) |
|
| 47 | - $array = safe_unserialize($_COOKIE[$cookiename]); |
|
| 47 | + if (is_null($array)) { |
|
| 48 | + $array = safe_unserialize($_COOKIE[$cookiename]); |
|
| 49 | + } |
|
| 48 | 50 | |
| 49 | 51 | // Out with the old, in with the new! |
| 50 | 52 | if (isset($array[3]) && $array[3] != $cookie_state) |
@@ -62,8 +64,9 @@ discard block |
||
| 62 | 64 | smf_setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], $cookie_url[0]); |
| 63 | 65 | |
| 64 | 66 | // If subdomain-independent cookies are on, unset the subdomain-dependent cookie too. |
| 65 | - if (empty($id) && !empty($modSettings['globalCookies'])) |
|
| 66 | - smf_setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], ''); |
|
| 67 | + if (empty($id) && !empty($modSettings['globalCookies'])) { |
|
| 68 | + smf_setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], ''); |
|
| 69 | + } |
|
| 67 | 70 | |
| 68 | 71 | // Any alias URLs? This is mainly for use with frames, etc. |
| 69 | 72 | if (!empty($modSettings['forum_alias_urls'])) |
@@ -79,8 +82,9 @@ discard block |
||
| 79 | 82 | |
| 80 | 83 | $cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])); |
| 81 | 84 | |
| 82 | - if ($cookie_url[0] == '') |
|
| 83 | - $cookie_url[0] = strtok($alias, '/'); |
|
| 85 | + if ($cookie_url[0] == '') { |
|
| 86 | + $cookie_url[0] = strtok($alias, '/'); |
|
| 87 | + } |
|
| 84 | 88 | |
| 85 | 89 | smf_setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], $cookie_url[0]); |
| 86 | 90 | } |
@@ -126,8 +130,9 @@ discard block |
||
| 126 | 130 | $identifier = $cookiename . '_tfa'; |
| 127 | 131 | $cookie_state = (empty($modSettings['localCookies']) ? 0 : 1) | (empty($modSettings['globalCookies']) ? 0 : 2); |
| 128 | 132 | |
| 129 | - if ($preserve) |
|
| 130 | - $cookie_length = 81600 * 30; |
|
| 133 | + if ($preserve) { |
|
| 134 | + $cookie_length = 81600 * 30; |
|
| 135 | + } |
|
| 131 | 136 | |
| 132 | 137 | // Get the data and path to set it on. |
| 133 | 138 | $data = $smcFunc['json_encode'](empty($id) ? array(0, '', 0, $cookie_state, false) : array($id, $secret, time() + $cookie_length, $cookie_state, $preserve)); |
@@ -137,8 +142,9 @@ discard block |
||
| 137 | 142 | smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], $cookie_url[0]); |
| 138 | 143 | |
| 139 | 144 | // If subdomain-independent cookies are on, unset the subdomain-dependent cookie too. |
| 140 | - if (empty($id) && !empty($modSettings['globalCookies'])) |
|
| 141 | - smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], ''); |
|
| 145 | + if (empty($id) && !empty($modSettings['globalCookies'])) { |
|
| 146 | + smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], ''); |
|
| 147 | + } |
|
| 142 | 148 | |
| 143 | 149 | $_COOKIE[$identifier] = $data; |
| 144 | 150 | } |
@@ -160,23 +166,28 @@ discard block |
||
| 160 | 166 | $parsed_url = parse_url($boardurl); |
| 161 | 167 | |
| 162 | 168 | // Is local cookies off? |
| 163 | - if (empty($parsed_url['path']) || !$local) |
|
| 164 | - $parsed_url['path'] = ''; |
|
| 169 | + if (empty($parsed_url['path']) || !$local) { |
|
| 170 | + $parsed_url['path'] = ''; |
|
| 171 | + } |
|
| 165 | 172 | |
| 166 | - if (!empty($modSettings['globalCookiesDomain']) && strpos($boardurl, $modSettings['globalCookiesDomain']) !== false) |
|
| 167 | - $parsed_url['host'] = $modSettings['globalCookiesDomain']; |
|
| 173 | + if (!empty($modSettings['globalCookiesDomain']) && strpos($boardurl, $modSettings['globalCookiesDomain']) !== false) { |
|
| 174 | + $parsed_url['host'] = $modSettings['globalCookiesDomain']; |
|
| 175 | + } |
|
| 168 | 176 | |
| 169 | 177 | // Globalize cookies across domains (filter out IP-addresses)? |
| 170 | - elseif ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
| 171 | - $parsed_url['host'] = '.' . $parts[1]; |
|
| 178 | + elseif ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
| 179 | + $parsed_url['host'] = '.' . $parts[1]; |
|
| 180 | + } |
|
| 172 | 181 | |
| 173 | 182 | // We shouldn't use a host at all if both options are off. |
| 174 | - elseif (!$local && !$global) |
|
| 175 | - $parsed_url['host'] = ''; |
|
| 183 | + elseif (!$local && !$global) { |
|
| 184 | + $parsed_url['host'] = ''; |
|
| 185 | + } |
|
| 176 | 186 | |
| 177 | 187 | // The host also shouldn't be set if there aren't any dots in it. |
| 178 | - elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false) |
|
| 179 | - $parsed_url['host'] = ''; |
|
| 188 | + elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false) { |
|
| 189 | + $parsed_url['host'] = ''; |
|
| 190 | + } |
|
| 180 | 191 | |
| 181 | 192 | return array($parsed_url['host'], $parsed_url['path'] . '/'); |
| 182 | 193 | } |
@@ -195,8 +206,9 @@ discard block |
||
| 195 | 206 | createToken('login'); |
| 196 | 207 | |
| 197 | 208 | // Never redirect to an attachment |
| 198 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
| 199 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
| 209 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
| 210 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
| 211 | + } |
|
| 200 | 212 | |
| 201 | 213 | $context['sub_template'] = 'kick_guest'; |
| 202 | 214 | $context['page_title'] = $txt['login']; |
@@ -251,10 +263,12 @@ discard block |
||
| 251 | 263 | $txt['security_wrong'] = sprintf($txt['security_wrong'], isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $txt['unknown'], $_SERVER['HTTP_USER_AGENT'], $user_info['ip']); |
| 252 | 264 | log_error($txt['security_wrong'], 'critical'); |
| 253 | 265 | |
| 254 | - if (isset($_POST[$type . '_hash_pass'])) |
|
| 255 | - unset($_POST[$type . '_hash_pass']); |
|
| 256 | - if (isset($_POST[$type . '_pass'])) |
|
| 257 | - unset($_POST[$type . '_pass']); |
|
| 266 | + if (isset($_POST[$type . '_hash_pass'])) { |
|
| 267 | + unset($_POST[$type . '_hash_pass']); |
|
| 268 | + } |
|
| 269 | + if (isset($_POST[$type . '_pass'])) { |
|
| 270 | + unset($_POST[$type . '_pass']); |
|
| 271 | + } |
|
| 258 | 272 | |
| 259 | 273 | $context['incorrect_password'] = true; |
| 260 | 274 | } |
@@ -267,15 +281,17 @@ discard block |
||
| 267 | 281 | |
| 268 | 282 | // Now go through $_POST. Make sure the session hash is sent. |
| 269 | 283 | $_POST[$context['session_var']] = $context['session_id']; |
| 270 | - foreach ($_POST as $k => $v) |
|
| 271 | - $context['post_data'] .= adminLogin_outputPostVars($k, $v); |
|
| 284 | + foreach ($_POST as $k => $v) { |
|
| 285 | + $context['post_data'] .= adminLogin_outputPostVars($k, $v); |
|
| 286 | + } |
|
| 272 | 287 | |
| 273 | 288 | // Now we'll use the admin_login sub template of the Login template. |
| 274 | 289 | $context['sub_template'] = 'admin_login'; |
| 275 | 290 | |
| 276 | 291 | // And title the page something like "Login". |
| 277 | - if (!isset($context['page_title'])) |
|
| 278 | - $context['page_title'] = $txt['login']; |
|
| 292 | + if (!isset($context['page_title'])) { |
|
| 293 | + $context['page_title'] = $txt['login']; |
|
| 294 | + } |
|
| 279 | 295 | |
| 280 | 296 | // The type of action. |
| 281 | 297 | $context['sessionCheckType'] = $type; |
@@ -298,14 +314,15 @@ discard block |
||
| 298 | 314 | { |
| 299 | 315 | global $smcFunc; |
| 300 | 316 | |
| 301 | - if (!is_array($v)) |
|
| 302 | - return ' |
|
| 317 | + if (!is_array($v)) { |
|
| 318 | + return ' |
|
| 303 | 319 | <input type="hidden" name="' . $smcFunc['htmlspecialchars']($k) . '" value="' . strtr($v, array('"' => '"', '<' => '<', '>' => '>')) . '">'; |
| 304 | - else |
|
| 320 | + } else |
|
| 305 | 321 | { |
| 306 | 322 | $ret = ''; |
| 307 | - foreach ($v as $k2 => $v2) |
|
| 308 | - $ret .= adminLogin_outputPostVars($k . '[' . $k2 . ']', $v2); |
|
| 323 | + foreach ($v as $k2 => $v2) { |
|
| 324 | + $ret .= adminLogin_outputPostVars($k . '[' . $k2 . ']', $v2); |
|
| 325 | + } |
|
| 309 | 326 | |
| 310 | 327 | return $ret; |
| 311 | 328 | } |
@@ -332,18 +349,20 @@ discard block |
||
| 332 | 349 | foreach ($get as $k => $v) |
| 333 | 350 | { |
| 334 | 351 | // Only if it's not already in the $scripturl! |
| 335 | - if (!isset($temp[$k])) |
|
| 336 | - $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
| 352 | + if (!isset($temp[$k])) { |
|
| 353 | + $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
| 354 | + } |
|
| 337 | 355 | // If it changed, put it out there, but with an ampersand. |
| 338 | - elseif ($temp[$k] != $get[$k]) |
|
| 339 | - $query_string .= urlencode($k) . '=' . urlencode($v) . '&'; |
|
| 356 | + elseif ($temp[$k] != $get[$k]) { |
|
| 357 | + $query_string .= urlencode($k) . '=' . urlencode($v) . '&'; |
|
| 358 | + } |
|
| 340 | 359 | } |
| 341 | - } |
|
| 342 | - else |
|
| 360 | + } else |
|
| 343 | 361 | { |
| 344 | 362 | // Add up all the data from $_GET into get_data. |
| 345 | - foreach ($get as $k => $v) |
|
| 346 | - $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
| 363 | + foreach ($get as $k => $v) { |
|
| 364 | + $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
| 365 | + } |
|
| 347 | 366 | } |
| 348 | 367 | |
| 349 | 368 | $query_string = substr($query_string, 0, -1); |
@@ -366,8 +385,9 @@ discard block |
||
| 366 | 385 | global $scripturl, $user_info, $smcFunc; |
| 367 | 386 | |
| 368 | 387 | // If it's not already an array, make it one. |
| 369 | - if (!is_array($names)) |
|
| 370 | - $names = explode(',', $names); |
|
| 388 | + if (!is_array($names)) { |
|
| 389 | + $names = explode(',', $names); |
|
| 390 | + } |
|
| 371 | 391 | |
| 372 | 392 | $maybe_email = false; |
| 373 | 393 | foreach ($names as $i => $name) |
@@ -378,10 +398,11 @@ discard block |
||
| 378 | 398 | $maybe_email |= strpos($name, '@') !== false; |
| 379 | 399 | |
| 380 | 400 | // Make it so standard wildcards will work. (* and ?) |
| 381 | - if ($use_wildcards) |
|
| 382 | - $names[$i] = strtr($names[$i], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '\'' => ''')); |
|
| 383 | - else |
|
| 384 | - $names[$i] = strtr($names[$i], array('\'' => ''')); |
|
| 401 | + if ($use_wildcards) { |
|
| 402 | + $names[$i] = strtr($names[$i], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '\'' => ''')); |
|
| 403 | + } else { |
|
| 404 | + $names[$i] = strtr($names[$i], array('\'' => ''')); |
|
| 405 | + } |
|
| 385 | 406 | } |
| 386 | 407 | |
| 387 | 408 | // What are we using to compare? |
@@ -391,11 +412,12 @@ discard block |
||
| 391 | 412 | $results = array(); |
| 392 | 413 | |
| 393 | 414 | // This ensures you can't search someones email address if you can't see it. |
| 394 | - if (($use_wildcards || $maybe_email) && allowedTo('moderate_forum')) |
|
| 395 | - $email_condition = ' |
|
| 415 | + if (($use_wildcards || $maybe_email) && allowedTo('moderate_forum')) { |
|
| 416 | + $email_condition = ' |
|
| 396 | 417 | OR (email_address ' . $comparison . ' \'' . implode('\') OR (email_address ' . $comparison . ' \'', $names) . '\')'; |
| 397 | - else |
|
| 398 | - $email_condition = ''; |
|
| 418 | + } else { |
|
| 419 | + $email_condition = ''; |
|
| 420 | + } |
|
| 399 | 421 | |
| 400 | 422 | // Get the case of the columns right - but only if we need to as things like MySQL will go slow needlessly otherwise. |
| 401 | 423 | $member_name = $smcFunc['db_case_sensitive'] ? 'LOWER(member_name)' : 'member_name'; |
@@ -453,10 +475,11 @@ discard block |
||
| 453 | 475 | $context['template_layers'] = array(); |
| 454 | 476 | $context['sub_template'] = 'find_members'; |
| 455 | 477 | |
| 456 | - if (isset($_REQUEST['search'])) |
|
| 457 | - $context['last_search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES); |
|
| 458 | - else |
|
| 459 | - $_REQUEST['start'] = 0; |
|
| 478 | + if (isset($_REQUEST['search'])) { |
|
| 479 | + $context['last_search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES); |
|
| 480 | + } else { |
|
| 481 | + $_REQUEST['start'] = 0; |
|
| 482 | + } |
|
| 460 | 483 | |
| 461 | 484 | // Allow the user to pass the input to be added to to the box. |
| 462 | 485 | $context['input_box_name'] = isset($_REQUEST['input']) && preg_match('~^[\w-]+$~', $_REQUEST['input']) === 1 ? $_REQUEST['input'] : 'to'; |
@@ -497,10 +520,10 @@ discard block |
||
| 497 | 520 | ); |
| 498 | 521 | |
| 499 | 522 | $context['results'] = array_slice($context['results'], $_REQUEST['start'], 7); |
| 523 | + } else { |
|
| 524 | + $context['links']['up'] = $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']); |
|
| 525 | + } |
|
| 500 | 526 | } |
| 501 | - else |
|
| 502 | - $context['links']['up'] = $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']); |
|
| 503 | -} |
|
| 504 | 527 | |
| 505 | 528 | /** |
| 506 | 529 | * Outputs each member name on its own line. |
@@ -516,8 +539,9 @@ discard block |
||
| 516 | 539 | $_REQUEST['search'] = trim($smcFunc['strtolower']($_REQUEST['search'])); |
| 517 | 540 | $_REQUEST['search'] = strtr($_REQUEST['search'], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '&' => '&')); |
| 518 | 541 | |
| 519 | - if (function_exists('iconv')) |
|
| 520 | - header('Content-Type: text/plain; charset=UTF-8'); |
|
| 542 | + if (function_exists('iconv')) { |
|
| 543 | + header('Content-Type: text/plain; charset=UTF-8'); |
|
| 544 | + } |
|
| 521 | 545 | |
| 522 | 546 | $request = $smcFunc['db_query']('', ' |
| 523 | 547 | SELECT real_name |
@@ -537,14 +561,16 @@ discard block |
||
| 537 | 561 | if (function_exists('iconv')) |
| 538 | 562 | { |
| 539 | 563 | $utf8 = iconv($txt['lang_character_set'], 'UTF-8', $row['real_name']); |
| 540 | - if ($utf8) |
|
| 541 | - $row['real_name'] = $utf8; |
|
| 564 | + if ($utf8) { |
|
| 565 | + $row['real_name'] = $utf8; |
|
| 566 | + } |
|
| 542 | 567 | } |
| 543 | 568 | |
| 544 | 569 | $row['real_name'] = strtr($row['real_name'], array('&' => '&', '<' => '<', '>' => '>', '"' => '"')); |
| 545 | 570 | |
| 546 | - if (preg_match('~&#\d+;~', $row['real_name']) != 0) |
|
| 547 | - $row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']); |
|
| 571 | + if (preg_match('~&#\d+;~', $row['real_name']) != 0) { |
|
| 572 | + $row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']); |
|
| 573 | + } |
|
| 548 | 574 | |
| 549 | 575 | echo $row['real_name'], "\n"; |
| 550 | 576 | } |
@@ -601,9 +627,9 @@ discard block |
||
| 601 | 627 | |
| 602 | 628 | // Update the database... |
| 603 | 629 | updateMemberData($memID, array('member_name' => $user, 'passwd' => $newPassword_sha1)); |
| 630 | + } else { |
|
| 631 | + updateMemberData($memID, array('passwd' => $newPassword_sha1)); |
|
| 604 | 632 | } |
| 605 | - else |
|
| 606 | - updateMemberData($memID, array('passwd' => $newPassword_sha1)); |
|
| 607 | 633 | |
| 608 | 634 | call_integration_hook('integrate_reset_pass', array($old_user, $user, $newPassword)); |
| 609 | 635 | |
@@ -634,31 +660,37 @@ discard block |
||
| 634 | 660 | $errors = array(); |
| 635 | 661 | |
| 636 | 662 | // Don't use too long a name. |
| 637 | - if ($smcFunc['strlen']($username) > 25) |
|
| 638 | - $errors[] = array('lang', 'error_long_name'); |
|
| 663 | + if ($smcFunc['strlen']($username) > 25) { |
|
| 664 | + $errors[] = array('lang', 'error_long_name'); |
|
| 665 | + } |
|
| 639 | 666 | |
| 640 | 667 | // No name?! How can you register with no name? |
| 641 | - if ($username == '') |
|
| 642 | - $errors[] = array('lang', 'need_username'); |
|
| 668 | + if ($username == '') { |
|
| 669 | + $errors[] = array('lang', 'need_username'); |
|
| 670 | + } |
|
| 643 | 671 | |
| 644 | 672 | // Only these characters are permitted. |
| 645 | - if (in_array($username, array('_', '|')) || preg_match('~[<>&"\'=\\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $username)) != 0 || strpos($username, '[code') !== false || strpos($username, '[/code') !== false) |
|
| 646 | - $errors[] = array('lang', 'error_invalid_characters_username'); |
|
| 673 | + if (in_array($username, array('_', '|')) || preg_match('~[<>&"\'=\\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $username)) != 0 || strpos($username, '[code') !== false || strpos($username, '[/code') !== false) { |
|
| 674 | + $errors[] = array('lang', 'error_invalid_characters_username'); |
|
| 675 | + } |
|
| 647 | 676 | |
| 648 | - if (stristr($username, $txt['guest_title']) !== false) |
|
| 649 | - $errors[] = array('lang', 'username_reserved', 'general', array($txt['guest_title'])); |
|
| 677 | + if (stristr($username, $txt['guest_title']) !== false) { |
|
| 678 | + $errors[] = array('lang', 'username_reserved', 'general', array($txt['guest_title'])); |
|
| 679 | + } |
|
| 650 | 680 | |
| 651 | 681 | if ($check_reserved_name) |
| 652 | 682 | { |
| 653 | 683 | require_once($sourcedir . '/Subs-Members.php'); |
| 654 | - if (isReservedName($username, $memID, false)) |
|
| 655 | - $errors[] = array('done', '(' . $smcFunc['htmlspecialchars']($username) . ') ' . $txt['name_in_use']); |
|
| 684 | + if (isReservedName($username, $memID, false)) { |
|
| 685 | + $errors[] = array('done', '(' . $smcFunc['htmlspecialchars']($username) . ') ' . $txt['name_in_use']); |
|
| 686 | + } |
|
| 656 | 687 | } |
| 657 | 688 | |
| 658 | - if ($return_error) |
|
| 659 | - return $errors; |
|
| 660 | - elseif (empty($errors)) |
|
| 661 | - return null; |
|
| 689 | + if ($return_error) { |
|
| 690 | + return $errors; |
|
| 691 | + } elseif (empty($errors)) { |
|
| 692 | + return null; |
|
| 693 | + } |
|
| 662 | 694 | |
| 663 | 695 | loadLanguage('Errors'); |
| 664 | 696 | $error = $errors[0]; |
@@ -684,22 +716,26 @@ discard block |
||
| 684 | 716 | global $modSettings, $smcFunc; |
| 685 | 717 | |
| 686 | 718 | // Perform basic requirements first. |
| 687 | - if ($smcFunc['strlen']($password) < (empty($modSettings['password_strength']) ? 4 : 8)) |
|
| 688 | - return 'short'; |
|
| 719 | + if ($smcFunc['strlen']($password) < (empty($modSettings['password_strength']) ? 4 : 8)) { |
|
| 720 | + return 'short'; |
|
| 721 | + } |
|
| 689 | 722 | |
| 690 | 723 | // Is this enough? |
| 691 | - if (empty($modSettings['password_strength'])) |
|
| 692 | - return null; |
|
| 724 | + if (empty($modSettings['password_strength'])) { |
|
| 725 | + return null; |
|
| 726 | + } |
|
| 693 | 727 | |
| 694 | 728 | // Otherwise, perform the medium strength test - checking if password appears in the restricted string. |
| 695 | - if (preg_match('~\b' . preg_quote($password, '~') . '\b~', implode(' ', $restrict_in)) != 0) |
|
| 696 | - return 'restricted_words'; |
|
| 697 | - elseif ($smcFunc['strpos']($password, $username) !== false) |
|
| 698 | - return 'restricted_words'; |
|
| 729 | + if (preg_match('~\b' . preg_quote($password, '~') . '\b~', implode(' ', $restrict_in)) != 0) { |
|
| 730 | + return 'restricted_words'; |
|
| 731 | + } elseif ($smcFunc['strpos']($password, $username) !== false) { |
|
| 732 | + return 'restricted_words'; |
|
| 733 | + } |
|
| 699 | 734 | |
| 700 | 735 | // If just medium, we're done. |
| 701 | - if ($modSettings['password_strength'] == 1) |
|
| 702 | - return null; |
|
| 736 | + if ($modSettings['password_strength'] == 1) { |
|
| 737 | + return null; |
|
| 738 | + } |
|
| 703 | 739 | |
| 704 | 740 | // Otherwise, hard test next, check for numbers and letters, uppercase too. |
| 705 | 741 | $good = preg_match('~(\D\d|\d\D)~', $password) != 0; |
@@ -731,14 +767,16 @@ discard block |
||
| 731 | 767 | ) |
| 732 | 768 | ); |
| 733 | 769 | $groups = array(); |
| 734 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 735 | - $groups[] = $row['id_group']; |
|
| 770 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 771 | + $groups[] = $row['id_group']; |
|
| 772 | + } |
|
| 736 | 773 | $smcFunc['db_free_result']($request); |
| 737 | 774 | |
| 738 | - if (empty($groups)) |
|
| 739 | - $group_query = '0=1'; |
|
| 740 | - else |
|
| 741 | - $group_query = 'id_group IN (' . implode(',', $groups) . ')'; |
|
| 775 | + if (empty($groups)) { |
|
| 776 | + $group_query = '0=1'; |
|
| 777 | + } else { |
|
| 778 | + $group_query = 'id_group IN (' . implode(',', $groups) . ')'; |
|
| 779 | + } |
|
| 742 | 780 | } |
| 743 | 781 | |
| 744 | 782 | // Then, same again, just the boards this time! |
@@ -748,10 +786,11 @@ discard block |
||
| 748 | 786 | { |
| 749 | 787 | $boards = boardsAllowedTo('moderate_board', true); |
| 750 | 788 | |
| 751 | - if (empty($boards)) |
|
| 752 | - $board_query = '0=1'; |
|
| 753 | - else |
|
| 754 | - $board_query = 'id_board IN (' . implode(',', $boards) . ')'; |
|
| 789 | + if (empty($boards)) { |
|
| 790 | + $board_query = '0=1'; |
|
| 791 | + } else { |
|
| 792 | + $board_query = 'id_board IN (' . implode(',', $boards) . ')'; |
|
| 793 | + } |
|
| 755 | 794 | } |
| 756 | 795 | |
| 757 | 796 | // What boards are they the moderator of? |
@@ -766,8 +805,9 @@ discard block |
||
| 766 | 805 | 'current_member' => $user_info['id'], |
| 767 | 806 | ) |
| 768 | 807 | ); |
| 769 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 770 | - $boards_mod[] = $row['id_board']; |
|
| 808 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 809 | + $boards_mod[] = $row['id_board']; |
|
| 810 | + } |
|
| 771 | 811 | $smcFunc['db_free_result']($request); |
| 772 | 812 | |
| 773 | 813 | // Can any of the groups they're in moderate any of the boards? |
@@ -779,8 +819,9 @@ discard block |
||
| 779 | 819 | 'groups' => $user_info['groups'], |
| 780 | 820 | ) |
| 781 | 821 | ); |
| 782 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 783 | - $boards_mod[] = $row['id_board']; |
|
| 822 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 823 | + $boards_mod[] = $row['id_board']; |
|
| 824 | + } |
|
| 784 | 825 | $smcFunc['db_free_result']($request); |
| 785 | 826 | |
| 786 | 827 | // Just in case we've got duplicates here... |
@@ -825,10 +866,12 @@ discard block |
||
| 825 | 866 | global $modSettings; |
| 826 | 867 | |
| 827 | 868 | // In case a customization wants to override the default settings |
| 828 | - if ($httponly === null) |
|
| 829 | - $httponly = !empty($modSettings['httponlyCookies']); |
|
| 830 | - if ($secure === null) |
|
| 831 | - $secure = !empty($modSettings['secureCookies']); |
|
| 869 | + if ($httponly === null) { |
|
| 870 | + $httponly = !empty($modSettings['httponlyCookies']); |
|
| 871 | + } |
|
| 872 | + if ($secure === null) { |
|
| 873 | + $secure = !empty($modSettings['secureCookies']); |
|
| 874 | + } |
|
| 832 | 875 | |
| 833 | 876 | // Intercept cookie? |
| 834 | 877 | call_integration_hook('integrate_cookie', array($name, $value, $expire, $path, $domain, $secure, $httponly)); |
@@ -848,8 +891,9 @@ discard block |
||
| 848 | 891 | function hash_password($username, $password, $cost = null) |
| 849 | 892 | { |
| 850 | 893 | global $sourcedir, $smcFunc, $modSettings; |
| 851 | - if (!function_exists('password_hash')) |
|
| 852 | - require_once($sourcedir . '/Subs-Password.php'); |
|
| 894 | + if (!function_exists('password_hash')) { |
|
| 895 | + require_once($sourcedir . '/Subs-Password.php'); |
|
| 896 | + } |
|
| 853 | 897 | |
| 854 | 898 | $cost = empty($cost) ? (empty($modSettings['bcrypt_hash_cost']) ? 10 : $modSettings['bcrypt_hash_cost']) : $cost; |
| 855 | 899 | |
@@ -881,8 +925,9 @@ discard block |
||
| 881 | 925 | function hash_verify_password($username, $password, $hash) |
| 882 | 926 | { |
| 883 | 927 | global $sourcedir, $smcFunc; |
| 884 | - if (!function_exists('password_verify')) |
|
| 885 | - require_once($sourcedir . '/Subs-Password.php'); |
|
| 928 | + if (!function_exists('password_verify')) { |
|
| 929 | + require_once($sourcedir . '/Subs-Password.php'); |
|
| 930 | + } |
|
| 886 | 931 | |
| 887 | 932 | return password_verify($smcFunc['strtolower']($username) . $password, $hash); |
| 888 | 933 | } |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * This helps organize things... |
@@ -37,13 +38,14 @@ discard block |
||
| 37 | 38 | |
| 38 | 39 | loadLanguage('PersonalMessage+Drafts'); |
| 39 | 40 | |
| 40 | - if (!isset($_REQUEST['xml'])) |
|
| 41 | - loadTemplate('PersonalMessage'); |
|
| 41 | + if (!isset($_REQUEST['xml'])) { |
|
| 42 | + loadTemplate('PersonalMessage'); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | // Load up the members maximum message capacity. |
| 44 | - if ($user_info['is_admin']) |
|
| 45 | - $context['message_limit'] = 0; |
|
| 46 | - elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
| 46 | + if ($user_info['is_admin']) { |
|
| 47 | + $context['message_limit'] = 0; |
|
| 48 | + } elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
| 47 | 49 | { |
| 48 | 50 | // @todo Why do we do this? It seems like if they have any limit we should use it. |
| 49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -78,8 +80,9 @@ discard block |
||
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | // a previous message was sent successfully? show a small indication. |
| 81 | - if (isset($_GET['done']) && ($_GET['done'] == 'sent')) |
|
| 82 | - $context['pm_sent'] = true; |
|
| 83 | + if (isset($_GET['done']) && ($_GET['done'] == 'sent')) { |
|
| 84 | + $context['pm_sent'] = true; |
|
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | $context['labels'] = array(); |
| 85 | 88 | |
@@ -210,11 +213,11 @@ discard block |
||
| 210 | 213 | { |
| 211 | 214 | $_REQUEST['sa'] = ''; |
| 212 | 215 | MessageFolder(); |
| 213 | - } |
|
| 214 | - else |
|
| 216 | + } else |
|
| 215 | 217 | { |
| 216 | - if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') |
|
| 217 | - messageIndexBar($_REQUEST['sa']); |
|
| 218 | + if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') { |
|
| 219 | + messageIndexBar($_REQUEST['sa']); |
|
| 220 | + } |
|
| 218 | 221 | |
| 219 | 222 | call_helper($subActions[$_REQUEST['sa']]); |
| 220 | 223 | } |
@@ -291,16 +294,17 @@ discard block |
||
| 291 | 294 | ); |
| 292 | 295 | |
| 293 | 296 | // Handle labels. |
| 294 | - if (empty($context['currently_using_labels'])) |
|
| 295 | - unset($pm_areas['labels']); |
|
| 296 | - else |
|
| 297 | + if (empty($context['currently_using_labels'])) { |
|
| 298 | + unset($pm_areas['labels']); |
|
| 299 | + } else |
|
| 297 | 300 | { |
| 298 | 301 | // Note we send labels by id as it will have less problems in the querystring. |
| 299 | 302 | $unread_in_labels = 0; |
| 300 | 303 | foreach ($context['labels'] as $label) |
| 301 | 304 | { |
| 302 | - if ($label['id'] == -1) |
|
| 303 | - continue; |
|
| 305 | + if ($label['id'] == -1) { |
|
| 306 | + continue; |
|
| 307 | + } |
|
| 304 | 308 | |
| 305 | 309 | // Count the amount of unread items in labels. |
| 306 | 310 | $unread_in_labels += $label['unread_messages']; |
@@ -314,8 +318,9 @@ discard block |
||
| 314 | 318 | ); |
| 315 | 319 | } |
| 316 | 320 | |
| 317 | - if (!empty($unread_in_labels)) |
|
| 318 | - $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
| 321 | + if (!empty($unread_in_labels)) { |
|
| 322 | + $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
| 323 | + } |
|
| 319 | 324 | } |
| 320 | 325 | |
| 321 | 326 | $pm_areas['folders']['areas']['inbox']['unread_messages'] = &$context['labels'][-1]['unread_messages']; |
@@ -353,8 +358,9 @@ discard block |
||
| 353 | 358 | unset($pm_areas); |
| 354 | 359 | |
| 355 | 360 | // No menu means no access. |
| 356 | - if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) |
|
| 357 | - fatal_lang_error('no_access', false); |
|
| 361 | + if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
| 362 | + fatal_lang_error('no_access', false); |
|
| 363 | + } |
|
| 358 | 364 | |
| 359 | 365 | // Make a note of the Unique ID for this menu. |
| 360 | 366 | $context['pm_menu_id'] = $context['max_menu_id']; |
@@ -365,9 +371,10 @@ discard block |
||
| 365 | 371 | $context['menu_item_selected'] = $current_area; |
| 366 | 372 | |
| 367 | 373 | // Set the template for this area and add the profile layer. |
| 368 | - if (!isset($_REQUEST['xml'])) |
|
| 369 | - $context['template_layers'][] = 'pm'; |
|
| 370 | -} |
|
| 374 | + if (!isset($_REQUEST['xml'])) { |
|
| 375 | + $context['template_layers'][] = 'pm'; |
|
| 376 | + } |
|
| 377 | + } |
|
| 371 | 378 | |
| 372 | 379 | /** |
| 373 | 380 | * The popup for when we ask for the popup from the user. |
@@ -399,8 +406,9 @@ discard block |
||
| 399 | 406 | ) |
| 400 | 407 | ); |
| 401 | 408 | $pms = array(); |
| 402 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 403 | - $pms[] = $row[0]; |
|
| 409 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 410 | + $pms[] = $row[0]; |
|
| 411 | + } |
|
| 404 | 412 | $smcFunc['db_free_result']($request); |
| 405 | 413 | |
| 406 | 414 | if (!empty($pms)) |
@@ -428,8 +436,9 @@ discard block |
||
| 428 | 436 | ); |
| 429 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 430 | 438 | { |
| 431 | - if (!empty($row['id_member_from'])) |
|
| 432 | - $senders[] = $row['id_member_from']; |
|
| 439 | + if (!empty($row['id_member_from'])) { |
|
| 440 | + $senders[] = $row['id_member_from']; |
|
| 441 | + } |
|
| 433 | 442 | |
| 434 | 443 | $row['replied_to_you'] = $row['id_pm'] != $row['id_pm_head']; |
| 435 | 444 | $row['time'] = timeformat($row['timestamp']); |
@@ -439,13 +448,15 @@ discard block |
||
| 439 | 448 | $smcFunc['db_free_result']($request); |
| 440 | 449 | |
| 441 | 450 | $senders = loadMemberData($senders); |
| 442 | - foreach ($senders as $member) |
|
| 443 | - loadMemberContext($member); |
|
| 451 | + foreach ($senders as $member) { |
|
| 452 | + loadMemberContext($member); |
|
| 453 | + } |
|
| 444 | 454 | |
| 445 | 455 | // Having loaded everyone, attach them to the PMs. |
| 446 | - foreach ($context['unread_pms'] as $id_pm => $details) |
|
| 447 | - if (!empty($memberContext[$details['id_member_from']])) |
|
| 456 | + foreach ($context['unread_pms'] as $id_pm => $details) { |
|
| 457 | + if (!empty($memberContext[$details['id_member_from']])) |
|
| 448 | 458 | $context['unread_pms'][$id_pm]['member'] = &$memberContext[$details['id_member_from']]; |
| 459 | + } |
|
| 449 | 460 | } |
| 450 | 461 | } |
| 451 | 462 | |
@@ -465,12 +476,13 @@ discard block |
||
| 465 | 476 | } |
| 466 | 477 | |
| 467 | 478 | // Make sure the starting location is valid. |
| 468 | - if (isset($_GET['start']) && $_GET['start'] != 'new') |
|
| 469 | - $_GET['start'] = (int) $_GET['start']; |
|
| 470 | - elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) |
|
| 471 | - $_GET['start'] = 0; |
|
| 472 | - else |
|
| 473 | - $_GET['start'] = 'new'; |
|
| 479 | + if (isset($_GET['start']) && $_GET['start'] != 'new') { |
|
| 480 | + $_GET['start'] = (int) $_GET['start']; |
|
| 481 | + } elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) { |
|
| 482 | + $_GET['start'] = 0; |
|
| 483 | + } else { |
|
| 484 | + $_GET['start'] = 'new'; |
|
| 485 | + } |
|
| 474 | 486 | |
| 475 | 487 | // Set up some basic theme stuff. |
| 476 | 488 | $context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to'; |
@@ -487,8 +499,7 @@ discard block |
||
| 487 | 499 | { |
| 488 | 500 | $labelQuery = ' |
| 489 | 501 | AND pmr.in_inbox = 1'; |
| 490 | - } |
|
| 491 | - elseif ($context['folder'] != 'sent') |
|
| 502 | + } elseif ($context['folder'] != 'sent') |
|
| 492 | 503 | { |
| 493 | 504 | $labelJoin = ' |
| 494 | 505 | INNER JOIN {db_prefix}pm_labeled_messages AS pl ON (pl.id_pm = pmr.id_pm)'; |
@@ -530,22 +541,24 @@ discard block |
||
| 530 | 541 | $txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']); |
| 531 | 542 | |
| 532 | 543 | // Now, build the link tree! |
| 533 | - if ($context['current_label_id'] == -1) |
|
| 534 | - $context['linktree'][] = array( |
|
| 544 | + if ($context['current_label_id'] == -1) { |
|
| 545 | + $context['linktree'][] = array( |
|
| 535 | 546 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'], |
| 536 | 547 | 'name' => $pmbox |
| 537 | 548 | ); |
| 549 | + } |
|
| 538 | 550 | |
| 539 | 551 | // Build it further for a label. |
| 540 | - if ($context['current_label_id'] != -1) |
|
| 541 | - $context['linktree'][] = array( |
|
| 552 | + if ($context['current_label_id'] != -1) { |
|
| 553 | + $context['linktree'][] = array( |
|
| 542 | 554 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'], |
| 543 | 555 | 'name' => $txt['pm_current_label'] . ': ' . $context['current_label'] |
| 544 | 556 | ); |
| 557 | + } |
|
| 545 | 558 | |
| 546 | 559 | // Figure out how many messages there are. |
| 547 | - if ($context['folder'] == 'sent') |
|
| 548 | - $request = $smcFunc['db_query']('', ' |
|
| 560 | + if ($context['folder'] == 'sent') { |
|
| 561 | + $request = $smcFunc['db_query']('', ' |
|
| 549 | 562 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 550 | 563 | FROM {db_prefix}personal_messages AS pm |
| 551 | 564 | WHERE pm.id_member_from = {int:current_member} |
@@ -555,8 +568,8 @@ discard block |
||
| 555 | 568 | 'not_deleted' => 0, |
| 556 | 569 | ) |
| 557 | 570 | ); |
| 558 | - else |
|
| 559 | - $request = $smcFunc['db_query']('', ' |
|
| 571 | + } else { |
|
| 572 | + $request = $smcFunc['db_query']('', ' |
|
| 560 | 573 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 561 | 574 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 562 | 575 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -567,6 +580,7 @@ discard block |
||
| 567 | 580 | 'not_deleted' => 0, |
| 568 | 581 | ) |
| 569 | 582 | ); |
| 583 | + } |
|
| 570 | 584 | list ($max_messages) = $smcFunc['db_fetch_row']($request); |
| 571 | 585 | $smcFunc['db_free_result']($request); |
| 572 | 586 | |
@@ -575,10 +589,11 @@ discard block |
||
| 575 | 589 | $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
| 576 | 590 | |
| 577 | 591 | // Start on the last page. |
| 578 | - if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) |
|
| 579 | - $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
| 580 | - elseif ($_GET['start'] < 0) |
|
| 581 | - $_GET['start'] = 0; |
|
| 592 | + if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) { |
|
| 593 | + $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
| 594 | + } elseif ($_GET['start'] < 0) { |
|
| 595 | + $_GET['start'] = 0; |
|
| 596 | + } |
|
| 582 | 597 | |
| 583 | 598 | // ... but wait - what if we want to start from a specific message? |
| 584 | 599 | if (isset($_GET['pmid'])) |
@@ -586,19 +601,21 @@ discard block |
||
| 586 | 601 | $pmID = (int) $_GET['pmid']; |
| 587 | 602 | |
| 588 | 603 | // Make sure you have access to this PM. |
| 589 | - if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 590 | - fatal_lang_error('no_access', false); |
|
| 604 | + if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 605 | + fatal_lang_error('no_access', false); |
|
| 606 | + } |
|
| 591 | 607 | |
| 592 | 608 | $context['current_pm'] = $pmID; |
| 593 | 609 | |
| 594 | 610 | // With only one page of PM's we're gonna want page 1. |
| 595 | - if ($max_messages <= $maxPerPage) |
|
| 596 | - $_GET['start'] = 0; |
|
| 611 | + if ($max_messages <= $maxPerPage) { |
|
| 612 | + $_GET['start'] = 0; |
|
| 613 | + } |
|
| 597 | 614 | // If we pass kstart we assume we're in the right place. |
| 598 | 615 | elseif (!isset($_GET['kstart'])) |
| 599 | 616 | { |
| 600 | - if ($context['folder'] == 'sent') |
|
| 601 | - $request = $smcFunc['db_query']('', ' |
|
| 617 | + if ($context['folder'] == 'sent') { |
|
| 618 | + $request = $smcFunc['db_query']('', ' |
|
| 602 | 619 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 603 | 620 | FROM {db_prefix}personal_messages |
| 604 | 621 | WHERE id_member_from = {int:current_member} |
@@ -610,8 +627,8 @@ discard block |
||
| 610 | 627 | 'id_pm' => $pmID, |
| 611 | 628 | ) |
| 612 | 629 | ); |
| 613 | - else |
|
| 614 | - $request = $smcFunc['db_query']('', ' |
|
| 630 | + } else { |
|
| 631 | + $request = $smcFunc['db_query']('', ' |
|
| 615 | 632 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 616 | 633 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 617 | 634 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -624,6 +641,7 @@ discard block |
||
| 624 | 641 | 'id_pm' => $pmID, |
| 625 | 642 | ) |
| 626 | 643 | ); |
| 644 | + } |
|
| 627 | 645 | |
| 628 | 646 | list ($_GET['start']) = $smcFunc['db_fetch_row']($request); |
| 629 | 647 | $smcFunc['db_free_result']($request); |
@@ -638,8 +656,9 @@ discard block |
||
| 638 | 656 | { |
| 639 | 657 | $pmsg = (int) $_GET['pmsg']; |
| 640 | 658 | |
| 641 | - if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 642 | - fatal_lang_error('no_access', false); |
|
| 659 | + if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 660 | + fatal_lang_error('no_access', false); |
|
| 661 | + } |
|
| 643 | 662 | } |
| 644 | 663 | |
| 645 | 664 | // Set up the page index. |
@@ -734,8 +753,9 @@ discard block |
||
| 734 | 753 | { |
| 735 | 754 | if (!isset($recipients[$row['id_pm']])) |
| 736 | 755 | { |
| 737 | - if (isset($row['id_member_from'])) |
|
| 738 | - $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 756 | + if (isset($row['id_member_from'])) { |
|
| 757 | + $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 758 | + } |
|
| 739 | 759 | $pms[$row['id_pm']] = $row['id_pm']; |
| 740 | 760 | $recipients[$row['id_pm']] = array( |
| 741 | 761 | 'to' => array(), |
@@ -744,29 +764,33 @@ discard block |
||
| 744 | 764 | } |
| 745 | 765 | |
| 746 | 766 | // Keep track of the last message so we know what the head is without another query! |
| 747 | - if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) |
|
| 748 | - $lastData = array( |
|
| 767 | + if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) { |
|
| 768 | + $lastData = array( |
|
| 749 | 769 | 'id' => $row['id_pm'], |
| 750 | 770 | 'head' => $row['id_pm_head'], |
| 751 | 771 | ); |
| 772 | + } |
|
| 752 | 773 | } |
| 753 | 774 | $smcFunc['db_free_result']($request); |
| 754 | 775 | |
| 755 | 776 | // Make sure that we have been given a correct head pm id! |
| 756 | - if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) |
|
| 757 | - fatal_lang_error('no_access', false); |
|
| 777 | + if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) { |
|
| 778 | + fatal_lang_error('no_access', false); |
|
| 779 | + } |
|
| 758 | 780 | |
| 759 | 781 | if (!empty($pms)) |
| 760 | 782 | { |
| 761 | 783 | // Select the correct current message. |
| 762 | - if (empty($pmID)) |
|
| 763 | - $context['current_pm'] = $lastData['id']; |
|
| 784 | + if (empty($pmID)) { |
|
| 785 | + $context['current_pm'] = $lastData['id']; |
|
| 786 | + } |
|
| 764 | 787 | |
| 765 | 788 | // This is a list of the pm's that are used for "full" display. |
| 766 | - if ($context['display_mode'] == 0) |
|
| 767 | - $display_pms = $pms; |
|
| 768 | - else |
|
| 769 | - $display_pms = array($context['current_pm']); |
|
| 789 | + if ($context['display_mode'] == 0) { |
|
| 790 | + $display_pms = $pms; |
|
| 791 | + } else { |
|
| 792 | + $display_pms = array($context['current_pm']); |
|
| 793 | + } |
|
| 770 | 794 | |
| 771 | 795 | // At this point we know the main id_pm's. But - if we are looking at conversations we need the others! |
| 772 | 796 | if ($context['display_mode'] == 2) |
@@ -788,16 +812,18 @@ discard block |
||
| 788 | 812 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 789 | 813 | { |
| 790 | 814 | // This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn! |
| 791 | - if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) |
|
| 792 | - continue; |
|
| 793 | - elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) |
|
| 794 | - continue; |
|
| 815 | + if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) { |
|
| 816 | + continue; |
|
| 817 | + } elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) { |
|
| 818 | + continue; |
|
| 819 | + } |
|
| 795 | 820 | |
| 796 | - if (!isset($recipients[$row['id_pm']])) |
|
| 797 | - $recipients[$row['id_pm']] = array( |
|
| 821 | + if (!isset($recipients[$row['id_pm']])) { |
|
| 822 | + $recipients[$row['id_pm']] = array( |
|
| 798 | 823 | 'to' => array(), |
| 799 | 824 | 'bcc' => array() |
| 800 | 825 | ); |
| 826 | + } |
|
| 801 | 827 | $display_pms[] = $row['id_pm']; |
| 802 | 828 | $posters[$row['id_pm']] = $row['id_member_from']; |
| 803 | 829 | } |
@@ -848,8 +874,9 @@ discard block |
||
| 848 | 874 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 849 | 875 | { |
| 850 | 876 | $l_id = $row2['id_label']; |
| 851 | - if (isset($context['labels'][$l_id])) |
|
| 852 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 877 | + if (isset($context['labels'][$l_id])) { |
|
| 878 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 879 | + } |
|
| 853 | 880 | } |
| 854 | 881 | |
| 855 | 882 | $smcFunc['db_free_result']($request2); |
@@ -866,9 +893,10 @@ discard block |
||
| 866 | 893 | // Make sure we don't load unnecessary data. |
| 867 | 894 | if ($context['display_mode'] == 1) |
| 868 | 895 | { |
| 869 | - foreach ($posters as $k => $v) |
|
| 870 | - if (!in_array($k, $display_pms)) |
|
| 896 | + foreach ($posters as $k => $v) { |
|
| 897 | + if (!in_array($k, $display_pms)) |
|
| 871 | 898 | unset($posters[$k]); |
| 899 | + } |
|
| 872 | 900 | } |
| 873 | 901 | |
| 874 | 902 | // Load any users.... |
@@ -879,8 +907,9 @@ discard block |
||
| 879 | 907 | { |
| 880 | 908 | // Get the order right. |
| 881 | 909 | $orderBy = array(); |
| 882 | - foreach (array_reverse($pms) as $pm) |
|
| 883 | - $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 910 | + foreach (array_reverse($pms) as $pm) { |
|
| 911 | + $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 912 | + } |
|
| 884 | 913 | |
| 885 | 914 | // Seperate query for these bits! |
| 886 | 915 | $subjects_request = $smcFunc['db_query']('', ' |
@@ -926,9 +955,9 @@ discard block |
||
| 926 | 955 | // Allow mods to add additional buttons here |
| 927 | 956 | call_integration_hook('integrate_conversation_buttons'); |
| 928 | 957 | } |
| 958 | + } else { |
|
| 959 | + $messages_request = false; |
|
| 929 | 960 | } |
| 930 | - else |
|
| 931 | - $messages_request = false; |
|
| 932 | 961 | |
| 933 | 962 | $context['can_send_pm'] = allowedTo('pm_send'); |
| 934 | 963 | $context['can_send_email'] = allowedTo('moderate_forum'); |
@@ -939,11 +968,13 @@ discard block |
||
| 939 | 968 | if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages'])) |
| 940 | 969 | { |
| 941 | 970 | // If the display mode is "old sk00l" do them all... |
| 942 | - if ($context['display_mode'] == 0) |
|
| 943 | - markMessages(null, $context['current_label_id']); |
|
| 971 | + if ($context['display_mode'] == 0) { |
|
| 972 | + markMessages(null, $context['current_label_id']); |
|
| 973 | + } |
|
| 944 | 974 | // Otherwise do just the current one! |
| 945 | - elseif (!empty($context['current_pm'])) |
|
| 946 | - markMessages($display_pms, $context['current_label_id']); |
|
| 975 | + elseif (!empty($context['current_pm'])) { |
|
| 976 | + markMessages($display_pms, $context['current_label_id']); |
|
| 977 | + } |
|
| 947 | 978 | } |
| 948 | 979 | } |
| 949 | 980 | |
@@ -961,8 +992,9 @@ discard block |
||
| 961 | 992 | |
| 962 | 993 | // Count the current message number.... |
| 963 | 994 | static $counter = null; |
| 964 | - if ($counter === null || $reset) |
|
| 965 | - $counter = $context['start']; |
|
| 995 | + if ($counter === null || $reset) { |
|
| 996 | + $counter = $context['start']; |
|
| 997 | + } |
|
| 966 | 998 | |
| 967 | 999 | static $temp_pm_selected = null; |
| 968 | 1000 | if ($temp_pm_selected === null) |
@@ -1007,19 +1039,22 @@ discard block |
||
| 1007 | 1039 | } |
| 1008 | 1040 | |
| 1009 | 1041 | // Bail if it's false, ie. no messages. |
| 1010 | - if ($messages_request == false) |
|
| 1011 | - return false; |
|
| 1042 | + if ($messages_request == false) { |
|
| 1043 | + return false; |
|
| 1044 | + } |
|
| 1012 | 1045 | |
| 1013 | 1046 | // Reset the data? |
| 1014 | - if ($reset == true) |
|
| 1015 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1047 | + if ($reset == true) { |
|
| 1048 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1049 | + } |
|
| 1016 | 1050 | |
| 1017 | 1051 | // Get the next one... bail if anything goes wrong. |
| 1018 | 1052 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
| 1019 | 1053 | if (!$message) |
| 1020 | 1054 | { |
| 1021 | - if ($type != 'subject') |
|
| 1022 | - $smcFunc['db_free_result']($messages_request); |
|
| 1055 | + if ($type != 'subject') { |
|
| 1056 | + $smcFunc['db_free_result']($messages_request); |
|
| 1057 | + } |
|
| 1023 | 1058 | |
| 1024 | 1059 | return false; |
| 1025 | 1060 | } |
@@ -1039,8 +1074,7 @@ discard block |
||
| 1039 | 1074 | $memberContext[$message['id_member_from']]['email'] = ''; |
| 1040 | 1075 | $memberContext[$message['id_member_from']]['show_email'] = false; |
| 1041 | 1076 | $memberContext[$message['id_member_from']]['is_guest'] = true; |
| 1042 | - } |
|
| 1043 | - else |
|
| 1077 | + } else |
|
| 1044 | 1078 | { |
| 1045 | 1079 | $memberContext[$message['id_member_from']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member_from'] == $user_info['id'] && !$user_info['is_guest']); |
| 1046 | 1080 | $memberContext[$message['id_member_from']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member_from']]['warning_status'] && ($context['user']['can_mod'] || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member_from'] == $user_info['id']))); |
@@ -1081,12 +1115,13 @@ discard block |
||
| 1081 | 1115 | $counter++; |
| 1082 | 1116 | |
| 1083 | 1117 | // Any custom profile fields? |
| 1084 | - if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) |
|
| 1085 | - foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1118 | + if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) { |
|
| 1119 | + foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1086 | 1120 | switch ($custom['placement']) |
| 1087 | 1121 | { |
| 1088 | 1122 | case 1: |
| 1089 | 1123 | $output['custom_fields']['icons'][] = $custom; |
| 1124 | + } |
|
| 1090 | 1125 | break; |
| 1091 | 1126 | case 2: |
| 1092 | 1127 | $output['custom_fields']['above_signature'][] = $custom; |
@@ -1129,22 +1164,28 @@ discard block |
||
| 1129 | 1164 | $context['search_params'][$k] = $v; |
| 1130 | 1165 | } |
| 1131 | 1166 | } |
| 1132 | - if (isset($_REQUEST['search'])) |
|
| 1133 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1167 | + if (isset($_REQUEST['search'])) { |
|
| 1168 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1169 | + } |
|
| 1134 | 1170 | |
| 1135 | - if (isset($context['search_params']['search'])) |
|
| 1136 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1137 | - if (isset($context['search_params']['userspec'])) |
|
| 1138 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1171 | + if (isset($context['search_params']['search'])) { |
|
| 1172 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1173 | + } |
|
| 1174 | + if (isset($context['search_params']['userspec'])) { |
|
| 1175 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1176 | + } |
|
| 1139 | 1177 | |
| 1140 | - if (!empty($context['search_params']['searchtype'])) |
|
| 1141 | - $context['search_params']['searchtype'] = 2; |
|
| 1178 | + if (!empty($context['search_params']['searchtype'])) { |
|
| 1179 | + $context['search_params']['searchtype'] = 2; |
|
| 1180 | + } |
|
| 1142 | 1181 | |
| 1143 | - if (!empty($context['search_params']['minage'])) |
|
| 1144 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1182 | + if (!empty($context['search_params']['minage'])) { |
|
| 1183 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1184 | + } |
|
| 1145 | 1185 | |
| 1146 | - if (!empty($context['search_params']['maxage'])) |
|
| 1147 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1186 | + if (!empty($context['search_params']['maxage'])) { |
|
| 1187 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1188 | + } |
|
| 1148 | 1189 | |
| 1149 | 1190 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
| 1150 | 1191 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
@@ -1171,8 +1212,9 @@ discard block |
||
| 1171 | 1212 | $context['search_errors']['messages'] = array(); |
| 1172 | 1213 | foreach ($context['search_errors'] as $search_error => $dummy) |
| 1173 | 1214 | { |
| 1174 | - if ($search_error == 'messages') |
|
| 1175 | - continue; |
|
| 1215 | + if ($search_error == 'messages') { |
|
| 1216 | + continue; |
|
| 1217 | + } |
|
| 1176 | 1218 | |
| 1177 | 1219 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
| 1178 | 1220 | } |
@@ -1194,8 +1236,9 @@ discard block |
||
| 1194 | 1236 | global $scripturl, $modSettings, $user_info, $context, $txt; |
| 1195 | 1237 | global $memberContext, $smcFunc; |
| 1196 | 1238 | |
| 1197 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
| 1198 | - fatal_lang_error('loadavg_search_disabled', false); |
|
| 1239 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
| 1240 | + fatal_lang_error('loadavg_search_disabled', false); |
|
| 1241 | + } |
|
| 1199 | 1242 | |
| 1200 | 1243 | /** |
| 1201 | 1244 | * @todo For the moment force the folder to the inbox. |
@@ -1224,35 +1267,40 @@ discard block |
||
| 1224 | 1267 | $context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
| 1225 | 1268 | |
| 1226 | 1269 | // Store whether simple search was used (needed if the user wants to do another query). |
| 1227 | - if (!isset($search_params['advanced'])) |
|
| 1228 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1270 | + if (!isset($search_params['advanced'])) { |
|
| 1271 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1272 | + } |
|
| 1229 | 1273 | |
| 1230 | 1274 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
| 1231 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
| 1232 | - $search_params['searchtype'] = 2; |
|
| 1275 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
| 1276 | + $search_params['searchtype'] = 2; |
|
| 1277 | + } |
|
| 1233 | 1278 | |
| 1234 | 1279 | // Minimum age of messages. Default to zero (don't set param in that case). |
| 1235 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
| 1236 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1280 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
| 1281 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1282 | + } |
|
| 1237 | 1283 | |
| 1238 | 1284 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
| 1239 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) |
|
| 1240 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1285 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) { |
|
| 1286 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1287 | + } |
|
| 1241 | 1288 | |
| 1242 | 1289 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
| 1243 | 1290 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
| 1244 | 1291 | |
| 1245 | 1292 | // Default the user name to a wildcard matching every user (*). |
| 1246 | - if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
| 1247 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1293 | + if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
| 1294 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1295 | + } |
|
| 1248 | 1296 | |
| 1249 | 1297 | // This will be full of all kinds of parameters! |
| 1250 | 1298 | $searchq_parameters = array(); |
| 1251 | 1299 | |
| 1252 | 1300 | // If there's no specific user, then don't mention it in the main query. |
| 1253 | - if (empty($search_params['userspec'])) |
|
| 1254 | - $userQuery = ''; |
|
| 1255 | - else |
|
| 1301 | + if (empty($search_params['userspec'])) { |
|
| 1302 | + $userQuery = ''; |
|
| 1303 | + } else |
|
| 1256 | 1304 | { |
| 1257 | 1305 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
| 1258 | 1306 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -1264,8 +1312,9 @@ discard block |
||
| 1264 | 1312 | { |
| 1265 | 1313 | $possible_users[$k] = trim($possible_users[$k]); |
| 1266 | 1314 | |
| 1267 | - if (strlen($possible_users[$k]) == 0) |
|
| 1268 | - unset($possible_users[$k]); |
|
| 1315 | + if (strlen($possible_users[$k]) == 0) { |
|
| 1316 | + unset($possible_users[$k]); |
|
| 1317 | + } |
|
| 1269 | 1318 | } |
| 1270 | 1319 | |
| 1271 | 1320 | if (!empty($possible_users)) |
@@ -1277,8 +1326,9 @@ discard block |
||
| 1277 | 1326 | { |
| 1278 | 1327 | $where_params['name_' . $k] = $v; |
| 1279 | 1328 | $where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}'; |
| 1280 | - if (!isset($where_params['real_name'])) |
|
| 1281 | - $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1329 | + if (!isset($where_params['real_name'])) { |
|
| 1330 | + $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1331 | + } |
|
| 1282 | 1332 | } |
| 1283 | 1333 | |
| 1284 | 1334 | // Who matches those criteria? |
@@ -1291,28 +1341,28 @@ discard block |
||
| 1291 | 1341 | ); |
| 1292 | 1342 | |
| 1293 | 1343 | // Simply do nothing if there're too many members matching the criteria. |
| 1294 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
| 1295 | - $userQuery = ''; |
|
| 1296 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1344 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
| 1345 | + $userQuery = ''; |
|
| 1346 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1297 | 1347 | { |
| 1298 | 1348 | $userQuery = 'AND pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})'; |
| 1299 | 1349 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
| 1300 | 1350 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1301 | - } |
|
| 1302 | - else |
|
| 1351 | + } else |
|
| 1303 | 1352 | { |
| 1304 | 1353 | $memberlist = array(); |
| 1305 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1306 | - $memberlist[] = $row['id_member']; |
|
| 1354 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1355 | + $memberlist[] = $row['id_member']; |
|
| 1356 | + } |
|
| 1307 | 1357 | $userQuery = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})))'; |
| 1308 | 1358 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
| 1309 | 1359 | $searchq_parameters['member_list'] = $memberlist; |
| 1310 | 1360 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1311 | 1361 | } |
| 1312 | 1362 | $smcFunc['db_free_result']($request); |
| 1363 | + } else { |
|
| 1364 | + $userQuery = ''; |
|
| 1313 | 1365 | } |
| 1314 | - else |
|
| 1315 | - $userQuery = ''; |
|
| 1316 | 1366 | } |
| 1317 | 1367 | |
| 1318 | 1368 | // Setup the sorting variables... |
@@ -1320,8 +1370,9 @@ discard block |
||
| 1320 | 1370 | $sort_columns = array( |
| 1321 | 1371 | 'pm.id_pm', |
| 1322 | 1372 | ); |
| 1323 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
| 1324 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1373 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
| 1374 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1375 | + } |
|
| 1325 | 1376 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'pm.id_pm'; |
| 1326 | 1377 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
| 1327 | 1378 | |
@@ -1331,24 +1382,27 @@ discard block |
||
| 1331 | 1382 | if ($context['folder'] == 'inbox' && !empty($search_params['advanced']) && $context['currently_using_labels']) |
| 1332 | 1383 | { |
| 1333 | 1384 | // Came here from pagination? Put them back into $_REQUEST for sanitization. |
| 1334 | - if (isset($search_params['labels'])) |
|
| 1335 | - $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1385 | + if (isset($search_params['labels'])) { |
|
| 1386 | + $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1387 | + } |
|
| 1336 | 1388 | |
| 1337 | 1389 | // Assuming we have some labels - make them all integers. |
| 1338 | 1390 | if (!empty($_REQUEST['searchlabel']) && is_array($_REQUEST['searchlabel'])) |
| 1339 | 1391 | { |
| 1340 | - foreach ($_REQUEST['searchlabel'] as $key => $id) |
|
| 1341 | - $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1392 | + foreach ($_REQUEST['searchlabel'] as $key => $id) { |
|
| 1393 | + $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1394 | + } |
|
| 1395 | + } else { |
|
| 1396 | + $_REQUEST['searchlabel'] = array(); |
|
| 1342 | 1397 | } |
| 1343 | - else |
|
| 1344 | - $_REQUEST['searchlabel'] = array(); |
|
| 1345 | 1398 | |
| 1346 | 1399 | // Now that everything is cleaned up a bit, make the labels a param. |
| 1347 | 1400 | $search_params['labels'] = implode(',', $_REQUEST['searchlabel']); |
| 1348 | 1401 | |
| 1349 | 1402 | // No labels selected? That must be an error! |
| 1350 | - if (empty($_REQUEST['searchlabel'])) |
|
| 1351 | - $context['search_errors']['no_labels_selected'] = true; |
|
| 1403 | + if (empty($_REQUEST['searchlabel'])) { |
|
| 1404 | + $context['search_errors']['no_labels_selected'] = true; |
|
| 1405 | + } |
|
| 1352 | 1406 | // Otherwise prepare the query! |
| 1353 | 1407 | elseif (count($_REQUEST['searchlabel']) != count($context['labels'])) |
| 1354 | 1408 | { |
@@ -1371,8 +1425,7 @@ discard block |
||
| 1371 | 1425 | // Not searching the inbox - PM must be labeled |
| 1372 | 1426 | $labelQuery = ' AND pml.id_label IN ({array_int:labels})'; |
| 1373 | 1427 | $labelJoin = ' INNER JOIN {db_prefix}pm_labeled_messages AS pml ON (pml.id_pm = pmr.id_pm)'; |
| 1374 | - } |
|
| 1375 | - else |
|
| 1428 | + } else |
|
| 1376 | 1429 | { |
| 1377 | 1430 | // Searching the inbox - PM doesn't have to be labeled |
| 1378 | 1431 | $labelQuery = ' AND (' . substr($labelQuery, 5) . ' OR pml.id_label IN ({array_int:labels}))'; |
@@ -1387,8 +1440,9 @@ discard block |
||
| 1387 | 1440 | // What are we actually searching for? |
| 1388 | 1441 | $search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? $_REQUEST['search'] : ''); |
| 1389 | 1442 | // If we ain't got nothing - we should error! |
| 1390 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
| 1391 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1443 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
| 1444 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1445 | + } |
|
| 1392 | 1446 | |
| 1393 | 1447 | // Extract phrase parts first (e.g. some words "this is a phrase" some more words.) |
| 1394 | 1448 | preg_match_all('~(?:^|\s)([-]?)"([^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), $search_params['search'], $matches, PREG_PATTERN_ORDER); |
@@ -1401,12 +1455,14 @@ discard block |
||
| 1401 | 1455 | $excludedWords = array(); |
| 1402 | 1456 | |
| 1403 | 1457 | // .. first, we check for things like -"some words", but not "-some words". |
| 1404 | - foreach ($matches[1] as $index => $word) |
|
| 1405 | - if ($word == '-') |
|
| 1458 | + foreach ($matches[1] as $index => $word) { |
|
| 1459 | + if ($word == '-') |
|
| 1406 | 1460 | { |
| 1407 | 1461 | $word = $smcFunc['strtolower'](trim($searchArray[$index])); |
| 1408 | - if (strlen($word) > 0) |
|
| 1409 | - $excludedWords[] = $word; |
|
| 1462 | + } |
|
| 1463 | + if (strlen($word) > 0) { |
|
| 1464 | + $excludedWords[] = $word; |
|
| 1465 | + } |
|
| 1410 | 1466 | unset($searchArray[$index]); |
| 1411 | 1467 | } |
| 1412 | 1468 | |
@@ -1416,8 +1472,9 @@ discard block |
||
| 1416 | 1472 | if (strpos(trim($word), '-') === 0) |
| 1417 | 1473 | { |
| 1418 | 1474 | $word = substr($smcFunc['strtolower']($word), 1); |
| 1419 | - if (strlen($word) > 0) |
|
| 1420 | - $excludedWords[] = $word; |
|
| 1475 | + if (strlen($word) > 0) { |
|
| 1476 | + $excludedWords[] = $word; |
|
| 1477 | + } |
|
| 1421 | 1478 | unset($tempSearch[$index]); |
| 1422 | 1479 | } |
| 1423 | 1480 | } |
@@ -1428,9 +1485,9 @@ discard block |
||
| 1428 | 1485 | foreach ($searchArray as $index => $value) |
| 1429 | 1486 | { |
| 1430 | 1487 | $searchArray[$index] = $smcFunc['strtolower'](trim($value)); |
| 1431 | - if ($searchArray[$index] == '') |
|
| 1432 | - unset($searchArray[$index]); |
|
| 1433 | - else |
|
| 1488 | + if ($searchArray[$index] == '') { |
|
| 1489 | + unset($searchArray[$index]); |
|
| 1490 | + } else |
|
| 1434 | 1491 | { |
| 1435 | 1492 | // Sort out entities first. |
| 1436 | 1493 | $searchArray[$index] = $smcFunc['htmlspecialchars']($searchArray[$index]); |
@@ -1440,27 +1497,32 @@ discard block |
||
| 1440 | 1497 | |
| 1441 | 1498 | // Create an array of replacements for highlighting. |
| 1442 | 1499 | $context['mark'] = array(); |
| 1443 | - foreach ($searchArray as $word) |
|
| 1444 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1500 | + foreach ($searchArray as $word) { |
|
| 1501 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1502 | + } |
|
| 1445 | 1503 | |
| 1446 | 1504 | // This contains *everything* |
| 1447 | 1505 | $searchWords = array_merge($searchArray, $excludedWords); |
| 1448 | 1506 | |
| 1449 | 1507 | // Make sure at least one word is being searched for. |
| 1450 | - if (empty($searchArray)) |
|
| 1451 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1508 | + if (empty($searchArray)) { |
|
| 1509 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1510 | + } |
|
| 1452 | 1511 | |
| 1453 | 1512 | // Sort out the search query so the user can edit it - if they want. |
| 1454 | 1513 | $context['search_params'] = $search_params; |
| 1455 | - if (isset($context['search_params']['search'])) |
|
| 1456 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1457 | - if (isset($context['search_params']['userspec'])) |
|
| 1458 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1514 | + if (isset($context['search_params']['search'])) { |
|
| 1515 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1516 | + } |
|
| 1517 | + if (isset($context['search_params']['userspec'])) { |
|
| 1518 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1519 | + } |
|
| 1459 | 1520 | |
| 1460 | 1521 | // Now we have all the parameters, combine them together for pagination and the like... |
| 1461 | 1522 | $context['params'] = array(); |
| 1462 | - foreach ($search_params as $k => $v) |
|
| 1463 | - $context['params'][] = $k . '|\'|' . $v; |
|
| 1523 | + foreach ($search_params as $k => $v) { |
|
| 1524 | + $context['params'][] = $k . '|\'|' . $v; |
|
| 1525 | + } |
|
| 1464 | 1526 | $context['params'] = base64_encode(implode('|"|', $context['params'])); |
| 1465 | 1527 | |
| 1466 | 1528 | // Compile the subject query part. |
@@ -1468,26 +1530,31 @@ discard block |
||
| 1468 | 1530 | |
| 1469 | 1531 | foreach ($searchWords as $index => $word) |
| 1470 | 1532 | { |
| 1471 | - if ($word == '') |
|
| 1472 | - continue; |
|
| 1533 | + if ($word == '') { |
|
| 1534 | + continue; |
|
| 1535 | + } |
|
| 1473 | 1536 | |
| 1474 | - if ($search_params['subject_only']) |
|
| 1475 | - $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1476 | - else |
|
| 1477 | - $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
| 1537 | + if ($search_params['subject_only']) { |
|
| 1538 | + $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1539 | + } else { |
|
| 1540 | + $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
| 1541 | + } |
|
| 1478 | 1542 | $searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%'; |
| 1479 | 1543 | } |
| 1480 | 1544 | |
| 1481 | 1545 | $searchQuery = ' 1=1'; |
| 1482 | - if (!empty($andQueryParts)) |
|
| 1483 | - $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1546 | + if (!empty($andQueryParts)) { |
|
| 1547 | + $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1548 | + } |
|
| 1484 | 1549 | |
| 1485 | 1550 | // Age limits? |
| 1486 | 1551 | $timeQuery = ''; |
| 1487 | - if (!empty($search_params['minage'])) |
|
| 1488 | - $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1489 | - if (!empty($search_params['maxage'])) |
|
| 1490 | - $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1552 | + if (!empty($search_params['minage'])) { |
|
| 1553 | + $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1554 | + } |
|
| 1555 | + if (!empty($search_params['maxage'])) { |
|
| 1556 | + $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1557 | + } |
|
| 1491 | 1558 | |
| 1492 | 1559 | // If we have errors - return back to the first screen... |
| 1493 | 1560 | if (!empty($context['search_errors'])) |
@@ -1573,8 +1640,9 @@ discard block |
||
| 1573 | 1640 | ) |
| 1574 | 1641 | ); |
| 1575 | 1642 | $real_pm_ids = array(); |
| 1576 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1577 | - $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1643 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1644 | + $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1645 | + } |
|
| 1578 | 1646 | $smcFunc['db_free_result']($request); |
| 1579 | 1647 | } |
| 1580 | 1648 | |
@@ -1604,8 +1672,9 @@ discard block |
||
| 1604 | 1672 | ); |
| 1605 | 1673 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1606 | 1674 | { |
| 1607 | - if ($context['folder'] == 'sent' || empty($row['bcc'])) |
|
| 1608 | - $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
| 1675 | + if ($context['folder'] == 'sent' || empty($row['bcc'])) { |
|
| 1676 | + $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
| 1677 | + } |
|
| 1609 | 1678 | |
| 1610 | 1679 | if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') |
| 1611 | 1680 | { |
@@ -1626,12 +1695,14 @@ discard block |
||
| 1626 | 1695 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 1627 | 1696 | { |
| 1628 | 1697 | $l_id = $row2['id_label']; |
| 1629 | - if (isset($context['labels'][$l_id])) |
|
| 1630 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1698 | + if (isset($context['labels'][$l_id])) { |
|
| 1699 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1700 | + } |
|
| 1631 | 1701 | |
| 1632 | 1702 | // Here we find the first label on a message - for linking to posts in results |
| 1633 | - if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) |
|
| 1634 | - $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1703 | + if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) { |
|
| 1704 | + $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1705 | + } |
|
| 1635 | 1706 | } |
| 1636 | 1707 | |
| 1637 | 1708 | $smcFunc['db_free_result']($request2); |
@@ -1758,8 +1829,9 @@ discard block |
||
| 1758 | 1829 | list ($postCount) = $smcFunc['db_fetch_row']($request); |
| 1759 | 1830 | $smcFunc['db_free_result']($request); |
| 1760 | 1831 | |
| 1761 | - if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
|
| 1762 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1832 | + if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) { |
|
| 1833 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1834 | + } |
|
| 1763 | 1835 | } |
| 1764 | 1836 | |
| 1765 | 1837 | // Quoting/Replying to a message? |
@@ -1768,8 +1840,9 @@ discard block |
||
| 1768 | 1840 | $pmsg = (int) $_REQUEST['pmsg']; |
| 1769 | 1841 | |
| 1770 | 1842 | // Make sure this is yours. |
| 1771 | - if (!isAccessiblePM($pmsg)) |
|
| 1772 | - fatal_lang_error('no_access', false); |
|
| 1843 | + if (!isAccessiblePM($pmsg)) { |
|
| 1844 | + fatal_lang_error('no_access', false); |
|
| 1845 | + } |
|
| 1773 | 1846 | |
| 1774 | 1847 | // Work out whether this is one you've received? |
| 1775 | 1848 | $request = $smcFunc['db_query']('', ' |
@@ -1806,8 +1879,9 @@ discard block |
||
| 1806 | 1879 | 'id_pm' => $pmsg, |
| 1807 | 1880 | ) |
| 1808 | 1881 | ); |
| 1809 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1810 | - fatal_lang_error('pm_not_yours', false); |
|
| 1882 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1883 | + fatal_lang_error('pm_not_yours', false); |
|
| 1884 | + } |
|
| 1811 | 1885 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 1812 | 1886 | $smcFunc['db_free_result']($request); |
| 1813 | 1887 | |
@@ -1818,9 +1892,9 @@ discard block |
||
| 1818 | 1892 | // Add 'Re: ' to it.... |
| 1819 | 1893 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 1820 | 1894 | { |
| 1821 | - if ($language === $user_info['language']) |
|
| 1822 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 1823 | - else |
|
| 1895 | + if ($language === $user_info['language']) { |
|
| 1896 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 1897 | + } else |
|
| 1824 | 1898 | { |
| 1825 | 1899 | loadLanguage('index', $language, false); |
| 1826 | 1900 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1829,22 +1903,25 @@ discard block |
||
| 1829 | 1903 | cache_put_data('response_prefix', $context['response_prefix'], 600); |
| 1830 | 1904 | } |
| 1831 | 1905 | $form_subject = $row_quoted['subject']; |
| 1832 | - if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 1833 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1906 | + if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 1907 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1908 | + } |
|
| 1834 | 1909 | |
| 1835 | 1910 | if (isset($_REQUEST['quote'])) |
| 1836 | 1911 | { |
| 1837 | 1912 | // Remove any nested quotes and <br>... |
| 1838 | 1913 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $row_quoted['body']); |
| 1839 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 1840 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1841 | - if (empty($row_quoted['id_member'])) |
|
| 1842 | - $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1843 | - else |
|
| 1844 | - $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1914 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 1915 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1916 | + } |
|
| 1917 | + if (empty($row_quoted['id_member'])) { |
|
| 1918 | + $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1919 | + } else { |
|
| 1920 | + $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1921 | + } |
|
| 1922 | + } else { |
|
| 1923 | + $form_message = ''; |
|
| 1845 | 1924 | } |
| 1846 | - else |
|
| 1847 | - $form_message = ''; |
|
| 1848 | 1925 | |
| 1849 | 1926 | // Do the BBC thang on the message. |
| 1850 | 1927 | $row_quoted['body'] = parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']); |
@@ -1865,8 +1942,7 @@ discard block |
||
| 1865 | 1942 | 'timestamp' => forum_time(true, $row_quoted['msgtime']), |
| 1866 | 1943 | 'body' => $row_quoted['body'] |
| 1867 | 1944 | ); |
| 1868 | - } |
|
| 1869 | - else |
|
| 1945 | + } else |
|
| 1870 | 1946 | { |
| 1871 | 1947 | $context['quoted_message'] = false; |
| 1872 | 1948 | $form_subject = ''; |
@@ -1885,11 +1961,12 @@ discard block |
||
| 1885 | 1961 | if ($_REQUEST['u'] == 'all' && isset($row_quoted)) |
| 1886 | 1962 | { |
| 1887 | 1963 | // Firstly, to reply to all we clearly already have $row_quoted - so have the original member from. |
| 1888 | - if ($row_quoted['id_member'] != $user_info['id']) |
|
| 1889 | - $context['recipients']['to'][] = array( |
|
| 1964 | + if ($row_quoted['id_member'] != $user_info['id']) { |
|
| 1965 | + $context['recipients']['to'][] = array( |
|
| 1890 | 1966 | 'id' => $row_quoted['id_member'], |
| 1891 | 1967 | 'name' => $smcFunc['htmlspecialchars']($row_quoted['real_name']), |
| 1892 | 1968 | ); |
| 1969 | + } |
|
| 1893 | 1970 | |
| 1894 | 1971 | // Now to get the others. |
| 1895 | 1972 | $request = $smcFunc['db_query']('', ' |
@@ -1905,18 +1982,19 @@ discard block |
||
| 1905 | 1982 | 'not_bcc' => 0, |
| 1906 | 1983 | ) |
| 1907 | 1984 | ); |
| 1908 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1909 | - $context['recipients']['to'][] = array( |
|
| 1985 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1986 | + $context['recipients']['to'][] = array( |
|
| 1910 | 1987 | 'id' => $row['id_member'], |
| 1911 | 1988 | 'name' => $row['real_name'], |
| 1912 | 1989 | ); |
| 1990 | + } |
|
| 1913 | 1991 | $smcFunc['db_free_result']($request); |
| 1914 | - } |
|
| 1915 | - else |
|
| 1992 | + } else |
|
| 1916 | 1993 | { |
| 1917 | 1994 | $_REQUEST['u'] = explode(',', $_REQUEST['u']); |
| 1918 | - foreach ($_REQUEST['u'] as $key => $uID) |
|
| 1919 | - $_REQUEST['u'][$key] = (int) $uID; |
|
| 1995 | + foreach ($_REQUEST['u'] as $key => $uID) { |
|
| 1996 | + $_REQUEST['u'][$key] = (int) $uID; |
|
| 1997 | + } |
|
| 1920 | 1998 | |
| 1921 | 1999 | $_REQUEST['u'] = array_unique($_REQUEST['u']); |
| 1922 | 2000 | |
@@ -1930,22 +2008,24 @@ discard block |
||
| 1930 | 2008 | 'limit' => count($_REQUEST['u']), |
| 1931 | 2009 | ) |
| 1932 | 2010 | ); |
| 1933 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1934 | - $context['recipients']['to'][] = array( |
|
| 2011 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2012 | + $context['recipients']['to'][] = array( |
|
| 1935 | 2013 | 'id' => $row['id_member'], |
| 1936 | 2014 | 'name' => $row['real_name'], |
| 1937 | 2015 | ); |
| 2016 | + } |
|
| 1938 | 2017 | $smcFunc['db_free_result']($request); |
| 1939 | 2018 | } |
| 1940 | 2019 | |
| 1941 | 2020 | // Get a literal name list in case the user has JavaScript disabled. |
| 1942 | 2021 | $names = array(); |
| 1943 | - foreach ($context['recipients']['to'] as $to) |
|
| 1944 | - $names[] = $to['name']; |
|
| 2022 | + foreach ($context['recipients']['to'] as $to) { |
|
| 2023 | + $names[] = $to['name']; |
|
| 2024 | + } |
|
| 1945 | 2025 | $context['to_value'] = empty($names) ? '' : '"' . implode('", "', $names) . '"'; |
| 2026 | + } else { |
|
| 2027 | + $context['to_value'] = ''; |
|
| 1946 | 2028 | } |
| 1947 | - else |
|
| 1948 | - $context['to_value'] = ''; |
|
| 1949 | 2029 | |
| 1950 | 2030 | // Set the defaults... |
| 1951 | 2031 | $context['subject'] = $form_subject; |
@@ -2015,8 +2095,9 @@ discard block |
||
| 2015 | 2095 | |
| 2016 | 2096 | // validate with loadMemberData() |
| 2017 | 2097 | $memberResult = loadMemberData($user_info['id'], false); |
| 2018 | - if (!$memberResult) |
|
| 2019 | - fatal_lang_error('not_a_user', false); |
|
| 2098 | + if (!$memberResult) { |
|
| 2099 | + fatal_lang_error('not_a_user', false); |
|
| 2100 | + } |
|
| 2020 | 2101 | list ($memID) = $memberResult; |
| 2021 | 2102 | |
| 2022 | 2103 | // drafts is where the functions reside |
@@ -2042,9 +2123,9 @@ discard block |
||
| 2042 | 2123 | $context['sub_template'] = 'send'; |
| 2043 | 2124 | loadJavaScriptFile('PersonalMessage.js', array('defer' => false), 'smf_pms'); |
| 2044 | 2125 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 2126 | + } else { |
|
| 2127 | + $context['sub_template'] = 'pm'; |
|
| 2045 | 2128 | } |
| 2046 | - else |
|
| 2047 | - $context['sub_template'] = 'pm'; |
|
| 2048 | 2129 | |
| 2049 | 2130 | $context['page_title'] = $txt['send_message']; |
| 2050 | 2131 | |
@@ -2105,10 +2186,11 @@ discard block |
||
| 2105 | 2186 | ); |
| 2106 | 2187 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2107 | 2188 | { |
| 2108 | - if (!isset($_REQUEST['xml'])) |
|
| 2109 | - fatal_lang_error('pm_not_yours', false); |
|
| 2110 | - else |
|
| 2111 | - $error_types[] = 'pm_not_yours'; |
|
| 2189 | + if (!isset($_REQUEST['xml'])) { |
|
| 2190 | + fatal_lang_error('pm_not_yours', false); |
|
| 2191 | + } else { |
|
| 2192 | + $error_types[] = 'pm_not_yours'; |
|
| 2193 | + } |
|
| 2112 | 2194 | } |
| 2113 | 2195 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 2114 | 2196 | $smcFunc['db_free_result']($request); |
@@ -2155,14 +2237,16 @@ discard block |
||
| 2155 | 2237 | $context['post_error'][$error_type] = true; |
| 2156 | 2238 | if (isset($txt['error_' . $error_type])) |
| 2157 | 2239 | { |
| 2158 | - if ($error_type == 'long_message') |
|
| 2159 | - $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2240 | + if ($error_type == 'long_message') { |
|
| 2241 | + $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2242 | + } |
|
| 2160 | 2243 | $context['post_error']['messages'][] = $txt['error_' . $error_type]; |
| 2161 | 2244 | } |
| 2162 | 2245 | |
| 2163 | 2246 | // If it's not a minor error flag it as such. |
| 2164 | - if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) |
|
| 2165 | - $context['error_type'] = 'serious'; |
|
| 2247 | + if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) { |
|
| 2248 | + $context['error_type'] = 'serious'; |
|
| 2249 | + } |
|
| 2166 | 2250 | } |
| 2167 | 2251 | |
| 2168 | 2252 | // We need to load the editor once more. |
@@ -2220,8 +2304,9 @@ discard block |
||
| 2220 | 2304 | require_once($sourcedir . '/Subs-Auth.php'); |
| 2221 | 2305 | |
| 2222 | 2306 | // PM Drafts enabled and needed? |
| 2223 | - if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) |
|
| 2224 | - require_once($sourcedir . '/Drafts.php'); |
|
| 2307 | + if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) { |
|
| 2308 | + require_once($sourcedir . '/Drafts.php'); |
|
| 2309 | + } |
|
| 2225 | 2310 | |
| 2226 | 2311 | loadLanguage('PersonalMessage', '', false); |
| 2227 | 2312 | |
@@ -2251,24 +2336,27 @@ discard block |
||
| 2251 | 2336 | |
| 2252 | 2337 | if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
| 2253 | 2338 | { |
| 2254 | - if (!isset($_REQUEST['xml'])) |
|
| 2255 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2256 | - else |
|
| 2257 | - $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2339 | + if (!isset($_REQUEST['xml'])) { |
|
| 2340 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2341 | + } else { |
|
| 2342 | + $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2343 | + } |
|
| 2258 | 2344 | } |
| 2259 | 2345 | } |
| 2260 | 2346 | |
| 2261 | 2347 | // If your session timed out, show an error, but do allow to re-submit. |
| 2262 | - if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') |
|
| 2263 | - $post_errors[] = 'session_timeout'; |
|
| 2348 | + if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') { |
|
| 2349 | + $post_errors[] = 'session_timeout'; |
|
| 2350 | + } |
|
| 2264 | 2351 | |
| 2265 | 2352 | $_REQUEST['subject'] = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : ''; |
| 2266 | 2353 | $_REQUEST['to'] = empty($_POST['to']) ? (empty($_GET['to']) ? '' : $_GET['to']) : $_POST['to']; |
| 2267 | 2354 | $_REQUEST['bcc'] = empty($_POST['bcc']) ? (empty($_GET['bcc']) ? '' : $_GET['bcc']) : $_POST['bcc']; |
| 2268 | 2355 | |
| 2269 | 2356 | // Route the input from the 'u' parameter to the 'to'-list. |
| 2270 | - if (!empty($_POST['u'])) |
|
| 2271 | - $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2357 | + if (!empty($_POST['u'])) { |
|
| 2358 | + $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2359 | + } |
|
| 2272 | 2360 | |
| 2273 | 2361 | // Construct the list of recipients. |
| 2274 | 2362 | $recipientList = array(); |
@@ -2280,8 +2368,9 @@ discard block |
||
| 2280 | 2368 | $recipientList[$recipientType] = array(); |
| 2281 | 2369 | if (!empty($_POST['recipient_' . $recipientType]) && is_array($_POST['recipient_' . $recipientType])) |
| 2282 | 2370 | { |
| 2283 | - foreach ($_POST['recipient_' . $recipientType] as $recipient) |
|
| 2284 | - $recipientList[$recipientType][] = (int) $recipient; |
|
| 2371 | + foreach ($_POST['recipient_' . $recipientType] as $recipient) { |
|
| 2372 | + $recipientList[$recipientType][] = (int) $recipient; |
|
| 2373 | + } |
|
| 2285 | 2374 | } |
| 2286 | 2375 | |
| 2287 | 2376 | // Are there also literal names set? |
@@ -2295,10 +2384,11 @@ discard block |
||
| 2295 | 2384 | |
| 2296 | 2385 | foreach ($namedRecipientList[$recipientType] as $index => $recipient) |
| 2297 | 2386 | { |
| 2298 | - if (strlen(trim($recipient)) > 0) |
|
| 2299 | - $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2300 | - else |
|
| 2301 | - unset($namedRecipientList[$recipientType][$index]); |
|
| 2387 | + if (strlen(trim($recipient)) > 0) { |
|
| 2388 | + $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2389 | + } else { |
|
| 2390 | + unset($namedRecipientList[$recipientType][$index]); |
|
| 2391 | + } |
|
| 2302 | 2392 | } |
| 2303 | 2393 | |
| 2304 | 2394 | if (!empty($namedRecipientList[$recipientType])) |
@@ -2328,8 +2418,9 @@ discard block |
||
| 2328 | 2418 | } |
| 2329 | 2419 | |
| 2330 | 2420 | // Selected a recipient to be deleted? Remove them now. |
| 2331 | - if (!empty($_POST['delete_recipient'])) |
|
| 2332 | - $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2421 | + if (!empty($_POST['delete_recipient'])) { |
|
| 2422 | + $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2423 | + } |
|
| 2333 | 2424 | |
| 2334 | 2425 | // Make sure we don't include the same name twice |
| 2335 | 2426 | $recipientList[$recipientType] = array_unique($recipientList[$recipientType]); |
@@ -2339,8 +2430,9 @@ discard block |
||
| 2339 | 2430 | $is_recipient_change = !empty($_POST['delete_recipient']) || !empty($_POST['to_submit']) || !empty($_POST['bcc_submit']); |
| 2340 | 2431 | |
| 2341 | 2432 | // Check if there's at least one recipient. |
| 2342 | - if (empty($recipientList['to']) && empty($recipientList['bcc'])) |
|
| 2343 | - $post_errors[] = 'no_to'; |
|
| 2433 | + if (empty($recipientList['to']) && empty($recipientList['bcc'])) { |
|
| 2434 | + $post_errors[] = 'no_to'; |
|
| 2435 | + } |
|
| 2344 | 2436 | |
| 2345 | 2437 | // Make sure that we remove the members who did get it from the screen. |
| 2346 | 2438 | if (!$is_recipient_change) |
@@ -2354,28 +2446,31 @@ discard block |
||
| 2354 | 2446 | // Since we already have a post error, remove the previous one. |
| 2355 | 2447 | $post_errors = array_diff($post_errors, array('no_to')); |
| 2356 | 2448 | |
| 2357 | - foreach ($namesNotFound[$recipientType] as $name) |
|
| 2358 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2449 | + foreach ($namesNotFound[$recipientType] as $name) { |
|
| 2450 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2451 | + } |
|
| 2359 | 2452 | } |
| 2360 | 2453 | } |
| 2361 | 2454 | } |
| 2362 | 2455 | |
| 2363 | 2456 | // Did they make any mistakes? |
| 2364 | - if ($_REQUEST['subject'] == '') |
|
| 2365 | - $post_errors[] = 'no_subject'; |
|
| 2366 | - if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') |
|
| 2367 | - $post_errors[] = 'no_message'; |
|
| 2368 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) |
|
| 2369 | - $post_errors[] = 'long_message'; |
|
| 2370 | - else |
|
| 2457 | + if ($_REQUEST['subject'] == '') { |
|
| 2458 | + $post_errors[] = 'no_subject'; |
|
| 2459 | + } |
|
| 2460 | + if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') { |
|
| 2461 | + $post_errors[] = 'no_message'; |
|
| 2462 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) { |
|
| 2463 | + $post_errors[] = 'long_message'; |
|
| 2464 | + } else |
|
| 2371 | 2465 | { |
| 2372 | 2466 | // Preparse the message. |
| 2373 | 2467 | $message = $_REQUEST['message']; |
| 2374 | 2468 | preparsecode($message); |
| 2375 | 2469 | |
| 2376 | 2470 | // Make sure there's still some content left without the tags. |
| 2377 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) |
|
| 2378 | - $post_errors[] = 'no_message'; |
|
| 2471 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) { |
|
| 2472 | + $post_errors[] = 'no_message'; |
|
| 2473 | + } |
|
| 2379 | 2474 | } |
| 2380 | 2475 | |
| 2381 | 2476 | // Wrong verification code? |
@@ -2387,13 +2482,15 @@ discard block |
||
| 2387 | 2482 | ); |
| 2388 | 2483 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 2389 | 2484 | |
| 2390 | - if (is_array($context['require_verification'])) |
|
| 2391 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2485 | + if (is_array($context['require_verification'])) { |
|
| 2486 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2487 | + } |
|
| 2392 | 2488 | } |
| 2393 | 2489 | |
| 2394 | 2490 | // If they did, give a chance to make ammends. |
| 2395 | - if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) |
|
| 2396 | - return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2491 | + if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) { |
|
| 2492 | + return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2493 | + } |
|
| 2397 | 2494 | |
| 2398 | 2495 | // Want to take a second glance before you send? |
| 2399 | 2496 | if (isset($_REQUEST['preview'])) |
@@ -2424,8 +2521,9 @@ discard block |
||
| 2424 | 2521 | foreach ($namesNotFound as $recipientType => $names) |
| 2425 | 2522 | { |
| 2426 | 2523 | $post_errors[] = 'bad_' . $recipientType; |
| 2427 | - foreach ($names as $name) |
|
| 2428 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2524 | + foreach ($names as $name) { |
|
| 2525 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2526 | + } |
|
| 2429 | 2527 | } |
| 2430 | 2528 | |
| 2431 | 2529 | return messagePostError(array(), $namedRecipientList, $recipientList); |
@@ -2455,13 +2553,14 @@ discard block |
||
| 2455 | 2553 | checkSubmitOnce('check'); |
| 2456 | 2554 | |
| 2457 | 2555 | // Do the actual sending of the PM. |
| 2458 | - if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) |
|
| 2459 | - $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2460 | - else |
|
| 2461 | - $context['send_log'] = array( |
|
| 2556 | + if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) { |
|
| 2557 | + $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2558 | + } else { |
|
| 2559 | + $context['send_log'] = array( |
|
| 2462 | 2560 | 'sent' => array(), |
| 2463 | 2561 | 'failed' => array() |
| 2464 | 2562 | ); |
| 2563 | + } |
|
| 2465 | 2564 | |
| 2466 | 2565 | // Mark the message as "replied to". |
| 2467 | 2566 | if (!empty($context['send_log']['sent']) && !empty($_REQUEST['replied_to']) && isset($_REQUEST['f']) && $_REQUEST['f'] == 'inbox') |
@@ -2479,11 +2578,12 @@ discard block |
||
| 2479 | 2578 | } |
| 2480 | 2579 | |
| 2481 | 2580 | // If one or more of the recipient were invalid, go back to the post screen with the failed usernames. |
| 2482 | - if (!empty($context['send_log']['failed'])) |
|
| 2483 | - return messagePostError($post_errors, $namesNotFound, array( |
|
| 2581 | + if (!empty($context['send_log']['failed'])) { |
|
| 2582 | + return messagePostError($post_errors, $namesNotFound, array( |
|
| 2484 | 2583 | 'to' => array_intersect($recipientList['to'], $context['send_log']['failed']), |
| 2485 | 2584 | 'bcc' => array_intersect($recipientList['bcc'], $context['send_log']['failed']) |
| 2486 | 2585 | )); |
| 2586 | + } |
|
| 2487 | 2587 | |
| 2488 | 2588 | // Message sent successfully? |
| 2489 | 2589 | if (!empty($context['send_log']) && empty($context['send_log']['failed'])) |
@@ -2491,8 +2591,9 @@ discard block |
||
| 2491 | 2591 | $context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent'; |
| 2492 | 2592 | |
| 2493 | 2593 | // If we had a PM draft for this one, then its time to remove it since it was just sent |
| 2494 | - if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) |
|
| 2495 | - DeleteDraft($_POST['id_pm_draft']); |
|
| 2594 | + if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) { |
|
| 2595 | + DeleteDraft($_POST['id_pm_draft']); |
|
| 2596 | + } |
|
| 2496 | 2597 | } |
| 2497 | 2598 | |
| 2498 | 2599 | // Go back to the where they sent from, if possible... |
@@ -2507,24 +2608,28 @@ discard block |
||
| 2507 | 2608 | |
| 2508 | 2609 | checkSession('request'); |
| 2509 | 2610 | |
| 2510 | - if (isset($_REQUEST['del_selected'])) |
|
| 2511 | - $_REQUEST['pm_action'] = 'delete'; |
|
| 2611 | + if (isset($_REQUEST['del_selected'])) { |
|
| 2612 | + $_REQUEST['pm_action'] = 'delete'; |
|
| 2613 | + } |
|
| 2512 | 2614 | |
| 2513 | 2615 | if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms'])) |
| 2514 | 2616 | { |
| 2515 | - foreach ($_REQUEST['pms'] as $pm) |
|
| 2516 | - $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2617 | + foreach ($_REQUEST['pms'] as $pm) { |
|
| 2618 | + $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2619 | + } |
|
| 2517 | 2620 | } |
| 2518 | 2621 | |
| 2519 | - if (empty($_REQUEST['pm_actions'])) |
|
| 2520 | - redirectexit($context['current_label_redirect']); |
|
| 2622 | + if (empty($_REQUEST['pm_actions'])) { |
|
| 2623 | + redirectexit($context['current_label_redirect']); |
|
| 2624 | + } |
|
| 2521 | 2625 | |
| 2522 | 2626 | // If we are in conversation, we may need to apply this to every message in the conversation. |
| 2523 | 2627 | if ($context['display_mode'] == 2 && isset($_REQUEST['conversation'])) |
| 2524 | 2628 | { |
| 2525 | 2629 | $id_pms = array(); |
| 2526 | - foreach ($_REQUEST['pm_actions'] as $pm => $dummy) |
|
| 2527 | - $id_pms[] = (int) $pm; |
|
| 2630 | + foreach ($_REQUEST['pm_actions'] as $pm => $dummy) { |
|
| 2631 | + $id_pms[] = (int) $pm; |
|
| 2632 | + } |
|
| 2528 | 2633 | |
| 2529 | 2634 | $request = $smcFunc['db_query']('', ' |
| 2530 | 2635 | SELECT id_pm_head, id_pm |
@@ -2535,8 +2640,9 @@ discard block |
||
| 2535 | 2640 | ) |
| 2536 | 2641 | ); |
| 2537 | 2642 | $pm_heads = array(); |
| 2538 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2539 | - $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2643 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2644 | + $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2645 | + } |
|
| 2540 | 2646 | $smcFunc['db_free_result']($request); |
| 2541 | 2647 | |
| 2542 | 2648 | $request = $smcFunc['db_query']('', ' |
@@ -2550,8 +2656,9 @@ discard block |
||
| 2550 | 2656 | // Copy the action from the single to PM to the others. |
| 2551 | 2657 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2552 | 2658 | { |
| 2553 | - if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) |
|
| 2554 | - $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2659 | + if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) { |
|
| 2660 | + $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2661 | + } |
|
| 2555 | 2662 | } |
| 2556 | 2663 | $smcFunc['db_free_result']($request); |
| 2557 | 2664 | } |
@@ -2562,22 +2669,21 @@ discard block |
||
| 2562 | 2669 | $labels = array(); |
| 2563 | 2670 | foreach ($_REQUEST['pm_actions'] as $pm => $action) |
| 2564 | 2671 | { |
| 2565 | - if ($action === 'delete') |
|
| 2566 | - $to_delete[] = (int) $pm; |
|
| 2567 | - else |
|
| 2672 | + if ($action === 'delete') { |
|
| 2673 | + $to_delete[] = (int) $pm; |
|
| 2674 | + } else |
|
| 2568 | 2675 | { |
| 2569 | 2676 | if (substr($action, 0, 4) == 'add_') |
| 2570 | 2677 | { |
| 2571 | 2678 | $type = 'add'; |
| 2572 | 2679 | $action = substr($action, 4); |
| 2573 | - } |
|
| 2574 | - elseif (substr($action, 0, 4) == 'rem_') |
|
| 2680 | + } elseif (substr($action, 0, 4) == 'rem_') |
|
| 2575 | 2681 | { |
| 2576 | 2682 | $type = 'rem'; |
| 2577 | 2683 | $action = substr($action, 4); |
| 2684 | + } else { |
|
| 2685 | + $type = 'unk'; |
|
| 2578 | 2686 | } |
| 2579 | - else |
|
| 2580 | - $type = 'unk'; |
|
| 2581 | 2687 | |
| 2582 | 2688 | if ($action == '-1' || (int) $action > 0) |
| 2583 | 2689 | { |
@@ -2588,8 +2694,9 @@ discard block |
||
| 2588 | 2694 | } |
| 2589 | 2695 | |
| 2590 | 2696 | // Deleting, it looks like? |
| 2591 | - if (!empty($to_delete)) |
|
| 2592 | - deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2697 | + if (!empty($to_delete)) { |
|
| 2698 | + deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2699 | + } |
|
| 2593 | 2700 | |
| 2594 | 2701 | // Are we labeling anything? |
| 2595 | 2702 | if (!empty($to_label) && $context['folder'] == 'inbox') |
@@ -2655,8 +2762,7 @@ discard block |
||
| 2655 | 2762 | } |
| 2656 | 2763 | |
| 2657 | 2764 | $smcFunc['db_free_result']($request2); |
| 2658 | - } |
|
| 2659 | - elseif ($type == 'rem') |
|
| 2765 | + } elseif ($type == 'rem') |
|
| 2660 | 2766 | { |
| 2661 | 2767 | // If we're removing from the inbox, see if we have at least one other label. |
| 2662 | 2768 | // This query is faster than the one above |
@@ -2688,21 +2794,25 @@ discard block |
||
| 2688 | 2794 | if ($to_label[$row['id_pm']] != '-1') |
| 2689 | 2795 | { |
| 2690 | 2796 | // If this label is in the list and we're not adding it, remove it |
| 2691 | - if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') |
|
| 2692 | - unset($labels[$to_label[$row['id_pm']]]); |
|
| 2693 | - else if ($type !== 'rem') |
|
| 2694 | - $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2797 | + if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') { |
|
| 2798 | + unset($labels[$to_label[$row['id_pm']]]); |
|
| 2799 | + } else if ($type !== 'rem') { |
|
| 2800 | + $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2801 | + } |
|
| 2695 | 2802 | } |
| 2696 | 2803 | |
| 2697 | 2804 | // Removing all labels or just removing the inbox label |
| 2698 | - if ($type == 'rem' && empty($labels)) |
|
| 2699 | - $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2805 | + if ($type == 'rem' && empty($labels)) { |
|
| 2806 | + $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2807 | + } |
|
| 2700 | 2808 | // Adding new labels, but removing inbox and applying new ones |
| 2701 | - elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) |
|
| 2702 | - $in_inbox = 0; |
|
| 2809 | + elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) { |
|
| 2810 | + $in_inbox = 0; |
|
| 2811 | + } |
|
| 2703 | 2812 | // Just adding it to the inbox |
| 2704 | - else |
|
| 2705 | - $in_inbox = 1; |
|
| 2813 | + else { |
|
| 2814 | + $in_inbox = 1; |
|
| 2815 | + } |
|
| 2706 | 2816 | |
| 2707 | 2817 | // Are we adding it to or removing it from the inbox? |
| 2708 | 2818 | if ($in_inbox != $row['in_inbox']) |
@@ -2744,8 +2854,9 @@ discard block |
||
| 2744 | 2854 | if (!empty($labels_to_apply)) |
| 2745 | 2855 | { |
| 2746 | 2856 | $inserts = array(); |
| 2747 | - foreach ($labels_to_apply as $label) |
|
| 2748 | - $inserts[] = array($row['id_pm'], $label); |
|
| 2857 | + foreach ($labels_to_apply as $label) { |
|
| 2858 | + $inserts[] = array($row['id_pm'], $label); |
|
| 2859 | + } |
|
| 2749 | 2860 | |
| 2750 | 2861 | $smcFunc['db_insert']('', |
| 2751 | 2862 | '{db_prefix}pm_labeled_messages', |
@@ -2789,11 +2900,13 @@ discard block |
||
| 2789 | 2900 | checkSession('get'); |
| 2790 | 2901 | |
| 2791 | 2902 | // If all then delete all messages the user has. |
| 2792 | - if ($_REQUEST['f'] == 'all') |
|
| 2793 | - deleteMessages(null, null); |
|
| 2903 | + if ($_REQUEST['f'] == 'all') { |
|
| 2904 | + deleteMessages(null, null); |
|
| 2905 | + } |
|
| 2794 | 2906 | // Otherwise just the selected folder. |
| 2795 | - else |
|
| 2796 | - deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2907 | + else { |
|
| 2908 | + deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2909 | + } |
|
| 2797 | 2910 | |
| 2798 | 2911 | // Done... all gone. |
| 2799 | 2912 | redirectexit($context['current_label_redirect']); |
@@ -2830,8 +2943,9 @@ discard block |
||
| 2830 | 2943 | 'msgtime' => $deleteTime, |
| 2831 | 2944 | ) |
| 2832 | 2945 | ); |
| 2833 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 2834 | - $toDelete[] = $row[0]; |
|
| 2946 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 2947 | + $toDelete[] = $row[0]; |
|
| 2948 | + } |
|
| 2835 | 2949 | $smcFunc['db_free_result']($request); |
| 2836 | 2950 | |
| 2837 | 2951 | // Select all messages in their inbox older than $deleteTime. |
@@ -2848,8 +2962,9 @@ discard block |
||
| 2848 | 2962 | 'msgtime' => $deleteTime, |
| 2849 | 2963 | ) |
| 2850 | 2964 | ); |
| 2851 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2852 | - $toDelete[] = $row['id_pm']; |
|
| 2965 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2966 | + $toDelete[] = $row['id_pm']; |
|
| 2967 | + } |
|
| 2853 | 2968 | $smcFunc['db_free_result']($request); |
| 2854 | 2969 | |
| 2855 | 2970 | // Delete the actual messages. |
@@ -2880,26 +2995,29 @@ discard block |
||
| 2880 | 2995 | { |
| 2881 | 2996 | global $user_info, $smcFunc; |
| 2882 | 2997 | |
| 2883 | - if ($owner === null) |
|
| 2884 | - $owner = array($user_info['id']); |
|
| 2885 | - elseif (empty($owner)) |
|
| 2886 | - return; |
|
| 2887 | - elseif (!is_array($owner)) |
|
| 2888 | - $owner = array($owner); |
|
| 2998 | + if ($owner === null) { |
|
| 2999 | + $owner = array($user_info['id']); |
|
| 3000 | + } elseif (empty($owner)) { |
|
| 3001 | + return; |
|
| 3002 | + } elseif (!is_array($owner)) { |
|
| 3003 | + $owner = array($owner); |
|
| 3004 | + } |
|
| 2889 | 3005 | |
| 2890 | 3006 | if ($personal_messages !== null) |
| 2891 | 3007 | { |
| 2892 | - if (empty($personal_messages) || !is_array($personal_messages)) |
|
| 2893 | - return; |
|
| 3008 | + if (empty($personal_messages) || !is_array($personal_messages)) { |
|
| 3009 | + return; |
|
| 3010 | + } |
|
| 2894 | 3011 | |
| 2895 | - foreach ($personal_messages as $index => $delete_id) |
|
| 2896 | - $personal_messages[$index] = (int) $delete_id; |
|
| 3012 | + foreach ($personal_messages as $index => $delete_id) { |
|
| 3013 | + $personal_messages[$index] = (int) $delete_id; |
|
| 3014 | + } |
|
| 2897 | 3015 | |
| 2898 | 3016 | $where = ' |
| 2899 | 3017 | AND id_pm IN ({array_int:pm_list})'; |
| 3018 | + } else { |
|
| 3019 | + $where = ''; |
|
| 2900 | 3020 | } |
| 2901 | - else |
|
| 2902 | - $where = ''; |
|
| 2903 | 3021 | |
| 2904 | 3022 | if ($folder == 'sent' || $folder === null) |
| 2905 | 3023 | { |
@@ -2934,17 +3052,19 @@ discard block |
||
| 2934 | 3052 | // ...And update the statistics accordingly - now including unread messages!. |
| 2935 | 3053 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2936 | 3054 | { |
| 2937 | - if ($row['is_read']) |
|
| 2938 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 2939 | - else |
|
| 2940 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
| 3055 | + if ($row['is_read']) { |
|
| 3056 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 3057 | + } else { |
|
| 3058 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
| 3059 | + } |
|
| 2941 | 3060 | |
| 2942 | 3061 | // If this is the current member we need to make their message count correct. |
| 2943 | 3062 | if ($user_info['id'] == $row['id_member']) |
| 2944 | 3063 | { |
| 2945 | 3064 | $user_info['messages'] -= $row['num_deleted_messages']; |
| 2946 | - if (!($row['is_read'])) |
|
| 2947 | - $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3065 | + if (!($row['is_read'])) { |
|
| 3066 | + $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3067 | + } |
|
| 2948 | 3068 | } |
| 2949 | 3069 | } |
| 2950 | 3070 | $smcFunc['db_free_result']($request); |
@@ -3012,8 +3132,9 @@ discard block |
||
| 3012 | 3132 | ) |
| 3013 | 3133 | ); |
| 3014 | 3134 | $remove_pms = array(); |
| 3015 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3016 | - $remove_pms[] = $row['sender']; |
|
| 3135 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3136 | + $remove_pms[] = $row['sender']; |
|
| 3137 | + } |
|
| 3017 | 3138 | $smcFunc['db_free_result']($request); |
| 3018 | 3139 | |
| 3019 | 3140 | if (!empty($remove_pms)) |
@@ -3058,8 +3179,9 @@ discard block |
||
| 3058 | 3179 | { |
| 3059 | 3180 | global $user_info, $context, $smcFunc; |
| 3060 | 3181 | |
| 3061 | - if ($owner === null) |
|
| 3062 | - $owner = $user_info['id']; |
|
| 3182 | + if ($owner === null) { |
|
| 3183 | + $owner = $user_info['id']; |
|
| 3184 | + } |
|
| 3063 | 3185 | |
| 3064 | 3186 | $in_inbox = ''; |
| 3065 | 3187 | |
@@ -3083,8 +3205,7 @@ discard block |
||
| 3083 | 3205 | } |
| 3084 | 3206 | |
| 3085 | 3207 | $smcFunc['db_free_result']($get_messages); |
| 3086 | - } |
|
| 3087 | - elseif ($label = '-1') |
|
| 3208 | + } elseif ($label = '-1') |
|
| 3088 | 3209 | { |
| 3089 | 3210 | // Marking all PMs in your inbox read |
| 3090 | 3211 | $in_inbox = ' |
@@ -3109,8 +3230,9 @@ discard block |
||
| 3109 | 3230 | { |
| 3110 | 3231 | if ($owner == $user_info['id']) |
| 3111 | 3232 | { |
| 3112 | - foreach ($context['labels'] as $label) |
|
| 3113 | - $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3233 | + foreach ($context['labels'] as $label) { |
|
| 3234 | + $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3235 | + } |
|
| 3114 | 3236 | } |
| 3115 | 3237 | |
| 3116 | 3238 | $result = $smcFunc['db_query']('', ' |
@@ -3130,8 +3252,9 @@ discard block |
||
| 3130 | 3252 | { |
| 3131 | 3253 | $total_unread += $row['num']; |
| 3132 | 3254 | |
| 3133 | - if ($owner != $user_info['id'] || empty($row['id_pm'])) |
|
| 3134 | - continue; |
|
| 3255 | + if ($owner != $user_info['id'] || empty($row['id_pm'])) { |
|
| 3256 | + continue; |
|
| 3257 | + } |
|
| 3135 | 3258 | |
| 3136 | 3259 | $this_labels = array(); |
| 3137 | 3260 | |
@@ -3155,11 +3278,13 @@ discard block |
||
| 3155 | 3278 | |
| 3156 | 3279 | $smcFunc['db_free_result']($result2); |
| 3157 | 3280 | |
| 3158 | - foreach ($this_labels as $this_label) |
|
| 3159 | - $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3281 | + foreach ($this_labels as $this_label) { |
|
| 3282 | + $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3283 | + } |
|
| 3160 | 3284 | |
| 3161 | - if ($row['in_inbox'] == 1) |
|
| 3162 | - $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3285 | + if ($row['in_inbox'] == 1) { |
|
| 3286 | + $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3287 | + } |
|
| 3163 | 3288 | } |
| 3164 | 3289 | $smcFunc['db_free_result']($result); |
| 3165 | 3290 | |
@@ -3168,8 +3293,9 @@ discard block |
||
| 3168 | 3293 | updateMemberData($owner, array('unread_messages' => $total_unread)); |
| 3169 | 3294 | |
| 3170 | 3295 | // If it was for the current member, reflect this in the $user_info array too. |
| 3171 | - if ($owner == $user_info['id']) |
|
| 3172 | - $user_info['unread_messages'] = $total_unread; |
|
| 3296 | + if ($owner == $user_info['id']) { |
|
| 3297 | + $user_info['unread_messages'] = $total_unread; |
|
| 3298 | + } |
|
| 3173 | 3299 | } |
| 3174 | 3300 | } |
| 3175 | 3301 | |
@@ -3197,8 +3323,9 @@ discard block |
||
| 3197 | 3323 | // Add all existing labels to the array to save, slashing them as necessary... |
| 3198 | 3324 | foreach ($context['labels'] as $label) |
| 3199 | 3325 | { |
| 3200 | - if ($label['id'] != -1) |
|
| 3201 | - $the_labels[$label['id']] = $label['name']; |
|
| 3326 | + if ($label['id'] != -1) { |
|
| 3327 | + $the_labels[$label['id']] = $label['name']; |
|
| 3328 | + } |
|
| 3202 | 3329 | } |
| 3203 | 3330 | |
| 3204 | 3331 | if (isset($_POST[$context['session_var']])) |
@@ -3217,8 +3344,9 @@ discard block |
||
| 3217 | 3344 | { |
| 3218 | 3345 | $_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => ',')); |
| 3219 | 3346 | |
| 3220 | - if ($smcFunc['strlen']($_POST['label']) > 30) |
|
| 3221 | - $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3347 | + if ($smcFunc['strlen']($_POST['label']) > 30) { |
|
| 3348 | + $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3349 | + } |
|
| 3222 | 3350 | if ($_POST['label'] != '') |
| 3223 | 3351 | { |
| 3224 | 3352 | $the_labels[] = $_POST['label']; |
@@ -3239,24 +3367,25 @@ discard block |
||
| 3239 | 3367 | { |
| 3240 | 3368 | foreach ($the_labels as $id => $name) |
| 3241 | 3369 | { |
| 3242 | - if ($id == -1) |
|
| 3243 | - continue; |
|
| 3244 | - elseif (isset($_POST['label_name'][$id])) |
|
| 3370 | + if ($id == -1) { |
|
| 3371 | + continue; |
|
| 3372 | + } elseif (isset($_POST['label_name'][$id])) |
|
| 3245 | 3373 | { |
| 3246 | 3374 | $_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => ','))); |
| 3247 | 3375 | |
| 3248 | - if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) |
|
| 3249 | - $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3376 | + if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) { |
|
| 3377 | + $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3378 | + } |
|
| 3250 | 3379 | if ($_POST['label_name'][$id] != '') |
| 3251 | 3380 | { |
| 3252 | 3381 | // Changing the name of this label? |
| 3253 | - if ($the_labels[$id] != $_POST['label_name'][$id]) |
|
| 3254 | - $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3382 | + if ($the_labels[$id] != $_POST['label_name'][$id]) { |
|
| 3383 | + $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3384 | + } |
|
| 3255 | 3385 | |
| 3256 | 3386 | $the_labels[(int) $id] = $_POST['label_name'][$id]; |
| 3257 | 3387 | |
| 3258 | - } |
|
| 3259 | - else |
|
| 3388 | + } else |
|
| 3260 | 3389 | { |
| 3261 | 3390 | unset($the_labels[(int) $id]); |
| 3262 | 3391 | $labels_to_remove[] = $id; |
@@ -3270,8 +3399,9 @@ discard block |
||
| 3270 | 3399 | if (!empty($labels_to_add)) |
| 3271 | 3400 | { |
| 3272 | 3401 | $inserts = array(); |
| 3273 | - foreach ($labels_to_add AS $label) |
|
| 3274 | - $inserts[] = array($user_info['id'], $label); |
|
| 3402 | + foreach ($labels_to_add AS $label) { |
|
| 3403 | + $inserts[] = array($user_info['id'], $label); |
|
| 3404 | + } |
|
| 3275 | 3405 | |
| 3276 | 3406 | $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array()); |
| 3277 | 3407 | } |
@@ -3361,8 +3491,9 @@ discard block |
||
| 3361 | 3491 | // Each action... |
| 3362 | 3492 | foreach ($rule['actions'] as $k2 => $action) |
| 3363 | 3493 | { |
| 3364 | - if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) |
|
| 3365 | - continue; |
|
| 3494 | + if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) { |
|
| 3495 | + continue; |
|
| 3496 | + } |
|
| 3366 | 3497 | |
| 3367 | 3498 | $rule_changes[] = $rule['id']; |
| 3368 | 3499 | |
@@ -3377,8 +3508,8 @@ discard block |
||
| 3377 | 3508 | { |
| 3378 | 3509 | $rule_changes = array_unique($rule_changes); |
| 3379 | 3510 | // Update/delete as appropriate. |
| 3380 | - foreach ($rule_changes as $k => $id) |
|
| 3381 | - if (!empty($context['rules'][$id]['actions'])) |
|
| 3511 | + foreach ($rule_changes as $k => $id) { |
|
| 3512 | + if (!empty($context['rules'][$id]['actions'])) |
|
| 3382 | 3513 | { |
| 3383 | 3514 | $smcFunc['db_query']('', ' |
| 3384 | 3515 | UPDATE {db_prefix}pm_rules |
@@ -3391,12 +3522,13 @@ discard block |
||
| 3391 | 3522 | 'actions' => $smcFunc['json_encode']($context['rules'][$id]['actions']), |
| 3392 | 3523 | ) |
| 3393 | 3524 | ); |
| 3525 | + } |
|
| 3394 | 3526 | unset($rule_changes[$k]); |
| 3395 | 3527 | } |
| 3396 | 3528 | |
| 3397 | 3529 | // Anything left here means it's lost all actions... |
| 3398 | - if (!empty($rule_changes)) |
|
| 3399 | - $smcFunc['db_query']('', ' |
|
| 3530 | + if (!empty($rule_changes)) { |
|
| 3531 | + $smcFunc['db_query']('', ' |
|
| 3400 | 3532 | DELETE FROM {db_prefix}pm_rules |
| 3401 | 3533 | WHERE id_rule IN ({array_int:rule_list}) |
| 3402 | 3534 | AND id_member = {int:current_member}', |
@@ -3405,6 +3537,7 @@ discard block |
||
| 3405 | 3537 | 'rule_list' => $rule_changes, |
| 3406 | 3538 | ) |
| 3407 | 3539 | ); |
| 3540 | + } |
|
| 3408 | 3541 | } |
| 3409 | 3542 | |
| 3410 | 3543 | // Make sure we're not caching this! |
@@ -3474,8 +3607,9 @@ discard block |
||
| 3474 | 3607 | // Save the fields. |
| 3475 | 3608 | saveProfileFields(); |
| 3476 | 3609 | |
| 3477 | - if (!empty($profile_vars)) |
|
| 3478 | - updateMemberData($user_info['id'], $profile_vars); |
|
| 3610 | + if (!empty($profile_vars)) { |
|
| 3611 | + updateMemberData($user_info['id'], $profile_vars); |
|
| 3612 | + } |
|
| 3479 | 3613 | } |
| 3480 | 3614 | |
| 3481 | 3615 | setupProfileContext( |
@@ -3500,13 +3634,15 @@ discard block |
||
| 3500 | 3634 | global $user_info, $language, $modSettings, $smcFunc; |
| 3501 | 3635 | |
| 3502 | 3636 | // Check that this feature is even enabled! |
| 3503 | - if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) |
|
| 3504 | - fatal_lang_error('no_access', false); |
|
| 3637 | + if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) { |
|
| 3638 | + fatal_lang_error('no_access', false); |
|
| 3639 | + } |
|
| 3505 | 3640 | |
| 3506 | 3641 | $pmsg = (int) $_REQUEST['pmsg']; |
| 3507 | 3642 | |
| 3508 | - if (!isAccessiblePM($pmsg, 'inbox')) |
|
| 3509 | - fatal_lang_error('no_access', false); |
|
| 3643 | + if (!isAccessiblePM($pmsg, 'inbox')) { |
|
| 3644 | + fatal_lang_error('no_access', false); |
|
| 3645 | + } |
|
| 3510 | 3646 | |
| 3511 | 3647 | $context['pm_id'] = $pmsg; |
| 3512 | 3648 | $context['page_title'] = $txt['pm_report_title']; |
@@ -3528,8 +3664,9 @@ discard block |
||
| 3528 | 3664 | ) |
| 3529 | 3665 | ); |
| 3530 | 3666 | $context['admins'] = array(); |
| 3531 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3532 | - $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3667 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3668 | + $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3669 | + } |
|
| 3533 | 3670 | $smcFunc['db_free_result']($request); |
| 3534 | 3671 | |
| 3535 | 3672 | // How many admins in total? |
@@ -3558,8 +3695,9 @@ discard block |
||
| 3558 | 3695 | ) |
| 3559 | 3696 | ); |
| 3560 | 3697 | // Can only be a hacker here! |
| 3561 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3562 | - fatal_lang_error('no_access', false); |
|
| 3698 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3699 | + fatal_lang_error('no_access', false); |
|
| 3700 | + } |
|
| 3563 | 3701 | list ($subject, $body, $time, $memberFromID, $memberFromName) = $smcFunc['db_fetch_row']($request); |
| 3564 | 3702 | $smcFunc['db_free_result']($request); |
| 3565 | 3703 | |
@@ -3583,15 +3721,17 @@ discard block |
||
| 3583 | 3721 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3584 | 3722 | { |
| 3585 | 3723 | // If it's hidden still don't reveal their names - privacy after all ;) |
| 3586 | - if ($row['bcc']) |
|
| 3587 | - $hidden_recipients++; |
|
| 3588 | - else |
|
| 3589 | - $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3724 | + if ($row['bcc']) { |
|
| 3725 | + $hidden_recipients++; |
|
| 3726 | + } else { |
|
| 3727 | + $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3728 | + } |
|
| 3590 | 3729 | } |
| 3591 | 3730 | $smcFunc['db_free_result']($request); |
| 3592 | 3731 | |
| 3593 | - if ($hidden_recipients) |
|
| 3594 | - $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3732 | + if ($hidden_recipients) { |
|
| 3733 | + $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3734 | + } |
|
| 3595 | 3735 | |
| 3596 | 3736 | // Now let's get out and loop through the admins. |
| 3597 | 3737 | $request = $smcFunc['db_query']('', ' |
@@ -3607,8 +3747,9 @@ discard block |
||
| 3607 | 3747 | ); |
| 3608 | 3748 | |
| 3609 | 3749 | // Maybe we shouldn't advertise this? |
| 3610 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3611 | - fatal_lang_error('no_access', false); |
|
| 3750 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3751 | + fatal_lang_error('no_access', false); |
|
| 3752 | + } |
|
| 3612 | 3753 | |
| 3613 | 3754 | $memberFromName = un_htmlspecialchars($memberFromName); |
| 3614 | 3755 | |
@@ -3627,8 +3768,9 @@ discard block |
||
| 3627 | 3768 | // Make the body. |
| 3628 | 3769 | $report_body = str_replace(array('{REPORTER}', '{SENDER}'), array(un_htmlspecialchars($user_info['name']), $memberFromName), $txt['pm_report_pm_user_sent']); |
| 3629 | 3770 | $report_body .= "\n" . '[b]' . $_POST['reason'] . '[/b]' . "\n\n"; |
| 3630 | - if (!empty($recipients)) |
|
| 3631 | - $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3771 | + if (!empty($recipients)) { |
|
| 3772 | + $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3773 | + } |
|
| 3632 | 3774 | $report_body .= $txt['pm_report_pm_unedited_below'] . "\n" . '[quote author=' . (empty($memberFromID) ? '"' . $memberFromName . '"' : $memberFromName . ' link=action=profile;u=' . $memberFromID . ' date=' . $time) . ']' . "\n" . un_htmlspecialchars($body) . '[/quote]'; |
| 3633 | 3775 | |
| 3634 | 3776 | // Plonk it in the array ;) |
@@ -3648,12 +3790,14 @@ discard block |
||
| 3648 | 3790 | $smcFunc['db_free_result']($request); |
| 3649 | 3791 | |
| 3650 | 3792 | // Send a different email for each language. |
| 3651 | - foreach ($messagesToSend as $lang => $message) |
|
| 3652 | - sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3793 | + foreach ($messagesToSend as $lang => $message) { |
|
| 3794 | + sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3795 | + } |
|
| 3653 | 3796 | |
| 3654 | 3797 | // Give the user their own language back! |
| 3655 | - if (!empty($modSettings['userLanguage'])) |
|
| 3656 | - loadLanguage('PersonalMessage', '', false); |
|
| 3798 | + if (!empty($modSettings['userLanguage'])) { |
|
| 3799 | + loadLanguage('PersonalMessage', '', false); |
|
| 3800 | + } |
|
| 3657 | 3801 | |
| 3658 | 3802 | // Leave them with a template. |
| 3659 | 3803 | $context['sub_template'] = 'report_message_complete'; |
@@ -3699,8 +3843,9 @@ discard block |
||
| 3699 | 3843 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3700 | 3844 | { |
| 3701 | 3845 | // Hide hidden groups! |
| 3702 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
| 3703 | - continue; |
|
| 3846 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
| 3847 | + continue; |
|
| 3848 | + } |
|
| 3704 | 3849 | |
| 3705 | 3850 | $context['groups'][$row['id_group']] = $row['group_name']; |
| 3706 | 3851 | } |
@@ -3726,9 +3871,10 @@ discard block |
||
| 3726 | 3871 | $context['rule'] = $context['rules'][$context['rid']]; |
| 3727 | 3872 | $members = array(); |
| 3728 | 3873 | // Need to get member names! |
| 3729 | - foreach ($context['rule']['criteria'] as $k => $criteria) |
|
| 3730 | - if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3874 | + foreach ($context['rule']['criteria'] as $k => $criteria) { |
|
| 3875 | + if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3731 | 3876 | $members[(int) $criteria['v']] = $k; |
| 3877 | + } |
|
| 3732 | 3878 | |
| 3733 | 3879 | if (!empty($members)) |
| 3734 | 3880 | { |
@@ -3740,19 +3886,20 @@ discard block |
||
| 3740 | 3886 | 'member_list' => array_keys($members), |
| 3741 | 3887 | ) |
| 3742 | 3888 | ); |
| 3743 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3744 | - $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3889 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3890 | + $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3891 | + } |
|
| 3745 | 3892 | $smcFunc['db_free_result']($request); |
| 3746 | 3893 | } |
| 3747 | - } |
|
| 3748 | - else |
|
| 3749 | - $context['rule'] = array( |
|
| 3894 | + } else { |
|
| 3895 | + $context['rule'] = array( |
|
| 3750 | 3896 | 'id' => '', |
| 3751 | 3897 | 'name' => '', |
| 3752 | 3898 | 'criteria' => array(), |
| 3753 | 3899 | 'actions' => array(), |
| 3754 | 3900 | 'logic' => 'and', |
| 3755 | 3901 | ); |
| 3902 | + } |
|
| 3756 | 3903 | } |
| 3757 | 3904 | // Saving? |
| 3758 | 3905 | elseif (isset($_GET['save'])) |
@@ -3762,22 +3909,25 @@ discard block |
||
| 3762 | 3909 | |
| 3763 | 3910 | // Name is easy! |
| 3764 | 3911 | $ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name'])); |
| 3765 | - if (empty($ruleName)) |
|
| 3766 | - fatal_lang_error('pm_rule_no_name', false); |
|
| 3912 | + if (empty($ruleName)) { |
|
| 3913 | + fatal_lang_error('pm_rule_no_name', false); |
|
| 3914 | + } |
|
| 3767 | 3915 | |
| 3768 | 3916 | // Sanity check... |
| 3769 | - if (empty($_POST['ruletype']) || empty($_POST['acttype'])) |
|
| 3770 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3917 | + if (empty($_POST['ruletype']) || empty($_POST['acttype'])) { |
|
| 3918 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3919 | + } |
|
| 3771 | 3920 | |
| 3772 | 3921 | // Let's do the criteria first - it's also hardest! |
| 3773 | 3922 | $criteria = array(); |
| 3774 | 3923 | foreach ($_POST['ruletype'] as $ind => $type) |
| 3775 | 3924 | { |
| 3776 | 3925 | // Check everything is here... |
| 3777 | - if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) |
|
| 3778 | - continue; |
|
| 3779 | - elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) |
|
| 3780 | - continue; |
|
| 3926 | + if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) { |
|
| 3927 | + continue; |
|
| 3928 | + } elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) { |
|
| 3929 | + continue; |
|
| 3930 | + } |
|
| 3781 | 3931 | |
| 3782 | 3932 | // Members need to be found. |
| 3783 | 3933 | if ($type == 'mid') |
@@ -3801,13 +3951,13 @@ discard block |
||
| 3801 | 3951 | $smcFunc['db_free_result']($request); |
| 3802 | 3952 | |
| 3803 | 3953 | $criteria[] = array('t' => 'mid', 'v' => $memID); |
| 3954 | + } elseif ($type == 'bud') { |
|
| 3955 | + $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3956 | + } elseif ($type == 'gid') { |
|
| 3957 | + $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3958 | + } elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') { |
|
| 3959 | + $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3804 | 3960 | } |
| 3805 | - elseif ($type == 'bud') |
|
| 3806 | - $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3807 | - elseif ($type == 'gid') |
|
| 3808 | - $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3809 | - elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') |
|
| 3810 | - $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3811 | 3961 | } |
| 3812 | 3962 | |
| 3813 | 3963 | // Also do the actions! |
@@ -3817,26 +3967,29 @@ discard block |
||
| 3817 | 3967 | foreach ($_POST['acttype'] as $ind => $type) |
| 3818 | 3968 | { |
| 3819 | 3969 | // Picking a valid label? |
| 3820 | - if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) |
|
| 3821 | - continue; |
|
| 3970 | + if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) { |
|
| 3971 | + continue; |
|
| 3972 | + } |
|
| 3822 | 3973 | |
| 3823 | 3974 | // Record what we're doing. |
| 3824 | - if ($type == 'del') |
|
| 3825 | - $doDelete = 1; |
|
| 3826 | - elseif ($type == 'lab') |
|
| 3827 | - $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3975 | + if ($type == 'del') { |
|
| 3976 | + $doDelete = 1; |
|
| 3977 | + } elseif ($type == 'lab') { |
|
| 3978 | + $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3979 | + } |
|
| 3828 | 3980 | } |
| 3829 | 3981 | |
| 3830 | - if (empty($criteria) || (empty($actions) && !$doDelete)) |
|
| 3831 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3982 | + if (empty($criteria) || (empty($actions) && !$doDelete)) { |
|
| 3983 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3984 | + } |
|
| 3832 | 3985 | |
| 3833 | 3986 | // What are we storing? |
| 3834 | 3987 | $criteria = $smcFunc['json_encode']($criteria); |
| 3835 | 3988 | $actions = $smcFunc['json_encode']($actions); |
| 3836 | 3989 | |
| 3837 | 3990 | // Create the rule? |
| 3838 | - if (empty($context['rid'])) |
|
| 3839 | - $smcFunc['db_insert']('', |
|
| 3991 | + if (empty($context['rid'])) { |
|
| 3992 | + $smcFunc['db_insert']('', |
|
| 3840 | 3993 | '{db_prefix}pm_rules', |
| 3841 | 3994 | array( |
| 3842 | 3995 | 'id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string', |
@@ -3847,8 +4000,8 @@ discard block |
||
| 3847 | 4000 | ), |
| 3848 | 4001 | array('id_rule') |
| 3849 | 4002 | ); |
| 3850 | - else |
|
| 3851 | - $smcFunc['db_query']('', ' |
|
| 4003 | + } else { |
|
| 4004 | + $smcFunc['db_query']('', ' |
|
| 3852 | 4005 | UPDATE {db_prefix}pm_rules |
| 3853 | 4006 | SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions}, |
| 3854 | 4007 | delete_pm = {int:delete_pm}, is_or = {int:is_or} |
@@ -3864,6 +4017,7 @@ discard block |
||
| 3864 | 4017 | 'actions' => $actions, |
| 3865 | 4018 | ) |
| 3866 | 4019 | ); |
| 4020 | + } |
|
| 3867 | 4021 | |
| 3868 | 4022 | redirectexit('action=pm;sa=manrules'); |
| 3869 | 4023 | } |
@@ -3872,11 +4026,12 @@ discard block |
||
| 3872 | 4026 | { |
| 3873 | 4027 | checkSession(); |
| 3874 | 4028 | $toDelete = array(); |
| 3875 | - foreach ($_POST['delrule'] as $k => $v) |
|
| 3876 | - $toDelete[] = (int) $k; |
|
| 4029 | + foreach ($_POST['delrule'] as $k => $v) { |
|
| 4030 | + $toDelete[] = (int) $k; |
|
| 4031 | + } |
|
| 3877 | 4032 | |
| 3878 | - if (!empty($toDelete)) |
|
| 3879 | - $smcFunc['db_query']('', ' |
|
| 4033 | + if (!empty($toDelete)) { |
|
| 4034 | + $smcFunc['db_query']('', ' |
|
| 3880 | 4035 | DELETE FROM {db_prefix}pm_rules |
| 3881 | 4036 | WHERE id_rule IN ({array_int:delete_list}) |
| 3882 | 4037 | AND id_member = {int:current_member}', |
@@ -3885,6 +4040,7 @@ discard block |
||
| 3885 | 4040 | 'delete_list' => $toDelete, |
| 3886 | 4041 | ) |
| 3887 | 4042 | ); |
| 4043 | + } |
|
| 3888 | 4044 | |
| 3889 | 4045 | redirectexit('action=pm;sa=manrules'); |
| 3890 | 4046 | } |
@@ -3903,8 +4059,9 @@ discard block |
||
| 3903 | 4059 | loadRules(); |
| 3904 | 4060 | |
| 3905 | 4061 | // No rules? |
| 3906 | - if (empty($context['rules'])) |
|
| 3907 | - return; |
|
| 4062 | + if (empty($context['rules'])) { |
|
| 4063 | + return; |
|
| 4064 | + } |
|
| 3908 | 4065 | |
| 3909 | 4066 | // Just unread ones? |
| 3910 | 4067 | $ruleQuery = $all_messages ? '' : ' AND pmr.is_new = 1'; |
@@ -3934,8 +4091,9 @@ discard block |
||
| 3934 | 4091 | // Loop through all the criteria hoping to make a match. |
| 3935 | 4092 | foreach ($rule['criteria'] as $criterium) |
| 3936 | 4093 | { |
| 3937 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) |
|
| 3938 | - $match = true; |
|
| 4094 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) { |
|
| 4095 | + $match = true; |
|
| 4096 | + } |
|
| 3939 | 4097 | // If we're adding and one criteria don't match then we stop! |
| 3940 | 4098 | elseif ($rule['logic'] == 'and') |
| 3941 | 4099 | { |
@@ -3947,17 +4105,18 @@ discard block |
||
| 3947 | 4105 | // If we have a match the rule must be true - act! |
| 3948 | 4106 | if ($match) |
| 3949 | 4107 | { |
| 3950 | - if ($rule['delete']) |
|
| 3951 | - $actions['deletes'][] = $row['id_pm']; |
|
| 3952 | - else |
|
| 4108 | + if ($rule['delete']) { |
|
| 4109 | + $actions['deletes'][] = $row['id_pm']; |
|
| 4110 | + } else |
|
| 3953 | 4111 | { |
| 3954 | 4112 | foreach ($rule['actions'] as $ruleAction) |
| 3955 | 4113 | { |
| 3956 | 4114 | if ($ruleAction['t'] == 'lab') |
| 3957 | 4115 | { |
| 3958 | 4116 | // Get a basic pot started! |
| 3959 | - if (!isset($actions['labels'][$row['id_pm']])) |
|
| 3960 | - $actions['labels'][$row['id_pm']] = array(); |
|
| 4117 | + if (!isset($actions['labels'][$row['id_pm']])) { |
|
| 4118 | + $actions['labels'][$row['id_pm']] = array(); |
|
| 4119 | + } |
|
| 3961 | 4120 | $actions['labels'][$row['id_pm']][] = $ruleAction['v']; |
| 3962 | 4121 | } |
| 3963 | 4122 | } |
@@ -3968,8 +4127,9 @@ discard block |
||
| 3968 | 4127 | $smcFunc['db_free_result']($request); |
| 3969 | 4128 | |
| 3970 | 4129 | // Deletes are easy! |
| 3971 | - if (!empty($actions['deletes'])) |
|
| 3972 | - deleteMessages($actions['deletes']); |
|
| 4130 | + if (!empty($actions['deletes'])) { |
|
| 4131 | + deleteMessages($actions['deletes']); |
|
| 4132 | + } |
|
| 3973 | 4133 | |
| 3974 | 4134 | // Relabel? |
| 3975 | 4135 | if (!empty($actions['labels'])) |
@@ -3996,8 +4156,7 @@ discard block |
||
| 3996 | 4156 | 'current_member' => $user_info['id'], |
| 3997 | 4157 | ) |
| 3998 | 4158 | ); |
| 3999 | - } |
|
| 4000 | - else |
|
| 4159 | + } else |
|
| 4001 | 4160 | { |
| 4002 | 4161 | $realLabels[] = $label['id']; |
| 4003 | 4162 | } |
@@ -4006,8 +4165,9 @@ discard block |
||
| 4006 | 4165 | |
| 4007 | 4166 | $inserts = array(); |
| 4008 | 4167 | // Now we insert the label info |
| 4009 | - foreach ($realLabels as $a_label) |
|
| 4010 | - $inserts[] = array($pm, $a_label); |
|
| 4168 | + foreach ($realLabels as $a_label) { |
|
| 4169 | + $inserts[] = array($pm, $a_label); |
|
| 4170 | + } |
|
| 4011 | 4171 | |
| 4012 | 4172 | $smcFunc['db_insert']('ignore', |
| 4013 | 4173 | '{db_prefix}pm_labeled_messages', |
@@ -4028,8 +4188,9 @@ discard block |
||
| 4028 | 4188 | { |
| 4029 | 4189 | global $user_info, $context, $smcFunc; |
| 4030 | 4190 | |
| 4031 | - if (isset($context['rules']) && !$reload) |
|
| 4032 | - return; |
|
| 4191 | + if (isset($context['rules']) && !$reload) { |
|
| 4192 | + return; |
|
| 4193 | + } |
|
| 4033 | 4194 | |
| 4034 | 4195 | $request = $smcFunc['db_query']('', ' |
| 4035 | 4196 | SELECT |
@@ -4053,8 +4214,9 @@ discard block |
||
| 4053 | 4214 | 'logic' => $row['is_or'] ? 'or' : 'and', |
| 4054 | 4215 | ); |
| 4055 | 4216 | |
| 4056 | - if ($row['delete_pm']) |
|
| 4057 | - $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4217 | + if ($row['delete_pm']) { |
|
| 4218 | + $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4219 | + } |
|
| 4058 | 4220 | } |
| 4059 | 4221 | $smcFunc['db_free_result']($request); |
| 4060 | 4222 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get a list of versions that are currently installed on the server. |
@@ -45,8 +46,7 @@ discard block |
||
| 45 | 46 | $temp2 = $temp->getVersion(); |
| 46 | 47 | $im_version = $temp2['versionString']; |
| 47 | 48 | $extension_version = 'Imagick ' . phpversion('Imagick'); |
| 48 | - } |
|
| 49 | - else |
|
| 49 | + } else |
|
| 50 | 50 | { |
| 51 | 51 | $im_version = MagickGetVersionString(); |
| 52 | 52 | $extension_version = 'MagickWand ' . phpversion('MagickWand'); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | if (in_array('db_server', $checkFor)) |
| 62 | 62 | { |
| 63 | 63 | db_extend(); |
| 64 | - if (!isset($db_connection) || $db_connection === false) |
|
| 65 | - trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | - else |
|
| 64 | + if (!isset($db_connection) || $db_connection === false) { |
|
| 65 | + trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | + } else |
|
| 67 | 67 | { |
| 68 | 68 | $versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => ''); |
| 69 | 69 | $versions['db_engine']['version'] = $smcFunc['db_get_engine'](); |
@@ -74,24 +74,31 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // If we're using memcache we need the server info. |
| 77 | - if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') |
|
| 78 | - get_memcached_server(); |
|
| 77 | + if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') { |
|
| 78 | + get_memcached_server(); |
|
| 79 | + } |
|
| 79 | 80 | |
| 80 | 81 | // Check to see if we have any accelerators installed... |
| 81 | - if (in_array('phpa', $checkFor) && isset($_PHPA)) |
|
| 82 | - $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 83 | - if (in_array('apc', $checkFor) && extension_loaded('apc')) |
|
| 84 | - $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 85 | - if (in_array('memcache', $checkFor) && function_exists('memcache_set')) |
|
| 86 | - $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); |
|
| 87 | - if (in_array('xcache', $checkFor) && function_exists('xcache_set')) |
|
| 88 | - $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 82 | + if (in_array('phpa', $checkFor) && isset($_PHPA)) { |
|
| 83 | + $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 84 | + } |
|
| 85 | + if (in_array('apc', $checkFor) && extension_loaded('apc')) { |
|
| 86 | + $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 87 | + } |
|
| 88 | + if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { |
|
| 89 | + $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); |
|
| 90 | + } |
|
| 91 | + if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { |
|
| 92 | + $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 93 | + } |
|
| 89 | 94 | |
| 90 | - if (in_array('php', $checkFor)) |
|
| 91 | - $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 95 | + if (in_array('php', $checkFor)) { |
|
| 96 | + $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 97 | + } |
|
| 92 | 98 | |
| 93 | - if (in_array('server', $checkFor)) |
|
| 94 | - $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 99 | + if (in_array('server', $checkFor)) { |
|
| 100 | + $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 101 | + } |
|
| 95 | 102 | |
| 96 | 103 | return $versions; |
| 97 | 104 | } |
@@ -131,11 +138,13 @@ discard block |
||
| 131 | 138 | fclose($fp); |
| 132 | 139 | |
| 133 | 140 | // The comment looks rougly like... that. |
| 134 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 135 | - $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 141 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 142 | + $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 143 | + } |
|
| 136 | 144 | // Not found! This is bad. |
| 137 | - else |
|
| 138 | - $version_info['file_versions']['SSI.php'] = '??'; |
|
| 145 | + else { |
|
| 146 | + $version_info['file_versions']['SSI.php'] = '??'; |
|
| 147 | + } |
|
| 139 | 148 | } |
| 140 | 149 | |
| 141 | 150 | // Do the paid subscriptions handler? |
@@ -146,11 +155,13 @@ discard block |
||
| 146 | 155 | fclose($fp); |
| 147 | 156 | |
| 148 | 157 | // Found it? |
| 149 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 150 | - $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 158 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 159 | + $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 160 | + } |
|
| 151 | 161 | // If we haven't how do we all get paid? |
| 152 | - else |
|
| 153 | - $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 162 | + else { |
|
| 163 | + $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 164 | + } |
|
| 154 | 165 | } |
| 155 | 166 | |
| 156 | 167 | // Load all the files in the Sources directory, except this file and the redirect. |
@@ -165,11 +176,13 @@ discard block |
||
| 165 | 176 | fclose($fp); |
| 166 | 177 | |
| 167 | 178 | // Look for the version comment in the file header. |
| 168 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 169 | - $version_info['file_versions'][$entry] = $match[1]; |
|
| 179 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 180 | + $version_info['file_versions'][$entry] = $match[1]; |
|
| 181 | + } |
|
| 170 | 182 | // It wasn't found, but the file was... show a '??'. |
| 171 | - else |
|
| 172 | - $version_info['file_versions'][$entry] = '??'; |
|
| 183 | + else { |
|
| 184 | + $version_info['file_versions'][$entry] = '??'; |
|
| 185 | + } |
|
| 173 | 186 | } |
| 174 | 187 | } |
| 175 | 188 | $sources_dir->close(); |
@@ -188,11 +201,13 @@ discard block |
||
| 188 | 201 | fclose($fp); |
| 189 | 202 | |
| 190 | 203 | // Look for the version comment in the file header. |
| 191 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 192 | - $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 204 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 205 | + $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 206 | + } |
|
| 193 | 207 | // It wasn't found, but the file was... show a '??'. |
| 194 | - else |
|
| 195 | - $version_info['tasks_versions'][$entry] = '??'; |
|
| 208 | + else { |
|
| 209 | + $version_info['tasks_versions'][$entry] = '??'; |
|
| 210 | + } |
|
| 196 | 211 | } |
| 197 | 212 | } |
| 198 | 213 | $tasks_dir->close(); |
@@ -200,8 +215,9 @@ discard block |
||
| 200 | 215 | |
| 201 | 216 | // Load all the files in the default template directory - and the current theme if applicable. |
| 202 | 217 | $directories = array('default_template_versions' => $settings['default_theme_dir']); |
| 203 | - if ($settings['theme_id'] != 1) |
|
| 204 | - $directories += array('template_versions' => $settings['theme_dir']); |
|
| 218 | + if ($settings['theme_id'] != 1) { |
|
| 219 | + $directories += array('template_versions' => $settings['theme_dir']); |
|
| 220 | + } |
|
| 205 | 221 | |
| 206 | 222 | foreach ($directories as $type => $dirname) |
| 207 | 223 | { |
@@ -216,11 +232,13 @@ discard block |
||
| 216 | 232 | fclose($fp); |
| 217 | 233 | |
| 218 | 234 | // Look for the version comment in the file header. |
| 219 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 220 | - $version_info[$type][$entry] = $match[1]; |
|
| 235 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 236 | + $version_info[$type][$entry] = $match[1]; |
|
| 237 | + } |
|
| 221 | 238 | // It wasn't found, but the file was... show a '??'. |
| 222 | - else |
|
| 223 | - $version_info[$type][$entry] = '??'; |
|
| 239 | + else { |
|
| 240 | + $version_info[$type][$entry] = '??'; |
|
| 241 | + } |
|
| 224 | 242 | } |
| 225 | 243 | } |
| 226 | 244 | $this_dir->close(); |
@@ -241,11 +259,13 @@ discard block |
||
| 241 | 259 | list ($name, $language) = explode('.', $entry); |
| 242 | 260 | |
| 243 | 261 | // Look for the version comment in the file header. |
| 244 | - if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) |
|
| 245 | - $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 262 | + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { |
|
| 263 | + $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 264 | + } |
|
| 246 | 265 | // It wasn't found, but the file was... show a '??'. |
| 247 | - else |
|
| 248 | - $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 266 | + else { |
|
| 267 | + $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 268 | + } |
|
| 249 | 269 | } |
| 250 | 270 | } |
| 251 | 271 | $this_dir->close(); |
@@ -260,8 +280,9 @@ discard block |
||
| 260 | 280 | ksort($version_info['tasks_versions']); |
| 261 | 281 | |
| 262 | 282 | // For languages sort each language too. |
| 263 | - foreach ($version_info['default_language_versions'] as $language => $dummy) |
|
| 264 | - ksort($version_info['default_language_versions'][$language]); |
|
| 283 | + foreach ($version_info['default_language_versions'] as $language => $dummy) { |
|
| 284 | + ksort($version_info['default_language_versions'][$language]); |
|
| 285 | + } |
|
| 265 | 286 | } |
| 266 | 287 | return $version_info; |
| 267 | 288 | } |
@@ -303,27 +324,31 @@ discard block |
||
| 303 | 324 | $settingsArray = trim(file_get_contents($boarddir . '/Settings.php')); |
| 304 | 325 | |
| 305 | 326 | // Break it up based on \r or \n, and then clean out extra characters. |
| 306 | - if (strpos($settingsArray, "\n") !== false) |
|
| 307 | - $settingsArray = explode("\n", $settingsArray); |
|
| 308 | - elseif (strpos($settingsArray, "\r") !== false) |
|
| 309 | - $settingsArray = explode("\r", $settingsArray); |
|
| 310 | - else |
|
| 311 | - return; |
|
| 327 | + if (strpos($settingsArray, "\n") !== false) { |
|
| 328 | + $settingsArray = explode("\n", $settingsArray); |
|
| 329 | + } elseif (strpos($settingsArray, "\r") !== false) { |
|
| 330 | + $settingsArray = explode("\r", $settingsArray); |
|
| 331 | + } else { |
|
| 332 | + return; |
|
| 333 | + } |
|
| 312 | 334 | |
| 313 | 335 | // Presumably, the file has to have stuff in it for this function to be called :P. |
| 314 | - if (count($settingsArray) < 10) |
|
| 315 | - return; |
|
| 336 | + if (count($settingsArray) < 10) { |
|
| 337 | + return; |
|
| 338 | + } |
|
| 316 | 339 | |
| 317 | 340 | // remove any /r's that made there way in here |
| 318 | - foreach ($settingsArray as $k => $dummy) |
|
| 319 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 341 | + foreach ($settingsArray as $k => $dummy) { |
|
| 342 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 343 | + } |
|
| 320 | 344 | |
| 321 | 345 | // go line by line and see whats changing |
| 322 | 346 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 323 | 347 | { |
| 324 | 348 | // Don't trim or bother with it if it's not a variable. |
| 325 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 326 | - continue; |
|
| 349 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 350 | + continue; |
|
| 351 | + } |
|
| 327 | 352 | |
| 328 | 353 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
| 329 | 354 | |
@@ -335,8 +360,7 @@ discard block |
||
| 335 | 360 | { |
| 336 | 361 | updateDbLastError($val); |
| 337 | 362 | unset($config_vars[$var]); |
| 338 | - } |
|
| 339 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 363 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 340 | 364 | { |
| 341 | 365 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 342 | 366 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -347,34 +371,39 @@ discard block |
||
| 347 | 371 | } |
| 348 | 372 | |
| 349 | 373 | // End of the file ... maybe |
| 350 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
| 351 | - $end = $i; |
|
| 374 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
| 375 | + $end = $i; |
|
| 376 | + } |
|
| 352 | 377 | } |
| 353 | 378 | |
| 354 | 379 | // This should never happen, but apparently it is happening. |
| 355 | - if (empty($end) || $end < 10) |
|
| 356 | - $end = count($settingsArray) - 1; |
|
| 380 | + if (empty($end) || $end < 10) { |
|
| 381 | + $end = count($settingsArray) - 1; |
|
| 382 | + } |
|
| 357 | 383 | |
| 358 | 384 | // Still more variables to go? Then lets add them at the end. |
| 359 | 385 | if (!empty($config_vars)) |
| 360 | 386 | { |
| 361 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
| 362 | - $settingsArray[$end++] = ''; |
|
| 363 | - else |
|
| 364 | - $end++; |
|
| 387 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
| 388 | + $settingsArray[$end++] = ''; |
|
| 389 | + } else { |
|
| 390 | + $end++; |
|
| 391 | + } |
|
| 365 | 392 | |
| 366 | 393 | // Add in any newly defined vars that were passed |
| 367 | - foreach ($config_vars as $var => $val) |
|
| 368 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 394 | + foreach ($config_vars as $var => $val) { |
|
| 395 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 396 | + } |
|
| 369 | 397 | |
| 370 | 398 | $settingsArray[$end] = '?' . '>'; |
| 399 | + } else { |
|
| 400 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 371 | 401 | } |
| 372 | - else |
|
| 373 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 374 | 402 | |
| 375 | 403 | // Sanity error checking: the file needs to be at least 12 lines. |
| 376 | - if (count($settingsArray) < 12) |
|
| 377 | - return; |
|
| 404 | + if (count($settingsArray) < 12) { |
|
| 405 | + return; |
|
| 406 | + } |
|
| 378 | 407 | |
| 379 | 408 | // Try to avoid a few pitfalls: |
| 380 | 409 | // - like a possible race condition, |
@@ -382,8 +411,9 @@ discard block |
||
| 382 | 411 | // |
| 383 | 412 | // Check before you act: if cache is enabled, we can do a simple write test |
| 384 | 413 | // to validate that we even write things on this filesystem. |
| 385 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 386 | - $cachedir = $boarddir . '/cache'; |
|
| 414 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 415 | + $cachedir = $boarddir . '/cache'; |
|
| 416 | + } |
|
| 387 | 417 | |
| 388 | 418 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
| 389 | 419 | if ($test_fp) |
@@ -418,16 +448,18 @@ discard block |
||
| 418 | 448 | // Well this is not good at all, lets see if we can save this |
| 419 | 449 | $context['settings_message'] = 'settings_error'; |
| 420 | 450 | |
| 421 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
| 422 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 451 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
| 452 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 453 | + } |
|
| 423 | 454 | } |
| 424 | 455 | } |
| 425 | 456 | |
| 426 | 457 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 427 | 458 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 428 | - if (function_exists('opcache_invalidate')) |
|
| 429 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 430 | -} |
|
| 459 | + if (function_exists('opcache_invalidate')) { |
|
| 460 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 461 | + } |
|
| 462 | + } |
|
| 431 | 463 | |
| 432 | 464 | /** |
| 433 | 465 | * Saves the time of the last db error for the error log |
@@ -453,8 +485,9 @@ discard block |
||
| 453 | 485 | global $options, $context, $smcFunc, $settings, $user_info; |
| 454 | 486 | |
| 455 | 487 | // This must exist! |
| 456 | - if (!isset($context['admin_preferences'])) |
|
| 457 | - return false; |
|
| 488 | + if (!isset($context['admin_preferences'])) { |
|
| 489 | + return false; |
|
| 490 | + } |
|
| 458 | 491 | |
| 459 | 492 | // This is what we'll be saving. |
| 460 | 493 | $options['admin_preferences'] = $smcFunc['json_encode']($context['admin_preferences']); |
@@ -518,8 +551,9 @@ discard block |
||
| 518 | 551 | $emails_sent = array(); |
| 519 | 552 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 520 | 553 | { |
| 521 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 522 | - continue; |
|
| 554 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 555 | + continue; |
|
| 556 | + } |
|
| 523 | 557 | |
| 524 | 558 | // Stick their particulars in the replacement data. |
| 525 | 559 | $replacements['IDMEMBER'] = $row['id_member']; |
@@ -538,11 +572,12 @@ discard block |
||
| 538 | 572 | $smcFunc['db_free_result']($request); |
| 539 | 573 | |
| 540 | 574 | // Any additional users we must email this to? |
| 541 | - if (!empty($additional_recipients)) |
|
| 542 | - foreach ($additional_recipients as $recipient) |
|
| 575 | + if (!empty($additional_recipients)) { |
|
| 576 | + foreach ($additional_recipients as $recipient) |
|
| 543 | 577 | { |
| 544 | 578 | if (in_array($recipient['email'], $emails_sent)) |
| 545 | 579 | continue; |
| 580 | + } |
|
| 546 | 581 | |
| 547 | 582 | $replacements['IDMEMBER'] = $recipient['id']; |
| 548 | 583 | $replacements['REALNAME'] = $recipient['name']; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Class Likes |
@@ -108,8 +109,9 @@ discard block |
||
| 108 | 109 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
| 109 | 110 | |
| 110 | 111 | // We do not want to output debug information here. |
| 111 | - if ($this->_js) |
|
| 112 | - $db_show_debug = false; |
|
| 112 | + if ($this->_js) { |
|
| 113 | + $db_show_debug = false; |
|
| 114 | + } |
|
| 113 | 115 | } |
| 114 | 116 | |
| 115 | 117 | /** |
@@ -143,8 +145,9 @@ discard block |
||
| 143 | 145 | $call = $this->_sa; |
| 144 | 146 | |
| 145 | 147 | // Guest can only view likes. |
| 146 | - if ($call != 'view') |
|
| 147 | - is_not_guest(); |
|
| 148 | + if ($call != 'view') { |
|
| 149 | + is_not_guest(); |
|
| 150 | + } |
|
| 148 | 151 | |
| 149 | 152 | checkSession('get'); |
| 150 | 153 | |
@@ -182,15 +185,17 @@ discard block |
||
| 182 | 185 | global $smcFunc, $modSettings; |
| 183 | 186 | |
| 184 | 187 | // This feature is currently disable. |
| 185 | - if (empty($modSettings['enable_likes'])) |
|
| 186 | - return $this->_error = 'like_disable'; |
|
| 188 | + if (empty($modSettings['enable_likes'])) { |
|
| 189 | + return $this->_error = 'like_disable'; |
|
| 190 | + } |
|
| 187 | 191 | |
| 188 | 192 | // Zerothly, they did indicate some kind of content to like, right? |
| 189 | 193 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
| 190 | 194 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
| 191 | 195 | |
| 192 | - if ($this->_type == '' || $this->_content <= 0) |
|
| 193 | - return $this->_error = 'cannot_'; |
|
| 196 | + if ($this->_type == '' || $this->_content <= 0) { |
|
| 197 | + return $this->_error = 'cannot_'; |
|
| 198 | + } |
|
| 194 | 199 | |
| 195 | 200 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
| 196 | 201 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -209,12 +214,14 @@ discard block |
||
| 209 | 214 | 'msg' => $this->_content, |
| 210 | 215 | ) |
| 211 | 216 | ); |
| 212 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 213 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 217 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 218 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 219 | + } |
|
| 214 | 220 | |
| 215 | 221 | $smcFunc['db_free_result']($request); |
| 216 | - if (empty($this->_idTopic)) |
|
| 217 | - return $this->_error = 'cannot_'; |
|
| 222 | + if (empty($this->_idTopic)) { |
|
| 223 | + return $this->_error = 'cannot_'; |
|
| 224 | + } |
|
| 218 | 225 | |
| 219 | 226 | // So we know what topic it's in and more importantly we know the user can see it. |
| 220 | 227 | // If we're not viewing, we need some info set up. |
@@ -224,9 +231,7 @@ discard block |
||
| 224 | 231 | $this->_validLikes['can_see'] = allowedTo('likes_view') ? true : 'cannot_view_likes'; |
| 225 | 232 | |
| 226 | 233 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
| 227 | - } |
|
| 228 | - |
|
| 229 | - else |
|
| 234 | + } else |
|
| 230 | 235 | { |
| 231 | 236 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
| 232 | 237 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -244,8 +249,9 @@ discard block |
||
| 244 | 249 | if ($result !== false) |
| 245 | 250 | { |
| 246 | 251 | // Match the type with what we already have. |
| 247 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
| 248 | - return $this->_error = 'not_valid_like_type'; |
|
| 252 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
| 253 | + return $this->_error = 'not_valid_like_type'; |
|
| 254 | + } |
|
| 249 | 255 | |
| 250 | 256 | // Fill out the rest. |
| 251 | 257 | $this->_type = $result['type']; |
@@ -256,17 +262,20 @@ discard block |
||
| 256 | 262 | } |
| 257 | 263 | } |
| 258 | 264 | |
| 259 | - if (!$found) |
|
| 260 | - return $this->_error = 'cannot_'; |
|
| 265 | + if (!$found) { |
|
| 266 | + return $this->_error = 'cannot_'; |
|
| 267 | + } |
|
| 261 | 268 | } |
| 262 | 269 | |
| 263 | 270 | // Does the user can see this? |
| 264 | - if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) |
|
| 265 | - return $this->_error = $this->_validLikes['can_see']; |
|
| 271 | + if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) { |
|
| 272 | + return $this->_error = $this->_validLikes['can_see']; |
|
| 273 | + } |
|
| 266 | 274 | |
| 267 | 275 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
| 268 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
| 269 | - return $this->_error = $this->_validLikes['can_like']; |
|
| 276 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
| 277 | + return $this->_error = $this->_validLikes['can_like']; |
|
| 278 | + } |
|
| 270 | 279 | } |
| 271 | 280 | |
| 272 | 281 | /** |
@@ -291,8 +300,9 @@ discard block |
||
| 291 | 300 | ); |
| 292 | 301 | |
| 293 | 302 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 294 | - if ($this->_sa == __FUNCTION__) |
|
| 295 | - $this->_data = __FUNCTION__; |
|
| 303 | + if ($this->_sa == __FUNCTION__) { |
|
| 304 | + $this->_data = __FUNCTION__; |
|
| 305 | + } |
|
| 296 | 306 | } |
| 297 | 307 | |
| 298 | 308 | /** |
@@ -322,8 +332,8 @@ discard block |
||
| 322 | 332 | |
| 323 | 333 | // Add a background task to process sending alerts. |
| 324 | 334 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
| 325 | - if ($this->_type == 'msg') |
|
| 326 | - $smcFunc['db_insert']('insert', |
|
| 335 | + if ($this->_type == 'msg') { |
|
| 336 | + $smcFunc['db_insert']('insert', |
|
| 327 | 337 | '{db_prefix}background_tasks', |
| 328 | 338 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 329 | 339 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array( |
@@ -335,10 +345,12 @@ discard block |
||
| 335 | 345 | )), 0), |
| 336 | 346 | array('id_task') |
| 337 | 347 | ); |
| 348 | + } |
|
| 338 | 349 | |
| 339 | 350 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 340 | - if ($this->_sa == __FUNCTION__) |
|
| 341 | - $this->_data = __FUNCTION__; |
|
| 351 | + if ($this->_sa == __FUNCTION__) { |
|
| 352 | + $this->_data = __FUNCTION__; |
|
| 353 | + } |
|
| 342 | 354 | } |
| 343 | 355 | |
| 344 | 356 | /** |
@@ -364,8 +376,9 @@ discard block |
||
| 364 | 376 | $smcFunc['db_free_result']($request); |
| 365 | 377 | |
| 366 | 378 | // If you want to call this directly, fill out _data property too. |
| 367 | - if ($this->_sa == __FUNCTION__) |
|
| 368 | - $this->_data = $this->_numLikes; |
|
| 379 | + if ($this->_sa == __FUNCTION__) { |
|
| 380 | + $this->_data = $this->_numLikes; |
|
| 381 | + } |
|
| 369 | 382 | } |
| 370 | 383 | |
| 371 | 384 | /** |
@@ -378,8 +391,9 @@ discard block |
||
| 378 | 391 | global $smcFunc; |
| 379 | 392 | |
| 380 | 393 | // Safety first! |
| 381 | - if (empty($this->_type) || empty($this->_content)) |
|
| 382 | - return $this->_error = 'cannot_'; |
|
| 394 | + if (empty($this->_type) || empty($this->_content)) { |
|
| 395 | + return $this->_error = 'cannot_'; |
|
| 396 | + } |
|
| 383 | 397 | |
| 384 | 398 | // Do we already like this? |
| 385 | 399 | $request = $smcFunc['db_query']('', ' |
@@ -397,26 +411,28 @@ discard block |
||
| 397 | 411 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
| 398 | 412 | $smcFunc['db_free_result']($request); |
| 399 | 413 | |
| 400 | - if ($this->_alreadyLiked) |
|
| 401 | - $this->delete(); |
|
| 402 | - |
|
| 403 | - else |
|
| 404 | - $this->insert(); |
|
| 414 | + if ($this->_alreadyLiked) { |
|
| 415 | + $this->delete(); |
|
| 416 | + } else { |
|
| 417 | + $this->insert(); |
|
| 418 | + } |
|
| 405 | 419 | |
| 406 | 420 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
| 407 | 421 | $this->_count(); |
| 408 | 422 | |
| 409 | 423 | // Update the likes count for messages. |
| 410 | - if ($this->_type == 'msg') |
|
| 411 | - $this->msgIssueLike(); |
|
| 424 | + if ($this->_type == 'msg') { |
|
| 425 | + $this->msgIssueLike(); |
|
| 426 | + } |
|
| 412 | 427 | |
| 413 | 428 | // Any callbacks? |
| 414 | 429 | elseif (!empty($this->_validLikes['callback'])) |
| 415 | 430 | { |
| 416 | 431 | $call = call_helper($this->_validLikes['callback'], true); |
| 417 | 432 | |
| 418 | - if (!empty($call)) |
|
| 419 | - call_user_func_array($call, array($this)); |
|
| 433 | + if (!empty($call)) { |
|
| 434 | + call_user_func_array($call, array($this)); |
|
| 435 | + } |
|
| 420 | 436 | } |
| 421 | 437 | |
| 422 | 438 | // Sometimes there might be other things that need updating after we do this like. |
@@ -425,8 +441,9 @@ discard block |
||
| 425 | 441 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
| 426 | 442 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
| 427 | 443 | // in integrate_valid_likes where it absolutely has to exist. |
| 428 | - if (!empty($this->_validLikes['flush_cache'])) |
|
| 429 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 444 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
| 445 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 446 | + } |
|
| 430 | 447 | |
| 431 | 448 | // All done, start building the data to pass as response. |
| 432 | 449 | $this->_data = array( |
@@ -450,8 +467,9 @@ discard block |
||
| 450 | 467 | { |
| 451 | 468 | global $smcFunc; |
| 452 | 469 | |
| 453 | - if ($this->_type !== 'msg') |
|
| 454 | - return; |
|
| 470 | + if ($this->_type !== 'msg') { |
|
| 471 | + return; |
|
| 472 | + } |
|
| 455 | 473 | |
| 456 | 474 | $smcFunc['db_query']('', ' |
| 457 | 475 | UPDATE {db_prefix}messages |
@@ -492,8 +510,9 @@ discard block |
||
| 492 | 510 | 'like_type' => $this->_type, |
| 493 | 511 | ) |
| 494 | 512 | ); |
| 495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 496 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 513 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 514 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 515 | + } |
|
| 497 | 516 | |
| 498 | 517 | // Now to get member data, including avatars and so on. |
| 499 | 518 | $members = array_keys($context['likers']); |
@@ -501,8 +520,9 @@ discard block |
||
| 501 | 520 | if (count($loaded) != count($members)) |
| 502 | 521 | { |
| 503 | 522 | $members = array_diff($members, $loaded); |
| 504 | - foreach ($members as $not_loaded) |
|
| 505 | - unset ($context['likers'][$not_loaded]); |
|
| 523 | + foreach ($members as $not_loaded) { |
|
| 524 | + unset ($context['likers'][$not_loaded]); |
|
| 525 | + } |
|
| 506 | 526 | } |
| 507 | 527 | |
| 508 | 528 | foreach ($context['likers'] as $liker => $dummy) |
@@ -544,12 +564,14 @@ discard block |
||
| 544 | 564 | global $context, $txt; |
| 545 | 565 | |
| 546 | 566 | // Don't do anything if someone else has already take care of the response. |
| 547 | - if (!$this->_setResponse) |
|
| 548 | - return; |
|
| 567 | + if (!$this->_setResponse) { |
|
| 568 | + return; |
|
| 569 | + } |
|
| 549 | 570 | |
| 550 | 571 | // Want a json response huh? |
| 551 | - if ($this->_validLikes['json']) |
|
| 552 | - return $this->jsonResponse(); |
|
| 572 | + if ($this->_validLikes['json']) { |
|
| 573 | + return $this->jsonResponse(); |
|
| 574 | + } |
|
| 553 | 575 | |
| 554 | 576 | // Set everything up for display. |
| 555 | 577 | loadTemplate('Likes'); |
@@ -559,8 +581,9 @@ discard block |
||
| 559 | 581 | if ($this->_error) |
| 560 | 582 | { |
| 561 | 583 | // If this is a generic error, set it up good. |
| 562 | - if ($this->_error == 'cannot_') |
|
| 563 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 584 | + if ($this->_error == 'cannot_') { |
|
| 585 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 586 | + } |
|
| 564 | 587 | |
| 565 | 588 | // Is this request coming from an ajax call? |
| 566 | 589 | if ($this->_js) |
@@ -570,8 +593,9 @@ discard block |
||
| 570 | 593 | } |
| 571 | 594 | |
| 572 | 595 | // Nope? then just do a redirect to whatever URL was provided. |
| 573 | - else |
|
| 574 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 596 | + else { |
|
| 597 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 598 | + } |
|
| 575 | 599 | |
| 576 | 600 | return; |
| 577 | 601 | } |
@@ -580,8 +604,9 @@ discard block |
||
| 580 | 604 | else |
| 581 | 605 | { |
| 582 | 606 | // Not an ajax request so send the user back to the previous location or the main page. |
| 583 | - if (!$this->_js) |
|
| 584 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 607 | + if (!$this->_js) { |
|
| 608 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 609 | + } |
|
| 585 | 610 | |
| 586 | 611 | // These fine gentlemen all share the same template. |
| 587 | 612 | $generic = array('delete', 'insert', '_count'); |
@@ -614,8 +639,9 @@ discard block |
||
| 614 | 639 | // If there is an error, send it. |
| 615 | 640 | if ($this->_error) |
| 616 | 641 | { |
| 617 | - if ($this->_error == 'cannot_') |
|
| 618 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 642 | + if ($this->_error == 'cannot_') { |
|
| 643 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 644 | + } |
|
| 619 | 645 | |
| 620 | 646 | $print['error'] = $this->_error; |
| 621 | 647 | } |
@@ -651,33 +677,36 @@ discard block |
||
| 651 | 677 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
| 652 | 678 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
| 653 | 679 | |
| 654 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
| 655 | - $_GET['verse'] = '4:16'; |
|
| 680 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
| 681 | + $_GET['verse'] = '4:16'; |
|
| 682 | + } |
|
| 656 | 683 | |
| 657 | - if ($_GET['verse'] == '2:18') |
|
| 658 | - echo ' |
|
| 684 | + if ($_GET['verse'] == '2:18') { |
|
| 685 | + echo ' |
|
| 659 | 686 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
| 660 | - elseif ($_GET['verse'] == '4:16') |
|
| 661 | - echo ' |
|
| 687 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 688 | + echo ' |
|
| 662 | 689 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
| 663 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 664 | - echo ' |
|
| 690 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 691 | + echo ' |
|
| 665 | 692 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
| 666 | 693 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
| 694 | + } |
|
| 667 | 695 | |
| 668 | 696 | echo ' |
| 669 | 697 | </div> |
| 670 | 698 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
| 671 | 699 | |
| 672 | - if ($_GET['verse'] == '2:18') |
|
| 673 | - echo ' |
|
| 700 | + if ($_GET['verse'] == '2:18') { |
|
| 701 | + echo ' |
|
| 674 | 702 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
| 675 | - elseif ($_GET['verse'] == '4:16') |
|
| 676 | - echo ' |
|
| 703 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 704 | + echo ' |
|
| 677 | 705 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
| 678 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 679 | - echo ' |
|
| 706 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 707 | + echo ' |
|
| 680 | 708 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
| 709 | + } |
|
| 681 | 710 | |
| 682 | 711 | echo ' |
| 683 | 712 | </div> |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
| 23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
| 24 | 25 | |
| 25 | 26 | // Attempt to load the member's profile data. |
| 26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
| 27 | - fatal_lang_error('not_a_user', false, 404); |
|
| 27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
| 28 | + fatal_lang_error('not_a_user', false, 404); |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | // Set up the stuff and load the user. |
| 30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
| 49 | 51 | |
| 50 | 52 | // See if they have broken any warning levels... |
| 51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
| 52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
| 53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
| 55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
| 57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
| 55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
| 57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
| 59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | // They haven't even been registered for a full day!? |
| 60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
| 61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
| 62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 63 | - else |
|
| 64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
| 65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 66 | + } else { |
|
| 67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | // Set the age... |
| 67 | 71 | if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002) |
@@ -70,8 +74,7 @@ discard block |
||
| 70 | 74 | 'age' => $txt['not_applicable'], |
| 71 | 75 | 'today_is_birthday' => false |
| 72 | 76 | ); |
| 73 | - } |
|
| 74 | - else |
|
| 77 | + } else |
|
| 75 | 78 | { |
| 76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
| 77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
| 84 | 87 | if (allowedTo('moderate_forum')) |
| 85 | 88 | { |
| 86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
| 87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
| 88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 89 | - else |
|
| 90 | - $context['member']['hostname'] = ''; |
|
| 90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
| 91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 92 | + } else { |
|
| 93 | + $context['member']['hostname'] = ''; |
|
| 94 | + } |
|
| 91 | 95 | |
| 92 | 96 | $context['can_see_ip'] = true; |
| 97 | + } else { |
|
| 98 | + $context['can_see_ip'] = false; |
|
| 93 | 99 | } |
| 94 | - else |
|
| 95 | - $context['can_see_ip'] = false; |
|
| 96 | 100 | |
| 97 | 101 | // Are they hidden? |
| 98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
| 103 | 107 | include_once($sourcedir . '/Who.php'); |
| 104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
| 105 | 109 | |
| 106 | - if ($action !== false) |
|
| 107 | - $context['member']['action'] = $action; |
|
| 110 | + if ($action !== false) { |
|
| 111 | + $context['member']['action'] = $action; |
|
| 112 | + } |
|
| 108 | 113 | } |
| 109 | 114 | |
| 110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
| 167 | 172 | { |
| 168 | 173 | // Work out what restrictions we actually have. |
| 169 | 174 | $ban_restrictions = array(); |
| 170 | - foreach (array('access', 'register', 'login', 'post') as $type) |
|
| 171 | - if ($row['cannot_' . $type]) |
|
| 175 | + foreach (array('access', 'register', 'login', 'post') as $type) { |
|
| 176 | + if ($row['cannot_' . $type]) |
|
| 172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
| 178 | + } |
|
| 173 | 179 | |
| 174 | 180 | // No actual ban in place? |
| 175 | - if (empty($ban_restrictions)) |
|
| 176 | - continue; |
|
| 181 | + if (empty($ban_restrictions)) { |
|
| 182 | + continue; |
|
| 183 | + } |
|
| 177 | 184 | |
| 178 | 185 | // Prepare the link for context. |
| 179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -196,9 +203,10 @@ discard block |
||
| 196 | 203 | $context['print_custom_fields'] = array(); |
| 197 | 204 | |
| 198 | 205 | // Any custom profile fields? |
| 199 | - if (!empty($context['custom_fields'])) |
|
| 200 | - foreach ($context['custom_fields'] as $custom) |
|
| 206 | + if (!empty($context['custom_fields'])) { |
|
| 207 | + foreach ($context['custom_fields'] as $custom) |
|
| 201 | 208 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 209 | + } |
|
| 202 | 210 | |
| 203 | 211 | } |
| 204 | 212 | |
@@ -242,14 +250,16 @@ discard block |
||
| 242 | 250 | $row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array(); |
| 243 | 251 | $alerts[$id_alert] = $row; |
| 244 | 252 | |
| 245 | - if (!empty($row['sender_id'])) |
|
| 246 | - $senders[] = $row['sender_id']; |
|
| 253 | + if (!empty($row['sender_id'])) { |
|
| 254 | + $senders[] = $row['sender_id']; |
|
| 255 | + } |
|
| 247 | 256 | } |
| 248 | 257 | $smcFunc['db_free_result']($request); |
| 249 | 258 | |
| 250 | 259 | $senders = loadMemberData($senders); |
| 251 | - foreach ($senders as $member) |
|
| 252 | - loadMemberContext($member); |
|
| 260 | + foreach ($senders as $member) { |
|
| 261 | + loadMemberContext($member); |
|
| 262 | + } |
|
| 253 | 263 | |
| 254 | 264 | // Now go through and actually make with the text. |
| 255 | 265 | loadLanguage('Alerts'); |
@@ -263,12 +273,15 @@ discard block |
||
| 263 | 273 | $msgs = array(); |
| 264 | 274 | foreach ($alerts as $id_alert => $alert) |
| 265 | 275 | { |
| 266 | - if (isset($alert['extra']['board'])) |
|
| 267 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 268 | - if (isset($alert['extra']['topic'])) |
|
| 269 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 270 | - if ($alert['content_type'] == 'msg') |
|
| 271 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 276 | + if (isset($alert['extra']['board'])) { |
|
| 277 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 278 | + } |
|
| 279 | + if (isset($alert['extra']['topic'])) { |
|
| 280 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 281 | + } |
|
| 282 | + if ($alert['content_type'] == 'msg') { |
|
| 283 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 284 | + } |
|
| 272 | 285 | } |
| 273 | 286 | |
| 274 | 287 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -283,8 +296,9 @@ discard block |
||
| 283 | 296 | 'boards' => array_keys($boards), |
| 284 | 297 | ) |
| 285 | 298 | ); |
| 286 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 287 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 299 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 300 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 301 | + } |
|
| 288 | 302 | } |
| 289 | 303 | if (!empty($topics)) |
| 290 | 304 | { |
@@ -299,8 +313,9 @@ discard block |
||
| 299 | 313 | 'topics' => array_keys($topics), |
| 300 | 314 | ) |
| 301 | 315 | ); |
| 302 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 303 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 317 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 318 | + } |
|
| 304 | 319 | } |
| 305 | 320 | if (!empty($msgs)) |
| 306 | 321 | { |
@@ -315,26 +330,33 @@ discard block |
||
| 315 | 330 | 'msgs' => array_keys($msgs), |
| 316 | 331 | ) |
| 317 | 332 | ); |
| 318 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 319 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 333 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 334 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 335 | + } |
|
| 320 | 336 | } |
| 321 | 337 | |
| 322 | 338 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
| 323 | 339 | foreach ($alerts as $id_alert => $alert) |
| 324 | 340 | { |
| 325 | - if (!empty($alert['text'])) |
|
| 326 | - continue; |
|
| 327 | - if (isset($alert['extra']['board'])) |
|
| 328 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 329 | - if (isset($alert['extra']['topic'])) |
|
| 330 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 331 | - if ($alert['content_type'] == 'msg') |
|
| 332 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 333 | - if ($alert['content_type'] == 'profile') |
|
| 334 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 335 | - |
|
| 336 | - if (!empty($memberContext[$alert['sender_id']])) |
|
| 337 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 341 | + if (!empty($alert['text'])) { |
|
| 342 | + continue; |
|
| 343 | + } |
|
| 344 | + if (isset($alert['extra']['board'])) { |
|
| 345 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 346 | + } |
|
| 347 | + if (isset($alert['extra']['topic'])) { |
|
| 348 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 349 | + } |
|
| 350 | + if ($alert['content_type'] == 'msg') { |
|
| 351 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 352 | + } |
|
| 353 | + if ($alert['content_type'] == 'profile') { |
|
| 354 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
| 358 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 359 | + } |
|
| 338 | 360 | |
| 339 | 361 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
| 340 | 362 | if (isset($txt[$string])) |
@@ -422,11 +444,11 @@ discard block |
||
| 422 | 444 | checkSession('request'); |
| 423 | 445 | |
| 424 | 446 | // Call it! |
| 425 | - if ($action == 'remove') |
|
| 426 | - alert_delete($toMark, $memID); |
|
| 427 | - |
|
| 428 | - else |
|
| 429 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 447 | + if ($action == 'remove') { |
|
| 448 | + alert_delete($toMark, $memID); |
|
| 449 | + } else { |
|
| 450 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 451 | + } |
|
| 430 | 452 | |
| 431 | 453 | // Set a nice update message. |
| 432 | 454 | $_SESSION['update_message'] = true; |
@@ -476,23 +498,27 @@ discard block |
||
| 476 | 498 | ); |
| 477 | 499 | |
| 478 | 500 | // Set the page title |
| 479 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
| 480 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 481 | - else |
|
| 482 | - $context['page_title'] = $txt['showPosts']; |
|
| 501 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
| 502 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 503 | + } else { |
|
| 504 | + $context['page_title'] = $txt['showPosts']; |
|
| 505 | + } |
|
| 483 | 506 | |
| 484 | 507 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
| 485 | 508 | |
| 486 | 509 | // Is the load average too high to allow searching just now? |
| 487 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
| 488 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 510 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
| 511 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 512 | + } |
|
| 489 | 513 | |
| 490 | 514 | // If we're specifically dealing with attachments use that function! |
| 491 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
| 492 | - return showAttachments($memID); |
|
| 515 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
| 516 | + return showAttachments($memID); |
|
| 517 | + } |
|
| 493 | 518 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
| 494 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
| 495 | - return showUnwatched($memID); |
|
| 519 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
| 520 | + return showUnwatched($memID); |
|
| 521 | + } |
|
| 496 | 522 | |
| 497 | 523 | // Are we just viewing topics? |
| 498 | 524 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -515,27 +541,30 @@ discard block |
||
| 515 | 541 | $smcFunc['db_free_result']($request); |
| 516 | 542 | |
| 517 | 543 | // Trying to remove a message that doesn't exist. |
| 518 | - if (empty($info)) |
|
| 519 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 544 | + if (empty($info)) { |
|
| 545 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 546 | + } |
|
| 520 | 547 | |
| 521 | 548 | // We can be lazy, since removeMessage() will check the permissions for us. |
| 522 | 549 | require_once($sourcedir . '/RemoveTopic.php'); |
| 523 | 550 | removeMessage((int) $_GET['delete']); |
| 524 | 551 | |
| 525 | 552 | // Add it to the mod log. |
| 526 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 527 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 553 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 554 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 555 | + } |
|
| 528 | 556 | |
| 529 | 557 | // Back to... where we are now ;). |
| 530 | 558 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
| 531 | 559 | } |
| 532 | 560 | |
| 533 | 561 | // Default to 10. |
| 534 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 535 | - $_REQUEST['viewscount'] = '10'; |
|
| 562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 563 | + $_REQUEST['viewscount'] = '10'; |
|
| 564 | + } |
|
| 536 | 565 | |
| 537 | - if ($context['is_topics']) |
|
| 538 | - $request = $smcFunc['db_query']('', ' |
|
| 566 | + if ($context['is_topics']) { |
|
| 567 | + $request = $smcFunc['db_query']('', ' |
|
| 539 | 568 | SELECT COUNT(*) |
| 540 | 569 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 541 | 570 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -548,8 +577,8 @@ discard block |
||
| 548 | 577 | 'board' => $board, |
| 549 | 578 | ) |
| 550 | 579 | ); |
| 551 | - else |
|
| 552 | - $request = $smcFunc['db_query']('', ' |
|
| 580 | + } else { |
|
| 581 | + $request = $smcFunc['db_query']('', ' |
|
| 553 | 582 | SELECT COUNT(*) |
| 554 | 583 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 555 | 584 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -562,6 +591,7 @@ discard block |
||
| 562 | 591 | 'board' => $board, |
| 563 | 592 | ) |
| 564 | 593 | ); |
| 594 | + } |
|
| 565 | 595 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
| 566 | 596 | $smcFunc['db_free_result']($request); |
| 567 | 597 | |
@@ -582,10 +612,11 @@ discard block |
||
| 582 | 612 | |
| 583 | 613 | $range_limit = ''; |
| 584 | 614 | |
| 585 | - if ($context['is_topics']) |
|
| 586 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 587 | - else |
|
| 588 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 615 | + if ($context['is_topics']) { |
|
| 616 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 617 | + } else { |
|
| 618 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 619 | + } |
|
| 589 | 620 | |
| 590 | 621 | $maxIndex = $maxPerPage; |
| 591 | 622 | |
@@ -611,9 +642,9 @@ discard block |
||
| 611 | 642 | { |
| 612 | 643 | $margin *= 5; |
| 613 | 644 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
| 645 | + } else { |
|
| 646 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 614 | 647 | } |
| 615 | - else |
|
| 616 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 617 | 648 | } |
| 618 | 649 | |
| 619 | 650 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -645,8 +676,7 @@ discard block |
||
| 645 | 676 | 'max' => $maxIndex, |
| 646 | 677 | ) |
| 647 | 678 | ); |
| 648 | - } |
|
| 649 | - else |
|
| 679 | + } else |
|
| 650 | 680 | { |
| 651 | 681 | $request = $smcFunc['db_query']('', ' |
| 652 | 682 | SELECT |
@@ -675,8 +705,9 @@ discard block |
||
| 675 | 705 | } |
| 676 | 706 | |
| 677 | 707 | // Make sure we quit this loop. |
| 678 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
| 679 | - break; |
|
| 708 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
| 709 | + break; |
|
| 710 | + } |
|
| 680 | 711 | $looped = true; |
| 681 | 712 | $range_limit = ''; |
| 682 | 713 | } |
@@ -720,19 +751,21 @@ discard block |
||
| 720 | 751 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
| 721 | 752 | ); |
| 722 | 753 | |
| 723 | - if ($user_info['id'] == $row['id_member_started']) |
|
| 724 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
| 754 | + if ($user_info['id'] == $row['id_member_started']) { |
|
| 755 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
| 756 | + } |
|
| 725 | 757 | $board_ids['any'][$row['id_board']][] = $counter; |
| 726 | 758 | } |
| 727 | 759 | $smcFunc['db_free_result']($request); |
| 728 | 760 | |
| 729 | 761 | // All posts were retrieved in reverse order, get them right again. |
| 730 | - if ($reverse) |
|
| 731 | - $context['posts'] = array_reverse($context['posts'], true); |
|
| 762 | + if ($reverse) { |
|
| 763 | + $context['posts'] = array_reverse($context['posts'], true); |
|
| 764 | + } |
|
| 732 | 765 | |
| 733 | 766 | // These are all the permissions that are different from board to board.. |
| 734 | - if ($context['is_topics']) |
|
| 735 | - $permissions = array( |
|
| 767 | + if ($context['is_topics']) { |
|
| 768 | + $permissions = array( |
|
| 736 | 769 | 'own' => array( |
| 737 | 770 | 'post_reply_own' => 'can_reply', |
| 738 | 771 | ), |
@@ -740,8 +773,8 @@ discard block |
||
| 740 | 773 | 'post_reply_any' => 'can_reply', |
| 741 | 774 | ) |
| 742 | 775 | ); |
| 743 | - else |
|
| 744 | - $permissions = array( |
|
| 776 | + } else { |
|
| 777 | + $permissions = array( |
|
| 745 | 778 | 'own' => array( |
| 746 | 779 | 'post_reply_own' => 'can_reply', |
| 747 | 780 | 'delete_own' => 'can_delete', |
@@ -751,6 +784,7 @@ discard block |
||
| 751 | 784 | 'delete_any' => 'can_delete', |
| 752 | 785 | ) |
| 753 | 786 | ); |
| 787 | + } |
|
| 754 | 788 | |
| 755 | 789 | // For every permission in the own/any lists... |
| 756 | 790 | foreach ($permissions as $type => $list) |
@@ -761,19 +795,22 @@ discard block |
||
| 761 | 795 | $boards = boardsAllowedTo($permission); |
| 762 | 796 | |
| 763 | 797 | // Hmm, they can do it on all boards, can they? |
| 764 | - if (!empty($boards) && $boards[0] == 0) |
|
| 765 | - $boards = array_keys($board_ids[$type]); |
|
| 798 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 799 | + $boards = array_keys($board_ids[$type]); |
|
| 800 | + } |
|
| 766 | 801 | |
| 767 | 802 | // Now go through each board they can do the permission on. |
| 768 | 803 | foreach ($boards as $board_id) |
| 769 | 804 | { |
| 770 | 805 | // There aren't any posts displayed from this board. |
| 771 | - if (!isset($board_ids[$type][$board_id])) |
|
| 772 | - continue; |
|
| 806 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 807 | + continue; |
|
| 808 | + } |
|
| 773 | 809 | |
| 774 | 810 | // Set the permission to true ;). |
| 775 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 776 | - $context['posts'][$counter][$allowed] = true; |
|
| 811 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 812 | + $context['posts'][$counter][$allowed] = true; |
|
| 813 | + } |
|
| 777 | 814 | } |
| 778 | 815 | } |
| 779 | 816 | } |
@@ -804,8 +841,9 @@ discard block |
||
| 804 | 841 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
| 805 | 842 | |
| 806 | 843 | // Make sure we can't actually see anything... |
| 807 | - if (empty($boardsAllowed)) |
|
| 808 | - $boardsAllowed = array(-1); |
|
| 844 | + if (empty($boardsAllowed)) { |
|
| 845 | + $boardsAllowed = array(-1); |
|
| 846 | + } |
|
| 809 | 847 | |
| 810 | 848 | require_once($sourcedir . '/Subs-List.php'); |
| 811 | 849 | |
@@ -956,8 +994,8 @@ discard block |
||
| 956 | 994 | ) |
| 957 | 995 | ); |
| 958 | 996 | $attachments = array(); |
| 959 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 960 | - $attachments[] = array( |
|
| 997 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 998 | + $attachments[] = array( |
|
| 961 | 999 | 'id' => $row['id_attach'], |
| 962 | 1000 | 'filename' => $row['filename'], |
| 963 | 1001 | 'downloads' => $row['downloads'], |
@@ -969,6 +1007,7 @@ discard block |
||
| 969 | 1007 | 'board_name' => $row['name'], |
| 970 | 1008 | 'approved' => $row['approved'], |
| 971 | 1009 | ); |
| 1010 | + } |
|
| 972 | 1011 | |
| 973 | 1012 | $smcFunc['db_free_result']($request); |
| 974 | 1013 | |
@@ -1023,8 +1062,9 @@ discard block |
||
| 1023 | 1062 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
| 1024 | 1063 | |
| 1025 | 1064 | // Only the owner can see the list (if the function is enabled of course) |
| 1026 | - if ($user_info['id'] != $memID) |
|
| 1027 | - return; |
|
| 1065 | + if ($user_info['id'] != $memID) { |
|
| 1066 | + return; |
|
| 1067 | + } |
|
| 1028 | 1068 | |
| 1029 | 1069 | require_once($sourcedir . '/Subs-List.php'); |
| 1030 | 1070 | |
@@ -1170,8 +1210,9 @@ discard block |
||
| 1170 | 1210 | ); |
| 1171 | 1211 | |
| 1172 | 1212 | $topics = array(); |
| 1173 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1174 | - $topics[] = $row['id_topic']; |
|
| 1213 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1214 | + $topics[] = $row['id_topic']; |
|
| 1215 | + } |
|
| 1175 | 1216 | |
| 1176 | 1217 | $smcFunc['db_free_result']($request); |
| 1177 | 1218 | |
@@ -1191,8 +1232,9 @@ discard block |
||
| 1191 | 1232 | 'topics' => $topics, |
| 1192 | 1233 | ) |
| 1193 | 1234 | ); |
| 1194 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1195 | - $topicsInfo[] = $row; |
|
| 1235 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1236 | + $topicsInfo[] = $row; |
|
| 1237 | + } |
|
| 1196 | 1238 | $smcFunc['db_free_result']($request); |
| 1197 | 1239 | } |
| 1198 | 1240 | |
@@ -1240,8 +1282,9 @@ discard block |
||
| 1240 | 1282 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
| 1241 | 1283 | |
| 1242 | 1284 | // Is the load average too high to allow searching just now? |
| 1243 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
| 1244 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1285 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
| 1286 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1287 | + } |
|
| 1245 | 1288 | |
| 1246 | 1289 | // General user statistics. |
| 1247 | 1290 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1399,11 +1442,13 @@ discard block |
||
| 1399 | 1442 | } |
| 1400 | 1443 | $smcFunc['db_free_result']($result); |
| 1401 | 1444 | |
| 1402 | - if ($maxPosts > 0) |
|
| 1403 | - for ($hour = 0; $hour < 24; $hour++) |
|
| 1445 | + if ($maxPosts > 0) { |
|
| 1446 | + for ($hour = 0; |
|
| 1447 | + } |
|
| 1448 | + $hour < 24; $hour++) |
|
| 1404 | 1449 | { |
| 1405 | - if (!isset($context['posts_by_time'][$hour])) |
|
| 1406 | - $context['posts_by_time'][$hour] = array( |
|
| 1450 | + if (!isset($context['posts_by_time'][$hour])) { |
|
| 1451 | + $context['posts_by_time'][$hour] = array( |
|
| 1407 | 1452 | 'hour' => $hour, |
| 1408 | 1453 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
| 1409 | 1454 | 'posts' => 0, |
@@ -1411,7 +1456,7 @@ discard block |
||
| 1411 | 1456 | 'relative_percent' => 0, |
| 1412 | 1457 | 'is_last' => $hour == 23, |
| 1413 | 1458 | ); |
| 1414 | - else |
|
| 1459 | + } else |
|
| 1415 | 1460 | { |
| 1416 | 1461 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
| 1417 | 1462 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1444,8 +1489,9 @@ discard block |
||
| 1444 | 1489 | |
| 1445 | 1490 | foreach ($subActions as $sa => $action) |
| 1446 | 1491 | { |
| 1447 | - if (!allowedTo($action[2])) |
|
| 1448 | - unset($subActions[$sa]); |
|
| 1492 | + if (!allowedTo($action[2])) { |
|
| 1493 | + unset($subActions[$sa]); |
|
| 1494 | + } |
|
| 1449 | 1495 | } |
| 1450 | 1496 | |
| 1451 | 1497 | // Create the tabs for the template. |
@@ -1463,15 +1509,18 @@ discard block |
||
| 1463 | 1509 | ); |
| 1464 | 1510 | |
| 1465 | 1511 | // Moderation must be on to track edits. |
| 1466 | - if (empty($modSettings['userlog_enabled'])) |
|
| 1467 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1512 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 1513 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1514 | + } |
|
| 1468 | 1515 | |
| 1469 | 1516 | // Group requests must be active to show it... |
| 1470 | - if (empty($modSettings['show_group_membership'])) |
|
| 1471 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1517 | + if (empty($modSettings['show_group_membership'])) { |
|
| 1518 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1519 | + } |
|
| 1472 | 1520 | |
| 1473 | - if (empty($subActions)) |
|
| 1474 | - fatal_lang_error('no_access', false); |
|
| 1521 | + if (empty($subActions)) { |
|
| 1522 | + fatal_lang_error('no_access', false); |
|
| 1523 | + } |
|
| 1475 | 1524 | |
| 1476 | 1525 | $keys = array_keys($subActions); |
| 1477 | 1526 | $default = array_shift($keys); |
@@ -1484,9 +1533,10 @@ discard block |
||
| 1484 | 1533 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
| 1485 | 1534 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
| 1486 | 1535 | |
| 1487 | - if (!empty($call)) |
|
| 1488 | - call_user_func($call, $memID); |
|
| 1489 | -} |
|
| 1536 | + if (!empty($call)) { |
|
| 1537 | + call_user_func($call, $memID); |
|
| 1538 | + } |
|
| 1539 | + } |
|
| 1490 | 1540 | |
| 1491 | 1541 | /** |
| 1492 | 1542 | * Handles tracking a user's activity |
@@ -1502,8 +1552,9 @@ discard block |
||
| 1502 | 1552 | isAllowedTo('moderate_forum'); |
| 1503 | 1553 | |
| 1504 | 1554 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
| 1505 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
| 1506 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1555 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
| 1556 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1557 | + } |
|
| 1507 | 1558 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
| 1508 | 1559 | |
| 1509 | 1560 | // Set the options for the list component. |
@@ -1669,8 +1720,9 @@ discard block |
||
| 1669 | 1720 | ) |
| 1670 | 1721 | ); |
| 1671 | 1722 | $message_members = array(); |
| 1672 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1673 | - $message_members[] = $row['id_member']; |
|
| 1723 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1724 | + $message_members[] = $row['id_member']; |
|
| 1725 | + } |
|
| 1674 | 1726 | $smcFunc['db_free_result']($request); |
| 1675 | 1727 | |
| 1676 | 1728 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1685,8 +1737,9 @@ discard block |
||
| 1685 | 1737 | 'ip_list' => $ips, |
| 1686 | 1738 | ) |
| 1687 | 1739 | ); |
| 1688 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1689 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1740 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1741 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1742 | + } |
|
| 1690 | 1743 | $smcFunc['db_free_result']($request); |
| 1691 | 1744 | } |
| 1692 | 1745 | |
@@ -1700,8 +1753,9 @@ discard block |
||
| 1700 | 1753 | 'ip_list' => $ips, |
| 1701 | 1754 | ) |
| 1702 | 1755 | ); |
| 1703 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1704 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1756 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1757 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1758 | + } |
|
| 1705 | 1759 | $smcFunc['db_free_result']($request); |
| 1706 | 1760 | } |
| 1707 | 1761 | } |
@@ -1761,8 +1815,8 @@ discard block |
||
| 1761 | 1815 | )) |
| 1762 | 1816 | ); |
| 1763 | 1817 | $error_messages = array(); |
| 1764 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1765 | - $error_messages[] = array( |
|
| 1818 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1819 | + $error_messages[] = array( |
|
| 1766 | 1820 | 'ip' => inet_dtop($row['ip']), |
| 1767 | 1821 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
| 1768 | 1822 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1770,6 +1824,7 @@ discard block |
||
| 1770 | 1824 | 'time' => timeformat($row['log_time']), |
| 1771 | 1825 | 'timestamp' => forum_time(true, $row['log_time']), |
| 1772 | 1826 | ); |
| 1827 | + } |
|
| 1773 | 1828 | $smcFunc['db_free_result']($request); |
| 1774 | 1829 | |
| 1775 | 1830 | return $error_messages; |
@@ -1832,8 +1887,8 @@ discard block |
||
| 1832 | 1887 | )) |
| 1833 | 1888 | ); |
| 1834 | 1889 | $messages = array(); |
| 1835 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1836 | - $messages[] = array( |
|
| 1890 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1891 | + $messages[] = array( |
|
| 1837 | 1892 | 'ip' => inet_dtop($row['poster_ip']), |
| 1838 | 1893 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
| 1839 | 1894 | 'board' => array( |
@@ -1846,6 +1901,7 @@ discard block |
||
| 1846 | 1901 | 'time' => timeformat($row['poster_time']), |
| 1847 | 1902 | 'timestamp' => forum_time(true, $row['poster_time']) |
| 1848 | 1903 | ); |
| 1904 | + } |
|
| 1849 | 1905 | $smcFunc['db_free_result']($request); |
| 1850 | 1906 | |
| 1851 | 1907 | return $messages; |
@@ -1872,19 +1928,20 @@ discard block |
||
| 1872 | 1928 | $context['sub_template'] = 'trackIP'; |
| 1873 | 1929 | $context['page_title'] = $txt['profile']; |
| 1874 | 1930 | $context['base_url'] = $scripturl . '?action=trackip'; |
| 1875 | - } |
|
| 1876 | - else |
|
| 1931 | + } else |
|
| 1877 | 1932 | { |
| 1878 | 1933 | $context['ip'] = $user_profile[$memID]['member_ip']; |
| 1879 | 1934 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
| 1880 | 1935 | } |
| 1881 | 1936 | |
| 1882 | 1937 | // Searching? |
| 1883 | - if (isset($_REQUEST['searchip'])) |
|
| 1884 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1938 | + if (isset($_REQUEST['searchip'])) { |
|
| 1939 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1940 | + } |
|
| 1885 | 1941 | |
| 1886 | - if (isValidIP($context['ip']) === false) |
|
| 1887 | - fatal_lang_error('invalid_tracking_ip', false); |
|
| 1942 | + if (isValidIP($context['ip']) === false) { |
|
| 1943 | + fatal_lang_error('invalid_tracking_ip', false); |
|
| 1944 | + } |
|
| 1888 | 1945 | |
| 1889 | 1946 | //mysql didn't support like search with varbinary |
| 1890 | 1947 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1892,8 +1949,9 @@ discard block |
||
| 1892 | 1949 | $ip_var = $context['ip']; |
| 1893 | 1950 | $ip_string = '= {inet:ip_address}'; |
| 1894 | 1951 | |
| 1895 | - if (empty($context['tracking_area'])) |
|
| 1896 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1952 | + if (empty($context['tracking_area'])) { |
|
| 1953 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1954 | + } |
|
| 1897 | 1955 | |
| 1898 | 1956 | $request = $smcFunc['db_query']('', ' |
| 1899 | 1957 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1904,8 +1962,9 @@ discard block |
||
| 1904 | 1962 | ) |
| 1905 | 1963 | ); |
| 1906 | 1964 | $context['ips'] = array(); |
| 1907 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1908 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1965 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1966 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1967 | + } |
|
| 1909 | 1968 | $smcFunc['db_free_result']($request); |
| 1910 | 1969 | |
| 1911 | 1970 | ksort($context['ips']); |
@@ -2134,8 +2193,9 @@ discard block |
||
| 2134 | 2193 | foreach ($context['whois_servers'] as $whois) |
| 2135 | 2194 | { |
| 2136 | 2195 | // Strip off the "decimal point" and anything following... |
| 2137 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
| 2138 | - $context['auto_whois_server'] = $whois; |
|
| 2196 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
| 2197 | + $context['auto_whois_server'] = $whois; |
|
| 2198 | + } |
|
| 2139 | 2199 | } |
| 2140 | 2200 | } |
| 2141 | 2201 | } |
@@ -2152,10 +2212,11 @@ discard block |
||
| 2152 | 2212 | // Gonna want this for the list. |
| 2153 | 2213 | require_once($sourcedir . '/Subs-List.php'); |
| 2154 | 2214 | |
| 2155 | - if ($memID == 0) |
|
| 2156 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2157 | - else |
|
| 2158 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2215 | + if ($memID == 0) { |
|
| 2216 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2217 | + } else { |
|
| 2218 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2219 | + } |
|
| 2159 | 2220 | |
| 2160 | 2221 | // Start with the user messages. |
| 2161 | 2222 | $listOptions = array( |
@@ -2265,12 +2326,13 @@ discard block |
||
| 2265 | 2326 | ) |
| 2266 | 2327 | ); |
| 2267 | 2328 | $logins = array(); |
| 2268 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2269 | - $logins[] = array( |
|
| 2329 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2330 | + $logins[] = array( |
|
| 2270 | 2331 | 'time' => timeformat($row['time']), |
| 2271 | 2332 | 'ip' => inet_dtop($row['ip']), |
| 2272 | 2333 | 'ip2' => inet_dtop($row['ip2']), |
| 2273 | 2334 | ); |
| 2335 | + } |
|
| 2274 | 2336 | $smcFunc['db_free_result']($request); |
| 2275 | 2337 | |
| 2276 | 2338 | return $logins; |
@@ -2295,11 +2357,12 @@ discard block |
||
| 2295 | 2357 | ) |
| 2296 | 2358 | ); |
| 2297 | 2359 | $context['custom_field_titles'] = array(); |
| 2298 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2299 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2360 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2361 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2300 | 2362 | 'title' => $row['field_name'], |
| 2301 | 2363 | 'parse_bbc' => $row['bbc'], |
| 2302 | 2364 | ); |
| 2365 | + } |
|
| 2303 | 2366 | $smcFunc['db_free_result']($request); |
| 2304 | 2367 | |
| 2305 | 2368 | // Set the options for the error lists. |
@@ -2438,19 +2501,22 @@ discard block |
||
| 2438 | 2501 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2439 | 2502 | { |
| 2440 | 2503 | $extra = $smcFunc['json_decode']($row['extra'], true); |
| 2441 | - if (!empty($extra['applicator'])) |
|
| 2442 | - $members[] = $extra['applicator']; |
|
| 2504 | + if (!empty($extra['applicator'])) { |
|
| 2505 | + $members[] = $extra['applicator']; |
|
| 2506 | + } |
|
| 2443 | 2507 | |
| 2444 | 2508 | // Work out what the name of the action is. |
| 2445 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
| 2446 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2447 | - elseif (isset($txt[$row['action']])) |
|
| 2448 | - $action_text = $txt[$row['action']]; |
|
| 2509 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
| 2510 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2511 | + } elseif (isset($txt[$row['action']])) { |
|
| 2512 | + $action_text = $txt[$row['action']]; |
|
| 2513 | + } |
|
| 2449 | 2514 | // Custom field? |
| 2450 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
| 2451 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2452 | - else |
|
| 2453 | - $action_text = $row['action']; |
|
| 2515 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
| 2516 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2517 | + } else { |
|
| 2518 | + $action_text = $row['action']; |
|
| 2519 | + } |
|
| 2454 | 2520 | |
| 2455 | 2521 | // Parse BBC? |
| 2456 | 2522 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2482,13 +2548,15 @@ discard block |
||
| 2482 | 2548 | ) |
| 2483 | 2549 | ); |
| 2484 | 2550 | $members = array(); |
| 2485 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2486 | - $members[$row['id_member']] = $row['real_name']; |
|
| 2551 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2552 | + $members[$row['id_member']] = $row['real_name']; |
|
| 2553 | + } |
|
| 2487 | 2554 | $smcFunc['db_free_result']($request); |
| 2488 | 2555 | |
| 2489 | - foreach ($edits as $key => $value) |
|
| 2490 | - if (isset($members[$value['id_member']])) |
|
| 2556 | + foreach ($edits as $key => $value) { |
|
| 2557 | + if (isset($members[$value['id_member']])) |
|
| 2491 | 2558 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
| 2559 | + } |
|
| 2492 | 2560 | } |
| 2493 | 2561 | |
| 2494 | 2562 | return $edits; |
@@ -2689,10 +2757,11 @@ discard block |
||
| 2689 | 2757 | $context['board'] = $board; |
| 2690 | 2758 | |
| 2691 | 2759 | // Determine which groups this user is in. |
| 2692 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
| 2693 | - $curGroups = array(); |
|
| 2694 | - else |
|
| 2695 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2760 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
| 2761 | + $curGroups = array(); |
|
| 2762 | + } else { |
|
| 2763 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2764 | + } |
|
| 2696 | 2765 | $curGroups[] = $user_profile[$memID]['id_group']; |
| 2697 | 2766 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
| 2698 | 2767 | |
@@ -2712,28 +2781,30 @@ discard block |
||
| 2712 | 2781 | $context['no_access_boards'] = array(); |
| 2713 | 2782 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2714 | 2783 | { |
| 2715 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
| 2716 | - $context['no_access_boards'][] = array( |
|
| 2784 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
| 2785 | + $context['no_access_boards'][] = array( |
|
| 2717 | 2786 | 'id' => $row['id_board'], |
| 2718 | 2787 | 'name' => $row['name'], |
| 2719 | 2788 | 'is_last' => false, |
| 2720 | 2789 | ); |
| 2721 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
| 2722 | - $context['boards'][$row['id_board']] = array( |
|
| 2790 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
| 2791 | + $context['boards'][$row['id_board']] = array( |
|
| 2723 | 2792 | 'id' => $row['id_board'], |
| 2724 | 2793 | 'name' => $row['name'], |
| 2725 | 2794 | 'selected' => $board == $row['id_board'], |
| 2726 | 2795 | 'profile' => $row['id_profile'], |
| 2727 | 2796 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
| 2728 | 2797 | ); |
| 2798 | + } |
|
| 2729 | 2799 | } |
| 2730 | 2800 | $smcFunc['db_free_result']($request); |
| 2731 | 2801 | |
| 2732 | 2802 | require_once($sourcedir . '/Subs-Boards.php'); |
| 2733 | 2803 | sortBoards($context['boards']); |
| 2734 | 2804 | |
| 2735 | - if (!empty($context['no_access_boards'])) |
|
| 2736 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2805 | + if (!empty($context['no_access_boards'])) { |
|
| 2806 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2807 | + } |
|
| 2737 | 2808 | |
| 2738 | 2809 | $context['member']['permissions'] = array( |
| 2739 | 2810 | 'general' => array(), |
@@ -2742,8 +2813,9 @@ discard block |
||
| 2742 | 2813 | |
| 2743 | 2814 | // If you're an admin we know you can do everything, we might as well leave. |
| 2744 | 2815 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
| 2745 | - if ($context['member']['has_all_permissions']) |
|
| 2746 | - return; |
|
| 2816 | + if ($context['member']['has_all_permissions']) { |
|
| 2817 | + return; |
|
| 2818 | + } |
|
| 2747 | 2819 | |
| 2748 | 2820 | $denied = array(); |
| 2749 | 2821 | |
@@ -2762,21 +2834,24 @@ discard block |
||
| 2762 | 2834 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2763 | 2835 | { |
| 2764 | 2836 | // We don't know about this permission, it doesn't exist :P. |
| 2765 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2766 | - continue; |
|
| 2837 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2838 | + continue; |
|
| 2839 | + } |
|
| 2767 | 2840 | |
| 2768 | - if (empty($row['add_deny'])) |
|
| 2769 | - $denied[] = $row['permission']; |
|
| 2841 | + if (empty($row['add_deny'])) { |
|
| 2842 | + $denied[] = $row['permission']; |
|
| 2843 | + } |
|
| 2770 | 2844 | |
| 2771 | 2845 | // Permissions that end with _own or _any consist of two parts. |
| 2772 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2773 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2774 | - else |
|
| 2775 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2846 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2847 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2848 | + } else { |
|
| 2849 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2850 | + } |
|
| 2776 | 2851 | |
| 2777 | 2852 | // Add this permission if it doesn't exist yet. |
| 2778 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
| 2779 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2853 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
| 2854 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2780 | 2855 | 'id' => $row['permission'], |
| 2781 | 2856 | 'groups' => array( |
| 2782 | 2857 | 'allowed' => array(), |
@@ -2786,6 +2861,7 @@ discard block |
||
| 2786 | 2861 | 'is_denied' => false, |
| 2787 | 2862 | 'is_global' => true, |
| 2788 | 2863 | ); |
| 2864 | + } |
|
| 2789 | 2865 | |
| 2790 | 2866 | // Add the membergroup to either the denied or the allowed groups. |
| 2791 | 2867 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2819,18 +2895,20 @@ discard block |
||
| 2819 | 2895 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2820 | 2896 | { |
| 2821 | 2897 | // We don't know about this permission, it doesn't exist :P. |
| 2822 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2823 | - continue; |
|
| 2898 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2899 | + continue; |
|
| 2900 | + } |
|
| 2824 | 2901 | |
| 2825 | 2902 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
| 2826 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2827 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2828 | - else |
|
| 2829 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2903 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2904 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2905 | + } else { |
|
| 2906 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2907 | + } |
|
| 2830 | 2908 | |
| 2831 | 2909 | // Create the structure for this permission. |
| 2832 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
| 2833 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2910 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
| 2911 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2834 | 2912 | 'id' => $row['permission'], |
| 2835 | 2913 | 'groups' => array( |
| 2836 | 2914 | 'allowed' => array(), |
@@ -2840,6 +2918,7 @@ discard block |
||
| 2840 | 2918 | 'is_denied' => false, |
| 2841 | 2919 | 'is_global' => empty($board), |
| 2842 | 2920 | ); |
| 2921 | + } |
|
| 2843 | 2922 | |
| 2844 | 2923 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
| 2845 | 2924 | |
@@ -2858,8 +2937,9 @@ discard block |
||
| 2858 | 2937 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
| 2859 | 2938 | |
| 2860 | 2939 | // Firstly, can we actually even be here? |
| 2861 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
| 2862 | - fatal_lang_error('no_access', false); |
|
| 2940 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
| 2941 | + fatal_lang_error('no_access', false); |
|
| 2942 | + } |
|
| 2863 | 2943 | |
| 2864 | 2944 | // Make sure things which are disabled stay disabled. |
| 2865 | 2945 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2946,9 +3026,10 @@ discard block |
||
| 2946 | 3026 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
| 2947 | 3027 | ); |
| 2948 | 3028 | $context['current_level'] = 0; |
| 2949 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
| 2950 | - if ($context['member']['warning'] >= $limit) |
|
| 3029 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
| 3030 | + if ($context['member']['warning'] >= $limit) |
|
| 2951 | 3031 | $context['current_level'] = $limit; |
| 2952 | -} |
|
| 3032 | + } |
|
| 3033 | + } |
|
| 2953 | 3034 | |
| 2954 | 3035 | ?> |
| 2955 | 3036 | \ No newline at end of file |