@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // Get everything started up... |
| 27 | 27 | define('SMF', 1); |
| 28 | -if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(),'5.3.0') < 0) |
|
| 28 | +if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(),'5.3.0') < 0) { |
|
| 29 | 29 | @set_magic_quotes_runtime(0); |
| 30 | +} |
|
| 30 | 31 | error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL); |
| 31 | 32 | $time_start = microtime(); |
| 32 | 33 | |
@@ -34,16 +35,18 @@ discard block |
||
| 34 | 35 | ob_start(); |
| 35 | 36 | |
| 36 | 37 | // Do some cleaning, just in case. |
| 37 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 38 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 38 | 39 | if (isset($GLOBALS[$variable])) |
| 39 | 40 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
| 41 | +} |
|
| 40 | 42 | |
| 41 | 43 | // Load the settings... |
| 42 | 44 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 43 | 45 | |
| 44 | 46 | // Make absolutely sure the cache directory is defined. |
| 45 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 47 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 46 | 48 | $cachedir = $boarddir . '/cache'; |
| 49 | +} |
|
| 47 | 50 | |
| 48 | 51 | // Without those we can't go anywhere |
| 49 | 52 | require_once($sourcedir . '/QueryString.php'); |
@@ -53,8 +56,9 @@ discard block |
||
| 53 | 56 | require_once($sourcedir . '/Load.php'); |
| 54 | 57 | |
| 55 | 58 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
| 56 | -if (!empty($maintenance) && $maintenance == 2) |
|
| 59 | +if (!empty($maintenance) && $maintenance == 2) { |
|
| 57 | 60 | display_maintenance_message(); |
| 61 | +} |
|
| 58 | 62 | |
| 59 | 63 | // Create a variable to store some SMF specific functions in. |
| 60 | 64 | $smcFunc = array(); |
@@ -69,8 +73,9 @@ discard block |
||
| 69 | 73 | cleanRequest(); |
| 70 | 74 | |
| 71 | 75 | // Seed the random generator. |
| 72 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 76 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 73 | 77 | smf_seed_generator(); |
| 78 | +} |
|
| 74 | 79 | |
| 75 | 80 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
| 76 | 81 | if (isset($_GET['scheduled'])) |
@@ -90,9 +95,9 @@ discard block |
||
| 90 | 95 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
| 91 | 96 | { |
| 92 | 97 | // If zlib is being used, turn off output compression. |
| 93 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
| 94 | - $modSettings['enableCompressedOutput'] = '0'; |
|
| 95 | - else |
|
| 98 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
| 99 | + $modSettings['enableCompressedOutput'] = '0'; |
|
| 100 | + } else |
|
| 96 | 101 | { |
| 97 | 102 | ob_end_clean(); |
| 98 | 103 | ob_start('ob_gzhandler'); |
@@ -141,18 +146,21 @@ discard block |
||
| 141 | 146 | loadPermissions(); |
| 142 | 147 | |
| 143 | 148 | // Attachments don't require the entire theme to be loaded. |
| 144 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
| 145 | - detectBrowser(); |
|
| 149 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
| 150 | + detectBrowser(); |
|
| 151 | + } |
|
| 146 | 152 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
| 147 | - else |
|
| 148 | - loadTheme(); |
|
| 153 | + else { |
|
| 154 | + loadTheme(); |
|
| 155 | + } |
|
| 149 | 156 | |
| 150 | 157 | // Check if the user should be disallowed access. |
| 151 | 158 | is_not_banned(); |
| 152 | 159 | |
| 153 | 160 | // If we are in a topic and don't have permission to approve it then duck out now. |
| 154 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
| 155 | - fatal_lang_error('not_a_topic', false); |
|
| 161 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
| 162 | + fatal_lang_error('not_a_topic', false); |
|
| 163 | + } |
|
| 156 | 164 | |
| 157 | 165 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
| 158 | 166 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -163,8 +171,9 @@ discard block |
||
| 163 | 171 | writeLog(); |
| 164 | 172 | |
| 165 | 173 | // Track forum statistics and hits...? |
| 166 | - if (!empty($modSettings['hitStats'])) |
|
| 167 | - trackStats(array('hits' => '+')); |
|
| 174 | + if (!empty($modSettings['hitStats'])) { |
|
| 175 | + trackStats(array('hits' => '+')); |
|
| 176 | + } |
|
| 168 | 177 | } |
| 169 | 178 | unset($no_stat_actions); |
| 170 | 179 | |
@@ -178,13 +187,14 @@ discard block |
||
| 178 | 187 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
| 179 | 188 | } |
| 180 | 189 | // Don't even try it, sonny. |
| 181 | - else |
|
| 182 | - return 'InMaintenance'; |
|
| 190 | + else { |
|
| 191 | + return 'InMaintenance'; |
|
| 192 | + } |
|
| 183 | 193 | } |
| 184 | 194 | // If guest access is off, a guest can only do one of the very few following actions. |
| 185 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
| 186 | - return 'KickGuest'; |
|
| 187 | - elseif (empty($_REQUEST['action'])) |
|
| 195 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
| 196 | + return 'KickGuest'; |
|
| 197 | + } elseif (empty($_REQUEST['action'])) |
|
| 188 | 198 | { |
| 189 | 199 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
| 190 | 200 | if (empty($board) && empty($topic)) |
@@ -200,8 +210,9 @@ discard block |
||
| 200 | 210 | |
| 201 | 211 | $call = call_helper($defaultAction, true); |
| 202 | 212 | |
| 203 | - if (!empty($call)) |
|
| 204 | - return $call; |
|
| 213 | + if (!empty($call)) { |
|
| 214 | + return $call; |
|
| 215 | + } |
|
| 205 | 216 | } |
| 206 | 217 | |
| 207 | 218 | // No default action huh? then go to our good old BoardIndex. |
@@ -331,8 +342,9 @@ discard block |
||
| 331 | 342 | |
| 332 | 343 | $call = call_helper($fallbackAction, true); |
| 333 | 344 | |
| 334 | - if (!empty($call)) |
|
| 335 | - return $call; |
|
| 345 | + if (!empty($call)) { |
|
| 346 | + return $call; |
|
| 347 | + } |
|
| 336 | 348 | } |
| 337 | 349 | |
| 338 | 350 | // No fallback action, huh? |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * The main designating function for modifying profiles. Loads up info, determins what to do, etc. |
@@ -30,18 +31,21 @@ discard block |
||
| 30 | 31 | global $db_show_debug, $smcFunc; |
| 31 | 32 | |
| 32 | 33 | // Don't reload this as we may have processed error strings. |
| 33 | - if (empty($post_errors)) |
|
| 34 | - loadLanguage('Profile+Drafts'); |
|
| 34 | + if (empty($post_errors)) { |
|
| 35 | + loadLanguage('Profile+Drafts'); |
|
| 36 | + } |
|
| 35 | 37 | loadTemplate('Profile'); |
| 36 | 38 | |
| 37 | 39 | require_once($sourcedir . '/Subs-Menu.php'); |
| 38 | 40 | |
| 39 | 41 | // Did we get the user by name... |
| 40 | - if (isset($_REQUEST['user'])) |
|
| 41 | - $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
| 42 | + if (isset($_REQUEST['user'])) { |
|
| 43 | + $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
| 44 | + } |
|
| 42 | 45 | // ... or by id_member? |
| 43 | - elseif (!empty($_REQUEST['u'])) |
|
| 44 | - $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
| 46 | + elseif (!empty($_REQUEST['u'])) { |
|
| 47 | + $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
| 48 | + } |
|
| 45 | 49 | // If it was just ?action=profile, edit your own profile, but only if you're not a guest. |
| 46 | 50 | else |
| 47 | 51 | { |
@@ -51,8 +55,9 @@ discard block |
||
| 51 | 55 | } |
| 52 | 56 | |
| 53 | 57 | // Check if loadMemberData() has returned a valid result. |
| 54 | - if (!$memberResult) |
|
| 55 | - fatal_lang_error('not_a_user', false, 404); |
|
| 58 | + if (!$memberResult) { |
|
| 59 | + fatal_lang_error('not_a_user', false, 404); |
|
| 60 | + } |
|
| 56 | 61 | |
| 57 | 62 | // If all went well, we have a valid member ID! |
| 58 | 63 | list ($memID) = $memberResult; |
@@ -68,8 +73,9 @@ discard block |
||
| 68 | 73 | |
| 69 | 74 | // Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission. |
| 70 | 75 | // And we care about what the current user can do, not what the user whose profile it is. |
| 71 | - if ($user_info['mod_cache']['gq'] != '0=1') |
|
| 72 | - $user_info['permissions'][] = 'approve_group_requests'; |
|
| 76 | + if ($user_info['mod_cache']['gq'] != '0=1') { |
|
| 77 | + $user_info['permissions'][] = 'approve_group_requests'; |
|
| 78 | + } |
|
| 73 | 79 | |
| 74 | 80 | // If paid subscriptions are enabled, make sure we actually have at least one subscription available... |
| 75 | 81 | $context['subs_available'] = false; |
@@ -437,21 +443,25 @@ discard block |
||
| 437 | 443 | foreach ($section['areas'] as $area_id => $area) |
| 438 | 444 | { |
| 439 | 445 | // If it said no permissions that meant it wasn't valid! |
| 440 | - if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) |
|
| 441 | - $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
| 446 | + if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) { |
|
| 447 | + $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
| 448 | + } |
|
| 442 | 449 | // Otherwise pick the right set. |
| 443 | - else |
|
| 444 | - $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
| 450 | + else { |
|
| 451 | + $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
| 452 | + } |
|
| 445 | 453 | |
| 446 | 454 | // Password required in most cases |
| 447 | - if (!empty($area['password'])) |
|
| 448 | - $context['password_areas'][] = $area_id; |
|
| 455 | + if (!empty($area['password'])) { |
|
| 456 | + $context['password_areas'][] = $area_id; |
|
| 457 | + } |
|
| 449 | 458 | } |
| 450 | 459 | } |
| 451 | 460 | |
| 452 | 461 | // Is there an updated message to show? |
| 453 | - if (isset($_GET['updated'])) |
|
| 454 | - $context['profile_updated'] = $txt['profile_updated_own']; |
|
| 462 | + if (isset($_GET['updated'])) { |
|
| 463 | + $context['profile_updated'] = $txt['profile_updated_own']; |
|
| 464 | + } |
|
| 455 | 465 | |
| 456 | 466 | // Set a few options for the menu. |
| 457 | 467 | $menuOptions = array( |
@@ -466,8 +476,9 @@ discard block |
||
| 466 | 476 | $profile_include_data = createMenu($profile_areas, $menuOptions); |
| 467 | 477 | |
| 468 | 478 | // No menu means no access. |
| 469 | - if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) |
|
| 470 | - fatal_lang_error('no_access', false); |
|
| 479 | + if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
| 480 | + fatal_lang_error('no_access', false); |
|
| 481 | + } |
|
| 471 | 482 | |
| 472 | 483 | // Make a note of the Unique ID for this menu. |
| 473 | 484 | $context['profile_menu_id'] = $context['max_menu_id']; |
@@ -493,8 +504,9 @@ discard block |
||
| 493 | 504 | if ($current_area == $area_id) |
| 494 | 505 | { |
| 495 | 506 | // This can't happen - but is a security check. |
| 496 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) |
|
| 497 | - fatal_lang_error('no_access', false); |
|
| 507 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) { |
|
| 508 | + fatal_lang_error('no_access', false); |
|
| 509 | + } |
|
| 498 | 510 | |
| 499 | 511 | // Are we saving data in a valid area? |
| 500 | 512 | if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview'])) |
@@ -513,12 +525,14 @@ discard block |
||
| 513 | 525 | } |
| 514 | 526 | |
| 515 | 527 | // Does this require session validating? |
| 516 | - if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) |
|
| 517 | - $security_checks['validate'] = true; |
|
| 528 | + if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) { |
|
| 529 | + $security_checks['validate'] = true; |
|
| 530 | + } |
|
| 518 | 531 | |
| 519 | 532 | // Permissions for good measure. |
| 520 | - if (!empty($profile_include_data['permission'])) |
|
| 521 | - $security_checks['permission'] = $profile_include_data['permission']; |
|
| 533 | + if (!empty($profile_include_data['permission'])) { |
|
| 534 | + $security_checks['permission'] = $profile_include_data['permission']; |
|
| 535 | + } |
|
| 522 | 536 | |
| 523 | 537 | // Either way got something. |
| 524 | 538 | $found_area = true; |
@@ -527,21 +541,26 @@ discard block |
||
| 527 | 541 | } |
| 528 | 542 | |
| 529 | 543 | // Oh dear, some serious security lapse is going on here... we'll put a stop to that! |
| 530 | - if (!$found_area) |
|
| 531 | - fatal_lang_error('no_access', false); |
|
| 544 | + if (!$found_area) { |
|
| 545 | + fatal_lang_error('no_access', false); |
|
| 546 | + } |
|
| 532 | 547 | |
| 533 | 548 | // Release this now. |
| 534 | 549 | unset($profile_areas); |
| 535 | 550 | |
| 536 | 551 | // Now the context is setup have we got any security checks to carry out additional to that above? |
| 537 | - if (isset($security_checks['session'])) |
|
| 538 | - checkSession($security_checks['session']); |
|
| 539 | - if (isset($security_checks['validate'])) |
|
| 540 | - validateSession(); |
|
| 541 | - if (isset($security_checks['validateToken'])) |
|
| 542 | - validateToken($token_name, $token_type); |
|
| 543 | - if (isset($security_checks['permission'])) |
|
| 544 | - isAllowedTo($security_checks['permission']); |
|
| 552 | + if (isset($security_checks['session'])) { |
|
| 553 | + checkSession($security_checks['session']); |
|
| 554 | + } |
|
| 555 | + if (isset($security_checks['validate'])) { |
|
| 556 | + validateSession(); |
|
| 557 | + } |
|
| 558 | + if (isset($security_checks['validateToken'])) { |
|
| 559 | + validateToken($token_name, $token_type); |
|
| 560 | + } |
|
| 561 | + if (isset($security_checks['permission'])) { |
|
| 562 | + isAllowedTo($security_checks['permission']); |
|
| 563 | + } |
|
| 545 | 564 | |
| 546 | 565 | // Create a token if needed. |
| 547 | 566 | if (isset($security_checks['needsToken']) || isset($security_checks['validateToken'])) |
@@ -551,8 +570,9 @@ discard block |
||
| 551 | 570 | } |
| 552 | 571 | |
| 553 | 572 | // File to include? |
| 554 | - if (isset($profile_include_data['file'])) |
|
| 555 | - require_once($sourcedir . '/' . $profile_include_data['file']); |
|
| 573 | + if (isset($profile_include_data['file'])) { |
|
| 574 | + require_once($sourcedir . '/' . $profile_include_data['file']); |
|
| 575 | + } |
|
| 556 | 576 | |
| 557 | 577 | // Build the link tree. |
| 558 | 578 | $context['linktree'][] = array( |
@@ -560,17 +580,19 @@ discard block |
||
| 560 | 580 | 'name' => sprintf($txt['profile_of_username'], $context['member']['name']), |
| 561 | 581 | ); |
| 562 | 582 | |
| 563 | - if (!empty($profile_include_data['label'])) |
|
| 564 | - $context['linktree'][] = array( |
|
| 583 | + if (!empty($profile_include_data['label'])) { |
|
| 584 | + $context['linktree'][] = array( |
|
| 565 | 585 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'], |
| 566 | 586 | 'name' => $profile_include_data['label'], |
| 567 | 587 | ); |
| 588 | + } |
|
| 568 | 589 | |
| 569 | - if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) |
|
| 570 | - $context['linktree'][] = array( |
|
| 590 | + if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) { |
|
| 591 | + $context['linktree'][] = array( |
|
| 571 | 592 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'], |
| 572 | 593 | 'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0], |
| 573 | 594 | ); |
| 595 | + } |
|
| 574 | 596 | |
| 575 | 597 | // Set the template for this area and add the profile layer. |
| 576 | 598 | $context['sub_template'] = $profile_include_data['function']; |
@@ -596,12 +618,14 @@ discard block |
||
| 596 | 618 | if ($check_password) |
| 597 | 619 | { |
| 598 | 620 | // Check to ensure we're forcing SSL for authentication |
| 599 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 600 | - fatal_lang_error('login_ssl_required'); |
|
| 621 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 622 | + fatal_lang_error('login_ssl_required'); |
|
| 623 | + } |
|
| 601 | 624 | |
| 602 | 625 | // You didn't even enter a password! |
| 603 | - if (trim($_POST['oldpasswrd']) == '') |
|
| 604 | - $post_errors[] = 'no_password'; |
|
| 626 | + if (trim($_POST['oldpasswrd']) == '') { |
|
| 627 | + $post_errors[] = 'no_password'; |
|
| 628 | + } |
|
| 605 | 629 | |
| 606 | 630 | // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password |
| 607 | 631 | $_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']); |
@@ -610,33 +634,35 @@ discard block |
||
| 610 | 634 | $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true); |
| 611 | 635 | |
| 612 | 636 | // Bad password!!! |
| 613 | - if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) |
|
| 614 | - $post_errors[] = 'bad_password'; |
|
| 637 | + if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) { |
|
| 638 | + $post_errors[] = 'bad_password'; |
|
| 639 | + } |
|
| 615 | 640 | |
| 616 | 641 | // Warn other elements not to jump the gun and do custom changes! |
| 617 | - if (in_array('bad_password', $post_errors)) |
|
| 618 | - $context['password_auth_failed'] = true; |
|
| 642 | + if (in_array('bad_password', $post_errors)) { |
|
| 643 | + $context['password_auth_failed'] = true; |
|
| 644 | + } |
|
| 619 | 645 | } |
| 620 | 646 | |
| 621 | 647 | // Change the IP address in the database. |
| 622 | - if ($context['user']['is_owner']) |
|
| 623 | - $profile_vars['member_ip'] = $user_info['ip']; |
|
| 648 | + if ($context['user']['is_owner']) { |
|
| 649 | + $profile_vars['member_ip'] = $user_info['ip']; |
|
| 650 | + } |
|
| 624 | 651 | |
| 625 | 652 | // Now call the sub-action function... |
| 626 | 653 | if ($current_area == 'activateaccount') |
| 627 | 654 | { |
| 628 | - if (empty($post_errors)) |
|
| 629 | - activateAccount($memID); |
|
| 630 | - } |
|
| 631 | - elseif ($current_area == 'deleteaccount') |
|
| 655 | + if (empty($post_errors)) { |
|
| 656 | + activateAccount($memID); |
|
| 657 | + } |
|
| 658 | + } elseif ($current_area == 'deleteaccount') |
|
| 632 | 659 | { |
| 633 | 660 | if (empty($post_errors)) |
| 634 | 661 | { |
| 635 | 662 | deleteAccount2($memID); |
| 636 | 663 | redirectexit(); |
| 637 | 664 | } |
| 638 | - } |
|
| 639 | - elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
| 665 | + } elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
| 640 | 666 | { |
| 641 | 667 | $msg = groupMembership2($profile_vars, $post_errors, $memID); |
| 642 | 668 | |
@@ -647,10 +673,9 @@ discard block |
||
| 647 | 673 | elseif ($current_area == 'authentication') |
| 648 | 674 | { |
| 649 | 675 | authentication($memID, true); |
| 650 | - } |
|
| 651 | - elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) |
|
| 652 | - saveProfileFields(); |
|
| 653 | - else |
|
| 676 | + } elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) { |
|
| 677 | + saveProfileFields(); |
|
| 678 | + } else |
|
| 654 | 679 | { |
| 655 | 680 | $force_redirect = true; |
| 656 | 681 | // Ensure we include this. |
@@ -666,34 +691,36 @@ discard block |
||
| 666 | 691 | // Load the language file so we can give a nice explanation of the errors. |
| 667 | 692 | loadLanguage('Errors'); |
| 668 | 693 | $context['post_errors'] = $post_errors; |
| 669 | - } |
|
| 670 | - elseif (!empty($profile_vars)) |
|
| 694 | + } elseif (!empty($profile_vars)) |
|
| 671 | 695 | { |
| 672 | 696 | // If we've changed the password, notify any integration that may be listening in. |
| 673 | - if (isset($profile_vars['passwd'])) |
|
| 674 | - call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
| 697 | + if (isset($profile_vars['passwd'])) { |
|
| 698 | + call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
| 699 | + } |
|
| 675 | 700 | |
| 676 | 701 | updateMemberData($memID, $profile_vars); |
| 677 | 702 | |
| 678 | 703 | // What if this is the newest member? |
| 679 | - if ($modSettings['latestMember'] == $memID) |
|
| 680 | - updateStats('member'); |
|
| 681 | - elseif (isset($profile_vars['real_name'])) |
|
| 682 | - updateSettings(array('memberlist_updated' => time())); |
|
| 704 | + if ($modSettings['latestMember'] == $memID) { |
|
| 705 | + updateStats('member'); |
|
| 706 | + } elseif (isset($profile_vars['real_name'])) { |
|
| 707 | + updateSettings(array('memberlist_updated' => time())); |
|
| 708 | + } |
|
| 683 | 709 | |
| 684 | 710 | // If the member changed his/her birthdate, update calendar statistics. |
| 685 | - if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) |
|
| 686 | - updateSettings(array( |
|
| 711 | + if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) { |
|
| 712 | + updateSettings(array( |
|
| 687 | 713 | 'calendar_updated' => time(), |
| 688 | 714 | )); |
| 715 | + } |
|
| 689 | 716 | |
| 690 | 717 | // Anything worth logging? |
| 691 | 718 | if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled'])) |
| 692 | 719 | { |
| 693 | 720 | $log_changes = array(); |
| 694 | 721 | require_once($sourcedir . '/Logging.php'); |
| 695 | - foreach ($context['log_changes'] as $k => $v) |
|
| 696 | - $log_changes[] = array( |
|
| 722 | + foreach ($context['log_changes'] as $k => $v) { |
|
| 723 | + $log_changes[] = array( |
|
| 697 | 724 | 'action' => $k, |
| 698 | 725 | 'log_type' => 'user', |
| 699 | 726 | 'extra' => array_merge($v, array( |
@@ -701,14 +728,16 @@ discard block |
||
| 701 | 728 | 'member_affected' => $memID, |
| 702 | 729 | )), |
| 703 | 730 | ); |
| 731 | + } |
|
| 704 | 732 | |
| 705 | 733 | logActions($log_changes); |
| 706 | 734 | } |
| 707 | 735 | |
| 708 | 736 | // Have we got any post save functions to execute? |
| 709 | - if (!empty($context['profile_execute_on_save'])) |
|
| 710 | - foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
| 737 | + if (!empty($context['profile_execute_on_save'])) { |
|
| 738 | + foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
| 711 | 739 | $saveFunc(); |
| 740 | + } |
|
| 712 | 741 | |
| 713 | 742 | // Let them know it worked! |
| 714 | 743 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']); |
@@ -722,27 +751,31 @@ discard block |
||
| 722 | 751 | if (!empty($post_errors)) |
| 723 | 752 | { |
| 724 | 753 | // Set all the errors so the template knows what went wrong. |
| 725 | - foreach ($post_errors as $error_type) |
|
| 726 | - $context['modify_error'][$error_type] = true; |
|
| 754 | + foreach ($post_errors as $error_type) { |
|
| 755 | + $context['modify_error'][$error_type] = true; |
|
| 756 | + } |
|
| 727 | 757 | } |
| 728 | 758 | // If it's you then we should redirect upon save. |
| 729 | - elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) |
|
| 730 | - redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
| 731 | - elseif (!empty($force_redirect)) |
|
| 732 | - redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
| 759 | + elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) { |
|
| 760 | + redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
| 761 | + } elseif (!empty($force_redirect)) { |
|
| 762 | + redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
| 763 | + } |
|
| 733 | 764 | |
| 734 | 765 | |
| 735 | 766 | // Get the right callable. |
| 736 | 767 | $call = call_helper($profile_include_data['function'], true); |
| 737 | 768 | |
| 738 | 769 | // Is it valid? |
| 739 | - if (!empty($call)) |
|
| 740 | - call_user_func($call, $memID); |
|
| 770 | + if (!empty($call)) { |
|
| 771 | + call_user_func($call, $memID); |
|
| 772 | + } |
|
| 741 | 773 | |
| 742 | 774 | // Set the page title if it's not already set... |
| 743 | - if (!isset($context['page_title'])) |
|
| 744 | - $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
| 745 | -} |
|
| 775 | + if (!isset($context['page_title'])) { |
|
| 776 | + $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
| 777 | + } |
|
| 778 | + } |
|
| 746 | 779 | |
| 747 | 780 | /** |
| 748 | 781 | * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user. |
@@ -865,16 +898,18 @@ discard block |
||
| 865 | 898 | if (!allowedTo('admin_forum') && $area != 'register') |
| 866 | 899 | { |
| 867 | 900 | // If it's the owner they can see two types of private fields, regardless. |
| 868 | - if ($memID == $user_info['id']) |
|
| 869 | - $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
| 870 | - else |
|
| 871 | - $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
| 901 | + if ($memID == $user_info['id']) { |
|
| 902 | + $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
| 903 | + } else { |
|
| 904 | + $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
| 905 | + } |
|
| 872 | 906 | } |
| 873 | 907 | |
| 874 | - if ($area == 'register') |
|
| 875 | - $where .= ' AND show_reg != 0'; |
|
| 876 | - elseif ($area != 'summary') |
|
| 877 | - $where .= ' AND show_profile = {string:area}'; |
|
| 908 | + if ($area == 'register') { |
|
| 909 | + $where .= ' AND show_reg != 0'; |
|
| 910 | + } elseif ($area != 'summary') { |
|
| 911 | + $where .= ' AND show_profile = {string:area}'; |
|
| 912 | + } |
|
| 878 | 913 | |
| 879 | 914 | // Load all the relevant fields - and data. |
| 880 | 915 | $request = $smcFunc['db_query']('', ' |
@@ -900,13 +935,15 @@ discard block |
||
| 900 | 935 | if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']])) |
| 901 | 936 | { |
| 902 | 937 | $value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]); |
| 903 | - if (in_array($row['field_type'], array('select', 'radio'))) |
|
| 904 | - $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
| 938 | + if (in_array($row['field_type'], array('select', 'radio'))) { |
|
| 939 | + $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
| 940 | + } |
|
| 905 | 941 | } |
| 906 | 942 | |
| 907 | 943 | // Don't show the "disabled" option for the "gender" field if we are on the "summary" area. |
| 908 | - if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
| 909 | - continue; |
|
| 944 | + if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
| 945 | + continue; |
|
| 946 | + } |
|
| 910 | 947 | |
| 911 | 948 | // HTML for the input form. |
| 912 | 949 | $output_html = $value; |
@@ -915,8 +952,7 @@ discard block |
||
| 915 | 952 | $true = (!$exists && $row['default_value']) || $value; |
| 916 | 953 | $input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . ' class="input_check">'; |
| 917 | 954 | $output_html = $true ? $txt['yes'] : $txt['no']; |
| 918 | - } |
|
| 919 | - elseif ($row['field_type'] == 'select') |
|
| 955 | + } elseif ($row['field_type'] == 'select') |
|
| 920 | 956 | { |
| 921 | 957 | $input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>'; |
| 922 | 958 | $options = explode(',', $row['field_options']); |
@@ -924,13 +960,13 @@ discard block |
||
| 924 | 960 | { |
| 925 | 961 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
| 926 | 962 | $input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>'; |
| 927 | - if ($true) |
|
| 928 | - $output_html = $v; |
|
| 963 | + if ($true) { |
|
| 964 | + $output_html = $v; |
|
| 965 | + } |
|
| 929 | 966 | } |
| 930 | 967 | |
| 931 | 968 | $input_html .= '</select>'; |
| 932 | - } |
|
| 933 | - elseif ($row['field_type'] == 'radio') |
|
| 969 | + } elseif ($row['field_type'] == 'radio') |
|
| 934 | 970 | { |
| 935 | 971 | $input_html = '<fieldset>'; |
| 936 | 972 | $options = explode(',', $row['field_options']); |
@@ -938,36 +974,37 @@ discard block |
||
| 938 | 974 | { |
| 939 | 975 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
| 940 | 976 | $input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" class="input_radio" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>'; |
| 941 | - if ($true) |
|
| 942 | - $output_html = $v; |
|
| 977 | + if ($true) { |
|
| 978 | + $output_html = $v; |
|
| 979 | + } |
|
| 943 | 980 | } |
| 944 | 981 | $input_html .= '</fieldset>'; |
| 945 | - } |
|
| 946 | - elseif ($row['field_type'] == 'text') |
|
| 982 | + } elseif ($row['field_type'] == 'text') |
|
| 947 | 983 | { |
| 948 | 984 | $input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '" class="input_text"' . ($row['show_reg'] == 2 ? ' required' : '') . '>'; |
| 949 | - } |
|
| 950 | - else |
|
| 985 | + } else |
|
| 951 | 986 | { |
| 952 | 987 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
| 953 | 988 | $input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '' ). '>' . un_htmlspecialchars($value) . '</textarea>'; |
| 954 | 989 | } |
| 955 | 990 | |
| 956 | 991 | // Parse BBCode |
| 957 | - if ($row['bbc']) |
|
| 958 | - $output_html = parse_bbc($output_html); |
|
| 959 | - elseif ($row['field_type'] == 'textarea') |
|
| 960 | - // Allow for newlines at least |
|
| 992 | + if ($row['bbc']) { |
|
| 993 | + $output_html = parse_bbc($output_html); |
|
| 994 | + } elseif ($row['field_type'] == 'textarea') { |
|
| 995 | + // Allow for newlines at least |
|
| 961 | 996 | $output_html = strtr($output_html, array("\n" => '<br>')); |
| 997 | + } |
|
| 962 | 998 | |
| 963 | 999 | // Enclosing the user input within some other text? |
| 964 | - if (!empty($row['enclose']) && !empty($output_html)) |
|
| 965 | - $output_html = strtr($row['enclose'], array( |
|
| 1000 | + if (!empty($row['enclose']) && !empty($output_html)) { |
|
| 1001 | + $output_html = strtr($row['enclose'], array( |
|
| 966 | 1002 | '{SCRIPTURL}' => $scripturl, |
| 967 | 1003 | '{IMAGES_URL}' => $settings['images_url'], |
| 968 | 1004 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 969 | 1005 | '{INPUT}' => un_htmlspecialchars($output_html), |
| 970 | 1006 | )); |
| 1007 | + } |
|
| 971 | 1008 | |
| 972 | 1009 | $context['custom_fields'][] = array( |
| 973 | 1010 | 'name' => $row['field_name'], |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 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 | * The main entrance point for the 'Paid Subscription' screen, calling |
@@ -32,18 +33,19 @@ discard block |
||
| 32 | 33 | loadLanguage('ManagePaid'); |
| 33 | 34 | loadTemplate('ManagePaid'); |
| 34 | 35 | |
| 35 | - if (!empty($modSettings['paid_enabled'])) |
|
| 36 | - $subActions = array( |
|
| 36 | + if (!empty($modSettings['paid_enabled'])) { |
|
| 37 | + $subActions = array( |
|
| 37 | 38 | 'modify' => array('ModifySubscription', 'admin_forum'), |
| 38 | 39 | 'modifyuser' => array('ModifyUserSubscription', 'admin_forum'), |
| 39 | 40 | 'settings' => array('ModifySubscriptionSettings', 'admin_forum'), |
| 40 | 41 | 'view' => array('ViewSubscriptions', 'admin_forum'), |
| 41 | 42 | 'viewsub' => array('ViewSubscribedUsers', 'admin_forum'), |
| 42 | 43 | ); |
| 43 | - else |
|
| 44 | - $subActions = array( |
|
| 44 | + } else { |
|
| 45 | + $subActions = array( |
|
| 45 | 46 | 'settings' => array('ModifySubscriptionSettings', 'admin_forum'), |
| 46 | 47 | ); |
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Default the sub-action to 'view subscriptions', but only if they have already set things up.. |
| 49 | 51 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($modSettings['paid_currency_symbol']) && !empty($modSettings['paid_enabled']) ? 'view' : 'settings'); |
@@ -59,8 +61,8 @@ discard block |
||
| 59 | 61 | 'help' => '', |
| 60 | 62 | 'description' => $txt['paid_subscriptions_desc'], |
| 61 | 63 | ); |
| 62 | - if (!empty($modSettings['paid_enabled'])) |
|
| 63 | - $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 64 | + if (!empty($modSettings['paid_enabled'])) { |
|
| 65 | + $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 64 | 66 | 'view' => array( |
| 65 | 67 | 'description' => $txt['paid_subs_view_desc'], |
| 66 | 68 | ), |
@@ -68,6 +70,7 @@ discard block |
||
| 68 | 70 | 'description' => $txt['paid_subs_settings_desc'], |
| 69 | 71 | ), |
| 70 | 72 | ); |
| 73 | + } |
|
| 71 | 74 | |
| 72 | 75 | call_integration_hook('integrate_manage_subscriptions', array(&$subActions)); |
| 73 | 76 | |
@@ -92,8 +95,9 @@ discard block |
||
| 92 | 95 | { |
| 93 | 96 | // If the currency is set to something different then we need to set it to other for this to work and set it back shortly. |
| 94 | 97 | $modSettings['paid_currency'] = !empty($modSettings['paid_currency_code']) ? $modSettings['paid_currency_code'] : ''; |
| 95 | - if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp', 'cad', 'aud'))) |
|
| 96 | - $modSettings['paid_currency'] = 'other'; |
|
| 98 | + if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp', 'cad', 'aud'))) { |
|
| 99 | + $modSettings['paid_currency'] = 'other'; |
|
| 100 | + } |
|
| 97 | 101 | |
| 98 | 102 | // These are all the default settings. |
| 99 | 103 | $config_vars = array( |
@@ -156,8 +160,7 @@ discard block |
||
| 156 | 160 | } |
| 157 | 161 | } |
| 158 | 162 | toggleOther();', true); |
| 159 | - } |
|
| 160 | - else |
|
| 163 | + } else |
|
| 161 | 164 | { |
| 162 | 165 | $config_vars = array( |
| 163 | 166 | array('check', 'paid_enabled'), |
@@ -166,8 +169,9 @@ discard block |
||
| 166 | 169 | } |
| 167 | 170 | |
| 168 | 171 | // Just searching? |
| 169 | - if ($return_config) |
|
| 170 | - return $config_vars; |
|
| 172 | + if ($return_config) { |
|
| 173 | + return $config_vars; |
|
| 174 | + } |
|
| 171 | 175 | |
| 172 | 176 | // Get the settings template fired up. |
| 173 | 177 | require_once($sourcedir . '/ManageServer.php'); |
@@ -211,8 +215,9 @@ discard block |
||
| 211 | 215 | foreach (explode(',', $_POST['paid_email_to']) as $email) |
| 212 | 216 | { |
| 213 | 217 | $email = trim($email); |
| 214 | - if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 215 | - $email_addresses[] = $email; |
|
| 218 | + if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 219 | + $email_addresses[] = $email; |
|
| 220 | + } |
|
| 216 | 221 | $_POST['paid_email_to'] = implode(',', $email_addresses); |
| 217 | 222 | } |
| 218 | 223 | } |
@@ -249,8 +254,9 @@ discard block |
||
| 249 | 254 | global $context, $txt, $modSettings, $sourcedir, $scripturl; |
| 250 | 255 | |
| 251 | 256 | // Not made the settings yet? |
| 252 | - if (empty($modSettings['paid_currency_symbol'])) |
|
| 253 | - fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings'); |
|
| 257 | + if (empty($modSettings['paid_currency_symbol'])) { |
|
| 258 | + fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings'); |
|
| 259 | + } |
|
| 254 | 260 | |
| 255 | 261 | // Some basic stuff. |
| 256 | 262 | $context['page_title'] = $txt['paid_subs_view']; |
@@ -270,10 +276,11 @@ discard block |
||
| 270 | 276 | |
| 271 | 277 | foreach ($context['subscriptions'] as $data) |
| 272 | 278 | { |
| 273 | - if (++$counter < $start) |
|
| 274 | - continue; |
|
| 275 | - elseif ($counter == $start + $items_per_page) |
|
| 276 | - break; |
|
| 279 | + if (++$counter < $start) { |
|
| 280 | + continue; |
|
| 281 | + } elseif ($counter == $start + $items_per_page) { |
|
| 282 | + break; |
|
| 283 | + } |
|
| 277 | 284 | |
| 278 | 285 | $subscriptions[] = $data; |
| 279 | 286 | } |
@@ -450,8 +457,9 @@ discard block |
||
| 450 | 457 | ); |
| 451 | 458 | $id_group = 0; |
| 452 | 459 | $add_groups = ''; |
| 453 | - if ($smcFunc['db_num_rows']($request)) |
|
| 454 | - list ($id_group, $add_groups) = $smcFunc['db_fetch_row']($request); |
|
| 460 | + if ($smcFunc['db_num_rows']($request)) { |
|
| 461 | + list ($id_group, $add_groups) = $smcFunc['db_fetch_row']($request); |
|
| 462 | + } |
|
| 455 | 463 | $smcFunc['db_free_result']($request); |
| 456 | 464 | |
| 457 | 465 | $changes = array(); |
@@ -463,8 +471,9 @@ discard block |
||
| 463 | 471 | { |
| 464 | 472 | // If their current primary group isn't what they had before the subscription, and their current group was |
| 465 | 473 | // granted by the sub, remove it. |
| 466 | - if ($member_data['old_id_group'] != $member_data['id_group'] && $member_data['id_group'] == $id_group) |
|
| 467 | - $changes[$id_member]['id_group'] = $member_data['old_id_group']; |
|
| 474 | + if ($member_data['old_id_group'] != $member_data['id_group'] && $member_data['id_group'] == $id_group) { |
|
| 475 | + $changes[$id_member]['id_group'] = $member_data['old_id_group']; |
|
| 476 | + } |
|
| 468 | 477 | } |
| 469 | 478 | } |
| 470 | 479 | |
@@ -477,15 +486,17 @@ discard block |
||
| 477 | 486 | // First let's get their groups sorted. |
| 478 | 487 | $current_groups = explode(',', $member_data['additional_groups']); |
| 479 | 488 | $new_groups = implode(',', array_diff($current_groups, $add_groups)); |
| 480 | - if ($new_groups != $member_data['additional_groups']) |
|
| 481 | - $changes[$id_member]['additional_groups'] = $new_groups; |
|
| 489 | + if ($new_groups != $member_data['additional_groups']) { |
|
| 490 | + $changes[$id_member]['additional_groups'] = $new_groups; |
|
| 491 | + } |
|
| 482 | 492 | } |
| 483 | 493 | } |
| 484 | 494 | |
| 485 | 495 | // We're going through changes... |
| 486 | - if (!empty($changes)) |
|
| 487 | - foreach ($changes as $id_member => $new_values) |
|
| 496 | + if (!empty($changes)) { |
|
| 497 | + foreach ($changes as $id_member => $new_values) |
|
| 488 | 498 | updateMemberData($id_member, $new_values); |
| 499 | + } |
|
| 489 | 500 | } |
| 490 | 501 | |
| 491 | 502 | // Delete the subscription |
@@ -533,11 +544,13 @@ discard block |
||
| 533 | 544 | 'M' => 24, |
| 534 | 545 | 'Y' => 5, |
| 535 | 546 | ); |
| 536 | - if (empty($_POST['span_unit']) || empty($limits[$_POST['span_unit']]) || empty($_POST['span_value']) || $_POST['span_value'] < 1) |
|
| 537 | - fatal_lang_error('paid_invalid_duration', false); |
|
| 547 | + if (empty($_POST['span_unit']) || empty($limits[$_POST['span_unit']]) || empty($_POST['span_value']) || $_POST['span_value'] < 1) { |
|
| 548 | + fatal_lang_error('paid_invalid_duration', false); |
|
| 549 | + } |
|
| 538 | 550 | |
| 539 | - if ($_POST['span_value'] > $limits[$_POST['span_unit']]) |
|
| 540 | - fatal_lang_error('paid_invalid_duration_' . $_POST['span_unit'], false); |
|
| 551 | + if ($_POST['span_value'] > $limits[$_POST['span_unit']]) { |
|
| 552 | + fatal_lang_error('paid_invalid_duration_' . $_POST['span_unit'], false); |
|
| 553 | + } |
|
| 541 | 554 | |
| 542 | 555 | // Clean the span. |
| 543 | 556 | $span = $_POST['span_value'] . $_POST['span_unit']; |
@@ -546,8 +559,9 @@ discard block |
||
| 546 | 559 | $cost = array('fixed' => sprintf('%01.2f', strtr($_POST['cost'], ',', '.'))); |
| 547 | 560 | |
| 548 | 561 | // There needs to be something. |
| 549 | - if (empty($_POST['span_value']) || empty($_POST['cost'])) |
|
| 550 | - fatal_lang_error('paid_no_cost_value'); |
|
| 562 | + if (empty($_POST['span_value']) || empty($_POST['cost'])) { |
|
| 563 | + fatal_lang_error('paid_no_cost_value'); |
|
| 564 | + } |
|
| 551 | 565 | } |
| 552 | 566 | // Flexible is harder but more fun ;) |
| 553 | 567 | else |
@@ -561,8 +575,9 @@ discard block |
||
| 561 | 575 | 'year' => sprintf('%01.2f', strtr($_POST['cost_year'], ',', '.')), |
| 562 | 576 | ); |
| 563 | 577 | |
| 564 | - if (empty($_POST['cost_day']) && empty($_POST['cost_week']) && empty($_POST['cost_month']) && empty($_POST['cost_year'])) |
|
| 565 | - fatal_lang_error('paid_all_freq_blank'); |
|
| 578 | + if (empty($_POST['cost_day']) && empty($_POST['cost_week']) && empty($_POST['cost_month']) && empty($_POST['cost_year'])) { |
|
| 579 | + fatal_lang_error('paid_all_freq_blank'); |
|
| 580 | + } |
|
| 566 | 581 | } |
| 567 | 582 | $cost = json_encode($cost); |
| 568 | 583 | |
@@ -571,9 +586,10 @@ discard block |
||
| 571 | 586 | |
| 572 | 587 | // Yep, time to do additional groups. |
| 573 | 588 | $addgroups = array(); |
| 574 | - if (!empty($_POST['addgroup'])) |
|
| 575 | - foreach ($_POST['addgroup'] as $id => $dummy) |
|
| 589 | + if (!empty($_POST['addgroup'])) { |
|
| 590 | + foreach ($_POST['addgroup'] as $id => $dummy) |
|
| 576 | 591 | $addgroups[] = (int) $id; |
| 592 | + } |
|
| 577 | 593 | $addgroups = implode(',', $addgroups); |
| 578 | 594 | |
| 579 | 595 | // Is it new?! |
@@ -682,18 +698,18 @@ discard block |
||
| 682 | 698 | { |
| 683 | 699 | $span_value = $match[1]; |
| 684 | 700 | $span_unit = $match[2]; |
| 685 | - } |
|
| 686 | - else |
|
| 701 | + } else |
|
| 687 | 702 | { |
| 688 | 703 | $span_value = 0; |
| 689 | 704 | $span_unit = 'D'; |
| 690 | 705 | } |
| 691 | 706 | |
| 692 | 707 | // Is this a flexible one? |
| 693 | - if ($row['length'] == 'F') |
|
| 694 | - $isFlexible = true; |
|
| 695 | - else |
|
| 696 | - $isFlexible = false; |
|
| 708 | + if ($row['length'] == 'F') { |
|
| 709 | + $isFlexible = true; |
|
| 710 | + } else { |
|
| 711 | + $isFlexible = false; |
|
| 712 | + } |
|
| 697 | 713 | |
| 698 | 714 | $context['sub'] = array( |
| 699 | 715 | 'name' => $row['name'], |
@@ -742,8 +758,9 @@ discard block |
||
| 742 | 758 | ) |
| 743 | 759 | ); |
| 744 | 760 | $context['groups'] = array(); |
| 745 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 746 | - $context['groups'][$row['id_group']] = $row['group_name']; |
|
| 761 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 762 | + $context['groups'][$row['id_group']] = $row['group_name']; |
|
| 763 | + } |
|
| 747 | 764 | $smcFunc['db_free_result']($request); |
| 748 | 765 | |
| 749 | 766 | // This always happens. |
@@ -777,8 +794,9 @@ discard block |
||
| 777 | 794 | ) |
| 778 | 795 | ); |
| 779 | 796 | // Something wrong? |
| 780 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 781 | - fatal_lang_error('no_access', false); |
|
| 797 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 798 | + fatal_lang_error('no_access', false); |
|
| 799 | + } |
|
| 782 | 800 | // Do the subscription context. |
| 783 | 801 | $row = $smcFunc['db_fetch_assoc']($request); |
| 784 | 802 | $context['subscription'] = array( |
@@ -1013,8 +1031,8 @@ discard block |
||
| 1013 | 1031 | )) |
| 1014 | 1032 | ); |
| 1015 | 1033 | $subscribers = array(); |
| 1016 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1017 | - $subscribers[] = array( |
|
| 1034 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1035 | + $subscribers[] = array( |
|
| 1018 | 1036 | 'id' => $row['id_sublog'], |
| 1019 | 1037 | 'id_member' => $row['id_member'], |
| 1020 | 1038 | 'name' => $row['name'], |
@@ -1024,6 +1042,7 @@ discard block |
||
| 1024 | 1042 | 'status' => $row['status'], |
| 1025 | 1043 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] == 0 ? $txt['paid_finished'] : $txt['paid_pending']) : $txt['paid_active'], |
| 1026 | 1044 | ); |
| 1045 | + } |
|
| 1027 | 1046 | $smcFunc['db_free_result']($request); |
| 1028 | 1047 | |
| 1029 | 1048 | return $subscribers; |
@@ -1058,14 +1077,16 @@ discard block |
||
| 1058 | 1077 | 'current_log_item' => $context['log_id'], |
| 1059 | 1078 | ) |
| 1060 | 1079 | ); |
| 1061 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1062 | - fatal_lang_error('no_access', false); |
|
| 1080 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1081 | + fatal_lang_error('no_access', false); |
|
| 1082 | + } |
|
| 1063 | 1083 | list ($context['sub_id']) = $smcFunc['db_fetch_row']($request); |
| 1064 | 1084 | $smcFunc['db_free_result']($request); |
| 1065 | 1085 | } |
| 1066 | 1086 | |
| 1067 | - if (!isset($context['subscriptions'][$context['sub_id']])) |
|
| 1068 | - fatal_lang_error('no_access', false); |
|
| 1087 | + if (!isset($context['subscriptions'][$context['sub_id']])) { |
|
| 1088 | + fatal_lang_error('no_access', false); |
|
| 1089 | + } |
|
| 1069 | 1090 | $context['current_subscription'] = $context['subscriptions'][$context['sub_id']]; |
| 1070 | 1091 | |
| 1071 | 1092 | // Searching? |
@@ -1098,8 +1119,9 @@ discard block |
||
| 1098 | 1119 | 'name' => $_POST['name'], |
| 1099 | 1120 | ) |
| 1100 | 1121 | ); |
| 1101 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1102 | - fatal_lang_error('error_member_not_found'); |
|
| 1122 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1123 | + fatal_lang_error('error_member_not_found'); |
|
| 1124 | + } |
|
| 1103 | 1125 | |
| 1104 | 1126 | list ($id_member, $id_group) = $smcFunc['db_fetch_row']($request); |
| 1105 | 1127 | $smcFunc['db_free_result']($request); |
@@ -1115,14 +1137,15 @@ discard block |
||
| 1115 | 1137 | 'current_member' => $id_member, |
| 1116 | 1138 | ) |
| 1117 | 1139 | ); |
| 1118 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1119 | - fatal_lang_error('member_already_subscribed'); |
|
| 1140 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1141 | + fatal_lang_error('member_already_subscribed'); |
|
| 1142 | + } |
|
| 1120 | 1143 | $smcFunc['db_free_result']($request); |
| 1121 | 1144 | |
| 1122 | 1145 | // Actually put the subscription in place. |
| 1123 | - if ($status == 1) |
|
| 1124 | - addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
|
| 1125 | - else |
|
| 1146 | + if ($status == 1) { |
|
| 1147 | + addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
|
| 1148 | + } else |
|
| 1126 | 1149 | { |
| 1127 | 1150 | $smcFunc['db_insert']('', |
| 1128 | 1151 | '{db_prefix}log_subscribed', |
@@ -1149,20 +1172,20 @@ discard block |
||
| 1149 | 1172 | 'current_log_item' => $context['log_id'], |
| 1150 | 1173 | ) |
| 1151 | 1174 | ); |
| 1152 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1153 | - fatal_lang_error('no_access', false); |
|
| 1175 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1176 | + fatal_lang_error('no_access', false); |
|
| 1177 | + } |
|
| 1154 | 1178 | |
| 1155 | 1179 | list ($id_member, $old_status) = $smcFunc['db_fetch_row']($request); |
| 1156 | 1180 | $smcFunc['db_free_result']($request); |
| 1157 | 1181 | |
| 1158 | 1182 | // Pick the right permission stuff depending on what the status is changing from/to. |
| 1159 | - if ($old_status == 1 && $status != 1) |
|
| 1160 | - removeSubscription($context['sub_id'], $id_member); |
|
| 1161 | - elseif ($status == 1 && $old_status != 1) |
|
| 1183 | + if ($old_status == 1 && $status != 1) { |
|
| 1184 | + removeSubscription($context['sub_id'], $id_member); |
|
| 1185 | + } elseif ($status == 1 && $old_status != 1) |
|
| 1162 | 1186 | { |
| 1163 | 1187 | addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
| 1164 | - } |
|
| 1165 | - else |
|
| 1188 | + } else |
|
| 1166 | 1189 | { |
| 1167 | 1190 | $smcFunc['db_query']('', ' |
| 1168 | 1191 | UPDATE {db_prefix}log_subscribed |
@@ -1190,8 +1213,9 @@ discard block |
||
| 1190 | 1213 | if (!empty($_REQUEST['delsub'])) |
| 1191 | 1214 | { |
| 1192 | 1215 | $toDelete = array(); |
| 1193 | - foreach ($_REQUEST['delsub'] as $id => $dummy) |
|
| 1194 | - $toDelete[] = (int) $id; |
|
| 1216 | + foreach ($_REQUEST['delsub'] as $id => $dummy) { |
|
| 1217 | + $toDelete[] = (int) $id; |
|
| 1218 | + } |
|
| 1195 | 1219 | |
| 1196 | 1220 | $request = $smcFunc['db_query']('', ' |
| 1197 | 1221 | SELECT id_subscribe, id_member |
@@ -1201,8 +1225,9 @@ discard block |
||
| 1201 | 1225 | 'subscription_list' => $toDelete, |
| 1202 | 1226 | ) |
| 1203 | 1227 | ); |
| 1204 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1205 | - removeSubscription($row['id_subscribe'], $row['id_member'], isset($_REQUEST['delete'])); |
|
| 1228 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1229 | + removeSubscription($row['id_subscribe'], $row['id_member'], isset($_REQUEST['delete'])); |
|
| 1230 | + } |
|
| 1206 | 1231 | $smcFunc['db_free_result']($request); |
| 1207 | 1232 | } |
| 1208 | 1233 | redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']); |
@@ -1246,9 +1271,9 @@ discard block |
||
| 1246 | 1271 | ); |
| 1247 | 1272 | list ($context['sub']['username']) = $smcFunc['db_fetch_row']($request); |
| 1248 | 1273 | $smcFunc['db_free_result']($request); |
| 1274 | + } else { |
|
| 1275 | + $context['sub']['username'] = ''; |
|
| 1249 | 1276 | } |
| 1250 | - else |
|
| 1251 | - $context['sub']['username'] = ''; |
|
| 1252 | 1277 | } |
| 1253 | 1278 | // Otherwise load the existing info. |
| 1254 | 1279 | else |
@@ -1265,8 +1290,9 @@ discard block |
||
| 1265 | 1290 | 'blank_string' => '', |
| 1266 | 1291 | ) |
| 1267 | 1292 | ); |
| 1268 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1269 | - fatal_lang_error('no_access', false); |
|
| 1293 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1294 | + fatal_lang_error('no_access', false); |
|
| 1295 | + } |
|
| 1270 | 1296 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1271 | 1297 | $smcFunc['db_free_result']($request); |
| 1272 | 1298 | |
@@ -1287,13 +1313,13 @@ discard block |
||
| 1287 | 1313 | { |
| 1288 | 1314 | foreach ($costs as $duration => $cost) |
| 1289 | 1315 | { |
| 1290 | - if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) |
|
| 1291 | - $context['pending_payments'][$id] = array( |
|
| 1316 | + if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) { |
|
| 1317 | + $context['pending_payments'][$id] = array( |
|
| 1292 | 1318 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $cost . '/' . $txt[$duration]), |
| 1293 | 1319 | ); |
| 1320 | + } |
|
| 1294 | 1321 | } |
| 1295 | - } |
|
| 1296 | - elseif ($costs['fixed'] == $pending[1]) |
|
| 1322 | + } elseif ($costs['fixed'] == $pending[1]) |
|
| 1297 | 1323 | { |
| 1298 | 1324 | $context['pending_payments'][$id] = array( |
| 1299 | 1325 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $costs['fixed']), |
@@ -1311,8 +1337,9 @@ discard block |
||
| 1311 | 1337 | if ($_GET['pending'] == $id && $pending[3] == 'payback' && isset($context['pending_payments'][$id])) |
| 1312 | 1338 | { |
| 1313 | 1339 | // Flexible? |
| 1314 | - if (isset($_GET['accept'])) |
|
| 1315 | - addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1340 | + if (isset($_GET['accept'])) { |
|
| 1341 | + addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1342 | + } |
|
| 1316 | 1343 | unset($pending_details[$id]); |
| 1317 | 1344 | |
| 1318 | 1345 | $new_details = json_encode($pending_details); |
@@ -1374,8 +1401,9 @@ discard block |
||
| 1374 | 1401 | global $smcFunc; |
| 1375 | 1402 | |
| 1376 | 1403 | // Make it an array. |
| 1377 | - if (!is_array($users)) |
|
| 1378 | - $users = array($users); |
|
| 1404 | + if (!is_array($users)) { |
|
| 1405 | + $users = array($users); |
|
| 1406 | + } |
|
| 1379 | 1407 | |
| 1380 | 1408 | // Get all the members current groups. |
| 1381 | 1409 | $groups = array(); |
@@ -1413,14 +1441,16 @@ discard block |
||
| 1413 | 1441 | if ($row['id_group'] != 0) |
| 1414 | 1442 | { |
| 1415 | 1443 | // If this is changing - add the old one to the additional groups so it's not lost. |
| 1416 | - if ($row['id_group'] != $groups[$row['id_member']]['primary']) |
|
| 1417 | - $groups[$row['id_member']]['additional'][] = $groups[$row['id_member']]['primary']; |
|
| 1444 | + if ($row['id_group'] != $groups[$row['id_member']]['primary']) { |
|
| 1445 | + $groups[$row['id_member']]['additional'][] = $groups[$row['id_member']]['primary']; |
|
| 1446 | + } |
|
| 1418 | 1447 | $groups[$row['id_member']]['primary'] = $row['id_group']; |
| 1419 | 1448 | } |
| 1420 | 1449 | |
| 1421 | 1450 | // Additional groups. |
| 1422 | - if (!empty($row['add_groups'])) |
|
| 1423 | - $groups[$row['id_member']]['additional'] = array_merge($groups[$row['id_member']]['additional'], explode(',', $row['add_groups'])); |
|
| 1451 | + if (!empty($row['add_groups'])) { |
|
| 1452 | + $groups[$row['id_member']]['additional'] = array_merge($groups[$row['id_member']]['additional'], explode(',', $row['add_groups'])); |
|
| 1453 | + } |
|
| 1424 | 1454 | } |
| 1425 | 1455 | $smcFunc['db_free_result']($request); |
| 1426 | 1456 | |
@@ -1428,9 +1458,10 @@ discard block |
||
| 1428 | 1458 | foreach ($groups as $id => $group) |
| 1429 | 1459 | { |
| 1430 | 1460 | $group['additional'] = array_unique($group['additional']); |
| 1431 | - foreach ($group['additional'] as $key => $value) |
|
| 1432 | - if (empty($value)) |
|
| 1461 | + foreach ($group['additional'] as $key => $value) { |
|
| 1462 | + if (empty($value)) |
|
| 1433 | 1463 | unset($group['additional'][$key]); |
| 1464 | + } |
|
| 1434 | 1465 | $addgroups = implode(',', $group['additional']); |
| 1435 | 1466 | |
| 1436 | 1467 | $smcFunc['db_query']('', ' |
@@ -1464,8 +1495,9 @@ discard block |
||
| 1464 | 1495 | loadSubscriptions(); |
| 1465 | 1496 | |
| 1466 | 1497 | // Exists, yes? |
| 1467 | - if (!isset($context['subscriptions'][$id_subscribe])) |
|
| 1468 | - return; |
|
| 1498 | + if (!isset($context['subscriptions'][$id_subscribe])) { |
|
| 1499 | + return; |
|
| 1500 | + } |
|
| 1469 | 1501 | |
| 1470 | 1502 | $curSub = $context['subscriptions'][$id_subscribe]; |
| 1471 | 1503 | |
@@ -1513,16 +1545,19 @@ discard block |
||
| 1513 | 1545 | list ($id_sublog, $endtime, $starttime) = $smcFunc['db_fetch_row']($request); |
| 1514 | 1546 | |
| 1515 | 1547 | // If this has already expired but is active, extension means the period from now. |
| 1516 | - if ($endtime < time()) |
|
| 1517 | - $endtime = time(); |
|
| 1518 | - if ($starttime == 0) |
|
| 1519 | - $starttime = time(); |
|
| 1548 | + if ($endtime < time()) { |
|
| 1549 | + $endtime = time(); |
|
| 1550 | + } |
|
| 1551 | + if ($starttime == 0) { |
|
| 1552 | + $starttime = time(); |
|
| 1553 | + } |
|
| 1520 | 1554 | |
| 1521 | 1555 | // Work out the new expiry date. |
| 1522 | 1556 | $endtime += $duration; |
| 1523 | 1557 | |
| 1524 | - if ($forceEndTime != 0) |
|
| 1525 | - $endtime = $forceEndTime; |
|
| 1558 | + if ($forceEndTime != 0) { |
|
| 1559 | + $endtime = $forceEndTime; |
|
| 1560 | + } |
|
| 1526 | 1561 | |
| 1527 | 1562 | // As everything else should be good, just update! |
| 1528 | 1563 | $smcFunc['db_query']('', ' |
@@ -1552,8 +1587,9 @@ discard block |
||
| 1552 | 1587 | ); |
| 1553 | 1588 | |
| 1554 | 1589 | // Just in case the member doesn't exist. |
| 1555 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1556 | - return; |
|
| 1590 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1591 | + return; |
|
| 1592 | + } |
|
| 1557 | 1593 | |
| 1558 | 1594 | list ($old_id_group, $additional_groups) = $smcFunc['db_fetch_row']($request); |
| 1559 | 1595 | $smcFunc['db_free_result']($request); |
@@ -1570,16 +1606,18 @@ discard block |
||
| 1570 | 1606 | $id_group = $curSub['prim_group']; |
| 1571 | 1607 | |
| 1572 | 1608 | // Ensure their old privileges are maintained. |
| 1573 | - if ($old_id_group != 0) |
|
| 1574 | - $newAddGroups[] = $old_id_group; |
|
| 1609 | + if ($old_id_group != 0) { |
|
| 1610 | + $newAddGroups[] = $old_id_group; |
|
| 1611 | + } |
|
| 1612 | + } else { |
|
| 1613 | + $id_group = $old_id_group; |
|
| 1575 | 1614 | } |
| 1576 | - else |
|
| 1577 | - $id_group = $old_id_group; |
|
| 1578 | 1615 | |
| 1579 | 1616 | // Yep, make sure it's unique, and no empties. |
| 1580 | - foreach ($newAddGroups as $k => $v) |
|
| 1581 | - if (empty($v)) |
|
| 1617 | + foreach ($newAddGroups as $k => $v) { |
|
| 1618 | + if (empty($v)) |
|
| 1582 | 1619 | unset($newAddGroups[$k]); |
| 1620 | + } |
|
| 1583 | 1621 | $newAddGroups = array_unique($newAddGroups); |
| 1584 | 1622 | $newAddGroups = implode(',', $newAddGroups); |
| 1585 | 1623 | |
@@ -1615,16 +1653,19 @@ discard block |
||
| 1615 | 1653 | list ($id_sublog, $endtime, $starttime) = $smcFunc['db_fetch_row']($request); |
| 1616 | 1654 | |
| 1617 | 1655 | // If this has already expired but is active, extension means the period from now. |
| 1618 | - if ($endtime < time()) |
|
| 1619 | - $endtime = time(); |
|
| 1620 | - if ($starttime == 0) |
|
| 1621 | - $starttime = time(); |
|
| 1656 | + if ($endtime < time()) { |
|
| 1657 | + $endtime = time(); |
|
| 1658 | + } |
|
| 1659 | + if ($starttime == 0) { |
|
| 1660 | + $starttime = time(); |
|
| 1661 | + } |
|
| 1622 | 1662 | |
| 1623 | 1663 | // Work out the new expiry date. |
| 1624 | 1664 | $endtime += $duration; |
| 1625 | 1665 | |
| 1626 | - if ($forceEndTime != 0) |
|
| 1627 | - $endtime = $forceEndTime; |
|
| 1666 | + if ($forceEndTime != 0) { |
|
| 1667 | + $endtime = $forceEndTime; |
|
| 1668 | + } |
|
| 1628 | 1669 | |
| 1629 | 1670 | // As everything else should be good, just update! |
| 1630 | 1671 | $smcFunc['db_query']('', ' |
@@ -1647,13 +1688,15 @@ discard block |
||
| 1647 | 1688 | |
| 1648 | 1689 | // Otherwise a very simple insert. |
| 1649 | 1690 | $endtime = time() + $duration; |
| 1650 | - if ($forceEndTime != 0) |
|
| 1651 | - $endtime = $forceEndTime; |
|
| 1691 | + if ($forceEndTime != 0) { |
|
| 1692 | + $endtime = $forceEndTime; |
|
| 1693 | + } |
|
| 1652 | 1694 | |
| 1653 | - if ($forceStartTime == 0) |
|
| 1654 | - $starttime = time(); |
|
| 1655 | - else |
|
| 1656 | - $starttime = $forceStartTime; |
|
| 1695 | + if ($forceStartTime == 0) { |
|
| 1696 | + $starttime = time(); |
|
| 1697 | + } else { |
|
| 1698 | + $starttime = $forceStartTime; |
|
| 1699 | + } |
|
| 1657 | 1700 | |
| 1658 | 1701 | $smcFunc['db_insert']('', |
| 1659 | 1702 | '{db_prefix}log_subscribed', |
@@ -1726,15 +1769,17 @@ discard block |
||
| 1726 | 1769 | $new_id_group = -1; |
| 1727 | 1770 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1728 | 1771 | { |
| 1729 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 1730 | - continue; |
|
| 1772 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 1773 | + continue; |
|
| 1774 | + } |
|
| 1731 | 1775 | |
| 1732 | 1776 | // The one we're removing? |
| 1733 | 1777 | if ($row['id_subscribe'] == $id_subscribe) |
| 1734 | 1778 | { |
| 1735 | 1779 | $removals = explode(',', $context['subscriptions'][$row['id_subscribe']]['add_groups']); |
| 1736 | - if ($context['subscriptions'][$row['id_subscribe']]['prim_group'] != 0) |
|
| 1737 | - $removals[] = $context['subscriptions'][$row['id_subscribe']]['prim_group']; |
|
| 1780 | + if ($context['subscriptions'][$row['id_subscribe']]['prim_group'] != 0) { |
|
| 1781 | + $removals[] = $context['subscriptions'][$row['id_subscribe']]['prim_group']; |
|
| 1782 | + } |
|
| 1738 | 1783 | $old_id_group = $row['old_id_group']; |
| 1739 | 1784 | } |
| 1740 | 1785 | // Otherwise things we allow. |
@@ -1752,30 +1797,33 @@ discard block |
||
| 1752 | 1797 | |
| 1753 | 1798 | // Now, for everything we are removing check they definitely are not allowed it. |
| 1754 | 1799 | $existingGroups = explode(',', $additional_groups); |
| 1755 | - foreach ($existingGroups as $key => $group) |
|
| 1756 | - if (empty($group) || (in_array($group, $removals) && !in_array($group, $allowed))) |
|
| 1800 | + foreach ($existingGroups as $key => $group) { |
|
| 1801 | + if (empty($group) || (in_array($group, $removals) && !in_array($group, $allowed))) |
|
| 1757 | 1802 | unset($existingGroups[$key]); |
| 1803 | + } |
|
| 1758 | 1804 | |
| 1759 | 1805 | // Finally, do something with the current primary group. |
| 1760 | 1806 | if (in_array($id_group, $removals)) |
| 1761 | 1807 | { |
| 1762 | 1808 | // If this primary group is actually allowed keep it. |
| 1763 | - if (in_array($id_group, $allowed)) |
|
| 1764 | - $existingGroups[] = $id_group; |
|
| 1809 | + if (in_array($id_group, $allowed)) { |
|
| 1810 | + $existingGroups[] = $id_group; |
|
| 1811 | + } |
|
| 1765 | 1812 | |
| 1766 | 1813 | // Either way, change the id_group back. |
| 1767 | 1814 | if ($new_id_group < 1) |
| 1768 | 1815 | { |
| 1769 | 1816 | // If we revert to the old id-group we need to ensure it wasn't from a subscription. |
| 1770 | - foreach ($context['subscriptions'] as $id => $group) |
|
| 1771 | - // It was? Make them a regular member then! |
|
| 1817 | + foreach ($context['subscriptions'] as $id => $group) { |
|
| 1818 | + // It was? Make them a regular member then! |
|
| 1772 | 1819 | if ($group['prim_group'] == $old_id_group) |
| 1773 | 1820 | $old_id_group = 0; |
| 1821 | + } |
|
| 1774 | 1822 | |
| 1775 | 1823 | $id_group = $old_id_group; |
| 1824 | + } else { |
|
| 1825 | + $id_group = $new_id_group; |
|
| 1776 | 1826 | } |
| 1777 | - else |
|
| 1778 | - $id_group = $new_id_group; |
|
| 1779 | 1827 | } |
| 1780 | 1828 | |
| 1781 | 1829 | // Crazy stuff, we seem to have our groups fixed, just make them unique |
@@ -1795,8 +1843,8 @@ discard block |
||
| 1795 | 1843 | ); |
| 1796 | 1844 | |
| 1797 | 1845 | // Disable the subscription. |
| 1798 | - if (!$delete) |
|
| 1799 | - $smcFunc['db_query']('', ' |
|
| 1846 | + if (!$delete) { |
|
| 1847 | + $smcFunc['db_query']('', ' |
|
| 1800 | 1848 | UPDATE {db_prefix}log_subscribed |
| 1801 | 1849 | SET status = {int:not_active} |
| 1802 | 1850 | WHERE id_member = {int:current_member} |
@@ -1807,9 +1855,10 @@ discard block |
||
| 1807 | 1855 | 'current_subscription' => $id_subscribe, |
| 1808 | 1856 | ) |
| 1809 | 1857 | ); |
| 1858 | + } |
|
| 1810 | 1859 | // Otherwise delete it! |
| 1811 | - else |
|
| 1812 | - $smcFunc['db_query']('', ' |
|
| 1860 | + else { |
|
| 1861 | + $smcFunc['db_query']('', ' |
|
| 1813 | 1862 | DELETE FROM {db_prefix}log_subscribed |
| 1814 | 1863 | WHERE id_member = {int:current_member} |
| 1815 | 1864 | AND id_subscribe = {int:current_subscription}', |
@@ -1818,7 +1867,8 @@ discard block |
||
| 1818 | 1867 | 'current_subscription' => $id_subscribe, |
| 1819 | 1868 | ) |
| 1820 | 1869 | ); |
| 1821 | -} |
|
| 1870 | + } |
|
| 1871 | + } |
|
| 1822 | 1872 | |
| 1823 | 1873 | /** |
| 1824 | 1874 | * This just kind of caches all the subscription data. |
@@ -1827,8 +1877,9 @@ discard block |
||
| 1827 | 1877 | { |
| 1828 | 1878 | global $context, $txt, $modSettings, $smcFunc; |
| 1829 | 1879 | |
| 1830 | - if (!empty($context['subscriptions'])) |
|
| 1831 | - return; |
|
| 1880 | + if (!empty($context['subscriptions'])) { |
|
| 1881 | + return; |
|
| 1882 | + } |
|
| 1832 | 1883 | |
| 1833 | 1884 | // Make sure this is loaded, just in case. |
| 1834 | 1885 | loadLanguage('ManagePaid'); |
@@ -1845,10 +1896,11 @@ discard block |
||
| 1845 | 1896 | // Pick a cost. |
| 1846 | 1897 | $costs = smf_json_decode($row['cost'], true); |
| 1847 | 1898 | |
| 1848 | - if ($row['length'] != 'F' && !empty($modSettings['paid_currency_symbol']) && !empty($costs['fixed'])) |
|
| 1849 | - $cost = sprintf($modSettings['paid_currency_symbol'], $costs['fixed']); |
|
| 1850 | - else |
|
| 1851 | - $cost = '???'; |
|
| 1899 | + if ($row['length'] != 'F' && !empty($modSettings['paid_currency_symbol']) && !empty($costs['fixed'])) { |
|
| 1900 | + $cost = sprintf($modSettings['paid_currency_symbol'], $costs['fixed']); |
|
| 1901 | + } else { |
|
| 1902 | + $cost = '???'; |
|
| 1903 | + } |
|
| 1852 | 1904 | |
| 1853 | 1905 | // Do the span. |
| 1854 | 1906 | preg_match('~(\d*)(\w)~', $row['length'], $match); |
@@ -1875,9 +1927,9 @@ discard block |
||
| 1875 | 1927 | $num_length *= 31556926; |
| 1876 | 1928 | break; |
| 1877 | 1929 | } |
| 1930 | + } else { |
|
| 1931 | + $length = '??'; |
|
| 1878 | 1932 | } |
| 1879 | - else |
|
| 1880 | - $length = '??'; |
|
| 1881 | 1933 | |
| 1882 | 1934 | $context['subscriptions'][$row['id_subscribe']] = array( |
| 1883 | 1935 | 'id' => $row['id_subscribe'], |
@@ -1912,8 +1964,9 @@ discard block |
||
| 1912 | 1964 | { |
| 1913 | 1965 | $ind = $row['status'] == 0 ? 'finished' : 'total'; |
| 1914 | 1966 | |
| 1915 | - if (isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 1916 | - $context['subscriptions'][$row['id_subscribe']][$ind] = $row['member_count']; |
|
| 1967 | + if (isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 1968 | + $context['subscriptions'][$row['id_subscribe']][$ind] = $row['member_count']; |
|
| 1969 | + } |
|
| 1917 | 1970 | } |
| 1918 | 1971 | $smcFunc['db_free_result']($request); |
| 1919 | 1972 | |
@@ -1927,8 +1980,9 @@ discard block |
||
| 1927 | 1980 | ); |
| 1928 | 1981 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1929 | 1982 | { |
| 1930 | - if (isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 1931 | - $context['subscriptions'][$row['id_subscribe']]['pending'] = $row['total_pending']; |
|
| 1983 | + if (isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 1984 | + $context['subscriptions'][$row['id_subscribe']]['pending'] = $row['total_pending']; |
|
| 1985 | + } |
|
| 1932 | 1986 | } |
| 1933 | 1987 | $smcFunc['db_free_result']($request); |
| 1934 | 1988 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,12 +46,14 @@ 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 | // Get it from the cache and send it back. |
| 52 | - if (($temp = cache_get_data('membersOnlineStats-' . $membersOnlineOptions['sort'], 240)) !== null) |
|
| 53 | - return $temp; |
|
| 54 | + if (($temp = cache_get_data('membersOnlineStats-' . $membersOnlineOptions['sort'], 240)) !== null) { |
|
| 55 | + return $temp; |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Initialize the array that'll be returned later on. |
| 56 | 59 | $membersOnlineStats = array( |
@@ -67,8 +70,9 @@ discard block |
||
| 67 | 70 | // Get any spiders if enabled. |
| 68 | 71 | $spiders = array(); |
| 69 | 72 | $spider_finds = array(); |
| 70 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
| 71 | - $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
| 73 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
| 74 | + $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
| 75 | + } |
|
| 72 | 76 | |
| 73 | 77 | // Load the users online right now. |
| 74 | 78 | $request = $smcFunc['db_query']('', ' |
@@ -96,9 +100,7 @@ discard block |
||
| 96 | 100 | $membersOnlineStats['num_guests']++; |
| 97 | 101 | |
| 98 | 102 | continue; |
| 99 | - } |
|
| 100 | - |
|
| 101 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 103 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 102 | 104 | { |
| 103 | 105 | // Just increase the stats and don't add this hidden user to any list. |
| 104 | 106 | $membersOnlineStats['num_users_hidden']++; |
@@ -106,10 +108,11 @@ discard block |
||
| 106 | 108 | } |
| 107 | 109 | |
| 108 | 110 | // Some basic color coding... |
| 109 | - if (!empty($row['online_color'])) |
|
| 110 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 111 | - else |
|
| 112 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 111 | + if (!empty($row['online_color'])) { |
|
| 112 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 113 | + } else { |
|
| 114 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 115 | + } |
|
| 113 | 116 | |
| 114 | 117 | // Buddies get counted and highlighted. |
| 115 | 118 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -136,12 +139,13 @@ discard block |
||
| 136 | 139 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
| 137 | 140 | |
| 138 | 141 | // Store all distinct (primary) membergroups that are shown. |
| 139 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
| 140 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 142 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
| 143 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 141 | 144 | 'id' => $row['id_group'], |
| 142 | 145 | 'name' => $row['group_name'], |
| 143 | 146 | 'color' => $row['online_color'] |
| 144 | 147 | ); |
| 148 | + } |
|
| 145 | 149 | } |
| 146 | 150 | $smcFunc['db_free_result']($request); |
| 147 | 151 | |
@@ -204,11 +208,12 @@ discard block |
||
| 204 | 208 | $settingsToUpdate = array(); |
| 205 | 209 | |
| 206 | 210 | // More members on now than ever were? Update it! |
| 207 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
| 208 | - $settingsToUpdate = array( |
|
| 211 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
| 212 | + $settingsToUpdate = array( |
|
| 209 | 213 | 'mostOnline' => $total_users_online, |
| 210 | 214 | 'mostDate' => time() |
| 211 | 215 | ); |
| 216 | + } |
|
| 212 | 217 | |
| 213 | 218 | $date = strftime('%Y-%m-%d', forum_time(false)); |
| 214 | 219 | |
@@ -240,8 +245,9 @@ discard block |
||
| 240 | 245 | { |
| 241 | 246 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
| 242 | 247 | |
| 243 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
| 244 | - trackStats(array('most_on' => $total_users_online)); |
|
| 248 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
| 249 | + trackStats(array('most_on' => $total_users_online)); |
|
| 250 | + } |
|
| 245 | 251 | |
| 246 | 252 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
| 247 | 253 | } |
@@ -258,8 +264,9 @@ discard block |
||
| 258 | 264 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
| 259 | 265 | } |
| 260 | 266 | |
| 261 | - if (!empty($settingsToUpdate)) |
|
| 262 | - updateSettings($settingsToUpdate); |
|
| 263 | -} |
|
| 267 | + if (!empty($settingsToUpdate)) { |
|
| 268 | + updateSettings($settingsToUpdate); |
|
| 269 | + } |
|
| 270 | + } |
|
| 264 | 271 | |
| 265 | 272 | ?> |
| 266 | 273 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get the latest posts of a forum. |
@@ -59,8 +60,9 @@ discard block |
||
| 59 | 60 | censorText($row['body']); |
| 60 | 61 | |
| 61 | 62 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
| 62 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 63 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 63 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 64 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // Build the array. |
| 66 | 68 | $posts[] = array( |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | class Attachments |
| 20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
| 70 | 71 | |
| 71 | 72 | $this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false; |
| 72 | 73 | |
| 73 | - if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) |
|
| 74 | - $this->{$this->_sa}(); |
|
| 74 | + if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) { |
|
| 75 | + $this->{$this->_sa}(); |
|
| 76 | + } |
|
| 75 | 77 | |
| 76 | 78 | // Just send a generic message. |
| 77 | - else |
|
| 78 | - $this->setResponse(array( |
|
| 79 | + else { |
|
| 80 | + $this->setResponse(array( |
|
| 79 | 81 | 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
| 80 | 82 | 'type' => 'error', |
| 81 | 83 | 'data' => false, |
| 82 | 84 | )); |
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | // Back to the future, oh, to the browser! |
| 85 | 88 | $this->sendResponse(); |
@@ -95,12 +98,13 @@ discard block |
||
| 95 | 98 | $attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0; |
| 96 | 99 | |
| 97 | 100 | // Need something to work with. |
| 98 | - if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) |
|
| 99 | - return $this->setResponse(array( |
|
| 101 | + if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) { |
|
| 102 | + return $this->setResponse(array( |
|
| 100 | 103 | 'text' => 'attached_file_deleted_error', |
| 101 | 104 | 'type' => 'error', |
| 102 | 105 | 'data' => false, |
| 103 | 106 | )); |
| 107 | + } |
|
| 104 | 108 | |
| 105 | 109 | // Lets pass some params and see what happens :P |
| 106 | 110 | $affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true); |
@@ -121,19 +125,21 @@ discard block |
||
| 121 | 125 | $result = array(); |
| 122 | 126 | |
| 123 | 127 | // You gotta be able to post attachments. |
| 124 | - if (!$this->_canPostAttachment) |
|
| 125 | - return $this->setResponse(array( |
|
| 128 | + if (!$this->_canPostAttachment) { |
|
| 129 | + return $this->setResponse(array( |
|
| 126 | 130 | 'text' => 'attached_file_cannot', |
| 127 | 131 | 'type' => 'error', |
| 128 | 132 | 'data' => false, |
| 129 | 133 | )); |
| 134 | + } |
|
| 130 | 135 | |
| 131 | 136 | // Process them at once! |
| 132 | 137 | $this->processAttachments(); |
| 133 | 138 | |
| 134 | 139 | // The attachments was created and moved the the right folder, time to update the DB. |
| 135 | - if (!empty($_SESSION['temp_attachments'])) |
|
| 136 | - $this->createAtttach(); |
|
| 140 | + if (!empty($_SESSION['temp_attachments'])) { |
|
| 141 | + $this->createAtttach(); |
|
| 142 | + } |
|
| 137 | 143 | |
| 138 | 144 | // Set the response. |
| 139 | 145 | $this->setResponse(); |
@@ -146,8 +152,9 @@ discard block |
||
| 146 | 152 | { |
| 147 | 153 | global $context, $modSettings, $smcFunc, $user_info, $txt; |
| 148 | 154 | |
| 149 | - if (!isset($_FILES['attachment']['name'])) |
|
| 150 | - $_FILES['attachment']['tmp_name'] = array(); |
|
| 155 | + if (!isset($_FILES['attachment']['name'])) { |
|
| 156 | + $_FILES['attachment']['tmp_name'] = array(); |
|
| 157 | + } |
|
| 151 | 158 | |
| 152 | 159 | // If there are attachments, calculate the total size and how many. |
| 153 | 160 | $context['attachments']['total_size'] = 0; |
@@ -157,25 +164,30 @@ discard block |
||
| 157 | 164 | if (isset($_REQUEST['msg'])) |
| 158 | 165 | { |
| 159 | 166 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 160 | - foreach ($context['current_attachments'] as $attachment) |
|
| 161 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 167 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 168 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 169 | + } |
|
| 162 | 170 | } |
| 163 | 171 | |
| 164 | 172 | // A bit of house keeping first. |
| 165 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 166 | - unset($_SESSION['temp_attachments']); |
|
| 173 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 174 | + unset($_SESSION['temp_attachments']); |
|
| 175 | + } |
|
| 167 | 176 | |
| 168 | 177 | // Our infamous SESSION var, we are gonna have soo much fun with it! |
| 169 | - if (!isset($_SESSION['temp_attachments'])) |
|
| 170 | - $_SESSION['temp_attachments'] = array(); |
|
| 178 | + if (!isset($_SESSION['temp_attachments'])) { |
|
| 179 | + $_SESSION['temp_attachments'] = array(); |
|
| 180 | + } |
|
| 171 | 181 | |
| 172 | 182 | // Make sure we're uploading to the right place. |
| 173 | - if (!empty($modSettings['automanage_attachments'])) |
|
| 174 | - automanage_attachments_check_directory(); |
|
| 183 | + if (!empty($modSettings['automanage_attachments'])) { |
|
| 184 | + automanage_attachments_check_directory(); |
|
| 185 | + } |
|
| 175 | 186 | |
| 176 | 187 | // Is the attachments folder actually there? |
| 177 | - if (!empty($context['dir_creation_error'])) |
|
| 178 | - $this->_generalErrors[] = $context['dir_creation_error']; |
|
| 188 | + if (!empty($context['dir_creation_error'])) { |
|
| 189 | + $this->_generalErrors[] = $context['dir_creation_error']; |
|
| 190 | + } |
|
| 179 | 191 | |
| 180 | 192 | // The current attach folder ha some issues... |
| 181 | 193 | elseif (!is_dir($this->_attchDir)) |
@@ -200,13 +212,12 @@ discard block |
||
| 200 | 212 | ); |
| 201 | 213 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
| 202 | 214 | $smcFunc['db_free_result']($request); |
| 203 | - } |
|
| 204 | - |
|
| 205 | - else |
|
| 206 | - $context['attachments'] = array( |
|
| 215 | + } else { |
|
| 216 | + $context['attachments'] = array( |
|
| 207 | 217 | 'quantity' => 0, |
| 208 | 218 | 'total_size' => 0, |
| 209 | 219 | ); |
| 220 | + } |
|
| 210 | 221 | |
| 211 | 222 | // Check for other general errors here. |
| 212 | 223 | |
@@ -214,9 +225,10 @@ discard block |
||
| 214 | 225 | if (!empty($this->_generalErrors)) |
| 215 | 226 | { |
| 216 | 227 | // And delete the files 'cos they ain't going nowhere. |
| 217 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
| 218 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 228 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
| 229 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 219 | 230 | unlink($_FILES['attachment']['tmp_name'][$n]); |
| 231 | + } |
|
| 220 | 232 | |
| 221 | 233 | $_FILES['attachment']['tmp_name'] = array(); |
| 222 | 234 | |
@@ -227,26 +239,29 @@ discard block |
||
| 227 | 239 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
| 228 | 240 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
| 229 | 241 | { |
| 230 | - if ($_FILES['attachment']['name'][$n] == '') |
|
| 231 | - continue; |
|
| 242 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
| 243 | + continue; |
|
| 244 | + } |
|
| 232 | 245 | |
| 233 | 246 | // First, let's first check for PHP upload errors. |
| 234 | 247 | $errors = array(); |
| 235 | 248 | if (!empty($_FILES['attachment']['error'][$n])) |
| 236 | 249 | { |
| 237 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
| 238 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 239 | - |
|
| 240 | - else |
|
| 241 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
| 250 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
| 251 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 252 | + } else { |
|
| 253 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
| 254 | + } |
|
| 242 | 255 | |
| 243 | 256 | // Log this one, because... |
| 244 | - if ($_FILES['attachment']['error'][$n] == 6) |
|
| 245 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 257 | + if ($_FILES['attachment']['error'][$n] == 6) { |
|
| 258 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 259 | + } |
|
| 246 | 260 | |
| 247 | 261 | // Weird, no errors were cached, still fill out a generic one. |
| 248 | - if (empty($errors)) |
|
| 249 | - $errors[] = 'attach_php_error'; |
|
| 262 | + if (empty($errors)) { |
|
| 263 | + $errors[] = 'attach_php_error'; |
|
| 264 | + } |
|
| 250 | 265 | } |
| 251 | 266 | |
| 252 | 267 | // Try to move and rename the file before doing any more checks on it. |
@@ -266,16 +281,18 @@ discard block |
||
| 266 | 281 | ); |
| 267 | 282 | |
| 268 | 283 | // Move the file to the attachments folder with a temp name for now. |
| 269 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
| 270 | - smf_chmod($destName, 0644); |
|
| 284 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
| 285 | + smf_chmod($destName, 0644); |
|
| 286 | + } |
|
| 271 | 287 | |
| 272 | 288 | // This is madness!! |
| 273 | 289 | else |
| 274 | 290 | { |
| 275 | 291 | // File couldn't be moved. |
| 276 | 292 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
| 277 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 278 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 293 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
| 294 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 295 | + } |
|
| 279 | 296 | } |
| 280 | 297 | } |
| 281 | 298 | |
@@ -288,13 +305,15 @@ discard block |
||
| 288 | 305 | 'errors' => $errors, |
| 289 | 306 | ); |
| 290 | 307 | |
| 291 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 292 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 308 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
| 309 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 310 | + } |
|
| 293 | 311 | } |
| 294 | 312 | |
| 295 | 313 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
| 296 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
| 297 | - attachmentChecks($attachID); |
|
| 314 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
| 315 | + attachmentChecks($attachID); |
|
| 316 | + } |
|
| 298 | 317 | } |
| 299 | 318 | |
| 300 | 319 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
@@ -333,23 +352,24 @@ discard block |
||
| 333 | 352 | 'errors' => $attachment['errors'], |
| 334 | 353 | ); |
| 335 | 354 | |
| 336 | - if (empty($attachment['errors'])) |
|
| 337 | - if (createAttachment($attachmentOptions)) |
|
| 355 | + if (empty($attachment['errors'])) { |
|
| 356 | + if (createAttachment($attachmentOptions)) |
|
| 338 | 357 | { |
| 339 | 358 | // Avoid JS getting confused. |
| 340 | 359 | $attachmentOptions['attachID'] = $attachmentOptions['id']; |
| 360 | + } |
|
| 341 | 361 | unset($attachmentOptions['id']); |
| 342 | 362 | |
| 343 | 363 | $_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID']; |
| 344 | 364 | |
| 345 | - if (!empty($attachmentOptions['thumb'])) |
|
| 346 | - $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
| 347 | - |
|
| 348 | - if ($this->_msg) |
|
| 349 | - assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
| 350 | - } |
|
| 365 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 366 | + $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
| 367 | + } |
|
| 351 | 368 | |
| 352 | - elseif (!empty($attachmentOptions['errors'])) |
|
| 369 | + if ($this->_msg) { |
|
| 370 | + assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
| 371 | + } |
|
| 372 | + } elseif (!empty($attachmentOptions['errors'])) |
|
| 353 | 373 | { |
| 354 | 374 | // Sort out the errors for display and delete any associated files. |
| 355 | 375 | $log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file'); |
@@ -361,14 +381,16 @@ discard block |
||
| 361 | 381 | if (!is_array($error)) |
| 362 | 382 | { |
| 363 | 383 | $attachmentOptions['errors'][] = $txt[$error]; |
| 364 | - if (in_array($error, $log_these)) |
|
| 365 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 384 | + if (in_array($error, $log_these)) { |
|
| 385 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 386 | + } |
|
| 387 | + } else { |
|
| 388 | + $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
| 366 | 389 | } |
| 367 | - else |
|
| 368 | - $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
| 369 | 390 | } |
| 370 | - if (file_exists($attachment['tmp_name'])) |
|
| 371 | - unlink($attachment['tmp_name']); |
|
| 391 | + if (file_exists($attachment['tmp_name'])) { |
|
| 392 | + unlink($attachment['tmp_name']); |
|
| 393 | + } |
|
| 372 | 394 | } |
| 373 | 395 | |
| 374 | 396 | // Regardless of errors, pass the results. |
@@ -376,8 +398,9 @@ discard block |
||
| 376 | 398 | } |
| 377 | 399 | |
| 378 | 400 | // Temp save this on the db. |
| 379 | - if (!empty($_SESSION['already_attached'])) |
|
| 380 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 401 | + if (!empty($_SESSION['already_attached'])) { |
|
| 402 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 403 | + } |
|
| 381 | 404 | |
| 382 | 405 | unset($_SESSION['temp_attachments']); |
| 383 | 406 | } |
@@ -397,14 +420,16 @@ discard block |
||
| 397 | 420 | if ($this->_sa == 'add') |
| 398 | 421 | { |
| 399 | 422 | // Is there any generic errors? made some sense out of them! |
| 400 | - if ($this->_generalErrors) |
|
| 401 | - foreach ($this->_generalErrors as $k => $v) |
|
| 423 | + if ($this->_generalErrors) { |
|
| 424 | + foreach ($this->_generalErrors as $k => $v) |
|
| 402 | 425 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
| 426 | + } |
|
| 403 | 427 | |
| 404 | 428 | // Gotta urlencode the filename. |
| 405 | - if ($this->_attachResults) |
|
| 406 | - foreach ($this->_attachResults as $k => $v) |
|
| 429 | + if ($this->_attachResults) { |
|
| 430 | + foreach ($this->_attachResults as $k => $v) |
|
| 407 | 431 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
| 432 | + } |
|
| 408 | 433 | |
| 409 | 434 | $this->_response = array( |
| 410 | 435 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -413,9 +438,10 @@ discard block |
||
| 413 | 438 | } |
| 414 | 439 | |
| 415 | 440 | // Rest of us mere mortals gets no special treatment... |
| 416 | - elseif (!empty($data)) |
|
| 417 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 441 | + elseif (!empty($data)) { |
|
| 442 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 418 | 443 | $this->_response['text'] = $txt[$data['text']]; |
| 444 | + } |
|
| 419 | 445 | } |
| 420 | 446 | |
| 421 | 447 | protected function sendResponse() |
@@ -424,11 +450,11 @@ discard block |
||
| 424 | 450 | |
| 425 | 451 | ob_end_clean(); |
| 426 | 452 | |
| 427 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 428 | - @ob_start('ob_gzhandler'); |
|
| 429 | - |
|
| 430 | - else |
|
| 431 | - ob_start(); |
|
| 453 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 454 | + @ob_start('ob_gzhandler'); |
|
| 455 | + } else { |
|
| 456 | + ob_start(); |
|
| 457 | + } |
|
| 432 | 458 | |
| 433 | 459 | // Set the header. |
| 434 | 460 | header('Content-Type: application/json; charset='. $context['character_set'] .''); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Put this user in the online log. |
@@ -33,8 +34,9 @@ discard block |
||
| 33 | 34 | // Don't update for every page - this isn't wholly accurate but who cares. |
| 34 | 35 | if ($topic) |
| 35 | 36 | { |
| 36 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
| 37 | - $force = false; |
|
| 37 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
| 38 | + $force = false; |
|
| 39 | + } |
|
| 38 | 40 | $_SESSION['last_topic_id'] = $topic; |
| 39 | 41 | } |
| 40 | 42 | } |
@@ -47,22 +49,24 @@ discard block |
||
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | // Don't mark them as online more than every so often. |
| 50 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
| 51 | - return; |
|
| 52 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | if (!empty($modSettings['who_enabled'])) |
| 54 | 57 | { |
| 55 | 58 | $serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
| 56 | 59 | |
| 57 | 60 | // In the case of a dlattach action, session_var may not be set. |
| 58 | - if (!isset($context['session_var'])) |
|
| 59 | - $context['session_var'] = $_SESSION['session_var']; |
|
| 61 | + if (!isset($context['session_var'])) { |
|
| 62 | + $context['session_var'] = $_SESSION['session_var']; |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | unset($serialized['sesc'], $serialized[$context['session_var']]); |
| 62 | 66 | $serialized = json_encode($serialized); |
| 67 | + } else { |
|
| 68 | + $serialized = ''; |
|
| 63 | 69 | } |
| 64 | - else |
|
| 65 | - $serialized = ''; |
|
| 66 | 70 | |
| 67 | 71 | // Guests use 0, members use their session ID. |
| 68 | 72 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -102,17 +106,18 @@ discard block |
||
| 102 | 106 | ); |
| 103 | 107 | |
| 104 | 108 | // Guess it got deleted. |
| 105 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 109 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 110 | + $_SESSION['log_time'] = 0; |
|
| 111 | + } |
|
| 112 | + } else { |
|
| 106 | 113 | $_SESSION['log_time'] = 0; |
| 107 | 114 | } |
| 108 | - else |
|
| 109 | - $_SESSION['log_time'] = 0; |
|
| 110 | 115 | |
| 111 | 116 | // Otherwise, we have to delete and insert. |
| 112 | 117 | if (empty($_SESSION['log_time'])) |
| 113 | 118 | { |
| 114 | - if ($do_delete || !empty($user_info['id'])) |
|
| 115 | - $smcFunc['db_query']('', ' |
|
| 119 | + if ($do_delete || !empty($user_info['id'])) { |
|
| 120 | + $smcFunc['db_query']('', ' |
|
| 116 | 121 | DELETE FROM {db_prefix}log_online |
| 117 | 122 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
| 118 | 123 | array( |
@@ -120,6 +125,7 @@ discard block |
||
| 120 | 125 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
| 121 | 126 | ) |
| 122 | 127 | ); |
| 128 | + } |
|
| 123 | 129 | |
| 124 | 130 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
| 125 | 131 | '{db_prefix}log_online', |
@@ -133,21 +139,24 @@ discard block |
||
| 133 | 139 | $_SESSION['log_time'] = time(); |
| 134 | 140 | |
| 135 | 141 | // Well, they are online now. |
| 136 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
| 137 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 142 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
| 143 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 144 | + } |
|
| 138 | 145 | |
| 139 | 146 | // Set their login time, if not already done within the last minute. |
| 140 | 147 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
| 141 | 148 | { |
| 142 | 149 | // Don't count longer than 15 minutes. |
| 143 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
| 144 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 150 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
| 151 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 152 | + } |
|
| 145 | 153 | |
| 146 | 154 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 147 | 155 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
| 148 | 156 | |
| 149 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 150 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 157 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 158 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 159 | + } |
|
| 151 | 160 | |
| 152 | 161 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 153 | 162 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -184,8 +193,7 @@ discard block |
||
| 184 | 193 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
| 185 | 194 | // Copy the file back and run for your life! |
| 186 | 195 | @copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php'); |
| 187 | - } |
|
| 188 | - else |
|
| 196 | + } else |
|
| 189 | 197 | { |
| 190 | 198 | @touch($boarddir . '/' . 'Settings.php'); |
| 191 | 199 | return true; |
@@ -205,22 +213,27 @@ discard block |
||
| 205 | 213 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
| 206 | 214 | |
| 207 | 215 | // Add to Settings.php if you want to show the debugging information. |
| 208 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
| 209 | - return; |
|
| 216 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
| 217 | + return; |
|
| 218 | + } |
|
| 210 | 219 | |
| 211 | - if (empty($_SESSION['view_queries'])) |
|
| 212 | - $_SESSION['view_queries'] = 0; |
|
| 213 | - if (empty($context['debug']['language_files'])) |
|
| 214 | - $context['debug']['language_files'] = array(); |
|
| 215 | - if (empty($context['debug']['sheets'])) |
|
| 216 | - $context['debug']['sheets'] = array(); |
|
| 220 | + if (empty($_SESSION['view_queries'])) { |
|
| 221 | + $_SESSION['view_queries'] = 0; |
|
| 222 | + } |
|
| 223 | + if (empty($context['debug']['language_files'])) { |
|
| 224 | + $context['debug']['language_files'] = array(); |
|
| 225 | + } |
|
| 226 | + if (empty($context['debug']['sheets'])) { |
|
| 227 | + $context['debug']['sheets'] = array(); |
|
| 228 | + } |
|
| 217 | 229 | |
| 218 | 230 | $files = get_included_files(); |
| 219 | 231 | $total_size = 0; |
| 220 | 232 | for ($i = 0, $n = count($files); $i < $n; $i++) |
| 221 | 233 | { |
| 222 | - if (file_exists($files[$i])) |
|
| 223 | - $total_size += filesize($files[$i]); |
|
| 234 | + if (file_exists($files[$i])) { |
|
| 235 | + $total_size += filesize($files[$i]); |
|
| 236 | + } |
|
| 224 | 237 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
| 225 | 238 | } |
| 226 | 239 | |
@@ -229,8 +242,9 @@ discard block |
||
| 229 | 242 | { |
| 230 | 243 | foreach ($db_cache as $q => $qq) |
| 231 | 244 | { |
| 232 | - if (!empty($qq['w'])) |
|
| 233 | - $warnings += count($qq['w']); |
|
| 245 | + if (!empty($qq['w'])) { |
|
| 246 | + $warnings += count($qq['w']); |
|
| 247 | + } |
|
| 234 | 248 | } |
| 235 | 249 | |
| 236 | 250 | $_SESSION['debug'] = &$db_cache; |
@@ -251,12 +265,14 @@ discard block |
||
| 251 | 265 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
| 252 | 266 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 253 | 267 | |
| 254 | - if (function_exists('memory_get_peak_usage')) |
|
| 255 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 268 | + if (function_exists('memory_get_peak_usage')) { |
|
| 269 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 270 | + } |
|
| 256 | 271 | |
| 257 | 272 | // What tokens are active? |
| 258 | - if (isset($_SESSION['token'])) |
|
| 259 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 273 | + if (isset($_SESSION['token'])) { |
|
| 274 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 275 | + } |
|
| 260 | 276 | |
| 261 | 277 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
| 262 | 278 | { |
@@ -269,10 +285,12 @@ discard block |
||
| 269 | 285 | $total_t += $cache_hit['t']; |
| 270 | 286 | $total_s += $cache_hit['s']; |
| 271 | 287 | } |
| 272 | - if (!isset($cache_misses)) |
|
| 273 | - $cache_misses = array(); |
|
| 274 | - foreach ($cache_misses as $missed) |
|
| 275 | - $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
| 288 | + if (!isset($cache_misses)) { |
|
| 289 | + $cache_misses = array(); |
|
| 290 | + } |
|
| 291 | + foreach ($cache_misses as $missed) { |
|
| 292 | + $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
| 293 | + } |
|
| 276 | 294 | |
| 277 | 295 | echo ' |
| 278 | 296 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -283,38 +301,44 @@ discard block |
||
| 283 | 301 | <a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
| 284 | 302 | <br>'; |
| 285 | 303 | |
| 286 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
| 287 | - foreach ($db_cache as $q => $qq) |
|
| 304 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
| 305 | + foreach ($db_cache as $q => $qq) |
|
| 288 | 306 | { |
| 289 | 307 | $is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0; |
| 308 | + } |
|
| 290 | 309 | // Temporary tables created in earlier queries are not explainable. |
| 291 | 310 | if ($is_select) |
| 292 | 311 | { |
| 293 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
| 294 | - if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 312 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
| 313 | + if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 295 | 314 | { |
| 296 | 315 | $is_select = false; |
| 316 | + } |
|
| 297 | 317 | break; |
| 298 | 318 | } |
| 299 | 319 | } |
| 300 | 320 | // But actual creation of the temporary tables are. |
| 301 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) |
|
| 302 | - $is_select = true; |
|
| 321 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) { |
|
| 322 | + $is_select = true; |
|
| 323 | + } |
|
| 303 | 324 | |
| 304 | 325 | // Make the filenames look a bit better. |
| 305 | - if (isset($qq['f'])) |
|
| 306 | - $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 326 | + if (isset($qq['f'])) { |
|
| 327 | + $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 328 | + } |
|
| 307 | 329 | |
| 308 | 330 | echo ' |
| 309 | 331 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
| 310 | 332 | '; |
| 311 | - if (!empty($qq['f']) && !empty($qq['l'])) |
|
| 312 | - echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 333 | + if (!empty($qq['f']) && !empty($qq['l'])) { |
|
| 334 | + echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 335 | + } |
|
| 313 | 336 | |
| 314 | - if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) |
|
| 315 | - echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 316 | - elseif (isset($qq['t'])) |
|
| 317 | - echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 337 | + if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) { |
|
| 338 | + echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 339 | + } elseif (isset($qq['t'])) { |
|
| 340 | + echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 341 | + } |
|
| 318 | 342 | echo ' |
| 319 | 343 | <br>'; |
| 320 | 344 | } |
@@ -339,12 +363,14 @@ discard block |
||
| 339 | 363 | global $modSettings, $smcFunc; |
| 340 | 364 | static $cache_stats = array(); |
| 341 | 365 | |
| 342 | - if (empty($modSettings['trackStats'])) |
|
| 343 | - return false; |
|
| 344 | - if (!empty($stats)) |
|
| 345 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
| 346 | - elseif (empty($cache_stats)) |
|
| 347 | - return false; |
|
| 366 | + if (empty($modSettings['trackStats'])) { |
|
| 367 | + return false; |
|
| 368 | + } |
|
| 369 | + if (!empty($stats)) { |
|
| 370 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
| 371 | + } elseif (empty($cache_stats)) { |
|
| 372 | + return false; |
|
| 373 | + } |
|
| 348 | 374 | |
| 349 | 375 | $setStringUpdate = ''; |
| 350 | 376 | $insert_keys = array(); |
@@ -357,10 +383,11 @@ discard block |
||
| 357 | 383 | $setStringUpdate .= ' |
| 358 | 384 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
| 359 | 385 | |
| 360 | - if ($change === '+') |
|
| 361 | - $cache_stats[$field] = 1; |
|
| 362 | - else |
|
| 363 | - $update_parameters[$field] = $change; |
|
| 386 | + if ($change === '+') { |
|
| 387 | + $cache_stats[$field] = 1; |
|
| 388 | + } else { |
|
| 389 | + $update_parameters[$field] = $change; |
|
| 390 | + } |
|
| 364 | 391 | $insert_keys[$field] = 'int'; |
| 365 | 392 | } |
| 366 | 393 | |
@@ -424,43 +451,50 @@ discard block |
||
| 424 | 451 | ); |
| 425 | 452 | |
| 426 | 453 | // Make sure this particular log is enabled first... |
| 427 | - if (empty($modSettings['modlog_enabled'])) |
|
| 428 | - unset ($log_types['moderate']); |
|
| 429 | - if (empty($modSettings['userlog_enabled'])) |
|
| 430 | - unset ($log_types['user']); |
|
| 431 | - if (empty($modSettings['adminlog_enabled'])) |
|
| 432 | - unset ($log_types['admin']); |
|
| 454 | + if (empty($modSettings['modlog_enabled'])) { |
|
| 455 | + unset ($log_types['moderate']); |
|
| 456 | + } |
|
| 457 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 458 | + unset ($log_types['user']); |
|
| 459 | + } |
|
| 460 | + if (empty($modSettings['adminlog_enabled'])) { |
|
| 461 | + unset ($log_types['admin']); |
|
| 462 | + } |
|
| 433 | 463 | |
| 434 | 464 | call_integration_hook('integrate_log_types', array(&$log_types)); |
| 435 | 465 | |
| 436 | 466 | foreach ($logs as $log) |
| 437 | 467 | { |
| 438 | - if (!isset($log_types[$log['log_type']])) |
|
| 439 | - return false; |
|
| 468 | + if (!isset($log_types[$log['log_type']])) { |
|
| 469 | + return false; |
|
| 470 | + } |
|
| 440 | 471 | |
| 441 | - if (!is_array($log['extra'])) |
|
| 442 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 472 | + if (!is_array($log['extra'])) { |
|
| 473 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 474 | + } |
|
| 443 | 475 | |
| 444 | 476 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
| 445 | 477 | if (isset($log['extra']['topic'])) |
| 446 | 478 | { |
| 447 | - if (!is_numeric($log['extra']['topic'])) |
|
| 448 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 479 | + if (!is_numeric($log['extra']['topic'])) { |
|
| 480 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 481 | + } |
|
| 449 | 482 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
| 450 | 483 | unset($log['extra']['topic']); |
| 484 | + } else { |
|
| 485 | + $topic_id = 0; |
|
| 451 | 486 | } |
| 452 | - else |
|
| 453 | - $topic_id = 0; |
|
| 454 | 487 | |
| 455 | 488 | if (isset($log['extra']['message'])) |
| 456 | 489 | { |
| 457 | - if (!is_numeric($log['extra']['message'])) |
|
| 458 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 490 | + if (!is_numeric($log['extra']['message'])) { |
|
| 491 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 492 | + } |
|
| 459 | 493 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
| 460 | 494 | unset($log['extra']['message']); |
| 495 | + } else { |
|
| 496 | + $msg_id = 0; |
|
| 461 | 497 | } |
| 462 | - else |
|
| 463 | - $msg_id = 0; |
|
| 464 | 498 | |
| 465 | 499 | // @todo cache this? |
| 466 | 500 | // Is there an associated report on this? |
@@ -487,23 +521,26 @@ discard block |
||
| 487 | 521 | $smcFunc['db_free_result']($request); |
| 488 | 522 | } |
| 489 | 523 | |
| 490 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
| 491 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 524 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
| 525 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 526 | + } |
|
| 492 | 527 | |
| 493 | 528 | if (isset($log['extra']['board'])) |
| 494 | 529 | { |
| 495 | - if (!is_numeric($log['extra']['board'])) |
|
| 496 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 530 | + if (!is_numeric($log['extra']['board'])) { |
|
| 531 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 532 | + } |
|
| 497 | 533 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
| 498 | 534 | unset($log['extra']['board']); |
| 535 | + } else { |
|
| 536 | + $board_id = 0; |
|
| 499 | 537 | } |
| 500 | - else |
|
| 501 | - $board_id = 0; |
|
| 502 | 538 | |
| 503 | 539 | if (isset($log['extra']['board_to'])) |
| 504 | 540 | { |
| 505 | - if (!is_numeric($log['extra']['board_to'])) |
|
| 506 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 541 | + if (!is_numeric($log['extra']['board_to'])) { |
|
| 542 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 543 | + } |
|
| 507 | 544 | if (empty($board_id)) |
| 508 | 545 | { |
| 509 | 546 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -511,10 +548,11 @@ discard block |
||
| 511 | 548 | } |
| 512 | 549 | } |
| 513 | 550 | |
| 514 | - if (isset($log['extra']['member_affected'])) |
|
| 515 | - $memID = $log['extra']['member_affected']; |
|
| 516 | - else |
|
| 517 | - $memID = $user_info['id']; |
|
| 551 | + if (isset($log['extra']['member_affected'])) { |
|
| 552 | + $memID = $log['extra']['member_affected']; |
|
| 553 | + } else { |
|
| 554 | + $memID = $user_info['id']; |
|
| 555 | + } |
|
| 518 | 556 | |
| 519 | 557 | $inserts[] = array( |
| 520 | 558 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
| 54 | 55 | return; |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | - if (empty($modSettings['search_custom_index_config'])) |
|
| 58 | - return; |
|
| 58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
| 59 | + return; |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | $this->indexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
| 61 | 63 | |
@@ -118,21 +120,23 @@ discard block |
||
| 118 | 120 | |
| 119 | 121 | $subwords = text2words($word, $this->min_word_length, true); |
| 120 | 122 | |
| 121 | - if (empty($modSettings['search_force_index'])) |
|
| 122 | - $wordsSearch['words'][] = $word; |
|
| 123 | + if (empty($modSettings['search_force_index'])) { |
|
| 124 | + $wordsSearch['words'][] = $word; |
|
| 125 | + } |
|
| 123 | 126 | |
| 124 | 127 | // Excluded phrases don't benefit from being split into subwords. |
| 125 | - if (count($subwords) > 1 && $isExcluded) |
|
| 126 | - return; |
|
| 127 | - else |
|
| 128 | + if (count($subwords) > 1 && $isExcluded) { |
|
| 129 | + return; |
|
| 130 | + } else |
|
| 128 | 131 | { |
| 129 | 132 | foreach ($subwords as $subword) |
| 130 | 133 | { |
| 131 | 134 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
| 132 | 135 | { |
| 133 | 136 | $wordsSearch['indexed_words'][] = $subword; |
| 134 | - if ($isExcluded) |
|
| 135 | - $wordsExclude[] = $subword; |
|
| 137 | + if ($isExcluded) { |
|
| 138 | + $wordsExclude[] = $subword; |
|
| 139 | + } |
|
| 136 | 140 | } |
| 137 | 141 | } |
| 138 | 142 | } |
@@ -153,8 +157,9 @@ discard block |
||
| 153 | 157 | $query_where = array(); |
| 154 | 158 | $query_params = $search_data['params']; |
| 155 | 159 | |
| 156 | - if ($query_params['id_search']) |
|
| 157 | - $query_select['id_search'] = '{int:id_search}'; |
|
| 160 | + if ($query_params['id_search']) { |
|
| 161 | + $query_select['id_search'] = '{int:id_search}'; |
|
| 162 | + } |
|
| 158 | 163 | |
| 159 | 164 | $count = 0; |
| 160 | 165 | foreach ($words['words'] as $regularWord) |
@@ -163,30 +168,37 @@ discard block |
||
| 163 | 168 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 164 | 169 | } |
| 165 | 170 | |
| 166 | - if ($query_params['user_query']) |
|
| 167 | - $query_where[] = '{raw:user_query}'; |
|
| 168 | - if ($query_params['board_query']) |
|
| 169 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 171 | + if ($query_params['user_query']) { |
|
| 172 | + $query_where[] = '{raw:user_query}'; |
|
| 173 | + } |
|
| 174 | + if ($query_params['board_query']) { |
|
| 175 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 176 | + } |
|
| 170 | 177 | |
| 171 | - if ($query_params['topic']) |
|
| 172 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 173 | - if ($query_params['min_msg_id']) |
|
| 174 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 175 | - if ($query_params['max_msg_id']) |
|
| 176 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 178 | + if ($query_params['topic']) { |
|
| 179 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 180 | + } |
|
| 181 | + if ($query_params['min_msg_id']) { |
|
| 182 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 183 | + } |
|
| 184 | + if ($query_params['max_msg_id']) { |
|
| 185 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 186 | + } |
|
| 177 | 187 | |
| 178 | 188 | $count = 0; |
| 179 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
| 180 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 189 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
| 190 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 181 | 191 | { |
| 182 | 192 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
| 193 | + } |
|
| 183 | 194 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
| 184 | 195 | } |
| 185 | 196 | $count = 0; |
| 186 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
| 187 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 197 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
| 198 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 188 | 199 | { |
| 189 | 200 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
| 201 | + } |
|
| 190 | 202 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
| 191 | 203 | } |
| 192 | 204 | |
@@ -199,8 +211,7 @@ discard block |
||
| 199 | 211 | { |
| 200 | 212 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
| 201 | 213 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
| 202 | - } |
|
| 203 | - else |
|
| 214 | + } else |
|
| 204 | 215 | { |
| 205 | 216 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
| 206 | 217 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -236,16 +247,18 @@ discard block |
||
| 236 | 247 | $customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
| 237 | 248 | |
| 238 | 249 | $inserts = array(); |
| 239 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
| 240 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 250 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
| 251 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 252 | + } |
|
| 241 | 253 | |
| 242 | - if (!empty($inserts)) |
|
| 243 | - $smcFunc['db_insert']('ignore', |
|
| 254 | + if (!empty($inserts)) { |
|
| 255 | + $smcFunc['db_insert']('ignore', |
|
| 244 | 256 | '{db_prefix}log_search_words', |
| 245 | 257 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 246 | 258 | $inserts, |
| 247 | 259 | array('id_word', 'id_msg') |
| 248 | 260 | ); |
| 261 | + } |
|
| 249 | 262 | } |
| 250 | 263 | |
| 251 | 264 | /** |
@@ -288,8 +301,9 @@ discard block |
||
| 288 | 301 | if (!empty($inserted_words)) |
| 289 | 302 | { |
| 290 | 303 | $inserts = array(); |
| 291 | - foreach ($inserted_words as $word) |
|
| 292 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 304 | + foreach ($inserted_words as $word) { |
|
| 305 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 306 | + } |
|
| 293 | 307 | $smcFunc['db_insert']('insert', |
| 294 | 308 | '{db_prefix}log_search_words', |
| 295 | 309 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Sets and call a function based on the given subaction. Acts as a dispatcher function. |
@@ -54,8 +55,9 @@ discard block |
||
| 54 | 55 | ); |
| 55 | 56 | |
| 56 | 57 | // This comes under the umbrella of moderating posts. |
| 57 | - if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') |
|
| 58 | - isAllowedTo('moderate_forum'); |
|
| 58 | + if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') { |
|
| 59 | + isAllowedTo('moderate_forum'); |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | $subActions = array( |
| 61 | 63 | 'show' => 'ShowReports', |
@@ -70,11 +72,11 @@ discard block |
||
| 70 | 72 | call_integration_hook('integrate_reported_' . $context['report_type'], array(&$subActions)); |
| 71 | 73 | |
| 72 | 74 | // By default we call the open sub-action. |
| 73 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 74 | - $context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES); |
|
| 75 | - |
|
| 76 | - else |
|
| 77 | - $context['sub_action'] = 'show'; |
|
| 75 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 76 | + $context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES); |
|
| 77 | + } else { |
|
| 78 | + $context['sub_action'] = 'show'; |
|
| 79 | + } |
|
| 78 | 80 | |
| 79 | 81 | // Hi Ho Silver Away! |
| 80 | 82 | call_helper($subActions[$context['sub_action']]); |
@@ -116,11 +118,13 @@ discard block |
||
| 116 | 118 | |
| 117 | 119 | // All the ones to update... |
| 118 | 120 | $toClose = array(); |
| 119 | - foreach ($_POST['close'] as $rid) |
|
| 120 | - $toClose[] = (int) $rid; |
|
| 121 | + foreach ($_POST['close'] as $rid) { |
|
| 122 | + $toClose[] = (int) $rid; |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | - if (!empty($toClose)) |
|
| 123 | - updateReport('closed', 1, $toClose); |
|
| 125 | + if (!empty($toClose)) { |
|
| 126 | + updateReport('closed', 1, $toClose); |
|
| 127 | + } |
|
| 124 | 128 | |
| 125 | 129 | // Set the confirmation message. |
| 126 | 130 | $_SESSION['rc_confirmation'] = 'close_all'; |
@@ -178,8 +182,9 @@ discard block |
||
| 178 | 182 | $reportComments = array(); |
| 179 | 183 | |
| 180 | 184 | // Have to at least give us something to work with. |
| 181 | - if (empty($_REQUEST['rid'])) |
|
| 182 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 185 | + if (empty($_REQUEST['rid'])) { |
|
| 186 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 187 | + } |
|
| 183 | 188 | |
| 184 | 189 | // Integers only please |
| 185 | 190 | $report_id = (int) $_REQUEST['rid']; |
@@ -187,8 +192,9 @@ discard block |
||
| 187 | 192 | // Get the report details. |
| 188 | 193 | $report = getReportDetails($report_id); |
| 189 | 194 | |
| 190 | - if(!$report) |
|
| 191 | - fatal_lang_error('mc_no_modreport_found'); |
|
| 195 | + if(!$report) { |
|
| 196 | + fatal_lang_error('mc_no_modreport_found'); |
|
| 197 | + } |
|
| 192 | 198 | |
| 193 | 199 | // Build the report data - basic details first, then extra stuff based on the type |
| 194 | 200 | $context['report'] = array( |
@@ -214,8 +220,7 @@ discard block |
||
| 214 | 220 | 'href' => $scripturl . '?action=profile;u=' . $report['id_user'], |
| 215 | 221 | ), |
| 216 | 222 | ); |
| 217 | - } |
|
| 218 | - else |
|
| 223 | + } else |
|
| 219 | 224 | { |
| 220 | 225 | $extraDetails = array( |
| 221 | 226 | 'topic_id' => $report['id_topic'], |
@@ -238,8 +243,9 @@ discard block |
||
| 238 | 243 | |
| 239 | 244 | $reportComments = getReportComments($report_id); |
| 240 | 245 | |
| 241 | - if (!empty($reportComments)) |
|
| 242 | - $context['report'] = array_merge($context['report'], $reportComments); |
|
| 246 | + if (!empty($reportComments)) { |
|
| 247 | + $context['report'] = array_merge($context['report'], $reportComments); |
|
| 248 | + } |
|
| 243 | 249 | |
| 244 | 250 | // What have the other moderators done to this message? |
| 245 | 251 | require_once($sourcedir . '/Modlog.php'); |
@@ -260,8 +266,7 @@ discard block |
||
| 260 | 266 | 1, |
| 261 | 267 | true, |
| 262 | 268 | ); |
| 263 | - } |
|
| 264 | - else |
|
| 269 | + } else |
|
| 265 | 270 | { |
| 266 | 271 | $params = array( |
| 267 | 272 | 'lm.id_topic = {int:id_topic} |
@@ -361,16 +366,16 @@ discard block |
||
| 361 | 366 | createList($listOptions); |
| 362 | 367 | |
| 363 | 368 | // Make sure to get the correct tab selected. |
| 364 | - if ($context['report']['closed']) |
|
| 365 | - $context[$context['moderation_menu_name']]['current_subsection'] = 'closed'; |
|
| 369 | + if ($context['report']['closed']) { |
|
| 370 | + $context[$context['moderation_menu_name']]['current_subsection'] = 'closed'; |
|
| 371 | + } |
|
| 366 | 372 | |
| 367 | 373 | // Finally we are done :P |
| 368 | 374 | if ($context['report_type'] == 'members') |
| 369 | 375 | { |
| 370 | 376 | $context['page_title'] = sprintf($txt['mc_viewmemberreport'], $context['report']['user']['name']); |
| 371 | 377 | $context['sub_template'] = 'viewmemberreport'; |
| 372 | - } |
|
| 373 | - else |
|
| 378 | + } else |
|
| 374 | 379 | { |
| 375 | 380 | $context['page_title'] = sprintf($txt['mc_viewmodreport'], $context['report']['subject'], $context['report']['author']['name']); |
| 376 | 381 | $context['sub_template'] = 'viewmodreport'; |
@@ -395,8 +400,9 @@ discard block |
||
| 395 | 400 | $comment = array(); |
| 396 | 401 | |
| 397 | 402 | // The report ID is a must. |
| 398 | - if (empty($_REQUEST['rid'])) |
|
| 399 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 403 | + if (empty($_REQUEST['rid'])) { |
|
| 404 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 405 | + } |
|
| 400 | 406 | |
| 401 | 407 | // Integers only please. |
| 402 | 408 | $report_id = (int) $_REQUEST['rid']; |
@@ -421,8 +427,9 @@ discard block |
||
| 421 | 427 | checkSession('get'); |
| 422 | 428 | validateToken('mod-reportC-delete', 'get'); |
| 423 | 429 | |
| 424 | - if (empty($_REQUEST['mid'])) |
|
| 425 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 430 | + if (empty($_REQUEST['mid'])) { |
|
| 431 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 432 | + } |
|
| 426 | 433 | |
| 427 | 434 | $comment_id = (int) $_REQUEST['mid']; |
| 428 | 435 | |
@@ -430,15 +437,17 @@ discard block |
||
| 430 | 437 | $comment = getCommentModDetails($comment_id); |
| 431 | 438 | |
| 432 | 439 | // Perhaps somebody else already deleted this fine gem... |
| 433 | - if (empty($comment)) |
|
| 434 | - fatal_lang_error('report_action_message_delete_issue'); |
|
| 440 | + if (empty($comment)) { |
|
| 441 | + fatal_lang_error('report_action_message_delete_issue'); |
|
| 442 | + } |
|
| 435 | 443 | |
| 436 | 444 | // Can you actually do this? |
| 437 | 445 | $comment_owner = $user_info['id'] == $comment['id_member']; |
| 438 | 446 | |
| 439 | 447 | // Nope! sorry. |
| 440 | - if (!allowedTo('admin_forum') && !$comment_owner) |
|
| 441 | - fatal_lang_error('report_action_message_delete_cannot'); |
|
| 448 | + if (!allowedTo('admin_forum') && !$comment_owner) { |
|
| 449 | + fatal_lang_error('report_action_message_delete_cannot'); |
|
| 450 | + } |
|
| 442 | 451 | |
| 443 | 452 | // All good! |
| 444 | 453 | deleteModComment($comment_id); |
@@ -465,11 +474,13 @@ discard block |
||
| 465 | 474 | checkSession(isset($_REQUEST['save']) ? 'post' : 'get'); |
| 466 | 475 | |
| 467 | 476 | // The report ID is a must. |
| 468 | - if (empty($_REQUEST['rid'])) |
|
| 469 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 477 | + if (empty($_REQUEST['rid'])) { |
|
| 478 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 479 | + } |
|
| 470 | 480 | |
| 471 | - if (empty($_REQUEST['mid'])) |
|
| 472 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 481 | + if (empty($_REQUEST['mid'])) { |
|
| 482 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 483 | + } |
|
| 473 | 484 | |
| 474 | 485 | // Integers only please. |
| 475 | 486 | $context['report_id'] = (int) $_REQUEST['rid']; |
@@ -477,8 +488,9 @@ discard block |
||
| 477 | 488 | |
| 478 | 489 | $context['comment'] = getCommentModDetails($context['comment_id']); |
| 479 | 490 | |
| 480 | - if (empty($context['comment'])) |
|
| 481 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 491 | + if (empty($context['comment'])) { |
|
| 492 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 493 | + } |
|
| 482 | 494 | |
| 483 | 495 | // Set up the comforting bits... |
| 484 | 496 | $context['page_title'] = $txt['mc_reported_posts']; |
@@ -489,15 +501,17 @@ discard block |
||
| 489 | 501 | validateToken('mod-reportC-edit'); |
| 490 | 502 | |
| 491 | 503 | // Make sure there is some data to edit on the DB. |
| 492 | - if (empty($context['comment'])) |
|
| 493 | - fatal_lang_error('report_action_message_edit_issue'); |
|
| 504 | + if (empty($context['comment'])) { |
|
| 505 | + fatal_lang_error('report_action_message_edit_issue'); |
|
| 506 | + } |
|
| 494 | 507 | |
| 495 | 508 | // Still there, good, now lets see if you can actually edit it... |
| 496 | 509 | $comment_owner = $user_info['id'] == $context['comment']['id_member']; |
| 497 | 510 | |
| 498 | 511 | // So, you aren't neither an admin or the comment owner huh? that's too bad. |
| 499 | - if (!allowedTo('admin_forum') && !$comment_owner) |
|
| 500 | - fatal_lang_error('report_action_message_edit_cannot'); |
|
| 512 | + if (!allowedTo('admin_forum') && !$comment_owner) { |
|
| 513 | + fatal_lang_error('report_action_message_edit_cannot'); |
|
| 514 | + } |
|
| 501 | 515 | |
| 502 | 516 | // All good! |
| 503 | 517 | $edited_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment'])); |
@@ -523,8 +537,9 @@ discard block |
||
| 523 | 537 | checkSession('get'); |
| 524 | 538 | |
| 525 | 539 | // We need to do something! |
| 526 | - if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) |
|
| 527 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 540 | + if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) { |
|
| 541 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 542 | + } |
|
| 528 | 543 | |
| 529 | 544 | // What are we gonna do? |
| 530 | 545 | $action = isset($_GET['ignore']) ? 'ignore' : 'closed'; |