@@ -25,7 +25,7 @@ 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 | error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL); |
31 | 31 | $time_start = microtime(); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
91 | 91 | { |
92 | 92 | // If zlib is being used, turn off output compression. |
93 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
93 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
94 | 94 | $modSettings['enableCompressedOutput'] = '0'; |
95 | 95 | else |
96 | 96 | { |
@@ -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? |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | col_name, field_name, field_desc, field_type, field_order, show_reg, field_length, field_options, |
883 | 883 | default_value, bbc, enclose, placement |
884 | 884 | FROM {db_prefix}custom_fields |
885 | - WHERE ' . $where .' |
|
885 | + WHERE ' . $where . ' |
|
886 | 886 | ORDER BY field_order', |
887 | 887 | array( |
888 | 888 | 'area' => $area, |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | else |
951 | 951 | { |
952 | 952 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
953 | - $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>'; |
|
953 | + $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 | 954 | } |
955 | 955 | |
956 | 956 | // Parse BBCode |
@@ -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'], |
@@ -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( |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | // Just send a generic message. |
77 | 77 | else |
78 | 78 | $this->setResponse(array( |
79 | - 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
79 | + 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
80 | 80 | 'type' => 'error', |
81 | 81 | 'data' => false, |
82 | 82 | )); |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | // Gotta urlencode the filename. |
405 | 405 | if ($this->_attachResults) |
406 | 406 | foreach ($this->_attachResults as $k => $v) |
407 | - $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
407 | + $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
408 | 408 | |
409 | 409 | $this->_response = array( |
410 | 410 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | ob_start(); |
432 | 432 | |
433 | 433 | // Set the header. |
434 | - header('Content-Type: application/json; charset='. $context['character_set'] .''); |
|
434 | + header('Content-Type: application/json; charset=' . $context['character_set'] . ''); |
|
435 | 435 | |
436 | 436 | echo json_encode($this->_response ? $this->_response : array()); |
437 | 437 |
@@ -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'] .''); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | if (filemtime($boarddir . '/db_last_error.php') === $last_db_error_change) |
176 | 176 | { |
177 | 177 | // Write the change |
178 | - $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
178 | + $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
179 | 179 | $written_bytes = file_put_contents($boarddir . '/db_last_error.php', $write_db_change, LOCK_EX); |
180 | 180 | |
181 | 181 | // survey says ... |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | ', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br> |
249 | 249 | ', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br> |
250 | 250 | ', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br> |
251 | - ',(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>') : ''),' |
|
251 | + ',(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 | 252 | ', $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 | 253 | |
254 | 254 | if (function_exists('memory_get_peak_usage')) |
@@ -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'], |
@@ -208,7 +208,7 @@ |
||
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
211 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
212 | 212 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
213 | 213 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
214 | 214 | SELECT ' . implode(', ', $query_select) . ' |
@@ -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'), |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | // Get the report details. |
188 | 188 | $report = getReportDetails($report_id); |
189 | 189 | |
190 | - if(!$report) |
|
190 | + if (!$report) |
|
191 | 191 | fatal_lang_error('mc_no_modreport_found'); |
192 | 192 | |
193 | 193 | // Build the report data - basic details first, then extra stuff based on the type |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | if ($context['report_type'] == 'members') |
251 | 251 | { |
252 | 252 | // Find their ID in the serialized action string... |
253 | - $user_id_length = strlen((string)$context['report']['user']['id']); |
|
253 | + $user_id_length = strlen((string) $context['report']['user']['id']); |
|
254 | 254 | $member = 's:6:"member";s:' . $user_id_length . ':"' . $context['report']['user']['id'] . '";}'; |
255 | 255 | |
256 | 256 | $params = array( |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | // What are we gonna do? |
530 | 530 | $action = isset($_GET['ignore']) ? 'ignore' : 'closed'; |
531 | 531 | |
532 | - validateToken('mod-report-'. $action, 'get'); |
|
532 | + validateToken('mod-report-' . $action, 'get'); |
|
533 | 533 | |
534 | 534 | // Are we ignore or "un-ignore"? "un-ignore" that's a funny word! |
535 | 535 | $value = (int) $_GET[$action]; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * 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'; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Redirect to the user help ;). |
@@ -95,12 +96,13 @@ discard block |
||
95 | 96 | ); |
96 | 97 | |
97 | 98 | // Have we got a localized one? |
98 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
99 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
100 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
101 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
102 | - else |
|
103 | - $context['agreement'] = ''; |
|
99 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
100 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
101 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
102 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
103 | + } else { |
|
104 | + $context['agreement'] = ''; |
|
105 | + } |
|
104 | 106 | |
105 | 107 | // Nothing to show, so let's get out of here |
106 | 108 | if (empty($context['agreement'])) |
@@ -128,18 +130,21 @@ discard block |
||
128 | 130 | { |
129 | 131 | global $txt, $helptxt, $context, $scripturl; |
130 | 132 | |
131 | - if (!isset($_GET['help']) || !is_string($_GET['help'])) |
|
132 | - fatal_lang_error('no_access', false); |
|
133 | + if (!isset($_GET['help']) || !is_string($_GET['help'])) { |
|
134 | + fatal_lang_error('no_access', false); |
|
135 | + } |
|
133 | 136 | |
134 | - if (!isset($helptxt)) |
|
135 | - $helptxt = array(); |
|
137 | + if (!isset($helptxt)) { |
|
138 | + $helptxt = array(); |
|
139 | + } |
|
136 | 140 | |
137 | 141 | // Load the admin help language file and template. |
138 | 142 | loadLanguage('Help'); |
139 | 143 | |
140 | 144 | // Permission specific help? |
141 | - if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') |
|
142 | - loadLanguage('ManagePermissions'); |
|
145 | + if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') { |
|
146 | + loadLanguage('ManagePermissions'); |
|
147 | + } |
|
143 | 148 | |
144 | 149 | loadTemplate('Help'); |
145 | 150 | |
@@ -154,16 +159,18 @@ discard block |
||
154 | 159 | $context['sub_template'] = 'popup'; |
155 | 160 | |
156 | 161 | // What help string should be used? |
157 | - if (isset($helptxt[$_GET['help']])) |
|
158 | - $context['help_text'] = $helptxt[$_GET['help']]; |
|
159 | - elseif (isset($txt[$_GET['help']])) |
|
160 | - $context['help_text'] = $txt[$_GET['help']]; |
|
161 | - else |
|
162 | - $context['help_text'] = $_GET['help']; |
|
162 | + if (isset($helptxt[$_GET['help']])) { |
|
163 | + $context['help_text'] = $helptxt[$_GET['help']]; |
|
164 | + } elseif (isset($txt[$_GET['help']])) { |
|
165 | + $context['help_text'] = $txt[$_GET['help']]; |
|
166 | + } else { |
|
167 | + $context['help_text'] = $_GET['help']; |
|
168 | + } |
|
163 | 169 | |
164 | 170 | // Does this text contain a link that we should fill in? |
165 | - if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) |
|
166 | - $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
167 | -} |
|
171 | + if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) { |
|
172 | + $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
173 | + } |
|
174 | + } |
|
168 | 175 | |
169 | 176 | ?> |
170 | 177 | \ No newline at end of file |