@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main admin handling function.<br> |
@@ -444,8 +445,9 @@ discard block |
||
444 | 445 | foreach ($admin_includes as $include) |
445 | 446 | { |
446 | 447 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
447 | - if (file_exists($include)) |
|
448 | - require_once($include); |
|
448 | + if (file_exists($include)) { |
|
449 | + require_once($include); |
|
450 | + } |
|
449 | 451 | } |
450 | 452 | } |
451 | 453 | |
@@ -457,24 +459,27 @@ discard block |
||
457 | 459 | unset($admin_areas); |
458 | 460 | |
459 | 461 | // Nothing valid? |
460 | - if ($admin_include_data == false) |
|
461 | - fatal_lang_error('no_access', false); |
|
462 | + if ($admin_include_data == false) { |
|
463 | + fatal_lang_error('no_access', false); |
|
464 | + } |
|
462 | 465 | |
463 | 466 | // Build the link tree. |
464 | 467 | $context['linktree'][] = array( |
465 | 468 | 'url' => $scripturl . '?action=admin', |
466 | 469 | 'name' => $txt['admin_center'], |
467 | 470 | ); |
468 | - if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') |
|
469 | - $context['linktree'][] = array( |
|
471 | + if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') { |
|
472 | + $context['linktree'][] = array( |
|
470 | 473 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
471 | 474 | 'name' => $admin_include_data['label'], |
472 | 475 | ); |
473 | - if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) |
|
474 | - $context['linktree'][] = array( |
|
476 | + } |
|
477 | + if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) { |
|
478 | + $context['linktree'][] = array( |
|
475 | 479 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
476 | 480 | 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0], |
477 | 481 | ); |
482 | + } |
|
478 | 483 | |
479 | 484 | // Make a note of the Unique ID for this menu. |
480 | 485 | $context['admin_menu_id'] = $context['max_menu_id']; |
@@ -484,16 +489,18 @@ discard block |
||
484 | 489 | $context['admin_area'] = $admin_include_data['current_area']; |
485 | 490 | |
486 | 491 | // Now - finally - call the right place! |
487 | - if (isset($admin_include_data['file'])) |
|
488 | - require_once($sourcedir . '/' . $admin_include_data['file']); |
|
492 | + if (isset($admin_include_data['file'])) { |
|
493 | + require_once($sourcedir . '/' . $admin_include_data['file']); |
|
494 | + } |
|
489 | 495 | |
490 | 496 | // Get the right callable. |
491 | 497 | $call = call_helper($admin_include_data['function'], true); |
492 | 498 | |
493 | 499 | // Is it valid? |
494 | - if (!empty($call)) |
|
495 | - call_user_func($call); |
|
496 | -} |
|
500 | + if (!empty($call)) { |
|
501 | + call_user_func($call); |
|
502 | + } |
|
503 | + } |
|
497 | 504 | |
498 | 505 | /** |
499 | 506 | * The main administration section. |
@@ -547,13 +554,14 @@ discard block |
||
547 | 554 | |
548 | 555 | $context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin'; |
549 | 556 | $context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center']; |
550 | - if ($context['admin_area'] != 'credits') |
|
551 | - $context[$context['admin_menu_name']]['tab_data'] = array( |
|
557 | + if ($context['admin_area'] != 'credits') { |
|
558 | + $context[$context['admin_menu_name']]['tab_data'] = array( |
|
552 | 559 | 'title' => $txt['admin_center'], |
553 | 560 | 'help' => '', |
554 | 561 | 'description' => '<strong>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</strong> |
555 | 562 | ' . sprintf($txt['admin_main_welcome'], $txt['admin_center'], $txt['help'], $txt['help']), |
556 | 563 | ); |
564 | + } |
|
557 | 565 | |
558 | 566 | // Lastly, fill in the blanks in the support resources paragraphs. |
559 | 567 | $txt['support_resources_p1'] = sprintf($txt['support_resources_p1'], |
@@ -571,9 +579,10 @@ discard block |
||
571 | 579 | 'https://www.simplemachines.org/redirect/customize_support' |
572 | 580 | ); |
573 | 581 | |
574 | - if ($context['admin_area'] == 'admin') |
|
575 | - loadJavaScriptFile('admin.js', array('defer' => false, 'minimize' => true), 'smf_admin'); |
|
576 | -} |
|
582 | + if ($context['admin_area'] == 'admin') { |
|
583 | + loadJavaScriptFile('admin.js', array('defer' => false, 'minimize' => true), 'smf_admin'); |
|
584 | + } |
|
585 | + } |
|
577 | 586 | |
578 | 587 | /** |
579 | 588 | * Get one of the admin information files from Simple Machines. |
@@ -584,8 +593,9 @@ discard block |
||
584 | 593 | |
585 | 594 | setMemoryLimit('32M'); |
586 | 595 | |
587 | - if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) |
|
588 | - fatal_lang_error('no_access', false); |
|
596 | + if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) { |
|
597 | + fatal_lang_error('no_access', false); |
|
598 | + } |
|
589 | 599 | |
590 | 600 | // Strip off the forum cache part or we won't find it... |
591 | 601 | $_REQUEST['filename'] = str_replace($modSettings['browser_cache'], '', $_REQUEST['filename']); |
@@ -600,27 +610,30 @@ discard block |
||
600 | 610 | ) |
601 | 611 | ); |
602 | 612 | |
603 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
604 | - fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
613 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
614 | + fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
615 | + } |
|
605 | 616 | |
606 | 617 | list ($file_data, $filetype) = $smcFunc['db_fetch_row']($request); |
607 | 618 | $smcFunc['db_free_result']($request); |
608 | 619 | |
609 | 620 | // @todo Temp |
610 | 621 | // Figure out if sesc is still being used. |
611 | - if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') |
|
612 | - $file_data = ' |
|
622 | + if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') { |
|
623 | + $file_data = ' |
|
613 | 624 | if (!(\'smfForum_sessionvar\' in window)) |
614 | 625 | window.smfForum_sessionvar = \'sesc\'; |
615 | 626 | ' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'=')); |
627 | + } |
|
616 | 628 | |
617 | 629 | $context['template_layers'] = array(); |
618 | 630 | // Lets make sure we aren't going to output anything nasty. |
619 | 631 | @ob_end_clean(); |
620 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
621 | - @ob_start('ob_gzhandler'); |
|
622 | - else |
|
623 | - @ob_start(); |
|
632 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
633 | + @ob_start('ob_gzhandler'); |
|
634 | + } else { |
|
635 | + @ob_start(); |
|
636 | + } |
|
624 | 637 | |
625 | 638 | // Make sure they know what type of file we are. |
626 | 639 | header('content-type: ' . $filetype); |
@@ -660,11 +673,12 @@ discard block |
||
660 | 673 | updateAdminPreferences(); |
661 | 674 | } |
662 | 675 | |
663 | - if (trim($context['search_term']) == '') |
|
664 | - $context['search_results'] = array(); |
|
665 | - else |
|
666 | - call_helper($subActions[$context['search_type']]); |
|
667 | -} |
|
676 | + if (trim($context['search_term']) == '') { |
|
677 | + $context['search_results'] = array(); |
|
678 | + } else { |
|
679 | + call_helper($subActions[$context['search_type']]); |
|
680 | + } |
|
681 | + } |
|
668 | 682 | |
669 | 683 | /** |
670 | 684 | * A complicated but relatively quick internal search. |
@@ -728,8 +742,9 @@ discard block |
||
728 | 742 | |
729 | 743 | loadLanguage(implode('+', $language_files)); |
730 | 744 | |
731 | - foreach ($include_files as $file) |
|
732 | - require_once($sourcedir . '/' . $file . '.php'); |
|
745 | + foreach ($include_files as $file) { |
|
746 | + require_once($sourcedir . '/' . $file . '.php'); |
|
747 | + } |
|
733 | 748 | |
734 | 749 | /* This is the huge array that defines everything... it's a huge array of items formatted as follows: |
735 | 750 | 0 = Language index (Can be array of indexes) to search through for this setting. |
@@ -753,11 +768,12 @@ discard block |
||
753 | 768 | foreach ($section['areas'] as $menu_key => $menu_item) |
754 | 769 | { |
755 | 770 | $search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key); |
756 | - if (!empty($menu_item['subsections'])) |
|
757 | - foreach ($menu_item['subsections'] as $key => $sublabel) |
|
771 | + if (!empty($menu_item['subsections'])) { |
|
772 | + foreach ($menu_item['subsections'] as $key => $sublabel) |
|
758 | 773 | { |
759 | 774 | if (isset($sublabel['label'])) |
760 | 775 | $search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key); |
776 | + } |
|
761 | 777 | } |
762 | 778 | } |
763 | 779 | } |
@@ -767,9 +783,10 @@ discard block |
||
767 | 783 | // Get a list of their variables. |
768 | 784 | $config_vars = $setting_area[0](true); |
769 | 785 | |
770 | - foreach ($config_vars as $var) |
|
771 | - if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
786 | + foreach ($config_vars as $var) { |
|
787 | + if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
772 | 788 | $search_data['settings'][] = array($var[(isset($var[2]) && in_array($var[2], array('file', 'db'))) ? 0 : 1], $setting_area[1], 'alttxt' => (isset($var[2]) && in_array($var[2], array('file', 'db'))) || isset($var[3]) ? (in_array($var[2], array('file', 'db')) ? $var[1] : $var[3]) : ''); |
789 | + } |
|
773 | 790 | } |
774 | 791 | |
775 | 792 | $context['page_title'] = $txt['admin_search_results']; |
@@ -782,8 +799,9 @@ discard block |
||
782 | 799 | foreach ($data as $item) |
783 | 800 | { |
784 | 801 | $found = false; |
785 | - if (!is_array($item[0])) |
|
786 | - $item[0] = array($item[0]); |
|
802 | + if (!is_array($item[0])) { |
|
803 | + $item[0] = array($item[0]); |
|
804 | + } |
|
787 | 805 | foreach ($item[0] as $term) |
788 | 806 | { |
789 | 807 | if (stripos($term, $search_term) !== false || (isset($txt[$term]) && stripos($txt[$term], $search_term) !== false) || (isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false)) |
@@ -841,8 +859,9 @@ discard block |
||
841 | 859 | $postVars = explode(' ', $context['search_term']); |
842 | 860 | |
843 | 861 | // Encode the search data. |
844 | - foreach ($postVars as $k => $v) |
|
845 | - $postVars[$k] = urlencode($v); |
|
862 | + foreach ($postVars as $k => $v) { |
|
863 | + $postVars[$k] = urlencode($v); |
|
864 | + } |
|
846 | 865 | |
847 | 866 | // This is what we will send. |
848 | 867 | $postVars = implode('+', $postVars); |
@@ -853,8 +872,9 @@ discard block |
||
853 | 872 | $search_results = fetch_web_data($context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars); |
854 | 873 | |
855 | 874 | // If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded? |
856 | - if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) |
|
857 | - fatal_lang_error('cannot_connect_doc_site'); |
|
875 | + if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) { |
|
876 | + fatal_lang_error('cannot_connect_doc_site'); |
|
877 | + } |
|
858 | 878 | |
859 | 879 | $search_results = $matches[1]; |
860 | 880 | |
@@ -866,8 +886,9 @@ discard block |
||
866 | 886 | $results = new xmlArray($search_results, false); |
867 | 887 | |
868 | 888 | // Move through the api layer. |
869 | - if (!$results->exists('api')) |
|
870 | - fatal_lang_error('cannot_connect_doc_site'); |
|
889 | + if (!$results->exists('api')) { |
|
890 | + fatal_lang_error('cannot_connect_doc_site'); |
|
891 | + } |
|
871 | 892 | |
872 | 893 | // Are there actually some results? |
873 | 894 | if ($results->exists('api/query/search/p')) |
@@ -903,8 +924,9 @@ discard block |
||
903 | 924 | ); |
904 | 925 | |
905 | 926 | // If it's not got a sa set it must have come here for first time, pretend error log should be reversed. |
906 | - if (!isset($_REQUEST['sa'])) |
|
907 | - $_REQUEST['desc'] = true; |
|
927 | + if (!isset($_REQUEST['sa'])) { |
|
928 | + $_REQUEST['desc'] = true; |
|
929 | + } |
|
908 | 930 | |
909 | 931 | // Setup some tab stuff. |
910 | 932 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -954,9 +976,10 @@ discard block |
||
954 | 976 | unset($_SESSION['admin_time']); |
955 | 977 | |
956 | 978 | // Clean any admin tokens as well. |
957 | - foreach ($_SESSION['token'] as $key => $token) |
|
958 | - if (strpos($key, '-admin') !== false) |
|
979 | + foreach ($_SESSION['token'] as $key => $token) { |
|
980 | + if (strpos($key, '-admin') !== false) |
|
959 | 981 | unset($_SESSION['token'][$key]); |
982 | + } |
|
960 | 983 | |
961 | 984 | redirectexit(); |
962 | 985 | } |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * The main designating function for modifying profiles. Loads up info, determins what to do, etc. |
@@ -29,18 +30,21 @@ discard block |
||
29 | 30 | global $modSettings, $memberContext, $profile_vars, $post_errors, $smcFunc; |
30 | 31 | |
31 | 32 | // Don't reload this as we may have processed error strings. |
32 | - if (empty($post_errors)) |
|
33 | - loadLanguage('Profile+Drafts'); |
|
33 | + if (empty($post_errors)) { |
|
34 | + loadLanguage('Profile+Drafts'); |
|
35 | + } |
|
34 | 36 | loadTemplate('Profile'); |
35 | 37 | |
36 | 38 | require_once($sourcedir . '/Subs-Menu.php'); |
37 | 39 | |
38 | 40 | // Did we get the user by name... |
39 | - if (isset($_REQUEST['user'])) |
|
40 | - $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
41 | + if (isset($_REQUEST['user'])) { |
|
42 | + $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
43 | + } |
|
41 | 44 | // ... or by id_member? |
42 | - elseif (!empty($_REQUEST['u'])) |
|
43 | - $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
45 | + elseif (!empty($_REQUEST['u'])) { |
|
46 | + $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
47 | + } |
|
44 | 48 | // If it was just ?action=profile, edit your own profile, but only if you're not a guest. |
45 | 49 | else |
46 | 50 | { |
@@ -50,8 +54,9 @@ discard block |
||
50 | 54 | } |
51 | 55 | |
52 | 56 | // Check if loadMemberData() has returned a valid result. |
53 | - if (!$memberResult) |
|
54 | - fatal_lang_error('not_a_user', false, 404); |
|
57 | + if (!$memberResult) { |
|
58 | + fatal_lang_error('not_a_user', false, 404); |
|
59 | + } |
|
55 | 60 | |
56 | 61 | // If all went well, we have a valid member ID! |
57 | 62 | list ($memID) = $memberResult; |
@@ -67,8 +72,9 @@ discard block |
||
67 | 72 | |
68 | 73 | // Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission. |
69 | 74 | // And we care about what the current user can do, not what the user whose profile it is. |
70 | - if ($user_info['mod_cache']['gq'] != '0=1') |
|
71 | - $user_info['permissions'][] = 'approve_group_requests'; |
|
75 | + if ($user_info['mod_cache']['gq'] != '0=1') { |
|
76 | + $user_info['permissions'][] = 'approve_group_requests'; |
|
77 | + } |
|
72 | 78 | |
73 | 79 | // If paid subscriptions are enabled, make sure we actually have at least one subscription available... |
74 | 80 | $context['subs_available'] = false; |
@@ -436,21 +442,25 @@ discard block |
||
436 | 442 | foreach ($section['areas'] as $area_id => $area) |
437 | 443 | { |
438 | 444 | // If it said no permissions that meant it wasn't valid! |
439 | - if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) |
|
440 | - $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
445 | + if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) { |
|
446 | + $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
447 | + } |
|
441 | 448 | // Otherwise pick the right set. |
442 | - else |
|
443 | - $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
449 | + else { |
|
450 | + $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
451 | + } |
|
444 | 452 | |
445 | 453 | // Password required in most cases |
446 | - if (!empty($area['password'])) |
|
447 | - $context['password_areas'][] = $area_id; |
|
454 | + if (!empty($area['password'])) { |
|
455 | + $context['password_areas'][] = $area_id; |
|
456 | + } |
|
448 | 457 | } |
449 | 458 | } |
450 | 459 | |
451 | 460 | // Is there an updated message to show? |
452 | - if (isset($_GET['updated'])) |
|
453 | - $context['profile_updated'] = $txt['profile_updated_own']; |
|
461 | + if (isset($_GET['updated'])) { |
|
462 | + $context['profile_updated'] = $txt['profile_updated_own']; |
|
463 | + } |
|
454 | 464 | |
455 | 465 | // Set a few options for the menu. |
456 | 466 | $menuOptions = array( |
@@ -465,8 +475,9 @@ discard block |
||
465 | 475 | $profile_include_data = createMenu($profile_areas, $menuOptions); |
466 | 476 | |
467 | 477 | // No menu means no access. |
468 | - if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) |
|
469 | - fatal_lang_error('no_access', false); |
|
478 | + if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
479 | + fatal_lang_error('no_access', false); |
|
480 | + } |
|
470 | 481 | |
471 | 482 | // Make a note of the Unique ID for this menu. |
472 | 483 | $context['profile_menu_id'] = $context['max_menu_id']; |
@@ -492,8 +503,9 @@ discard block |
||
492 | 503 | if ($current_area == $area_id) |
493 | 504 | { |
494 | 505 | // This can't happen - but is a security check. |
495 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) |
|
496 | - fatal_lang_error('no_access', false); |
|
506 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) { |
|
507 | + fatal_lang_error('no_access', false); |
|
508 | + } |
|
497 | 509 | |
498 | 510 | // Are we saving data in a valid area? |
499 | 511 | if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview'])) |
@@ -512,12 +524,14 @@ discard block |
||
512 | 524 | } |
513 | 525 | |
514 | 526 | // Does this require session validating? |
515 | - if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) |
|
516 | - $security_checks['validate'] = true; |
|
527 | + if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) { |
|
528 | + $security_checks['validate'] = true; |
|
529 | + } |
|
517 | 530 | |
518 | 531 | // Permissions for good measure. |
519 | - if (!empty($profile_include_data['permission'])) |
|
520 | - $security_checks['permission'] = $profile_include_data['permission']; |
|
532 | + if (!empty($profile_include_data['permission'])) { |
|
533 | + $security_checks['permission'] = $profile_include_data['permission']; |
|
534 | + } |
|
521 | 535 | |
522 | 536 | // Either way got something. |
523 | 537 | $found_area = true; |
@@ -526,21 +540,26 @@ discard block |
||
526 | 540 | } |
527 | 541 | |
528 | 542 | // Oh dear, some serious security lapse is going on here... we'll put a stop to that! |
529 | - if (!$found_area) |
|
530 | - fatal_lang_error('no_access', false); |
|
543 | + if (!$found_area) { |
|
544 | + fatal_lang_error('no_access', false); |
|
545 | + } |
|
531 | 546 | |
532 | 547 | // Release this now. |
533 | 548 | unset($profile_areas); |
534 | 549 | |
535 | 550 | // Now the context is setup have we got any security checks to carry out additional to that above? |
536 | - if (isset($security_checks['session'])) |
|
537 | - checkSession($security_checks['session']); |
|
538 | - if (isset($security_checks['validate'])) |
|
539 | - validateSession(); |
|
540 | - if (isset($security_checks['validateToken'])) |
|
541 | - validateToken($token_name, $token_type); |
|
542 | - if (isset($security_checks['permission'])) |
|
543 | - isAllowedTo($security_checks['permission']); |
|
551 | + if (isset($security_checks['session'])) { |
|
552 | + checkSession($security_checks['session']); |
|
553 | + } |
|
554 | + if (isset($security_checks['validate'])) { |
|
555 | + validateSession(); |
|
556 | + } |
|
557 | + if (isset($security_checks['validateToken'])) { |
|
558 | + validateToken($token_name, $token_type); |
|
559 | + } |
|
560 | + if (isset($security_checks['permission'])) { |
|
561 | + isAllowedTo($security_checks['permission']); |
|
562 | + } |
|
544 | 563 | |
545 | 564 | // Create a token if needed. |
546 | 565 | if (isset($security_checks['needsToken']) || isset($security_checks['validateToken'])) |
@@ -550,8 +569,9 @@ discard block |
||
550 | 569 | } |
551 | 570 | |
552 | 571 | // File to include? |
553 | - if (isset($profile_include_data['file'])) |
|
554 | - require_once($sourcedir . '/' . $profile_include_data['file']); |
|
572 | + if (isset($profile_include_data['file'])) { |
|
573 | + require_once($sourcedir . '/' . $profile_include_data['file']); |
|
574 | + } |
|
555 | 575 | |
556 | 576 | // Build the link tree. |
557 | 577 | $context['linktree'][] = array( |
@@ -559,17 +579,19 @@ discard block |
||
559 | 579 | 'name' => sprintf($txt['profile_of_username'], $context['member']['name']), |
560 | 580 | ); |
561 | 581 | |
562 | - if (!empty($profile_include_data['label'])) |
|
563 | - $context['linktree'][] = array( |
|
582 | + if (!empty($profile_include_data['label'])) { |
|
583 | + $context['linktree'][] = array( |
|
564 | 584 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'], |
565 | 585 | 'name' => $profile_include_data['label'], |
566 | 586 | ); |
587 | + } |
|
567 | 588 | |
568 | - if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) |
|
569 | - $context['linktree'][] = array( |
|
589 | + if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) { |
|
590 | + $context['linktree'][] = array( |
|
570 | 591 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'], |
571 | 592 | 'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0], |
572 | 593 | ); |
594 | + } |
|
573 | 595 | |
574 | 596 | // Set the template for this area and add the profile layer. |
575 | 597 | $context['sub_template'] = $profile_include_data['function']; |
@@ -595,12 +617,14 @@ discard block |
||
595 | 617 | if ($check_password) |
596 | 618 | { |
597 | 619 | // Check to ensure we're forcing SSL for authentication |
598 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
599 | - fatal_lang_error('login_ssl_required'); |
|
620 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
621 | + fatal_lang_error('login_ssl_required'); |
|
622 | + } |
|
600 | 623 | |
601 | 624 | // You didn't even enter a password! |
602 | - if (trim($_POST['oldpasswrd']) == '') |
|
603 | - $post_errors[] = 'no_password'; |
|
625 | + if (trim($_POST['oldpasswrd']) == '') { |
|
626 | + $post_errors[] = 'no_password'; |
|
627 | + } |
|
604 | 628 | |
605 | 629 | // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password |
606 | 630 | $_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']); |
@@ -609,42 +633,43 @@ discard block |
||
609 | 633 | $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true); |
610 | 634 | |
611 | 635 | // Bad password!!! |
612 | - if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) |
|
613 | - $post_errors[] = 'bad_password'; |
|
636 | + if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) { |
|
637 | + $post_errors[] = 'bad_password'; |
|
638 | + } |
|
614 | 639 | |
615 | 640 | // Warn other elements not to jump the gun and do custom changes! |
616 | - if (in_array('bad_password', $post_errors)) |
|
617 | - $context['password_auth_failed'] = true; |
|
641 | + if (in_array('bad_password', $post_errors)) { |
|
642 | + $context['password_auth_failed'] = true; |
|
643 | + } |
|
618 | 644 | } |
619 | 645 | |
620 | 646 | // Change the IP address in the database. |
621 | - if ($context['user']['is_owner']) |
|
622 | - $profile_vars['member_ip'] = $user_info['ip']; |
|
647 | + if ($context['user']['is_owner']) { |
|
648 | + $profile_vars['member_ip'] = $user_info['ip']; |
|
649 | + } |
|
623 | 650 | |
624 | 651 | // Now call the sub-action function... |
625 | 652 | if ($current_area == 'activateaccount') |
626 | 653 | { |
627 | - if (empty($post_errors)) |
|
628 | - activateAccount($memID); |
|
629 | - } |
|
630 | - elseif ($current_area == 'deleteaccount') |
|
654 | + if (empty($post_errors)) { |
|
655 | + activateAccount($memID); |
|
656 | + } |
|
657 | + } elseif ($current_area == 'deleteaccount') |
|
631 | 658 | { |
632 | 659 | if (empty($post_errors)) |
633 | 660 | { |
634 | 661 | deleteAccount2($memID); |
635 | 662 | redirectexit(); |
636 | 663 | } |
637 | - } |
|
638 | - elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
664 | + } elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
639 | 665 | { |
640 | 666 | $msg = groupMembership2($profile_vars, $post_errors, $memID); |
641 | 667 | |
642 | 668 | // Whatever we've done, we have nothing else to do here... |
643 | 669 | redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=groupmembership' . (!empty($msg) ? ';msg=' . $msg : '')); |
644 | - } |
|
645 | - elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) |
|
646 | - saveProfileFields(); |
|
647 | - else |
|
670 | + } elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) { |
|
671 | + saveProfileFields(); |
|
672 | + } else |
|
648 | 673 | { |
649 | 674 | $force_redirect = true; |
650 | 675 | // Ensure we include this. |
@@ -660,34 +685,36 @@ discard block |
||
660 | 685 | // Load the language file so we can give a nice explanation of the errors. |
661 | 686 | loadLanguage('Errors'); |
662 | 687 | $context['post_errors'] = $post_errors; |
663 | - } |
|
664 | - elseif (!empty($profile_vars)) |
|
688 | + } elseif (!empty($profile_vars)) |
|
665 | 689 | { |
666 | 690 | // If we've changed the password, notify any integration that may be listening in. |
667 | - if (isset($profile_vars['passwd'])) |
|
668 | - call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
691 | + if (isset($profile_vars['passwd'])) { |
|
692 | + call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
693 | + } |
|
669 | 694 | |
670 | 695 | updateMemberData($memID, $profile_vars); |
671 | 696 | |
672 | 697 | // What if this is the newest member? |
673 | - if ($modSettings['latestMember'] == $memID) |
|
674 | - updateStats('member'); |
|
675 | - elseif (isset($profile_vars['real_name'])) |
|
676 | - updateSettings(array('memberlist_updated' => time())); |
|
698 | + if ($modSettings['latestMember'] == $memID) { |
|
699 | + updateStats('member'); |
|
700 | + } elseif (isset($profile_vars['real_name'])) { |
|
701 | + updateSettings(array('memberlist_updated' => time())); |
|
702 | + } |
|
677 | 703 | |
678 | 704 | // If the member changed his/her birthdate, update calendar statistics. |
679 | - if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) |
|
680 | - updateSettings(array( |
|
705 | + if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) { |
|
706 | + updateSettings(array( |
|
681 | 707 | 'calendar_updated' => time(), |
682 | 708 | )); |
709 | + } |
|
683 | 710 | |
684 | 711 | // Anything worth logging? |
685 | 712 | if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled'])) |
686 | 713 | { |
687 | 714 | $log_changes = array(); |
688 | 715 | require_once($sourcedir . '/Logging.php'); |
689 | - foreach ($context['log_changes'] as $k => $v) |
|
690 | - $log_changes[] = array( |
|
716 | + foreach ($context['log_changes'] as $k => $v) { |
|
717 | + $log_changes[] = array( |
|
691 | 718 | 'action' => $k, |
692 | 719 | 'log_type' => 'user', |
693 | 720 | 'extra' => array_merge($v, array( |
@@ -695,14 +722,16 @@ discard block |
||
695 | 722 | 'member_affected' => $memID, |
696 | 723 | )), |
697 | 724 | ); |
725 | + } |
|
698 | 726 | |
699 | 727 | logActions($log_changes); |
700 | 728 | } |
701 | 729 | |
702 | 730 | // Have we got any post save functions to execute? |
703 | - if (!empty($context['profile_execute_on_save'])) |
|
704 | - foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
731 | + if (!empty($context['profile_execute_on_save'])) { |
|
732 | + foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
705 | 733 | $saveFunc(); |
734 | + } |
|
706 | 735 | |
707 | 736 | // Let them know it worked! |
708 | 737 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']); |
@@ -716,27 +745,31 @@ discard block |
||
716 | 745 | if (!empty($post_errors)) |
717 | 746 | { |
718 | 747 | // Set all the errors so the template knows what went wrong. |
719 | - foreach ($post_errors as $error_type) |
|
720 | - $context['modify_error'][$error_type] = true; |
|
748 | + foreach ($post_errors as $error_type) { |
|
749 | + $context['modify_error'][$error_type] = true; |
|
750 | + } |
|
721 | 751 | } |
722 | 752 | // If it's you then we should redirect upon save. |
723 | - elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) |
|
724 | - redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
725 | - elseif (!empty($force_redirect)) |
|
726 | - redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
753 | + elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) { |
|
754 | + redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
755 | + } elseif (!empty($force_redirect)) { |
|
756 | + redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
757 | + } |
|
727 | 758 | |
728 | 759 | |
729 | 760 | // Get the right callable. |
730 | 761 | $call = call_helper($profile_include_data['function'], true); |
731 | 762 | |
732 | 763 | // Is it valid? |
733 | - if (!empty($call)) |
|
734 | - call_user_func($call, $memID); |
|
764 | + if (!empty($call)) { |
|
765 | + call_user_func($call, $memID); |
|
766 | + } |
|
735 | 767 | |
736 | 768 | // Set the page title if it's not already set... |
737 | - if (!isset($context['page_title'])) |
|
738 | - $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
739 | -} |
|
769 | + if (!isset($context['page_title'])) { |
|
770 | + $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
771 | + } |
|
772 | + } |
|
740 | 773 | |
741 | 774 | /** |
742 | 775 | * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user. |
@@ -859,16 +892,18 @@ discard block |
||
859 | 892 | if (!allowedTo('admin_forum') && $area != 'register') |
860 | 893 | { |
861 | 894 | // If it's the owner they can see two types of private fields, regardless. |
862 | - if ($memID == $user_info['id']) |
|
863 | - $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
864 | - else |
|
865 | - $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
895 | + if ($memID == $user_info['id']) { |
|
896 | + $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
897 | + } else { |
|
898 | + $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
899 | + } |
|
866 | 900 | } |
867 | 901 | |
868 | - if ($area == 'register') |
|
869 | - $where .= ' AND show_reg != 0'; |
|
870 | - elseif ($area != 'summary') |
|
871 | - $where .= ' AND show_profile = {string:area}'; |
|
902 | + if ($area == 'register') { |
|
903 | + $where .= ' AND show_reg != 0'; |
|
904 | + } elseif ($area != 'summary') { |
|
905 | + $where .= ' AND show_profile = {string:area}'; |
|
906 | + } |
|
872 | 907 | |
873 | 908 | // Load all the relevant fields - and data. |
874 | 909 | $request = $smcFunc['db_query']('', ' |
@@ -893,8 +928,9 @@ discard block |
||
893 | 928 | $fieldOptions = explode(',', $row['field_options']); |
894 | 929 | foreach ($fieldOptions as $k => $v) |
895 | 930 | { |
896 | - if (empty($currentKey)) |
|
897 | - $currentKey = $v === $value ? $k : 0; |
|
931 | + if (empty($currentKey)) { |
|
932 | + $currentKey = $v === $value ? $k : 0; |
|
933 | + } |
|
898 | 934 | } |
899 | 935 | } |
900 | 936 | |
@@ -906,13 +942,15 @@ discard block |
||
906 | 942 | if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']])) |
907 | 943 | { |
908 | 944 | $value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]); |
909 | - if (in_array($row['field_type'], array('select', 'radio'))) |
|
910 | - $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
945 | + if (in_array($row['field_type'], array('select', 'radio'))) { |
|
946 | + $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
947 | + } |
|
911 | 948 | } |
912 | 949 | |
913 | 950 | // Don't show the "disabled" option for the "gender" field if we are on the "summary" area. |
914 | - if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') |
|
915 | - continue; |
|
951 | + if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') { |
|
952 | + continue; |
|
953 | + } |
|
916 | 954 | |
917 | 955 | // HTML for the input form. |
918 | 956 | $output_html = $value; |
@@ -921,8 +959,7 @@ discard block |
||
921 | 959 | $true = (!$exists && $row['default_value']) || $value; |
922 | 960 | $input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>'; |
923 | 961 | $output_html = $true ? $txt['yes'] : $txt['no']; |
924 | - } |
|
925 | - elseif ($row['field_type'] == 'select') |
|
962 | + } elseif ($row['field_type'] == 'select') |
|
926 | 963 | { |
927 | 964 | $input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>'; |
928 | 965 | $options = explode(',', $row['field_options']); |
@@ -930,13 +967,13 @@ discard block |
||
930 | 967 | { |
931 | 968 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
932 | 969 | $input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>'; |
933 | - if ($true) |
|
934 | - $output_html = $v; |
|
970 | + if ($true) { |
|
971 | + $output_html = $v; |
|
972 | + } |
|
935 | 973 | } |
936 | 974 | |
937 | 975 | $input_html .= '</select>'; |
938 | - } |
|
939 | - elseif ($row['field_type'] == 'radio') |
|
976 | + } elseif ($row['field_type'] == 'radio') |
|
940 | 977 | { |
941 | 978 | $input_html = '<fieldset>'; |
942 | 979 | $options = explode(',', $row['field_options']); |
@@ -944,37 +981,38 @@ discard block |
||
944 | 981 | { |
945 | 982 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
946 | 983 | $input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>'; |
947 | - if ($true) |
|
948 | - $output_html = $v; |
|
984 | + if ($true) { |
|
985 | + $output_html = $v; |
|
986 | + } |
|
949 | 987 | } |
950 | 988 | $input_html .= '</fieldset>'; |
951 | - } |
|
952 | - elseif ($row['field_type'] == 'text') |
|
989 | + } elseif ($row['field_type'] == 'text') |
|
953 | 990 | { |
954 | 991 | $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) . '"' . ($row['show_reg'] == 2 ? ' required' : '') . '>'; |
955 | - } |
|
956 | - else |
|
992 | + } else |
|
957 | 993 | { |
958 | 994 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
959 | 995 | $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>'; |
960 | 996 | } |
961 | 997 | |
962 | 998 | // Parse BBCode |
963 | - if ($row['bbc']) |
|
964 | - $output_html = parse_bbc($output_html); |
|
965 | - elseif ($row['field_type'] == 'textarea') |
|
966 | - // Allow for newlines at least |
|
999 | + if ($row['bbc']) { |
|
1000 | + $output_html = parse_bbc($output_html); |
|
1001 | + } elseif ($row['field_type'] == 'textarea') { |
|
1002 | + // Allow for newlines at least |
|
967 | 1003 | $output_html = strtr($output_html, array("\n" => '<br>')); |
1004 | + } |
|
968 | 1005 | |
969 | 1006 | // Enclosing the user input within some other text? |
970 | - if (!empty($row['enclose']) && !empty($output_html)) |
|
971 | - $output_html = strtr($row['enclose'], array( |
|
1007 | + if (!empty($row['enclose']) && !empty($output_html)) { |
|
1008 | + $output_html = strtr($row['enclose'], array( |
|
972 | 1009 | '{SCRIPTURL}' => $scripturl, |
973 | 1010 | '{IMAGES_URL}' => $settings['images_url'], |
974 | 1011 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
975 | 1012 | '{INPUT}' => un_htmlspecialchars($output_html), |
976 | 1013 | '{KEY}' => $currentKey |
977 | 1014 | )); |
1015 | + } |
|
978 | 1016 | |
979 | 1017 | $context['custom_fields'][] = array( |
980 | 1018 | 'name' => $row['field_name'], |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
206 | 207 | { |
207 | 208 | $all_zones = timezone_identifiers_list(); |
208 | 209 | // Make sure we set the value to the same as the printed value. |
209 | - foreach ($all_zones as $zone) |
|
210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
210 | + foreach ($all_zones as $zone) { |
|
211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
212 | + } |
|
213 | + } else { |
|
214 | + unset($config_vars['default_timezone']); |
|
211 | 215 | } |
212 | - else |
|
213 | - unset($config_vars['default_timezone']); |
|
214 | 216 | |
215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
216 | 218 | |
217 | - if ($return_config) |
|
218 | - return $config_vars; |
|
219 | + if ($return_config) { |
|
220 | + return $config_vars; |
|
221 | + } |
|
219 | 222 | |
220 | 223 | // Saving? |
221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
223 | 226 | checkSession(); |
224 | 227 | |
225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
226 | - if (isset($_POST['lastActive'])) |
|
227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
229 | + if (isset($_POST['lastActive'])) { |
|
230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
231 | + } |
|
228 | 232 | |
229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
230 | 234 | |
@@ -232,8 +236,9 @@ discard block |
||
232 | 236 | $_SESSION['adm-save'] = true; |
233 | 237 | |
234 | 238 | // Do a bit of housekeeping |
235 | - if (empty($_POST['minimize_files'])) |
|
236 | - deleteAllMinified(); |
|
239 | + if (empty($_POST['minimize_files'])) { |
|
240 | + deleteAllMinified(); |
|
241 | + } |
|
237 | 242 | |
238 | 243 | writeLog(); |
239 | 244 | redirectexit('action=admin;area=featuresettings;sa=basic'); |
@@ -273,8 +278,9 @@ discard block |
||
273 | 278 | |
274 | 279 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
275 | 280 | |
276 | - if ($return_config) |
|
277 | - return $config_vars; |
|
281 | + if ($return_config) { |
|
282 | + return $config_vars; |
|
283 | + } |
|
278 | 284 | |
279 | 285 | // Setup the template. |
280 | 286 | require_once($sourcedir . '/ManageServer.php'); |
@@ -291,13 +297,15 @@ discard block |
||
291 | 297 | |
292 | 298 | // Clean up the tags. |
293 | 299 | $bbcTags = array(); |
294 | - foreach (parse_bbc(false) as $tag) |
|
295 | - $bbcTags[] = $tag['tag']; |
|
300 | + foreach (parse_bbc(false) as $tag) { |
|
301 | + $bbcTags[] = $tag['tag']; |
|
302 | + } |
|
296 | 303 | |
297 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
298 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
299 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
300 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
304 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
305 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
306 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
307 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
308 | + } |
|
301 | 309 | // Work out what is actually disabled! |
302 | 310 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
303 | 311 | |
@@ -341,8 +349,9 @@ discard block |
||
341 | 349 | |
342 | 350 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
343 | 351 | |
344 | - if ($return_config) |
|
345 | - return $config_vars; |
|
352 | + if ($return_config) { |
|
353 | + return $config_vars; |
|
354 | + } |
|
346 | 355 | |
347 | 356 | // Saving? |
348 | 357 | if (isset($_GET['save'])) |
@@ -382,8 +391,9 @@ discard block |
||
382 | 391 | |
383 | 392 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
384 | 393 | |
385 | - if ($return_config) |
|
386 | - return $config_vars; |
|
394 | + if ($return_config) { |
|
395 | + return $config_vars; |
|
396 | + } |
|
387 | 397 | |
388 | 398 | // Saving? |
389 | 399 | if (isset($_GET['save'])) |
@@ -421,8 +431,9 @@ discard block |
||
421 | 431 | |
422 | 432 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
423 | 433 | |
424 | - if ($return_config) |
|
425 | - return $config_vars; |
|
434 | + if ($return_config) { |
|
435 | + return $config_vars; |
|
436 | + } |
|
426 | 437 | |
427 | 438 | // Saving? |
428 | 439 | if (isset($_GET['save'])) |
@@ -466,8 +477,8 @@ discard block |
||
466 | 477 | 'enable' => array('check', 'warning_enable'), |
467 | 478 | ); |
468 | 479 | |
469 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
470 | - $config_vars += array( |
|
480 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
481 | + $config_vars += array( |
|
471 | 482 | '', |
472 | 483 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
473 | 484 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -476,15 +487,18 @@ discard block |
||
476 | 487 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
477 | 488 | array('permissions', 'view_warning'), |
478 | 489 | ); |
490 | + } |
|
479 | 491 | |
480 | 492 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
481 | 493 | |
482 | - if ($return_config) |
|
483 | - return $config_vars; |
|
494 | + if ($return_config) { |
|
495 | + return $config_vars; |
|
496 | + } |
|
484 | 497 | |
485 | 498 | // Cannot use moderation if post moderation is not enabled. |
486 | - if (!$modSettings['postmod_active']) |
|
487 | - unset($config_vars['moderate']); |
|
499 | + if (!$modSettings['postmod_active']) { |
|
500 | + unset($config_vars['moderate']); |
|
501 | + } |
|
488 | 502 | |
489 | 503 | // Will need the utility functions from here. |
490 | 504 | require_once($sourcedir . '/ManageServer.php'); |
@@ -509,16 +523,16 @@ discard block |
||
509 | 523 | 'warning_watch' => 10, |
510 | 524 | 'warning_mute' => 60, |
511 | 525 | ); |
512 | - if ($modSettings['postmod_active']) |
|
513 | - $vars['warning_moderate'] = 35; |
|
526 | + if ($modSettings['postmod_active']) { |
|
527 | + $vars['warning_moderate'] = 35; |
|
528 | + } |
|
514 | 529 | |
515 | 530 | foreach ($vars as $var => $value) |
516 | 531 | { |
517 | 532 | $config_vars[] = array('int', $var); |
518 | 533 | $_POST[$var] = $value; |
519 | 534 | } |
520 | - } |
|
521 | - else |
|
535 | + } else |
|
522 | 536 | { |
523 | 537 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
524 | 538 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -606,8 +620,9 @@ discard block |
||
606 | 620 | |
607 | 621 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
608 | 622 | |
609 | - if ($return_config) |
|
610 | - return $config_vars; |
|
623 | + if ($return_config) { |
|
624 | + return $config_vars; |
|
625 | + } |
|
611 | 626 | |
612 | 627 | // You need to be an admin to edit settings! |
613 | 628 | isAllowedTo('admin_forum'); |
@@ -641,8 +656,9 @@ discard block |
||
641 | 656 | |
642 | 657 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
643 | 658 | { |
644 | - if (empty($context['settings_insert_above'])) |
|
645 | - $context['settings_insert_above'] = ''; |
|
659 | + if (empty($context['settings_insert_above'])) { |
|
660 | + $context['settings_insert_above'] = ''; |
|
661 | + } |
|
646 | 662 | |
647 | 663 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
648 | 664 | } |
@@ -685,8 +701,9 @@ discard block |
||
685 | 701 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
686 | 702 | |
687 | 703 | // Hack in guest requiring verification! |
688 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
689 | - $_POST['posts_require_captcha'] = -1; |
|
704 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
705 | + $_POST['posts_require_captcha'] = -1; |
|
706 | + } |
|
690 | 707 | |
691 | 708 | $save_vars = $config_vars; |
692 | 709 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -703,14 +720,16 @@ discard block |
||
703 | 720 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
704 | 721 | { |
705 | 722 | // If we had some questions for this language before, but don't now, delete everything from that language. |
706 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
707 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
723 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
724 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
725 | + } |
|
708 | 726 | |
709 | 727 | // Now step through and see if any existing questions no longer exist. |
710 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
711 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
728 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
729 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
712 | 730 | if (empty($_POST['question'][$lang_id][$q_id])) |
713 | 731 | $changes['delete'][] = $q_id; |
732 | + } |
|
714 | 733 | |
715 | 734 | // Now let's see if there are new questions or ones that need updating. |
716 | 735 | if (isset($_POST['question'][$lang_id])) |
@@ -719,14 +738,16 @@ discard block |
||
719 | 738 | { |
720 | 739 | // Ignore junky ids. |
721 | 740 | $q_id = (int) $q_id; |
722 | - if ($q_id <= 0) |
|
723 | - continue; |
|
741 | + if ($q_id <= 0) { |
|
742 | + continue; |
|
743 | + } |
|
724 | 744 | |
725 | 745 | // Check the question isn't empty (because they want to delete it?) |
726 | 746 | if (empty($question) || trim($question) == '') |
727 | 747 | { |
728 | - if (isset($context['question_answers'][$q_id])) |
|
729 | - $changes['delete'][] = $q_id; |
|
748 | + if (isset($context['question_answers'][$q_id])) { |
|
749 | + $changes['delete'][] = $q_id; |
|
750 | + } |
|
730 | 751 | continue; |
731 | 752 | } |
732 | 753 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -734,19 +755,22 @@ discard block |
||
734 | 755 | // Get the answers. Firstly check there actually might be some. |
735 | 756 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
736 | 757 | { |
737 | - if (isset($context['question_answers'][$q_id])) |
|
738 | - $changes['delete'][] = $q_id; |
|
758 | + if (isset($context['question_answers'][$q_id])) { |
|
759 | + $changes['delete'][] = $q_id; |
|
760 | + } |
|
739 | 761 | continue; |
740 | 762 | } |
741 | 763 | // Now get them and check that they might be viable. |
742 | 764 | $answers = array(); |
743 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
744 | - if (!empty($answer) && trim($answer) !== '') |
|
765 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
766 | + if (!empty($answer) && trim($answer) !== '') |
|
745 | 767 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
768 | + } |
|
746 | 769 | if (empty($answers)) |
747 | 770 | { |
748 | - if (isset($context['question_answers'][$q_id])) |
|
749 | - $changes['delete'][] = $q_id; |
|
771 | + if (isset($context['question_answers'][$q_id])) { |
|
772 | + $changes['delete'][] = $q_id; |
|
773 | + } |
|
750 | 774 | continue; |
751 | 775 | } |
752 | 776 | $answers = $smcFunc['json_encode']($answers); |
@@ -756,16 +780,17 @@ discard block |
||
756 | 780 | { |
757 | 781 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
758 | 782 | $changes['insert'][] = array($lang_id, $question, $answers); |
759 | - } |
|
760 | - else |
|
783 | + } else |
|
761 | 784 | { |
762 | 785 | // It's an existing question. Let's see what's changed, if anything. |
763 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
764 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
786 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
787 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
788 | + } |
|
765 | 789 | } |
766 | 790 | |
767 | - if (!isset($qs_per_lang[$lang_id])) |
|
768 | - $qs_per_lang[$lang_id] = 0; |
|
791 | + if (!isset($qs_per_lang[$lang_id])) { |
|
792 | + $qs_per_lang[$lang_id] = 0; |
|
793 | + } |
|
769 | 794 | $qs_per_lang[$lang_id]++; |
770 | 795 | } |
771 | 796 | } |
@@ -815,8 +840,9 @@ discard block |
||
815 | 840 | |
816 | 841 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
817 | 842 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
818 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
819 | - $_POST['qa_verification_number'] = $count_questions; |
|
843 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
844 | + $_POST['qa_verification_number'] = $count_questions; |
|
845 | + } |
|
820 | 846 | |
821 | 847 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
822 | 848 | |
@@ -831,24 +857,27 @@ discard block |
||
831 | 857 | |
832 | 858 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
833 | 859 | $_SESSION['visual_verification_code'] = ''; |
834 | - for ($i = 0; $i < 6; $i++) |
|
835 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
860 | + for ($i = 0; $i < 6; $i++) { |
|
861 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
862 | + } |
|
836 | 863 | |
837 | 864 | // Some javascript for CAPTCHA. |
838 | 865 | $context['settings_post_javascript'] = ''; |
839 | - if ($context['use_graphic_library']) |
|
840 | - $context['settings_post_javascript'] .= ' |
|
866 | + if ($context['use_graphic_library']) { |
|
867 | + $context['settings_post_javascript'] .= ' |
|
841 | 868 | function refreshImages() |
842 | 869 | { |
843 | 870 | var imageType = document.getElementById(\'visual_verification_type\').value; |
844 | 871 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
845 | 872 | }'; |
873 | + } |
|
846 | 874 | |
847 | 875 | // Show the image itself, or text saying we can't. |
848 | - if ($context['use_graphic_library']) |
|
849 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
850 | - else |
|
851 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
876 | + if ($context['use_graphic_library']) { |
|
877 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
878 | + } else { |
|
879 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
880 | + } |
|
852 | 881 | |
853 | 882 | // Hack for PM spam settings. |
854 | 883 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -858,9 +887,10 @@ discard block |
||
858 | 887 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
859 | 888 | |
860 | 889 | // Some minor javascript for the guest post setting. |
861 | - if ($modSettings['posts_require_captcha']) |
|
862 | - $context['settings_post_javascript'] .= ' |
|
890 | + if ($modSettings['posts_require_captcha']) { |
|
891 | + $context['settings_post_javascript'] .= ' |
|
863 | 892 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
893 | + } |
|
864 | 894 | |
865 | 895 | // And everything else. |
866 | 896 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -907,8 +937,9 @@ discard block |
||
907 | 937 | |
908 | 938 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
909 | 939 | |
910 | - if ($return_config) |
|
911 | - return $config_vars; |
|
940 | + if ($return_config) { |
|
941 | + return $config_vars; |
|
942 | + } |
|
912 | 943 | |
913 | 944 | // Setup the template. |
914 | 945 | $context['page_title'] = $txt['signature_settings']; |
@@ -963,8 +994,9 @@ discard block |
||
963 | 994 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
964 | 995 | |
965 | 996 | // Max characters... |
966 | - if (!empty($sig_limits[1])) |
|
967 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
997 | + if (!empty($sig_limits[1])) { |
|
998 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
999 | + } |
|
968 | 1000 | // Max lines... |
969 | 1001 | if (!empty($sig_limits[2])) |
970 | 1002 | { |
@@ -974,8 +1006,9 @@ discard block |
||
974 | 1006 | if ($sig[$i] == "\n") |
975 | 1007 | { |
976 | 1008 | $count++; |
977 | - if ($count >= $sig_limits[2]) |
|
978 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1009 | + if ($count >= $sig_limits[2]) { |
|
1010 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1011 | + } |
|
979 | 1012 | } |
980 | 1013 | } |
981 | 1014 | } |
@@ -986,17 +1019,19 @@ discard block |
||
986 | 1019 | { |
987 | 1020 | $limit_broke = 0; |
988 | 1021 | // Attempt to allow all sizes of abuse, so to speak. |
989 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
990 | - $limit_broke = $sig_limits[7] . 'px'; |
|
991 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
992 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
993 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
994 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
995 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
996 | - $limit_broke = 'large'; |
|
997 | - |
|
998 | - if ($limit_broke) |
|
999 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1022 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
1023 | + $limit_broke = $sig_limits[7] . 'px'; |
|
1024 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
1025 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
1026 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
1027 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
1028 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
1029 | + $limit_broke = 'large'; |
|
1030 | + } |
|
1031 | + |
|
1032 | + if ($limit_broke) { |
|
1033 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1034 | + } |
|
1000 | 1035 | } |
1001 | 1036 | } |
1002 | 1037 | |
@@ -1052,32 +1087,34 @@ discard block |
||
1052 | 1087 | $img_offset = false; |
1053 | 1088 | } |
1054 | 1089 | } |
1090 | + } else { |
|
1091 | + $replaces[$image] = ''; |
|
1055 | 1092 | } |
1056 | - else |
|
1057 | - $replaces[$image] = ''; |
|
1058 | 1093 | |
1059 | 1094 | continue; |
1060 | 1095 | } |
1061 | 1096 | |
1062 | 1097 | // Does it have predefined restraints? Width first. |
1063 | - if ($matches[6][$key]) |
|
1064 | - $matches[2][$key] = $matches[6][$key]; |
|
1098 | + if ($matches[6][$key]) { |
|
1099 | + $matches[2][$key] = $matches[6][$key]; |
|
1100 | + } |
|
1065 | 1101 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
1066 | 1102 | { |
1067 | 1103 | $width = $sig_limits[5]; |
1068 | 1104 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
1105 | + } elseif ($matches[2][$key]) { |
|
1106 | + $width = $matches[2][$key]; |
|
1069 | 1107 | } |
1070 | - elseif ($matches[2][$key]) |
|
1071 | - $width = $matches[2][$key]; |
|
1072 | 1108 | // ... and height. |
1073 | 1109 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
1074 | 1110 | { |
1075 | 1111 | $height = $sig_limits[6]; |
1076 | - if ($width != -1) |
|
1077 | - $width = $width * ($height / $matches[4][$key]); |
|
1112 | + if ($width != -1) { |
|
1113 | + $width = $width * ($height / $matches[4][$key]); |
|
1114 | + } |
|
1115 | + } elseif ($matches[4][$key]) { |
|
1116 | + $height = $matches[4][$key]; |
|
1078 | 1117 | } |
1079 | - elseif ($matches[4][$key]) |
|
1080 | - $height = $matches[4][$key]; |
|
1081 | 1118 | |
1082 | 1119 | // If the dimensions are still not fixed - we need to check the actual image. |
1083 | 1120 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1095,12 +1132,13 @@ discard block |
||
1095 | 1132 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
1096 | 1133 | { |
1097 | 1134 | $height = $sig_limits[6]; |
1098 | - if ($width == -1) |
|
1099 | - $width = $sizes[0]; |
|
1135 | + if ($width == -1) { |
|
1136 | + $width = $sizes[0]; |
|
1137 | + } |
|
1100 | 1138 | $width = $width * ($height / $sizes[1]); |
1139 | + } elseif ($width != -1) { |
|
1140 | + $height = $sizes[1]; |
|
1101 | 1141 | } |
1102 | - elseif ($width != -1) |
|
1103 | - $height = $sizes[1]; |
|
1104 | 1142 | } |
1105 | 1143 | } |
1106 | 1144 | |
@@ -1113,8 +1151,9 @@ discard block |
||
1113 | 1151 | // Record that we got one. |
1114 | 1152 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
1115 | 1153 | } |
1116 | - if (!empty($replaces)) |
|
1117 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1154 | + if (!empty($replaces)) { |
|
1155 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1156 | + } |
|
1118 | 1157 | } |
1119 | 1158 | } |
1120 | 1159 | // Try to fix disabled tags. |
@@ -1126,18 +1165,20 @@ discard block |
||
1126 | 1165 | |
1127 | 1166 | $sig = strtr($sig, array("\n" => '<br>')); |
1128 | 1167 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
1129 | - if ($sig != $row['signature']) |
|
1130 | - $changes[$row['id_member']] = $sig; |
|
1168 | + if ($sig != $row['signature']) { |
|
1169 | + $changes[$row['id_member']] = $sig; |
|
1170 | + } |
|
1171 | + } |
|
1172 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1173 | + $done = true; |
|
1131 | 1174 | } |
1132 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1133 | - $done = true; |
|
1134 | 1175 | $smcFunc['db_free_result']($request); |
1135 | 1176 | |
1136 | 1177 | // Do we need to delete what we have? |
1137 | 1178 | if (!empty($changes)) |
1138 | 1179 | { |
1139 | - foreach ($changes as $id => $sig) |
|
1140 | - $smcFunc['db_query']('', ' |
|
1180 | + foreach ($changes as $id => $sig) { |
|
1181 | + $smcFunc['db_query']('', ' |
|
1141 | 1182 | UPDATE {db_prefix}members |
1142 | 1183 | SET signature = {string:signature} |
1143 | 1184 | WHERE id_member = {int:id_member}', |
@@ -1146,11 +1187,13 @@ discard block |
||
1146 | 1187 | 'signature' => $sig, |
1147 | 1188 | ) |
1148 | 1189 | ); |
1190 | + } |
|
1149 | 1191 | } |
1150 | 1192 | |
1151 | 1193 | $_GET['step'] += 50; |
1152 | - if (!$done) |
|
1153 | - pauseSignatureApplySettings(); |
|
1194 | + if (!$done) { |
|
1195 | + pauseSignatureApplySettings(); |
|
1196 | + } |
|
1154 | 1197 | } |
1155 | 1198 | $settings_applied = true; |
1156 | 1199 | } |
@@ -1168,8 +1211,9 @@ discard block |
||
1168 | 1211 | ); |
1169 | 1212 | |
1170 | 1213 | // Temporarily make each setting a modSetting! |
1171 | - foreach ($context['signature_settings'] as $key => $value) |
|
1172 | - $modSettings['signature_' . $key] = $value; |
|
1214 | + foreach ($context['signature_settings'] as $key => $value) { |
|
1215 | + $modSettings['signature_' . $key] = $value; |
|
1216 | + } |
|
1173 | 1217 | |
1174 | 1218 | // Make sure we check the right tags! |
1175 | 1219 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1181,23 +1225,26 @@ discard block |
||
1181 | 1225 | |
1182 | 1226 | // Clean up the tag stuff! |
1183 | 1227 | $bbcTags = array(); |
1184 | - foreach (parse_bbc(false) as $tag) |
|
1185 | - $bbcTags[] = $tag['tag']; |
|
1228 | + foreach (parse_bbc(false) as $tag) { |
|
1229 | + $bbcTags[] = $tag['tag']; |
|
1230 | + } |
|
1186 | 1231 | |
1187 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
1188 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
1189 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
1190 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1232 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
1233 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
1234 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
1235 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1236 | + } |
|
1191 | 1237 | |
1192 | 1238 | $sig_limits = array(); |
1193 | 1239 | foreach ($context['signature_settings'] as $key => $value) |
1194 | 1240 | { |
1195 | - if ($key == 'allow_smileys') |
|
1196 | - continue; |
|
1197 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
1198 | - $sig_limits[] = -1; |
|
1199 | - else |
|
1200 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1241 | + if ($key == 'allow_smileys') { |
|
1242 | + continue; |
|
1243 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
1244 | + $sig_limits[] = -1; |
|
1245 | + } else { |
|
1246 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1247 | + } |
|
1201 | 1248 | } |
1202 | 1249 | |
1203 | 1250 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1230,12 +1277,14 @@ discard block |
||
1230 | 1277 | |
1231 | 1278 | // Try get more time... |
1232 | 1279 | @set_time_limit(600); |
1233 | - if (function_exists('apache_reset_timeout')) |
|
1234 | - @apache_reset_timeout(); |
|
1280 | + if (function_exists('apache_reset_timeout')) { |
|
1281 | + @apache_reset_timeout(); |
|
1282 | + } |
|
1235 | 1283 | |
1236 | 1284 | // Have we exhausted all the time we allowed? |
1237 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
1238 | - return; |
|
1285 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
1286 | + return; |
|
1287 | + } |
|
1239 | 1288 | |
1240 | 1289 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1241 | 1290 | $context['page_title'] = $txt['not_done_title']; |
@@ -1281,9 +1330,10 @@ discard block |
||
1281 | 1330 | $disable_fields = array_flip($standard_fields); |
1282 | 1331 | if (!empty($_POST['active'])) |
1283 | 1332 | { |
1284 | - foreach ($_POST['active'] as $value) |
|
1285 | - if (isset($disable_fields[$value])) |
|
1333 | + foreach ($_POST['active'] as $value) { |
|
1334 | + if (isset($disable_fields[$value])) |
|
1286 | 1335 | unset($disable_fields[$value]); |
1336 | + } |
|
1287 | 1337 | } |
1288 | 1338 | // What we have left! |
1289 | 1339 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1292,16 +1342,18 @@ discard block |
||
1292 | 1342 | $reg_fields = array(); |
1293 | 1343 | if (!empty($_POST['reg'])) |
1294 | 1344 | { |
1295 | - foreach ($_POST['reg'] as $value) |
|
1296 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1345 | + foreach ($_POST['reg'] as $value) { |
|
1346 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1297 | 1347 | $reg_fields[] = $value; |
1348 | + } |
|
1298 | 1349 | } |
1299 | 1350 | // What we have left! |
1300 | 1351 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
1301 | 1352 | |
1302 | 1353 | $_SESSION['adm-save'] = true; |
1303 | - if (!empty($changes)) |
|
1304 | - updateSettings($changes); |
|
1354 | + if (!empty($changes)) { |
|
1355 | + updateSettings($changes); |
|
1356 | + } |
|
1305 | 1357 | } |
1306 | 1358 | |
1307 | 1359 | createToken('admin-scp'); |
@@ -1404,11 +1456,13 @@ discard block |
||
1404 | 1456 | { |
1405 | 1457 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
1406 | 1458 | |
1407 | - if ($rowData['field_order'] > 1) |
|
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1459 | + if ($rowData['field_order'] > 1) { |
|
1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1461 | + } |
|
1409 | 1462 | |
1410 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
1411 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1463 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
1464 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1465 | + } |
|
1412 | 1466 | |
1413 | 1467 | $return .= '</p>'; |
1414 | 1468 | |
@@ -1546,16 +1600,16 @@ discard block |
||
1546 | 1600 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
1547 | 1601 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
1548 | 1602 | |
1549 | - foreach ($standard_fields as $field) |
|
1550 | - $list[] = array( |
|
1603 | + foreach ($standard_fields as $field) { |
|
1604 | + $list[] = array( |
|
1551 | 1605 | 'id' => $field, |
1552 | 1606 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
1553 | 1607 | 'disabled' => in_array($field, $disabled_fields), |
1554 | 1608 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
1555 | 1609 | 'can_show_register' => !in_array($field, $fields_no_registration), |
1556 | 1610 | ); |
1557 | - } |
|
1558 | - else |
|
1611 | + } |
|
1612 | + } else |
|
1559 | 1613 | { |
1560 | 1614 | // Load all the fields. |
1561 | 1615 | $request = $smcFunc['db_query']('', ' |
@@ -1569,8 +1623,9 @@ discard block |
||
1569 | 1623 | 'items_per_page' => $items_per_page, |
1570 | 1624 | ) |
1571 | 1625 | ); |
1572 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1573 | - $list[] = $row; |
|
1626 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1627 | + $list[] = $row; |
|
1628 | + } |
|
1574 | 1629 | $smcFunc['db_free_result']($request); |
1575 | 1630 | } |
1576 | 1631 | |
@@ -1636,9 +1691,9 @@ discard block |
||
1636 | 1691 | $context['field'] = array(); |
1637 | 1692 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1638 | 1693 | { |
1639 | - if ($row['field_type'] == 'textarea') |
|
1640 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1641 | - else |
|
1694 | + if ($row['field_type'] == 'textarea') { |
|
1695 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1696 | + } else |
|
1642 | 1697 | { |
1643 | 1698 | $rows = 3; |
1644 | 1699 | $cols = 30; |
@@ -1674,8 +1729,8 @@ discard block |
||
1674 | 1729 | } |
1675 | 1730 | |
1676 | 1731 | // Setup the default values as needed. |
1677 | - if (empty($context['field'])) |
|
1678 | - $context['field'] = array( |
|
1732 | + if (empty($context['field'])) { |
|
1733 | + $context['field'] = array( |
|
1679 | 1734 | 'name' => '', |
1680 | 1735 | 'col_name' => '???', |
1681 | 1736 | 'desc' => '', |
@@ -1700,6 +1755,7 @@ discard block |
||
1700 | 1755 | 'enclose' => '', |
1701 | 1756 | 'placement' => 0, |
1702 | 1757 | ); |
1758 | + } |
|
1703 | 1759 | |
1704 | 1760 | // Are we moving it? |
1705 | 1761 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1708,8 +1764,10 @@ discard block |
||
1708 | 1764 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
1709 | 1765 | |
1710 | 1766 | // Is this a valid position? |
1711 | - if ($new_order <= 0 || $new_order > $order_count) |
|
1712 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
1767 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
1768 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
1769 | + } |
|
1770 | + // @todo implement an error handler |
|
1713 | 1771 | |
1714 | 1772 | // All good, proceed. |
1715 | 1773 | $smcFunc['db_query']('',' |
@@ -1740,12 +1798,14 @@ discard block |
||
1740 | 1798 | validateToken('admin-ecp'); |
1741 | 1799 | |
1742 | 1800 | // Everyone needs a name - even the (bracket) unknown... |
1743 | - if (trim($_POST['field_name']) == '') |
|
1744 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1801 | + if (trim($_POST['field_name']) == '') { |
|
1802 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1803 | + } |
|
1745 | 1804 | |
1746 | 1805 | // Regex you say? Do a very basic test to see if the pattern is valid |
1747 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
1748 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1806 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
1807 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1808 | + } |
|
1749 | 1809 | |
1750 | 1810 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
1751 | 1811 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1762,8 +1822,9 @@ discard block |
||
1762 | 1822 | |
1763 | 1823 | // Some masking stuff... |
1764 | 1824 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
1765 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
1766 | - $mask .= $_POST['regex']; |
|
1825 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
1826 | + $mask .= $_POST['regex']; |
|
1827 | + } |
|
1767 | 1828 | |
1768 | 1829 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
1769 | 1830 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1782,8 +1843,9 @@ discard block |
||
1782 | 1843 | $v = strtr($v, array(',' => '')); |
1783 | 1844 | |
1784 | 1845 | // Nada, zip, etc... |
1785 | - if (trim($v) == '') |
|
1786 | - continue; |
|
1846 | + if (trim($v) == '') { |
|
1847 | + continue; |
|
1848 | + } |
|
1787 | 1849 | |
1788 | 1850 | // Otherwise, save it boy. |
1789 | 1851 | $field_options .= $v . ','; |
@@ -1791,15 +1853,17 @@ discard block |
||
1791 | 1853 | $newOptions[$k] = $v; |
1792 | 1854 | |
1793 | 1855 | // Is it default? |
1794 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
1795 | - $default = $v; |
|
1856 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
1857 | + $default = $v; |
|
1858 | + } |
|
1796 | 1859 | } |
1797 | 1860 | $field_options = substr($field_options, 0, -1); |
1798 | 1861 | } |
1799 | 1862 | |
1800 | 1863 | // Text area has default has dimensions |
1801 | - if ($_POST['field_type'] == 'textarea') |
|
1802 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1864 | + if ($_POST['field_type'] == 'textarea') { |
|
1865 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1866 | + } |
|
1803 | 1867 | |
1804 | 1868 | // Come up with the unique name? |
1805 | 1869 | if (empty($context['fid'])) |
@@ -1808,32 +1872,36 @@ discard block |
||
1808 | 1872 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
1809 | 1873 | |
1810 | 1874 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
1811 | - if (isset($matches[1])) |
|
1812 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1813 | - else |
|
1814 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1875 | + if (isset($matches[1])) { |
|
1876 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1877 | + } else { |
|
1878 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1879 | + } |
|
1815 | 1880 | |
1816 | 1881 | // Make sure this is unique. |
1817 | 1882 | $current_fields = array(); |
1818 | 1883 | $request = $smcFunc['db_query']('', ' |
1819 | 1884 | SELECT id_field, col_name |
1820 | 1885 | FROM {db_prefix}custom_fields'); |
1821 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1822 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
1886 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1887 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
1888 | + } |
|
1823 | 1889 | $smcFunc['db_free_result']($request); |
1824 | 1890 | |
1825 | 1891 | $unique = false; |
1826 | 1892 | for ($i = 0; !$unique && $i < 9; $i ++) |
1827 | 1893 | { |
1828 | - if (!in_array($col_name, $current_fields)) |
|
1829 | - $unique = true; |
|
1830 | - else |
|
1831 | - $col_name = $initial_col_name . $i; |
|
1894 | + if (!in_array($col_name, $current_fields)) { |
|
1895 | + $unique = true; |
|
1896 | + } else { |
|
1897 | + $col_name = $initial_col_name . $i; |
|
1898 | + } |
|
1832 | 1899 | } |
1833 | 1900 | |
1834 | 1901 | // Still not a unique column name? Leave it up to the user, then. |
1835 | - if (!$unique) |
|
1836 | - fatal_lang_error('custom_option_not_unique'); |
|
1902 | + if (!$unique) { |
|
1903 | + fatal_lang_error('custom_option_not_unique'); |
|
1904 | + } |
|
1837 | 1905 | } |
1838 | 1906 | // Work out what to do with the user data otherwise... |
1839 | 1907 | else |
@@ -1861,8 +1929,9 @@ discard block |
||
1861 | 1929 | // Work out what's changed! |
1862 | 1930 | foreach ($context['field']['options'] as $k => $option) |
1863 | 1931 | { |
1864 | - if (trim($option) == '') |
|
1865 | - continue; |
|
1932 | + if (trim($option) == '') { |
|
1933 | + continue; |
|
1934 | + } |
|
1866 | 1935 | |
1867 | 1936 | // Still exists? |
1868 | 1937 | if (in_array($option, $newOptions)) |
@@ -1876,8 +1945,8 @@ discard block |
||
1876 | 1945 | foreach ($optionChanges as $k => $option) |
1877 | 1946 | { |
1878 | 1947 | // Just been renamed? |
1879 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
1880 | - $smcFunc['db_query']('', ' |
|
1948 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
1949 | + $smcFunc['db_query']('', ' |
|
1881 | 1950 | UPDATE {db_prefix}themes |
1882 | 1951 | SET value = {string:new_value} |
1883 | 1952 | WHERE variable = {string:current_column} |
@@ -1890,6 +1959,7 @@ discard block |
||
1890 | 1959 | 'old_value' => $option, |
1891 | 1960 | ) |
1892 | 1961 | ); |
1962 | + } |
|
1893 | 1963 | } |
1894 | 1964 | } |
1895 | 1965 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1932,8 +2002,8 @@ discard block |
||
1932 | 2002 | ); |
1933 | 2003 | |
1934 | 2004 | // Just clean up any old selects - these are a pain! |
1935 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
1936 | - $smcFunc['db_query']('', ' |
|
2005 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
2006 | + $smcFunc['db_query']('', ' |
|
1937 | 2007 | DELETE FROM {db_prefix}themes |
1938 | 2008 | WHERE variable = {string:current_column} |
1939 | 2009 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1944,8 +2014,8 @@ discard block |
||
1944 | 2014 | 'current_column' => $context['field']['col_name'], |
1945 | 2015 | ) |
1946 | 2016 | ); |
1947 | - } |
|
1948 | - else |
|
2017 | + } |
|
2018 | + } else |
|
1949 | 2019 | { |
1950 | 2020 | // Gotta figure it out the order. |
1951 | 2021 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2120,11 +2190,13 @@ discard block |
||
2120 | 2190 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
2121 | 2191 | |
2122 | 2192 | $prune_toggle_dt = array(); |
2123 | - foreach ($prune_toggle as $item) |
|
2124 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
2193 | + foreach ($prune_toggle as $item) { |
|
2194 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
2195 | + } |
|
2125 | 2196 | |
2126 | - if ($return_config) |
|
2127 | - return $config_vars; |
|
2197 | + if ($return_config) { |
|
2198 | + return $config_vars; |
|
2199 | + } |
|
2128 | 2200 | |
2129 | 2201 | addInlineJavaScript(' |
2130 | 2202 | function togglePruned() |
@@ -2162,15 +2234,16 @@ discard block |
||
2162 | 2234 | $vals = array(); |
2163 | 2235 | foreach ($config_vars as $index => $dummy) |
2164 | 2236 | { |
2165 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
2166 | - continue; |
|
2237 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
2238 | + continue; |
|
2239 | + } |
|
2167 | 2240 | |
2168 | 2241 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
2169 | 2242 | } |
2170 | 2243 | $_POST['pruningOptions'] = implode(',', $vals); |
2244 | + } else { |
|
2245 | + $_POST['pruningOptions'] = ''; |
|
2171 | 2246 | } |
2172 | - else |
|
2173 | - $_POST['pruningOptions'] = ''; |
|
2174 | 2247 | |
2175 | 2248 | saveDBSettings($savevar); |
2176 | 2249 | $_SESSION['adm-save'] = true; |
@@ -2182,10 +2255,11 @@ discard block |
||
2182 | 2255 | $context['sub_template'] = 'show_settings'; |
2183 | 2256 | |
2184 | 2257 | // Get the actual values |
2185 | - if (!empty($modSettings['pruningOptions'])) |
|
2186 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2187 | - else |
|
2188 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2258 | + if (!empty($modSettings['pruningOptions'])) { |
|
2259 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2260 | + } else { |
|
2261 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2262 | + } |
|
2189 | 2263 | |
2190 | 2264 | prepareDBSettingContext($config_vars); |
2191 | 2265 | } |
@@ -2207,8 +2281,9 @@ discard block |
||
2207 | 2281 | // Make it even easier to add new settings. |
2208 | 2282 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
2209 | 2283 | |
2210 | - if ($return_config) |
|
2211 | - return $config_vars; |
|
2284 | + if ($return_config) { |
|
2285 | + return $config_vars; |
|
2286 | + } |
|
2212 | 2287 | |
2213 | 2288 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
2214 | 2289 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * This function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
24 | 25 | global $time_start, $smcFunc; |
25 | 26 | |
26 | 27 | // Special case for doing the mail queue. |
27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
28 | - ReduceMailQueue(); |
|
29 | - else |
|
28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
29 | + ReduceMailQueue(); |
|
30 | + } else |
|
30 | 31 | { |
31 | 32 | $task_string = ''; |
32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
53 | 54 | |
54 | 55 | // How long in seconds it the gap? |
55 | 56 | $duration = $row['time_regularity']; |
56 | - if ($row['time_unit'] == 'm') |
|
57 | - $duration *= 60; |
|
58 | - elseif ($row['time_unit'] == 'h') |
|
59 | - $duration *= 3600; |
|
60 | - elseif ($row['time_unit'] == 'd') |
|
61 | - $duration *= 86400; |
|
62 | - elseif ($row['time_unit'] == 'w') |
|
63 | - $duration *= 604800; |
|
57 | + if ($row['time_unit'] == 'm') { |
|
58 | + $duration *= 60; |
|
59 | + } elseif ($row['time_unit'] == 'h') { |
|
60 | + $duration *= 3600; |
|
61 | + } elseif ($row['time_unit'] == 'd') { |
|
62 | + $duration *= 86400; |
|
63 | + } elseif ($row['time_unit'] == 'w') { |
|
64 | + $duration *= 604800; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | // If we were really late running this task actually skip the next one. |
66 | - if (time() + ($duration / 2) > $next_time) |
|
67 | - $next_time += $duration; |
|
68 | + if (time() + ($duration / 2) > $next_time) { |
|
69 | + $next_time += $duration; |
|
70 | + } |
|
68 | 71 | |
69 | 72 | // Update it now, so no others run this! |
70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
82 | 85 | |
83 | 86 | // What kind of task are we handling? |
84 | - if (!empty($row['callable'])) |
|
85 | - $task_string = $row['callable']; |
|
87 | + if (!empty($row['callable'])) { |
|
88 | + $task_string = $row['callable']; |
|
89 | + } |
|
86 | 90 | |
87 | 91 | // Default SMF task or old mods? |
88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
89 | - $task_string = 'scheduled_' . $row['task']; |
|
92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
93 | + $task_string = 'scheduled_' . $row['task']; |
|
94 | + } |
|
90 | 95 | |
91 | 96 | // One last resource, the task name. |
92 | - elseif (!empty($row['task'])) |
|
93 | - $task_string = $row['task']; |
|
97 | + elseif (!empty($row['task'])) { |
|
98 | + $task_string = $row['task']; |
|
99 | + } |
|
94 | 100 | |
95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
101 | 107 | $callable_task = call_helper($task_string, true); |
102 | 108 | |
103 | 109 | // Perform the task. |
104 | - if (!empty($callable_task)) |
|
105 | - $completed = call_user_func($callable_task); |
|
106 | - |
|
107 | - else |
|
108 | - $completed = false; |
|
110 | + if (!empty($callable_task)) { |
|
111 | + $completed = call_user_func($callable_task); |
|
112 | + } else { |
|
113 | + $completed = false; |
|
114 | + } |
|
109 | 115 | |
110 | 116 | // Log that we did it ;) |
111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
138 | 144 | ) |
139 | 145 | ); |
140 | 146 | // No new task scheduled yet? |
141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
142 | - $nextEvent = time() + 86400; |
|
143 | - else |
|
144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
148 | + $nextEvent = time() + 86400; |
|
149 | + } else { |
|
150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
151 | + } |
|
145 | 152 | $smcFunc['db_free_result']($request); |
146 | 153 | |
147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
148 | 155 | } |
149 | 156 | |
150 | 157 | // Shall we return? |
151 | - if (!isset($_GET['scheduled'])) |
|
152 | - return true; |
|
158 | + if (!isset($_GET['scheduled'])) { |
|
159 | + return true; |
|
160 | + } |
|
153 | 161 | |
154 | 162 | // Finally, send some stuff... |
155 | 163 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
182 | 190 | { |
183 | 191 | // If this is no longer around we'll ignore it. |
184 | - if (empty($row['id_topic'])) |
|
185 | - continue; |
|
192 | + if (empty($row['id_topic'])) { |
|
193 | + continue; |
|
194 | + } |
|
186 | 195 | |
187 | 196 | // What type is it? |
188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
189 | - $type = 'topic'; |
|
190 | - elseif ($row['id_attach']) |
|
191 | - $type = 'attach'; |
|
192 | - else |
|
193 | - $type = 'msg'; |
|
197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
198 | + $type = 'topic'; |
|
199 | + } elseif ($row['id_attach']) { |
|
200 | + $type = 'attach'; |
|
201 | + } else { |
|
202 | + $type = 'msg'; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | // Add it to the array otherwise. |
196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
211 | 221 | ); |
212 | 222 | |
213 | 223 | // If nothing quit now. |
214 | - if (empty($notices)) |
|
215 | - return true; |
|
224 | + if (empty($notices)) { |
|
225 | + return true; |
|
226 | + } |
|
216 | 227 | |
217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
232 | 243 | { |
233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
234 | - if ($row['id_group'] < 2) |
|
235 | - continue; |
|
245 | + if ($row['id_group'] < 2) { |
|
246 | + continue; |
|
247 | + } |
|
236 | 248 | |
237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
238 | 250 | |
239 | 251 | // Anyone who can access has to be considered. |
240 | - if ($row['add_deny']) |
|
241 | - $addGroups[] = $row['id_group']; |
|
252 | + if ($row['add_deny']) { |
|
253 | + $addGroups[] = $row['id_group']; |
|
254 | + } |
|
242 | 255 | } |
243 | 256 | $smcFunc['db_free_result']($request); |
244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
283 | 296 | if (!empty($row['mod_prefs'])) |
284 | 297 | { |
285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
286 | - if (!($pref_binary & 4)) |
|
287 | - continue; |
|
299 | + if (!($pref_binary & 4)) { |
|
300 | + continue; |
|
301 | + } |
|
288 | 302 | } |
289 | 303 | |
290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
309 | 323 | $emailbody = ''; |
310 | 324 | |
311 | 325 | // Load the language file as required. |
312 | - if (empty($current_language) || $current_language != $member['language']) |
|
313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
328 | + } |
|
314 | 329 | |
315 | 330 | // Loop through each notice... |
316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
318 | 333 | $access = false; |
319 | 334 | |
320 | 335 | // Can they mod in this board? |
321 | - if (isset($mods[$id][$board])) |
|
322 | - $access = true; |
|
336 | + if (isset($mods[$id][$board])) { |
|
337 | + $access = true; |
|
338 | + } |
|
323 | 339 | |
324 | 340 | // Do the group check... |
325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
326 | 342 | { |
327 | 343 | // They can access?! |
328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
329 | - $access = true; |
|
344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
345 | + $access = true; |
|
346 | + } |
|
330 | 347 | |
331 | 348 | // If they have deny rights don't consider them! |
332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
334 | 351 | $access = false; |
352 | + } |
|
335 | 353 | } |
336 | 354 | |
337 | 355 | // Finally, fix it for admins! |
338 | - if (in_array(1, $member['groups'])) |
|
339 | - $access = true; |
|
356 | + if (in_array(1, $member['groups'])) { |
|
357 | + $access = true; |
|
358 | + } |
|
340 | 359 | |
341 | 360 | // If they can't access it then give it a break! |
342 | - if (!$access) |
|
343 | - continue; |
|
361 | + if (!$access) { |
|
362 | + continue; |
|
363 | + } |
|
344 | 364 | |
345 | 365 | foreach ($notice as $type => $items) |
346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
349 | 369 | '------------------------------------------------------' . "\n"; |
350 | 370 | |
351 | - foreach ($items as $item) |
|
352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
371 | + foreach ($items as $item) { |
|
372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
373 | + } |
|
353 | 374 | |
354 | 375 | $emailbody .= "\n"; |
355 | 376 | } |
356 | 377 | } |
357 | 378 | |
358 | - if ($emailbody == '') |
|
359 | - continue; |
|
379 | + if ($emailbody == '') { |
|
380 | + continue; |
|
381 | + } |
|
360 | 382 | |
361 | 383 | $replacements = array( |
362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
397 | 419 | ) |
398 | 420 | ); |
399 | 421 | $members = array(); |
400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
401 | - $members[$row['id_member']] = $row['warning']; |
|
422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
423 | + $members[$row['id_member']] = $row['warning']; |
|
424 | + } |
|
402 | 425 | $smcFunc['db_free_result']($request); |
403 | 426 | |
404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
421 | 444 | { |
422 | 445 | // More than 24 hours ago? |
423 | - if ($row['last_warning'] <= time() - 86400) |
|
424 | - $member_changes[] = array( |
|
446 | + if ($row['last_warning'] <= time() - 86400) { |
|
447 | + $member_changes[] = array( |
|
425 | 448 | 'id' => $row['id_recipient'], |
426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
427 | 450 | ); |
451 | + } |
|
428 | 452 | } |
429 | 453 | $smcFunc['db_free_result']($request); |
430 | 454 | |
431 | 455 | // Have some members to change? |
432 | - if (!empty($member_changes)) |
|
433 | - foreach ($member_changes as $change) |
|
456 | + if (!empty($member_changes)) { |
|
457 | + foreach ($member_changes as $change) |
|
434 | 458 | $smcFunc['db_query']('', ' |
435 | 459 | UPDATE {db_prefix}members |
436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
440 | 464 | 'id_member' => $change['id'], |
441 | 465 | ) |
442 | 466 | ); |
467 | + } |
|
443 | 468 | } |
444 | 469 | } |
445 | 470 | |
@@ -519,15 +544,17 @@ discard block |
||
519 | 544 | |
520 | 545 | // Store this useful data! |
521 | 546 | $boards[$row['id_board']] = $row['id_board']; |
522 | - if ($row['id_topic']) |
|
523 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
524 | - else |
|
525 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
547 | + if ($row['id_topic']) { |
|
548 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
549 | + } else { |
|
550 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
551 | + } |
|
526 | 552 | } |
527 | 553 | $smcFunc['db_free_result']($request); |
528 | 554 | |
529 | - if (empty($boards)) |
|
530 | - return true; |
|
555 | + if (empty($boards)) { |
|
556 | + return true; |
|
557 | + } |
|
531 | 558 | |
532 | 559 | // Just get the board names. |
533 | 560 | $request = $smcFunc['db_query']('', ' |
@@ -539,12 +566,14 @@ discard block |
||
539 | 566 | ) |
540 | 567 | ); |
541 | 568 | $boards = array(); |
542 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
543 | - $boards[$row['id_board']] = $row['name']; |
|
569 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
570 | + $boards[$row['id_board']] = $row['name']; |
|
571 | + } |
|
544 | 572 | $smcFunc['db_free_result']($request); |
545 | 573 | |
546 | - if (empty($boards)) |
|
547 | - return true; |
|
574 | + if (empty($boards)) { |
|
575 | + return true; |
|
576 | + } |
|
548 | 577 | |
549 | 578 | // Get the actual topics... |
550 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -564,52 +593,57 @@ discard block |
||
564 | 593 | $types = array(); |
565 | 594 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
566 | 595 | { |
567 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
568 | - $types[$row['note_type']][$row['id_board']] = array( |
|
596 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
597 | + $types[$row['note_type']][$row['id_board']] = array( |
|
569 | 598 | 'lines' => array(), |
570 | 599 | 'name' => $row['board_name'], |
571 | 600 | 'id' => $row['id_board'], |
572 | 601 | ); |
602 | + } |
|
573 | 603 | |
574 | 604 | if ($row['note_type'] == 'reply') |
575 | 605 | { |
576 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
577 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
578 | - else |
|
579 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
606 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
607 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
608 | + } else { |
|
609 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
580 | 610 | 'id' => $row['id_topic'], |
581 | 611 | 'subject' => un_htmlspecialchars($row['subject']), |
582 | 612 | 'count' => 1, |
583 | 613 | ); |
584 | - } |
|
585 | - elseif ($row['note_type'] == 'topic') |
|
614 | + } |
|
615 | + } elseif ($row['note_type'] == 'topic') |
|
586 | 616 | { |
587 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
588 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
617 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
618 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
589 | 619 | 'id' => $row['id_topic'], |
590 | 620 | 'subject' => un_htmlspecialchars($row['subject']), |
591 | 621 | ); |
592 | - } |
|
593 | - else |
|
622 | + } |
|
623 | + } else |
|
594 | 624 | { |
595 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
596 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
625 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
626 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
597 | 627 | 'id' => $row['id_topic'], |
598 | 628 | 'subject' => un_htmlspecialchars($row['subject']), |
599 | 629 | 'starter' => $row['id_member_started'], |
600 | 630 | ); |
631 | + } |
|
601 | 632 | } |
602 | 633 | |
603 | 634 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
604 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
605 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
606 | - if (!empty($notify['boards'][$row['id_board']])) |
|
607 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
635 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
636 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
637 | + } |
|
638 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
639 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
640 | + } |
|
608 | 641 | } |
609 | 642 | $smcFunc['db_free_result']($request); |
610 | 643 | |
611 | - if (empty($types)) |
|
612 | - return true; |
|
644 | + if (empty($types)) { |
|
645 | + return true; |
|
646 | + } |
|
613 | 647 | |
614 | 648 | // Let's load all the languages into a cache thingy. |
615 | 649 | $langtxt = array(); |
@@ -650,8 +684,9 @@ discard block |
||
650 | 684 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
651 | 685 | |
652 | 686 | // Did they not elect to choose this? |
653 | - if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
654 | - continue; |
|
687 | + if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
688 | + continue; |
|
689 | + } |
|
655 | 690 | |
656 | 691 | // Right character set! |
657 | 692 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -667,39 +702,43 @@ discard block |
||
667 | 702 | if (isset($types['topic'])) |
668 | 703 | { |
669 | 704 | $titled = false; |
670 | - foreach ($types['topic'] as $id => $board) |
|
671 | - foreach ($board['lines'] as $topic) |
|
705 | + foreach ($types['topic'] as $id => $board) { |
|
706 | + foreach ($board['lines'] as $topic) |
|
672 | 707 | if (in_array($mid, $topic['members'])) |
673 | 708 | { |
674 | 709 | if (!$titled) |
675 | 710 | { |
676 | 711 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
712 | + } |
|
677 | 713 | $titled = true; |
678 | 714 | } |
679 | 715 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
680 | 716 | } |
681 | - if ($titled) |
|
682 | - $email['body'] .= "\n"; |
|
717 | + if ($titled) { |
|
718 | + $email['body'] .= "\n"; |
|
719 | + } |
|
683 | 720 | } |
684 | 721 | |
685 | 722 | // What about replies? |
686 | 723 | if (isset($types['reply'])) |
687 | 724 | { |
688 | 725 | $titled = false; |
689 | - foreach ($types['reply'] as $id => $board) |
|
690 | - foreach ($board['lines'] as $topic) |
|
726 | + foreach ($types['reply'] as $id => $board) { |
|
727 | + foreach ($board['lines'] as $topic) |
|
691 | 728 | if (in_array($mid, $topic['members'])) |
692 | 729 | { |
693 | 730 | if (!$titled) |
694 | 731 | { |
695 | 732 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
733 | + } |
|
696 | 734 | $titled = true; |
697 | 735 | } |
698 | 736 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
699 | 737 | } |
700 | 738 | |
701 | - if ($titled) |
|
702 | - $email['body'] .= "\n"; |
|
739 | + if ($titled) { |
|
740 | + $email['body'] .= "\n"; |
|
741 | + } |
|
703 | 742 | } |
704 | 743 | |
705 | 744 | // Finally, moderation actions! |
@@ -708,24 +747,27 @@ discard block |
||
708 | 747 | $titled = false; |
709 | 748 | foreach ($types as $note_type => $type) |
710 | 749 | { |
711 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
712 | - continue; |
|
750 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
751 | + continue; |
|
752 | + } |
|
713 | 753 | |
714 | - foreach ($type as $id => $board) |
|
715 | - foreach ($board['lines'] as $topic) |
|
754 | + foreach ($type as $id => $board) { |
|
755 | + foreach ($board['lines'] as $topic) |
|
716 | 756 | if (in_array($mid, $topic['members'])) |
717 | 757 | { |
718 | 758 | if (!$titled) |
719 | 759 | { |
720 | 760 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
761 | + } |
|
721 | 762 | $titled = true; |
722 | 763 | } |
723 | 764 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
724 | 765 | } |
725 | 766 | } |
726 | 767 | } |
727 | - if ($titled) |
|
728 | - $email['body'] .= "\n"; |
|
768 | + if ($titled) { |
|
769 | + $email['body'] .= "\n"; |
|
770 | + } |
|
729 | 771 | |
730 | 772 | // Then just say our goodbyes! |
731 | 773 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -753,8 +795,7 @@ discard block |
||
753 | 795 | 'not_daily' => 0, |
754 | 796 | ) |
755 | 797 | ); |
756 | - } |
|
757 | - else |
|
798 | + } else |
|
758 | 799 | { |
759 | 800 | // Clear any only weekly ones, and stop us from sending daily again. |
760 | 801 | $smcFunc['db_query']('', ' |
@@ -816,16 +857,19 @@ discard block |
||
816 | 857 | global $modSettings, $smcFunc, $sourcedir; |
817 | 858 | |
818 | 859 | // Are we intending another script to be sending out the queue? |
819 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
820 | - return false; |
|
860 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
861 | + return false; |
|
862 | + } |
|
821 | 863 | |
822 | 864 | // By default send 5 at once. |
823 | - if (!$number) |
|
824 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
865 | + if (!$number) { |
|
866 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
867 | + } |
|
825 | 868 | |
826 | 869 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
827 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
828 | - return false; |
|
870 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
871 | + return false; |
|
872 | + } |
|
829 | 873 | |
830 | 874 | // By default move the next sending on by 10 seconds, and require an affected row. |
831 | 875 | if (!$override_limit) |
@@ -842,8 +886,9 @@ discard block |
||
842 | 886 | 'last_send' => $modSettings['mail_next_send'], |
843 | 887 | ) |
844 | 888 | ); |
845 | - if ($smcFunc['db_affected_rows']() == 0) |
|
846 | - return false; |
|
889 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
890 | + return false; |
|
891 | + } |
|
847 | 892 | $modSettings['mail_next_send'] = time() + $delay; |
848 | 893 | } |
849 | 894 | |
@@ -864,8 +909,9 @@ discard block |
||
864 | 909 | $mn += $number; |
865 | 910 | } |
866 | 911 | // No more I'm afraid, return! |
867 | - else |
|
868 | - return false; |
|
912 | + else { |
|
913 | + return false; |
|
914 | + } |
|
869 | 915 | |
870 | 916 | // Reflect that we're about to send some, do it now to be safe. |
871 | 917 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -900,14 +946,15 @@ discard block |
||
900 | 946 | $smcFunc['db_free_result']($request); |
901 | 947 | |
902 | 948 | // Delete, delete, delete!!! |
903 | - if (!empty($ids)) |
|
904 | - $smcFunc['db_query']('', ' |
|
949 | + if (!empty($ids)) { |
|
950 | + $smcFunc['db_query']('', ' |
|
905 | 951 | DELETE FROM {db_prefix}mail_queue |
906 | 952 | WHERE id_mail IN ({array_int:mail_list})', |
907 | 953 | array( |
908 | 954 | 'mail_list' => $ids, |
909 | 955 | ) |
910 | 956 | ); |
957 | + } |
|
911 | 958 | |
912 | 959 | // Don't believe we have any left? |
913 | 960 | if (count($ids) < $number) |
@@ -925,11 +972,13 @@ discard block |
||
925 | 972 | ); |
926 | 973 | } |
927 | 974 | |
928 | - if (empty($ids)) |
|
929 | - return false; |
|
975 | + if (empty($ids)) { |
|
976 | + return false; |
|
977 | + } |
|
930 | 978 | |
931 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
932 | - require_once($sourcedir . '/Subs-Post.php'); |
|
979 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
980 | + require_once($sourcedir . '/Subs-Post.php'); |
|
981 | + } |
|
933 | 982 | |
934 | 983 | // Send each email, yea! |
935 | 984 | $failed_emails = array(); |
@@ -949,15 +998,17 @@ discard block |
||
949 | 998 | |
950 | 999 | // Try to stop a timeout, this would be bad... |
951 | 1000 | @set_time_limit(300); |
952 | - if (function_exists('apache_reset_timeout')) |
|
953 | - @apache_reset_timeout(); |
|
1001 | + if (function_exists('apache_reset_timeout')) { |
|
1002 | + @apache_reset_timeout(); |
|
1003 | + } |
|
1004 | + } else { |
|
1005 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
954 | 1006 | } |
955 | - else |
|
956 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
957 | 1007 | |
958 | 1008 | // Hopefully it sent? |
959 | - if (!$result) |
|
960 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
1009 | + if (!$result) { |
|
1010 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
1011 | + } |
|
961 | 1012 | } |
962 | 1013 | |
963 | 1014 | // Any emails that didn't send? |
@@ -972,8 +1023,8 @@ discard block |
||
972 | 1023 | ); |
973 | 1024 | |
974 | 1025 | // If we have failed to many times, tell mail to wait a bit and try again. |
975 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
976 | - $smcFunc['db_query']('', ' |
|
1026 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
1027 | + $smcFunc['db_query']('', ' |
|
977 | 1028 | UPDATE {db_prefix}settings |
978 | 1029 | SET value = {string:next_mail_send} |
979 | 1030 | WHERE variable = {literal:mail_next_send} |
@@ -982,6 +1033,7 @@ discard block |
||
982 | 1033 | 'next_mail_send' => time() + 60, |
983 | 1034 | 'last_send' => $modSettings['mail_next_send'], |
984 | 1035 | )); |
1036 | + } |
|
985 | 1037 | |
986 | 1038 | // Add our email back to the queue, manually. |
987 | 1039 | $smcFunc['db_insert']('insert', |
@@ -994,8 +1046,8 @@ discard block |
||
994 | 1046 | return false; |
995 | 1047 | } |
996 | 1048 | // We where unable to send the email, clear our failed attempts. |
997 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
998 | - $smcFunc['db_query']('', ' |
|
1049 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
1050 | + $smcFunc['db_query']('', ' |
|
999 | 1051 | UPDATE {db_prefix}settings |
1000 | 1052 | SET value = {string:zero} |
1001 | 1053 | WHERE variable = {string:mail_failed_attempts}', |
@@ -1003,6 +1055,7 @@ discard block |
||
1003 | 1055 | 'zero' => '0', |
1004 | 1056 | 'mail_failed_attempts' => 'mail_failed_attempts', |
1005 | 1057 | )); |
1058 | + } |
|
1006 | 1059 | |
1007 | 1060 | // Had something to send... |
1008 | 1061 | return true; |
@@ -1019,16 +1072,18 @@ discard block |
||
1019 | 1072 | global $modSettings, $smcFunc; |
1020 | 1073 | |
1021 | 1074 | $task_query = ''; |
1022 | - if (!is_array($tasks)) |
|
1023 | - $tasks = array($tasks); |
|
1075 | + if (!is_array($tasks)) { |
|
1076 | + $tasks = array($tasks); |
|
1077 | + } |
|
1024 | 1078 | |
1025 | 1079 | // Actually have something passed? |
1026 | 1080 | if (!empty($tasks)) |
1027 | 1081 | { |
1028 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
1029 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1030 | - else |
|
1031 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
1082 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
1083 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1084 | + } else { |
|
1085 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
1086 | + } |
|
1032 | 1087 | } |
1033 | 1088 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
1034 | 1089 | |
@@ -1049,20 +1104,22 @@ discard block |
||
1049 | 1104 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
1050 | 1105 | |
1051 | 1106 | // Only bother moving the task if it's out of place or we're forcing it! |
1052 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
1053 | - $tasks[$row['id_task']] = $next_time; |
|
1054 | - else |
|
1055 | - $next_time = $row['next_time']; |
|
1107 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
1108 | + $tasks[$row['id_task']] = $next_time; |
|
1109 | + } else { |
|
1110 | + $next_time = $row['next_time']; |
|
1111 | + } |
|
1056 | 1112 | |
1057 | 1113 | // If this is sooner than the current next task, make this the next task. |
1058 | - if ($next_time < $nextTaskTime) |
|
1059 | - $nextTaskTime = $next_time; |
|
1114 | + if ($next_time < $nextTaskTime) { |
|
1115 | + $nextTaskTime = $next_time; |
|
1116 | + } |
|
1060 | 1117 | } |
1061 | 1118 | $smcFunc['db_free_result']($request); |
1062 | 1119 | |
1063 | 1120 | // Now make the changes! |
1064 | - foreach ($tasks as $id => $time) |
|
1065 | - $smcFunc['db_query']('', ' |
|
1121 | + foreach ($tasks as $id => $time) { |
|
1122 | + $smcFunc['db_query']('', ' |
|
1066 | 1123 | UPDATE {db_prefix}scheduled_tasks |
1067 | 1124 | SET next_time = {int:next_time} |
1068 | 1125 | WHERE id_task = {int:id_task}', |
@@ -1071,11 +1128,13 @@ discard block |
||
1071 | 1128 | 'id_task' => $id, |
1072 | 1129 | ) |
1073 | 1130 | ); |
1131 | + } |
|
1074 | 1132 | |
1075 | 1133 | // If the next task is now different update. |
1076 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
1077 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1078 | -} |
|
1134 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
1135 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1136 | + } |
|
1137 | + } |
|
1079 | 1138 | |
1080 | 1139 | /** |
1081 | 1140 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1088,8 +1147,9 @@ discard block |
||
1088 | 1147 | function next_time($regularity, $unit, $offset) |
1089 | 1148 | { |
1090 | 1149 | // Just in case! |
1091 | - if ($regularity == 0) |
|
1092 | - $regularity = 2; |
|
1150 | + if ($regularity == 0) { |
|
1151 | + $regularity = 2; |
|
1152 | + } |
|
1093 | 1153 | |
1094 | 1154 | $curMin = date('i', time()); |
1095 | 1155 | |
@@ -1099,15 +1159,16 @@ discard block |
||
1099 | 1159 | $off = date('i', $offset); |
1100 | 1160 | |
1101 | 1161 | // If it's now just pretend it ain't, |
1102 | - if ($off == $curMin) |
|
1103 | - $next_time = time() + $regularity; |
|
1104 | - else |
|
1162 | + if ($off == $curMin) { |
|
1163 | + $next_time = time() + $regularity; |
|
1164 | + } else |
|
1105 | 1165 | { |
1106 | 1166 | // Make sure that the offset is always in the past. |
1107 | 1167 | $off = $off > $curMin ? $off - 60 : $off; |
1108 | 1168 | |
1109 | - while ($off <= $curMin) |
|
1110 | - $off += $regularity; |
|
1169 | + while ($off <= $curMin) { |
|
1170 | + $off += $regularity; |
|
1171 | + } |
|
1111 | 1172 | |
1112 | 1173 | // Now we know when the time should be! |
1113 | 1174 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1127,11 +1188,13 @@ discard block |
||
1127 | 1188 | // Default we'll jump in hours. |
1128 | 1189 | $applyOffset = 3600; |
1129 | 1190 | // 24 hours = 1 day. |
1130 | - if ($unit == 'd') |
|
1131 | - $applyOffset = 86400; |
|
1191 | + if ($unit == 'd') { |
|
1192 | + $applyOffset = 86400; |
|
1193 | + } |
|
1132 | 1194 | // Otherwise a week. |
1133 | - if ($unit == 'w') |
|
1134 | - $applyOffset = 604800; |
|
1195 | + if ($unit == 'w') { |
|
1196 | + $applyOffset = 604800; |
|
1197 | + } |
|
1135 | 1198 | |
1136 | 1199 | $applyOffset *= $regularity; |
1137 | 1200 | |
@@ -1168,8 +1231,9 @@ discard block |
||
1168 | 1231 | $settings[$row['variable']] = $row['value']; |
1169 | 1232 | |
1170 | 1233 | // Is this the default theme? |
1171 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
1172 | - $settings['default_' . $row['variable']] = $row['value']; |
|
1234 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
1235 | + $settings['default_' . $row['variable']] = $row['value']; |
|
1236 | + } |
|
1173 | 1237 | } |
1174 | 1238 | $smcFunc['db_free_result']($result); |
1175 | 1239 | |
@@ -1179,12 +1243,14 @@ discard block |
||
1179 | 1243 | $settings['template_dirs'] = array($settings['theme_dir']); |
1180 | 1244 | |
1181 | 1245 | // Based on theme (if there is one). |
1182 | - if (!empty($settings['base_theme_dir'])) |
|
1183 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1246 | + if (!empty($settings['base_theme_dir'])) { |
|
1247 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1248 | + } |
|
1184 | 1249 | |
1185 | 1250 | // Lastly the default theme. |
1186 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1187 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1251 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1252 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1253 | + } |
|
1188 | 1254 | } |
1189 | 1255 | |
1190 | 1256 | // Assume we want this. |
@@ -1328,8 +1394,9 @@ discard block |
||
1328 | 1394 | // Ok should we prune the logs? |
1329 | 1395 | if (!empty($modSettings['pruningOptions'])) |
1330 | 1396 | { |
1331 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
1332 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1397 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
1398 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1399 | + } |
|
1333 | 1400 | |
1334 | 1401 | if (!empty($modSettings['pruneErrorLog'])) |
1335 | 1402 | { |
@@ -1395,8 +1462,9 @@ discard block |
||
1395 | 1462 | ) |
1396 | 1463 | ); |
1397 | 1464 | |
1398 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
1399 | - $reports[] = $row[0]; |
|
1465 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
1466 | + $reports[] = $row[0]; |
|
1467 | + } |
|
1400 | 1468 | |
1401 | 1469 | $smcFunc['db_free_result']($result); |
1402 | 1470 | |
@@ -1481,8 +1549,9 @@ discard block |
||
1481 | 1549 | ); |
1482 | 1550 | |
1483 | 1551 | // Run Cache housekeeping |
1484 | - if (!empty($cache_enable) && !empty($cacheAPI)) |
|
1485 | - $cacheAPI->housekeeping(); |
|
1552 | + if (!empty($cache_enable) && !empty($cacheAPI)) { |
|
1553 | + $cacheAPI->housekeeping(); |
|
1554 | + } |
|
1486 | 1555 | |
1487 | 1556 | // Prevent stale minimized CSS and JavaScript from cluttering up the theme directories |
1488 | 1557 | deleteAllMinified(); |
@@ -1565,8 +1634,9 @@ discard block |
||
1565 | 1634 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
1566 | 1635 | |
1567 | 1636 | // Send the actual email. |
1568 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
1569 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1637 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
1638 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1639 | + } |
|
1570 | 1640 | |
1571 | 1641 | if ($notifyPrefs[$row['id_member']] & 0x01) |
1572 | 1642 | { |
@@ -1589,18 +1659,19 @@ discard block |
||
1589 | 1659 | } |
1590 | 1660 | |
1591 | 1661 | // Insert the alerts if any |
1592 | - if (!empty($alert_rows)) |
|
1593 | - $smcFunc['db_insert']('', |
|
1662 | + if (!empty($alert_rows)) { |
|
1663 | + $smcFunc['db_insert']('', |
|
1594 | 1664 | '{db_prefix}user_alerts', |
1595 | 1665 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
1596 | 1666 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
1597 | 1667 | $alert_rows, |
1598 | 1668 | array() |
1599 | 1669 | ); |
1670 | + } |
|
1600 | 1671 | |
1601 | 1672 | // Mark the reminder as sent. |
1602 | - if (!empty($subs_reminded)) |
|
1603 | - $smcFunc['db_query']('', ' |
|
1673 | + if (!empty($subs_reminded)) { |
|
1674 | + $smcFunc['db_query']('', ' |
|
1604 | 1675 | UPDATE {db_prefix}log_subscribed |
1605 | 1676 | SET reminder_sent = {int:reminder_sent} |
1606 | 1677 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1609,6 +1680,7 @@ discard block |
||
1609 | 1680 | 'reminder_sent' => 1, |
1610 | 1681 | ) |
1611 | 1682 | ); |
1683 | + } |
|
1612 | 1684 | |
1613 | 1685 | return true; |
1614 | 1686 | } |
@@ -1624,13 +1696,13 @@ discard block |
||
1624 | 1696 | // We need to know where this thing is going. |
1625 | 1697 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1626 | 1698 | { |
1627 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
1628 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1699 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
1700 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1701 | + } |
|
1629 | 1702 | |
1630 | 1703 | // Just use the current path for temp files. |
1631 | 1704 | $attach_dirs = $modSettings['attachmentUploadDir']; |
1632 | - } |
|
1633 | - else |
|
1705 | + } else |
|
1634 | 1706 | { |
1635 | 1707 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
1636 | 1708 | } |
@@ -1649,14 +1721,16 @@ discard block |
||
1649 | 1721 | |
1650 | 1722 | while ($file = readdir($dir)) |
1651 | 1723 | { |
1652 | - if ($file == '.' || $file == '..') |
|
1653 | - continue; |
|
1724 | + if ($file == '.' || $file == '..') { |
|
1725 | + continue; |
|
1726 | + } |
|
1654 | 1727 | |
1655 | 1728 | if (strpos($file, 'post_tmp_') !== false) |
1656 | 1729 | { |
1657 | 1730 | // Temp file is more than 5 hours old! |
1658 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
1659 | - @unlink($attach_dir . '/' . $file); |
|
1731 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
1732 | + @unlink($attach_dir . '/' . $file); |
|
1733 | + } |
|
1660 | 1734 | } |
1661 | 1735 | } |
1662 | 1736 | closedir($dir); |
@@ -1689,8 +1763,9 @@ discard block |
||
1689 | 1763 | ) |
1690 | 1764 | ); |
1691 | 1765 | |
1692 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1693 | - $topics[] = $row[0]; |
|
1766 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1767 | + $topics[] = $row[0]; |
|
1768 | + } |
|
1694 | 1769 | $smcFunc['db_free_result']($request); |
1695 | 1770 | |
1696 | 1771 | // Zap, your gone |
@@ -1710,8 +1785,9 @@ discard block |
||
1710 | 1785 | { |
1711 | 1786 | global $smcFunc, $sourcedir, $modSettings; |
1712 | 1787 | |
1713 | - if (empty($modSettings['drafts_keep_days'])) |
|
1714 | - return true; |
|
1788 | + if (empty($modSettings['drafts_keep_days'])) { |
|
1789 | + return true; |
|
1790 | + } |
|
1715 | 1791 | |
1716 | 1792 | // init |
1717 | 1793 | $drafts = array(); |
@@ -1729,8 +1805,9 @@ discard block |
||
1729 | 1805 | ) |
1730 | 1806 | ); |
1731 | 1807 | |
1732 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1733 | - $drafts[] = (int) $row[0]; |
|
1808 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1809 | + $drafts[] = (int) $row[0]; |
|
1810 | + } |
|
1734 | 1811 | $smcFunc['db_free_result']($request); |
1735 | 1812 | |
1736 | 1813 | // If we have old one, remove them |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Main dispatcher, the maintenance access point. |
@@ -96,14 +97,16 @@ discard block |
||
96 | 97 | call_integration_hook('integrate_manage_maintenance', array(&$subActions)); |
97 | 98 | |
98 | 99 | // Yep, sub-action time! |
99 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
100 | - $subAction = $_REQUEST['sa']; |
|
101 | - else |
|
102 | - $subAction = 'routine'; |
|
100 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
101 | + $subAction = $_REQUEST['sa']; |
|
102 | + } else { |
|
103 | + $subAction = 'routine'; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | // Doing something special? |
105 | - if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) |
|
106 | - $activity = $_REQUEST['activity']; |
|
107 | + if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) { |
|
108 | + $activity = $_REQUEST['activity']; |
|
109 | + } |
|
107 | 110 | |
108 | 111 | // Set a few things. |
109 | 112 | $context['page_title'] = $txt['maintain_title']; |
@@ -114,12 +117,14 @@ discard block |
||
114 | 117 | call_helper($subActions[$subAction]['function']); |
115 | 118 | |
116 | 119 | // Any special activity? |
117 | - if (isset($activity)) |
|
118 | - call_helper($subActions[$subAction]['activities'][$activity]); |
|
120 | + if (isset($activity)) { |
|
121 | + call_helper($subActions[$subAction]['activities'][$activity]); |
|
122 | + } |
|
119 | 123 | |
120 | 124 | //converted to UTF-8? show a small maintenance info |
121 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
122 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
125 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
126 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
127 | + } |
|
123 | 128 | |
124 | 129 | // Create a maintenance token. Kinda hard to do it any other way. |
125 | 130 | createToken('admin-maint'); |
@@ -141,19 +146,22 @@ discard block |
||
141 | 146 | db_extend('packages'); |
142 | 147 | |
143 | 148 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
144 | - foreach ($colData as $column) |
|
145 | - if ($column['name'] == 'body') |
|
149 | + foreach ($colData as $column) { |
|
150 | + if ($column['name'] == 'body') |
|
146 | 151 | $body_type = $column['type']; |
152 | + } |
|
147 | 153 | |
148 | 154 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
149 | 155 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
150 | 156 | } |
151 | 157 | |
152 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
153 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
154 | - if (isset($_GET['done']) && $_GET['done'] == 'convertentities') |
|
155 | - $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
156 | -} |
|
158 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
159 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
160 | + } |
|
161 | + if (isset($_GET['done']) && $_GET['done'] == 'convertentities') { |
|
162 | + $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
163 | + } |
|
164 | + } |
|
157 | 165 | |
158 | 166 | /** |
159 | 167 | * Supporting function for the routine maintenance area. |
@@ -162,9 +170,10 @@ discard block |
||
162 | 170 | { |
163 | 171 | global $context, $txt; |
164 | 172 | |
165 | - if (isset($_GET['done']) && $_GET['done'] == 'recount') |
|
166 | - $context['maintenance_finished'] = $txt['maintain_recount']; |
|
167 | -} |
|
173 | + if (isset($_GET['done']) && $_GET['done'] == 'recount') { |
|
174 | + $context['maintenance_finished'] = $txt['maintain_recount']; |
|
175 | + } |
|
176 | + } |
|
168 | 177 | |
169 | 178 | /** |
170 | 179 | * Supporting function for the members maintenance area. |
@@ -195,8 +204,9 @@ discard block |
||
195 | 204 | } |
196 | 205 | $smcFunc['db_free_result']($result); |
197 | 206 | |
198 | - if (isset($_GET['done']) && $_GET['done'] == 'recountposts') |
|
199 | - $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
207 | + if (isset($_GET['done']) && $_GET['done'] == 'recountposts') { |
|
208 | + $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
209 | + } |
|
200 | 210 | |
201 | 211 | loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest'); |
202 | 212 | } |
@@ -222,11 +232,12 @@ discard block |
||
222 | 232 | $context['categories'] = array(); |
223 | 233 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
224 | 234 | { |
225 | - if (!isset($context['categories'][$row['id_cat']])) |
|
226 | - $context['categories'][$row['id_cat']] = array( |
|
235 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
236 | + $context['categories'][$row['id_cat']] = array( |
|
227 | 237 | 'name' => $row['cat_name'], |
228 | 238 | 'boards' => array() |
229 | 239 | ); |
240 | + } |
|
230 | 241 | |
231 | 242 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
232 | 243 | 'id' => $row['id_board'], |
@@ -239,11 +250,12 @@ discard block |
||
239 | 250 | require_once($sourcedir . '/Subs-Boards.php'); |
240 | 251 | sortCategories($context['categories']); |
241 | 252 | |
242 | - if (isset($_GET['done']) && $_GET['done'] == 'purgeold') |
|
243 | - $context['maintenance_finished'] = $txt['maintain_old']; |
|
244 | - elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') |
|
245 | - $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
246 | -} |
|
253 | + if (isset($_GET['done']) && $_GET['done'] == 'purgeold') { |
|
254 | + $context['maintenance_finished'] = $txt['maintain_old']; |
|
255 | + } elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') { |
|
256 | + $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
257 | + } |
|
258 | + } |
|
247 | 259 | |
248 | 260 | /** |
249 | 261 | * Find and fix all errors on the forum. |
@@ -351,15 +363,17 @@ discard block |
||
351 | 363 | // Show me your badge! |
352 | 364 | isAllowedTo('admin_forum'); |
353 | 365 | |
354 | - if ($db_type != 'mysql') |
|
355 | - return; |
|
366 | + if ($db_type != 'mysql') { |
|
367 | + return; |
|
368 | + } |
|
356 | 369 | |
357 | 370 | db_extend('packages'); |
358 | 371 | |
359 | 372 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
360 | - foreach ($colData as $column) |
|
361 | - if ($column['name'] == 'body') |
|
373 | + foreach ($colData as $column) { |
|
374 | + if ($column['name'] == 'body') |
|
362 | 375 | $body_type = $column['type']; |
376 | + } |
|
363 | 377 | |
364 | 378 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
365 | 379 | |
@@ -369,33 +383,36 @@ discard block |
||
369 | 383 | validateToken('admin-maint'); |
370 | 384 | |
371 | 385 | // Make it longer so we can do their limit. |
372 | - if ($body_type == 'text') |
|
373 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
386 | + if ($body_type == 'text') { |
|
387 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
388 | + } |
|
374 | 389 | // Shorten the column so we can have a bit (literally per record) less space occupied |
375 | - else |
|
376 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
390 | + else { |
|
391 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
392 | + } |
|
377 | 393 | |
378 | 394 | // 3rd party integrations may be interested in knowning about this. |
379 | 395 | call_integration_hook('integrate_convert_msgbody', array($body_type)); |
380 | 396 | |
381 | 397 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
382 | - foreach ($colData as $column) |
|
383 | - if ($column['name'] == 'body') |
|
398 | + foreach ($colData as $column) { |
|
399 | + if ($column['name'] == 'body') |
|
384 | 400 | $body_type = $column['type']; |
401 | + } |
|
385 | 402 | |
386 | 403 | $context['maintenance_finished'] = $txt[$context['convert_to'] . '_title']; |
387 | 404 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
388 | 405 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
389 | 406 | |
390 | 407 | return; |
391 | - } |
|
392 | - elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
408 | + } elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
393 | 409 | { |
394 | 410 | checkSession(); |
395 | - if (empty($_REQUEST['start'])) |
|
396 | - validateToken('admin-maint'); |
|
397 | - else |
|
398 | - validateToken('admin-convertMsg'); |
|
411 | + if (empty($_REQUEST['start'])) { |
|
412 | + validateToken('admin-maint'); |
|
413 | + } else { |
|
414 | + validateToken('admin-convertMsg'); |
|
415 | + } |
|
399 | 416 | |
400 | 417 | $context['page_title'] = $txt['not_done_title']; |
401 | 418 | $context['continue_post_data'] = ''; |
@@ -427,8 +444,9 @@ discard block |
||
427 | 444 | 'increment' => $increment - 1, |
428 | 445 | ) |
429 | 446 | ); |
430 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
431 | - $id_msg_exceeding[] = $row['id_msg']; |
|
447 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
448 | + $id_msg_exceeding[] = $row['id_msg']; |
|
449 | + } |
|
432 | 450 | $smcFunc['db_free_result']($request); |
433 | 451 | |
434 | 452 | $_REQUEST['start'] += $increment; |
@@ -457,9 +475,9 @@ discard block |
||
457 | 475 | { |
458 | 476 | $query_msg = array_slice($id_msg_exceeding, 0, 100); |
459 | 477 | $context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding)); |
478 | + } else { |
|
479 | + $query_msg = $id_msg_exceeding; |
|
460 | 480 | } |
461 | - else |
|
462 | - $query_msg = $id_msg_exceeding; |
|
463 | 481 | |
464 | 482 | $context['exceeding_messages'] = array(); |
465 | 483 | $request = $smcFunc['db_query']('', ' |
@@ -470,8 +488,9 @@ discard block |
||
470 | 488 | 'messages' => $query_msg, |
471 | 489 | ) |
472 | 490 | ); |
473 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
474 | - $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
491 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
492 | + $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
493 | + } |
|
475 | 494 | $smcFunc['db_free_result']($request); |
476 | 495 | } |
477 | 496 | } |
@@ -495,8 +514,9 @@ discard block |
||
495 | 514 | isAllowedTo('admin_forum'); |
496 | 515 | |
497 | 516 | // Check to see if UTF-8 is currently the default character set. |
498 | - if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') |
|
499 | - fatal_lang_error('entity_convert_only_utf8'); |
|
517 | + if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') { |
|
518 | + fatal_lang_error('entity_convert_only_utf8'); |
|
519 | + } |
|
500 | 520 | |
501 | 521 | // Some starting values. |
502 | 522 | $context['table'] = empty($_REQUEST['table']) ? 0 : (int) $_REQUEST['table']; |
@@ -558,8 +578,9 @@ discard block |
||
558 | 578 | // Make sure we keep stuff unique! |
559 | 579 | $primary_keys = array(); |
560 | 580 | |
561 | - if (function_exists('apache_reset_timeout')) |
|
562 | - @apache_reset_timeout(); |
|
581 | + if (function_exists('apache_reset_timeout')) { |
|
582 | + @apache_reset_timeout(); |
|
583 | + } |
|
563 | 584 | |
564 | 585 | // Get a list of text columns. |
565 | 586 | $columns = array(); |
@@ -570,9 +591,10 @@ discard block |
||
570 | 591 | 'cur_table' => $cur_table, |
571 | 592 | ) |
572 | 593 | ); |
573 | - while ($column_info = $smcFunc['db_fetch_assoc']($request)) |
|
574 | - if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
594 | + while ($column_info = $smcFunc['db_fetch_assoc']($request)) { |
|
595 | + if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
575 | 596 | $columns[] = strtolower($column_info['Field']); |
597 | + } |
|
576 | 598 | |
577 | 599 | // Get the column with the (first) primary key. |
578 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -586,8 +608,9 @@ discard block |
||
586 | 608 | { |
587 | 609 | if ($row['Key_name'] === 'PRIMARY') |
588 | 610 | { |
589 | - if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) |
|
590 | - $primary_key = $row['Column_name']; |
|
611 | + if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) { |
|
612 | + $primary_key = $row['Column_name']; |
|
613 | + } |
|
591 | 614 | |
592 | 615 | $primary_keys[] = $row['Column_name']; |
593 | 616 | } |
@@ -596,8 +619,9 @@ discard block |
||
596 | 619 | |
597 | 620 | // No primary key, no glory. |
598 | 621 | // Same for columns. Just to be sure we've work to do! |
599 | - if (empty($primary_key) || empty($columns)) |
|
600 | - continue; |
|
622 | + if (empty($primary_key) || empty($columns)) { |
|
623 | + continue; |
|
624 | + } |
|
601 | 625 | |
602 | 626 | // Get the maximum value for the primary key. |
603 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -611,8 +635,9 @@ discard block |
||
611 | 635 | list($max_value) = $smcFunc['db_fetch_row']($request); |
612 | 636 | $smcFunc['db_free_result']($request); |
613 | 637 | |
614 | - if (empty($max_value)) |
|
615 | - continue; |
|
638 | + if (empty($max_value)) { |
|
639 | + continue; |
|
640 | + } |
|
616 | 641 | |
617 | 642 | while ($context['start'] <= $max_value) |
618 | 643 | { |
@@ -636,10 +661,11 @@ discard block |
||
636 | 661 | { |
637 | 662 | $insertion_variables = array(); |
638 | 663 | $changes = array(); |
639 | - foreach ($row as $column_name => $column_value) |
|
640 | - if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
664 | + foreach ($row as $column_name => $column_value) { |
|
665 | + if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
641 | 666 | { |
642 | 667 | $changes[] = $column_name . ' = {string:changes_' . $column_name . '}'; |
668 | + } |
|
643 | 669 | $insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,5}|x[0-9a-fA-F]{1,4});~', 'fixchardb__callback', $column_value); |
644 | 670 | } |
645 | 671 | |
@@ -651,8 +677,8 @@ discard block |
||
651 | 677 | } |
652 | 678 | |
653 | 679 | // Update the row. |
654 | - if (!empty($changes)) |
|
655 | - $smcFunc['db_query']('', ' |
|
680 | + if (!empty($changes)) { |
|
681 | + $smcFunc['db_query']('', ' |
|
656 | 682 | UPDATE {db_prefix}' . $cur_table . ' |
657 | 683 | SET |
658 | 684 | ' . implode(', |
@@ -660,6 +686,7 @@ discard block |
||
660 | 686 | WHERE ' . implode(' AND ', $where), |
661 | 687 | $insertion_variables |
662 | 688 | ); |
689 | + } |
|
663 | 690 | } |
664 | 691 | $smcFunc['db_free_result']($request); |
665 | 692 | $context['start'] += 500; |
@@ -700,10 +727,11 @@ discard block |
||
700 | 727 | |
701 | 728 | checkSession('request'); |
702 | 729 | |
703 | - if (!isset($_SESSION['optimized_tables'])) |
|
704 | - validateToken('admin-maint'); |
|
705 | - else |
|
706 | - validateToken('admin-optimize', 'post', false); |
|
730 | + if (!isset($_SESSION['optimized_tables'])) { |
|
731 | + validateToken('admin-maint'); |
|
732 | + } else { |
|
733 | + validateToken('admin-optimize', 'post', false); |
|
734 | + } |
|
707 | 735 | |
708 | 736 | ignore_user_abort(true); |
709 | 737 | db_extend(); |
@@ -719,13 +747,15 @@ discard block |
||
719 | 747 | // Get a list of tables, as well as how many there are. |
720 | 748 | $temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%'); |
721 | 749 | $tables = array(); |
722 | - foreach ($temp_tables as $table) |
|
723 | - $tables[] = array('table_name' => $table); |
|
750 | + foreach ($temp_tables as $table) { |
|
751 | + $tables[] = array('table_name' => $table); |
|
752 | + } |
|
724 | 753 | |
725 | 754 | // If there aren't any tables then I believe that would mean the world has exploded... |
726 | 755 | $context['num_tables'] = count($tables); |
727 | - if ($context['num_tables'] == 0) |
|
728 | - fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
756 | + if ($context['num_tables'] == 0) { |
|
757 | + fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
758 | + } |
|
729 | 759 | |
730 | 760 | $_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
731 | 761 | |
@@ -736,8 +766,9 @@ discard block |
||
736 | 766 | $_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array(); |
737 | 767 | for ($key = $_REQUEST['start']; $context['num_tables'] - 1; $key++) |
738 | 768 | { |
739 | - if (empty($tables[$key])) |
|
740 | - break; |
|
769 | + if (empty($tables[$key])) { |
|
770 | + break; |
|
771 | + } |
|
741 | 772 | |
742 | 773 | // Continue? |
743 | 774 | if (microtime(true) - $time_start > 10) |
@@ -751,8 +782,9 @@ discard block |
||
751 | 782 | createToken('admin-optimize'); |
752 | 783 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">'; |
753 | 784 | |
754 | - if (function_exists('apache_reset_timeout')) |
|
755 | - apache_reset_timeout(); |
|
785 | + if (function_exists('apache_reset_timeout')) { |
|
786 | + apache_reset_timeout(); |
|
787 | + } |
|
756 | 788 | |
757 | 789 | return; |
758 | 790 | } |
@@ -760,11 +792,12 @@ discard block |
||
760 | 792 | // Optimize the table! We use backticks here because it might be a custom table. |
761 | 793 | $data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']); |
762 | 794 | |
763 | - if ($data_freed > 0) |
|
764 | - $_SESSION['optimized_tables'][] = array( |
|
795 | + if ($data_freed > 0) { |
|
796 | + $_SESSION['optimized_tables'][] = array( |
|
765 | 797 | 'name' => $tables[$key]['table_name'], |
766 | 798 | 'data_freed' => $data_freed, |
767 | 799 | ); |
800 | + } |
|
768 | 801 | } |
769 | 802 | |
770 | 803 | // Number of tables, etc... |
@@ -799,10 +832,11 @@ discard block |
||
799 | 832 | checkSession('request'); |
800 | 833 | |
801 | 834 | // validate the request or the loop |
802 | - if (!isset($_REQUEST['step'])) |
|
803 | - validateToken('admin-maint'); |
|
804 | - else |
|
805 | - validateToken('admin-boardrecount'); |
|
835 | + if (!isset($_REQUEST['step'])) { |
|
836 | + validateToken('admin-maint'); |
|
837 | + } else { |
|
838 | + validateToken('admin-boardrecount'); |
|
839 | + } |
|
806 | 840 | |
807 | 841 | $context['page_title'] = $txt['not_done_title']; |
808 | 842 | $context['continue_post_data'] = ''; |
@@ -823,8 +857,9 @@ discard block |
||
823 | 857 | $smcFunc['db_free_result']($request); |
824 | 858 | |
825 | 859 | $increment = min(max(50, ceil($max_topics / 4)), 2000); |
826 | - if (empty($_REQUEST['start'])) |
|
827 | - $_REQUEST['start'] = 0; |
|
860 | + if (empty($_REQUEST['start'])) { |
|
861 | + $_REQUEST['start'] = 0; |
|
862 | + } |
|
828 | 863 | |
829 | 864 | $total_steps = 8; |
830 | 865 | |
@@ -851,8 +886,8 @@ discard block |
||
851 | 886 | 'max_id' => $_REQUEST['start'] + $increment, |
852 | 887 | ) |
853 | 888 | ); |
854 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
855 | - $smcFunc['db_query']('', ' |
|
889 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
890 | + $smcFunc['db_query']('', ' |
|
856 | 891 | UPDATE {db_prefix}topics |
857 | 892 | SET num_replies = {int:num_replies} |
858 | 893 | WHERE id_topic = {int:id_topic}', |
@@ -861,6 +896,7 @@ discard block |
||
861 | 896 | 'id_topic' => $row['id_topic'], |
862 | 897 | ) |
863 | 898 | ); |
899 | + } |
|
864 | 900 | $smcFunc['db_free_result']($request); |
865 | 901 | |
866 | 902 | // Recount unapproved messages |
@@ -879,8 +915,8 @@ discard block |
||
879 | 915 | 'max_id' => $_REQUEST['start'] + $increment, |
880 | 916 | ) |
881 | 917 | ); |
882 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
883 | - $smcFunc['db_query']('', ' |
|
918 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
919 | + $smcFunc['db_query']('', ' |
|
884 | 920 | UPDATE {db_prefix}topics |
885 | 921 | SET unapproved_posts = {int:unapproved_posts} |
886 | 922 | WHERE id_topic = {int:id_topic}', |
@@ -889,6 +925,7 @@ discard block |
||
889 | 925 | 'id_topic' => $row['id_topic'], |
890 | 926 | ) |
891 | 927 | ); |
928 | + } |
|
892 | 929 | $smcFunc['db_free_result']($request); |
893 | 930 | |
894 | 931 | $_REQUEST['start'] += $increment; |
@@ -911,8 +948,8 @@ discard block |
||
911 | 948 | // Update the post count of each board. |
912 | 949 | if ($_REQUEST['step'] <= 1) |
913 | 950 | { |
914 | - if (empty($_REQUEST['start'])) |
|
915 | - $smcFunc['db_query']('', ' |
|
951 | + if (empty($_REQUEST['start'])) { |
|
952 | + $smcFunc['db_query']('', ' |
|
916 | 953 | UPDATE {db_prefix}boards |
917 | 954 | SET num_posts = {int:num_posts} |
918 | 955 | WHERE redirect = {string:redirect}', |
@@ -921,6 +958,7 @@ discard block |
||
921 | 958 | 'redirect' => '', |
922 | 959 | ) |
923 | 960 | ); |
961 | + } |
|
924 | 962 | |
925 | 963 | while ($_REQUEST['start'] < $max_topics) |
926 | 964 | { |
@@ -937,8 +975,8 @@ discard block |
||
937 | 975 | 'is_approved' => 1, |
938 | 976 | ) |
939 | 977 | ); |
940 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
941 | - $smcFunc['db_query']('', ' |
|
978 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
979 | + $smcFunc['db_query']('', ' |
|
942 | 980 | UPDATE {db_prefix}boards |
943 | 981 | SET num_posts = num_posts + {int:real_num_posts} |
944 | 982 | WHERE id_board = {int:id_board}', |
@@ -947,6 +985,7 @@ discard block |
||
947 | 985 | 'real_num_posts' => $row['real_num_posts'], |
948 | 986 | ) |
949 | 987 | ); |
988 | + } |
|
950 | 989 | $smcFunc['db_free_result']($request); |
951 | 990 | |
952 | 991 | $_REQUEST['start'] += $increment; |
@@ -969,14 +1008,15 @@ discard block |
||
969 | 1008 | // Update the topic count of each board. |
970 | 1009 | if ($_REQUEST['step'] <= 2) |
971 | 1010 | { |
972 | - if (empty($_REQUEST['start'])) |
|
973 | - $smcFunc['db_query']('', ' |
|
1011 | + if (empty($_REQUEST['start'])) { |
|
1012 | + $smcFunc['db_query']('', ' |
|
974 | 1013 | UPDATE {db_prefix}boards |
975 | 1014 | SET num_topics = {int:num_topics}', |
976 | 1015 | array( |
977 | 1016 | 'num_topics' => 0, |
978 | 1017 | ) |
979 | 1018 | ); |
1019 | + } |
|
980 | 1020 | |
981 | 1021 | while ($_REQUEST['start'] < $max_topics) |
982 | 1022 | { |
@@ -993,8 +1033,8 @@ discard block |
||
993 | 1033 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
994 | 1034 | ) |
995 | 1035 | ); |
996 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
997 | - $smcFunc['db_query']('', ' |
|
1036 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1037 | + $smcFunc['db_query']('', ' |
|
998 | 1038 | UPDATE {db_prefix}boards |
999 | 1039 | SET num_topics = num_topics + {int:real_num_topics} |
1000 | 1040 | WHERE id_board = {int:id_board}', |
@@ -1003,6 +1043,7 @@ discard block |
||
1003 | 1043 | 'real_num_topics' => $row['real_num_topics'], |
1004 | 1044 | ) |
1005 | 1045 | ); |
1046 | + } |
|
1006 | 1047 | $smcFunc['db_free_result']($request); |
1007 | 1048 | |
1008 | 1049 | $_REQUEST['start'] += $increment; |
@@ -1025,14 +1066,15 @@ discard block |
||
1025 | 1066 | // Update the unapproved post count of each board. |
1026 | 1067 | if ($_REQUEST['step'] <= 3) |
1027 | 1068 | { |
1028 | - if (empty($_REQUEST['start'])) |
|
1029 | - $smcFunc['db_query']('', ' |
|
1069 | + if (empty($_REQUEST['start'])) { |
|
1070 | + $smcFunc['db_query']('', ' |
|
1030 | 1071 | UPDATE {db_prefix}boards |
1031 | 1072 | SET unapproved_posts = {int:unapproved_posts}', |
1032 | 1073 | array( |
1033 | 1074 | 'unapproved_posts' => 0, |
1034 | 1075 | ) |
1035 | 1076 | ); |
1077 | + } |
|
1036 | 1078 | |
1037 | 1079 | while ($_REQUEST['start'] < $max_topics) |
1038 | 1080 | { |
@@ -1049,8 +1091,8 @@ discard block |
||
1049 | 1091 | 'is_approved' => 0, |
1050 | 1092 | ) |
1051 | 1093 | ); |
1052 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1053 | - $smcFunc['db_query']('', ' |
|
1094 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1095 | + $smcFunc['db_query']('', ' |
|
1054 | 1096 | UPDATE {db_prefix}boards |
1055 | 1097 | SET unapproved_posts = unapproved_posts + {int:unapproved_posts} |
1056 | 1098 | WHERE id_board = {int:id_board}', |
@@ -1059,6 +1101,7 @@ discard block |
||
1059 | 1101 | 'unapproved_posts' => $row['real_unapproved_posts'], |
1060 | 1102 | ) |
1061 | 1103 | ); |
1104 | + } |
|
1062 | 1105 | $smcFunc['db_free_result']($request); |
1063 | 1106 | |
1064 | 1107 | $_REQUEST['start'] += $increment; |
@@ -1081,14 +1124,15 @@ discard block |
||
1081 | 1124 | // Update the unapproved topic count of each board. |
1082 | 1125 | if ($_REQUEST['step'] <= 4) |
1083 | 1126 | { |
1084 | - if (empty($_REQUEST['start'])) |
|
1085 | - $smcFunc['db_query']('', ' |
|
1127 | + if (empty($_REQUEST['start'])) { |
|
1128 | + $smcFunc['db_query']('', ' |
|
1086 | 1129 | UPDATE {db_prefix}boards |
1087 | 1130 | SET unapproved_topics = {int:unapproved_topics}', |
1088 | 1131 | array( |
1089 | 1132 | 'unapproved_topics' => 0, |
1090 | 1133 | ) |
1091 | 1134 | ); |
1135 | + } |
|
1092 | 1136 | |
1093 | 1137 | while ($_REQUEST['start'] < $max_topics) |
1094 | 1138 | { |
@@ -1105,8 +1149,8 @@ discard block |
||
1105 | 1149 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
1106 | 1150 | ) |
1107 | 1151 | ); |
1108 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1109 | - $smcFunc['db_query']('', ' |
|
1152 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1153 | + $smcFunc['db_query']('', ' |
|
1110 | 1154 | UPDATE {db_prefix}boards |
1111 | 1155 | SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics} |
1112 | 1156 | WHERE id_board = {int:id_board}', |
@@ -1115,6 +1159,7 @@ discard block |
||
1115 | 1159 | 'real_unapproved_topics' => $row['real_unapproved_topics'], |
1116 | 1160 | ) |
1117 | 1161 | ); |
1162 | + } |
|
1118 | 1163 | $smcFunc['db_free_result']($request); |
1119 | 1164 | |
1120 | 1165 | $_REQUEST['start'] += $increment; |
@@ -1148,8 +1193,9 @@ discard block |
||
1148 | 1193 | 'is_not_deleted' => 0, |
1149 | 1194 | ) |
1150 | 1195 | ); |
1151 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1152 | - updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
1196 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1197 | + updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
1198 | + } |
|
1153 | 1199 | $smcFunc['db_free_result']($request); |
1154 | 1200 | |
1155 | 1201 | $request = $smcFunc['db_query']('', ' |
@@ -1164,8 +1210,9 @@ discard block |
||
1164 | 1210 | 'is_not_read' => 0, |
1165 | 1211 | ) |
1166 | 1212 | ); |
1167 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1168 | - updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
1213 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1214 | + updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
1215 | + } |
|
1169 | 1216 | $smcFunc['db_free_result']($request); |
1170 | 1217 | |
1171 | 1218 | if (microtime(true) - $time_start > 3) |
@@ -1197,12 +1244,13 @@ discard block |
||
1197 | 1244 | ) |
1198 | 1245 | ); |
1199 | 1246 | $boards = array(); |
1200 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1201 | - $boards[$row['id_board']][] = $row['id_msg']; |
|
1247 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1248 | + $boards[$row['id_board']][] = $row['id_msg']; |
|
1249 | + } |
|
1202 | 1250 | $smcFunc['db_free_result']($request); |
1203 | 1251 | |
1204 | - foreach ($boards as $board_id => $messages) |
|
1205 | - $smcFunc['db_query']('', ' |
|
1252 | + foreach ($boards as $board_id => $messages) { |
|
1253 | + $smcFunc['db_query']('', ' |
|
1206 | 1254 | UPDATE {db_prefix}messages |
1207 | 1255 | SET id_board = {int:id_board} |
1208 | 1256 | WHERE id_msg IN ({array_int:id_msg_array})', |
@@ -1211,6 +1259,7 @@ discard block |
||
1211 | 1259 | 'id_board' => $board_id, |
1212 | 1260 | ) |
1213 | 1261 | ); |
1262 | + } |
|
1214 | 1263 | |
1215 | 1264 | $_REQUEST['start'] += $increment; |
1216 | 1265 | |
@@ -1240,8 +1289,9 @@ discard block |
||
1240 | 1289 | ) |
1241 | 1290 | ); |
1242 | 1291 | $realBoardCounts = array(); |
1243 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1244 | - $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
1292 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1293 | + $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
1294 | + } |
|
1245 | 1295 | $smcFunc['db_free_result']($request); |
1246 | 1296 | |
1247 | 1297 | $request = $smcFunc['db_query']('', ' |
@@ -1261,18 +1311,20 @@ discard block |
||
1261 | 1311 | krsort($resort_me); |
1262 | 1312 | |
1263 | 1313 | $lastModifiedMsg = array(); |
1264 | - foreach ($resort_me as $rows) |
|
1265 | - foreach ($rows as $row) |
|
1314 | + foreach ($resort_me as $rows) { |
|
1315 | + foreach ($rows as $row) |
|
1266 | 1316 | { |
1267 | 1317 | // The latest message is the latest of the current board and its children. |
1268 | 1318 | if (isset($lastModifiedMsg[$row['id_board']])) |
1269 | 1319 | $curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]); |
1270 | - else |
|
1271 | - $curLastModifiedMsg = $row['local_last_msg']; |
|
1320 | + } |
|
1321 | + else { |
|
1322 | + $curLastModifiedMsg = $row['local_last_msg']; |
|
1323 | + } |
|
1272 | 1324 | |
1273 | 1325 | // If what is and what should be the latest message differ, an update is necessary. |
1274 | - if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) |
|
1275 | - $smcFunc['db_query']('', ' |
|
1326 | + if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) { |
|
1327 | + $smcFunc['db_query']('', ' |
|
1276 | 1328 | UPDATE {db_prefix}boards |
1277 | 1329 | SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated} |
1278 | 1330 | WHERE id_board = {int:id_board}', |
@@ -1282,12 +1334,14 @@ discard block |
||
1282 | 1334 | 'id_board' => $row['id_board'], |
1283 | 1335 | ) |
1284 | 1336 | ); |
1337 | + } |
|
1285 | 1338 | |
1286 | 1339 | // Parent boards inherit the latest modified message of their children. |
1287 | - if (isset($lastModifiedMsg[$row['id_parent']])) |
|
1288 | - $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
1289 | - else |
|
1290 | - $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
1340 | + if (isset($lastModifiedMsg[$row['id_parent']])) { |
|
1341 | + $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
1342 | + } else { |
|
1343 | + $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
1344 | + } |
|
1291 | 1345 | } |
1292 | 1346 | |
1293 | 1347 | // Update all the basic statistics. |
@@ -1359,8 +1413,9 @@ discard block |
||
1359 | 1413 | require_once($sourcedir . '/Subs-Auth.php'); |
1360 | 1414 | $members = findMembers($_POST['to']); |
1361 | 1415 | |
1362 | - if (empty($members)) |
|
1363 | - fatal_lang_error('reattribute_cannot_find_member'); |
|
1416 | + if (empty($members)) { |
|
1417 | + fatal_lang_error('reattribute_cannot_find_member'); |
|
1418 | + } |
|
1364 | 1419 | |
1365 | 1420 | $memID = array_shift($members); |
1366 | 1421 | $memID = $memID['id']; |
@@ -1390,8 +1445,9 @@ discard block |
||
1390 | 1445 | validateToken('admin-maint'); |
1391 | 1446 | |
1392 | 1447 | $groups = array(); |
1393 | - foreach ($_POST['groups'] as $id => $dummy) |
|
1394 | - $groups[] = (int) $id; |
|
1448 | + foreach ($_POST['groups'] as $id => $dummy) { |
|
1449 | + $groups[] = (int) $id; |
|
1450 | + } |
|
1395 | 1451 | $time_limit = (time() - ($_POST['maxdays'] * 24 * 3600)); |
1396 | 1452 | $where_vars = array( |
1397 | 1453 | 'time_limit' => $time_limit, |
@@ -1400,9 +1456,9 @@ discard block |
||
1400 | 1456 | { |
1401 | 1457 | $where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}'; |
1402 | 1458 | $where_vars['is_activated'] = 0; |
1459 | + } else { |
|
1460 | + $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
1403 | 1461 | } |
1404 | - else |
|
1405 | - $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
1406 | 1462 | |
1407 | 1463 | // Need to get *all* groups then work out which (if any) we avoid. |
1408 | 1464 | $request = $smcFunc['db_query']('', ' |
@@ -1421,8 +1477,7 @@ discard block |
||
1421 | 1477 | { |
1422 | 1478 | $where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}'; |
1423 | 1479 | $where_vars['id_post_group_' . $row['id_group']] = $row['id_group']; |
1424 | - } |
|
1425 | - else |
|
1480 | + } else |
|
1426 | 1481 | { |
1427 | 1482 | $where .= ' AND mem.id_group != {int:id_group_' . $row['id_group'] . '} AND FIND_IN_SET({int:id_group_' . $row['id_group'] . '}, mem.additional_groups) = 0'; |
1428 | 1483 | $where_vars['id_group_' . $row['id_group']] = $row['id_group']; |
@@ -1449,8 +1504,9 @@ discard block |
||
1449 | 1504 | $members = array(); |
1450 | 1505 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1451 | 1506 | { |
1452 | - if (!$row['is_mod'] || !in_array(3, $groups)) |
|
1453 | - $members[] = $row['id_member']; |
|
1507 | + if (!$row['is_mod'] || !in_array(3, $groups)) { |
|
1508 | + $members[] = $row['id_member']; |
|
1509 | + } |
|
1454 | 1510 | } |
1455 | 1511 | $smcFunc['db_free_result']($request); |
1456 | 1512 | |
@@ -1497,8 +1553,9 @@ discard block |
||
1497 | 1553 | ) |
1498 | 1554 | ); |
1499 | 1555 | |
1500 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1501 | - $drafts[] = (int) $row[0]; |
|
1556 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1557 | + $drafts[] = (int) $row[0]; |
|
1558 | + } |
|
1502 | 1559 | $smcFunc['db_free_result']($request); |
1503 | 1560 | |
1504 | 1561 | // If we have old drafts, remove them |
@@ -1541,8 +1598,9 @@ discard block |
||
1541 | 1598 | $sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']); |
1542 | 1599 | |
1543 | 1600 | // No boards then this is your stop. |
1544 | - if (empty($id_board_from) || empty($id_board_to)) |
|
1545 | - return; |
|
1601 | + if (empty($id_board_from) || empty($id_board_to)) { |
|
1602 | + return; |
|
1603 | + } |
|
1546 | 1604 | |
1547 | 1605 | // The big WHERE clause |
1548 | 1606 | $conditions = 'WHERE t.id_board = {int:id_board_from} |
@@ -1590,18 +1648,20 @@ discard block |
||
1590 | 1648 | ); |
1591 | 1649 | list ($total_topics) = $smcFunc['db_fetch_row']($request); |
1592 | 1650 | $smcFunc['db_free_result']($request); |
1651 | + } else { |
|
1652 | + $total_topics = (int) $_REQUEST['totaltopics']; |
|
1593 | 1653 | } |
1594 | - else |
|
1595 | - $total_topics = (int) $_REQUEST['totaltopics']; |
|
1596 | 1654 | |
1597 | 1655 | // Seems like we need this here. |
1598 | 1656 | $context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';max_days=' . $max_days; |
1599 | 1657 | |
1600 | - if ($locked) |
|
1601 | - $context['continue_get_data'] .= ';locked'; |
|
1658 | + if ($locked) { |
|
1659 | + $context['continue_get_data'] .= ';locked'; |
|
1660 | + } |
|
1602 | 1661 | |
1603 | - if ($sticky) |
|
1604 | - $context['continue_get_data'] .= ';sticky'; |
|
1662 | + if ($sticky) { |
|
1663 | + $context['continue_get_data'] .= ';sticky'; |
|
1664 | + } |
|
1605 | 1665 | |
1606 | 1666 | $context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1607 | 1667 | |
@@ -1622,8 +1682,9 @@ discard block |
||
1622 | 1682 | |
1623 | 1683 | // Get the ids. |
1624 | 1684 | $topics = array(); |
1625 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1626 | - $topics[] = $row['id_topic']; |
|
1685 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1686 | + $topics[] = $row['id_topic']; |
|
1687 | + } |
|
1627 | 1688 | |
1628 | 1689 | // Just return if we don't have any topics left to move. |
1629 | 1690 | if (empty($topics)) |
@@ -1714,9 +1775,9 @@ discard block |
||
1714 | 1775 | // save it so we don't do this again for this task |
1715 | 1776 | list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request); |
1716 | 1777 | $smcFunc['db_free_result']($request); |
1778 | + } else { |
|
1779 | + validateToken('admin-recountposts'); |
|
1717 | 1780 | } |
1718 | - else |
|
1719 | - validateToken('admin-recountposts'); |
|
1720 | 1781 | |
1721 | 1782 | // Lets get a group of members and determine their post count (from the boards that have post count enabled of course). |
1722 | 1783 | $request = $smcFunc['db_query']('', ' |
@@ -1762,8 +1823,9 @@ discard block |
||
1762 | 1823 | createToken('admin-recountposts'); |
1763 | 1824 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">'; |
1764 | 1825 | |
1765 | - if (function_exists('apache_reset_timeout')) |
|
1766 | - apache_reset_timeout(); |
|
1826 | + if (function_exists('apache_reset_timeout')) { |
|
1827 | + apache_reset_timeout(); |
|
1828 | + } |
|
1767 | 1829 | return; |
1768 | 1830 | } |
1769 | 1831 | |
@@ -1849,10 +1911,9 @@ discard block |
||
1849 | 1911 | checkSession('request'); |
1850 | 1912 | validateToken('admin-hook', 'request'); |
1851 | 1913 | |
1852 | - if ($_REQUEST['do'] == 'remove') |
|
1853 | - remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
1854 | - |
|
1855 | - else |
|
1914 | + if ($_REQUEST['do'] == 'remove') { |
|
1915 | + remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
1916 | + } else |
|
1856 | 1917 | { |
1857 | 1918 | $function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!'); |
1858 | 1919 | $function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : ''); |
@@ -1902,11 +1963,11 @@ discard block |
||
1902 | 1963 | // Show a nice icon to indicate this is an instance. |
1903 | 1964 | $instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="' . $txt['hooks_field_function_method'] . '"></span> ' : ''); |
1904 | 1965 | |
1905 | - if (!empty($data['included_file'])) |
|
1906 | - return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
1907 | - |
|
1908 | - else |
|
1909 | - return $instance . $data['real_function']; |
|
1966 | + if (!empty($data['included_file'])) { |
|
1967 | + return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
1968 | + } else { |
|
1969 | + return $instance . $data['real_function']; |
|
1970 | + } |
|
1910 | 1971 | }, |
1911 | 1972 | ), |
1912 | 1973 | 'sort' => array( |
@@ -1971,11 +2032,12 @@ discard block |
||
1971 | 2032 | 'data' => array( |
1972 | 2033 | 'function' => function($data) use ($txt, $scripturl, $context) |
1973 | 2034 | { |
1974 | - if (!$data['hook_exists']) |
|
1975 | - return ' |
|
2035 | + if (!$data['hook_exists']) { |
|
2036 | + return ' |
|
1976 | 2037 | <a href="' . $scripturl . '?action=admin;area=maintain;sa=hooks;do=remove;hook=' . $data['hook_name'] . ';function=' . urlencode($data['function_name']) . $context['filter_url'] . ';' . $context['admin-hook_token_var'] . '=' . $context['admin-hook_token'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['quickmod_confirm'] . '" class="you_sure"> |
1977 | 2038 | <span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span> |
1978 | 2039 | </a>'; |
2040 | + } |
|
1979 | 2041 | }, |
1980 | 2042 | 'class' => 'centertext', |
1981 | 2043 | ), |
@@ -2010,10 +2072,11 @@ discard block |
||
2010 | 2072 | { |
2011 | 2073 | if ($file != '.' && $file != '..') |
2012 | 2074 | { |
2013 | - if (is_dir($dir_path . '/' . $file)) |
|
2014 | - $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
2015 | - else |
|
2016 | - $files[] = array('dir' => $dir_path, 'name' => $file); |
|
2075 | + if (is_dir($dir_path . '/' . $file)) { |
|
2076 | + $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
2077 | + } else { |
|
2078 | + $files[] = array('dir' => $dir_path, 'name' => $file); |
|
2079 | + } |
|
2017 | 2080 | } |
2018 | 2081 | } |
2019 | 2082 | } |
@@ -2062,16 +2125,16 @@ discard block |
||
2062 | 2125 | // I need to know if there is at least one function called in this file. |
2063 | 2126 | $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
2064 | 2127 | unset($temp_hooks[$hook][$rawFunc]); |
2065 | - } |
|
2066 | - elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
2128 | + } elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
2067 | 2129 | { |
2068 | 2130 | $hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData; |
2069 | 2131 | $hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true; |
2070 | 2132 | $hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : '')); |
2071 | 2133 | |
2072 | 2134 | // Does the hook has its own file? |
2073 | - if (!empty($hookParsedData['hookFile'])) |
|
2074 | - $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
2135 | + if (!empty($hookParsedData['hookFile'])) { |
|
2136 | + $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
2137 | + } |
|
2075 | 2138 | |
2076 | 2139 | // I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too) |
2077 | 2140 | $temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled']; |
@@ -2098,15 +2161,17 @@ discard block |
||
2098 | 2161 | $sort = array(); |
2099 | 2162 | $hooks_filters = array(); |
2100 | 2163 | |
2101 | - foreach ($hooks as $hook => $functions) |
|
2102 | - $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
2164 | + foreach ($hooks as $hook => $functions) { |
|
2165 | + $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
2166 | + } |
|
2103 | 2167 | |
2104 | - if (!empty($hooks_filters)) |
|
2105 | - $context['insert_after_template'] .= ' |
|
2168 | + if (!empty($hooks_filters)) { |
|
2169 | + $context['insert_after_template'] .= ' |
|
2106 | 2170 | <script> |
2107 | 2171 | var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\'); |
2108 | 2172 | hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;" onchange="window.location=(\'' . $scripturl . '?action=admin;area=maintain;sa=hooks\' + (this.value ? \';filter=\' + this.value : \'\'));"><option value="">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>') . '; |
2109 | 2173 | </script>'; |
2174 | + } |
|
2110 | 2175 | |
2111 | 2176 | $temp_data = array(); |
2112 | 2177 | $id = 0; |
@@ -2148,10 +2213,11 @@ discard block |
||
2148 | 2213 | |
2149 | 2214 | foreach ($temp_data as $data) |
2150 | 2215 | { |
2151 | - if (++$counter < $start) |
|
2152 | - continue; |
|
2153 | - elseif ($counter == $start + $per_page) |
|
2154 | - break; |
|
2216 | + if (++$counter < $start) { |
|
2217 | + continue; |
|
2218 | + } elseif ($counter == $start + $per_page) { |
|
2219 | + break; |
|
2220 | + } |
|
2155 | 2221 | |
2156 | 2222 | $hooks_data[] = $data; |
2157 | 2223 | } |
@@ -2173,13 +2239,15 @@ discard block |
||
2173 | 2239 | $hooks_count = 0; |
2174 | 2240 | |
2175 | 2241 | $context['filter'] = false; |
2176 | - if (isset($_GET['filter'])) |
|
2177 | - $context['filter'] = $_GET['filter']; |
|
2242 | + if (isset($_GET['filter'])) { |
|
2243 | + $context['filter'] = $_GET['filter']; |
|
2244 | + } |
|
2178 | 2245 | |
2179 | 2246 | foreach ($hooks as $hook => $functions) |
2180 | 2247 | { |
2181 | - if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) |
|
2182 | - $hooks_count += count($functions); |
|
2248 | + if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) { |
|
2249 | + $hooks_count += count($functions); |
|
2250 | + } |
|
2183 | 2251 | } |
2184 | 2252 | |
2185 | 2253 | return $hooks_count; |
@@ -2200,8 +2268,9 @@ discard block |
||
2200 | 2268 | $integration_hooks = array(); |
2201 | 2269 | foreach ($modSettings as $key => $value) |
2202 | 2270 | { |
2203 | - if (!empty($value) && substr($key, 0, 10) === 'integrate_') |
|
2204 | - $integration_hooks[$key] = explode(',', $value); |
|
2271 | + if (!empty($value) && substr($key, 0, 10) === 'integrate_') { |
|
2272 | + $integration_hooks[$key] = explode(',', $value); |
|
2273 | + } |
|
2205 | 2274 | } |
2206 | 2275 | } |
2207 | 2276 | |
@@ -2232,8 +2301,9 @@ discard block |
||
2232 | 2301 | ); |
2233 | 2302 | |
2234 | 2303 | // Meh... |
2235 | - if (empty($rawData)) |
|
2236 | - return $hookData; |
|
2304 | + if (empty($rawData)) { |
|
2305 | + return $hookData; |
|
2306 | + } |
|
2237 | 2307 | |
2238 | 2308 | // For convenience purposes only! |
2239 | 2309 | $modFunc = $rawData; |
@@ -2244,11 +2314,11 @@ discard block |
||
2244 | 2314 | list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc); |
2245 | 2315 | |
2246 | 2316 | // Does the file exists? who knows! |
2247 | - if (empty($settings['theme_dir'])) |
|
2248 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
2249 | - |
|
2250 | - else |
|
2251 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
2317 | + if (empty($settings['theme_dir'])) { |
|
2318 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
2319 | + } else { |
|
2320 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
2321 | + } |
|
2252 | 2322 | |
2253 | 2323 | $hookData['fileExists'] = file_exists($hookData['absPath']); |
2254 | 2324 | $hookData['hookFile'] = basename($hookData['hookFile']); |
@@ -2273,11 +2343,10 @@ discard block |
||
2273 | 2343 | { |
2274 | 2344 | list ($hookData['class'], $hookData['method']) = explode('::', $modFunc); |
2275 | 2345 | $hookData['pureFunc'] = $hookData['method']; |
2346 | + } else { |
|
2347 | + $hookData['pureFunc'] = $modFunc; |
|
2276 | 2348 | } |
2277 | 2349 | |
2278 | - else |
|
2279 | - $hookData['pureFunc'] = $modFunc; |
|
2280 | - |
|
2281 | 2350 | return $hookData; |
2282 | 2351 | } |
2283 | 2352 | |
@@ -2294,16 +2363,18 @@ discard block |
||
2294 | 2363 | */ |
2295 | 2364 | function fixchardb__callback($matches) |
2296 | 2365 | { |
2297 | - if (!isset($matches[1])) |
|
2298 | - return ''; |
|
2366 | + if (!isset($matches[1])) { |
|
2367 | + return ''; |
|
2368 | + } |
|
2299 | 2369 | |
2300 | 2370 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
2301 | 2371 | |
2302 | 2372 | // it's to big for mysql? |
2303 | - if ($num > 0xFFFF) |
|
2304 | - return $matches[0]; |
|
2305 | - else |
|
2306 | - return fixchar__callback ($matches); |
|
2307 | -} |
|
2373 | + if ($num > 0xFFFF) { |
|
2374 | + return $matches[0]; |
|
2375 | + } else { |
|
2376 | + return fixchar__callback ($matches); |
|
2377 | + } |
|
2378 | + } |
|
2308 | 2379 | |
2309 | 2380 | ?> |
2310 | 2381 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | define('SMF', 'proxy'); |
18 | +} |
|
18 | 19 | |
19 | 20 | global $proxyhousekeeping; |
20 | 21 | |
@@ -68,33 +69,38 @@ discard block |
||
68 | 69 | */ |
69 | 70 | public function checkRequest() |
70 | 71 | { |
71 | - if (!$this->enabled) |
|
72 | - return false; |
|
72 | + if (!$this->enabled) { |
|
73 | + return false; |
|
74 | + } |
|
73 | 75 | |
74 | 76 | // Try to create the image cache directory if it doesn't exist |
75 | - if (!file_exists($this->cache)) |
|
76 | - if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
77 | + if (!file_exists($this->cache)) { |
|
78 | + if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
77 | 79 | return false; |
80 | + } |
|
78 | 81 | |
79 | 82 | // Basic sanity check |
80 | 83 | $_GET['request'] = validate_iri($_GET['request']); |
81 | 84 | |
82 | 85 | // We aren't going anywhere without these |
83 | - if (empty($_GET['hash']) || empty($_GET['request'])) |
|
84 | - return false; |
|
86 | + if (empty($_GET['hash']) || empty($_GET['request'])) { |
|
87 | + return false; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | $hash = $_GET['hash']; |
87 | 91 | $request = $_GET['request']; |
88 | 92 | |
89 | - if (md5($request . $this->secret) != $hash) |
|
90 | - return false; |
|
93 | + if (md5($request . $this->secret) != $hash) { |
|
94 | + return false; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | // Ensure any non-ASCII characters in the URL are encoded correctly |
93 | 98 | $request = iri_to_url($request); |
94 | 99 | |
95 | 100 | // Attempt to cache the request if it doesn't exist |
96 | - if (!$this->isCached($request)) |
|
97 | - return $this->cacheImage($request); |
|
101 | + if (!$this->isCached($request)) { |
|
102 | + return $this->cacheImage($request); |
|
103 | + } |
|
98 | 104 | |
99 | 105 | return true; |
100 | 106 | } |
@@ -131,8 +137,9 @@ discard block |
||
131 | 137 | if (!$cached || $time - $cached['time'] > ($this->maxDays * 86400)) |
132 | 138 | { |
133 | 139 | @unlink($cached_file); |
134 | - if ($this->checkRequest()) |
|
135 | - $this->serve(); |
|
140 | + if ($this->checkRequest()) { |
|
141 | + $this->serve(); |
|
142 | + } |
|
136 | 143 | $this::redirectexit($request); |
137 | 144 | } |
138 | 145 | |
@@ -145,8 +152,9 @@ discard block |
||
145 | 152 | |
146 | 153 | // Make sure we're serving an image |
147 | 154 | $contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : ''); |
148 | - if ($contentParts[0] != 'image') |
|
149 | - exit; |
|
155 | + if ($contentParts[0] != 'image') { |
|
156 | + exit; |
|
157 | + } |
|
150 | 158 | |
151 | 159 | $max_age = $time - $cached['time'] + (5 * 86400); |
152 | 160 | header('content-type: ' . $cached['content_type']); |
@@ -196,25 +204,29 @@ discard block |
||
196 | 204 | $image = fetch_web_data($request); |
197 | 205 | |
198 | 206 | // Looks like nobody was home |
199 | - if (empty($image)) |
|
200 | - return -1; |
|
207 | + if (empty($image)) { |
|
208 | + return -1; |
|
209 | + } |
|
201 | 210 | |
202 | 211 | // What kind of file did they give us? |
203 | 212 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
204 | 213 | $mime_type = finfo_buffer($finfo, $image); |
205 | 214 | |
206 | 215 | // SVG needs a little extra care |
207 | - if ($ext == 'svg' && $mime_type == 'text/plain') |
|
208 | - $mime_type = 'image/svg+xml'; |
|
216 | + if ($ext == 'svg' && $mime_type == 'text/plain') { |
|
217 | + $mime_type = 'image/svg+xml'; |
|
218 | + } |
|
209 | 219 | |
210 | 220 | // Make sure the url is returning an image |
211 | - if (strpos($mime_type, 'image/') !== 0) |
|
212 | - return -1; |
|
221 | + if (strpos($mime_type, 'image/') !== 0) { |
|
222 | + return -1; |
|
223 | + } |
|
213 | 224 | |
214 | 225 | // Validate the filesize |
215 | 226 | $size = strlen($image); |
216 | - if ($size > ($this->maxSize * 1024)) |
|
217 | - return 0; |
|
227 | + if ($size > ($this->maxSize * 1024)) { |
|
228 | + return 0; |
|
229 | + } |
|
218 | 230 | |
219 | 231 | // Cache it for later |
220 | 232 | return file_put_contents($dest, json_encode(array( |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $sourcedir, $profile_vars; |
30 | 31 | |
31 | 32 | // Don't load this twice! |
32 | - if (!empty($profile_fields) && !$force_reload) |
|
33 | - return; |
|
33 | + if (!empty($profile_fields) && !$force_reload) { |
|
34 | + return; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
104 | 106 | { |
105 | 107 | // Set to blank? |
106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
107 | - $value = '1004-01-01'; |
|
108 | - else |
|
109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
109 | + $value = '1004-01-01'; |
|
110 | + } else { |
|
111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
112 | + } |
|
113 | + } else { |
|
114 | + $value = '1004-01-01'; |
|
110 | 115 | } |
111 | - else |
|
112 | - $value = '1004-01-01'; |
|
113 | 116 | |
114 | 117 | $profile_vars['birthdate'] = $value; |
115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
127 | 130 | { |
128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01'; |
129 | 132 | return true; |
130 | - } |
|
131 | - else |
|
133 | + } else |
|
132 | 134 | { |
133 | 135 | $value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate']; |
134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
151 | 153 | } |
152 | 154 | // As long as it doesn't equal "N/A"... |
153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
155 | - else |
|
156 | - $value = $cur_profile['date_registered']; |
|
155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
157 | + } else { |
|
158 | + $value = $cur_profile['date_registered']; |
|
159 | + } |
|
157 | 160 | |
158 | 161 | return true; |
159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
177 | 180 | { |
178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
179 | 182 | |
180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
181 | - return false; |
|
183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
184 | + return false; |
|
185 | + } |
|
182 | 186 | |
183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
254 | 258 | |
255 | 259 | if (isset($context['profile_languages'][$value])) |
256 | 260 | { |
257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
258 | - $_SESSION['language'] = $value; |
|
261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
262 | + $_SESSION['language'] = $value; |
|
263 | + } |
|
259 | 264 | return true; |
260 | - } |
|
261 | - else |
|
265 | + } else |
|
262 | 266 | { |
263 | 267 | $value = $cur_profile['lngfile']; |
264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
282 | 286 | |
283 | 287 | // Maybe they are trying to change their password as well? |
284 | 288 | $resetPassword = true; |
285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
286 | - $resetPassword = false; |
|
289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
290 | + $resetPassword = false; |
|
291 | + } |
|
287 | 292 | |
288 | 293 | // Do the reset... this will send them an email too. |
289 | - if ($resetPassword) |
|
290 | - resetPassword($context['id_member'], $value); |
|
291 | - elseif ($value !== null) |
|
294 | + if ($resetPassword) { |
|
295 | + resetPassword($context['id_member'], $value); |
|
296 | + } elseif ($value !== null) |
|
292 | 297 | { |
293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
313 | 318 | { |
314 | 319 | // If we didn't try it then ignore it! |
315 | - if ($value == '') |
|
316 | - return false; |
|
320 | + if ($value == '') { |
|
321 | + return false; |
|
322 | + } |
|
317 | 323 | |
318 | 324 | // Do the two entries for the password even match? |
319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
320 | - return 'bad_new_password'; |
|
325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
326 | + return 'bad_new_password'; |
|
327 | + } |
|
321 | 328 | |
322 | 329 | // Let's get the validation function into play... |
323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
325 | 332 | |
326 | 333 | // Were there errors? |
327 | - if ($passwordErrors != null) |
|
328 | - return 'password_' . $passwordErrors; |
|
334 | + if ($passwordErrors != null) { |
|
335 | + return 'password_' . $passwordErrors; |
|
336 | + } |
|
329 | 337 | |
330 | 338 | // Set up the new password variable... ready for storage. |
331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
350 | 358 | 'permission' => 'profile_blurb', |
351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
352 | 360 | { |
353 | - if ($smcFunc['strlen']($value) > 50) |
|
354 | - return 'personal_text_too_long'; |
|
361 | + if ($smcFunc['strlen']($value) > 50) { |
|
362 | + return 'personal_text_too_long'; |
|
363 | + } |
|
355 | 364 | |
356 | 365 | return true; |
357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
386 | 395 | 'permission' => 'moderate_forum', |
387 | 396 | 'input_validate' => function(&$value) |
388 | 397 | { |
389 | - if (!is_numeric($value)) |
|
390 | - return 'digits_only'; |
|
391 | - else |
|
392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
398 | + if (!is_numeric($value)) { |
|
399 | + return 'digits_only'; |
|
400 | + } else { |
|
401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
402 | + } |
|
393 | 403 | return true; |
394 | 404 | }, |
395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
405 | 415 | { |
406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
407 | 417 | |
408 | - if (trim($value) == '') |
|
409 | - return 'no_name'; |
|
410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
411 | - return 'name_too_long'; |
|
412 | - elseif ($cur_profile['real_name'] != $value) |
|
418 | + if (trim($value) == '') { |
|
419 | + return 'no_name'; |
|
420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
421 | + return 'name_too_long'; |
|
422 | + } elseif ($cur_profile['real_name'] != $value) |
|
413 | 423 | { |
414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
415 | - if (isReservedName($value, $context['id_member'])) |
|
416 | - return 'name_taken'; |
|
425 | + if (isReservedName($value, $context['id_member'])) { |
|
426 | + return 'name_taken'; |
|
427 | + } |
|
417 | 428 | } |
418 | 429 | return true; |
419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
472 | 483 | ); |
473 | 484 | |
474 | - if ($context['smiley_sets'][$i]['selected']) |
|
475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
487 | + } |
|
476 | 488 | } |
477 | 489 | return true; |
478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
481 | 493 | global $modSettings; |
482 | 494 | |
483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
485 | - $value = ''; |
|
496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
497 | + $value = ''; |
|
498 | + } |
|
486 | 499 | return true; |
487 | 500 | }, |
488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
497 | 510 | loadLanguage('Settings'); |
498 | 511 | |
499 | 512 | $context['allow_no_censored'] = false; |
500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
515 | + } |
|
502 | 516 | |
503 | 517 | return true; |
504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
545 | 559 | 'input_validate' => function($value) |
546 | 560 | { |
547 | 561 | $tz = smf_list_timezones(); |
548 | - if (!isset($tz[$value])) |
|
549 | - return 'bad_timezone'; |
|
562 | + if (!isset($tz[$value])) { |
|
563 | + return 'bad_timezone'; |
|
564 | + } |
|
550 | 565 | |
551 | 566 | return true; |
552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
563 | 578 | { |
564 | - if ($smcFunc['strlen']($value) > 50) |
|
565 | - return 'user_title_too_long'; |
|
579 | + if ($smcFunc['strlen']($value) > 50) { |
|
580 | + return 'user_title_too_long'; |
|
581 | + } |
|
566 | 582 | |
567 | 583 | return true; |
568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
584 | 600 | // Fix the URL... |
585 | 601 | 'input_validate' => function(&$value) |
586 | 602 | { |
587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
588 | - $value = 'http://' . $value; |
|
589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
590 | - $value = ''; |
|
603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
604 | + $value = 'http://' . $value; |
|
605 | + } |
|
606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
607 | + $value = ''; |
|
608 | + } |
|
591 | 609 | $value = (string) validate_iri(sanitize_iri($value)); |
592 | 610 | return true; |
593 | 611 | }, |
@@ -602,16 +620,19 @@ discard block |
||
602 | 620 | foreach ($profile_fields as $key => $field) |
603 | 621 | { |
604 | 622 | // Do we have permission to do this? |
605 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
606 | - unset($profile_fields[$key]); |
|
623 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
624 | + unset($profile_fields[$key]); |
|
625 | + } |
|
607 | 626 | |
608 | 627 | // Is it enabled? |
609 | - if (isset($field['enabled']) && !$field['enabled']) |
|
610 | - unset($profile_fields[$key]); |
|
628 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
629 | + unset($profile_fields[$key]); |
|
630 | + } |
|
611 | 631 | |
612 | 632 | // Is it specifically disabled? |
613 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
614 | - unset($profile_fields[$key]); |
|
633 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
634 | + unset($profile_fields[$key]); |
|
635 | + } |
|
615 | 636 | } |
616 | 637 | } |
617 | 638 | |
@@ -636,9 +657,10 @@ discard block |
||
636 | 657 | loadProfileFields(true); |
637 | 658 | |
638 | 659 | // First check for any linked sets. |
639 | - foreach ($profile_fields as $key => $field) |
|
640 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
660 | + foreach ($profile_fields as $key => $field) { |
|
661 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
641 | 662 | $fields[] = $key; |
663 | + } |
|
642 | 664 | |
643 | 665 | $i = 0; |
644 | 666 | $last_type = ''; |
@@ -650,38 +672,46 @@ discard block |
||
650 | 672 | $cur_field = &$profile_fields[$field]; |
651 | 673 | |
652 | 674 | // Does it have a preload and does that preload succeed? |
653 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
654 | - continue; |
|
675 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
676 | + continue; |
|
677 | + } |
|
655 | 678 | |
656 | 679 | // If this is anything but complex we need to do more cleaning! |
657 | 680 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
658 | 681 | { |
659 | - if (!isset($cur_field['label'])) |
|
660 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
682 | + if (!isset($cur_field['label'])) { |
|
683 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
684 | + } |
|
661 | 685 | |
662 | 686 | // Everything has a value! |
663 | - if (!isset($cur_field['value'])) |
|
664 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
687 | + if (!isset($cur_field['value'])) { |
|
688 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
689 | + } |
|
665 | 690 | |
666 | 691 | // Any input attributes? |
667 | 692 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
668 | 693 | } |
669 | 694 | |
670 | 695 | // Was there an error with this field on posting? |
671 | - if (isset($context['profile_errors'][$field])) |
|
672 | - $cur_field['is_error'] = true; |
|
696 | + if (isset($context['profile_errors'][$field])) { |
|
697 | + $cur_field['is_error'] = true; |
|
698 | + } |
|
673 | 699 | |
674 | 700 | // Any javascript stuff? |
675 | - if (!empty($cur_field['js_submit'])) |
|
676 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
677 | - if (!empty($cur_field['js'])) |
|
678 | - $context['profile_javascript'] .= $cur_field['js']; |
|
701 | + if (!empty($cur_field['js_submit'])) { |
|
702 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
703 | + } |
|
704 | + if (!empty($cur_field['js'])) { |
|
705 | + $context['profile_javascript'] .= $cur_field['js']; |
|
706 | + } |
|
679 | 707 | |
680 | 708 | // Any template stuff? |
681 | - if (!empty($cur_field['prehtml'])) |
|
682 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
683 | - if (!empty($cur_field['posthtml'])) |
|
684 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
709 | + if (!empty($cur_field['prehtml'])) { |
|
710 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
711 | + } |
|
712 | + if (!empty($cur_field['posthtml'])) { |
|
713 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
714 | + } |
|
685 | 715 | |
686 | 716 | // Finally put it into context? |
687 | 717 | if ($cur_field['type'] != 'hidden') |
@@ -714,12 +744,14 @@ discard block |
||
714 | 744 | }, false);' : ''), true); |
715 | 745 | |
716 | 746 | // Any onsubmit javascript? |
717 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
718 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
747 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
748 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
749 | + } |
|
719 | 750 | |
720 | 751 | // Any totally custom stuff? |
721 | - if (!empty($context['profile_javascript'])) |
|
722 | - addInlineJavaScript($context['profile_javascript'], true); |
|
752 | + if (!empty($context['profile_javascript'])) { |
|
753 | + addInlineJavaScript($context['profile_javascript'], true); |
|
754 | + } |
|
723 | 755 | |
724 | 756 | // Free up some memory. |
725 | 757 | unset($profile_fields); |
@@ -740,8 +772,9 @@ discard block |
||
740 | 772 | |
741 | 773 | // This allows variables to call activities when they save - by default just to reload their settings |
742 | 774 | $context['profile_execute_on_save'] = array(); |
743 | - if ($context['user']['is_owner']) |
|
744 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
775 | + if ($context['user']['is_owner']) { |
|
776 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
777 | + } |
|
745 | 778 | |
746 | 779 | // Assume we log nothing. |
747 | 780 | $context['log_changes'] = array(); |
@@ -749,8 +782,9 @@ discard block |
||
749 | 782 | // Cycle through the profile fields working out what to do! |
750 | 783 | foreach ($profile_fields as $key => $field) |
751 | 784 | { |
752 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
753 | - continue; |
|
785 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
786 | + continue; |
|
787 | + } |
|
754 | 788 | |
755 | 789 | // What gets updated? |
756 | 790 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -778,12 +812,13 @@ discard block |
||
778 | 812 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
779 | 813 | |
780 | 814 | // Finally, clean up certain types. |
781 | - if ($field['cast_type'] == 'int') |
|
782 | - $_POST[$key] = (int) $_POST[$key]; |
|
783 | - elseif ($field['cast_type'] == 'float') |
|
784 | - $_POST[$key] = (float) $_POST[$key]; |
|
785 | - elseif ($field['cast_type'] == 'check') |
|
786 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
815 | + if ($field['cast_type'] == 'int') { |
|
816 | + $_POST[$key] = (int) $_POST[$key]; |
|
817 | + } elseif ($field['cast_type'] == 'float') { |
|
818 | + $_POST[$key] = (float) $_POST[$key]; |
|
819 | + } elseif ($field['cast_type'] == 'check') { |
|
820 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
821 | + } |
|
787 | 822 | |
788 | 823 | // If we got here we're doing OK. |
789 | 824 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -794,11 +829,12 @@ discard block |
||
794 | 829 | $cur_profile[$key] = $_POST[$key]; |
795 | 830 | |
796 | 831 | // Are we logging it? |
797 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
798 | - $context['log_changes'][$key] = array( |
|
832 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
833 | + $context['log_changes'][$key] = array( |
|
799 | 834 | 'previous' => $old_profile[$key], |
800 | 835 | 'new' => $_POST[$key], |
801 | 836 | ); |
837 | + } |
|
802 | 838 | } |
803 | 839 | |
804 | 840 | // Logging group changes are a bit different... |
@@ -831,10 +867,11 @@ discard block |
||
831 | 867 | { |
832 | 868 | foreach ($groups as $id => $group) |
833 | 869 | { |
834 | - if (isset($context['member_groups'][$group])) |
|
835 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
836 | - else |
|
837 | - unset($additional_groups[$type][$id]); |
|
870 | + if (isset($context['member_groups'][$group])) { |
|
871 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
872 | + } else { |
|
873 | + unset($additional_groups[$type][$id]); |
|
874 | + } |
|
838 | 875 | } |
839 | 876 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
840 | 877 | } |
@@ -845,10 +882,11 @@ discard block |
||
845 | 882 | } |
846 | 883 | |
847 | 884 | // @todo Temporary |
848 | - if ($context['user']['is_owner']) |
|
849 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
850 | - else |
|
851 | - $changeOther = allowedTo('profile_extra_any'); |
|
885 | + if ($context['user']['is_owner']) { |
|
886 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
887 | + } else { |
|
888 | + $changeOther = allowedTo('profile_extra_any'); |
|
889 | + } |
|
852 | 890 | if ($changeOther && empty($post_errors)) |
853 | 891 | { |
854 | 892 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -856,8 +894,9 @@ discard block |
||
856 | 894 | { |
857 | 895 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
858 | 896 | |
859 | - if (!empty($custom_fields_errors)) |
|
860 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
897 | + if (!empty($custom_fields_errors)) { |
|
898 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
899 | + } |
|
861 | 900 | } |
862 | 901 | } |
863 | 902 | |
@@ -883,9 +922,9 @@ discard block |
||
883 | 922 | if ($context['user']['is_owner']) |
884 | 923 | { |
885 | 924 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
925 | + } else { |
|
926 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
886 | 927 | } |
887 | - else |
|
888 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
889 | 928 | |
890 | 929 | // Arrays of all the changes - makes things easier. |
891 | 930 | $profile_bools = array(); |
@@ -896,22 +935,25 @@ discard block |
||
896 | 935 | 'ignore_boards', |
897 | 936 | ); |
898 | 937 | |
899 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
900 | - $_POST['ignore_brd'] = array(); |
|
938 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
939 | + $_POST['ignore_brd'] = array(); |
|
940 | + } |
|
901 | 941 | |
902 | 942 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
903 | 943 | if (isset($_POST['ignore_brd'])) |
904 | 944 | { |
905 | - if (!is_array($_POST['ignore_brd'])) |
|
906 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
945 | + if (!is_array($_POST['ignore_brd'])) { |
|
946 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
947 | + } |
|
907 | 948 | |
908 | 949 | foreach ($_POST['ignore_brd'] as $k => $d) |
909 | 950 | { |
910 | 951 | $d = (int) $d; |
911 | - if ($d != 0) |
|
912 | - $_POST['ignore_brd'][$k] = $d; |
|
913 | - else |
|
914 | - unset($_POST['ignore_brd'][$k]); |
|
952 | + if ($d != 0) { |
|
953 | + $_POST['ignore_brd'][$k] = $d; |
|
954 | + } else { |
|
955 | + unset($_POST['ignore_brd'][$k]); |
|
956 | + } |
|
915 | 957 | } |
916 | 958 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
917 | 959 | unset($_POST['ignore_brd']); |
@@ -924,21 +966,26 @@ discard block |
||
924 | 966 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
925 | 967 | //makeAvatarChanges($memID, $post_errors); |
926 | 968 | |
927 | - if (!empty($_REQUEST['sa'])) |
|
928 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
969 | + if (!empty($_REQUEST['sa'])) { |
|
970 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
971 | + } |
|
929 | 972 | |
930 | - foreach ($profile_bools as $var) |
|
931 | - if (isset($_POST[$var])) |
|
973 | + foreach ($profile_bools as $var) { |
|
974 | + if (isset($_POST[$var])) |
|
932 | 975 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
933 | - foreach ($profile_ints as $var) |
|
934 | - if (isset($_POST[$var])) |
|
976 | + } |
|
977 | + foreach ($profile_ints as $var) { |
|
978 | + if (isset($_POST[$var])) |
|
935 | 979 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
936 | - foreach ($profile_floats as $var) |
|
937 | - if (isset($_POST[$var])) |
|
980 | + } |
|
981 | + foreach ($profile_floats as $var) { |
|
982 | + if (isset($_POST[$var])) |
|
938 | 983 | $profile_vars[$var] = (float) $_POST[$var]; |
939 | - foreach ($profile_strings as $var) |
|
940 | - if (isset($_POST[$var])) |
|
984 | + } |
|
985 | + foreach ($profile_strings as $var) { |
|
986 | + if (isset($_POST[$var])) |
|
941 | 987 | $profile_vars[$var] = $_POST[$var]; |
988 | + } |
|
942 | 989 | } |
943 | 990 | } |
944 | 991 | |
@@ -972,8 +1019,9 @@ discard block |
||
972 | 1019 | ); |
973 | 1020 | |
974 | 1021 | // Can't change reserved vars. |
975 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
976 | - fatal_lang_error('no_access', false); |
|
1022 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
1023 | + fatal_lang_error('no_access', false); |
|
1024 | + } |
|
977 | 1025 | |
978 | 1026 | // Don't allow any overriding of custom fields with default or non-default options. |
979 | 1027 | $request = $smcFunc['db_query']('', ' |
@@ -985,8 +1033,9 @@ discard block |
||
985 | 1033 | ) |
986 | 1034 | ); |
987 | 1035 | $custom_fields = array(); |
988 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
989 | - $custom_fields[] = $row['col_name']; |
|
1036 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1037 | + $custom_fields[] = $row['col_name']; |
|
1038 | + } |
|
990 | 1039 | $smcFunc['db_free_result']($request); |
991 | 1040 | |
992 | 1041 | // These are the theme changes... |
@@ -995,33 +1044,39 @@ discard block |
||
995 | 1044 | { |
996 | 1045 | foreach ($_POST['options'] as $opt => $val) |
997 | 1046 | { |
998 | - if (in_array($opt, $custom_fields)) |
|
999 | - continue; |
|
1047 | + if (in_array($opt, $custom_fields)) { |
|
1048 | + continue; |
|
1049 | + } |
|
1000 | 1050 | |
1001 | 1051 | // These need to be controlled. |
1002 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1003 | - $val = max(0, min($val, 50)); |
|
1052 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1053 | + $val = max(0, min($val, 50)); |
|
1054 | + } |
|
1004 | 1055 | // We don't set this per theme anymore. |
1005 | - elseif ($opt == 'allow_no_censored') |
|
1006 | - continue; |
|
1056 | + elseif ($opt == 'allow_no_censored') { |
|
1057 | + continue; |
|
1058 | + } |
|
1007 | 1059 | |
1008 | 1060 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
1009 | 1061 | } |
1010 | 1062 | } |
1011 | 1063 | |
1012 | 1064 | $erase_options = array(); |
1013 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
1014 | - foreach ($_POST['default_options'] as $opt => $val) |
|
1065 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
1066 | + foreach ($_POST['default_options'] as $opt => $val) |
|
1015 | 1067 | { |
1016 | 1068 | if (in_array($opt, $custom_fields)) |
1017 | 1069 | continue; |
1070 | + } |
|
1018 | 1071 | |
1019 | 1072 | // These need to be controlled. |
1020 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1021 | - $val = max(0, min($val, 50)); |
|
1073 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1074 | + $val = max(0, min($val, 50)); |
|
1075 | + } |
|
1022 | 1076 | // Only let admins and owners change the censor. |
1023 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
1024 | - continue; |
|
1077 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
1078 | + continue; |
|
1079 | + } |
|
1025 | 1080 | |
1026 | 1081 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
1027 | 1082 | $erase_options[] = $opt; |
@@ -1057,8 +1112,9 @@ discard block |
||
1057 | 1112 | |
1058 | 1113 | // Admins can choose any theme, even if it's not enabled... |
1059 | 1114 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
1060 | - foreach ($themes as $t) |
|
1061 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1115 | + foreach ($themes as $t) { |
|
1116 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1117 | + } |
|
1062 | 1118 | } |
1063 | 1119 | } |
1064 | 1120 | |
@@ -1077,8 +1133,9 @@ discard block |
||
1077 | 1133 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
1078 | 1134 | { |
1079 | 1135 | // Make sure only integers are deleted. |
1080 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
1081 | - $_POST['notify_boards'][$index] = (int) $id; |
|
1136 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
1137 | + $_POST['notify_boards'][$index] = (int) $id; |
|
1138 | + } |
|
1082 | 1139 | |
1083 | 1140 | // id_board = 0 is reserved for topic notifications. |
1084 | 1141 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1097,8 +1154,9 @@ discard block |
||
1097 | 1154 | // We are editing topic notifications...... |
1098 | 1155 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
1099 | 1156 | { |
1100 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
1101 | - $_POST['notify_topics'][$index] = (int) $id; |
|
1157 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
1158 | + $_POST['notify_topics'][$index] = (int) $id; |
|
1159 | + } |
|
1102 | 1160 | |
1103 | 1161 | // Make sure there are no zeros left. |
1104 | 1162 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1112,16 +1170,18 @@ discard block |
||
1112 | 1170 | 'selected_member' => $memID, |
1113 | 1171 | ) |
1114 | 1172 | ); |
1115 | - foreach ($_POST['notify_topics'] as $topic) |
|
1116 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1173 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1174 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1175 | + } |
|
1117 | 1176 | } |
1118 | 1177 | |
1119 | 1178 | // We are removing topic preferences |
1120 | 1179 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
1121 | 1180 | { |
1122 | 1181 | $prefs = array(); |
1123 | - foreach ($_POST['notify_topics'] as $topic) |
|
1124 | - $prefs[] = 'topic_notify_' . $topic; |
|
1182 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1183 | + $prefs[] = 'topic_notify_' . $topic; |
|
1184 | + } |
|
1125 | 1185 | deleteNotifyPrefs($memID, $prefs); |
1126 | 1186 | } |
1127 | 1187 | |
@@ -1129,8 +1189,9 @@ discard block |
||
1129 | 1189 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
1130 | 1190 | { |
1131 | 1191 | $prefs = array(); |
1132 | - foreach ($_POST['notify_boards'] as $board) |
|
1133 | - $prefs[] = 'board_notify_' . $board; |
|
1192 | + foreach ($_POST['notify_boards'] as $board) { |
|
1193 | + $prefs[] = 'board_notify_' . $board; |
|
1194 | + } |
|
1134 | 1195 | deleteNotifyPrefs($memID, $prefs); |
1135 | 1196 | } |
1136 | 1197 | } |
@@ -1151,8 +1212,9 @@ discard block |
||
1151 | 1212 | |
1152 | 1213 | $errors = array(); |
1153 | 1214 | |
1154 | - if ($sanitize && isset($_POST['customfield'])) |
|
1155 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1215 | + if ($sanitize && isset($_POST['customfield'])) { |
|
1216 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1217 | + } |
|
1156 | 1218 | |
1157 | 1219 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
1158 | 1220 | |
@@ -1178,26 +1240,29 @@ discard block |
||
1178 | 1240 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
1179 | 1241 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
1180 | 1242 | */ |
1181 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
1182 | - continue; |
|
1243 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
1244 | + continue; |
|
1245 | + } |
|
1183 | 1246 | |
1184 | 1247 | // Validate the user data. |
1185 | - if ($row['field_type'] == 'check') |
|
1186 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1187 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1248 | + if ($row['field_type'] == 'check') { |
|
1249 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1250 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1188 | 1251 | { |
1189 | 1252 | $value = $row['default_value']; |
1190 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1191 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1253 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
1254 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1192 | 1255 | $value = $v; |
1256 | + } |
|
1193 | 1257 | } |
1194 | 1258 | // Otherwise some form of text! |
1195 | 1259 | else |
1196 | 1260 | { |
1197 | 1261 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
1198 | 1262 | |
1199 | - if ($row['field_length']) |
|
1200 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1263 | + if ($row['field_length']) { |
|
1264 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1265 | + } |
|
1201 | 1266 | |
1202 | 1267 | // Any masks? |
1203 | 1268 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
@@ -1206,36 +1271,34 @@ discard block |
||
1206 | 1271 | $valueReference = un_htmlspecialchars($value); |
1207 | 1272 | |
1208 | 1273 | // Try and avoid some checks. '0' could be a valid non-empty value. |
1209 | - if (empty($value) && !is_numeric($value)) |
|
1210 | - $value = ''; |
|
1274 | + if (empty($value) && !is_numeric($value)) { |
|
1275 | + $value = ''; |
|
1276 | + } |
|
1211 | 1277 | |
1212 | 1278 | if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference))) |
1213 | 1279 | { |
1214 | - if ($returnErrors) |
|
1215 | - $errors[] = 'custom_field_nohtml_fail'; |
|
1216 | - |
|
1217 | - else |
|
1218 | - $value = ''; |
|
1219 | - } |
|
1220 | - elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
1280 | + if ($returnErrors) { |
|
1281 | + $errors[] = 'custom_field_nohtml_fail'; |
|
1282 | + } else { |
|
1283 | + $value = ''; |
|
1284 | + } |
|
1285 | + } elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
1221 | 1286 | { |
1222 | - if ($returnErrors) |
|
1223 | - $errors[] = 'custom_field_mail_fail'; |
|
1224 | - |
|
1225 | - else |
|
1226 | - $value = ''; |
|
1227 | - } |
|
1228 | - elseif ($row['mask'] == 'number') |
|
1287 | + if ($returnErrors) { |
|
1288 | + $errors[] = 'custom_field_mail_fail'; |
|
1289 | + } else { |
|
1290 | + $value = ''; |
|
1291 | + } |
|
1292 | + } elseif ($row['mask'] == 'number') |
|
1229 | 1293 | { |
1230 | 1294 | $value = (int) $value; |
1231 | - } |
|
1232 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1295 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1233 | 1296 | { |
1234 | - if ($returnErrors) |
|
1235 | - $errors[] = 'custom_field_regex_fail'; |
|
1236 | - |
|
1237 | - else |
|
1238 | - $value = ''; |
|
1297 | + if ($returnErrors) { |
|
1298 | + $errors[] = 'custom_field_regex_fail'; |
|
1299 | + } else { |
|
1300 | + $value = ''; |
|
1301 | + } |
|
1239 | 1302 | } |
1240 | 1303 | |
1241 | 1304 | unset($valueReference); |
@@ -1259,8 +1322,7 @@ discard block |
||
1259 | 1322 | { |
1260 | 1323 | $deletes = array('id_theme' => 1 , 'variable' => $row['col_name'], 'id_member' => $memID); |
1261 | 1324 | unset($user_profile[$memID]['options'][$row['col_name']]); |
1262 | - } |
|
1263 | - else |
|
1325 | + } else |
|
1264 | 1326 | { |
1265 | 1327 | $changes[] = array(1, $row['col_name'], $value, $memID); |
1266 | 1328 | $user_profile[$memID]['options'][$row['col_name']] = $value; |
@@ -1271,27 +1333,30 @@ discard block |
||
1271 | 1333 | |
1272 | 1334 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize, &$deletes)); |
1273 | 1335 | |
1274 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
1275 | - $errors = array_merge($errors, $hook_errors); |
|
1336 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
1337 | + $errors = array_merge($errors, $hook_errors); |
|
1338 | + } |
|
1276 | 1339 | |
1277 | 1340 | // Make those changes! |
1278 | 1341 | if ((!empty($changes) || !empty($deletes)) && empty($context['password_auth_failed']) && empty($errors)) |
1279 | 1342 | { |
1280 | - if (!empty($changes)) |
|
1281 | - $smcFunc['db_insert']('replace', |
|
1343 | + if (!empty($changes)) { |
|
1344 | + $smcFunc['db_insert']('replace', |
|
1282 | 1345 | '{db_prefix}themes', |
1283 | 1346 | array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534', 'id_member' => 'int'), |
1284 | 1347 | $changes, |
1285 | 1348 | array('id_theme', 'variable', 'id_member') |
1286 | 1349 | ); |
1287 | - if (!empty($deletes)) |
|
1288 | - $smcFunc['db_query']('',' |
|
1350 | + } |
|
1351 | + if (!empty($deletes)) { |
|
1352 | + $smcFunc['db_query']('',' |
|
1289 | 1353 | DELETE FROM {db_prefix}themes |
1290 | 1354 | WHERE id_theme = {int:id_theme} AND |
1291 | 1355 | variable = {string:variable} AND |
1292 | 1356 | id_member = {int:id_member}', |
1293 | 1357 | $deletes |
1294 | 1358 | ); |
1359 | + } |
|
1295 | 1360 | if (!empty($log_changes) && !empty($modSettings['modlog_enabled'])) |
1296 | 1361 | { |
1297 | 1362 | require_once($sourcedir . '/Logging.php'); |
@@ -1299,9 +1364,10 @@ discard block |
||
1299 | 1364 | } |
1300 | 1365 | } |
1301 | 1366 | |
1302 | - if ($returnErrors) |
|
1303 | - return $errors; |
|
1304 | -} |
|
1367 | + if ($returnErrors) { |
|
1368 | + return $errors; |
|
1369 | + } |
|
1370 | + } |
|
1305 | 1371 | |
1306 | 1372 | /** |
1307 | 1373 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1313,8 +1379,9 @@ discard block |
||
1313 | 1379 | global $context, $txt, $modSettings; |
1314 | 1380 | |
1315 | 1381 | // Do a quick check to ensure people aren't getting here illegally! |
1316 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
1317 | - fatal_lang_error('no_access', false); |
|
1382 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
1383 | + fatal_lang_error('no_access', false); |
|
1384 | + } |
|
1318 | 1385 | |
1319 | 1386 | // Can we email the user direct? |
1320 | 1387 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1344,9 +1411,10 @@ discard block |
||
1344 | 1411 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
1345 | 1412 | $call = call_helper($subActions[$context['list_area']][0], true); |
1346 | 1413 | |
1347 | - if (!empty($call)) |
|
1348 | - call_user_func($call, $memID); |
|
1349 | -} |
|
1414 | + if (!empty($call)) { |
|
1415 | + call_user_func($call, $memID); |
|
1416 | + } |
|
1417 | + } |
|
1350 | 1418 | |
1351 | 1419 | /** |
1352 | 1420 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1360,9 +1428,10 @@ discard block |
||
1360 | 1428 | |
1361 | 1429 | // For making changes! |
1362 | 1430 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
1363 | - foreach ($buddiesArray as $k => $dummy) |
|
1364 | - if ($dummy == '') |
|
1431 | + foreach ($buddiesArray as $k => $dummy) { |
|
1432 | + if ($dummy == '') |
|
1365 | 1433 | unset($buddiesArray[$k]); |
1434 | + } |
|
1366 | 1435 | |
1367 | 1436 | // Removing a buddy? |
1368 | 1437 | if (isset($_GET['remove'])) |
@@ -1374,10 +1443,11 @@ discard block |
||
1374 | 1443 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1375 | 1444 | |
1376 | 1445 | // Heh, I'm lazy, do it the easy way... |
1377 | - foreach ($buddiesArray as $key => $buddy) |
|
1378 | - if ($buddy == (int) $_GET['remove']) |
|
1446 | + foreach ($buddiesArray as $key => $buddy) { |
|
1447 | + if ($buddy == (int) $_GET['remove']) |
|
1379 | 1448 | { |
1380 | 1449 | unset($buddiesArray[$key]); |
1450 | + } |
|
1381 | 1451 | $_SESSION['prf-save'] = true; |
1382 | 1452 | } |
1383 | 1453 | |
@@ -1387,8 +1457,7 @@ discard block |
||
1387 | 1457 | |
1388 | 1458 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1389 | 1459 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
1390 | - } |
|
1391 | - elseif (isset($_POST['new_buddy'])) |
|
1460 | + } elseif (isset($_POST['new_buddy'])) |
|
1392 | 1461 | { |
1393 | 1462 | checkSession(); |
1394 | 1463 | |
@@ -1401,8 +1470,9 @@ discard block |
||
1401 | 1470 | { |
1402 | 1471 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
1403 | 1472 | |
1404 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1405 | - unset($new_buddies[$k]); |
|
1473 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1474 | + unset($new_buddies[$k]); |
|
1475 | + } |
|
1406 | 1476 | } |
1407 | 1477 | |
1408 | 1478 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1422,16 +1492,18 @@ discard block |
||
1422 | 1492 | ) |
1423 | 1493 | ); |
1424 | 1494 | |
1425 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1426 | - $_SESSION['prf-save'] = true; |
|
1495 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1496 | + $_SESSION['prf-save'] = true; |
|
1497 | + } |
|
1427 | 1498 | |
1428 | 1499 | // Add the new member to the buddies array. |
1429 | 1500 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1430 | 1501 | { |
1431 | - if (in_array($row['id_member'], $buddiesArray)) |
|
1432 | - continue; |
|
1433 | - else |
|
1434 | - $buddiesArray[] = (int) $row['id_member']; |
|
1502 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
1503 | + continue; |
|
1504 | + } else { |
|
1505 | + $buddiesArray[] = (int) $row['id_member']; |
|
1506 | + } |
|
1435 | 1507 | } |
1436 | 1508 | $smcFunc['db_free_result']($request); |
1437 | 1509 | |
@@ -1461,18 +1533,20 @@ discard block |
||
1461 | 1533 | |
1462 | 1534 | $context['custom_pf'] = array(); |
1463 | 1535 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
1464 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1465 | - if (!isset($disabled_fields[$row['col_name']])) |
|
1536 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1537 | + if (!isset($disabled_fields[$row['col_name']])) |
|
1466 | 1538 | $context['custom_pf'][$row['col_name']] = array( |
1467 | 1539 | 'label' => $row['field_name'], |
1468 | 1540 | 'type' => $row['field_type'], |
1469 | 1541 | 'bbc' => !empty($row['bbc']), |
1470 | 1542 | 'enclose' => $row['enclose'], |
1471 | 1543 | ); |
1544 | + } |
|
1472 | 1545 | |
1473 | 1546 | // Gotta disable the gender option. |
1474 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') |
|
1475 | - unset($context['custom_pf']['cust_gender']); |
|
1547 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') { |
|
1548 | + unset($context['custom_pf']['cust_gender']); |
|
1549 | + } |
|
1476 | 1550 | |
1477 | 1551 | $smcFunc['db_free_result']($request); |
1478 | 1552 | |
@@ -1489,8 +1563,9 @@ discard block |
||
1489 | 1563 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
1490 | 1564 | ) |
1491 | 1565 | ); |
1492 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1493 | - $buddies[] = $row['id_member']; |
|
1566 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1567 | + $buddies[] = $row['id_member']; |
|
1568 | + } |
|
1494 | 1569 | $smcFunc['db_free_result']($result); |
1495 | 1570 | } |
1496 | 1571 | |
@@ -1518,30 +1593,32 @@ discard block |
||
1518 | 1593 | continue; |
1519 | 1594 | } |
1520 | 1595 | |
1521 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1522 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1523 | - |
|
1524 | - elseif ($column['type'] == 'check') |
|
1525 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1596 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1597 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1598 | + } elseif ($column['type'] == 'check') { |
|
1599 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1600 | + } |
|
1526 | 1601 | |
1527 | 1602 | // Enclosing the user input within some other text? |
1528 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1529 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1603 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1604 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1530 | 1605 | '{SCRIPTURL}' => $scripturl, |
1531 | 1606 | '{IMAGES_URL}' => $settings['images_url'], |
1532 | 1607 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1533 | 1608 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
1534 | 1609 | )); |
1610 | + } |
|
1535 | 1611 | } |
1536 | 1612 | } |
1537 | 1613 | } |
1538 | 1614 | |
1539 | 1615 | if (isset($_SESSION['prf-save'])) |
1540 | 1616 | { |
1541 | - if ($_SESSION['prf-save'] === true) |
|
1542 | - $context['saved_successful'] = true; |
|
1543 | - else |
|
1544 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1617 | + if ($_SESSION['prf-save'] === true) { |
|
1618 | + $context['saved_successful'] = true; |
|
1619 | + } else { |
|
1620 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1621 | + } |
|
1545 | 1622 | |
1546 | 1623 | unset($_SESSION['prf-save']); |
1547 | 1624 | } |
@@ -1561,9 +1638,10 @@ discard block |
||
1561 | 1638 | |
1562 | 1639 | // For making changes! |
1563 | 1640 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
1564 | - foreach ($ignoreArray as $k => $dummy) |
|
1565 | - if ($dummy == '') |
|
1641 | + foreach ($ignoreArray as $k => $dummy) { |
|
1642 | + if ($dummy == '') |
|
1566 | 1643 | unset($ignoreArray[$k]); |
1644 | + } |
|
1567 | 1645 | |
1568 | 1646 | // Removing a member from the ignore list? |
1569 | 1647 | if (isset($_GET['remove'])) |
@@ -1573,10 +1651,11 @@ discard block |
||
1573 | 1651 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1574 | 1652 | |
1575 | 1653 | // Heh, I'm lazy, do it the easy way... |
1576 | - foreach ($ignoreArray as $key => $id_remove) |
|
1577 | - if ($id_remove == (int) $_GET['remove']) |
|
1654 | + foreach ($ignoreArray as $key => $id_remove) { |
|
1655 | + if ($id_remove == (int) $_GET['remove']) |
|
1578 | 1656 | { |
1579 | 1657 | unset($ignoreArray[$key]); |
1658 | + } |
|
1580 | 1659 | $_SESSION['prf-save'] = true; |
1581 | 1660 | } |
1582 | 1661 | |
@@ -1586,8 +1665,7 @@ discard block |
||
1586 | 1665 | |
1587 | 1666 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1588 | 1667 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
1589 | - } |
|
1590 | - elseif (isset($_POST['new_ignore'])) |
|
1668 | + } elseif (isset($_POST['new_ignore'])) |
|
1591 | 1669 | { |
1592 | 1670 | checkSession(); |
1593 | 1671 | // Prepare the string for extraction... |
@@ -1599,8 +1677,9 @@ discard block |
||
1599 | 1677 | { |
1600 | 1678 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
1601 | 1679 | |
1602 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1603 | - unset($new_entries[$k]); |
|
1680 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1681 | + unset($new_entries[$k]); |
|
1682 | + } |
|
1604 | 1683 | } |
1605 | 1684 | |
1606 | 1685 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1618,16 +1697,18 @@ discard block |
||
1618 | 1697 | ) |
1619 | 1698 | ); |
1620 | 1699 | |
1621 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1622 | - $_SESSION['prf-save'] = true; |
|
1700 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1701 | + $_SESSION['prf-save'] = true; |
|
1702 | + } |
|
1623 | 1703 | |
1624 | 1704 | // Add the new member to the buddies array. |
1625 | 1705 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1626 | 1706 | { |
1627 | - if (in_array($row['id_member'], $ignoreArray)) |
|
1628 | - continue; |
|
1629 | - else |
|
1630 | - $ignoreArray[] = (int) $row['id_member']; |
|
1707 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
1708 | + continue; |
|
1709 | + } else { |
|
1710 | + $ignoreArray[] = (int) $row['id_member']; |
|
1711 | + } |
|
1631 | 1712 | } |
1632 | 1713 | $smcFunc['db_free_result']($request); |
1633 | 1714 | |
@@ -1656,8 +1737,9 @@ discard block |
||
1656 | 1737 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
1657 | 1738 | ) |
1658 | 1739 | ); |
1659 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1660 | - $ignored[] = $row['id_member']; |
|
1740 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1741 | + $ignored[] = $row['id_member']; |
|
1742 | + } |
|
1661 | 1743 | $smcFunc['db_free_result']($result); |
1662 | 1744 | } |
1663 | 1745 | |
@@ -1676,10 +1758,11 @@ discard block |
||
1676 | 1758 | |
1677 | 1759 | if (isset($_SESSION['prf-save'])) |
1678 | 1760 | { |
1679 | - if ($_SESSION['prf-save'] === true) |
|
1680 | - $context['saved_successful'] = true; |
|
1681 | - else |
|
1682 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1761 | + if ($_SESSION['prf-save'] === true) { |
|
1762 | + $context['saved_successful'] = true; |
|
1763 | + } else { |
|
1764 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1765 | + } |
|
1683 | 1766 | |
1684 | 1767 | unset($_SESSION['prf-save']); |
1685 | 1768 | } |
@@ -1695,8 +1778,9 @@ discard block |
||
1695 | 1778 | global $context, $txt; |
1696 | 1779 | |
1697 | 1780 | loadThemeOptions($memID); |
1698 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
1699 | - loadCustomFields($memID, 'account'); |
|
1781 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
1782 | + loadCustomFields($memID, 'account'); |
|
1783 | + } |
|
1700 | 1784 | |
1701 | 1785 | $context['sub_template'] = 'edit_options'; |
1702 | 1786 | $context['page_desc'] = $txt['account_info']; |
@@ -1723,8 +1807,9 @@ discard block |
||
1723 | 1807 | global $context, $txt; |
1724 | 1808 | |
1725 | 1809 | loadThemeOptions($memID); |
1726 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
1727 | - loadCustomFields($memID, 'forumprofile'); |
|
1810 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
1811 | + loadCustomFields($memID, 'forumprofile'); |
|
1812 | + } |
|
1728 | 1813 | |
1729 | 1814 | $context['sub_template'] = 'edit_options'; |
1730 | 1815 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1757,18 +1842,21 @@ discard block |
||
1757 | 1842 | $dirs = array(); |
1758 | 1843 | $files = array(); |
1759 | 1844 | |
1760 | - if (!$dir) |
|
1761 | - return array(); |
|
1845 | + if (!$dir) { |
|
1846 | + return array(); |
|
1847 | + } |
|
1762 | 1848 | |
1763 | 1849 | while ($line = $dir->read()) |
1764 | 1850 | { |
1765 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
1766 | - continue; |
|
1851 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
1852 | + continue; |
|
1853 | + } |
|
1767 | 1854 | |
1768 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
1769 | - $dirs[] = $line; |
|
1770 | - else |
|
1771 | - $files[] = $line; |
|
1855 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
1856 | + $dirs[] = $line; |
|
1857 | + } else { |
|
1858 | + $files[] = $line; |
|
1859 | + } |
|
1772 | 1860 | } |
1773 | 1861 | $dir->close(); |
1774 | 1862 | |
@@ -1789,14 +1877,15 @@ discard block |
||
1789 | 1877 | foreach ($dirs as $line) |
1790 | 1878 | { |
1791 | 1879 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
1792 | - if (!empty($tmp)) |
|
1793 | - $result[] = array( |
|
1880 | + if (!empty($tmp)) { |
|
1881 | + $result[] = array( |
|
1794 | 1882 | 'filename' => $smcFunc['htmlspecialchars']($line), |
1795 | 1883 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
1796 | 1884 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
1797 | 1885 | 'is_dir' => true, |
1798 | 1886 | 'files' => $tmp |
1799 | 1887 | ); |
1888 | + } |
|
1800 | 1889 | unset($tmp); |
1801 | 1890 | } |
1802 | 1891 | |
@@ -1806,8 +1895,9 @@ discard block |
||
1806 | 1895 | $extension = substr(strrchr($line, '.'), 1); |
1807 | 1896 | |
1808 | 1897 | // Make sure it is an image. |
1809 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
1810 | - continue; |
|
1898 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
1899 | + continue; |
|
1900 | + } |
|
1811 | 1901 | |
1812 | 1902 | $result[] = array( |
1813 | 1903 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1815,8 +1905,9 @@ discard block |
||
1815 | 1905 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
1816 | 1906 | 'is_dir' => false |
1817 | 1907 | ); |
1818 | - if ($level == 1) |
|
1819 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
1908 | + if ($level == 1) { |
|
1909 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
1910 | + } |
|
1820 | 1911 | } |
1821 | 1912 | |
1822 | 1913 | return $result; |
@@ -1838,8 +1929,9 @@ discard block |
||
1838 | 1929 | call_integration_hook('integrate_theme_options'); |
1839 | 1930 | |
1840 | 1931 | loadThemeOptions($memID); |
1841 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
1842 | - loadCustomFields($memID, 'theme'); |
|
1932 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
1933 | + loadCustomFields($memID, 'theme'); |
|
1934 | + } |
|
1843 | 1935 | |
1844 | 1936 | $context['sub_template'] = 'edit_options'; |
1845 | 1937 | $context['page_desc'] = $txt['theme_info']; |
@@ -1893,16 +1985,19 @@ discard block |
||
1893 | 1985 | { |
1894 | 1986 | global $txt, $context, $modSettings, $smcFunc, $sourcedir; |
1895 | 1987 | |
1896 | - if (!isset($context['token_check'])) |
|
1897 | - $context['token_check'] = 'profile-nt' . $memID; |
|
1988 | + if (!isset($context['token_check'])) { |
|
1989 | + $context['token_check'] = 'profile-nt' . $memID; |
|
1990 | + } |
|
1898 | 1991 | |
1899 | 1992 | is_not_guest(); |
1900 | - if (!$context['user']['is_owner']) |
|
1901 | - isAllowedTo('profile_extra_any'); |
|
1993 | + if (!$context['user']['is_owner']) { |
|
1994 | + isAllowedTo('profile_extra_any'); |
|
1995 | + } |
|
1902 | 1996 | |
1903 | 1997 | // Set the post action if we're coming from the profile... |
1904 | - if (!isset($context['action'])) |
|
1905 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1998 | + if (!isset($context['action'])) { |
|
1999 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
2000 | + } |
|
1906 | 2001 | |
1907 | 2002 | // What options are set |
1908 | 2003 | loadThemeOptions($memID); |
@@ -1989,28 +2084,34 @@ discard block |
||
1989 | 2084 | ); |
1990 | 2085 | |
1991 | 2086 | // There are certain things that are disabled at the group level. |
1992 | - if (empty($modSettings['cal_enabled'])) |
|
1993 | - unset($alert_types['calendar']); |
|
2087 | + if (empty($modSettings['cal_enabled'])) { |
|
2088 | + unset($alert_types['calendar']); |
|
2089 | + } |
|
1994 | 2090 | |
1995 | 2091 | // Disable paid subscriptions at group level if they're disabled |
1996 | - if (empty($modSettings['paid_enabled'])) |
|
1997 | - unset($alert_types['paidsubs']); |
|
2092 | + if (empty($modSettings['paid_enabled'])) { |
|
2093 | + unset($alert_types['paidsubs']); |
|
2094 | + } |
|
1998 | 2095 | |
1999 | 2096 | // Disable membergroup requests at group level if they're disabled |
2000 | - if (empty($modSettings['show_group_membership'])) |
|
2001 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2097 | + if (empty($modSettings['show_group_membership'])) { |
|
2098 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2099 | + } |
|
2002 | 2100 | |
2003 | 2101 | // Disable mentions if they're disabled |
2004 | - if (empty($modSettings['enable_mentions'])) |
|
2005 | - unset($alert_types['msg']['msg_mention']); |
|
2102 | + if (empty($modSettings['enable_mentions'])) { |
|
2103 | + unset($alert_types['msg']['msg_mention']); |
|
2104 | + } |
|
2006 | 2105 | |
2007 | 2106 | // Disable likes if they're disabled |
2008 | - if (empty($modSettings['enable_likes'])) |
|
2009 | - unset($alert_types['msg']['msg_like']); |
|
2107 | + if (empty($modSettings['enable_likes'])) { |
|
2108 | + unset($alert_types['msg']['msg_like']); |
|
2109 | + } |
|
2010 | 2110 | |
2011 | 2111 | // Disable buddy requests if they're disabled |
2012 | - if (empty($modSettings['enable_buddylist'])) |
|
2013 | - unset($alert_types['members']['buddy_request']); |
|
2112 | + if (empty($modSettings['enable_buddylist'])) { |
|
2113 | + unset($alert_types['members']['buddy_request']); |
|
2114 | + } |
|
2014 | 2115 | |
2015 | 2116 | // Now, now, we could pass this through global but we should really get into the habit of |
2016 | 2117 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -2038,15 +2139,17 @@ discard block |
||
2038 | 2139 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
2039 | 2140 | } |
2040 | 2141 | |
2041 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
2042 | - unset($alert_types['members']['request_group']); |
|
2142 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
2143 | + unset($alert_types['members']['request_group']); |
|
2144 | + } |
|
2043 | 2145 | |
2044 | 2146 | foreach ($alert_types as $group => $items) |
2045 | 2147 | { |
2046 | 2148 | foreach ($items as $alert_key => $alert_value) |
2047 | 2149 | { |
2048 | - if (!isset($alert_value['permission'])) |
|
2049 | - continue; |
|
2150 | + if (!isset($alert_value['permission'])) { |
|
2151 | + continue; |
|
2152 | + } |
|
2050 | 2153 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
2051 | 2154 | { |
2052 | 2155 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2054,12 +2157,14 @@ discard block |
||
2054 | 2157 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
2055 | 2158 | } |
2056 | 2159 | |
2057 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
2058 | - unset ($alert_types[$group][$alert_key]); |
|
2160 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
2161 | + unset ($alert_types[$group][$alert_key]); |
|
2162 | + } |
|
2059 | 2163 | } |
2060 | 2164 | |
2061 | - if (empty($alert_types[$group])) |
|
2062 | - unset ($alert_types[$group]); |
|
2165 | + if (empty($alert_types[$group])) { |
|
2166 | + unset ($alert_types[$group]); |
|
2167 | + } |
|
2063 | 2168 | } |
2064 | 2169 | } |
2065 | 2170 | |
@@ -2091,9 +2196,9 @@ discard block |
||
2091 | 2196 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
2092 | 2197 | break; |
2093 | 2198 | case 'select': |
2094 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
2095 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2096 | - else |
|
2199 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
2200 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2201 | + } else |
|
2097 | 2202 | { |
2098 | 2203 | // We didn't have a sane value. Let's grab the first item from the possibles. |
2099 | 2204 | $keys = array_keys($this_option['opts']); |
@@ -2113,23 +2218,28 @@ discard block |
||
2113 | 2218 | $this_value = 0; |
2114 | 2219 | foreach ($context['alert_bits'] as $type => $bitvalue) |
2115 | 2220 | { |
2116 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
2117 | - $this_value |= $bitvalue; |
|
2221 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
2222 | + $this_value |= $bitvalue; |
|
2223 | + } |
|
2224 | + } |
|
2225 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
2226 | + $update_prefs[$item_key] = $this_value; |
|
2118 | 2227 | } |
2119 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
2120 | - $update_prefs[$item_key] = $this_value; |
|
2121 | 2228 | } |
2122 | 2229 | } |
2123 | 2230 | |
2124 | - if (!empty($_POST['opt_alert_timeout'])) |
|
2125 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2231 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
2232 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2233 | + } |
|
2126 | 2234 | |
2127 | - if (!empty($_POST['notify_announcements'])) |
|
2128 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2235 | + if (!empty($_POST['notify_announcements'])) { |
|
2236 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2237 | + } |
|
2129 | 2238 | |
2130 | 2239 | setNotifyPrefs((int) $memID, $update_prefs); |
2131 | - foreach ($update_prefs as $pref => $value) |
|
2132 | - $context['alert_prefs'][$pref] = $value; |
|
2240 | + foreach ($update_prefs as $pref => $value) { |
|
2241 | + $context['alert_prefs'][$pref] = $value; |
|
2242 | + } |
|
2133 | 2243 | |
2134 | 2244 | makeNotificationChanges($memID); |
2135 | 2245 | |
@@ -2159,8 +2269,9 @@ discard block |
||
2159 | 2269 | |
2160 | 2270 | // Now we're all set up. |
2161 | 2271 | is_not_guest(); |
2162 | - if (!$context['user']['is_owner']) |
|
2163 | - fatal_error('no_access'); |
|
2272 | + if (!$context['user']['is_owner']) { |
|
2273 | + fatal_error('no_access'); |
|
2274 | + } |
|
2164 | 2275 | |
2165 | 2276 | checkSession('get'); |
2166 | 2277 | |
@@ -2192,8 +2303,9 @@ discard block |
||
2192 | 2303 | { |
2193 | 2304 | global $smcFunc; |
2194 | 2305 | |
2195 | - if (empty($toMark) || empty($memID)) |
|
2196 | - return false; |
|
2306 | + if (empty($toMark) || empty($memID)) { |
|
2307 | + return false; |
|
2308 | + } |
|
2197 | 2309 | |
2198 | 2310 | $toMark = (array) $toMark; |
2199 | 2311 | |
@@ -2227,8 +2339,9 @@ discard block |
||
2227 | 2339 | { |
2228 | 2340 | global $smcFunc; |
2229 | 2341 | |
2230 | - if (empty($toDelete)) |
|
2231 | - return false; |
|
2342 | + if (empty($toDelete)) { |
|
2343 | + return false; |
|
2344 | + } |
|
2232 | 2345 | |
2233 | 2346 | $toDelete = (array) $toDelete; |
2234 | 2347 | |
@@ -2263,8 +2376,9 @@ discard block |
||
2263 | 2376 | { |
2264 | 2377 | global $smcFunc; |
2265 | 2378 | |
2266 | - if (empty($memID)) |
|
2267 | - return false; |
|
2379 | + if (empty($memID)) { |
|
2380 | + return false; |
|
2381 | + } |
|
2268 | 2382 | |
2269 | 2383 | $request = $smcFunc['db_query']('', ' |
2270 | 2384 | SELECT id_alert |
@@ -2341,8 +2455,9 @@ discard block |
||
2341 | 2455 | { |
2342 | 2456 | $link = $topic['link']; |
2343 | 2457 | |
2344 | - if ($topic['new']) |
|
2345 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2458 | + if ($topic['new']) { |
|
2459 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2460 | + } |
|
2346 | 2461 | |
2347 | 2462 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
2348 | 2463 | |
@@ -2493,8 +2608,9 @@ discard block |
||
2493 | 2608 | { |
2494 | 2609 | $link = $board['link']; |
2495 | 2610 | |
2496 | - if ($board['new']) |
|
2497 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2611 | + if ($board['new']) { |
|
2612 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2613 | + } |
|
2498 | 2614 | |
2499 | 2615 | return $link; |
2500 | 2616 | }, |
@@ -2694,8 +2810,8 @@ discard block |
||
2694 | 2810 | ) |
2695 | 2811 | ); |
2696 | 2812 | $notification_boards = array(); |
2697 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2698 | - $notification_boards[] = array( |
|
2813 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2814 | + $notification_boards[] = array( |
|
2699 | 2815 | 'id' => $row['id_board'], |
2700 | 2816 | 'name' => $row['name'], |
2701 | 2817 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2703,6 +2819,7 @@ discard block |
||
2703 | 2819 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
2704 | 2820 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
2705 | 2821 | ); |
2822 | + } |
|
2706 | 2823 | $smcFunc['db_free_result']($request); |
2707 | 2824 | |
2708 | 2825 | return $notification_boards; |
@@ -2717,17 +2834,18 @@ discard block |
||
2717 | 2834 | { |
2718 | 2835 | global $context, $options, $cur_profile, $smcFunc; |
2719 | 2836 | |
2720 | - if (isset($_POST['default_options'])) |
|
2721 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2837 | + if (isset($_POST['default_options'])) { |
|
2838 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2839 | + } |
|
2722 | 2840 | |
2723 | 2841 | if ($context['user']['is_owner']) |
2724 | 2842 | { |
2725 | 2843 | $context['member']['options'] = $options; |
2726 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
2727 | - foreach ($_POST['options'] as $k => $v) |
|
2844 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
2845 | + foreach ($_POST['options'] as $k => $v) |
|
2728 | 2846 | $context['member']['options'][$k] = $v; |
2729 | - } |
|
2730 | - else |
|
2847 | + } |
|
2848 | + } else |
|
2731 | 2849 | { |
2732 | 2850 | $request = $smcFunc['db_query']('', ' |
2733 | 2851 | SELECT id_member, variable, value |
@@ -2748,8 +2866,9 @@ discard block |
||
2748 | 2866 | continue; |
2749 | 2867 | } |
2750 | 2868 | |
2751 | - if (isset($_POST['options'][$row['variable']])) |
|
2752 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
2869 | + if (isset($_POST['options'][$row['variable']])) { |
|
2870 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
2871 | + } |
|
2753 | 2872 | $context['member']['options'][$row['variable']] = $row['value']; |
2754 | 2873 | } |
2755 | 2874 | $smcFunc['db_free_result']($request); |
@@ -2757,8 +2876,9 @@ discard block |
||
2757 | 2876 | // Load up the default theme options for any missing. |
2758 | 2877 | foreach ($temp as $k => $v) |
2759 | 2878 | { |
2760 | - if (!isset($context['member']['options'][$k])) |
|
2761 | - $context['member']['options'][$k] = $v; |
|
2879 | + if (!isset($context['member']['options'][$k])) { |
|
2880 | + $context['member']['options'][$k] = $v; |
|
2881 | + } |
|
2762 | 2882 | } |
2763 | 2883 | } |
2764 | 2884 | } |
@@ -2773,8 +2893,9 @@ discard block |
||
2773 | 2893 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
2774 | 2894 | |
2775 | 2895 | // Have the admins enabled this option? |
2776 | - if (empty($modSettings['allow_ignore_boards'])) |
|
2777 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2896 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
2897 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2898 | + } |
|
2778 | 2899 | |
2779 | 2900 | // Find all the boards this user is allowed to see. |
2780 | 2901 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2794,12 +2915,13 @@ discard block |
||
2794 | 2915 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2795 | 2916 | { |
2796 | 2917 | // This category hasn't been set up yet.. |
2797 | - if (!isset($context['categories'][$row['id_cat']])) |
|
2798 | - $context['categories'][$row['id_cat']] = array( |
|
2918 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
2919 | + $context['categories'][$row['id_cat']] = array( |
|
2799 | 2920 | 'id' => $row['id_cat'], |
2800 | 2921 | 'name' => $row['cat_name'], |
2801 | 2922 | 'boards' => array() |
2802 | 2923 | ); |
2924 | + } |
|
2803 | 2925 | |
2804 | 2926 | // Set this board up, and let the template know when it's a child. (indent them..) |
2805 | 2927 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2829,18 +2951,20 @@ discard block |
||
2829 | 2951 | } |
2830 | 2952 | |
2831 | 2953 | $max_boards = ceil(count($temp_boards) / 2); |
2832 | - if ($max_boards == 1) |
|
2833 | - $max_boards = 2; |
|
2954 | + if ($max_boards == 1) { |
|
2955 | + $max_boards = 2; |
|
2956 | + } |
|
2834 | 2957 | |
2835 | 2958 | // Now, alternate them so they can be shown left and right ;). |
2836 | 2959 | $context['board_columns'] = array(); |
2837 | 2960 | for ($i = 0; $i < $max_boards; $i++) |
2838 | 2961 | { |
2839 | 2962 | $context['board_columns'][] = $temp_boards[$i]; |
2840 | - if (isset($temp_boards[$i + $max_boards])) |
|
2841 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2842 | - else |
|
2843 | - $context['board_columns'][] = array(); |
|
2963 | + if (isset($temp_boards[$i + $max_boards])) { |
|
2964 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2965 | + } else { |
|
2966 | + $context['board_columns'][] = array(); |
|
2967 | + } |
|
2844 | 2968 | } |
2845 | 2969 | |
2846 | 2970 | loadThemeOptions($memID); |
@@ -2909,8 +3033,9 @@ discard block |
||
2909 | 3033 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2910 | 3034 | { |
2911 | 3035 | // We should skip the administrator group if they don't have the admin_forum permission! |
2912 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
2913 | - continue; |
|
3036 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
3037 | + continue; |
|
3038 | + } |
|
2914 | 3039 | |
2915 | 3040 | $context['member_groups'][$row['id_group']] = array( |
2916 | 3041 | 'id' => $row['id_group'], |
@@ -2956,16 +3081,17 @@ discard block |
||
2956 | 3081 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
2957 | 3082 | // Warning message for signature image limits? |
2958 | 3083 | $context['signature_warning'] = ''; |
2959 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
2960 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
2961 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
2962 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3084 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
3085 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
3086 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
3087 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3088 | + } |
|
2963 | 3089 | |
2964 | 3090 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
2965 | 3091 | |
2966 | - if (empty($context['do_preview'])) |
|
2967 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
2968 | - else |
|
3092 | + if (empty($context['do_preview'])) { |
|
3093 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
3094 | + } else |
|
2969 | 3095 | { |
2970 | 3096 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
2971 | 3097 | $validation = profileValidateSignature($signature); |
@@ -2975,8 +3101,9 @@ discard block |
||
2975 | 3101 | $context['post_errors'] = array(); |
2976 | 3102 | } |
2977 | 3103 | $context['post_errors'][] = 'signature_not_yet_saved'; |
2978 | - if ($validation !== true && $validation !== false) |
|
2979 | - $context['post_errors'][] = $validation; |
|
3104 | + if ($validation !== true && $validation !== false) { |
|
3105 | + $context['post_errors'][] = $validation; |
|
3106 | + } |
|
2980 | 3107 | |
2981 | 3108 | censorText($context['member']['signature']); |
2982 | 3109 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2986,8 +3113,9 @@ discard block |
||
2986 | 3113 | } |
2987 | 3114 | |
2988 | 3115 | // Load the spell checker? |
2989 | - if ($context['show_spellchecking']) |
|
2990 | - loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck'); |
|
3116 | + if ($context['show_spellchecking']) { |
|
3117 | + loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck'); |
|
3118 | + } |
|
2991 | 3119 | |
2992 | 3120 | return true; |
2993 | 3121 | } |
@@ -3021,8 +3149,7 @@ discard block |
||
3021 | 3149 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
3022 | 3150 | ); |
3023 | 3151 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
3024 | - } |
|
3025 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
3152 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
3026 | 3153 | { |
3027 | 3154 | $context['member']['avatar'] += array( |
3028 | 3155 | 'choice' => 'upload', |
@@ -3032,33 +3159,34 @@ discard block |
||
3032 | 3159 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
3033 | 3160 | } |
3034 | 3161 | // Use "avatar_original" here so we show what the user entered even if the image proxy is enabled |
3035 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
3036 | - $context['member']['avatar'] += array( |
|
3162 | + elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
3163 | + $context['member']['avatar'] += array( |
|
3037 | 3164 | 'choice' => 'external', |
3038 | 3165 | 'server_pic' => 'blank.png', |
3039 | 3166 | 'external' => $cur_profile['avatar_original'] |
3040 | 3167 | ); |
3041 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
3042 | - $context['member']['avatar'] += array( |
|
3168 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
3169 | + $context['member']['avatar'] += array( |
|
3043 | 3170 | 'choice' => 'server_stored', |
3044 | 3171 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
3045 | 3172 | 'external' => 'http://' |
3046 | 3173 | ); |
3047 | - else |
|
3048 | - $context['member']['avatar'] += array( |
|
3174 | + } else { |
|
3175 | + $context['member']['avatar'] += array( |
|
3049 | 3176 | 'choice' => 'none', |
3050 | 3177 | 'server_pic' => 'blank.png', |
3051 | 3178 | 'external' => 'http://' |
3052 | 3179 | ); |
3180 | + } |
|
3053 | 3181 | |
3054 | 3182 | // Get a list of all the avatars. |
3055 | 3183 | if ($context['member']['avatar']['allow_server_stored']) |
3056 | 3184 | { |
3057 | 3185 | $context['avatar_list'] = array(); |
3058 | 3186 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
3187 | + } else { |
|
3188 | + $context['avatars'] = array(); |
|
3059 | 3189 | } |
3060 | - else |
|
3061 | - $context['avatars'] = array(); |
|
3062 | 3190 | |
3063 | 3191 | // Second level selected avatar... |
3064 | 3192 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3087,19 +3215,22 @@ discard block |
||
3087 | 3215 | ) |
3088 | 3216 | ); |
3089 | 3217 | $protected_groups = array(1); |
3090 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3091 | - $protected_groups[] = $row['id_group']; |
|
3218 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3219 | + $protected_groups[] = $row['id_group']; |
|
3220 | + } |
|
3092 | 3221 | $smcFunc['db_free_result']($request); |
3093 | 3222 | |
3094 | 3223 | $protected_groups = array_unique($protected_groups); |
3095 | 3224 | } |
3096 | 3225 | |
3097 | 3226 | // The account page allows the change of your id_group - but not to a protected group! |
3098 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
3099 | - $value = (int) $value; |
|
3227 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
3228 | + $value = (int) $value; |
|
3229 | + } |
|
3100 | 3230 | // ... otherwise it's the old group sir. |
3101 | - else |
|
3102 | - $value = $old_profile['id_group']; |
|
3231 | + else { |
|
3232 | + $value = $old_profile['id_group']; |
|
3233 | + } |
|
3103 | 3234 | |
3104 | 3235 | // Find the additional membergroups (if any) |
3105 | 3236 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3108,16 +3239,18 @@ discard block |
||
3108 | 3239 | foreach ($_POST['additional_groups'] as $group_id) |
3109 | 3240 | { |
3110 | 3241 | $group_id = (int) $group_id; |
3111 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
3112 | - $additional_groups[] = $group_id; |
|
3242 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
3243 | + $additional_groups[] = $group_id; |
|
3244 | + } |
|
3113 | 3245 | } |
3114 | 3246 | |
3115 | 3247 | // Put the protected groups back in there if you don't have permission to take them away. |
3116 | 3248 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
3117 | 3249 | foreach ($old_additional_groups as $group_id) |
3118 | 3250 | { |
3119 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
3120 | - $additional_groups[] = $group_id; |
|
3251 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
3252 | + $additional_groups[] = $group_id; |
|
3253 | + } |
|
3121 | 3254 | } |
3122 | 3255 | |
3123 | 3256 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3149,18 +3282,20 @@ discard block |
||
3149 | 3282 | list ($another) = $smcFunc['db_fetch_row']($request); |
3150 | 3283 | $smcFunc['db_free_result']($request); |
3151 | 3284 | |
3152 | - if (empty($another)) |
|
3153 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
3285 | + if (empty($another)) { |
|
3286 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
3287 | + } |
|
3154 | 3288 | } |
3155 | 3289 | } |
3156 | 3290 | |
3157 | 3291 | // If we are changing group status, update permission cache as necessary. |
3158 | 3292 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
3159 | 3293 | { |
3160 | - if ($context['user']['is_owner']) |
|
3161 | - $_SESSION['mc']['time'] = 0; |
|
3162 | - else |
|
3163 | - updateSettings(array('settings_updated' => time())); |
|
3294 | + if ($context['user']['is_owner']) { |
|
3295 | + $_SESSION['mc']['time'] = 0; |
|
3296 | + } else { |
|
3297 | + updateSettings(array('settings_updated' => time())); |
|
3298 | + } |
|
3164 | 3299 | } |
3165 | 3300 | |
3166 | 3301 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3181,8 +3316,9 @@ discard block |
||
3181 | 3316 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
3182 | 3317 | |
3183 | 3318 | $memID = $context['id_member']; |
3184 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
3185 | - return false; |
|
3319 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
3320 | + return false; |
|
3321 | + } |
|
3186 | 3322 | |
3187 | 3323 | require_once($sourcedir . '/ManageAttachments.php'); |
3188 | 3324 | |
@@ -3193,8 +3329,9 @@ discard block |
||
3193 | 3329 | $downloadedExternalAvatar = false; |
3194 | 3330 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
3195 | 3331 | { |
3196 | - if (!is_writable($uploadDir)) |
|
3197 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3332 | + if (!is_writable($uploadDir)) { |
|
3333 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3334 | + } |
|
3198 | 3335 | |
3199 | 3336 | $url = parse_url($_POST['userpicpersonal']); |
3200 | 3337 | $contents = fetch_web_data($url['scheme'] . '://' . $url['host'] . (empty($url['port']) ? '' : ':' . $url['port']) . str_replace(' ', '%20', trim($url['path']))); |
@@ -3236,19 +3373,18 @@ discard block |
||
3236 | 3373 | |
3237 | 3374 | // Get rid of their old avatar. (if uploaded.) |
3238 | 3375 | removeAttachments(array('id_member' => $memID)); |
3239 | - } |
|
3240 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3376 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3241 | 3377 | { |
3242 | 3378 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
3243 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
3244 | - $profile_vars['avatar'] = 'gravatar://'; |
|
3245 | - else |
|
3246 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3379 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
3380 | + $profile_vars['avatar'] = 'gravatar://'; |
|
3381 | + } else { |
|
3382 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3383 | + } |
|
3247 | 3384 | |
3248 | 3385 | // Get rid of their old avatar. (if uploaded.) |
3249 | 3386 | removeAttachments(array('id_member' => $memID)); |
3250 | - } |
|
3251 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3387 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3252 | 3388 | { |
3253 | 3389 | // We need these clean... |
3254 | 3390 | $cur_profile['id_attach'] = 0; |
@@ -3260,11 +3396,13 @@ discard block |
||
3260 | 3396 | |
3261 | 3397 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
3262 | 3398 | |
3263 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
3264 | - $profile_vars['avatar'] = ''; |
|
3399 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
3400 | + $profile_vars['avatar'] = ''; |
|
3401 | + } |
|
3265 | 3402 | // Trying to make us do something we'll regret? |
3266 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
3267 | - return 'bad_avatar_invalid_url'; |
|
3403 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
3404 | + return 'bad_avatar_invalid_url'; |
|
3405 | + } |
|
3268 | 3406 | // Should we check dimensions? |
3269 | 3407 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
3270 | 3408 | { |
@@ -3274,9 +3412,9 @@ discard block |
||
3274 | 3412 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
3275 | 3413 | { |
3276 | 3414 | // Houston, we have a problem. The avatar is too large!! |
3277 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
3278 | - return 'bad_avatar_too_large'; |
|
3279 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3415 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
3416 | + return 'bad_avatar_too_large'; |
|
3417 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3280 | 3418 | { |
3281 | 3419 | // @todo remove this if appropriate |
3282 | 3420 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3286,26 +3424,27 @@ discard block |
||
3286 | 3424 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
3287 | 3425 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
3288 | 3426 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
3427 | + } else { |
|
3428 | + return 'bad_avatar'; |
|
3289 | 3429 | } |
3290 | - else |
|
3291 | - return 'bad_avatar'; |
|
3292 | 3430 | } |
3293 | 3431 | } |
3294 | 3432 | } |
3295 | - } |
|
3296 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3433 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3297 | 3434 | { |
3298 | 3435 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
3299 | 3436 | { |
3300 | 3437 | // Get the dimensions of the image. |
3301 | 3438 | if (!$downloadedExternalAvatar) |
3302 | 3439 | { |
3303 | - if (!is_writable($uploadDir)) |
|
3304 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3440 | + if (!is_writable($uploadDir)) { |
|
3441 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3442 | + } |
|
3305 | 3443 | |
3306 | 3444 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
3307 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
3308 | - fatal_lang_error('attach_timeout', 'critical'); |
|
3445 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
3446 | + fatal_lang_error('attach_timeout', 'critical'); |
|
3447 | + } |
|
3309 | 3448 | |
3310 | 3449 | $_FILES['attachment']['tmp_name'] = $new_filename; |
3311 | 3450 | } |
@@ -3418,17 +3557,19 @@ discard block |
||
3418 | 3557 | $profile_vars['avatar'] = ''; |
3419 | 3558 | |
3420 | 3559 | // Delete any temporary file. |
3421 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
3422 | - @unlink($_FILES['attachment']['tmp_name']); |
|
3560 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
3561 | + @unlink($_FILES['attachment']['tmp_name']); |
|
3562 | + } |
|
3423 | 3563 | } |
3424 | 3564 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
3425 | - else |
|
3565 | + else { |
|
3566 | + $profile_vars['avatar'] = ''; |
|
3567 | + } |
|
3568 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
3569 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3570 | + } else { |
|
3426 | 3571 | $profile_vars['avatar'] = ''; |
3427 | 3572 | } |
3428 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
3429 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3430 | - else |
|
3431 | - $profile_vars['avatar'] = ''; |
|
3432 | 3573 | |
3433 | 3574 | // Setup the profile variables so it shows things right on display! |
3434 | 3575 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3476,9 +3617,9 @@ discard block |
||
3476 | 3617 | $smiley_parsed = $unparsed_signature; |
3477 | 3618 | parsesmileys($smiley_parsed); |
3478 | 3619 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
3479 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
3480 | - return 'signature_allow_smileys'; |
|
3481 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3620 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
3621 | + return 'signature_allow_smileys'; |
|
3622 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3482 | 3623 | { |
3483 | 3624 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
3484 | 3625 | return 'signature_max_smileys'; |
@@ -3491,14 +3632,15 @@ discard block |
||
3491 | 3632 | { |
3492 | 3633 | $limit_broke = 0; |
3493 | 3634 | // Attempt to allow all sizes of abuse, so to speak. |
3494 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
3495 | - $limit_broke = $sig_limits[7] . 'px'; |
|
3496 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
3497 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3498 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
3499 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3500 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
3501 | - $limit_broke = 'large'; |
|
3635 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
3636 | + $limit_broke = $sig_limits[7] . 'px'; |
|
3637 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
3638 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3639 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
3640 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3641 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
3642 | + $limit_broke = 'large'; |
|
3643 | + } |
|
3502 | 3644 | |
3503 | 3645 | if ($limit_broke) |
3504 | 3646 | { |
@@ -3540,24 +3682,26 @@ discard block |
||
3540 | 3682 | $width = -1; $height = -1; |
3541 | 3683 | |
3542 | 3684 | // Does it have predefined restraints? Width first. |
3543 | - if ($matches[6][$key]) |
|
3544 | - $matches[2][$key] = $matches[6][$key]; |
|
3685 | + if ($matches[6][$key]) { |
|
3686 | + $matches[2][$key] = $matches[6][$key]; |
|
3687 | + } |
|
3545 | 3688 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
3546 | 3689 | { |
3547 | 3690 | $width = $sig_limits[5]; |
3548 | 3691 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
3692 | + } elseif ($matches[2][$key]) { |
|
3693 | + $width = $matches[2][$key]; |
|
3549 | 3694 | } |
3550 | - elseif ($matches[2][$key]) |
|
3551 | - $width = $matches[2][$key]; |
|
3552 | 3695 | // ... and height. |
3553 | 3696 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
3554 | 3697 | { |
3555 | 3698 | $height = $sig_limits[6]; |
3556 | - if ($width != -1) |
|
3557 | - $width = $width * ($height / $matches[4][$key]); |
|
3699 | + if ($width != -1) { |
|
3700 | + $width = $width * ($height / $matches[4][$key]); |
|
3701 | + } |
|
3702 | + } elseif ($matches[4][$key]) { |
|
3703 | + $height = $matches[4][$key]; |
|
3558 | 3704 | } |
3559 | - elseif ($matches[4][$key]) |
|
3560 | - $height = $matches[4][$key]; |
|
3561 | 3705 | |
3562 | 3706 | // If the dimensions are still not fixed - we need to check the actual image. |
3563 | 3707 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3575,21 +3719,24 @@ discard block |
||
3575 | 3719 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
3576 | 3720 | { |
3577 | 3721 | $height = $sig_limits[6]; |
3578 | - if ($width == -1) |
|
3579 | - $width = $sizes[0]; |
|
3722 | + if ($width == -1) { |
|
3723 | + $width = $sizes[0]; |
|
3724 | + } |
|
3580 | 3725 | $width = $width * ($height / $sizes[1]); |
3726 | + } elseif ($width != -1) { |
|
3727 | + $height = $sizes[1]; |
|
3581 | 3728 | } |
3582 | - elseif ($width != -1) |
|
3583 | - $height = $sizes[1]; |
|
3584 | 3729 | } |
3585 | 3730 | } |
3586 | 3731 | |
3587 | 3732 | // Did we come up with some changes? If so remake the string. |
3588 | - if ($width != -1 || $height != -1) |
|
3589 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3733 | + if ($width != -1 || $height != -1) { |
|
3734 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3735 | + } |
|
3736 | + } |
|
3737 | + if (!empty($replaces)) { |
|
3738 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3590 | 3739 | } |
3591 | - if (!empty($replaces)) |
|
3592 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3593 | 3740 | } |
3594 | 3741 | } |
3595 | 3742 | |
@@ -3633,10 +3780,12 @@ discard block |
||
3633 | 3780 | $email = strtr($email, array(''' => '\'')); |
3634 | 3781 | |
3635 | 3782 | // Check the name and email for validity. |
3636 | - if (trim($email) == '') |
|
3637 | - return 'no_email'; |
|
3638 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
3639 | - return 'bad_email'; |
|
3783 | + if (trim($email) == '') { |
|
3784 | + return 'no_email'; |
|
3785 | + } |
|
3786 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
3787 | + return 'bad_email'; |
|
3788 | + } |
|
3640 | 3789 | |
3641 | 3790 | // Email addresses should be and stay unique. |
3642 | 3791 | $request = $smcFunc['db_query']('', ' |
@@ -3651,8 +3800,9 @@ discard block |
||
3651 | 3800 | ) |
3652 | 3801 | ); |
3653 | 3802 | |
3654 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
3655 | - return 'email_taken'; |
|
3803 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
3804 | + return 'email_taken'; |
|
3805 | + } |
|
3656 | 3806 | $smcFunc['db_free_result']($request); |
3657 | 3807 | |
3658 | 3808 | return true; |
@@ -3665,8 +3815,9 @@ discard block |
||
3665 | 3815 | { |
3666 | 3816 | global $modSettings, $context, $cur_profile; |
3667 | 3817 | |
3668 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
3669 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3818 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
3819 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3820 | + } |
|
3670 | 3821 | |
3671 | 3822 | loadUserSettings(); |
3672 | 3823 | writeLog(); |
@@ -3682,8 +3833,9 @@ discard block |
||
3682 | 3833 | require_once($sourcedir . '/Subs-Post.php'); |
3683 | 3834 | |
3684 | 3835 | // Shouldn't happen but just in case. |
3685 | - if (empty($profile_vars['email_address'])) |
|
3686 | - return; |
|
3836 | + if (empty($profile_vars['email_address'])) { |
|
3837 | + return; |
|
3838 | + } |
|
3687 | 3839 | |
3688 | 3840 | $replacements = array( |
3689 | 3841 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3706,8 +3858,9 @@ discard block |
||
3706 | 3858 | $_SESSION['log_time'] = 0; |
3707 | 3859 | $_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0)); |
3708 | 3860 | |
3709 | - if (isset($_COOKIE[$cookiename])) |
|
3710 | - $_COOKIE[$cookiename] = ''; |
|
3861 | + if (isset($_COOKIE[$cookiename])) { |
|
3862 | + $_COOKIE[$cookiename] = ''; |
|
3863 | + } |
|
3711 | 3864 | |
3712 | 3865 | loadUserSettings(); |
3713 | 3866 | |
@@ -3740,11 +3893,13 @@ discard block |
||
3740 | 3893 | $groups[] = $curMember['id_group']; |
3741 | 3894 | |
3742 | 3895 | // Ensure the query doesn't croak! |
3743 | - if (empty($groups)) |
|
3744 | - $groups = array(0); |
|
3896 | + if (empty($groups)) { |
|
3897 | + $groups = array(0); |
|
3898 | + } |
|
3745 | 3899 | // Just to be sure... |
3746 | - foreach ($groups as $k => $v) |
|
3747 | - $groups[$k] = (int) $v; |
|
3900 | + foreach ($groups as $k => $v) { |
|
3901 | + $groups[$k] = (int) $v; |
|
3902 | + } |
|
3748 | 3903 | |
3749 | 3904 | // Get all the membergroups they can join. |
3750 | 3905 | $request = $smcFunc['db_query']('', ' |
@@ -3774,12 +3929,14 @@ discard block |
||
3774 | 3929 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3775 | 3930 | { |
3776 | 3931 | // Can they edit their primary group? |
3777 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
3778 | - $context['can_edit_primary'] = true; |
|
3932 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
3933 | + $context['can_edit_primary'] = true; |
|
3934 | + } |
|
3779 | 3935 | |
3780 | 3936 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
3781 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
3782 | - continue; |
|
3937 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
3938 | + continue; |
|
3939 | + } |
|
3783 | 3940 | |
3784 | 3941 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
3785 | 3942 | 'id' => $row['id_group'], |
@@ -3808,13 +3965,15 @@ discard block |
||
3808 | 3965 | ); |
3809 | 3966 | |
3810 | 3967 | // No changing primary one unless you have enough groups! |
3811 | - if (count($context['groups']['member']) < 2) |
|
3812 | - $context['can_edit_primary'] = false; |
|
3968 | + if (count($context['groups']['member']) < 2) { |
|
3969 | + $context['can_edit_primary'] = false; |
|
3970 | + } |
|
3813 | 3971 | |
3814 | 3972 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
3815 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
3816 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3817 | -} |
|
3973 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
3974 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3975 | + } |
|
3976 | + } |
|
3818 | 3977 | |
3819 | 3978 | /** |
3820 | 3979 | * This function actually makes all the group changes |
@@ -3829,10 +3988,12 @@ discard block |
||
3829 | 3988 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
3830 | 3989 | |
3831 | 3990 | // Let's be extra cautious... |
3832 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
3833 | - isAllowedTo('manage_membergroups'); |
|
3834 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
3835 | - fatal_lang_error('no_access', false); |
|
3991 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
3992 | + isAllowedTo('manage_membergroups'); |
|
3993 | + } |
|
3994 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
3995 | + fatal_lang_error('no_access', false); |
|
3996 | + } |
|
3836 | 3997 | |
3837 | 3998 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
3838 | 3999 | |
@@ -3851,8 +4012,9 @@ discard block |
||
3851 | 4012 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
3852 | 4013 | |
3853 | 4014 | // Sanity check!! |
3854 | - if ($group_id == 1) |
|
3855 | - isAllowedTo('admin_forum'); |
|
4015 | + if ($group_id == 1) { |
|
4016 | + isAllowedTo('admin_forum'); |
|
4017 | + } |
|
3856 | 4018 | // Protected groups too! |
3857 | 4019 | else |
3858 | 4020 | { |
@@ -3869,8 +4031,9 @@ discard block |
||
3869 | 4031 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
3870 | 4032 | $smcFunc['db_free_result']($request); |
3871 | 4033 | |
3872 | - if ($is_protected == 1) |
|
3873 | - isAllowedTo('admin_forum'); |
|
4034 | + if ($is_protected == 1) { |
|
4035 | + isAllowedTo('admin_forum'); |
|
4036 | + } |
|
3874 | 4037 | } |
3875 | 4038 | |
3876 | 4039 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3892,36 +4055,43 @@ discard block |
||
3892 | 4055 | $group_name = $row['group_name']; |
3893 | 4056 | |
3894 | 4057 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
3895 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
3896 | - fatal_lang_error('no_access', false); |
|
4058 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
4059 | + fatal_lang_error('no_access', false); |
|
4060 | + } |
|
3897 | 4061 | // What about leaving a requestable group we are not a member of? |
3898 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
3899 | - fatal_lang_error('no_access', false); |
|
3900 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
3901 | - fatal_lang_error('no_access', false); |
|
4062 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
4063 | + fatal_lang_error('no_access', false); |
|
4064 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
4065 | + fatal_lang_error('no_access', false); |
|
4066 | + } |
|
3902 | 4067 | |
3903 | 4068 | // We can't change the primary group if this is hidden! |
3904 | - if ($row['hidden'] == 2) |
|
3905 | - $canChangePrimary = false; |
|
4069 | + if ($row['hidden'] == 2) { |
|
4070 | + $canChangePrimary = false; |
|
4071 | + } |
|
3906 | 4072 | } |
3907 | 4073 | |
3908 | 4074 | // If this is their old primary, can we change it? |
3909 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
3910 | - $canChangePrimary = 1; |
|
4075 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
4076 | + $canChangePrimary = 1; |
|
4077 | + } |
|
3911 | 4078 | |
3912 | 4079 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
3913 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
3914 | - $canChangePrimary = false; |
|
4080 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
4081 | + $canChangePrimary = false; |
|
4082 | + } |
|
3915 | 4083 | |
3916 | 4084 | // If this is the one we are acting on, can we even act? |
3917 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
3918 | - $canChangePrimary = false; |
|
4085 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
4086 | + $canChangePrimary = false; |
|
4087 | + } |
|
3919 | 4088 | } |
3920 | 4089 | $smcFunc['db_free_result']($request); |
3921 | 4090 | |
3922 | 4091 | // Didn't find the target? |
3923 | - if (!$foundTarget) |
|
3924 | - fatal_lang_error('no_access', false); |
|
4092 | + if (!$foundTarget) { |
|
4093 | + fatal_lang_error('no_access', false); |
|
4094 | + } |
|
3925 | 4095 | |
3926 | 4096 | // Final security check, don't allow users to promote themselves to admin. |
3927 | 4097 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3941,8 +4111,9 @@ discard block |
||
3941 | 4111 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
3942 | 4112 | $smcFunc['db_free_result']($request); |
3943 | 4113 | |
3944 | - if ($disallow) |
|
3945 | - isAllowedTo('admin_forum'); |
|
4114 | + if ($disallow) { |
|
4115 | + isAllowedTo('admin_forum'); |
|
4116 | + } |
|
3946 | 4117 | } |
3947 | 4118 | |
3948 | 4119 | // If we're requesting, add the note then return. |
@@ -3960,8 +4131,9 @@ discard block |
||
3960 | 4131 | 'status_open' => 0, |
3961 | 4132 | ) |
3962 | 4133 | ); |
3963 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
3964 | - fatal_lang_error('profile_error_already_requested_group'); |
|
4134 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
4135 | + fatal_lang_error('profile_error_already_requested_group'); |
|
4136 | + } |
|
3965 | 4137 | $smcFunc['db_free_result']($request); |
3966 | 4138 | |
3967 | 4139 | // Log the request. |
@@ -3995,10 +4167,11 @@ discard block |
||
3995 | 4167 | // Are we leaving? |
3996 | 4168 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
3997 | 4169 | { |
3998 | - if ($old_profile['id_group'] == $group_id) |
|
3999 | - $newPrimary = 0; |
|
4000 | - else |
|
4001 | - unset($addGroups[$group_id]); |
|
4170 | + if ($old_profile['id_group'] == $group_id) { |
|
4171 | + $newPrimary = 0; |
|
4172 | + } else { |
|
4173 | + unset($addGroups[$group_id]); |
|
4174 | + } |
|
4002 | 4175 | } |
4003 | 4176 | // ... if not, must be joining. |
4004 | 4177 | else |
@@ -4006,36 +4179,42 @@ discard block |
||
4006 | 4179 | // Can we change the primary, and do we want to? |
4007 | 4180 | if ($canChangePrimary) |
4008 | 4181 | { |
4009 | - if ($old_profile['id_group'] != 0) |
|
4010 | - $addGroups[$old_profile['id_group']] = -1; |
|
4182 | + if ($old_profile['id_group'] != 0) { |
|
4183 | + $addGroups[$old_profile['id_group']] = -1; |
|
4184 | + } |
|
4011 | 4185 | $newPrimary = $group_id; |
4012 | 4186 | } |
4013 | 4187 | // Otherwise it's an additional group... |
4014 | - else |
|
4015 | - $addGroups[$group_id] = -1; |
|
4188 | + else { |
|
4189 | + $addGroups[$group_id] = -1; |
|
4190 | + } |
|
4016 | 4191 | } |
4017 | 4192 | } |
4018 | 4193 | // Finally, we must be setting the primary. |
4019 | 4194 | elseif ($canChangePrimary) |
4020 | 4195 | { |
4021 | - if ($old_profile['id_group'] != 0) |
|
4022 | - $addGroups[$old_profile['id_group']] = -1; |
|
4023 | - if (isset($addGroups[$group_id])) |
|
4024 | - unset($addGroups[$group_id]); |
|
4196 | + if ($old_profile['id_group'] != 0) { |
|
4197 | + $addGroups[$old_profile['id_group']] = -1; |
|
4198 | + } |
|
4199 | + if (isset($addGroups[$group_id])) { |
|
4200 | + unset($addGroups[$group_id]); |
|
4201 | + } |
|
4025 | 4202 | $newPrimary = $group_id; |
4026 | 4203 | } |
4027 | 4204 | |
4028 | 4205 | // Finally, we can make the changes! |
4029 | - foreach ($addGroups as $id => $dummy) |
|
4030 | - if (empty($id)) |
|
4206 | + foreach ($addGroups as $id => $dummy) { |
|
4207 | + if (empty($id)) |
|
4031 | 4208 | unset($addGroups[$id]); |
4209 | + } |
|
4032 | 4210 | $addGroups = implode(',', array_flip($addGroups)); |
4033 | 4211 | |
4034 | 4212 | // Ensure that we don't cache permissions if the group is changing. |
4035 | - if ($context['user']['is_owner']) |
|
4036 | - $_SESSION['mc']['time'] = 0; |
|
4037 | - else |
|
4038 | - updateSettings(array('settings_updated' => time())); |
|
4213 | + if ($context['user']['is_owner']) { |
|
4214 | + $_SESSION['mc']['time'] = 0; |
|
4215 | + } else { |
|
4216 | + updateSettings(array('settings_updated' => time())); |
|
4217 | + } |
|
4039 | 4218 | |
4040 | 4219 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
4041 | 4220 | |
@@ -4058,8 +4237,9 @@ discard block |
||
4058 | 4237 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
4059 | 4238 | { |
4060 | 4239 | // Check to ensure we're forcing SSL for authentication |
4061 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
4062 | - fatal_lang_error('login_ssl_required'); |
|
4240 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
4241 | + fatal_lang_error('login_ssl_required'); |
|
4242 | + } |
|
4063 | 4243 | |
4064 | 4244 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
4065 | 4245 | // we do not want too much AJAX to confuse them. |
@@ -4096,8 +4276,7 @@ discard block |
||
4096 | 4276 | $context['sub_template'] = 'tfasetup_backup'; |
4097 | 4277 | |
4098 | 4278 | return; |
4099 | - } |
|
4100 | - else |
|
4279 | + } else |
|
4101 | 4280 | { |
4102 | 4281 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
4103 | 4282 | $context['tfa_error'] = !$valid_code; |
@@ -4105,8 +4284,7 @@ discard block |
||
4105 | 4284 | $context['tfa_pass_value'] = $_POST['passwd']; |
4106 | 4285 | $context['tfa_value'] = $_POST['tfa_code']; |
4107 | 4286 | } |
4108 | - } |
|
4109 | - else |
|
4287 | + } else |
|
4110 | 4288 | { |
4111 | 4289 | $totp = new \TOTP\Auth(); |
4112 | 4290 | $secret = $totp->generateCode(); |
@@ -4116,17 +4294,16 @@ discard block |
||
4116 | 4294 | } |
4117 | 4295 | |
4118 | 4296 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
4119 | - } |
|
4120 | - elseif (isset($_REQUEST['disable'])) |
|
4297 | + } elseif (isset($_REQUEST['disable'])) |
|
4121 | 4298 | { |
4122 | 4299 | updateMemberData($memID, array( |
4123 | 4300 | 'tfa_secret' => '', |
4124 | 4301 | 'tfa_backup' => '', |
4125 | 4302 | )); |
4126 | 4303 | redirectexit('action=profile;area=account;u=' . $memID); |
4304 | + } else { |
|
4305 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
4306 | + } |
|
4127 | 4307 | } |
4128 | - else |
|
4129 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
4130 | -} |
|
4131 | 4308 | |
4132 | 4309 | ?> |
4133 | 4310 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
24 | 25 | |
25 | 26 | // Attempt to load the member's profile data. |
26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
27 | - fatal_lang_error('not_a_user', false, 404); |
|
27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
28 | + fatal_lang_error('not_a_user', false, 404); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | // Set up the stuff and load the user. |
30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
49 | 51 | |
50 | 52 | // See if they have broken any warning levels... |
51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | // They haven't even been registered for a full day!? |
60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
63 | - else |
|
64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
66 | + } else { |
|
67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
68 | + } |
|
65 | 69 | |
66 | 70 | // Set the age... |
67 | 71 | if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002) |
@@ -70,8 +74,7 @@ discard block |
||
70 | 74 | 'age' => $txt['not_applicable'], |
71 | 75 | 'today_is_birthday' => false |
72 | 76 | ); |
73 | - } |
|
74 | - else |
|
77 | + } else |
|
75 | 78 | { |
76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
84 | 87 | if (allowedTo('moderate_forum')) |
85 | 88 | { |
86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
89 | - else |
|
90 | - $context['member']['hostname'] = ''; |
|
90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
92 | + } else { |
|
93 | + $context['member']['hostname'] = ''; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | $context['can_see_ip'] = true; |
97 | + } else { |
|
98 | + $context['can_see_ip'] = false; |
|
93 | 99 | } |
94 | - else |
|
95 | - $context['can_see_ip'] = false; |
|
96 | 100 | |
97 | 101 | // Are they hidden? |
98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
103 | 107 | include_once($sourcedir . '/Who.php'); |
104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
105 | 109 | |
106 | - if ($action !== false) |
|
107 | - $context['member']['action'] = $action; |
|
110 | + if ($action !== false) { |
|
111 | + $context['member']['action'] = $action; |
|
112 | + } |
|
108 | 113 | } |
109 | 114 | |
110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | // Work out what restrictions we actually have. |
169 | 174 | $ban_restrictions = array(); |
170 | - foreach (array('access', 'login', 'post') as $type) |
|
171 | - if ($row['cannot_' . $type]) |
|
175 | + foreach (array('access', 'login', 'post') as $type) { |
|
176 | + if ($row['cannot_' . $type]) |
|
172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
178 | + } |
|
173 | 179 | |
174 | 180 | // No actual ban in place? |
175 | - if (empty($ban_restrictions)) |
|
176 | - continue; |
|
181 | + if (empty($ban_restrictions)) { |
|
182 | + continue; |
|
183 | + } |
|
177 | 184 | |
178 | 185 | // Prepare the link for context. |
179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -195,9 +202,10 @@ discard block |
||
195 | 202 | $context['print_custom_fields'] = array(); |
196 | 203 | |
197 | 204 | // Any custom profile fields? |
198 | - if (!empty($context['custom_fields'])) |
|
199 | - foreach ($context['custom_fields'] as $custom) |
|
205 | + if (!empty($context['custom_fields'])) { |
|
206 | + foreach ($context['custom_fields'] as $custom) |
|
200 | 207 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
208 | + } |
|
201 | 209 | |
202 | 210 | } |
203 | 211 | |
@@ -245,16 +253,18 @@ discard block |
||
245 | 253 | $row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array(); |
246 | 254 | $alerts[$id_alert] = $row; |
247 | 255 | |
248 | - if (!empty($row['sender_id'])) |
|
249 | - $senders[] = $row['sender_id']; |
|
256 | + if (!empty($row['sender_id'])) { |
|
257 | + $senders[] = $row['sender_id']; |
|
258 | + } |
|
250 | 259 | } |
251 | 260 | $smcFunc['db_free_result']($request); |
252 | 261 | |
253 | 262 | if($withSender) |
254 | 263 | { |
255 | 264 | $senders = loadMemberData($senders); |
256 | - foreach ($senders as $member) |
|
257 | - loadMemberContext($member); |
|
265 | + foreach ($senders as $member) { |
|
266 | + loadMemberContext($member); |
|
267 | + } |
|
258 | 268 | } |
259 | 269 | |
260 | 270 | // Now go through and actually make with the text. |
@@ -269,12 +279,15 @@ discard block |
||
269 | 279 | $msgs = array(); |
270 | 280 | foreach ($alerts as $id_alert => $alert) |
271 | 281 | { |
272 | - if (isset($alert['extra']['board'])) |
|
273 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
274 | - if (isset($alert['extra']['topic'])) |
|
275 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
276 | - if ($alert['content_type'] == 'msg') |
|
277 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
282 | + if (isset($alert['extra']['board'])) { |
|
283 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
284 | + } |
|
285 | + if (isset($alert['extra']['topic'])) { |
|
286 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
287 | + } |
|
288 | + if ($alert['content_type'] == 'msg') { |
|
289 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
290 | + } |
|
278 | 291 | } |
279 | 292 | |
280 | 293 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -289,8 +302,9 @@ discard block |
||
289 | 302 | 'boards' => array_keys($boards), |
290 | 303 | ) |
291 | 304 | ); |
292 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
293 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
305 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
306 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
307 | + } |
|
294 | 308 | } |
295 | 309 | if (!empty($topics)) |
296 | 310 | { |
@@ -305,8 +319,9 @@ discard block |
||
305 | 319 | 'topics' => array_keys($topics), |
306 | 320 | ) |
307 | 321 | ); |
308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
309 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
324 | + } |
|
310 | 325 | } |
311 | 326 | if (!empty($msgs)) |
312 | 327 | { |
@@ -321,44 +336,51 @@ discard block |
||
321 | 336 | 'msgs' => array_keys($msgs), |
322 | 337 | ) |
323 | 338 | ); |
324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
325 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
339 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
340 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
341 | + } |
|
326 | 342 | } |
327 | 343 | |
328 | 344 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
329 | 345 | foreach ($alerts as $id_alert => $alert) |
330 | 346 | { |
331 | - if (!empty($alert['text'])) |
|
332 | - continue; |
|
333 | - if (isset($alert['extra']['board'])) |
|
334 | - if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
347 | + if (!empty($alert['text'])) { |
|
348 | + continue; |
|
349 | + } |
|
350 | + if (isset($alert['extra']['board'])) { |
|
351 | + if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
335 | 352 | { |
336 | 353 | unset($alerts[$id_alert]); |
354 | + } |
|
337 | 355 | continue; |
356 | + } else { |
|
357 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
338 | 358 | } |
339 | - else |
|
340 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
341 | - if (isset($alert['extra']['topic'])) |
|
342 | - if ($alert['extra']['topic'] == $txt['topic_na']) |
|
359 | + if (isset($alert['extra']['topic'])) { |
|
360 | + if ($alert['extra']['topic'] == $txt['topic_na']) |
|
343 | 361 | { |
344 | 362 | unset($alerts[$id_alert]); |
363 | + } |
|
345 | 364 | continue; |
365 | + } else { |
|
366 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
346 | 367 | } |
347 | - else |
|
348 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
349 | - if ($alert['content_type'] == 'msg') |
|
350 | - if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
368 | + if ($alert['content_type'] == 'msg') { |
|
369 | + if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
351 | 370 | { |
352 | 371 | unset($alerts[$id_alert]); |
372 | + } |
|
353 | 373 | continue; |
374 | + } else { |
|
375 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
354 | 376 | } |
355 | - else |
|
356 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
357 | - if ($alert['content_type'] == 'profile') |
|
358 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
377 | + if ($alert['content_type'] == 'profile') { |
|
378 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
379 | + } |
|
359 | 380 | |
360 | - if (!empty($memberContext[$alert['sender_id']])) |
|
361 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
381 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
382 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
383 | + } |
|
362 | 384 | |
363 | 385 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
364 | 386 | if (isset($txt[$string])) |
@@ -406,8 +428,8 @@ discard block |
||
406 | 428 | $context['pagination'] = constructPageIndex($scripturl . '?action=profile;area=showalerts;u=' . $memID, $start, $count, $maxIndex, false); |
407 | 429 | |
408 | 430 | // Set some JavaScript for checking all alerts at once. |
409 | - if ($context['showCheckboxes']) |
|
410 | - addInlineJavaScript(' |
|
431 | + if ($context['showCheckboxes']) { |
|
432 | + addInlineJavaScript(' |
|
411 | 433 | $(function(){ |
412 | 434 | $(\'#select_all\').on(\'change\', function() { |
413 | 435 | var checkboxes = $(\'ul.quickbuttons\').find(\':checkbox\'); |
@@ -419,6 +441,7 @@ discard block |
||
419 | 441 | } |
420 | 442 | }); |
421 | 443 | });', true); |
444 | + } |
|
422 | 445 | |
423 | 446 | // Set a nice message. |
424 | 447 | if (!empty($_SESSION['update_message'])) |
@@ -450,11 +473,11 @@ discard block |
||
450 | 473 | checkSession('request'); |
451 | 474 | |
452 | 475 | // Call it! |
453 | - if ($action == 'remove') |
|
454 | - alert_delete($toMark, $memID); |
|
455 | - |
|
456 | - else |
|
457 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
476 | + if ($action == 'remove') { |
|
477 | + alert_delete($toMark, $memID); |
|
478 | + } else { |
|
479 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
480 | + } |
|
458 | 481 | |
459 | 482 | // Set a nice update message. |
460 | 483 | $_SESSION['update_message'] = true; |
@@ -504,23 +527,27 @@ discard block |
||
504 | 527 | ); |
505 | 528 | |
506 | 529 | // Set the page title |
507 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
508 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
509 | - else |
|
510 | - $context['page_title'] = $txt['showPosts']; |
|
530 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
531 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
532 | + } else { |
|
533 | + $context['page_title'] = $txt['showPosts']; |
|
534 | + } |
|
511 | 535 | |
512 | 536 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
513 | 537 | |
514 | 538 | // Is the load average too high to allow searching just now? |
515 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
516 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
539 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
540 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
541 | + } |
|
517 | 542 | |
518 | 543 | // If we're specifically dealing with attachments use that function! |
519 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
520 | - return showAttachments($memID); |
|
544 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
545 | + return showAttachments($memID); |
|
546 | + } |
|
521 | 547 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
522 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
523 | - return showUnwatched($memID); |
|
548 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
549 | + return showUnwatched($memID); |
|
550 | + } |
|
524 | 551 | |
525 | 552 | // Are we just viewing topics? |
526 | 553 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -543,27 +570,30 @@ discard block |
||
543 | 570 | $smcFunc['db_free_result']($request); |
544 | 571 | |
545 | 572 | // Trying to remove a message that doesn't exist. |
546 | - if (empty($info)) |
|
547 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
573 | + if (empty($info)) { |
|
574 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
575 | + } |
|
548 | 576 | |
549 | 577 | // We can be lazy, since removeMessage() will check the permissions for us. |
550 | 578 | require_once($sourcedir . '/RemoveTopic.php'); |
551 | 579 | removeMessage((int) $_GET['delete']); |
552 | 580 | |
553 | 581 | // Add it to the mod log. |
554 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
555 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
582 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
583 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
584 | + } |
|
556 | 585 | |
557 | 586 | // Back to... where we are now ;). |
558 | 587 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
559 | 588 | } |
560 | 589 | |
561 | 590 | // Default to 10. |
562 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
563 | - $_REQUEST['viewscount'] = '10'; |
|
591 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
592 | + $_REQUEST['viewscount'] = '10'; |
|
593 | + } |
|
564 | 594 | |
565 | - if ($context['is_topics']) |
|
566 | - $request = $smcFunc['db_query']('', ' |
|
595 | + if ($context['is_topics']) { |
|
596 | + $request = $smcFunc['db_query']('', ' |
|
567 | 597 | SELECT COUNT(*) |
568 | 598 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
569 | 599 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -576,8 +606,8 @@ discard block |
||
576 | 606 | 'board' => $board, |
577 | 607 | ) |
578 | 608 | ); |
579 | - else |
|
580 | - $request = $smcFunc['db_query']('', ' |
|
609 | + } else { |
|
610 | + $request = $smcFunc['db_query']('', ' |
|
581 | 611 | SELECT COUNT(*) |
582 | 612 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
583 | 613 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -590,6 +620,7 @@ discard block |
||
590 | 620 | 'board' => $board, |
591 | 621 | ) |
592 | 622 | ); |
623 | + } |
|
593 | 624 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
594 | 625 | $smcFunc['db_free_result']($request); |
595 | 626 | |
@@ -610,10 +641,11 @@ discard block |
||
610 | 641 | |
611 | 642 | $range_limit = ''; |
612 | 643 | |
613 | - if ($context['is_topics']) |
|
614 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
615 | - else |
|
616 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
644 | + if ($context['is_topics']) { |
|
645 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
646 | + } else { |
|
647 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
648 | + } |
|
617 | 649 | |
618 | 650 | $maxIndex = $maxPerPage; |
619 | 651 | |
@@ -639,9 +671,9 @@ discard block |
||
639 | 671 | { |
640 | 672 | $margin *= 5; |
641 | 673 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
674 | + } else { |
|
675 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
642 | 676 | } |
643 | - else |
|
644 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
645 | 677 | } |
646 | 678 | |
647 | 679 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -673,8 +705,7 @@ discard block |
||
673 | 705 | 'max' => $maxIndex, |
674 | 706 | ) |
675 | 707 | ); |
676 | - } |
|
677 | - else |
|
708 | + } else |
|
678 | 709 | { |
679 | 710 | $request = $smcFunc['db_query']('', ' |
680 | 711 | SELECT |
@@ -703,8 +734,9 @@ discard block |
||
703 | 734 | } |
704 | 735 | |
705 | 736 | // Make sure we quit this loop. |
706 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') |
|
707 | - break; |
|
737 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') { |
|
738 | + break; |
|
739 | + } |
|
708 | 740 | $looped = true; |
709 | 741 | $range_limit = ''; |
710 | 742 | } |
@@ -748,19 +780,21 @@ discard block |
||
748 | 780 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
749 | 781 | ); |
750 | 782 | |
751 | - if ($user_info['id'] == $row['id_member_started']) |
|
752 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
783 | + if ($user_info['id'] == $row['id_member_started']) { |
|
784 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
785 | + } |
|
753 | 786 | $board_ids['any'][$row['id_board']][] = $counter; |
754 | 787 | } |
755 | 788 | $smcFunc['db_free_result']($request); |
756 | 789 | |
757 | 790 | // All posts were retrieved in reverse order, get them right again. |
758 | - if ($reverse) |
|
759 | - $context['posts'] = array_reverse($context['posts'], true); |
|
791 | + if ($reverse) { |
|
792 | + $context['posts'] = array_reverse($context['posts'], true); |
|
793 | + } |
|
760 | 794 | |
761 | 795 | // These are all the permissions that are different from board to board.. |
762 | - if ($context['is_topics']) |
|
763 | - $permissions = array( |
|
796 | + if ($context['is_topics']) { |
|
797 | + $permissions = array( |
|
764 | 798 | 'own' => array( |
765 | 799 | 'post_reply_own' => 'can_reply', |
766 | 800 | ), |
@@ -768,8 +802,8 @@ discard block |
||
768 | 802 | 'post_reply_any' => 'can_reply', |
769 | 803 | ) |
770 | 804 | ); |
771 | - else |
|
772 | - $permissions = array( |
|
805 | + } else { |
|
806 | + $permissions = array( |
|
773 | 807 | 'own' => array( |
774 | 808 | 'post_reply_own' => 'can_reply', |
775 | 809 | 'delete_own' => 'can_delete', |
@@ -779,6 +813,7 @@ discard block |
||
779 | 813 | 'delete_any' => 'can_delete', |
780 | 814 | ) |
781 | 815 | ); |
816 | + } |
|
782 | 817 | |
783 | 818 | // For every permission in the own/any lists... |
784 | 819 | foreach ($permissions as $type => $list) |
@@ -789,19 +824,22 @@ discard block |
||
789 | 824 | $boards = boardsAllowedTo($permission); |
790 | 825 | |
791 | 826 | // Hmm, they can do it on all boards, can they? |
792 | - if (!empty($boards) && $boards[0] == 0) |
|
793 | - $boards = array_keys($board_ids[$type]); |
|
827 | + if (!empty($boards) && $boards[0] == 0) { |
|
828 | + $boards = array_keys($board_ids[$type]); |
|
829 | + } |
|
794 | 830 | |
795 | 831 | // Now go through each board they can do the permission on. |
796 | 832 | foreach ($boards as $board_id) |
797 | 833 | { |
798 | 834 | // There aren't any posts displayed from this board. |
799 | - if (!isset($board_ids[$type][$board_id])) |
|
800 | - continue; |
|
835 | + if (!isset($board_ids[$type][$board_id])) { |
|
836 | + continue; |
|
837 | + } |
|
801 | 838 | |
802 | 839 | // Set the permission to true ;). |
803 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
804 | - $context['posts'][$counter][$allowed] = true; |
|
840 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
841 | + $context['posts'][$counter][$allowed] = true; |
|
842 | + } |
|
805 | 843 | } |
806 | 844 | } |
807 | 845 | } |
@@ -832,8 +870,9 @@ discard block |
||
832 | 870 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
833 | 871 | |
834 | 872 | // Make sure we can't actually see anything... |
835 | - if (empty($boardsAllowed)) |
|
836 | - $boardsAllowed = array(-1); |
|
873 | + if (empty($boardsAllowed)) { |
|
874 | + $boardsAllowed = array(-1); |
|
875 | + } |
|
837 | 876 | |
838 | 877 | require_once($sourcedir . '/Subs-List.php'); |
839 | 878 | |
@@ -984,8 +1023,8 @@ discard block |
||
984 | 1023 | ) |
985 | 1024 | ); |
986 | 1025 | $attachments = array(); |
987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
988 | - $attachments[] = array( |
|
1026 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1027 | + $attachments[] = array( |
|
989 | 1028 | 'id' => $row['id_attach'], |
990 | 1029 | 'filename' => $row['filename'], |
991 | 1030 | 'downloads' => $row['downloads'], |
@@ -997,6 +1036,7 @@ discard block |
||
997 | 1036 | 'board_name' => $row['name'], |
998 | 1037 | 'approved' => $row['approved'], |
999 | 1038 | ); |
1039 | + } |
|
1000 | 1040 | |
1001 | 1041 | $smcFunc['db_free_result']($request); |
1002 | 1042 | |
@@ -1051,8 +1091,9 @@ discard block |
||
1051 | 1091 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
1052 | 1092 | |
1053 | 1093 | // Only the owner can see the list (if the function is enabled of course) |
1054 | - if ($user_info['id'] != $memID) |
|
1055 | - return; |
|
1094 | + if ($user_info['id'] != $memID) { |
|
1095 | + return; |
|
1096 | + } |
|
1056 | 1097 | |
1057 | 1098 | require_once($sourcedir . '/Subs-List.php'); |
1058 | 1099 | |
@@ -1198,8 +1239,9 @@ discard block |
||
1198 | 1239 | ); |
1199 | 1240 | |
1200 | 1241 | $topics = array(); |
1201 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1202 | - $topics[] = $row['id_topic']; |
|
1242 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1243 | + $topics[] = $row['id_topic']; |
|
1244 | + } |
|
1203 | 1245 | |
1204 | 1246 | $smcFunc['db_free_result']($request); |
1205 | 1247 | |
@@ -1219,8 +1261,9 @@ discard block |
||
1219 | 1261 | 'topics' => $topics, |
1220 | 1262 | ) |
1221 | 1263 | ); |
1222 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1223 | - $topicsInfo[] = $row; |
|
1264 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1265 | + $topicsInfo[] = $row; |
|
1266 | + } |
|
1224 | 1267 | $smcFunc['db_free_result']($request); |
1225 | 1268 | } |
1226 | 1269 | |
@@ -1268,8 +1311,9 @@ discard block |
||
1268 | 1311 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
1269 | 1312 | |
1270 | 1313 | // Is the load average too high to allow searching just now? |
1271 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
1272 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
1314 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
1315 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
1316 | + } |
|
1273 | 1317 | |
1274 | 1318 | // General user statistics. |
1275 | 1319 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1412,11 +1456,13 @@ discard block |
||
1412 | 1456 | } |
1413 | 1457 | $smcFunc['db_free_result']($result); |
1414 | 1458 | |
1415 | - if ($maxPosts > 0) |
|
1416 | - for ($hour = 0; $hour < 24; $hour++) |
|
1459 | + if ($maxPosts > 0) { |
|
1460 | + for ($hour = 0; |
|
1461 | + } |
|
1462 | + $hour < 24; $hour++) |
|
1417 | 1463 | { |
1418 | - if (!isset($context['posts_by_time'][$hour])) |
|
1419 | - $context['posts_by_time'][$hour] = array( |
|
1464 | + if (!isset($context['posts_by_time'][$hour])) { |
|
1465 | + $context['posts_by_time'][$hour] = array( |
|
1420 | 1466 | 'hour' => $hour, |
1421 | 1467 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
1422 | 1468 | 'posts' => 0, |
@@ -1424,7 +1470,7 @@ discard block |
||
1424 | 1470 | 'relative_percent' => 0, |
1425 | 1471 | 'is_last' => $hour == 23, |
1426 | 1472 | ); |
1427 | - else |
|
1473 | + } else |
|
1428 | 1474 | { |
1429 | 1475 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
1430 | 1476 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1457,8 +1503,9 @@ discard block |
||
1457 | 1503 | |
1458 | 1504 | foreach ($subActions as $sa => $action) |
1459 | 1505 | { |
1460 | - if (!allowedTo($action[2])) |
|
1461 | - unset($subActions[$sa]); |
|
1506 | + if (!allowedTo($action[2])) { |
|
1507 | + unset($subActions[$sa]); |
|
1508 | + } |
|
1462 | 1509 | } |
1463 | 1510 | |
1464 | 1511 | // Create the tabs for the template. |
@@ -1476,15 +1523,18 @@ discard block |
||
1476 | 1523 | ); |
1477 | 1524 | |
1478 | 1525 | // Moderation must be on to track edits. |
1479 | - if (empty($modSettings['userlog_enabled'])) |
|
1480 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1526 | + if (empty($modSettings['userlog_enabled'])) { |
|
1527 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1528 | + } |
|
1481 | 1529 | |
1482 | 1530 | // Group requests must be active to show it... |
1483 | - if (empty($modSettings['show_group_membership'])) |
|
1484 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1531 | + if (empty($modSettings['show_group_membership'])) { |
|
1532 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1533 | + } |
|
1485 | 1534 | |
1486 | - if (empty($subActions)) |
|
1487 | - fatal_lang_error('no_access', false); |
|
1535 | + if (empty($subActions)) { |
|
1536 | + fatal_lang_error('no_access', false); |
|
1537 | + } |
|
1488 | 1538 | |
1489 | 1539 | $keys = array_keys($subActions); |
1490 | 1540 | $default = array_shift($keys); |
@@ -1497,9 +1547,10 @@ discard block |
||
1497 | 1547 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
1498 | 1548 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
1499 | 1549 | |
1500 | - if (!empty($call)) |
|
1501 | - call_user_func($call, $memID); |
|
1502 | -} |
|
1550 | + if (!empty($call)) { |
|
1551 | + call_user_func($call, $memID); |
|
1552 | + } |
|
1553 | + } |
|
1503 | 1554 | |
1504 | 1555 | /** |
1505 | 1556 | * Handles tracking a user's activity |
@@ -1515,8 +1566,9 @@ discard block |
||
1515 | 1566 | isAllowedTo('moderate_forum'); |
1516 | 1567 | |
1517 | 1568 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
1518 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
1519 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1569 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
1570 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1571 | + } |
|
1520 | 1572 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
1521 | 1573 | |
1522 | 1574 | // Set the options for the list component. |
@@ -1683,8 +1735,9 @@ discard block |
||
1683 | 1735 | ) |
1684 | 1736 | ); |
1685 | 1737 | $message_members = array(); |
1686 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1687 | - $message_members[] = $row['id_member']; |
|
1738 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1739 | + $message_members[] = $row['id_member']; |
|
1740 | + } |
|
1688 | 1741 | $smcFunc['db_free_result']($request); |
1689 | 1742 | |
1690 | 1743 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1699,8 +1752,9 @@ discard block |
||
1699 | 1752 | 'ip_list' => $ips, |
1700 | 1753 | ) |
1701 | 1754 | ); |
1702 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1703 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1755 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1756 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1757 | + } |
|
1704 | 1758 | $smcFunc['db_free_result']($request); |
1705 | 1759 | } |
1706 | 1760 | |
@@ -1714,8 +1768,9 @@ discard block |
||
1714 | 1768 | 'ip_list' => $ips, |
1715 | 1769 | ) |
1716 | 1770 | ); |
1717 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1718 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1771 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1772 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1773 | + } |
|
1719 | 1774 | $smcFunc['db_free_result']($request); |
1720 | 1775 | } |
1721 | 1776 | } |
@@ -1775,8 +1830,8 @@ discard block |
||
1775 | 1830 | )) |
1776 | 1831 | ); |
1777 | 1832 | $error_messages = array(); |
1778 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1779 | - $error_messages[] = array( |
|
1833 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1834 | + $error_messages[] = array( |
|
1780 | 1835 | 'ip' => inet_dtop($row['ip']), |
1781 | 1836 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
1782 | 1837 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1784,6 +1839,7 @@ discard block |
||
1784 | 1839 | 'time' => timeformat($row['log_time']), |
1785 | 1840 | 'timestamp' => forum_time(true, $row['log_time']), |
1786 | 1841 | ); |
1842 | + } |
|
1787 | 1843 | $smcFunc['db_free_result']($request); |
1788 | 1844 | |
1789 | 1845 | return $error_messages; |
@@ -1846,8 +1902,8 @@ discard block |
||
1846 | 1902 | )) |
1847 | 1903 | ); |
1848 | 1904 | $messages = array(); |
1849 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1850 | - $messages[] = array( |
|
1905 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1906 | + $messages[] = array( |
|
1851 | 1907 | 'ip' => inet_dtop($row['poster_ip']), |
1852 | 1908 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
1853 | 1909 | 'board' => array( |
@@ -1860,6 +1916,7 @@ discard block |
||
1860 | 1916 | 'time' => timeformat($row['poster_time']), |
1861 | 1917 | 'timestamp' => forum_time(true, $row['poster_time']) |
1862 | 1918 | ); |
1919 | + } |
|
1863 | 1920 | $smcFunc['db_free_result']($request); |
1864 | 1921 | |
1865 | 1922 | return $messages; |
@@ -1886,19 +1943,20 @@ discard block |
||
1886 | 1943 | $context['sub_template'] = 'trackIP'; |
1887 | 1944 | $context['page_title'] = $txt['profile']; |
1888 | 1945 | $context['base_url'] = $scripturl . '?action=trackip'; |
1889 | - } |
|
1890 | - else |
|
1946 | + } else |
|
1891 | 1947 | { |
1892 | 1948 | $context['ip'] = ip2range($user_profile[$memID]['member_ip']); |
1893 | 1949 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
1894 | 1950 | } |
1895 | 1951 | |
1896 | 1952 | // Searching? |
1897 | - if (isset($_REQUEST['searchip'])) |
|
1898 | - $context['ip'] = ip2range(trim($_REQUEST['searchip'])); |
|
1953 | + if (isset($_REQUEST['searchip'])) { |
|
1954 | + $context['ip'] = ip2range(trim($_REQUEST['searchip'])); |
|
1955 | + } |
|
1899 | 1956 | |
1900 | - if (count($context['ip']) !== 2) |
|
1901 | - fatal_lang_error('invalid_tracking_ip', false); |
|
1957 | + if (count($context['ip']) !== 2) { |
|
1958 | + fatal_lang_error('invalid_tracking_ip', false); |
|
1959 | + } |
|
1902 | 1960 | |
1903 | 1961 | $ip_string = array('{inet:ip_address_low}','{inet:ip_address_high}'); |
1904 | 1962 | $fields = array( |
@@ -1908,13 +1966,15 @@ discard block |
||
1908 | 1966 | |
1909 | 1967 | $ip_var = $context['ip']; |
1910 | 1968 | |
1911 | - if ($context['ip']['low'] !== $context['ip']['high']) |
|
1912 | - $context['ip'] = $context['ip']['low'] . ' - ' . $context['ip']['high']; |
|
1913 | - else |
|
1914 | - $context['ip'] = $context['ip']['low']; |
|
1969 | + if ($context['ip']['low'] !== $context['ip']['high']) { |
|
1970 | + $context['ip'] = $context['ip']['low'] . ' - ' . $context['ip']['high']; |
|
1971 | + } else { |
|
1972 | + $context['ip'] = $context['ip']['low']; |
|
1973 | + } |
|
1915 | 1974 | |
1916 | - if (empty($context['tracking_area'])) |
|
1917 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1975 | + if (empty($context['tracking_area'])) { |
|
1976 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1977 | + } |
|
1918 | 1978 | |
1919 | 1979 | $request = $smcFunc['db_query']('', ' |
1920 | 1980 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1923,8 +1983,9 @@ discard block |
||
1923 | 1983 | $fields |
1924 | 1984 | ); |
1925 | 1985 | $context['ips'] = array(); |
1926 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1927 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1986 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1987 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1988 | + } |
|
1928 | 1989 | $smcFunc['db_free_result']($request); |
1929 | 1990 | |
1930 | 1991 | ksort($context['ips']); |
@@ -2154,10 +2215,11 @@ discard block |
||
2154 | 2215 | // Gonna want this for the list. |
2155 | 2216 | require_once($sourcedir . '/Subs-List.php'); |
2156 | 2217 | |
2157 | - if ($memID == 0) |
|
2158 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
2159 | - else |
|
2160 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2218 | + if ($memID == 0) { |
|
2219 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
2220 | + } else { |
|
2221 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2222 | + } |
|
2161 | 2223 | |
2162 | 2224 | // Start with the user messages. |
2163 | 2225 | $listOptions = array( |
@@ -2267,12 +2329,13 @@ discard block |
||
2267 | 2329 | ) |
2268 | 2330 | ); |
2269 | 2331 | $logins = array(); |
2270 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2271 | - $logins[] = array( |
|
2332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2333 | + $logins[] = array( |
|
2272 | 2334 | 'time' => timeformat($row['time']), |
2273 | 2335 | 'ip' => inet_dtop($row['ip']), |
2274 | 2336 | 'ip2' => inet_dtop($row['ip2']), |
2275 | 2337 | ); |
2338 | + } |
|
2276 | 2339 | $smcFunc['db_free_result']($request); |
2277 | 2340 | |
2278 | 2341 | return $logins; |
@@ -2297,11 +2360,12 @@ discard block |
||
2297 | 2360 | ) |
2298 | 2361 | ); |
2299 | 2362 | $context['custom_field_titles'] = array(); |
2300 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2301 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2363 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2364 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2302 | 2365 | 'title' => $row['field_name'], |
2303 | 2366 | 'parse_bbc' => $row['bbc'], |
2304 | 2367 | ); |
2368 | + } |
|
2305 | 2369 | $smcFunc['db_free_result']($request); |
2306 | 2370 | |
2307 | 2371 | // Set the options for the error lists. |
@@ -2440,19 +2504,22 @@ discard block |
||
2440 | 2504 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2441 | 2505 | { |
2442 | 2506 | $extra = $smcFunc['json_decode']($row['extra'], true); |
2443 | - if (!empty($extra['applicator'])) |
|
2444 | - $members[] = $extra['applicator']; |
|
2507 | + if (!empty($extra['applicator'])) { |
|
2508 | + $members[] = $extra['applicator']; |
|
2509 | + } |
|
2445 | 2510 | |
2446 | 2511 | // Work out what the name of the action is. |
2447 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
2448 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2449 | - elseif (isset($txt[$row['action']])) |
|
2450 | - $action_text = $txt[$row['action']]; |
|
2512 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
2513 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2514 | + } elseif (isset($txt[$row['action']])) { |
|
2515 | + $action_text = $txt[$row['action']]; |
|
2516 | + } |
|
2451 | 2517 | // Custom field? |
2452 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
2453 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2454 | - else |
|
2455 | - $action_text = $row['action']; |
|
2518 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
2519 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2520 | + } else { |
|
2521 | + $action_text = $row['action']; |
|
2522 | + } |
|
2456 | 2523 | |
2457 | 2524 | // Parse BBC? |
2458 | 2525 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2484,13 +2551,15 @@ discard block |
||
2484 | 2551 | ) |
2485 | 2552 | ); |
2486 | 2553 | $members = array(); |
2487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2488 | - $members[$row['id_member']] = $row['real_name']; |
|
2554 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2555 | + $members[$row['id_member']] = $row['real_name']; |
|
2556 | + } |
|
2489 | 2557 | $smcFunc['db_free_result']($request); |
2490 | 2558 | |
2491 | - foreach ($edits as $key => $value) |
|
2492 | - if (isset($members[$value['id_member']])) |
|
2559 | + foreach ($edits as $key => $value) { |
|
2560 | + if (isset($members[$value['id_member']])) |
|
2493 | 2561 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
2562 | + } |
|
2494 | 2563 | } |
2495 | 2564 | |
2496 | 2565 | return $edits; |
@@ -2691,10 +2760,11 @@ discard block |
||
2691 | 2760 | $context['board'] = $board; |
2692 | 2761 | |
2693 | 2762 | // Determine which groups this user is in. |
2694 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
2695 | - $curGroups = array(); |
|
2696 | - else |
|
2697 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2763 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
2764 | + $curGroups = array(); |
|
2765 | + } else { |
|
2766 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2767 | + } |
|
2698 | 2768 | $curGroups[] = $user_profile[$memID]['id_group']; |
2699 | 2769 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
2700 | 2770 | |
@@ -2714,28 +2784,30 @@ discard block |
||
2714 | 2784 | $context['no_access_boards'] = array(); |
2715 | 2785 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2716 | 2786 | { |
2717 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
2718 | - $context['no_access_boards'][] = array( |
|
2787 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
2788 | + $context['no_access_boards'][] = array( |
|
2719 | 2789 | 'id' => $row['id_board'], |
2720 | 2790 | 'name' => $row['name'], |
2721 | 2791 | 'is_last' => false, |
2722 | 2792 | ); |
2723 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
2724 | - $context['boards'][$row['id_board']] = array( |
|
2793 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
2794 | + $context['boards'][$row['id_board']] = array( |
|
2725 | 2795 | 'id' => $row['id_board'], |
2726 | 2796 | 'name' => $row['name'], |
2727 | 2797 | 'selected' => $board == $row['id_board'], |
2728 | 2798 | 'profile' => $row['id_profile'], |
2729 | 2799 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
2730 | 2800 | ); |
2801 | + } |
|
2731 | 2802 | } |
2732 | 2803 | $smcFunc['db_free_result']($request); |
2733 | 2804 | |
2734 | 2805 | require_once($sourcedir . '/Subs-Boards.php'); |
2735 | 2806 | sortBoards($context['boards']); |
2736 | 2807 | |
2737 | - if (!empty($context['no_access_boards'])) |
|
2738 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2808 | + if (!empty($context['no_access_boards'])) { |
|
2809 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2810 | + } |
|
2739 | 2811 | |
2740 | 2812 | $context['member']['permissions'] = array( |
2741 | 2813 | 'general' => array(), |
@@ -2744,8 +2816,9 @@ discard block |
||
2744 | 2816 | |
2745 | 2817 | // If you're an admin we know you can do everything, we might as well leave. |
2746 | 2818 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
2747 | - if ($context['member']['has_all_permissions']) |
|
2748 | - return; |
|
2819 | + if ($context['member']['has_all_permissions']) { |
|
2820 | + return; |
|
2821 | + } |
|
2749 | 2822 | |
2750 | 2823 | $denied = array(); |
2751 | 2824 | |
@@ -2764,21 +2837,24 @@ discard block |
||
2764 | 2837 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2765 | 2838 | { |
2766 | 2839 | // We don't know about this permission, it doesn't exist :P. |
2767 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2768 | - continue; |
|
2840 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2841 | + continue; |
|
2842 | + } |
|
2769 | 2843 | |
2770 | - if (empty($row['add_deny'])) |
|
2771 | - $denied[] = $row['permission']; |
|
2844 | + if (empty($row['add_deny'])) { |
|
2845 | + $denied[] = $row['permission']; |
|
2846 | + } |
|
2772 | 2847 | |
2773 | 2848 | // Permissions that end with _own or _any consist of two parts. |
2774 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2775 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2776 | - else |
|
2777 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2849 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2850 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2851 | + } else { |
|
2852 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2853 | + } |
|
2778 | 2854 | |
2779 | 2855 | // Add this permission if it doesn't exist yet. |
2780 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
2781 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
2856 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
2857 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
2782 | 2858 | 'id' => $row['permission'], |
2783 | 2859 | 'groups' => array( |
2784 | 2860 | 'allowed' => array(), |
@@ -2788,6 +2864,7 @@ discard block |
||
2788 | 2864 | 'is_denied' => false, |
2789 | 2865 | 'is_global' => true, |
2790 | 2866 | ); |
2867 | + } |
|
2791 | 2868 | |
2792 | 2869 | // Add the membergroup to either the denied or the allowed groups. |
2793 | 2870 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2821,18 +2898,20 @@ discard block |
||
2821 | 2898 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2822 | 2899 | { |
2823 | 2900 | // We don't know about this permission, it doesn't exist :P. |
2824 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2825 | - continue; |
|
2901 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2902 | + continue; |
|
2903 | + } |
|
2826 | 2904 | |
2827 | 2905 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
2828 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2829 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2830 | - else |
|
2831 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2906 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2907 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2908 | + } else { |
|
2909 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2910 | + } |
|
2832 | 2911 | |
2833 | 2912 | // Create the structure for this permission. |
2834 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
2835 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
2913 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
2914 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
2836 | 2915 | 'id' => $row['permission'], |
2837 | 2916 | 'groups' => array( |
2838 | 2917 | 'allowed' => array(), |
@@ -2842,6 +2921,7 @@ discard block |
||
2842 | 2921 | 'is_denied' => false, |
2843 | 2922 | 'is_global' => empty($board), |
2844 | 2923 | ); |
2924 | + } |
|
2845 | 2925 | |
2846 | 2926 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
2847 | 2927 | |
@@ -2860,8 +2940,9 @@ discard block |
||
2860 | 2940 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
2861 | 2941 | |
2862 | 2942 | // Firstly, can we actually even be here? |
2863 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
2864 | - fatal_lang_error('no_access', false); |
|
2943 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
2944 | + fatal_lang_error('no_access', false); |
|
2945 | + } |
|
2865 | 2946 | |
2866 | 2947 | // Make sure things which are disabled stay disabled. |
2867 | 2948 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2948,9 +3029,10 @@ discard block |
||
2948 | 3029 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
2949 | 3030 | ); |
2950 | 3031 | $context['current_level'] = 0; |
2951 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
2952 | - if ($context['member']['warning'] >= $limit) |
|
3032 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
3033 | + if ($context['member']['warning'] >= $limit) |
|
2953 | 3034 | $context['current_level'] = $limit; |
2954 | -} |
|
3035 | + } |
|
3036 | + } |
|
2955 | 3037 | |
2956 | 3038 | ?> |
2957 | 3039 | \ No newline at end of file |
@@ -18,8 +18,9 @@ |
||
18 | 18 | * @version 2.1 Beta 4 |
19 | 19 | */ |
20 | 20 | |
21 | -if (!defined('SMF')) |
|
21 | +if (!defined('SMF')) { |
|
22 | 22 | die('No direct access...'); |
23 | +} |
|
23 | 24 | |
24 | 25 | /** |
25 | 26 | * Punycode implementation as described in RFC 3492 |