@@ -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 | |
@@ -142,10 +144,11 @@ discard block |
||
| 142 | 144 | |
| 143 | 145 | // If no cert, force_ssl must remain 0 |
| 144 | 146 | require_once($sourcedir . '/Subs.php'); |
| 145 | - if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl'])) |
|
| 146 | - $disable_force_ssl = true; |
|
| 147 | - else |
|
| 148 | - $disable_force_ssl = false; |
|
| 147 | + if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl'])) { |
|
| 148 | + $disable_force_ssl = true; |
|
| 149 | + } else { |
|
| 150 | + $disable_force_ssl = false; |
|
| 151 | + } |
|
| 149 | 152 | |
| 150 | 153 | /* If you're writing a mod, it's a bad idea to add things here.... |
| 151 | 154 | For each option: |
@@ -175,8 +178,9 @@ discard block |
||
| 175 | 178 | |
| 176 | 179 | call_integration_hook('integrate_general_settings', array(&$config_vars)); |
| 177 | 180 | |
| 178 | - if ($return_config) |
|
| 179 | - return $config_vars; |
|
| 181 | + if ($return_config) { |
|
| 182 | + return $config_vars; |
|
| 183 | + } |
|
| 180 | 184 | |
| 181 | 185 | // Setup the template stuff. |
| 182 | 186 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save'; |
@@ -193,16 +197,18 @@ discard block |
||
| 193 | 197 | $registerSMStats = registerSMStats(); |
| 194 | 198 | |
| 195 | 199 | // Failed to register, disable it again. |
| 196 | - if (empty($registerSMStats)) |
|
| 197 | - $_POST['enable_sm_stats'] = 0; |
|
| 200 | + if (empty($registerSMStats)) { |
|
| 201 | + $_POST['enable_sm_stats'] = 0; |
|
| 202 | + } |
|
| 198 | 203 | } |
| 199 | 204 | |
| 200 | 205 | // Ensure all URLs are aligned with the new force_ssl setting |
| 201 | 206 | // Treat unset like 0 |
| 202 | - if (isset($_POST['force_ssl'])) |
|
| 203 | - AlignURLsWithSSLSetting($_POST['force_ssl']); |
|
| 204 | - else |
|
| 205 | - AlignURLsWithSSLSetting(0); |
|
| 207 | + if (isset($_POST['force_ssl'])) { |
|
| 208 | + AlignURLsWithSSLSetting($_POST['force_ssl']); |
|
| 209 | + } else { |
|
| 210 | + AlignURLsWithSSLSetting(0); |
|
| 211 | + } |
|
| 206 | 212 | |
| 207 | 213 | saveSettings($config_vars); |
| 208 | 214 | $_SESSION['adm-save'] = true; |
@@ -255,10 +261,11 @@ discard block |
||
| 255 | 261 | require_once($sourcedir . '/Subs-Admin.php'); |
| 256 | 262 | |
| 257 | 263 | // Check $boardurl |
| 258 | - if ($new_force_ssl == 2) |
|
| 259 | - $newval = strtr($boardurl, array('http://' => 'https://')); |
|
| 260 | - else |
|
| 261 | - $newval = strtr($boardurl, array('https://' => 'http://')); |
|
| 264 | + if ($new_force_ssl == 2) { |
|
| 265 | + $newval = strtr($boardurl, array('http://' => 'https://')); |
|
| 266 | + } else { |
|
| 267 | + $newval = strtr($boardurl, array('https://' => 'http://')); |
|
| 268 | + } |
|
| 262 | 269 | updateSettingsFile(array('boardurl' => '\'' . addslashes($newval) . '\'')); |
| 263 | 270 | |
| 264 | 271 | $new_settings = array(); |
@@ -266,20 +273,22 @@ discard block |
||
| 266 | 273 | // Check $smileys_url, but only if it points to a subfolder of $boardurl |
| 267 | 274 | if (BoardurlMatch($modSettings['smileys_url'])) |
| 268 | 275 | { |
| 269 | - if ($new_force_ssl == 2) |
|
| 270 | - $newval = strtr($modSettings['smileys_url'], array('http://' => 'https://')); |
|
| 271 | - else |
|
| 272 | - $newval = strtr($modSettings['smileys_url'], array('https://' => 'http://')); |
|
| 276 | + if ($new_force_ssl == 2) { |
|
| 277 | + $newval = strtr($modSettings['smileys_url'], array('http://' => 'https://')); |
|
| 278 | + } else { |
|
| 279 | + $newval = strtr($modSettings['smileys_url'], array('https://' => 'http://')); |
|
| 280 | + } |
|
| 273 | 281 | $new_settings['smileys_url'] = $newval; |
| 274 | 282 | } |
| 275 | 283 | |
| 276 | 284 | // Check $avatar_url, but only if it points to a subfolder of $boardurl |
| 277 | 285 | if (BoardurlMatch($modSettings['avatar_url'])) |
| 278 | 286 | { |
| 279 | - if ($new_force_ssl == 2) |
|
| 280 | - $newval = strtr($modSettings['avatar_url'], array('http://' => 'https://')); |
|
| 281 | - else |
|
| 282 | - $newval = strtr($modSettings['avatar_url'], array('https://' => 'http://')); |
|
| 287 | + if ($new_force_ssl == 2) { |
|
| 288 | + $newval = strtr($modSettings['avatar_url'], array('http://' => 'https://')); |
|
| 289 | + } else { |
|
| 290 | + $newval = strtr($modSettings['avatar_url'], array('https://' => 'http://')); |
|
| 291 | + } |
|
| 283 | 292 | $new_settings['avatar_url'] = $newval; |
| 284 | 293 | } |
| 285 | 294 | |
@@ -287,16 +296,18 @@ discard block |
||
| 287 | 296 | // This one had been optional in the past, make sure it is set first |
| 288 | 297 | if (isset($modSettings['custom_avatar_url']) && BoardurlMatch($modSettings['custom_avatar_url'])) |
| 289 | 298 | { |
| 290 | - if ($new_force_ssl == 2) |
|
| 291 | - $newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://')); |
|
| 292 | - else |
|
| 293 | - $newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://')); |
|
| 299 | + if ($new_force_ssl == 2) { |
|
| 300 | + $newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://')); |
|
| 301 | + } else { |
|
| 302 | + $newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://')); |
|
| 303 | + } |
|
| 294 | 304 | $new_settings['custom_avatar_url'] = $newval; |
| 295 | 305 | } |
| 296 | 306 | |
| 297 | 307 | // Save updates to the settings table |
| 298 | - if (!empty($new_settings)) |
|
| 299 | - updateSettings($new_settings, true); |
|
| 308 | + if (!empty($new_settings)) { |
|
| 309 | + updateSettings($new_settings, true); |
|
| 310 | + } |
|
| 300 | 311 | |
| 301 | 312 | // Now we move onto the themes. |
| 302 | 313 | // First, get a list of theme URLs... |
@@ -317,10 +328,11 @@ discard block |
||
| 317 | 328 | // First check to see if it points to a subfolder of $boardurl |
| 318 | 329 | if (BoardurlMatch($row['value'])) |
| 319 | 330 | { |
| 320 | - if ($new_force_ssl == 2) |
|
| 321 | - $newval = strtr($row['value'], array('http://' => 'https://')); |
|
| 322 | - else |
|
| 323 | - $newval = strtr($row['value'], array('https://' => 'http://')); |
|
| 331 | + if ($new_force_ssl == 2) { |
|
| 332 | + $newval = strtr($row['value'], array('http://' => 'https://')); |
|
| 333 | + } else { |
|
| 334 | + $newval = strtr($row['value'], array('https://' => 'http://')); |
|
| 335 | + } |
|
| 324 | 336 | $smcFunc['db_query']('', ' |
| 325 | 337 | UPDATE {db_prefix}themes |
| 326 | 338 | SET value = {string:theme_val} |
@@ -360,11 +372,12 @@ discard block |
||
| 360 | 372 | |
| 361 | 373 | // If leftmost portion of path matches boardurl, return true |
| 362 | 374 | $result = strpos($urlpath, $boardurlpath); |
| 363 | - if ($result === false || $result != 0) |
|
| 364 | - return false; |
|
| 365 | - else |
|
| 366 | - return true; |
|
| 367 | -} |
|
| 375 | + if ($result === false || $result != 0) { |
|
| 376 | + return false; |
|
| 377 | + } else { |
|
| 378 | + return true; |
|
| 379 | + } |
|
| 380 | + } |
|
| 368 | 381 | |
| 369 | 382 | /** |
| 370 | 383 | * Basic database and paths settings - database name, host, etc. |
@@ -402,8 +415,9 @@ discard block |
||
| 402 | 415 | $request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array()); |
| 403 | 416 | $fts_language = array(); |
| 404 | 417 | |
| 405 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 406 | - $fts_language[$row['cfgname']] = $row['cfgname']; |
|
| 418 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 419 | + $fts_language[$row['cfgname']] = $row['cfgname']; |
|
| 420 | + } |
|
| 407 | 421 | |
| 408 | 422 | $config_vars = array_merge ($config_vars, array( |
| 409 | 423 | '', |
@@ -415,8 +429,9 @@ discard block |
||
| 415 | 429 | |
| 416 | 430 | call_integration_hook('integrate_database_settings', array(&$config_vars)); |
| 417 | 431 | |
| 418 | - if ($return_config) |
|
| 419 | - return $config_vars; |
|
| 432 | + if ($return_config) { |
|
| 433 | + return $config_vars; |
|
| 434 | + } |
|
| 420 | 435 | |
| 421 | 436 | // Setup the template stuff. |
| 422 | 437 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save'; |
@@ -491,13 +506,15 @@ discard block |
||
| 491 | 506 | hideGlobalCookies(); |
| 492 | 507 | });', true); |
| 493 | 508 | |
| 494 | - if (empty($user_settings['tfa_secret'])) |
|
| 495 | - addInlineJavaScript(''); |
|
| 509 | + if (empty($user_settings['tfa_secret'])) { |
|
| 510 | + addInlineJavaScript(''); |
|
| 511 | + } |
|
| 496 | 512 | |
| 497 | 513 | call_integration_hook('integrate_cookie_settings', array(&$config_vars)); |
| 498 | 514 | |
| 499 | - if ($return_config) |
|
| 500 | - return $config_vars; |
|
| 515 | + if ($return_config) { |
|
| 516 | + return $config_vars; |
|
| 517 | + } |
|
| 501 | 518 | |
| 502 | 519 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save'; |
| 503 | 520 | $context['settings_title'] = $txt['cookies_sessions_settings']; |
@@ -508,11 +525,13 @@ discard block |
||
| 508 | 525 | call_integration_hook('integrate_save_cookie_settings'); |
| 509 | 526 | |
| 510 | 527 | // Local and global do not play nicely together. |
| 511 | - if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) |
|
| 512 | - unset ($_POST['globalCookies']); |
|
| 528 | + if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) { |
|
| 529 | + unset ($_POST['globalCookies']); |
|
| 530 | + } |
|
| 513 | 531 | |
| 514 | - if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) |
|
| 515 | - fatal_lang_error('invalid_cookie_domain', false); |
|
| 532 | + if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) { |
|
| 533 | + fatal_lang_error('invalid_cookie_domain', false); |
|
| 534 | + } |
|
| 516 | 535 | |
| 517 | 536 | saveSettings($config_vars); |
| 518 | 537 | |
@@ -595,8 +614,9 @@ discard block |
||
| 595 | 614 | |
| 596 | 615 | call_integration_hook('integrate_general_security_settings', array(&$config_vars)); |
| 597 | 616 | |
| 598 | - if ($return_config) |
|
| 599 | - return $config_vars; |
|
| 617 | + if ($return_config) { |
|
| 618 | + return $config_vars; |
|
| 619 | + } |
|
| 600 | 620 | |
| 601 | 621 | // Saving? |
| 602 | 622 | if (isset($_GET['save'])) |
@@ -635,8 +655,7 @@ discard block |
||
| 635 | 655 | $txt['cache_settings_message'] = $txt['detected_no_caching']; |
| 636 | 656 | $cache_level = array($txt['cache_off']); |
| 637 | 657 | $detected['none'] = $txt['cache_off']; |
| 638 | - } |
|
| 639 | - else |
|
| 658 | + } else |
|
| 640 | 659 | { |
| 641 | 660 | $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected)); |
| 642 | 661 | $cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']); |
@@ -673,8 +692,9 @@ discard block |
||
| 673 | 692 | } |
| 674 | 693 | } |
| 675 | 694 | } |
| 676 | - if ($return_config) |
|
| 677 | - return $config_vars; |
|
| 695 | + if ($return_config) { |
|
| 696 | + return $config_vars; |
|
| 697 | + } |
|
| 678 | 698 | |
| 679 | 699 | // Saving again? |
| 680 | 700 | if (isset($_GET['save'])) |
@@ -702,8 +722,9 @@ discard block |
||
| 702 | 722 | $context['save_disabled'] = $context['settings_not_writable']; |
| 703 | 723 | |
| 704 | 724 | // Decide what message to show. |
| 705 | - if (!$context['save_disabled']) |
|
| 706 | - $context['settings_message'] = $txt['caching_information']; |
|
| 725 | + if (!$context['save_disabled']) { |
|
| 726 | + $context['settings_message'] = $txt['caching_information']; |
|
| 727 | + } |
|
| 707 | 728 | |
| 708 | 729 | // Prepare the template. |
| 709 | 730 | prepareServerSettingsContext($config_vars); |
@@ -726,24 +747,25 @@ discard block |
||
| 726 | 747 | if (stripos(PHP_OS, 'win') === 0) |
| 727 | 748 | { |
| 728 | 749 | $context['settings_message'] = $txt['loadavg_disabled_windows']; |
| 729 | - if (isset($_GET['save'])) |
|
| 730 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
| 731 | - } |
|
| 732 | - elseif (stripos(PHP_OS, 'darwin') === 0) |
|
| 750 | + if (isset($_GET['save'])) { |
|
| 751 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
| 752 | + } |
|
| 753 | + } elseif (stripos(PHP_OS, 'darwin') === 0) |
|
| 733 | 754 | { |
| 734 | 755 | $context['settings_message'] = $txt['loadavg_disabled_osx']; |
| 735 | - if (isset($_GET['save'])) |
|
| 736 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
| 737 | - } |
|
| 738 | - else |
|
| 756 | + if (isset($_GET['save'])) { |
|
| 757 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
| 758 | + } |
|
| 759 | + } else |
|
| 739 | 760 | { |
| 740 | 761 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 741 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) |
|
| 742 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 743 | - elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) |
|
| 744 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 745 | - else |
|
| 746 | - unset($modSettings['load_average']); |
|
| 762 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) { |
|
| 763 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 764 | + } elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) { |
|
| 765 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 766 | + } else { |
|
| 767 | + unset($modSettings['load_average']); |
|
| 768 | + } |
|
| 747 | 769 | |
| 748 | 770 | if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
| 749 | 771 | { |
@@ -779,8 +801,9 @@ discard block |
||
| 779 | 801 | |
| 780 | 802 | call_integration_hook('integrate_loadavg_settings', array(&$config_vars)); |
| 781 | 803 | |
| 782 | - if ($return_config) |
|
| 783 | - return $config_vars; |
|
| 804 | + if ($return_config) { |
|
| 805 | + return $config_vars; |
|
| 806 | + } |
|
| 784 | 807 | |
| 785 | 808 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save'; |
| 786 | 809 | $context['settings_title'] = $txt['load_balancing_settings']; |
@@ -791,24 +814,27 @@ discard block |
||
| 791 | 814 | // Stupidity is not allowed. |
| 792 | 815 | foreach ($_POST as $key => $value) |
| 793 | 816 | { |
| 794 | - if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) |
|
| 795 | - continue; |
|
| 796 | - else |
|
| 797 | - $_POST[$key] = (float) $value; |
|
| 798 | - |
|
| 799 | - if ($key == 'loadavg_auto_opt' && $value <= 1) |
|
| 800 | - $_POST['loadavg_auto_opt'] = 1.0; |
|
| 801 | - elseif ($key == 'loadavg_forum' && $value < 10) |
|
| 802 | - $_POST['loadavg_forum'] = 10.0; |
|
| 803 | - elseif ($value < 2) |
|
| 804 | - $_POST[$key] = 2.0; |
|
| 817 | + if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) { |
|
| 818 | + continue; |
|
| 819 | + } else { |
|
| 820 | + $_POST[$key] = (float) $value; |
|
| 821 | + } |
|
| 822 | + |
|
| 823 | + if ($key == 'loadavg_auto_opt' && $value <= 1) { |
|
| 824 | + $_POST['loadavg_auto_opt'] = 1.0; |
|
| 825 | + } elseif ($key == 'loadavg_forum' && $value < 10) { |
|
| 826 | + $_POST['loadavg_forum'] = 10.0; |
|
| 827 | + } elseif ($value < 2) { |
|
| 828 | + $_POST[$key] = 2.0; |
|
| 829 | + } |
|
| 805 | 830 | } |
| 806 | 831 | |
| 807 | 832 | call_integration_hook('integrate_save_loadavg_settings'); |
| 808 | 833 | |
| 809 | 834 | saveDBSettings($config_vars); |
| 810 | - if (!isset($_SESSION['adm-save'])) |
|
| 811 | - $_SESSION['adm-save'] = true; |
|
| 835 | + if (!isset($_SESSION['adm-save'])) { |
|
| 836 | + $_SESSION['adm-save'] = true; |
|
| 837 | + } |
|
| 812 | 838 | redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']); |
| 813 | 839 | } |
| 814 | 840 | |
@@ -844,10 +870,11 @@ discard block |
||
| 844 | 870 | |
| 845 | 871 | if (isset($_SESSION['adm-save'])) |
| 846 | 872 | { |
| 847 | - if ($_SESSION['adm-save'] === true) |
|
| 848 | - $context['saved_successful'] = true; |
|
| 849 | - else |
|
| 850 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 873 | + if ($_SESSION['adm-save'] === true) { |
|
| 874 | + $context['saved_successful'] = true; |
|
| 875 | + } else { |
|
| 876 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 877 | + } |
|
| 851 | 878 | |
| 852 | 879 | unset($_SESSION['adm-save']); |
| 853 | 880 | } |
@@ -855,9 +882,9 @@ discard block |
||
| 855 | 882 | $context['config_vars'] = array(); |
| 856 | 883 | foreach ($config_vars as $identifier => $config_var) |
| 857 | 884 | { |
| 858 | - if (!is_array($config_var) || !isset($config_var[1])) |
|
| 859 | - $context['config_vars'][] = $config_var; |
|
| 860 | - else |
|
| 885 | + if (!is_array($config_var) || !isset($config_var[1])) { |
|
| 886 | + $context['config_vars'][] = $config_var; |
|
| 887 | + } else |
|
| 861 | 888 | { |
| 862 | 889 | $varname = $config_var[0]; |
| 863 | 890 | global $$varname; |
@@ -892,16 +919,19 @@ discard block |
||
| 892 | 919 | if ($config_var[3] == 'int' || $config_var[3] == 'float') |
| 893 | 920 | { |
| 894 | 921 | // Default to a min of 0 if one isn't set |
| 895 | - if (isset($config_var['min'])) |
|
| 896 | - $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
| 897 | - else |
|
| 898 | - $context['config_vars'][$config_var[0]]['min'] = 0; |
|
| 922 | + if (isset($config_var['min'])) { |
|
| 923 | + $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
| 924 | + } else { |
|
| 925 | + $context['config_vars'][$config_var[0]]['min'] = 0; |
|
| 926 | + } |
|
| 899 | 927 | |
| 900 | - if (isset($config_var['max'])) |
|
| 901 | - $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
| 928 | + if (isset($config_var['max'])) { |
|
| 929 | + $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
| 930 | + } |
|
| 902 | 931 | |
| 903 | - if (isset($config_var['step'])) |
|
| 904 | - $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
| 932 | + if (isset($config_var['step'])) { |
|
| 933 | + $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
| 934 | + } |
|
| 905 | 935 | } |
| 906 | 936 | |
| 907 | 937 | // If this is a select box handle any data. |
@@ -909,12 +939,13 @@ discard block |
||
| 909 | 939 | { |
| 910 | 940 | // If it's associative |
| 911 | 941 | $config_values = array_values($config_var[4]); |
| 912 | - if (isset($config_values[0]) && is_array($config_values[0])) |
|
| 913 | - $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
| 914 | - else |
|
| 942 | + if (isset($config_values[0]) && is_array($config_values[0])) { |
|
| 943 | + $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
| 944 | + } else |
|
| 915 | 945 | { |
| 916 | - foreach ($config_var[4] as $key => $item) |
|
| 917 | - $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
| 946 | + foreach ($config_var[4] as $key => $item) { |
|
| 947 | + $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
| 948 | + } |
|
| 918 | 949 | } |
| 919 | 950 | } |
| 920 | 951 | } |
@@ -939,10 +970,11 @@ discard block |
||
| 939 | 970 | |
| 940 | 971 | if (isset($_SESSION['adm-save'])) |
| 941 | 972 | { |
| 942 | - if ($_SESSION['adm-save'] === true) |
|
| 943 | - $context['saved_successful'] = true; |
|
| 944 | - else |
|
| 945 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 973 | + if ($_SESSION['adm-save'] === true) { |
|
| 974 | + $context['saved_successful'] = true; |
|
| 975 | + } else { |
|
| 976 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 977 | + } |
|
| 946 | 978 | |
| 947 | 979 | unset($_SESSION['adm-save']); |
| 948 | 980 | } |
@@ -954,26 +986,30 @@ discard block |
||
| 954 | 986 | foreach ($config_vars as $config_var) |
| 955 | 987 | { |
| 956 | 988 | // HR? |
| 957 | - if (!is_array($config_var)) |
|
| 958 | - $context['config_vars'][] = $config_var; |
|
| 959 | - else |
|
| 989 | + if (!is_array($config_var)) { |
|
| 990 | + $context['config_vars'][] = $config_var; |
|
| 991 | + } else |
|
| 960 | 992 | { |
| 961 | 993 | // If it has no name it doesn't have any purpose! |
| 962 | - if (empty($config_var[1])) |
|
| 963 | - continue; |
|
| 994 | + if (empty($config_var[1])) { |
|
| 995 | + continue; |
|
| 996 | + } |
|
| 964 | 997 | |
| 965 | 998 | // Special case for inline permissions |
| 966 | - if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) |
|
| 967 | - $inlinePermissions[] = $config_var[1]; |
|
| 968 | - elseif ($config_var[0] == 'permissions') |
|
| 969 | - continue; |
|
| 999 | + if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) { |
|
| 1000 | + $inlinePermissions[] = $config_var[1]; |
|
| 1001 | + } elseif ($config_var[0] == 'permissions') { |
|
| 1002 | + continue; |
|
| 1003 | + } |
|
| 970 | 1004 | |
| 971 | - if ($config_var[0] == 'boards') |
|
| 972 | - $board_list = true; |
|
| 1005 | + if ($config_var[0] == 'boards') { |
|
| 1006 | + $board_list = true; |
|
| 1007 | + } |
|
| 973 | 1008 | |
| 974 | 1009 | // Are we showing the BBC selection box? |
| 975 | - if ($config_var[0] == 'bbc') |
|
| 976 | - $bbcChoice[] = $config_var[1]; |
|
| 1010 | + if ($config_var[0] == 'bbc') { |
|
| 1011 | + $bbcChoice[] = $config_var[1]; |
|
| 1012 | + } |
|
| 977 | 1013 | |
| 978 | 1014 | // We need to do some parsing of the value before we pass it in. |
| 979 | 1015 | if (isset($modSettings[$config_var[1]])) |
@@ -992,8 +1028,7 @@ discard block |
||
| 992 | 1028 | default: |
| 993 | 1029 | $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]); |
| 994 | 1030 | } |
| 995 | - } |
|
| 996 | - else |
|
| 1031 | + } else |
|
| 997 | 1032 | { |
| 998 | 1033 | // Darn, it's empty. What type is expected? |
| 999 | 1034 | switch ($config_var[0]) |
@@ -1033,16 +1068,19 @@ discard block |
||
| 1033 | 1068 | if ($config_var[0] == 'int' || $config_var[0] == 'float') |
| 1034 | 1069 | { |
| 1035 | 1070 | // Default to a min of 0 if one isn't set |
| 1036 | - if (isset($config_var['min'])) |
|
| 1037 | - $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
| 1038 | - else |
|
| 1039 | - $context['config_vars'][$config_var[1]]['min'] = 0; |
|
| 1071 | + if (isset($config_var['min'])) { |
|
| 1072 | + $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
| 1073 | + } else { |
|
| 1074 | + $context['config_vars'][$config_var[1]]['min'] = 0; |
|
| 1075 | + } |
|
| 1040 | 1076 | |
| 1041 | - if (isset($config_var['max'])) |
|
| 1042 | - $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
| 1077 | + if (isset($config_var['max'])) { |
|
| 1078 | + $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
| 1079 | + } |
|
| 1043 | 1080 | |
| 1044 | - if (isset($config_var['step'])) |
|
| 1045 | - $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
| 1081 | + if (isset($config_var['step'])) { |
|
| 1082 | + $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
| 1083 | + } |
|
| 1046 | 1084 | } |
| 1047 | 1085 | |
| 1048 | 1086 | // If this is a select box handle any data. |
@@ -1056,12 +1094,13 @@ discard block |
||
| 1056 | 1094 | } |
| 1057 | 1095 | |
| 1058 | 1096 | // If it's associative |
| 1059 | - if (isset($config_var[2][0]) && is_array($config_var[2][0])) |
|
| 1060 | - $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
| 1061 | - else |
|
| 1097 | + if (isset($config_var[2][0]) && is_array($config_var[2][0])) { |
|
| 1098 | + $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
| 1099 | + } else |
|
| 1062 | 1100 | { |
| 1063 | - foreach ($config_var[2] as $key => $item) |
|
| 1064 | - $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
| 1101 | + foreach ($config_var[2] as $key => $item) { |
|
| 1102 | + $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
| 1103 | + } |
|
| 1065 | 1104 | } |
| 1066 | 1105 | } |
| 1067 | 1106 | |
@@ -1070,17 +1109,19 @@ discard block |
||
| 1070 | 1109 | { |
| 1071 | 1110 | if (!is_numeric($k)) |
| 1072 | 1111 | { |
| 1073 | - if (substr($k, 0, 2) == 'on') |
|
| 1074 | - $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
| 1075 | - else |
|
| 1076 | - $context['config_vars'][$config_var[1]][$k] = $v; |
|
| 1112 | + if (substr($k, 0, 2) == 'on') { |
|
| 1113 | + $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
| 1114 | + } else { |
|
| 1115 | + $context['config_vars'][$config_var[1]][$k] = $v; |
|
| 1116 | + } |
|
| 1077 | 1117 | } |
| 1078 | 1118 | |
| 1079 | 1119 | // See if there are any other labels that might fit? |
| 1080 | - if (isset($txt['setting_' . $config_var[1]])) |
|
| 1081 | - $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
| 1082 | - elseif (isset($txt['groups_' . $config_var[1]])) |
|
| 1083 | - $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
| 1120 | + if (isset($txt['setting_' . $config_var[1]])) { |
|
| 1121 | + $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
| 1122 | + } elseif (isset($txt['groups_' . $config_var[1]])) { |
|
| 1123 | + $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
| 1124 | + } |
|
| 1084 | 1125 | } |
| 1085 | 1126 | |
| 1086 | 1127 | // Set the subtext in case it's part of the label. |
@@ -1113,8 +1154,9 @@ discard block |
||
| 1113 | 1154 | // What are the options, eh? |
| 1114 | 1155 | $temp = parse_bbc(false); |
| 1115 | 1156 | $bbcTags = array(); |
| 1116 | - foreach ($temp as $tag) |
|
| 1117 | - $bbcTags[] = $tag['tag']; |
|
| 1157 | + foreach ($temp as $tag) { |
|
| 1158 | + $bbcTags[] = $tag['tag']; |
|
| 1159 | + } |
|
| 1118 | 1160 | |
| 1119 | 1161 | $bbcTags = array_unique($bbcTags); |
| 1120 | 1162 | $totalTags = count($bbcTags); |
@@ -1129,8 +1171,9 @@ discard block |
||
| 1129 | 1171 | $col = 0; $i = 0; |
| 1130 | 1172 | foreach ($bbcTags as $tag) |
| 1131 | 1173 | { |
| 1132 | - if ($i % $tagsPerColumn == 0 && $i != 0) |
|
| 1133 | - $col++; |
|
| 1174 | + if ($i % $tagsPerColumn == 0 && $i != 0) { |
|
| 1175 | + $col++; |
|
| 1176 | + } |
|
| 1134 | 1177 | |
| 1135 | 1178 | $context['bbc_columns'][$col][] = array( |
| 1136 | 1179 | 'tag' => $tag, |
@@ -1173,18 +1216,21 @@ discard block |
||
| 1173 | 1216 | validateToken('admin-ssc'); |
| 1174 | 1217 | |
| 1175 | 1218 | // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!) |
| 1176 | - if (isset($_POST['cookiename'])) |
|
| 1177 | - $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
| 1219 | + if (isset($_POST['cookiename'])) { |
|
| 1220 | + $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
| 1221 | + } |
|
| 1178 | 1222 | |
| 1179 | 1223 | // Fix the forum's URL if necessary. |
| 1180 | 1224 | if (isset($_POST['boardurl'])) |
| 1181 | 1225 | { |
| 1182 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 1183 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1184 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 1185 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1186 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 1187 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1226 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1227 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1228 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1229 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1230 | + } |
|
| 1231 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1232 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1233 | + } |
|
| 1188 | 1234 | } |
| 1189 | 1235 | |
| 1190 | 1236 | // Any passwords? |
@@ -1219,21 +1265,21 @@ discard block |
||
| 1219 | 1265 | // Figure out which config vars we're saving here... |
| 1220 | 1266 | foreach ($config_vars as $var) |
| 1221 | 1267 | { |
| 1222 | - if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) |
|
| 1223 | - continue; |
|
| 1268 | + if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) { |
|
| 1269 | + continue; |
|
| 1270 | + } |
|
| 1224 | 1271 | |
| 1225 | 1272 | $config_var = $var[0]; |
| 1226 | 1273 | |
| 1227 | 1274 | if (in_array($config_var, $config_passwords)) |
| 1228 | 1275 | { |
| 1229 | - if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) |
|
| 1230 | - $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
| 1231 | - } |
|
| 1232 | - elseif (in_array($config_var, $config_strs)) |
|
| 1276 | + if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) { |
|
| 1277 | + $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
| 1278 | + } |
|
| 1279 | + } elseif (in_array($config_var, $config_strs)) |
|
| 1233 | 1280 | { |
| 1234 | 1281 | $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\''; |
| 1235 | - } |
|
| 1236 | - elseif (in_array($config_var, $config_ints)) |
|
| 1282 | + } elseif (in_array($config_var, $config_ints)) |
|
| 1237 | 1283 | { |
| 1238 | 1284 | $new_settings[$config_var] = (int) $_POST[$config_var]; |
| 1239 | 1285 | |
@@ -1242,17 +1288,17 @@ discard block |
||
| 1242 | 1288 | $new_settings[$config_var] = max($min, $new_settings[$config_var]); |
| 1243 | 1289 | |
| 1244 | 1290 | // Is there a max value for this as well? |
| 1245 | - if (isset($var['max'])) |
|
| 1246 | - $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
| 1247 | - } |
|
| 1248 | - elseif (in_array($config_var, $config_bools)) |
|
| 1291 | + if (isset($var['max'])) { |
|
| 1292 | + $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
| 1293 | + } |
|
| 1294 | + } elseif (in_array($config_var, $config_bools)) |
|
| 1249 | 1295 | { |
| 1250 | - if (!empty($_POST[$config_var])) |
|
| 1251 | - $new_settings[$config_var] = '1'; |
|
| 1252 | - else |
|
| 1253 | - $new_settings[$config_var] = '0'; |
|
| 1254 | - } |
|
| 1255 | - else |
|
| 1296 | + if (!empty($_POST[$config_var])) { |
|
| 1297 | + $new_settings[$config_var] = '1'; |
|
| 1298 | + } else { |
|
| 1299 | + $new_settings[$config_var] = '0'; |
|
| 1300 | + } |
|
| 1301 | + } else |
|
| 1256 | 1302 | { |
| 1257 | 1303 | // This shouldn't happen, but it might... |
| 1258 | 1304 | fatal_error('Unknown config_var \'' . $config_var . '\''); |
@@ -1268,30 +1314,35 @@ discard block |
||
| 1268 | 1314 | foreach ($config_vars as $config_var) |
| 1269 | 1315 | { |
| 1270 | 1316 | // We just saved the file-based settings, so skip their definitions. |
| 1271 | - if (!is_array($config_var) || $config_var[2] == 'file') |
|
| 1272 | - continue; |
|
| 1317 | + if (!is_array($config_var) || $config_var[2] == 'file') { |
|
| 1318 | + continue; |
|
| 1319 | + } |
|
| 1273 | 1320 | |
| 1274 | 1321 | $new_setting = array($config_var[3], $config_var[0]); |
| 1275 | 1322 | |
| 1276 | 1323 | // Select options need carried over, too. |
| 1277 | - if (isset($config_var[4])) |
|
| 1278 | - $new_setting[] = $config_var[4]; |
|
| 1324 | + if (isset($config_var[4])) { |
|
| 1325 | + $new_setting[] = $config_var[4]; |
|
| 1326 | + } |
|
| 1279 | 1327 | |
| 1280 | 1328 | // Include min and max if necessary |
| 1281 | - if (isset($config_var['min'])) |
|
| 1282 | - $new_setting['min'] = $config_var['min']; |
|
| 1329 | + if (isset($config_var['min'])) { |
|
| 1330 | + $new_setting['min'] = $config_var['min']; |
|
| 1331 | + } |
|
| 1283 | 1332 | |
| 1284 | - if (isset($config_var['max'])) |
|
| 1285 | - $new_setting['max'] = $config_var['max']; |
|
| 1333 | + if (isset($config_var['max'])) { |
|
| 1334 | + $new_setting['max'] = $config_var['max']; |
|
| 1335 | + } |
|
| 1286 | 1336 | |
| 1287 | 1337 | // Rewrite the definition a bit. |
| 1288 | 1338 | $new_settings[] = $new_setting; |
| 1289 | 1339 | } |
| 1290 | 1340 | |
| 1291 | 1341 | // Save the new database-based settings, if any. |
| 1292 | - if (!empty($new_settings)) |
|
| 1293 | - saveDBSettings($new_settings); |
|
| 1294 | -} |
|
| 1342 | + if (!empty($new_settings)) { |
|
| 1343 | + saveDBSettings($new_settings); |
|
| 1344 | + } |
|
| 1345 | + } |
|
| 1295 | 1346 | |
| 1296 | 1347 | /** |
| 1297 | 1348 | * Helper function for saving database settings. |
@@ -1309,22 +1360,25 @@ discard block |
||
| 1309 | 1360 | $inlinePermissions = array(); |
| 1310 | 1361 | foreach ($config_vars as $var) |
| 1311 | 1362 | { |
| 1312 | - 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'])))) |
|
| 1313 | - continue; |
|
| 1363 | + 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'])))) { |
|
| 1364 | + continue; |
|
| 1365 | + } |
|
| 1314 | 1366 | |
| 1315 | 1367 | // Checkboxes! |
| 1316 | - elseif ($var[0] == 'check') |
|
| 1317 | - $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
| 1368 | + elseif ($var[0] == 'check') { |
|
| 1369 | + $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
| 1370 | + } |
|
| 1318 | 1371 | // Select boxes! |
| 1319 | - elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) |
|
| 1320 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1321 | - elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
| 1372 | + elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) { |
|
| 1373 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1374 | + } elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
| 1322 | 1375 | { |
| 1323 | 1376 | // For security purposes we validate this line by line. |
| 1324 | 1377 | $lOptions = array(); |
| 1325 | - foreach ($_POST[$var[1]] as $invar) |
|
| 1326 | - if (in_array($invar, array_keys($var[2]))) |
|
| 1378 | + foreach ($_POST[$var[1]] as $invar) { |
|
| 1379 | + if (in_array($invar, array_keys($var[2]))) |
|
| 1327 | 1380 | $lOptions[] = $invar; |
| 1381 | + } |
|
| 1328 | 1382 | |
| 1329 | 1383 | $setArray[$var[1]] = $smcFunc['json_encode']($lOptions); |
| 1330 | 1384 | } |
@@ -1338,18 +1392,20 @@ discard block |
||
| 1338 | 1392 | $request = $smcFunc['db_query']('', ' |
| 1339 | 1393 | SELECT id_board |
| 1340 | 1394 | FROM {db_prefix}boards'); |
| 1341 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1342 | - $board_list[$row[0]] = true; |
|
| 1395 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1396 | + $board_list[$row[0]] = true; |
|
| 1397 | + } |
|
| 1343 | 1398 | |
| 1344 | 1399 | $smcFunc['db_free_result']($request); |
| 1345 | 1400 | } |
| 1346 | 1401 | |
| 1347 | 1402 | $lOptions = array(); |
| 1348 | 1403 | |
| 1349 | - if (!empty($_POST[$var[1]])) |
|
| 1350 | - foreach ($_POST[$var[1]] as $invar => $dummy) |
|
| 1404 | + if (!empty($_POST[$var[1]])) { |
|
| 1405 | + foreach ($_POST[$var[1]] as $invar => $dummy) |
|
| 1351 | 1406 | if (isset($board_list[$invar])) |
| 1352 | 1407 | $lOptions[] = $invar; |
| 1408 | + } |
|
| 1353 | 1409 | |
| 1354 | 1410 | $setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : ''; |
| 1355 | 1411 | } |
@@ -1363,8 +1419,9 @@ discard block |
||
| 1363 | 1419 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
| 1364 | 1420 | |
| 1365 | 1421 | // Do we have a max value for this as well? |
| 1366 | - if (isset($var['max'])) |
|
| 1367 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1422 | + if (isset($var['max'])) { |
|
| 1423 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1424 | + } |
|
| 1368 | 1425 | } |
| 1369 | 1426 | // Floating point! |
| 1370 | 1427 | elseif ($var[0] == 'float') |
@@ -1376,40 +1433,47 @@ discard block |
||
| 1376 | 1433 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
| 1377 | 1434 | |
| 1378 | 1435 | // Do we have a max value for this as well? |
| 1379 | - if (isset($var['max'])) |
|
| 1380 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1436 | + if (isset($var['max'])) { |
|
| 1437 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1438 | + } |
|
| 1381 | 1439 | } |
| 1382 | 1440 | // Text! |
| 1383 | - elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) |
|
| 1384 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1441 | + elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) { |
|
| 1442 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1443 | + } |
|
| 1385 | 1444 | // Passwords! |
| 1386 | 1445 | elseif ($var[0] == 'password') |
| 1387 | 1446 | { |
| 1388 | - if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) |
|
| 1389 | - $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
| 1447 | + if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) { |
|
| 1448 | + $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
| 1449 | + } |
|
| 1390 | 1450 | } |
| 1391 | 1451 | // BBC. |
| 1392 | 1452 | elseif ($var[0] == 'bbc') |
| 1393 | 1453 | { |
| 1394 | 1454 | |
| 1395 | 1455 | $bbcTags = array(); |
| 1396 | - foreach (parse_bbc(false) as $tag) |
|
| 1397 | - $bbcTags[] = $tag['tag']; |
|
| 1456 | + foreach (parse_bbc(false) as $tag) { |
|
| 1457 | + $bbcTags[] = $tag['tag']; |
|
| 1458 | + } |
|
| 1398 | 1459 | |
| 1399 | - if (!isset($_POST[$var[1] . '_enabledTags'])) |
|
| 1400 | - $_POST[$var[1] . '_enabledTags'] = array(); |
|
| 1401 | - elseif (!is_array($_POST[$var[1] . '_enabledTags'])) |
|
| 1402 | - $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
| 1460 | + if (!isset($_POST[$var[1] . '_enabledTags'])) { |
|
| 1461 | + $_POST[$var[1] . '_enabledTags'] = array(); |
|
| 1462 | + } elseif (!is_array($_POST[$var[1] . '_enabledTags'])) { |
|
| 1463 | + $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
| 1464 | + } |
|
| 1403 | 1465 | |
| 1404 | 1466 | $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags'])); |
| 1405 | 1467 | } |
| 1406 | 1468 | // Permissions? |
| 1407 | - elseif ($var[0] == 'permissions') |
|
| 1408 | - $inlinePermissions[] = $var[1]; |
|
| 1469 | + elseif ($var[0] == 'permissions') { |
|
| 1470 | + $inlinePermissions[] = $var[1]; |
|
| 1471 | + } |
|
| 1409 | 1472 | } |
| 1410 | 1473 | |
| 1411 | - if (!empty($setArray)) |
|
| 1412 | - updateSettings($setArray); |
|
| 1474 | + if (!empty($setArray)) { |
|
| 1475 | + updateSettings($setArray); |
|
| 1476 | + } |
|
| 1413 | 1477 | |
| 1414 | 1478 | // If we have inline permissions we need to save them. |
| 1415 | 1479 | if (!empty($inlinePermissions) && allowedTo('manage_permissions')) |
@@ -1446,18 +1510,21 @@ discard block |
||
| 1446 | 1510 | // put all of it into an array |
| 1447 | 1511 | foreach ($info_lines as $line) |
| 1448 | 1512 | { |
| 1449 | - if (preg_match('~(' . $remove . ')~', $line)) |
|
| 1450 | - continue; |
|
| 1513 | + if (preg_match('~(' . $remove . ')~', $line)) { |
|
| 1514 | + continue; |
|
| 1515 | + } |
|
| 1451 | 1516 | |
| 1452 | 1517 | // new category? |
| 1453 | - if (strpos($line, '<h2>') !== false) |
|
| 1454 | - $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
| 1518 | + if (strpos($line, '<h2>') !== false) { |
|
| 1519 | + $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
| 1520 | + } |
|
| 1455 | 1521 | |
| 1456 | 1522 | // load it as setting => value or the old setting local master |
| 1457 | - if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
| 1458 | - $pinfo[$category][$val[1]] = $val[2]; |
|
| 1459 | - elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
| 1460 | - $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
| 1523 | + if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
| 1524 | + $pinfo[$category][$val[1]] = $val[2]; |
|
| 1525 | + } elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
| 1526 | + $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
| 1527 | + } |
|
| 1461 | 1528 | } |
| 1462 | 1529 | |
| 1463 | 1530 | // load it in to context and display it |
@@ -1492,8 +1559,9 @@ discard block |
||
| 1492 | 1559 | $testAPI = new $cache_class_name(); |
| 1493 | 1560 | |
| 1494 | 1561 | // No Support? NEXT! |
| 1495 | - if (!$testAPI->isSupported(true)) |
|
| 1496 | - continue; |
|
| 1562 | + if (!$testAPI->isSupported(true)) { |
|
| 1563 | + continue; |
|
| 1564 | + } |
|
| 1497 | 1565 | |
| 1498 | 1566 | $apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache; |
| 1499 | 1567 | } |
@@ -1518,8 +1586,9 @@ discard block |
||
| 1518 | 1586 | global $modSettings, $boardurl, $smcFunc; |
| 1519 | 1587 | |
| 1520 | 1588 | // Already have a key? Can't register again. |
| 1521 | - if (!empty($modSettings['sm_stats_key'])) |
|
| 1522 | - return true; |
|
| 1589 | + if (!empty($modSettings['sm_stats_key'])) { |
|
| 1590 | + return true; |
|
| 1591 | + } |
|
| 1523 | 1592 | |
| 1524 | 1593 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
| 1525 | 1594 | if ($fp) |
@@ -1530,8 +1599,9 @@ discard block |
||
| 1530 | 1599 | fwrite($fp, $out); |
| 1531 | 1600 | |
| 1532 | 1601 | $return_data = ''; |
| 1533 | - while (!feof($fp)) |
|
| 1534 | - $return_data .= fgets($fp, 128); |
|
| 1602 | + while (!feof($fp)) { |
|
| 1603 | + $return_data .= fgets($fp, 128); |
|
| 1604 | + } |
|
| 1535 | 1605 | |
| 1536 | 1606 | fclose($fp); |
| 1537 | 1607 | |
@@ -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 |
@@ -106,8 +107,9 @@ discard block |
||
| 106 | 107 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
| 107 | 108 | |
| 108 | 109 | // We do not want to output debug information here. |
| 109 | - if ($this->_js) |
|
| 110 | - $db_show_debug = false; |
|
| 110 | + if ($this->_js) { |
|
| 111 | + $db_show_debug = false; |
|
| 112 | + } |
|
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | /** |
@@ -141,8 +143,9 @@ discard block |
||
| 141 | 143 | $call = $this->_sa; |
| 142 | 144 | |
| 143 | 145 | // Guest can only view likes. |
| 144 | - if ($call != 'view') |
|
| 145 | - is_not_guest(); |
|
| 146 | + if ($call != 'view') { |
|
| 147 | + is_not_guest(); |
|
| 148 | + } |
|
| 146 | 149 | |
| 147 | 150 | checkSession('get'); |
| 148 | 151 | |
@@ -180,15 +183,17 @@ discard block |
||
| 180 | 183 | global $smcFunc, $modSettings; |
| 181 | 184 | |
| 182 | 185 | // This feature is currently disable. |
| 183 | - if (empty($modSettings['enable_likes'])) |
|
| 184 | - return $this->_error = 'like_disable'; |
|
| 186 | + if (empty($modSettings['enable_likes'])) { |
|
| 187 | + return $this->_error = 'like_disable'; |
|
| 188 | + } |
|
| 185 | 189 | |
| 186 | 190 | // Zerothly, they did indicate some kind of content to like, right? |
| 187 | 191 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
| 188 | 192 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
| 189 | 193 | |
| 190 | - if ($this->_type == '' || $this->_content <= 0) |
|
| 191 | - return $this->_error = 'cannot_'; |
|
| 194 | + if ($this->_type == '' || $this->_content <= 0) { |
|
| 195 | + return $this->_error = 'cannot_'; |
|
| 196 | + } |
|
| 192 | 197 | |
| 193 | 198 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
| 194 | 199 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -207,12 +212,14 @@ discard block |
||
| 207 | 212 | 'msg' => $this->_content, |
| 208 | 213 | ) |
| 209 | 214 | ); |
| 210 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 211 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 215 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 216 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 217 | + } |
|
| 212 | 218 | |
| 213 | 219 | $smcFunc['db_free_result']($request); |
| 214 | - if (empty($this->_idTopic)) |
|
| 215 | - return $this->_error = 'cannot_'; |
|
| 220 | + if (empty($this->_idTopic)) { |
|
| 221 | + return $this->_error = 'cannot_'; |
|
| 222 | + } |
|
| 216 | 223 | |
| 217 | 224 | // So we know what topic it's in and more importantly we know the user can see it. |
| 218 | 225 | // If we're not viewing, we need some info set up. |
@@ -221,9 +228,7 @@ discard block |
||
| 221 | 228 | $this->_validLikes['redirect'] = 'topic=' . $this->_idTopic . '.msg' . $this->_content . '#msg' . $this->_content; |
| 222 | 229 | |
| 223 | 230 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
| 224 | - } |
|
| 225 | - |
|
| 226 | - else |
|
| 231 | + } else |
|
| 227 | 232 | { |
| 228 | 233 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
| 229 | 234 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -241,8 +246,9 @@ discard block |
||
| 241 | 246 | if ($result !== false) |
| 242 | 247 | { |
| 243 | 248 | // Match the type with what we already have. |
| 244 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
| 245 | - return $this->_error = 'not_valid_like_type'; |
|
| 249 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
| 250 | + return $this->_error = 'not_valid_like_type'; |
|
| 251 | + } |
|
| 246 | 252 | |
| 247 | 253 | // Fill out the rest. |
| 248 | 254 | $this->_type = $result['type']; |
@@ -253,13 +259,15 @@ discard block |
||
| 253 | 259 | } |
| 254 | 260 | } |
| 255 | 261 | |
| 256 | - if (!$found) |
|
| 257 | - return $this->_error = 'cannot_'; |
|
| 262 | + if (!$found) { |
|
| 263 | + return $this->_error = 'cannot_'; |
|
| 264 | + } |
|
| 258 | 265 | } |
| 259 | 266 | |
| 260 | 267 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
| 261 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
| 262 | - return $this->_error = $this->_validLikes['can_like']; |
|
| 268 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
| 269 | + return $this->_error = $this->_validLikes['can_like']; |
|
| 270 | + } |
|
| 263 | 271 | } |
| 264 | 272 | |
| 265 | 273 | /** |
@@ -284,8 +292,9 @@ discard block |
||
| 284 | 292 | ); |
| 285 | 293 | |
| 286 | 294 | // 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. |
| 287 | - if ($this->_sa == __FUNCTION__) |
|
| 288 | - $this->_data = __FUNCTION__; |
|
| 295 | + if ($this->_sa == __FUNCTION__) { |
|
| 296 | + $this->_data = __FUNCTION__; |
|
| 297 | + } |
|
| 289 | 298 | } |
| 290 | 299 | |
| 291 | 300 | /** |
@@ -315,8 +324,8 @@ discard block |
||
| 315 | 324 | |
| 316 | 325 | // Add a background task to process sending alerts. |
| 317 | 326 | // 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. |
| 318 | - if ($this->_type == 'msg') |
|
| 319 | - $smcFunc['db_insert']('insert', |
|
| 327 | + if ($this->_type == 'msg') { |
|
| 328 | + $smcFunc['db_insert']('insert', |
|
| 320 | 329 | '{db_prefix}background_tasks', |
| 321 | 330 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 322 | 331 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array( |
@@ -328,10 +337,12 @@ discard block |
||
| 328 | 337 | )), 0), |
| 329 | 338 | array('id_task') |
| 330 | 339 | ); |
| 340 | + } |
|
| 331 | 341 | |
| 332 | 342 | // 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. |
| 333 | - if ($this->_sa == __FUNCTION__) |
|
| 334 | - $this->_data = __FUNCTION__; |
|
| 343 | + if ($this->_sa == __FUNCTION__) { |
|
| 344 | + $this->_data = __FUNCTION__; |
|
| 345 | + } |
|
| 335 | 346 | } |
| 336 | 347 | |
| 337 | 348 | /** |
@@ -357,8 +368,9 @@ discard block |
||
| 357 | 368 | $smcFunc['db_free_result']($request); |
| 358 | 369 | |
| 359 | 370 | // If you want to call this directly, fill out _data property too. |
| 360 | - if ($this->_sa == __FUNCTION__) |
|
| 361 | - $this->_data = $this->_numLikes; |
|
| 371 | + if ($this->_sa == __FUNCTION__) { |
|
| 372 | + $this->_data = $this->_numLikes; |
|
| 373 | + } |
|
| 362 | 374 | } |
| 363 | 375 | |
| 364 | 376 | /** |
@@ -371,8 +383,9 @@ discard block |
||
| 371 | 383 | global $smcFunc; |
| 372 | 384 | |
| 373 | 385 | // Safety first! |
| 374 | - if (empty($this->_type) || empty($this->_content)) |
|
| 375 | - return $this->_error = 'cannot_'; |
|
| 386 | + if (empty($this->_type) || empty($this->_content)) { |
|
| 387 | + return $this->_error = 'cannot_'; |
|
| 388 | + } |
|
| 376 | 389 | |
| 377 | 390 | // Do we already like this? |
| 378 | 391 | $request = $smcFunc['db_query']('', ' |
@@ -390,26 +403,28 @@ discard block |
||
| 390 | 403 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
| 391 | 404 | $smcFunc['db_free_result']($request); |
| 392 | 405 | |
| 393 | - if ($this->_alreadyLiked) |
|
| 394 | - $this->delete(); |
|
| 395 | - |
|
| 396 | - else |
|
| 397 | - $this->insert(); |
|
| 406 | + if ($this->_alreadyLiked) { |
|
| 407 | + $this->delete(); |
|
| 408 | + } else { |
|
| 409 | + $this->insert(); |
|
| 410 | + } |
|
| 398 | 411 | |
| 399 | 412 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
| 400 | 413 | $this->_count(); |
| 401 | 414 | |
| 402 | 415 | // Update the likes count for messages. |
| 403 | - if ($this->_type == 'msg') |
|
| 404 | - $this->msgIssueLike(); |
|
| 416 | + if ($this->_type == 'msg') { |
|
| 417 | + $this->msgIssueLike(); |
|
| 418 | + } |
|
| 405 | 419 | |
| 406 | 420 | // Any callbacks? |
| 407 | 421 | elseif (!empty($this->_validLikes['callback'])) |
| 408 | 422 | { |
| 409 | 423 | $call = call_helper($this->_validLikes['callback'], true); |
| 410 | 424 | |
| 411 | - if (!empty($call)) |
|
| 412 | - call_user_func_array($call, array($this)); |
|
| 425 | + if (!empty($call)) { |
|
| 426 | + call_user_func_array($call, array($this)); |
|
| 427 | + } |
|
| 413 | 428 | } |
| 414 | 429 | |
| 415 | 430 | // Sometimes there might be other things that need updating after we do this like. |
@@ -418,8 +433,9 @@ discard block |
||
| 418 | 433 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
| 419 | 434 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
| 420 | 435 | // in integrate_valid_likes where it absolutely has to exist. |
| 421 | - if (!empty($this->_validLikes['flush_cache'])) |
|
| 422 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 436 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
| 437 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 438 | + } |
|
| 423 | 439 | |
| 424 | 440 | // All done, start building the data to pass as response. |
| 425 | 441 | $this->_data = array( |
@@ -442,8 +458,9 @@ discard block |
||
| 442 | 458 | { |
| 443 | 459 | global $smcFunc; |
| 444 | 460 | |
| 445 | - if ($this->_type !== 'msg') |
|
| 446 | - return; |
|
| 461 | + if ($this->_type !== 'msg') { |
|
| 462 | + return; |
|
| 463 | + } |
|
| 447 | 464 | |
| 448 | 465 | $smcFunc['db_query']('', ' |
| 449 | 466 | UPDATE {db_prefix}messages |
@@ -484,8 +501,9 @@ discard block |
||
| 484 | 501 | 'like_type' => $this->_type, |
| 485 | 502 | ) |
| 486 | 503 | ); |
| 487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 488 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 504 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 505 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 506 | + } |
|
| 489 | 507 | |
| 490 | 508 | // Now to get member data, including avatars and so on. |
| 491 | 509 | $members = array_keys($context['likers']); |
@@ -493,8 +511,9 @@ discard block |
||
| 493 | 511 | if (count($loaded) != count($members)) |
| 494 | 512 | { |
| 495 | 513 | $members = array_diff($members, $loaded); |
| 496 | - foreach ($members as $not_loaded) |
|
| 497 | - unset ($context['likers'][$not_loaded]); |
|
| 514 | + foreach ($members as $not_loaded) { |
|
| 515 | + unset ($context['likers'][$not_loaded]); |
|
| 516 | + } |
|
| 498 | 517 | } |
| 499 | 518 | |
| 500 | 519 | foreach ($context['likers'] as $liker => $dummy) |
@@ -536,12 +555,14 @@ discard block |
||
| 536 | 555 | global $context, $txt; |
| 537 | 556 | |
| 538 | 557 | // Don't do anything if someone else has already take care of the response. |
| 539 | - if (!$this->_setResponse) |
|
| 540 | - return; |
|
| 558 | + if (!$this->_setResponse) { |
|
| 559 | + return; |
|
| 560 | + } |
|
| 541 | 561 | |
| 542 | 562 | // Want a json response huh? |
| 543 | - if ($this->_validLikes['json']) |
|
| 544 | - return $this->jsonResponse(); |
|
| 563 | + if ($this->_validLikes['json']) { |
|
| 564 | + return $this->jsonResponse(); |
|
| 565 | + } |
|
| 545 | 566 | |
| 546 | 567 | // Set everything up for display. |
| 547 | 568 | loadTemplate('Likes'); |
@@ -551,8 +572,9 @@ discard block |
||
| 551 | 572 | if ($this->_error) |
| 552 | 573 | { |
| 553 | 574 | // If this is a generic error, set it up good. |
| 554 | - if ($this->_error == 'cannot_') |
|
| 555 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 575 | + if ($this->_error == 'cannot_') { |
|
| 576 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 577 | + } |
|
| 556 | 578 | |
| 557 | 579 | // Is this request coming from an ajax call? |
| 558 | 580 | if ($this->_js) |
@@ -562,8 +584,9 @@ discard block |
||
| 562 | 584 | } |
| 563 | 585 | |
| 564 | 586 | // Nope? then just do a redirect to whatever URL was provided. |
| 565 | - else |
|
| 566 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 587 | + else { |
|
| 588 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 589 | + } |
|
| 567 | 590 | |
| 568 | 591 | return; |
| 569 | 592 | } |
@@ -572,8 +595,9 @@ discard block |
||
| 572 | 595 | else |
| 573 | 596 | { |
| 574 | 597 | // Not an ajax request so send the user back to the previous location or the main page. |
| 575 | - if (!$this->_js) |
|
| 576 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 598 | + if (!$this->_js) { |
|
| 599 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 600 | + } |
|
| 577 | 601 | |
| 578 | 602 | // These fine gentlemen all share the same template. |
| 579 | 603 | $generic = array('delete', 'insert', '_count'); |
@@ -606,8 +630,9 @@ discard block |
||
| 606 | 630 | // If there is an error, send it. |
| 607 | 631 | if ($this->_error) |
| 608 | 632 | { |
| 609 | - if ($this->_error == 'cannot_') |
|
| 610 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 633 | + if ($this->_error == 'cannot_') { |
|
| 634 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 635 | + } |
|
| 611 | 636 | |
| 612 | 637 | $print['error'] = $this->_error; |
| 613 | 638 | } |
@@ -643,33 +668,36 @@ discard block |
||
| 643 | 668 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
| 644 | 669 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
| 645 | 670 | |
| 646 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
| 647 | - $_GET['verse'] = '4:16'; |
|
| 671 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
| 672 | + $_GET['verse'] = '4:16'; |
|
| 673 | + } |
|
| 648 | 674 | |
| 649 | - if ($_GET['verse'] == '2:18') |
|
| 650 | - echo ' |
|
| 675 | + if ($_GET['verse'] == '2:18') { |
|
| 676 | + echo ' |
|
| 651 | 677 | 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.'; |
| 652 | - elseif ($_GET['verse'] == '4:16') |
|
| 653 | - echo ' |
|
| 678 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 679 | + echo ' |
|
| 654 | 680 | 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.'; |
| 655 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 656 | - echo ' |
|
| 681 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 682 | + echo ' |
|
| 657 | 683 | <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> |
| 658 | 684 | <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>'; |
| 685 | + } |
|
| 659 | 686 | |
| 660 | 687 | echo ' |
| 661 | 688 | </div> |
| 662 | 689 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
| 663 | 690 | |
| 664 | - if ($_GET['verse'] == '2:18') |
|
| 665 | - echo ' |
|
| 691 | + if ($_GET['verse'] == '2:18') { |
|
| 692 | + echo ' |
|
| 666 | 693 | 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>'; |
| 667 | - elseif ($_GET['verse'] == '4:16') |
|
| 668 | - echo ' |
|
| 694 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 695 | + echo ' |
|
| 669 | 696 | 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>'; |
| 670 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 671 | - echo ' |
|
| 697 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 698 | + echo ' |
|
| 672 | 699 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
| 700 | + } |
|
| 673 | 701 | |
| 674 | 702 | echo ' |
| 675 | 703 | </div> |
@@ -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 all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
| 60 | 61 | 'max_year' => $year_high, |
| 61 | 62 | ) |
| 62 | 63 | ); |
| 63 | - } |
|
| 64 | - else |
|
| 64 | + } else |
|
| 65 | 65 | { |
| 66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
| 67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
| 91 | 91 | $bday = array(); |
| 92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 93 | 93 | { |
| 94 | - if ($year_low != $year_high) |
|
| 95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | - else |
|
| 97 | - $age_year = $year_low; |
|
| 94 | + if ($year_low != $year_high) { |
|
| 95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | + } else { |
|
| 97 | + $age_year = $year_low; |
|
| 98 | + } |
|
| 98 | 99 | |
| 99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
| 100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
| 108 | 109 | ksort($bday); |
| 109 | 110 | |
| 110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
| 111 | - foreach ($bday as $mday => $array) |
|
| 112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 112 | + foreach ($bday as $mday => $array) { |
|
| 113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 114 | + } |
|
| 113 | 115 | |
| 114 | 116 | return $bday; |
| 115 | 117 | } |
@@ -133,8 +135,9 @@ discard block |
||
| 133 | 135 | static $timezone_array = array(); |
| 134 | 136 | require_once($sourcedir . '/Subs.php'); |
| 135 | 137 | |
| 136 | - if (empty($timezone_array['default'])) |
|
| 137 | - $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
| 138 | + if (empty($timezone_array['default'])) { |
|
| 139 | + $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
| 140 | + } |
|
| 138 | 141 | |
| 139 | 142 | $low_object = date_create($low_date); |
| 140 | 143 | $high_object = date_create($high_date); |
@@ -161,8 +164,9 @@ discard block |
||
| 161 | 164 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 162 | 165 | { |
| 163 | 166 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
| 164 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
| 165 | - continue; |
|
| 167 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
| 168 | + continue; |
|
| 169 | + } |
|
| 166 | 170 | |
| 167 | 171 | // Force a censor of the title - as often these are used by others. |
| 168 | 172 | censorText($row['title'], $use_permissions ? false : true); |
@@ -170,12 +174,14 @@ discard block |
||
| 170 | 174 | // Get the various time and date properties for this event |
| 171 | 175 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 172 | 176 | |
| 173 | - if (empty($timezone_array[$tz])) |
|
| 174 | - $timezone_array[$tz] = timezone_open($tz); |
|
| 177 | + if (empty($timezone_array[$tz])) { |
|
| 178 | + $timezone_array[$tz] = timezone_open($tz); |
|
| 179 | + } |
|
| 175 | 180 | |
| 176 | 181 | // Sanity check |
| 177 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 178 | - continue; |
|
| 182 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 183 | + continue; |
|
| 184 | + } |
|
| 179 | 185 | |
| 180 | 186 | // Get set up for the loop |
| 181 | 187 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]); |
@@ -239,8 +245,8 @@ discard block |
||
| 239 | 245 | ); |
| 240 | 246 | |
| 241 | 247 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
| 242 | - if ($use_permissions) |
|
| 243 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 248 | + if ($use_permissions) { |
|
| 249 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 244 | 250 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 245 | 251 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 246 | 252 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -248,9 +254,10 @@ discard block |
||
| 248 | 254 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
| 249 | 255 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 250 | 256 | )); |
| 257 | + } |
|
| 251 | 258 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
| 252 | - else |
|
| 253 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 259 | + else { |
|
| 260 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 254 | 261 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 255 | 262 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 256 | 263 | 'can_edit' => false, |
@@ -260,6 +267,7 @@ discard block |
||
| 260 | 267 | 'poster' => $row['id_member'], |
| 261 | 268 | 'allowed_groups' => explode(',', $row['member_groups']), |
| 262 | 269 | )); |
| 270 | + } |
|
| 263 | 271 | |
| 264 | 272 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
| 265 | 273 | } |
@@ -269,8 +277,9 @@ discard block |
||
| 269 | 277 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
| 270 | 278 | if ($use_permissions) |
| 271 | 279 | { |
| 272 | - foreach ($events as $mday => $array) |
|
| 273 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 280 | + foreach ($events as $mday => $array) { |
|
| 281 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 282 | + } |
|
| 274 | 283 | } |
| 275 | 284 | |
| 276 | 285 | ksort($events); |
@@ -290,11 +299,12 @@ discard block |
||
| 290 | 299 | global $smcFunc; |
| 291 | 300 | |
| 292 | 301 | // Get the lowest and highest dates for "all years". |
| 293 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 294 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 302 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 303 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 295 | 304 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
| 296 | - else |
|
| 297 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 305 | + } else { |
|
| 306 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 307 | + } |
|
| 298 | 308 | |
| 299 | 309 | // Find some holidays... ;). |
| 300 | 310 | $result = $smcFunc['db_query']('', ' |
@@ -314,10 +324,11 @@ discard block |
||
| 314 | 324 | $holidays = array(); |
| 315 | 325 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 316 | 326 | { |
| 317 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 318 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 319 | - else |
|
| 320 | - $event_year = substr($low_date, 0, 4); |
|
| 327 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 328 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 329 | + } else { |
|
| 330 | + $event_year = substr($low_date, 0, 4); |
|
| 331 | + } |
|
| 321 | 332 | |
| 322 | 333 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
| 323 | 334 | } |
@@ -343,10 +354,12 @@ discard block |
||
| 343 | 354 | isAllowedTo('calendar_post'); |
| 344 | 355 | |
| 345 | 356 | // No board? No topic?!? |
| 346 | - if (empty($board)) |
|
| 347 | - fatal_lang_error('missing_board_id', false); |
|
| 348 | - if (empty($topic)) |
|
| 349 | - fatal_lang_error('missing_topic_id', false); |
|
| 357 | + if (empty($board)) { |
|
| 358 | + fatal_lang_error('missing_board_id', false); |
|
| 359 | + } |
|
| 360 | + if (empty($topic)) { |
|
| 361 | + fatal_lang_error('missing_topic_id', false); |
|
| 362 | + } |
|
| 350 | 363 | |
| 351 | 364 | // Administrator, Moderator, or owner. Period. |
| 352 | 365 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -364,12 +377,14 @@ discard block |
||
| 364 | 377 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
| 365 | 378 | { |
| 366 | 379 | // Not the owner of the topic. |
| 367 | - if ($row['id_member_started'] != $user_info['id']) |
|
| 368 | - fatal_lang_error('not_your_topic', 'user'); |
|
| 380 | + if ($row['id_member_started'] != $user_info['id']) { |
|
| 381 | + fatal_lang_error('not_your_topic', 'user'); |
|
| 382 | + } |
|
| 369 | 383 | } |
| 370 | 384 | // Topic/Board doesn't exist..... |
| 371 | - else |
|
| 372 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
| 385 | + else { |
|
| 386 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
| 387 | + } |
|
| 373 | 388 | $smcFunc['db_free_result']($result); |
| 374 | 389 | } |
| 375 | 390 | } |
@@ -457,14 +472,16 @@ discard block |
||
| 457 | 472 | if (!empty($calendarOptions['start_day'])) |
| 458 | 473 | { |
| 459 | 474 | $nShift -= $calendarOptions['start_day']; |
| 460 | - if ($nShift < 0) |
|
| 461 | - $nShift = 7 + $nShift; |
|
| 475 | + if ($nShift < 0) { |
|
| 476 | + $nShift = 7 + $nShift; |
|
| 477 | + } |
|
| 462 | 478 | } |
| 463 | 479 | |
| 464 | 480 | // Number of rows required to fit the month. |
| 465 | 481 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
| 466 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
| 467 | - $nRows++; |
|
| 482 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
| 483 | + $nRows++; |
|
| 484 | + } |
|
| 468 | 485 | |
| 469 | 486 | // Fetch the arrays for birthdays, posted events, and holidays. |
| 470 | 487 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -477,8 +494,9 @@ discard block |
||
| 477 | 494 | { |
| 478 | 495 | $calendarGrid['week_days'][] = $count; |
| 479 | 496 | $count++; |
| 480 | - if ($count == 7) |
|
| 481 | - $count = 0; |
|
| 497 | + if ($count == 7) { |
|
| 498 | + $count = 0; |
|
| 499 | + } |
|
| 482 | 500 | } |
| 483 | 501 | |
| 484 | 502 | // Iterate through each week. |
@@ -495,8 +513,9 @@ discard block |
||
| 495 | 513 | { |
| 496 | 514 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
| 497 | 515 | |
| 498 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
| 499 | - $nDay = 0; |
|
| 516 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
| 517 | + $nDay = 0; |
|
| 518 | + } |
|
| 500 | 519 | |
| 501 | 520 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
| 502 | 521 | |
@@ -514,8 +533,9 @@ discard block |
||
| 514 | 533 | } |
| 515 | 534 | |
| 516 | 535 | // What is the last day of the month? |
| 517 | - if ($is_previous === true) |
|
| 518 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 536 | + if ($is_previous === true) { |
|
| 537 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 538 | + } |
|
| 519 | 539 | |
| 520 | 540 | // We'll use the shift in the template. |
| 521 | 541 | $calendarGrid['shift'] = $nShift; |
@@ -549,8 +569,9 @@ discard block |
||
| 549 | 569 | { |
| 550 | 570 | // Here we offset accordingly to get things to the real start of a week. |
| 551 | 571 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
| 552 | - if ($date_diff < 0) |
|
| 553 | - $date_diff += 7; |
|
| 572 | + if ($date_diff < 0) { |
|
| 573 | + $date_diff += 7; |
|
| 574 | + } |
|
| 554 | 575 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
| 555 | 576 | $day = (int) strftime('%d', $new_timestamp); |
| 556 | 577 | $month = (int) strftime('%m', $new_timestamp); |
@@ -680,18 +701,20 @@ discard block |
||
| 680 | 701 | { |
| 681 | 702 | foreach ($date_events as $event_key => $event_val) |
| 682 | 703 | { |
| 683 | - if (in_array($event_val['id'], $temp)) |
|
| 684 | - unset($calendarGrid['events'][$date][$event_key]); |
|
| 685 | - else |
|
| 686 | - $temp[] = $event_val['id']; |
|
| 704 | + if (in_array($event_val['id'], $temp)) { |
|
| 705 | + unset($calendarGrid['events'][$date][$event_key]); |
|
| 706 | + } else { |
|
| 707 | + $temp[] = $event_val['id']; |
|
| 708 | + } |
|
| 687 | 709 | } |
| 688 | 710 | } |
| 689 | 711 | |
| 690 | 712 | // Give birthdays and holidays a friendly format, without the year |
| 691 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 692 | - $date_format = '%b %d'; |
|
| 693 | - else |
|
| 694 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 713 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 714 | + $date_format = '%b %d'; |
|
| 715 | + } else { |
|
| 716 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 717 | + } |
|
| 695 | 718 | |
| 696 | 719 | foreach (array('birthdays', 'holidays') as $type) |
| 697 | 720 | { |
@@ -790,8 +813,9 @@ discard block |
||
| 790 | 813 | // Holidays between now and now + days. |
| 791 | 814 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
| 792 | 815 | { |
| 793 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
| 794 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 816 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
| 817 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 818 | + } |
|
| 795 | 819 | } |
| 796 | 820 | } |
| 797 | 821 | |
@@ -803,8 +827,9 @@ discard block |
||
| 803 | 827 | $loop_date = strftime('%Y-%m-%d', $i); |
| 804 | 828 | if (isset($cached_data['birthdays'][$loop_date])) |
| 805 | 829 | { |
| 806 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
| 807 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 830 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
| 831 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 832 | + } |
|
| 808 | 833 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
| 809 | 834 | } |
| 810 | 835 | } |
@@ -819,8 +844,9 @@ discard block |
||
| 819 | 844 | $loop_date = strftime('%Y-%m-%d', $i); |
| 820 | 845 | |
| 821 | 846 | // No events today? Check the next day. |
| 822 | - if (empty($cached_data['events'][$loop_date])) |
|
| 823 | - continue; |
|
| 847 | + if (empty($cached_data['events'][$loop_date])) { |
|
| 848 | + continue; |
|
| 849 | + } |
|
| 824 | 850 | |
| 825 | 851 | // Loop through all events to add a few last-minute values. |
| 826 | 852 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -833,9 +859,9 @@ discard block |
||
| 833 | 859 | { |
| 834 | 860 | unset($cached_data['events'][$loop_date][$ev]); |
| 835 | 861 | continue; |
| 862 | + } else { |
|
| 863 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 836 | 864 | } |
| 837 | - else |
|
| 838 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 839 | 865 | |
| 840 | 866 | // Might be set to true afterwards, depending on the permissions. |
| 841 | 867 | $this_event['can_edit'] = false; |
@@ -843,16 +869,19 @@ discard block |
||
| 843 | 869 | $this_event['date'] = $loop_date; |
| 844 | 870 | } |
| 845 | 871 | |
| 846 | - if (!empty($cached_data['events'][$loop_date])) |
|
| 847 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 872 | + if (!empty($cached_data['events'][$loop_date])) { |
|
| 873 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 874 | + } |
|
| 848 | 875 | } |
| 849 | 876 | } |
| 850 | 877 | |
| 851 | 878 | // Mark the last item so that a list separator can be used in the template. |
| 852 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
| 853 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 854 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
| 855 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 879 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
| 880 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 881 | + } |
|
| 882 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
| 883 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 884 | + } |
|
| 856 | 885 | |
| 857 | 886 | return array( |
| 858 | 887 | 'data' => $return_data, |
@@ -900,37 +929,46 @@ discard block |
||
| 900 | 929 | if (isset($_POST['start_date'])) |
| 901 | 930 | { |
| 902 | 931 | $d = date_parse($_POST['start_date']); |
| 903 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 904 | - fatal_lang_error('invalid_date', false); |
|
| 905 | - if (empty($d['year'])) |
|
| 906 | - fatal_lang_error('event_year_missing', false); |
|
| 907 | - if (empty($d['month'])) |
|
| 908 | - fatal_lang_error('event_month_missing', false); |
|
| 909 | - } |
|
| 910 | - elseif (isset($_POST['start_datetime'])) |
|
| 932 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 933 | + fatal_lang_error('invalid_date', false); |
|
| 934 | + } |
|
| 935 | + if (empty($d['year'])) { |
|
| 936 | + fatal_lang_error('event_year_missing', false); |
|
| 937 | + } |
|
| 938 | + if (empty($d['month'])) { |
|
| 939 | + fatal_lang_error('event_month_missing', false); |
|
| 940 | + } |
|
| 941 | + } elseif (isset($_POST['start_datetime'])) |
|
| 911 | 942 | { |
| 912 | 943 | $d = date_parse($_POST['start_datetime']); |
| 913 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 914 | - fatal_lang_error('invalid_date', false); |
|
| 915 | - if (empty($d['year'])) |
|
| 916 | - fatal_lang_error('event_year_missing', false); |
|
| 917 | - if (empty($d['month'])) |
|
| 918 | - fatal_lang_error('event_month_missing', false); |
|
| 944 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 945 | + fatal_lang_error('invalid_date', false); |
|
| 946 | + } |
|
| 947 | + if (empty($d['year'])) { |
|
| 948 | + fatal_lang_error('event_year_missing', false); |
|
| 949 | + } |
|
| 950 | + if (empty($d['month'])) { |
|
| 951 | + fatal_lang_error('event_month_missing', false); |
|
| 952 | + } |
|
| 919 | 953 | } |
| 920 | 954 | // The 2.0 way |
| 921 | 955 | else |
| 922 | 956 | { |
| 923 | 957 | // No month? No year? |
| 924 | - if (!isset($_POST['month'])) |
|
| 925 | - fatal_lang_error('event_month_missing', false); |
|
| 926 | - if (!isset($_POST['year'])) |
|
| 927 | - fatal_lang_error('event_year_missing', false); |
|
| 958 | + if (!isset($_POST['month'])) { |
|
| 959 | + fatal_lang_error('event_month_missing', false); |
|
| 960 | + } |
|
| 961 | + if (!isset($_POST['year'])) { |
|
| 962 | + fatal_lang_error('event_year_missing', false); |
|
| 963 | + } |
|
| 928 | 964 | |
| 929 | 965 | // Check the month and year... |
| 930 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
| 931 | - fatal_lang_error('invalid_month', false); |
|
| 932 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
| 933 | - fatal_lang_error('invalid_year', false); |
|
| 966 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
| 967 | + fatal_lang_error('invalid_month', false); |
|
| 968 | + } |
|
| 969 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
| 970 | + fatal_lang_error('invalid_year', false); |
|
| 971 | + } |
|
| 934 | 972 | } |
| 935 | 973 | } |
| 936 | 974 | |
@@ -940,8 +978,9 @@ discard block |
||
| 940 | 978 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
| 941 | 979 | if (isset($_POST['span'])) |
| 942 | 980 | { |
| 943 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
| 944 | - fatal_lang_error('invalid_days_numb', false); |
|
| 981 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
| 982 | + fatal_lang_error('invalid_days_numb', false); |
|
| 983 | + } |
|
| 945 | 984 | } |
| 946 | 985 | |
| 947 | 986 | // There is no need to validate the following values if we are just deleting the event. |
@@ -951,24 +990,29 @@ discard block |
||
| 951 | 990 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
| 952 | 991 | { |
| 953 | 992 | // No day? |
| 954 | - if (!isset($_POST['day'])) |
|
| 955 | - fatal_lang_error('event_day_missing', false); |
|
| 993 | + if (!isset($_POST['day'])) { |
|
| 994 | + fatal_lang_error('event_day_missing', false); |
|
| 995 | + } |
|
| 956 | 996 | |
| 957 | 997 | // Bad day? |
| 958 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
| 959 | - fatal_lang_error('invalid_date', false); |
|
| 998 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
| 999 | + fatal_lang_error('invalid_date', false); |
|
| 1000 | + } |
|
| 960 | 1001 | } |
| 961 | 1002 | |
| 962 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
| 963 | - fatal_lang_error('event_title_missing', false); |
|
| 964 | - elseif (!isset($_POST['evtitle'])) |
|
| 965 | - $_POST['evtitle'] = $_POST['subject']; |
|
| 1003 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
| 1004 | + fatal_lang_error('event_title_missing', false); |
|
| 1005 | + } elseif (!isset($_POST['evtitle'])) { |
|
| 1006 | + $_POST['evtitle'] = $_POST['subject']; |
|
| 1007 | + } |
|
| 966 | 1008 | |
| 967 | 1009 | // No title? |
| 968 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 969 | - fatal_lang_error('no_event_title', false); |
|
| 970 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
| 971 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 1010 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1011 | + fatal_lang_error('no_event_title', false); |
|
| 1012 | + } |
|
| 1013 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
| 1014 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 1015 | + } |
|
| 972 | 1016 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
| 973 | 1017 | } |
| 974 | 1018 | } |
@@ -995,8 +1039,9 @@ discard block |
||
| 995 | 1039 | ); |
| 996 | 1040 | |
| 997 | 1041 | // No results, return false. |
| 998 | - if ($smcFunc['db_num_rows'] === 0) |
|
| 999 | - return false; |
|
| 1042 | + if ($smcFunc['db_num_rows'] === 0) { |
|
| 1043 | + return false; |
|
| 1044 | + } |
|
| 1000 | 1045 | |
| 1001 | 1046 | // Grab the results and return. |
| 1002 | 1047 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1130,8 +1175,9 @@ discard block |
||
| 1130 | 1175 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
| 1131 | 1176 | |
| 1132 | 1177 | $column_clauses = array(); |
| 1133 | - foreach ($event_columns as $col => $crit) |
|
| 1134 | - $column_clauses[] = $col . ' = ' . $crit; |
|
| 1178 | + foreach ($event_columns as $col => $crit) { |
|
| 1179 | + $column_clauses[] = $col . ' = ' . $crit; |
|
| 1180 | + } |
|
| 1135 | 1181 | |
| 1136 | 1182 | $smcFunc['db_query']('', ' |
| 1137 | 1183 | UPDATE {db_prefix}calendar |
@@ -1216,8 +1262,9 @@ discard block |
||
| 1216 | 1262 | ); |
| 1217 | 1263 | |
| 1218 | 1264 | // If nothing returned, we are in poo, poo. |
| 1219 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 1220 | - return false; |
|
| 1265 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1266 | + return false; |
|
| 1267 | + } |
|
| 1221 | 1268 | |
| 1222 | 1269 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1223 | 1270 | $smcFunc['db_free_result']($request); |
@@ -1225,8 +1272,9 @@ discard block |
||
| 1225 | 1272 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 1226 | 1273 | |
| 1227 | 1274 | // Sanity check |
| 1228 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 1229 | - return false; |
|
| 1275 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 1276 | + return false; |
|
| 1277 | + } |
|
| 1230 | 1278 | |
| 1231 | 1279 | $return_value = array( |
| 1232 | 1280 | 'boards' => array(), |
@@ -1363,24 +1411,27 @@ discard block |
||
| 1363 | 1411 | |
| 1364 | 1412 | // Set $span, in case we need it |
| 1365 | 1413 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
| 1366 | - if ($span > 0) |
|
| 1367 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1414 | + if ($span > 0) { |
|
| 1415 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1416 | + } |
|
| 1368 | 1417 | |
| 1369 | 1418 | // Define the timezone for this event, falling back to the default if not provided |
| 1370 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1371 | - $tz = $eventOptions['tz']; |
|
| 1372 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1373 | - $tz = $_POST['tz']; |
|
| 1374 | - else |
|
| 1375 | - $tz = getUserTimezone(); |
|
| 1419 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1420 | + $tz = $eventOptions['tz']; |
|
| 1421 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1422 | + $tz = $_POST['tz']; |
|
| 1423 | + } else { |
|
| 1424 | + $tz = getUserTimezone(); |
|
| 1425 | + } |
|
| 1376 | 1426 | |
| 1377 | 1427 | // Is this supposed to be an all day event, or should it have specific start and end times? |
| 1378 | - if (isset($eventOptions['allday'])) |
|
| 1379 | - $allday = $eventOptions['allday']; |
|
| 1380 | - elseif (empty($_POST['allday'])) |
|
| 1381 | - $allday = false; |
|
| 1382 | - else |
|
| 1383 | - $allday = true; |
|
| 1428 | + if (isset($eventOptions['allday'])) { |
|
| 1429 | + $allday = $eventOptions['allday']; |
|
| 1430 | + } elseif (empty($_POST['allday'])) { |
|
| 1431 | + $allday = false; |
|
| 1432 | + } else { |
|
| 1433 | + $allday = true; |
|
| 1434 | + } |
|
| 1384 | 1435 | |
| 1385 | 1436 | // Input might come as individual parameters... |
| 1386 | 1437 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1407,10 +1458,12 @@ discard block |
||
| 1407 | 1458 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
| 1408 | 1459 | |
| 1409 | 1460 | // If the date and time were given in separate strings, combine them |
| 1410 | - if (empty($start_string) && isset($start_date_string)) |
|
| 1411 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1412 | - if (empty($end_string) && isset($end_date_string)) |
|
| 1413 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1461 | + if (empty($start_string) && isset($start_date_string)) { |
|
| 1462 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1463 | + } |
|
| 1464 | + if (empty($end_string) && isset($end_date_string)) { |
|
| 1465 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1466 | + } |
|
| 1414 | 1467 | |
| 1415 | 1468 | // If some form of string input was given, override individually defined options with it |
| 1416 | 1469 | if (isset($start_string)) |
@@ -1501,10 +1554,11 @@ discard block |
||
| 1501 | 1554 | if ($start_object >= $end_object) |
| 1502 | 1555 | { |
| 1503 | 1556 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1504 | - if ($span > 0) |
|
| 1505 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1506 | - else |
|
| 1507 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1557 | + if ($span > 0) { |
|
| 1558 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1559 | + } else { |
|
| 1560 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1561 | + } |
|
| 1508 | 1562 | } |
| 1509 | 1563 | |
| 1510 | 1564 | // Is $end_object too late? |
@@ -1517,9 +1571,9 @@ discard block |
||
| 1517 | 1571 | { |
| 1518 | 1572 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1519 | 1573 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
| 1574 | + } else { |
|
| 1575 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1520 | 1576 | } |
| 1521 | - else |
|
| 1522 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1523 | 1577 | } |
| 1524 | 1578 | } |
| 1525 | 1579 | |
@@ -1532,8 +1586,7 @@ discard block |
||
| 1532 | 1586 | $start_time = null; |
| 1533 | 1587 | $end_time = null; |
| 1534 | 1588 | $tz = null; |
| 1535 | - } |
|
| 1536 | - else |
|
| 1589 | + } else |
|
| 1537 | 1590 | { |
| 1538 | 1591 | $start_time = date_format($start_object, 'H:i:s'); |
| 1539 | 1592 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1559,19 +1612,21 @@ discard block |
||
| 1559 | 1612 | // First, try to create a better date format, ignoring the "time" elements. |
| 1560 | 1613 | if (empty($date_format)) |
| 1561 | 1614 | { |
| 1562 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1563 | - $date_format = '%F'; |
|
| 1564 | - else |
|
| 1565 | - $date_format = $matches[0]; |
|
| 1615 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1616 | + $date_format = '%F'; |
|
| 1617 | + } else { |
|
| 1618 | + $date_format = $matches[0]; |
|
| 1619 | + } |
|
| 1566 | 1620 | } |
| 1567 | 1621 | |
| 1568 | 1622 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 1569 | 1623 | if (empty($time_format)) |
| 1570 | 1624 | { |
| 1571 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1572 | - $time_format = '%k:%M'; |
|
| 1573 | - else |
|
| 1574 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1625 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1626 | + $time_format = '%k:%M'; |
|
| 1627 | + } else { |
|
| 1628 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1629 | + } |
|
| 1575 | 1630 | } |
| 1576 | 1631 | |
| 1577 | 1632 | // Should this be an all day event? |
@@ -1581,11 +1636,13 @@ discard block |
||
| 1581 | 1636 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
| 1582 | 1637 | |
| 1583 | 1638 | // We need to have a defined timezone in the steps below |
| 1584 | - if (empty($row['timezone'])) |
|
| 1585 | - $row['timezone'] = getUserTimezone(); |
|
| 1639 | + if (empty($row['timezone'])) { |
|
| 1640 | + $row['timezone'] = getUserTimezone(); |
|
| 1641 | + } |
|
| 1586 | 1642 | |
| 1587 | - if (empty($timezone_array[$row['timezone']])) |
|
| 1588 | - $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
| 1643 | + if (empty($timezone_array[$row['timezone']])) { |
|
| 1644 | + $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
| 1645 | + } |
|
| 1589 | 1646 | |
| 1590 | 1647 | // Get most of the standard date information for the start and end datetimes |
| 1591 | 1648 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1633,8 +1690,9 @@ discard block |
||
| 1633 | 1690 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
| 1634 | 1691 | static $member_cache = array(); |
| 1635 | 1692 | |
| 1636 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
| 1637 | - $id_member = $context['user']['id']; |
|
| 1693 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
| 1694 | + $id_member = $context['user']['id']; |
|
| 1695 | + } |
|
| 1638 | 1696 | |
| 1639 | 1697 | //check if the cache got the data |
| 1640 | 1698 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1663,11 +1721,13 @@ discard block |
||
| 1663 | 1721 | $smcFunc['db_free_result']($request); |
| 1664 | 1722 | } |
| 1665 | 1723 | |
| 1666 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1667 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1724 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1725 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1726 | + } |
|
| 1668 | 1727 | |
| 1669 | - if (isset($id_member)) |
|
| 1670 | - $member_cache[$id_member] = $timezone; |
|
| 1728 | + if (isset($id_member)) { |
|
| 1729 | + $member_cache[$id_member] = $timezone; |
|
| 1730 | + } |
|
| 1671 | 1731 | |
| 1672 | 1732 | return $timezone; |
| 1673 | 1733 | } |
@@ -1696,8 +1756,9 @@ discard block |
||
| 1696 | 1756 | ) |
| 1697 | 1757 | ); |
| 1698 | 1758 | $holidays = array(); |
| 1699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1700 | - $holidays[] = $row; |
|
| 1759 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1760 | + $holidays[] = $row; |
|
| 1761 | + } |
|
| 1701 | 1762 | $smcFunc['db_free_result']($request); |
| 1702 | 1763 | |
| 1703 | 1764 | return $holidays; |
@@ -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', 'login', 'post') as $type) |
|
| 171 | - if ($row['cannot_' . $type]) |
|
| 175 | + foreach (array('access', '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>'); |
@@ -195,9 +202,10 @@ discard block |
||
| 195 | 202 | $context['print_custom_fields'] = array(); |
| 196 | 203 | |
| 197 | 204 | // Any custom profile fields? |
| 198 | - if (!empty($context['custom_fields'])) |
|
| 199 | - foreach ($context['custom_fields'] as $custom) |
|
| 205 | + if (!empty($context['custom_fields'])) { |
|
| 206 | + foreach ($context['custom_fields'] as $custom) |
|
| 200 | 207 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 208 | + } |
|
| 201 | 209 | |
| 202 | 210 | } |
| 203 | 211 | |
@@ -242,16 +250,18 @@ 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 | if($withSender) |
| 251 | 260 | { |
| 252 | 261 | $senders = loadMemberData($senders); |
| 253 | - foreach ($senders as $member) |
|
| 254 | - loadMemberContext($member); |
|
| 262 | + foreach ($senders as $member) { |
|
| 263 | + loadMemberContext($member); |
|
| 264 | + } |
|
| 255 | 265 | } |
| 256 | 266 | |
| 257 | 267 | // Now go through and actually make with the text. |
@@ -266,12 +276,15 @@ discard block |
||
| 266 | 276 | $msgs = array(); |
| 267 | 277 | foreach ($alerts as $id_alert => $alert) |
| 268 | 278 | { |
| 269 | - if (isset($alert['extra']['board'])) |
|
| 270 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 271 | - if (isset($alert['extra']['topic'])) |
|
| 272 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 273 | - if ($alert['content_type'] == 'msg') |
|
| 274 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 279 | + if (isset($alert['extra']['board'])) { |
|
| 280 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 281 | + } |
|
| 282 | + if (isset($alert['extra']['topic'])) { |
|
| 283 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 284 | + } |
|
| 285 | + if ($alert['content_type'] == 'msg') { |
|
| 286 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 287 | + } |
|
| 275 | 288 | } |
| 276 | 289 | |
| 277 | 290 | // 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. |
@@ -286,8 +299,9 @@ discard block |
||
| 286 | 299 | 'boards' => array_keys($boards), |
| 287 | 300 | ) |
| 288 | 301 | ); |
| 289 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 290 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 303 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 304 | + } |
|
| 291 | 305 | } |
| 292 | 306 | if (!empty($topics)) |
| 293 | 307 | { |
@@ -302,8 +316,9 @@ discard block |
||
| 302 | 316 | 'topics' => array_keys($topics), |
| 303 | 317 | ) |
| 304 | 318 | ); |
| 305 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 306 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 319 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 320 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 321 | + } |
|
| 307 | 322 | } |
| 308 | 323 | if (!empty($msgs)) |
| 309 | 324 | { |
@@ -318,44 +333,51 @@ discard block |
||
| 318 | 333 | 'msgs' => array_keys($msgs), |
| 319 | 334 | ) |
| 320 | 335 | ); |
| 321 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 322 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 336 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 337 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 338 | + } |
|
| 323 | 339 | } |
| 324 | 340 | |
| 325 | 341 | // 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) |
| 326 | 342 | foreach ($alerts as $id_alert => $alert) |
| 327 | 343 | { |
| 328 | - if (!empty($alert['text'])) |
|
| 329 | - continue; |
|
| 330 | - if (isset($alert['extra']['board'])) |
|
| 331 | - if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
| 344 | + if (!empty($alert['text'])) { |
|
| 345 | + continue; |
|
| 346 | + } |
|
| 347 | + if (isset($alert['extra']['board'])) { |
|
| 348 | + if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
| 332 | 349 | { |
| 333 | 350 | unset($alerts[$id_alert]); |
| 351 | + } |
|
| 334 | 352 | continue; |
| 353 | + } else { |
|
| 354 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 335 | 355 | } |
| 336 | - else |
|
| 337 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 338 | - if (isset($alert['extra']['topic'])) |
|
| 339 | - if ($alert['extra']['topic'] == $txt['topic_na']) |
|
| 356 | + if (isset($alert['extra']['topic'])) { |
|
| 357 | + if ($alert['extra']['topic'] == $txt['topic_na']) |
|
| 340 | 358 | { |
| 341 | 359 | unset($alerts[$id_alert]); |
| 360 | + } |
|
| 342 | 361 | continue; |
| 362 | + } else { |
|
| 363 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 343 | 364 | } |
| 344 | - else |
|
| 345 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 346 | - if ($alert['content_type'] == 'msg') |
|
| 347 | - if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
| 365 | + if ($alert['content_type'] == 'msg') { |
|
| 366 | + if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
| 348 | 367 | { |
| 349 | 368 | unset($alerts[$id_alert]); |
| 369 | + } |
|
| 350 | 370 | continue; |
| 351 | - } |
|
| 352 | - else |
|
| 353 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 354 | - if ($alert['content_type'] == 'profile') |
|
| 355 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 371 | + } else { |
|
| 372 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 373 | + } |
|
| 374 | + if ($alert['content_type'] == 'profile') { |
|
| 375 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 376 | + } |
|
| 356 | 377 | |
| 357 | - if (!empty($memberContext[$alert['sender_id']])) |
|
| 358 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 378 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
| 379 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 380 | + } |
|
| 359 | 381 | |
| 360 | 382 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
| 361 | 383 | if (isset($txt[$string])) |
@@ -443,11 +465,11 @@ discard block |
||
| 443 | 465 | checkSession('request'); |
| 444 | 466 | |
| 445 | 467 | // Call it! |
| 446 | - if ($action == 'remove') |
|
| 447 | - alert_delete($toMark, $memID); |
|
| 448 | - |
|
| 449 | - else |
|
| 450 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 468 | + if ($action == 'remove') { |
|
| 469 | + alert_delete($toMark, $memID); |
|
| 470 | + } else { |
|
| 471 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 472 | + } |
|
| 451 | 473 | |
| 452 | 474 | // Set a nice update message. |
| 453 | 475 | $_SESSION['update_message'] = true; |
@@ -497,23 +519,27 @@ discard block |
||
| 497 | 519 | ); |
| 498 | 520 | |
| 499 | 521 | // Set the page title |
| 500 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
| 501 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 502 | - else |
|
| 503 | - $context['page_title'] = $txt['showPosts']; |
|
| 522 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
| 523 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 524 | + } else { |
|
| 525 | + $context['page_title'] = $txt['showPosts']; |
|
| 526 | + } |
|
| 504 | 527 | |
| 505 | 528 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
| 506 | 529 | |
| 507 | 530 | // Is the load average too high to allow searching just now? |
| 508 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
| 509 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 531 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
| 532 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 533 | + } |
|
| 510 | 534 | |
| 511 | 535 | // If we're specifically dealing with attachments use that function! |
| 512 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
| 513 | - return showAttachments($memID); |
|
| 536 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
| 537 | + return showAttachments($memID); |
|
| 538 | + } |
|
| 514 | 539 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
| 515 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
| 516 | - return showUnwatched($memID); |
|
| 540 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
| 541 | + return showUnwatched($memID); |
|
| 542 | + } |
|
| 517 | 543 | |
| 518 | 544 | // Are we just viewing topics? |
| 519 | 545 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -536,27 +562,30 @@ discard block |
||
| 536 | 562 | $smcFunc['db_free_result']($request); |
| 537 | 563 | |
| 538 | 564 | // Trying to remove a message that doesn't exist. |
| 539 | - if (empty($info)) |
|
| 540 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 565 | + if (empty($info)) { |
|
| 566 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 567 | + } |
|
| 541 | 568 | |
| 542 | 569 | // We can be lazy, since removeMessage() will check the permissions for us. |
| 543 | 570 | require_once($sourcedir . '/RemoveTopic.php'); |
| 544 | 571 | removeMessage((int) $_GET['delete']); |
| 545 | 572 | |
| 546 | 573 | // Add it to the mod log. |
| 547 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 548 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 574 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 575 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 576 | + } |
|
| 549 | 577 | |
| 550 | 578 | // Back to... where we are now ;). |
| 551 | 579 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
| 552 | 580 | } |
| 553 | 581 | |
| 554 | 582 | // Default to 10. |
| 555 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 556 | - $_REQUEST['viewscount'] = '10'; |
|
| 583 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 584 | + $_REQUEST['viewscount'] = '10'; |
|
| 585 | + } |
|
| 557 | 586 | |
| 558 | - if ($context['is_topics']) |
|
| 559 | - $request = $smcFunc['db_query']('', ' |
|
| 587 | + if ($context['is_topics']) { |
|
| 588 | + $request = $smcFunc['db_query']('', ' |
|
| 560 | 589 | SELECT COUNT(*) |
| 561 | 590 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 562 | 591 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -569,8 +598,8 @@ discard block |
||
| 569 | 598 | 'board' => $board, |
| 570 | 599 | ) |
| 571 | 600 | ); |
| 572 | - else |
|
| 573 | - $request = $smcFunc['db_query']('', ' |
|
| 601 | + } else { |
|
| 602 | + $request = $smcFunc['db_query']('', ' |
|
| 574 | 603 | SELECT COUNT(*) |
| 575 | 604 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 576 | 605 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -583,6 +612,7 @@ discard block |
||
| 583 | 612 | 'board' => $board, |
| 584 | 613 | ) |
| 585 | 614 | ); |
| 615 | + } |
|
| 586 | 616 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
| 587 | 617 | $smcFunc['db_free_result']($request); |
| 588 | 618 | |
@@ -603,10 +633,11 @@ discard block |
||
| 603 | 633 | |
| 604 | 634 | $range_limit = ''; |
| 605 | 635 | |
| 606 | - if ($context['is_topics']) |
|
| 607 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 608 | - else |
|
| 609 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 636 | + if ($context['is_topics']) { |
|
| 637 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 638 | + } else { |
|
| 639 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 640 | + } |
|
| 610 | 641 | |
| 611 | 642 | $maxIndex = $maxPerPage; |
| 612 | 643 | |
@@ -632,9 +663,9 @@ discard block |
||
| 632 | 663 | { |
| 633 | 664 | $margin *= 5; |
| 634 | 665 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
| 666 | + } else { |
|
| 667 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 635 | 668 | } |
| 636 | - else |
|
| 637 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 638 | 669 | } |
| 639 | 670 | |
| 640 | 671 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -666,8 +697,7 @@ discard block |
||
| 666 | 697 | 'max' => $maxIndex, |
| 667 | 698 | ) |
| 668 | 699 | ); |
| 669 | - } |
|
| 670 | - else |
|
| 700 | + } else |
|
| 671 | 701 | { |
| 672 | 702 | $request = $smcFunc['db_query']('', ' |
| 673 | 703 | SELECT |
@@ -696,8 +726,9 @@ discard block |
||
| 696 | 726 | } |
| 697 | 727 | |
| 698 | 728 | // Make sure we quit this loop. |
| 699 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
| 700 | - break; |
|
| 729 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
| 730 | + break; |
|
| 731 | + } |
|
| 701 | 732 | $looped = true; |
| 702 | 733 | $range_limit = ''; |
| 703 | 734 | } |
@@ -741,19 +772,21 @@ discard block |
||
| 741 | 772 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
| 742 | 773 | ); |
| 743 | 774 | |
| 744 | - if ($user_info['id'] == $row['id_member_started']) |
|
| 745 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
| 775 | + if ($user_info['id'] == $row['id_member_started']) { |
|
| 776 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
| 777 | + } |
|
| 746 | 778 | $board_ids['any'][$row['id_board']][] = $counter; |
| 747 | 779 | } |
| 748 | 780 | $smcFunc['db_free_result']($request); |
| 749 | 781 | |
| 750 | 782 | // All posts were retrieved in reverse order, get them right again. |
| 751 | - if ($reverse) |
|
| 752 | - $context['posts'] = array_reverse($context['posts'], true); |
|
| 783 | + if ($reverse) { |
|
| 784 | + $context['posts'] = array_reverse($context['posts'], true); |
|
| 785 | + } |
|
| 753 | 786 | |
| 754 | 787 | // These are all the permissions that are different from board to board.. |
| 755 | - if ($context['is_topics']) |
|
| 756 | - $permissions = array( |
|
| 788 | + if ($context['is_topics']) { |
|
| 789 | + $permissions = array( |
|
| 757 | 790 | 'own' => array( |
| 758 | 791 | 'post_reply_own' => 'can_reply', |
| 759 | 792 | ), |
@@ -761,8 +794,8 @@ discard block |
||
| 761 | 794 | 'post_reply_any' => 'can_reply', |
| 762 | 795 | ) |
| 763 | 796 | ); |
| 764 | - else |
|
| 765 | - $permissions = array( |
|
| 797 | + } else { |
|
| 798 | + $permissions = array( |
|
| 766 | 799 | 'own' => array( |
| 767 | 800 | 'post_reply_own' => 'can_reply', |
| 768 | 801 | 'delete_own' => 'can_delete', |
@@ -772,6 +805,7 @@ discard block |
||
| 772 | 805 | 'delete_any' => 'can_delete', |
| 773 | 806 | ) |
| 774 | 807 | ); |
| 808 | + } |
|
| 775 | 809 | |
| 776 | 810 | // For every permission in the own/any lists... |
| 777 | 811 | foreach ($permissions as $type => $list) |
@@ -782,19 +816,22 @@ discard block |
||
| 782 | 816 | $boards = boardsAllowedTo($permission); |
| 783 | 817 | |
| 784 | 818 | // Hmm, they can do it on all boards, can they? |
| 785 | - if (!empty($boards) && $boards[0] == 0) |
|
| 786 | - $boards = array_keys($board_ids[$type]); |
|
| 819 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 820 | + $boards = array_keys($board_ids[$type]); |
|
| 821 | + } |
|
| 787 | 822 | |
| 788 | 823 | // Now go through each board they can do the permission on. |
| 789 | 824 | foreach ($boards as $board_id) |
| 790 | 825 | { |
| 791 | 826 | // There aren't any posts displayed from this board. |
| 792 | - if (!isset($board_ids[$type][$board_id])) |
|
| 793 | - continue; |
|
| 827 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 828 | + continue; |
|
| 829 | + } |
|
| 794 | 830 | |
| 795 | 831 | // Set the permission to true ;). |
| 796 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 797 | - $context['posts'][$counter][$allowed] = true; |
|
| 832 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 833 | + $context['posts'][$counter][$allowed] = true; |
|
| 834 | + } |
|
| 798 | 835 | } |
| 799 | 836 | } |
| 800 | 837 | } |
@@ -825,8 +862,9 @@ discard block |
||
| 825 | 862 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
| 826 | 863 | |
| 827 | 864 | // Make sure we can't actually see anything... |
| 828 | - if (empty($boardsAllowed)) |
|
| 829 | - $boardsAllowed = array(-1); |
|
| 865 | + if (empty($boardsAllowed)) { |
|
| 866 | + $boardsAllowed = array(-1); |
|
| 867 | + } |
|
| 830 | 868 | |
| 831 | 869 | require_once($sourcedir . '/Subs-List.php'); |
| 832 | 870 | |
@@ -977,8 +1015,8 @@ discard block |
||
| 977 | 1015 | ) |
| 978 | 1016 | ); |
| 979 | 1017 | $attachments = array(); |
| 980 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 981 | - $attachments[] = array( |
|
| 1018 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1019 | + $attachments[] = array( |
|
| 982 | 1020 | 'id' => $row['id_attach'], |
| 983 | 1021 | 'filename' => $row['filename'], |
| 984 | 1022 | 'downloads' => $row['downloads'], |
@@ -990,6 +1028,7 @@ discard block |
||
| 990 | 1028 | 'board_name' => $row['name'], |
| 991 | 1029 | 'approved' => $row['approved'], |
| 992 | 1030 | ); |
| 1031 | + } |
|
| 993 | 1032 | |
| 994 | 1033 | $smcFunc['db_free_result']($request); |
| 995 | 1034 | |
@@ -1044,8 +1083,9 @@ discard block |
||
| 1044 | 1083 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
| 1045 | 1084 | |
| 1046 | 1085 | // Only the owner can see the list (if the function is enabled of course) |
| 1047 | - if ($user_info['id'] != $memID) |
|
| 1048 | - return; |
|
| 1086 | + if ($user_info['id'] != $memID) { |
|
| 1087 | + return; |
|
| 1088 | + } |
|
| 1049 | 1089 | |
| 1050 | 1090 | require_once($sourcedir . '/Subs-List.php'); |
| 1051 | 1091 | |
@@ -1191,8 +1231,9 @@ discard block |
||
| 1191 | 1231 | ); |
| 1192 | 1232 | |
| 1193 | 1233 | $topics = array(); |
| 1194 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1195 | - $topics[] = $row['id_topic']; |
|
| 1234 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1235 | + $topics[] = $row['id_topic']; |
|
| 1236 | + } |
|
| 1196 | 1237 | |
| 1197 | 1238 | $smcFunc['db_free_result']($request); |
| 1198 | 1239 | |
@@ -1212,8 +1253,9 @@ discard block |
||
| 1212 | 1253 | 'topics' => $topics, |
| 1213 | 1254 | ) |
| 1214 | 1255 | ); |
| 1215 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1216 | - $topicsInfo[] = $row; |
|
| 1256 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1257 | + $topicsInfo[] = $row; |
|
| 1258 | + } |
|
| 1217 | 1259 | $smcFunc['db_free_result']($request); |
| 1218 | 1260 | } |
| 1219 | 1261 | |
@@ -1261,8 +1303,9 @@ discard block |
||
| 1261 | 1303 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
| 1262 | 1304 | |
| 1263 | 1305 | // Is the load average too high to allow searching just now? |
| 1264 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
| 1265 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1306 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
| 1307 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1308 | + } |
|
| 1266 | 1309 | |
| 1267 | 1310 | // General user statistics. |
| 1268 | 1311 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1405,11 +1448,13 @@ discard block |
||
| 1405 | 1448 | } |
| 1406 | 1449 | $smcFunc['db_free_result']($result); |
| 1407 | 1450 | |
| 1408 | - if ($maxPosts > 0) |
|
| 1409 | - for ($hour = 0; $hour < 24; $hour++) |
|
| 1451 | + if ($maxPosts > 0) { |
|
| 1452 | + for ($hour = 0; |
|
| 1453 | + } |
|
| 1454 | + $hour < 24; $hour++) |
|
| 1410 | 1455 | { |
| 1411 | - if (!isset($context['posts_by_time'][$hour])) |
|
| 1412 | - $context['posts_by_time'][$hour] = array( |
|
| 1456 | + if (!isset($context['posts_by_time'][$hour])) { |
|
| 1457 | + $context['posts_by_time'][$hour] = array( |
|
| 1413 | 1458 | 'hour' => $hour, |
| 1414 | 1459 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
| 1415 | 1460 | 'posts' => 0, |
@@ -1417,7 +1462,7 @@ discard block |
||
| 1417 | 1462 | 'relative_percent' => 0, |
| 1418 | 1463 | 'is_last' => $hour == 23, |
| 1419 | 1464 | ); |
| 1420 | - else |
|
| 1465 | + } else |
|
| 1421 | 1466 | { |
| 1422 | 1467 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
| 1423 | 1468 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1450,8 +1495,9 @@ discard block |
||
| 1450 | 1495 | |
| 1451 | 1496 | foreach ($subActions as $sa => $action) |
| 1452 | 1497 | { |
| 1453 | - if (!allowedTo($action[2])) |
|
| 1454 | - unset($subActions[$sa]); |
|
| 1498 | + if (!allowedTo($action[2])) { |
|
| 1499 | + unset($subActions[$sa]); |
|
| 1500 | + } |
|
| 1455 | 1501 | } |
| 1456 | 1502 | |
| 1457 | 1503 | // Create the tabs for the template. |
@@ -1469,15 +1515,18 @@ discard block |
||
| 1469 | 1515 | ); |
| 1470 | 1516 | |
| 1471 | 1517 | // Moderation must be on to track edits. |
| 1472 | - if (empty($modSettings['userlog_enabled'])) |
|
| 1473 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1518 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 1519 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1520 | + } |
|
| 1474 | 1521 | |
| 1475 | 1522 | // Group requests must be active to show it... |
| 1476 | - if (empty($modSettings['show_group_membership'])) |
|
| 1477 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1523 | + if (empty($modSettings['show_group_membership'])) { |
|
| 1524 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1525 | + } |
|
| 1478 | 1526 | |
| 1479 | - if (empty($subActions)) |
|
| 1480 | - fatal_lang_error('no_access', false); |
|
| 1527 | + if (empty($subActions)) { |
|
| 1528 | + fatal_lang_error('no_access', false); |
|
| 1529 | + } |
|
| 1481 | 1530 | |
| 1482 | 1531 | $keys = array_keys($subActions); |
| 1483 | 1532 | $default = array_shift($keys); |
@@ -1490,9 +1539,10 @@ discard block |
||
| 1490 | 1539 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
| 1491 | 1540 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
| 1492 | 1541 | |
| 1493 | - if (!empty($call)) |
|
| 1494 | - call_user_func($call, $memID); |
|
| 1495 | -} |
|
| 1542 | + if (!empty($call)) { |
|
| 1543 | + call_user_func($call, $memID); |
|
| 1544 | + } |
|
| 1545 | + } |
|
| 1496 | 1546 | |
| 1497 | 1547 | /** |
| 1498 | 1548 | * Handles tracking a user's activity |
@@ -1508,8 +1558,9 @@ discard block |
||
| 1508 | 1558 | isAllowedTo('moderate_forum'); |
| 1509 | 1559 | |
| 1510 | 1560 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
| 1511 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
| 1512 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1561 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
| 1562 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1563 | + } |
|
| 1513 | 1564 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
| 1514 | 1565 | |
| 1515 | 1566 | // Set the options for the list component. |
@@ -1675,8 +1726,9 @@ discard block |
||
| 1675 | 1726 | ) |
| 1676 | 1727 | ); |
| 1677 | 1728 | $message_members = array(); |
| 1678 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1679 | - $message_members[] = $row['id_member']; |
|
| 1729 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1730 | + $message_members[] = $row['id_member']; |
|
| 1731 | + } |
|
| 1680 | 1732 | $smcFunc['db_free_result']($request); |
| 1681 | 1733 | |
| 1682 | 1734 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1691,8 +1743,9 @@ discard block |
||
| 1691 | 1743 | 'ip_list' => $ips, |
| 1692 | 1744 | ) |
| 1693 | 1745 | ); |
| 1694 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1695 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1746 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1747 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1748 | + } |
|
| 1696 | 1749 | $smcFunc['db_free_result']($request); |
| 1697 | 1750 | } |
| 1698 | 1751 | |
@@ -1706,8 +1759,9 @@ discard block |
||
| 1706 | 1759 | 'ip_list' => $ips, |
| 1707 | 1760 | ) |
| 1708 | 1761 | ); |
| 1709 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1710 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1762 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1763 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1764 | + } |
|
| 1711 | 1765 | $smcFunc['db_free_result']($request); |
| 1712 | 1766 | } |
| 1713 | 1767 | } |
@@ -1767,8 +1821,8 @@ discard block |
||
| 1767 | 1821 | )) |
| 1768 | 1822 | ); |
| 1769 | 1823 | $error_messages = array(); |
| 1770 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1771 | - $error_messages[] = array( |
|
| 1824 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1825 | + $error_messages[] = array( |
|
| 1772 | 1826 | 'ip' => inet_dtop($row['ip']), |
| 1773 | 1827 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
| 1774 | 1828 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1776,6 +1830,7 @@ discard block |
||
| 1776 | 1830 | 'time' => timeformat($row['log_time']), |
| 1777 | 1831 | 'timestamp' => forum_time(true, $row['log_time']), |
| 1778 | 1832 | ); |
| 1833 | + } |
|
| 1779 | 1834 | $smcFunc['db_free_result']($request); |
| 1780 | 1835 | |
| 1781 | 1836 | return $error_messages; |
@@ -1838,8 +1893,8 @@ discard block |
||
| 1838 | 1893 | )) |
| 1839 | 1894 | ); |
| 1840 | 1895 | $messages = array(); |
| 1841 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1842 | - $messages[] = array( |
|
| 1896 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1897 | + $messages[] = array( |
|
| 1843 | 1898 | 'ip' => inet_dtop($row['poster_ip']), |
| 1844 | 1899 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
| 1845 | 1900 | 'board' => array( |
@@ -1852,6 +1907,7 @@ discard block |
||
| 1852 | 1907 | 'time' => timeformat($row['poster_time']), |
| 1853 | 1908 | 'timestamp' => forum_time(true, $row['poster_time']) |
| 1854 | 1909 | ); |
| 1910 | + } |
|
| 1855 | 1911 | $smcFunc['db_free_result']($request); |
| 1856 | 1912 | |
| 1857 | 1913 | return $messages; |
@@ -1878,19 +1934,20 @@ discard block |
||
| 1878 | 1934 | $context['sub_template'] = 'trackIP'; |
| 1879 | 1935 | $context['page_title'] = $txt['profile']; |
| 1880 | 1936 | $context['base_url'] = $scripturl . '?action=trackip'; |
| 1881 | - } |
|
| 1882 | - else |
|
| 1937 | + } else |
|
| 1883 | 1938 | { |
| 1884 | 1939 | $context['ip'] = $user_profile[$memID]['member_ip']; |
| 1885 | 1940 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
| 1886 | 1941 | } |
| 1887 | 1942 | |
| 1888 | 1943 | // Searching? |
| 1889 | - if (isset($_REQUEST['searchip'])) |
|
| 1890 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1944 | + if (isset($_REQUEST['searchip'])) { |
|
| 1945 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1946 | + } |
|
| 1891 | 1947 | |
| 1892 | - if (isValidIP($context['ip']) === false) |
|
| 1893 | - fatal_lang_error('invalid_tracking_ip', false); |
|
| 1948 | + if (isValidIP($context['ip']) === false) { |
|
| 1949 | + fatal_lang_error('invalid_tracking_ip', false); |
|
| 1950 | + } |
|
| 1894 | 1951 | |
| 1895 | 1952 | //mysql didn't support like search with varbinary |
| 1896 | 1953 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1898,8 +1955,9 @@ discard block |
||
| 1898 | 1955 | $ip_var = $context['ip']; |
| 1899 | 1956 | $ip_string = '= {inet:ip_address}'; |
| 1900 | 1957 | |
| 1901 | - if (empty($context['tracking_area'])) |
|
| 1902 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1958 | + if (empty($context['tracking_area'])) { |
|
| 1959 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1960 | + } |
|
| 1903 | 1961 | |
| 1904 | 1962 | $request = $smcFunc['db_query']('', ' |
| 1905 | 1963 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1910,8 +1968,9 @@ discard block |
||
| 1910 | 1968 | ) |
| 1911 | 1969 | ); |
| 1912 | 1970 | $context['ips'] = array(); |
| 1913 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1914 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1971 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1972 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1973 | + } |
|
| 1915 | 1974 | $smcFunc['db_free_result']($request); |
| 1916 | 1975 | |
| 1917 | 1976 | ksort($context['ips']); |
@@ -2140,8 +2199,9 @@ discard block |
||
| 2140 | 2199 | foreach ($context['whois_servers'] as $whois) |
| 2141 | 2200 | { |
| 2142 | 2201 | // Strip off the "decimal point" and anything following... |
| 2143 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
| 2144 | - $context['auto_whois_server'] = $whois; |
|
| 2202 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
| 2203 | + $context['auto_whois_server'] = $whois; |
|
| 2204 | + } |
|
| 2145 | 2205 | } |
| 2146 | 2206 | } |
| 2147 | 2207 | } |
@@ -2158,10 +2218,11 @@ discard block |
||
| 2158 | 2218 | // Gonna want this for the list. |
| 2159 | 2219 | require_once($sourcedir . '/Subs-List.php'); |
| 2160 | 2220 | |
| 2161 | - if ($memID == 0) |
|
| 2162 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2163 | - else |
|
| 2164 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2221 | + if ($memID == 0) { |
|
| 2222 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2223 | + } else { |
|
| 2224 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2225 | + } |
|
| 2165 | 2226 | |
| 2166 | 2227 | // Start with the user messages. |
| 2167 | 2228 | $listOptions = array( |
@@ -2271,12 +2332,13 @@ discard block |
||
| 2271 | 2332 | ) |
| 2272 | 2333 | ); |
| 2273 | 2334 | $logins = array(); |
| 2274 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2275 | - $logins[] = array( |
|
| 2335 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2336 | + $logins[] = array( |
|
| 2276 | 2337 | 'time' => timeformat($row['time']), |
| 2277 | 2338 | 'ip' => inet_dtop($row['ip']), |
| 2278 | 2339 | 'ip2' => inet_dtop($row['ip2']), |
| 2279 | 2340 | ); |
| 2341 | + } |
|
| 2280 | 2342 | $smcFunc['db_free_result']($request); |
| 2281 | 2343 | |
| 2282 | 2344 | return $logins; |
@@ -2301,11 +2363,12 @@ discard block |
||
| 2301 | 2363 | ) |
| 2302 | 2364 | ); |
| 2303 | 2365 | $context['custom_field_titles'] = array(); |
| 2304 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2305 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2366 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2367 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2306 | 2368 | 'title' => $row['field_name'], |
| 2307 | 2369 | 'parse_bbc' => $row['bbc'], |
| 2308 | 2370 | ); |
| 2371 | + } |
|
| 2309 | 2372 | $smcFunc['db_free_result']($request); |
| 2310 | 2373 | |
| 2311 | 2374 | // Set the options for the error lists. |
@@ -2444,19 +2507,22 @@ discard block |
||
| 2444 | 2507 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2445 | 2508 | { |
| 2446 | 2509 | $extra = $smcFunc['json_decode']($row['extra'], true); |
| 2447 | - if (!empty($extra['applicator'])) |
|
| 2448 | - $members[] = $extra['applicator']; |
|
| 2510 | + if (!empty($extra['applicator'])) { |
|
| 2511 | + $members[] = $extra['applicator']; |
|
| 2512 | + } |
|
| 2449 | 2513 | |
| 2450 | 2514 | // Work out what the name of the action is. |
| 2451 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
| 2452 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2453 | - elseif (isset($txt[$row['action']])) |
|
| 2454 | - $action_text = $txt[$row['action']]; |
|
| 2515 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
| 2516 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2517 | + } elseif (isset($txt[$row['action']])) { |
|
| 2518 | + $action_text = $txt[$row['action']]; |
|
| 2519 | + } |
|
| 2455 | 2520 | // Custom field? |
| 2456 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
| 2457 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2458 | - else |
|
| 2459 | - $action_text = $row['action']; |
|
| 2521 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
| 2522 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2523 | + } else { |
|
| 2524 | + $action_text = $row['action']; |
|
| 2525 | + } |
|
| 2460 | 2526 | |
| 2461 | 2527 | // Parse BBC? |
| 2462 | 2528 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2488,13 +2554,15 @@ discard block |
||
| 2488 | 2554 | ) |
| 2489 | 2555 | ); |
| 2490 | 2556 | $members = array(); |
| 2491 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2492 | - $members[$row['id_member']] = $row['real_name']; |
|
| 2557 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2558 | + $members[$row['id_member']] = $row['real_name']; |
|
| 2559 | + } |
|
| 2493 | 2560 | $smcFunc['db_free_result']($request); |
| 2494 | 2561 | |
| 2495 | - foreach ($edits as $key => $value) |
|
| 2496 | - if (isset($members[$value['id_member']])) |
|
| 2562 | + foreach ($edits as $key => $value) { |
|
| 2563 | + if (isset($members[$value['id_member']])) |
|
| 2497 | 2564 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
| 2565 | + } |
|
| 2498 | 2566 | } |
| 2499 | 2567 | |
| 2500 | 2568 | return $edits; |
@@ -2695,10 +2763,11 @@ discard block |
||
| 2695 | 2763 | $context['board'] = $board; |
| 2696 | 2764 | |
| 2697 | 2765 | // Determine which groups this user is in. |
| 2698 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
| 2699 | - $curGroups = array(); |
|
| 2700 | - else |
|
| 2701 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2766 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
| 2767 | + $curGroups = array(); |
|
| 2768 | + } else { |
|
| 2769 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2770 | + } |
|
| 2702 | 2771 | $curGroups[] = $user_profile[$memID]['id_group']; |
| 2703 | 2772 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
| 2704 | 2773 | |
@@ -2718,28 +2787,30 @@ discard block |
||
| 2718 | 2787 | $context['no_access_boards'] = array(); |
| 2719 | 2788 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2720 | 2789 | { |
| 2721 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
| 2722 | - $context['no_access_boards'][] = array( |
|
| 2790 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
| 2791 | + $context['no_access_boards'][] = array( |
|
| 2723 | 2792 | 'id' => $row['id_board'], |
| 2724 | 2793 | 'name' => $row['name'], |
| 2725 | 2794 | 'is_last' => false, |
| 2726 | 2795 | ); |
| 2727 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
| 2728 | - $context['boards'][$row['id_board']] = array( |
|
| 2796 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
| 2797 | + $context['boards'][$row['id_board']] = array( |
|
| 2729 | 2798 | 'id' => $row['id_board'], |
| 2730 | 2799 | 'name' => $row['name'], |
| 2731 | 2800 | 'selected' => $board == $row['id_board'], |
| 2732 | 2801 | 'profile' => $row['id_profile'], |
| 2733 | 2802 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
| 2734 | 2803 | ); |
| 2804 | + } |
|
| 2735 | 2805 | } |
| 2736 | 2806 | $smcFunc['db_free_result']($request); |
| 2737 | 2807 | |
| 2738 | 2808 | require_once($sourcedir . '/Subs-Boards.php'); |
| 2739 | 2809 | sortBoards($context['boards']); |
| 2740 | 2810 | |
| 2741 | - if (!empty($context['no_access_boards'])) |
|
| 2742 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2811 | + if (!empty($context['no_access_boards'])) { |
|
| 2812 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2813 | + } |
|
| 2743 | 2814 | |
| 2744 | 2815 | $context['member']['permissions'] = array( |
| 2745 | 2816 | 'general' => array(), |
@@ -2748,8 +2819,9 @@ discard block |
||
| 2748 | 2819 | |
| 2749 | 2820 | // If you're an admin we know you can do everything, we might as well leave. |
| 2750 | 2821 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
| 2751 | - if ($context['member']['has_all_permissions']) |
|
| 2752 | - return; |
|
| 2822 | + if ($context['member']['has_all_permissions']) { |
|
| 2823 | + return; |
|
| 2824 | + } |
|
| 2753 | 2825 | |
| 2754 | 2826 | $denied = array(); |
| 2755 | 2827 | |
@@ -2768,21 +2840,24 @@ discard block |
||
| 2768 | 2840 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2769 | 2841 | { |
| 2770 | 2842 | // We don't know about this permission, it doesn't exist :P. |
| 2771 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2772 | - continue; |
|
| 2843 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2844 | + continue; |
|
| 2845 | + } |
|
| 2773 | 2846 | |
| 2774 | - if (empty($row['add_deny'])) |
|
| 2775 | - $denied[] = $row['permission']; |
|
| 2847 | + if (empty($row['add_deny'])) { |
|
| 2848 | + $denied[] = $row['permission']; |
|
| 2849 | + } |
|
| 2776 | 2850 | |
| 2777 | 2851 | // Permissions that end with _own or _any consist of two parts. |
| 2778 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2779 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2780 | - else |
|
| 2781 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2852 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2853 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2854 | + } else { |
|
| 2855 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2856 | + } |
|
| 2782 | 2857 | |
| 2783 | 2858 | // Add this permission if it doesn't exist yet. |
| 2784 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
| 2785 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2859 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
| 2860 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2786 | 2861 | 'id' => $row['permission'], |
| 2787 | 2862 | 'groups' => array( |
| 2788 | 2863 | 'allowed' => array(), |
@@ -2792,6 +2867,7 @@ discard block |
||
| 2792 | 2867 | 'is_denied' => false, |
| 2793 | 2868 | 'is_global' => true, |
| 2794 | 2869 | ); |
| 2870 | + } |
|
| 2795 | 2871 | |
| 2796 | 2872 | // Add the membergroup to either the denied or the allowed groups. |
| 2797 | 2873 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2825,18 +2901,20 @@ discard block |
||
| 2825 | 2901 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2826 | 2902 | { |
| 2827 | 2903 | // We don't know about this permission, it doesn't exist :P. |
| 2828 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2829 | - continue; |
|
| 2904 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2905 | + continue; |
|
| 2906 | + } |
|
| 2830 | 2907 | |
| 2831 | 2908 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
| 2832 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2833 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2834 | - else |
|
| 2835 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2909 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2910 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2911 | + } else { |
|
| 2912 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2913 | + } |
|
| 2836 | 2914 | |
| 2837 | 2915 | // Create the structure for this permission. |
| 2838 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
| 2839 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2916 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
| 2917 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2840 | 2918 | 'id' => $row['permission'], |
| 2841 | 2919 | 'groups' => array( |
| 2842 | 2920 | 'allowed' => array(), |
@@ -2846,6 +2924,7 @@ discard block |
||
| 2846 | 2924 | 'is_denied' => false, |
| 2847 | 2925 | 'is_global' => empty($board), |
| 2848 | 2926 | ); |
| 2927 | + } |
|
| 2849 | 2928 | |
| 2850 | 2929 | $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']; |
| 2851 | 2930 | |
@@ -2864,8 +2943,9 @@ discard block |
||
| 2864 | 2943 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
| 2865 | 2944 | |
| 2866 | 2945 | // Firstly, can we actually even be here? |
| 2867 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
| 2868 | - fatal_lang_error('no_access', false); |
|
| 2946 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
| 2947 | + fatal_lang_error('no_access', false); |
|
| 2948 | + } |
|
| 2869 | 2949 | |
| 2870 | 2950 | // Make sure things which are disabled stay disabled. |
| 2871 | 2951 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2952,9 +3032,10 @@ discard block |
||
| 2952 | 3032 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
| 2953 | 3033 | ); |
| 2954 | 3034 | $context['current_level'] = 0; |
| 2955 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
| 2956 | - if ($context['member']['warning'] >= $limit) |
|
| 3035 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
| 3036 | + if ($context['member']['warning'] >= $limit) |
|
| 2957 | 3037 | $context['current_level'] = $limit; |
| 2958 | -} |
|
| 3038 | + } |
|
| 3039 | + } |
|
| 2959 | 3040 | |
| 2960 | 3041 | ?> |
| 2961 | 3042 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Interface cache_api_interface |
@@ -182,8 +183,9 @@ discard block |
||
| 182 | 183 | { |
| 183 | 184 | global $cache_enable; |
| 184 | 185 | |
| 185 | - if ($test) |
|
| 186 | - return true; |
|
| 186 | + if ($test) { |
|
| 187 | + return true; |
|
| 188 | + } |
|
| 187 | 189 | return !empty($cache_enable); |
| 188 | 190 | } |
| 189 | 191 | |
@@ -202,18 +204,20 @@ discard block |
||
| 202 | 204 | global $boardurl, $cachedir; |
| 203 | 205 | |
| 204 | 206 | // Find a valid good file to do mtime checks on. |
| 205 | - if (file_exists($cachedir . '/' . 'index.php')) |
|
| 206 | - $filemtime = $cachedir . '/' . 'index.php'; |
|
| 207 | - elseif (is_dir($cachedir . '/')) |
|
| 208 | - $filemtime = $cachedir . '/'; |
|
| 209 | - else |
|
| 210 | - $filemtime = $boardurl . '/index.php'; |
|
| 207 | + if (file_exists($cachedir . '/' . 'index.php')) { |
|
| 208 | + $filemtime = $cachedir . '/' . 'index.php'; |
|
| 209 | + } elseif (is_dir($cachedir . '/')) { |
|
| 210 | + $filemtime = $cachedir . '/'; |
|
| 211 | + } else { |
|
| 212 | + $filemtime = $boardurl . '/index.php'; |
|
| 213 | + } |
|
| 211 | 214 | |
| 212 | 215 | // Set the default if no prefix was specified. |
| 213 | - if (empty($prefix)) |
|
| 214 | - $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
| 215 | - else |
|
| 216 | - $this->prefix = $prefix; |
|
| 216 | + if (empty($prefix)) { |
|
| 217 | + $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
| 218 | + } else { |
|
| 219 | + $this->prefix = $prefix; |
|
| 220 | + } |
|
| 217 | 221 | |
| 218 | 222 | return true; |
| 219 | 223 | } |
@@ -276,8 +280,9 @@ discard block |
||
| 276 | 280 | |
| 277 | 281 | // Invalidate cache, to be sure! |
| 278 | 282 | // ... as long as index.php can be modified, anyway. |
| 279 | - if (is_writable($cachedir . '/' . 'index.php')) |
|
| 280 | - @touch($cachedir . '/' . 'index.php'); |
|
| 283 | + if (is_writable($cachedir . '/' . 'index.php')) { |
|
| 284 | + @touch($cachedir . '/' . 'index.php'); |
|
| 285 | + } |
|
| 281 | 286 | |
| 282 | 287 | return true; |
| 283 | 288 | } |
@@ -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('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * SQLite Cache API class |
@@ -68,8 +69,9 @@ discard block |
||
| 68 | 69 | { |
| 69 | 70 | $supported = class_exists("SQLite3") && is_writable($this->cachedir); |
| 70 | 71 | |
| 71 | - if ($test) |
|
| 72 | - return $supported; |
|
| 72 | + if ($test) { |
|
| 73 | + return $supported; |
|
| 74 | + } |
|
| 73 | 75 | |
| 74 | 76 | return parent::isSupported() && $supported; |
| 75 | 77 | } |
@@ -84,8 +86,9 @@ discard block |
||
| 84 | 86 | $result = $this->cacheDB->query($query); |
| 85 | 87 | |
| 86 | 88 | $value = null; |
| 87 | - while ($res = $result->fetchArray(SQLITE3_ASSOC)) |
|
| 88 | - $value = $res['value']; |
|
| 89 | + while ($res = $result->fetchArray(SQLITE3_ASSOC)) { |
|
| 90 | + $value = $res['value']; |
|
| 91 | + } |
|
| 89 | 92 | |
| 90 | 93 | return !empty($value) ? $value : null; |
| 91 | 94 | } |
@@ -125,8 +128,9 @@ discard block |
||
| 125 | 128 | $config_vars[] = $txt['cache_sqlite_settings']; |
| 126 | 129 | $config_vars[] = array('cachedir_sqlite', $txt['cachedir_sqlite'], 'file', 'text', 36, 'cache_sqlite_cachedir'); |
| 127 | 130 | |
| 128 | - if (!isset($context['settings_post_javascript'])) |
|
| 129 | - $context['settings_post_javascript'] = ''; |
|
| 131 | + if (!isset($context['settings_post_javascript'])) { |
|
| 132 | + $context['settings_post_javascript'] = ''; |
|
| 133 | + } |
|
| 130 | 134 | |
| 131 | 135 | $context['settings_post_javascript'] .= ' |
| 132 | 136 | $("#cache_accelerator").change(function (e) { |
@@ -149,10 +153,11 @@ discard block |
||
| 149 | 153 | global $cachedir_sqlite; |
| 150 | 154 | |
| 151 | 155 | // If its invalid, use SMF's. |
| 152 | - if (is_null($dir) || !is_writable($dir)) |
|
| 153 | - $this->cachedir = $cachedir_sqlite; |
|
| 154 | - else |
|
| 155 | - $this->cachedir = $dir; |
|
| 156 | + if (is_null($dir) || !is_writable($dir)) { |
|
| 157 | + $this->cachedir = $cachedir_sqlite; |
|
| 158 | + } else { |
|
| 159 | + $this->cachedir = $dir; |
|
| 160 | + } |
|
| 156 | 161 | } |
| 157 | 162 | |
| 158 | 163 | /** |
@@ -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('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * PostgreSQL Cache API class |
@@ -49,8 +50,9 @@ discard block |
||
| 49 | 50 | |
| 50 | 51 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
| 51 | 52 | |
| 52 | - if (pg_affected_rows($result) === 0) |
|
| 53 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
| 53 | + if (pg_affected_rows($result) === 0) { |
|
| 54 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
| 55 | + } |
|
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | /** |
@@ -60,14 +62,16 @@ discard block |
||
| 60 | 62 | { |
| 61 | 63 | global $smcFunc, $db_connection; |
| 62 | 64 | |
| 63 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
| 64 | - return false; |
|
| 65 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 65 | 68 | |
| 66 | 69 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
| 67 | 70 | $res = pg_fetch_assoc($result); |
| 68 | 71 | |
| 69 | - if ($res['server_version_num'] < 90500) |
|
| 70 | - return false; |
|
| 72 | + if ($res['server_version_num'] < 90500) { |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 71 | 75 | |
| 72 | 76 | return $test ? true : parent::isSupported(); |
| 73 | 77 | } |
@@ -81,13 +85,15 @@ discard block |
||
| 81 | 85 | |
| 82 | 86 | $ttl = time() - $ttl; |
| 83 | 87 | |
| 84 | - if (empty($this->pg_get_data_prep)) |
|
| 85 | - $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
| 88 | + if (empty($this->pg_get_data_prep)) { |
|
| 89 | + $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
| 90 | + } |
|
| 86 | 91 | |
| 87 | 92 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
| 88 | 93 | |
| 89 | - if (pg_affected_rows($result) === 0) |
|
| 90 | - return null; |
|
| 94 | + if (pg_affected_rows($result) === 0) { |
|
| 95 | + return null; |
|
| 96 | + } |
|
| 91 | 97 | |
| 92 | 98 | $res = pg_fetch_assoc($result); |
| 93 | 99 | |
@@ -101,23 +107,26 @@ discard block |
||
| 101 | 107 | { |
| 102 | 108 | global $db_prefix, $db_connection; |
| 103 | 109 | |
| 104 | - if (!isset($value)) |
|
| 105 | - $value = ''; |
|
| 110 | + if (!isset($value)) { |
|
| 111 | + $value = ''; |
|
| 112 | + } |
|
| 106 | 113 | |
| 107 | 114 | $ttl = time() + $ttl; |
| 108 | 115 | |
| 109 | - if (empty($this->pg_put_data_prep)) |
|
| 110 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
| 116 | + if (empty($this->pg_put_data_prep)) { |
|
| 117 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
| 111 | 118 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
| 112 | 119 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
| 113 | 120 | ); |
| 121 | + } |
|
| 114 | 122 | |
| 115 | 123 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
| 116 | 124 | |
| 117 | - if (pg_affected_rows($result) > 0) |
|
| 118 | - return true; |
|
| 119 | - else |
|
| 120 | - return false; |
|
| 125 | + if (pg_affected_rows($result) > 0) { |
|
| 126 | + return true; |
|
| 127 | + } else { |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 121 | 130 | } |
| 122 | 131 | |
| 123 | 132 | /** |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
| 32 | 33 | |
| 33 | 34 | // Are we looking at the moderation log or the administration log. |
| 34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
| 35 | - if ($context['log_type'] == 3) |
|
| 36 | - isAllowedTo('admin_forum'); |
|
| 36 | + if ($context['log_type'] == 3) { |
|
| 37 | + isAllowedTo('admin_forum'); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
| 39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
| 40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 41 | - else |
|
| 42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
| 42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 43 | + } else { |
|
| 44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 45 | + } |
|
| 43 | 46 | |
| 44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
| 45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
| 67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
| 68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
| 69 | 72 | |
| 70 | - } |
|
| 71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 72 | 74 | { |
| 73 | 75 | checkSession(); |
| 74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
| 114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
| 115 | 117 | ); |
| 116 | 118 | |
| 117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
| 118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 119 | - else |
|
| 120 | - $search_params_string = $search_params['string']; |
|
| 119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
| 120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 121 | + } else { |
|
| 122 | + $search_params_string = $search_params['string']; |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
| 123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 124 | - else |
|
| 125 | - $search_params_type = $search_params['type']; |
|
| 125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
| 126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 127 | + } else { |
|
| 128 | + $search_params_type = $search_params['type']; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
| 128 | 132 | $search_params = array( |
@@ -301,15 +305,16 @@ discard block |
||
| 301 | 305 | $context['default_list'] = 'moderation_log_list'; |
| 302 | 306 | |
| 303 | 307 | // If a hook has changed this, respect it. |
| 304 | - if (!empty($moderation_menu_name)) |
|
| 305 | - $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
| 306 | - elseif (isset($context['moderation_menu_name'])) |
|
| 307 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 308 | + if (!empty($moderation_menu_name)) { |
|
| 309 | + $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
| 310 | + } elseif (isset($context['moderation_menu_name'])) { |
|
| 311 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 308 | 312 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
| 309 | 313 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
| 310 | 314 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
| 311 | 315 | ); |
| 312 | -} |
|
| 316 | + } |
|
| 317 | + } |
|
| 313 | 318 | |
| 314 | 319 | /** |
| 315 | 320 | * Get the number of mod log entries. |
@@ -413,30 +418,35 @@ discard block |
||
| 413 | 418 | // Add on some of the column stuff info |
| 414 | 419 | if (!empty($row['id_board'])) |
| 415 | 420 | { |
| 416 | - if ($row['action'] == 'move') |
|
| 417 | - $row['extra']['board_to'] = $row['id_board']; |
|
| 418 | - else |
|
| 419 | - $row['extra']['board'] = $row['id_board']; |
|
| 421 | + if ($row['action'] == 'move') { |
|
| 422 | + $row['extra']['board_to'] = $row['id_board']; |
|
| 423 | + } else { |
|
| 424 | + $row['extra']['board'] = $row['id_board']; |
|
| 425 | + } |
|
| 420 | 426 | } |
| 421 | 427 | |
| 422 | - if (!empty($row['id_topic'])) |
|
| 423 | - $row['extra']['topic'] = $row['id_topic']; |
|
| 424 | - if (!empty($row['id_msg'])) |
|
| 425 | - $row['extra']['message'] = $row['id_msg']; |
|
| 428 | + if (!empty($row['id_topic'])) { |
|
| 429 | + $row['extra']['topic'] = $row['id_topic']; |
|
| 430 | + } |
|
| 431 | + if (!empty($row['id_msg'])) { |
|
| 432 | + $row['extra']['message'] = $row['id_msg']; |
|
| 433 | + } |
|
| 426 | 434 | |
| 427 | 435 | // Is this associated with a topic? |
| 428 | - if (isset($row['extra']['topic'])) |
|
| 429 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 430 | - if (isset($row['extra']['new_topic'])) |
|
| 431 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 436 | + if (isset($row['extra']['topic'])) { |
|
| 437 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 438 | + } |
|
| 439 | + if (isset($row['extra']['new_topic'])) { |
|
| 440 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 441 | + } |
|
| 432 | 442 | |
| 433 | 443 | // How about a member? |
| 434 | 444 | if (isset($row['extra']['member'])) |
| 435 | 445 | { |
| 436 | 446 | // Guests don't have names! |
| 437 | - if (empty($row['extra']['member'])) |
|
| 438 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 439 | - else |
|
| 447 | + if (empty($row['extra']['member'])) { |
|
| 448 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 449 | + } else |
|
| 440 | 450 | { |
| 441 | 451 | // Try to find it... |
| 442 | 452 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -444,35 +454,42 @@ discard block |
||
| 444 | 454 | } |
| 445 | 455 | |
| 446 | 456 | // Associated with a board? |
| 447 | - if (isset($row['extra']['board_to'])) |
|
| 448 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 449 | - if (isset($row['extra']['board_from'])) |
|
| 450 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 451 | - if (isset($row['extra']['board'])) |
|
| 452 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 457 | + if (isset($row['extra']['board_to'])) { |
|
| 458 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 459 | + } |
|
| 460 | + if (isset($row['extra']['board_from'])) { |
|
| 461 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 462 | + } |
|
| 463 | + if (isset($row['extra']['board'])) { |
|
| 464 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 465 | + } |
|
| 453 | 466 | |
| 454 | 467 | // A message? |
| 455 | - if (isset($row['extra']['message'])) |
|
| 456 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 468 | + if (isset($row['extra']['message'])) { |
|
| 469 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 470 | + } |
|
| 457 | 471 | |
| 458 | 472 | // IP Info? |
| 459 | - if (isset($row['extra']['ip_range'])) |
|
| 460 | - if ($seeIP) |
|
| 473 | + if (isset($row['extra']['ip_range'])) { |
|
| 474 | + if ($seeIP) |
|
| 461 | 475 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
| 462 | - else |
|
| 463 | - $row['extra']['ip_range'] = $txt['logged']; |
|
| 476 | + } else { |
|
| 477 | + $row['extra']['ip_range'] = $txt['logged']; |
|
| 478 | + } |
|
| 464 | 479 | |
| 465 | 480 | // Email? |
| 466 | - if (isset($row['extra']['email'])) |
|
| 467 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 481 | + if (isset($row['extra']['email'])) { |
|
| 482 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 483 | + } |
|
| 468 | 484 | |
| 469 | 485 | // Bans are complex. |
| 470 | 486 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
| 471 | 487 | { |
| 472 | 488 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
| 473 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
| 474 | - if (isset($row['extra'][$type])) |
|
| 489 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
| 490 | + if (isset($row['extra'][$type])) |
|
| 475 | 491 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
| 492 | + } |
|
| 476 | 493 | } |
| 477 | 494 | |
| 478 | 495 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -508,12 +525,13 @@ discard block |
||
| 508 | 525 | foreach ($boards[$row['id_board']] as $action) |
| 509 | 526 | { |
| 510 | 527 | // Make the board number into a link - dealing with moving too. |
| 511 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
| 512 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 513 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
| 514 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 515 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
| 516 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 528 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
| 529 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 530 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
| 531 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 532 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
| 533 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 534 | + } |
|
| 517 | 535 | } |
| 518 | 536 | } |
| 519 | 537 | $smcFunc['db_free_result']($request); |
@@ -547,10 +565,11 @@ discard block |
||
| 547 | 565 | ); |
| 548 | 566 | |
| 549 | 567 | // Make the topic number into a link - dealing with splitting too. |
| 550 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
| 551 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 552 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
| 553 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 568 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
| 569 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 570 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
| 571 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 572 | + } |
|
| 554 | 573 | } |
| 555 | 574 | } |
| 556 | 575 | $smcFunc['db_free_result']($request); |
@@ -583,8 +602,9 @@ discard block |
||
| 583 | 602 | ); |
| 584 | 603 | |
| 585 | 604 | // Make the message number into a link. |
| 586 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
| 587 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 605 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
| 606 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 607 | + } |
|
| 588 | 608 | } |
| 589 | 609 | } |
| 590 | 610 | $smcFunc['db_free_result']($request); |
@@ -624,25 +644,29 @@ discard block |
||
| 624 | 644 | foreach ($entries as $k => $entry) |
| 625 | 645 | { |
| 626 | 646 | // Make any message info links so its easier to go find that message. |
| 627 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
| 628 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 647 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
| 648 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 649 | + } |
|
| 629 | 650 | |
| 630 | 651 | // Mark up any deleted members, topics and boards. |
| 631 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
| 632 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 652 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
| 653 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 633 | 654 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
| 655 | + } |
|
| 634 | 656 | |
| 635 | 657 | if (isset($entry['extra']['report'])) |
| 636 | 658 | { |
| 637 | 659 | // Member profile reports go in a different area |
| 638 | - if (stristr($entry['action'], 'user_report')) |
|
| 639 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 640 | - else |
|
| 641 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 660 | + if (stristr($entry['action'], 'user_report')) { |
|
| 661 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 662 | + } else { |
|
| 663 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 664 | + } |
|
| 642 | 665 | } |
| 643 | 666 | |
| 644 | - if (empty($entries[$k]['action_text'])) |
|
| 645 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 667 | + if (empty($entries[$k]['action_text'])) { |
|
| 668 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 669 | + } |
|
| 646 | 670 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
| 647 | 671 | function ($matches) use ($entries, $k) |
| 648 | 672 | { |
@@ -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 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | // Not allowed sort method? Bang! Error! |
| 48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
| 49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
| 50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | // Initialize the array that'll be returned later on. |
| 52 | 54 | $membersOnlineStats = array( |
@@ -63,8 +65,9 @@ discard block |
||
| 63 | 65 | // Get any spiders if enabled. |
| 64 | 66 | $spiders = array(); |
| 65 | 67 | $spider_finds = array(); |
| 66 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
| 67 | - $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
| 68 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
| 69 | + $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | // Load the users online right now. |
| 70 | 73 | $request = $smcFunc['db_query']('', ' |
@@ -92,9 +95,7 @@ discard block |
||
| 92 | 95 | $membersOnlineStats['num_guests']++; |
| 93 | 96 | |
| 94 | 97 | continue; |
| 95 | - } |
|
| 96 | - |
|
| 97 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 98 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 98 | 99 | { |
| 99 | 100 | // Just increase the stats and don't add this hidden user to any list. |
| 100 | 101 | $membersOnlineStats['num_users_hidden']++; |
@@ -102,10 +103,11 @@ discard block |
||
| 102 | 103 | } |
| 103 | 104 | |
| 104 | 105 | // Some basic color coding... |
| 105 | - if (!empty($row['online_color'])) |
|
| 106 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 107 | - else |
|
| 108 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 106 | + if (!empty($row['online_color'])) { |
|
| 107 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 108 | + } else { |
|
| 109 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 110 | + } |
|
| 109 | 111 | |
| 110 | 112 | // Buddies get counted and highlighted. |
| 111 | 113 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -132,8 +134,8 @@ discard block |
||
| 132 | 134 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
| 133 | 135 | |
| 134 | 136 | // Store all distinct (primary) membergroups that are shown. |
| 135 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
| 136 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 137 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
| 138 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 137 | 139 | 'id' => $row['id_group'], |
| 138 | 140 | 'name' => $row['group_name'], |
| 139 | 141 | 'color' => $row['online_color'], |
@@ -141,6 +143,7 @@ discard block |
||
| 141 | 143 | 'type' => $row['group_type'], |
| 142 | 144 | 'parent' => $row['id_parent'], |
| 143 | 145 | ); |
| 146 | + } |
|
| 144 | 147 | } |
| 145 | 148 | $smcFunc['db_free_result']($request); |
| 146 | 149 | |
@@ -201,11 +204,12 @@ discard block |
||
| 201 | 204 | $settingsToUpdate = array(); |
| 202 | 205 | |
| 203 | 206 | // More members on now than ever were? Update it! |
| 204 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
| 205 | - $settingsToUpdate = array( |
|
| 207 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
| 208 | + $settingsToUpdate = array( |
|
| 206 | 209 | 'mostOnline' => $total_users_online, |
| 207 | 210 | 'mostDate' => time() |
| 208 | 211 | ); |
| 212 | + } |
|
| 209 | 213 | |
| 210 | 214 | $date = strftime('%Y-%m-%d', forum_time(false)); |
| 211 | 215 | |
@@ -237,8 +241,9 @@ discard block |
||
| 237 | 241 | { |
| 238 | 242 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
| 239 | 243 | |
| 240 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
| 241 | - trackStats(array('most_on' => $total_users_online)); |
|
| 244 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
| 245 | + trackStats(array('most_on' => $total_users_online)); |
|
| 246 | + } |
|
| 242 | 247 | |
| 243 | 248 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
| 244 | 249 | } |
@@ -255,8 +260,9 @@ discard block |
||
| 255 | 260 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
| 256 | 261 | } |
| 257 | 262 | |
| 258 | - if (!empty($settingsToUpdate)) |
|
| 259 | - updateSettings($settingsToUpdate); |
|
| 260 | -} |
|
| 263 | + if (!empty($settingsToUpdate)) { |
|
| 264 | + updateSettings($settingsToUpdate); |
|
| 265 | + } |
|
| 266 | + } |
|
| 261 | 267 | |
| 262 | 268 | ?> |
| 263 | 269 | \ No newline at end of file |