@@ -1096,7 +1096,7 @@ |
||
1096 | 1096 | /** |
1097 | 1097 | * CHMOD control form |
1098 | 1098 | * |
1099 | - * @return bool False if nothing to do. |
|
1099 | + * @return false|null False if nothing to do. |
|
1100 | 1100 | */ |
1101 | 1101 | function template_control_chmod() |
1102 | 1102 | { |
@@ -31,12 +31,13 @@ discard block |
||
31 | 31 | </div> |
32 | 32 | <div class="information">'; |
33 | 33 | |
34 | - if ($context['is_installed']) |
|
35 | - echo ' |
|
34 | + if ($context['is_installed']) { |
|
35 | + echo ' |
|
36 | 36 | <strong>', $txt['package_installed_warning1'], '</strong><br> |
37 | 37 | <br> |
38 | 38 | ', $txt['package_installed_warning2'], '<br> |
39 | 39 | <br>'; |
40 | + } |
|
40 | 41 | |
41 | 42 | echo $txt['package_installed_warning3'], ' |
42 | 43 | </div><br>'; |
@@ -63,8 +64,9 @@ discard block |
||
63 | 64 | ', $context['package_readme'], ' |
64 | 65 | <span class="floatright">', $txt['package_available_readme_language'], ' |
65 | 66 | <select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">'; |
66 | - foreach ($context['readmes'] as $a => $b) |
|
67 | - echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>'; |
|
67 | + foreach ($context['readmes'] as $a => $b) { |
|
68 | + echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>'; |
|
69 | + } |
|
68 | 70 | echo ' |
69 | 71 | </select> |
70 | 72 | </span> |
@@ -83,8 +85,9 @@ discard block |
||
83 | 85 | ', $context['package_license'], ' |
84 | 86 | <span class="floatright">', $txt['package_available_license_language'], ' |
85 | 87 | <select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">'; |
86 | - foreach ($context['licenses'] as $a => $b) |
|
87 | - echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>'; |
|
88 | + foreach ($context['licenses'] as $a => $b) { |
|
89 | + echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>'; |
|
90 | + } |
|
88 | 91 | echo ' |
89 | 92 | </select> |
90 | 93 | </span> |
@@ -111,9 +114,10 @@ discard block |
||
111 | 114 | ', $txt['package_db_uninstall_actions'], ': |
112 | 115 | <ul>'; |
113 | 116 | |
114 | - foreach ($context['database_changes'] as $change) |
|
115 | - echo ' |
|
117 | + foreach ($context['database_changes'] as $change) { |
|
118 | + echo ' |
|
116 | 119 | <li>', $change, '</li>'; |
120 | + } |
|
117 | 121 | echo ' |
118 | 122 | </ul> |
119 | 123 | </div> |
@@ -123,14 +127,14 @@ discard block |
||
123 | 127 | echo ' |
124 | 128 | <div class="information">'; |
125 | 129 | |
126 | - if (empty($context['actions']) && empty($context['database_changes'])) |
|
127 | - echo ' |
|
130 | + if (empty($context['actions']) && empty($context['database_changes'])) { |
|
131 | + echo ' |
|
128 | 132 | <br> |
129 | 133 | <div class="errorbox"> |
130 | 134 | ', $txt['corrupt_compatible'], ' |
131 | 135 | </div> |
132 | 136 | </div>'; |
133 | - else |
|
137 | + } else |
|
134 | 138 | { |
135 | 139 | echo ' |
136 | 140 | ', $txt['perform_actions'], ' |
@@ -230,9 +234,10 @@ discard block |
||
230 | 234 | <tr class="title_bar"> |
231 | 235 | <td></td> |
232 | 236 | <td>'; |
233 | - if (!empty($context['themes_locked'])) |
|
234 | - echo ' |
|
237 | + if (!empty($context['themes_locked'])) { |
|
238 | + echo ' |
|
235 | 239 | <input type="hidden" name="custom_theme[]" value="', $id, '">'; |
240 | + } |
|
236 | 241 | echo ' |
237 | 242 | <input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" class="input_check" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '> |
238 | 243 | </td> |
@@ -373,14 +378,15 @@ discard block |
||
373 | 378 | </script>'; |
374 | 379 | |
375 | 380 | // And a bit more for database changes. |
376 | - if (!empty($context['database_changes'])) |
|
377 | - echo ' |
|
381 | + if (!empty($context['database_changes'])) { |
|
382 | + echo ' |
|
378 | 383 | <script> |
379 | 384 | var database_changes_area = document.getElementById(\'db_changes_div\'); |
380 | 385 | var db_vis = false; |
381 | 386 | database_changes_area.style.display = "none"; |
382 | 387 | </script>'; |
383 | -} |
|
388 | + } |
|
389 | + } |
|
384 | 390 | |
385 | 391 | /** |
386 | 392 | * Extract package contents |
@@ -412,12 +418,12 @@ discard block |
||
412 | 418 | <h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3> |
413 | 419 | </div> |
414 | 420 | <div class="information">', $txt['package_installed_extract'], '</div>'; |
415 | - } |
|
416 | - else |
|
417 | - echo ' |
|
421 | + } else { |
|
422 | + echo ' |
|
418 | 423 | <div class="cat_bar"> |
419 | 424 | <h3 class="catbg">', $txt['package_installed_redirecting'], '</h3> |
420 | 425 | </div>'; |
426 | + } |
|
421 | 427 | |
422 | 428 | echo ' |
423 | 429 | <div class="windowbg">'; |
@@ -428,25 +434,25 @@ discard block |
||
428 | 434 | echo ' |
429 | 435 | ', $context['redirect_text'], '<br><br> |
430 | 436 | <a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>'; |
431 | - } |
|
432 | - elseif ($context['uninstalling']) |
|
433 | - echo ' |
|
437 | + } elseif ($context['uninstalling']) { |
|
438 | + echo ' |
|
434 | 439 | ', $txt['package_uninstall_done']; |
435 | - elseif ($context['install_finished']) |
|
440 | + } elseif ($context['install_finished']) |
|
436 | 441 | { |
437 | - if ($context['extract_type'] == 'avatar') |
|
438 | - echo ' |
|
442 | + if ($context['extract_type'] == 'avatar') { |
|
443 | + echo ' |
|
439 | 444 | ', $txt['avatars_extracted']; |
440 | - elseif ($context['extract_type'] == 'language') |
|
441 | - echo ' |
|
445 | + } elseif ($context['extract_type'] == 'language') { |
|
446 | + echo ' |
|
442 | 447 | ', $txt['language_extracted']; |
443 | - else |
|
444 | - echo ' |
|
448 | + } else { |
|
449 | + echo ' |
|
445 | 450 | ', $txt['package_installed_done']; |
446 | - } |
|
447 | - else |
|
448 | - echo ' |
|
451 | + } |
|
452 | + } else { |
|
453 | + echo ' |
|
449 | 454 | ', $txt['corrupt_compatible']; |
455 | + } |
|
450 | 456 | |
451 | 457 | echo ' |
452 | 458 | </div>'; |
@@ -480,9 +486,10 @@ discard block |
||
480 | 486 | <div class="windowbg"> |
481 | 487 | <ol>'; |
482 | 488 | |
483 | - foreach ($context['files'] as $fileinfo) |
|
484 | - echo ' |
|
489 | + foreach ($context['files'] as $fileinfo) { |
|
490 | + echo ' |
|
485 | 491 | <li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>'; |
492 | + } |
|
486 | 493 | |
487 | 494 | echo ' |
488 | 495 | </ol> |
@@ -546,9 +553,10 @@ discard block |
||
546 | 553 | </script> |
547 | 554 | <div id="yourVersion" style="display:none">', $context['forum_version'], '</div>'; |
548 | 555 | |
549 | - if (empty($modSettings['disable_smf_js'])) |
|
550 | - echo ' |
|
556 | + if (empty($modSettings['disable_smf_js'])) { |
|
557 | + echo ' |
|
551 | 558 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
559 | + } |
|
552 | 560 | |
553 | 561 | // This sets the announcements and current versions themselves ;). |
554 | 562 | echo ' |
@@ -587,12 +595,13 @@ discard block |
||
587 | 595 | } |
588 | 596 | } |
589 | 597 | |
590 | - if (!$mods_available) |
|
591 | - echo ' |
|
598 | + if (!$mods_available) { |
|
599 | + echo ' |
|
592 | 600 | <div class="noticebox">', $txt['no_packages'], '</div>'; |
593 | - else |
|
594 | - echo ' |
|
601 | + } else { |
|
602 | + echo ' |
|
595 | 603 | <br>'; |
604 | + } |
|
596 | 605 | |
597 | 606 | // the advanced (emulation) box, collapsed by default |
598 | 607 | echo ' |
@@ -681,11 +690,12 @@ discard block |
||
681 | 690 | { |
682 | 691 | global $context, $txt, $scripturl; |
683 | 692 | |
684 | - if (!empty($context['package_ftp']['error'])) |
|
685 | - echo ' |
|
693 | + if (!empty($context['package_ftp']['error'])) { |
|
694 | + echo ' |
|
686 | 695 | <div class="errorbox"> |
687 | 696 | <pre>', $context['package_ftp']['error'], '</pre> |
688 | 697 | </div>'; |
698 | + } |
|
689 | 699 | |
690 | 700 | echo ' |
691 | 701 | <div id="admin_form_wrapper"> |
@@ -766,13 +776,14 @@ discard block |
||
766 | 776 | <fieldset> |
767 | 777 | <legend>' . $txt['package_servers'] . '</legend> |
768 | 778 | <ul class="package_servers">'; |
769 | - foreach ($context['servers'] as $server) |
|
770 | - echo ' |
|
779 | + foreach ($context['servers'] as $server) { |
|
780 | + echo ' |
|
771 | 781 | <li class="flow_auto"> |
772 | 782 | <span class="floatleft">' . $server['name'] . '</span> |
773 | 783 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span> |
774 | 784 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span> |
775 | 785 | </li>'; |
786 | + } |
|
776 | 787 | echo ' |
777 | 788 | </ul> |
778 | 789 | </fieldset> |
@@ -859,11 +870,12 @@ discard block |
||
859 | 870 | <div class="windowbg2">'; |
860 | 871 | |
861 | 872 | // No packages, as yet. |
862 | - if (empty($context['package_list'])) |
|
863 | - echo ' |
|
873 | + if (empty($context['package_list'])) { |
|
874 | + echo ' |
|
864 | 875 | <ul> |
865 | 876 | <li>', $txt['no_packages'], '</li> |
866 | 877 | </ul>'; |
878 | + } |
|
867 | 879 | // List out the packages... |
868 | 880 | else |
869 | 881 | { |
@@ -875,11 +887,12 @@ discard block |
||
875 | 887 | <li> |
876 | 888 | <strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>'; |
877 | 889 | |
878 | - if (!empty($packageSection['text'])) |
|
879 | - echo ' |
|
890 | + if (!empty($packageSection['text'])) { |
|
891 | + echo ' |
|
880 | 892 | <div class="sub_bar"> |
881 | 893 | <h3 class="subbg">', $packageSection['text'], '</h3> |
882 | 894 | </div>'; |
895 | + } |
|
883 | 896 | |
884 | 897 | echo ' |
885 | 898 | <', $context['list_type'], ' id="package_section_', $i, '" class="packages">'; |
@@ -889,13 +902,15 @@ discard block |
||
889 | 902 | echo ' |
890 | 903 | <li>'; |
891 | 904 | // Textual message. Could be empty just for a blank line... |
892 | - if ($package['is_text']) |
|
893 | - echo ' |
|
905 | + if ($package['is_text']) { |
|
906 | + echo ' |
|
894 | 907 | ', empty($package['name']) ? ' ' : $package['name']; |
908 | + } |
|
895 | 909 | // This is supposed to be a rule.. |
896 | - elseif ($package['is_line']) |
|
897 | - echo ' |
|
910 | + elseif ($package['is_line']) { |
|
911 | + echo ' |
|
898 | 912 | <hr>'; |
913 | + } |
|
899 | 914 | // A remote link. |
900 | 915 | elseif ($package['is_remote']) |
901 | 916 | { |
@@ -917,21 +932,25 @@ discard block |
||
917 | 932 | <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">'; |
918 | 933 | |
919 | 934 | // Show the mod type? |
920 | - if ($package['type'] != '') |
|
921 | - echo ' |
|
935 | + if ($package['type'] != '') { |
|
936 | + echo ' |
|
922 | 937 | <li class="package_section">', $txt['package_type'], ': ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '</li>'; |
938 | + } |
|
923 | 939 | // Show the version number? |
924 | - if ($package['version'] != '') |
|
925 | - echo ' |
|
940 | + if ($package['version'] != '') { |
|
941 | + echo ' |
|
926 | 942 | <li class="package_section">', $txt['mod_version'], ': ', $package['version'], '</li>'; |
943 | + } |
|
927 | 944 | // How 'bout the author? |
928 | - if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) |
|
929 | - echo ' |
|
945 | + if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) { |
|
946 | + echo ' |
|
930 | 947 | <li class="package_section">', $txt['mod_author'], ': ', $package['author']['link'], '</li>'; |
948 | + } |
|
931 | 949 | // The homepage.... |
932 | - if ($package['author']['website']['link'] != '') |
|
933 | - echo ' |
|
950 | + if ($package['author']['website']['link'] != '') { |
|
951 | + echo ' |
|
934 | 952 | <li class="package_section">', $txt['author_website'], ': ', $package['author']['website']['link'], '</li>'; |
953 | + } |
|
935 | 954 | |
936 | 955 | // Desciption: bleh bleh! |
937 | 956 | // Location of file: http://someplace/. |
@@ -984,8 +1003,8 @@ discard block |
||
984 | 1003 | |
985 | 1004 | foreach ($ps['items'] as $id => $package) |
986 | 1005 | { |
987 | - if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) |
|
988 | - echo ' |
|
1006 | + if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) { |
|
1007 | + echo ' |
|
989 | 1008 | var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({ |
990 | 1009 | bToggleEnabled: true, |
991 | 1010 | bCurrentlyCollapsed: true, |
@@ -1000,6 +1019,7 @@ discard block |
||
1000 | 1019 | } |
1001 | 1020 | ] |
1002 | 1021 | });'; |
1022 | + } |
|
1003 | 1023 | } |
1004 | 1024 | } |
1005 | 1025 | echo ' |
@@ -1040,9 +1060,10 @@ discard block |
||
1040 | 1060 | { |
1041 | 1061 | global $context, $txt, $scripturl; |
1042 | 1062 | |
1043 | - if (!empty($context['saved_successful'])) |
|
1044 | - echo ' |
|
1063 | + if (!empty($context['saved_successful'])) { |
|
1064 | + echo ' |
|
1045 | 1065 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1066 | + } |
|
1046 | 1067 | |
1047 | 1068 | echo ' |
1048 | 1069 | <div id="admincenter"> |
@@ -1104,8 +1125,9 @@ discard block |
||
1104 | 1125 | global $context, $txt; |
1105 | 1126 | |
1106 | 1127 | // Nothing to do? Brilliant! |
1107 | - if (empty($context['package_ftp'])) |
|
1108 | - return false; |
|
1128 | + if (empty($context['package_ftp'])) { |
|
1129 | + return false; |
|
1130 | + } |
|
1109 | 1131 | |
1110 | 1132 | if (empty($context['package_ftp']['form_elements_only'])) |
1111 | 1133 | { |
@@ -1114,19 +1136,21 @@ discard block |
||
1114 | 1136 | <div id="need_writable_list" class="smalltext"> |
1115 | 1137 | ', $txt['package_ftp_why_file_list'], ' |
1116 | 1138 | <ul style="display: inline;">'; |
1117 | - if (!empty($context['notwritable_files'])) |
|
1118 | - foreach ($context['notwritable_files'] as $file) |
|
1139 | + if (!empty($context['notwritable_files'])) { |
|
1140 | + foreach ($context['notwritable_files'] as $file) |
|
1119 | 1141 | echo ' |
1120 | 1142 | <li>', $file, '</li>'; |
1143 | + } |
|
1121 | 1144 | |
1122 | 1145 | echo ' |
1123 | 1146 | </ul>'; |
1124 | 1147 | |
1125 | - if (!$context['server']['is_windows']) |
|
1126 | - echo ' |
|
1148 | + if (!$context['server']['is_windows']) { |
|
1149 | + echo ' |
|
1127 | 1150 | <hr> |
1128 | 1151 | ', $txt['package_chmod_linux'], '<br /> |
1129 | 1152 | <tt># chmod a+w ', implode(' ', $context['notwritable_files']), '</tt>'; |
1153 | + } |
|
1130 | 1154 | |
1131 | 1155 | echo ' |
1132 | 1156 | </div>'; |
@@ -1137,9 +1161,10 @@ discard block |
||
1137 | 1161 | <tt id="ftp_error_message">', !empty($context['package_ftp']['error']) ? $context['package_ftp']['error'] : '', '</tt> |
1138 | 1162 | </div></div>'; |
1139 | 1163 | |
1140 | - if (!empty($context['package_ftp']['destination'])) |
|
1141 | - echo ' |
|
1164 | + if (!empty($context['package_ftp']['destination'])) { |
|
1165 | + echo ' |
|
1142 | 1166 | <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">'; |
1167 | + } |
|
1143 | 1168 | |
1144 | 1169 | echo ' |
1145 | 1170 | <fieldset> |
@@ -1172,25 +1197,28 @@ discard block |
||
1172 | 1197 | </dl> |
1173 | 1198 | </fieldset>'; |
1174 | 1199 | |
1175 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
1176 | - echo ' |
|
1200 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
1201 | + echo ' |
|
1177 | 1202 | |
1178 | 1203 | <div class="righttext" style="margin: 1ex;"> |
1179 | 1204 | <span id="test_ftp_placeholder_full"></span> |
1180 | 1205 | <input type="submit" value="', $txt['package_proceed'], '" class="button_submit"> |
1181 | 1206 | </div>'; |
1207 | + } |
|
1182 | 1208 | |
1183 | - if (!empty($context['package_ftp']['destination'])) |
|
1184 | - echo ' |
|
1209 | + if (!empty($context['package_ftp']['destination'])) { |
|
1210 | + echo ' |
|
1185 | 1211 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1186 | 1212 | </form>'; |
1213 | + } |
|
1187 | 1214 | |
1188 | 1215 | // Hide the details of the list. |
1189 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
1190 | - echo ' |
|
1216 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
1217 | + echo ' |
|
1191 | 1218 | <script> |
1192 | 1219 | document.getElementById(\'need_writable_list\').style.display = \'none\'; |
1193 | 1220 | </script>'; |
1221 | + } |
|
1194 | 1222 | |
1195 | 1223 | // Quick generate the test button. |
1196 | 1224 | echo ' |
@@ -1546,9 +1574,10 @@ discard block |
||
1546 | 1574 | <tr class="windowbg"> |
1547 | 1575 | <td width="30%"><strong>'; |
1548 | 1576 | |
1549 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
1550 | - echo ' |
|
1577 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
1578 | + echo ' |
|
1551 | 1579 | <span class="generic_icons folder"></span>'; |
1580 | + } |
|
1552 | 1581 | |
1553 | 1582 | echo ' |
1554 | 1583 | ', $name, ' |
@@ -1565,8 +1594,9 @@ discard block |
||
1565 | 1594 | </tr> |
1566 | 1595 | '; |
1567 | 1596 | |
1568 | - if (!empty($dir['contents'])) |
|
1569 | - template_permission_show_contents($name, $dir['contents'], 1); |
|
1597 | + if (!empty($dir['contents'])) { |
|
1598 | + template_permission_show_contents($name, $dir['contents'], 1); |
|
1599 | + } |
|
1570 | 1600 | } |
1571 | 1601 | |
1572 | 1602 | echo ' |
@@ -1602,13 +1632,14 @@ discard block |
||
1602 | 1632 | </fieldset>'; |
1603 | 1633 | |
1604 | 1634 | // Likely to need FTP? |
1605 | - if (empty($context['ftp_connected'])) |
|
1606 | - echo ' |
|
1635 | + if (empty($context['ftp_connected'])) { |
|
1636 | + echo ' |
|
1607 | 1637 | <p> |
1608 | 1638 | ', $txt['package_file_perms_ftp_details'], ': |
1609 | 1639 | </p> |
1610 | 1640 | ', template_control_chmod(), ' |
1611 | 1641 | <div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>'; |
1642 | + } |
|
1612 | 1643 | |
1613 | 1644 | echo ' |
1614 | 1645 | <span id="test_ftp_placeholder_full"></span> |
@@ -1617,9 +1648,10 @@ discard block |
||
1617 | 1648 | </div>'; |
1618 | 1649 | |
1619 | 1650 | // Any looks fors we've already done? |
1620 | - foreach ($context['look_for'] as $path) |
|
1621 | - echo ' |
|
1651 | + foreach ($context['look_for'] as $path) { |
|
1652 | + echo ' |
|
1622 | 1653 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
1654 | + } |
|
1623 | 1655 | echo ' |
1624 | 1656 | </form><br>'; |
1625 | 1657 | } |
@@ -1658,9 +1690,10 @@ discard block |
||
1658 | 1690 | <td class="smalltext" width="30%">' . str_repeat(' ', $level * 5), ' |
1659 | 1691 | ', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : ''; |
1660 | 1692 | |
1661 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
1662 | - echo ' |
|
1693 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
1694 | + echo ' |
|
1663 | 1695 | <span class="generic_icons folder"></span>'; |
1696 | + } |
|
1664 | 1697 | |
1665 | 1698 | echo ' |
1666 | 1699 | ', $name, ' |
@@ -1686,14 +1719,15 @@ discard block |
||
1686 | 1719 | } |
1687 | 1720 | |
1688 | 1721 | // We have more files to show? |
1689 | - if ($has_more) |
|
1690 | - echo ' |
|
1722 | + if ($has_more) { |
|
1723 | + echo ' |
|
1691 | 1724 | <tr class="windowbg" id="content_', $js_ident, '_more"> |
1692 | 1725 | <td class="smalltext" width="40%">' . str_repeat(' ', $level * 5), ' |
1693 | 1726 | « <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> » |
1694 | 1727 | </td> |
1695 | 1728 | <td colspan="6"></td> |
1696 | 1729 | </tr>'; |
1730 | + } |
|
1697 | 1731 | |
1698 | 1732 | if ($drawn_div) |
1699 | 1733 | { |
@@ -1701,15 +1735,17 @@ discard block |
||
1701 | 1735 | $isFound = false; |
1702 | 1736 | foreach ($context['look_for'] as $tree) |
1703 | 1737 | { |
1704 | - if (substr($tree, 0, strlen($ident)) == $ident) |
|
1705 | - $isFound = true; |
|
1738 | + if (substr($tree, 0, strlen($ident)) == $ident) { |
|
1739 | + $isFound = true; |
|
1740 | + } |
|
1706 | 1741 | } |
1707 | 1742 | |
1708 | - if ($level > 1 && !$isFound) |
|
1709 | - echo ' |
|
1743 | + if ($level > 1 && !$isFound) { |
|
1744 | + echo ' |
|
1710 | 1745 | <script> |
1711 | 1746 | expandFolder(\'', $js_ident, '\', \'\'); |
1712 | 1747 | </script>'; |
1748 | + } |
|
1713 | 1749 | } |
1714 | 1750 | } |
1715 | 1751 | |
@@ -1729,11 +1765,12 @@ discard block |
||
1729 | 1765 | <h3 class="catbg">', $txt['package_file_perms_applying'], '</h3> |
1730 | 1766 | </div>'; |
1731 | 1767 | |
1732 | - if (!empty($context['skip_ftp'])) |
|
1733 | - echo ' |
|
1768 | + if (!empty($context['skip_ftp'])) { |
|
1769 | + echo ' |
|
1734 | 1770 | <div class="errorbox"> |
1735 | 1771 | ', $txt['package_file_perms_skipping_ftp'], ' |
1736 | 1772 | </div>'; |
1773 | + } |
|
1737 | 1774 | |
1738 | 1775 | // How many have we done? |
1739 | 1776 | $remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']); |
@@ -1771,28 +1808,31 @@ discard block |
||
1771 | 1808 | <br>'; |
1772 | 1809 | |
1773 | 1810 | // Put out the right hidden data. |
1774 | - if ($context['method'] == 'individual') |
|
1775 | - echo ' |
|
1811 | + if ($context['method'] == 'individual') { |
|
1812 | + echo ' |
|
1776 | 1813 | <input type="hidden" name="custom_value" value="', $context['custom_value'], '"> |
1777 | 1814 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
1778 | 1815 | <input type="hidden" name="toProcess" value="', $context['to_process_encode'], '">'; |
1779 | - else |
|
1780 | - echo ' |
|
1816 | + } else { |
|
1817 | + echo ' |
|
1781 | 1818 | <input type="hidden" name="predefined" value="', $context['predefined_type'], '"> |
1782 | 1819 | <input type="hidden" name="fileOffset" value="', $context['file_offset'], '"> |
1783 | 1820 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
1784 | 1821 | <input type="hidden" name="dirList" value="', $context['directory_list_encode'], '"> |
1785 | 1822 | <input type="hidden" name="specialFiles" value="', $context['special_files_encode'], '">'; |
1823 | + } |
|
1786 | 1824 | |
1787 | 1825 | // Are we not using FTP for whatever reason. |
1788 | - if (!empty($context['skip_ftp'])) |
|
1789 | - echo ' |
|
1826 | + if (!empty($context['skip_ftp'])) { |
|
1827 | + echo ' |
|
1790 | 1828 | <input type="hidden" name="skip_ftp" value="1">'; |
1829 | + } |
|
1791 | 1830 | |
1792 | 1831 | // Retain state. |
1793 | - foreach ($context['back_look_data'] as $path) |
|
1794 | - echo ' |
|
1832 | + foreach ($context['back_look_data'] as $path) { |
|
1833 | + echo ' |
|
1795 | 1834 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
1835 | + } |
|
1796 | 1836 | |
1797 | 1837 | echo ' |
1798 | 1838 | <input type="hidden" name="method" value="', $context['method'], '"> |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('Location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -273,7 +273,6 @@ |
||
273 | 273 | * Modify any setting related to topics. |
274 | 274 | * Requires the admin_forum permission. |
275 | 275 | * Accessed from ?action=admin;area=postsettings;sa=topics. |
276 | - |
|
277 | 276 | * @param bool $return_config Whether or not to return the config_vars array (used for admin search) |
278 | 277 | * @return void|array Returns nothing or returns $config_vars if $return_config is true |
279 | 278 | * @uses Admin template, edit_topic_settings sub-template. |
@@ -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 entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
98 | 99 | { |
99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
100 | 101 | |
101 | - foreach ($_POST['censortext'] as $c) |
|
102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
103 | - } |
|
104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
102 | + foreach ($_POST['censortext'] as $c) { |
|
103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
104 | + } |
|
105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
105 | 106 | { |
106 | 107 | if (is_array($_POST['censor_vulgar'])) |
107 | 108 | { |
108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
109 | 110 | { |
110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
113 | + } |
|
112 | 114 | } |
113 | 115 | |
114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
115 | 117 | $censored_proper = $_POST['censor_proper']; |
116 | - } |
|
117 | - else |
|
118 | + } else |
|
118 | 119 | { |
119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
151 | 152 | $context['censored_words'] = array(); |
152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
153 | 154 | { |
154 | - if (empty($censor_vulgar[$i])) |
|
155 | - continue; |
|
155 | + if (empty($censor_vulgar[$i])) { |
|
156 | + continue; |
|
157 | + } |
|
156 | 158 | |
157 | 159 | // Skip it, it's either spaces or stars only. |
158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
159 | - continue; |
|
160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
161 | + continue; |
|
162 | + } |
|
160 | 163 | |
161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
187 | 190 | |
188 | 191 | // Make an inline conditional a little shorter... |
189 | 192 | $can_spell_check = false; |
190 | - if (function_exists('pspell_new')) |
|
191 | - $can_spell_check = true; |
|
192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
193 | - $can_spell_check = true; |
|
193 | + if (function_exists('pspell_new')) { |
|
194 | + $can_spell_check = true; |
|
195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
196 | + $can_spell_check = true; |
|
197 | + } |
|
194 | 198 | |
195 | 199 | // All the settings... |
196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
221 | 225 | |
222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
223 | 227 | |
224 | - if ($return_config) |
|
225 | - return $config_vars; |
|
228 | + if ($return_config) { |
|
229 | + return $config_vars; |
|
230 | + } |
|
226 | 231 | |
227 | 232 | // We'll want this for our easy save. |
228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
242 | 247 | db_extend('packages'); |
243 | 248 | |
244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
245 | - foreach ($colData as $column) |
|
246 | - if ($column['name'] == 'body') |
|
250 | + foreach ($colData as $column) { |
|
251 | + if ($column['name'] == 'body') |
|
247 | 252 | $body_type = $column['type']; |
253 | + } |
|
248 | 254 | |
249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
257 | + } |
|
251 | 258 | } |
252 | 259 | |
253 | 260 | // If we're changing the post preview length let's check its valid |
254 | - if (!empty($_POST['preview_characters'])) |
|
255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
261 | + if (!empty($_POST['preview_characters'])) { |
|
262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
263 | + } |
|
256 | 264 | |
257 | 265 | call_integration_hook('integrate_save_post_settings'); |
258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
313 | 321 | |
314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
315 | 323 | |
316 | - if ($return_config) |
|
317 | - return $config_vars; |
|
324 | + if ($return_config) { |
|
325 | + return $config_vars; |
|
326 | + } |
|
318 | 327 | |
319 | 328 | // Get the settings template ready. |
320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
368 | 377 | ); |
369 | 378 | |
370 | - if ($return_config) |
|
371 | - return $config_vars; |
|
379 | + if ($return_config) { |
|
380 | + return $config_vars; |
|
381 | + } |
|
372 | 382 | |
373 | 383 | // Get the settings template ready. |
374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | else |
238 | 238 | { |
239 | 239 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
240 | - AND b.id_board != {int:recycle_board}' : ''). ' |
|
240 | + AND b.id_board != {int:recycle_board}' : '') . ' |
|
241 | 241 | AND m.id_msg >= {int:max_id_msg}'; |
242 | 242 | $query_parameters['max_id_msg'] = max(0, $modSettings['maxMsgID'] - 100 - $_REQUEST['start'] * 6); |
243 | 243 | $query_parameters['recycle_board'] = $modSettings['recycle_board']; |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | ); |
1125 | 1125 | else |
1126 | 1126 | $request = $smcFunc['db_query']('', ' |
1127 | - SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
|
1127 | + SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'] . ' |
|
1128 | 1128 | FROM {db_prefix}topics AS t |
1129 | 1129 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
1130 | 1130 | INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)') . (strpos($_REQUEST['sort'], 'mems.') === false ? '' : ' |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | if ($is_topics) |
1392 | 1392 | { |
1393 | 1393 | $context['recent_buttons'] = array( |
1394 | - 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1394 | + 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1395 | 1395 | ); |
1396 | 1396 | |
1397 | 1397 | if ($context['showCheckboxes']) |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | elseif (!$is_topics && isset($context['topics_to_mark'])) |
1408 | 1408 | { |
1409 | 1409 | $context['recent_buttons'] = array( |
1410 | - 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1410 | + 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1411 | 1411 | ); |
1412 | 1412 | |
1413 | 1413 | if ($context['showCheckboxes']) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | 'is_approved' => 1, |
45 | 46 | ) |
46 | 47 | ); |
47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
48 | - return array(); |
|
48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
49 | + return array(); |
|
50 | + } |
|
49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
50 | 52 | $smcFunc['db_free_result']($request); |
51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
54 | 56 | censorText($row['body']); |
55 | 57 | |
56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
61 | + } |
|
59 | 62 | |
60 | 63 | // Send the data. |
61 | 64 | return array( |
@@ -83,15 +86,17 @@ discard block |
||
83 | 86 | |
84 | 87 | $context['is_redirect'] = false; |
85 | 88 | |
86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
87 | - $_REQUEST['start'] = 95; |
|
89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
90 | + $_REQUEST['start'] = 95; |
|
91 | + } |
|
88 | 92 | |
89 | 93 | $query_parameters = array(); |
90 | 94 | if (!empty($_REQUEST['c']) && empty($board)) |
91 | 95 | { |
92 | 96 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
93 | - foreach ($_REQUEST['c'] as $i => $c) |
|
94 | - $_REQUEST['c'][$i] = (int) $c; |
|
97 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
98 | + $_REQUEST['c'][$i] = (int) $c; |
|
99 | + } |
|
95 | 100 | |
96 | 101 | if (count($_REQUEST['c']) == 1) |
97 | 102 | { |
@@ -107,8 +112,9 @@ discard block |
||
107 | 112 | list ($name) = $smcFunc['db_fetch_row']($request); |
108 | 113 | $smcFunc['db_free_result']($request); |
109 | 114 | |
110 | - if (empty($name)) |
|
111 | - fatal_lang_error('no_access', false); |
|
115 | + if (empty($name)) { |
|
116 | + fatal_lang_error('no_access', false); |
|
117 | + } |
|
112 | 118 | |
113 | 119 | $context['linktree'][] = array( |
114 | 120 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -140,8 +146,9 @@ discard block |
||
140 | 146 | } |
141 | 147 | $smcFunc['db_free_result']($request); |
142 | 148 | |
143 | - if (empty($boards)) |
|
144 | - fatal_lang_error('error_no_boards_selected'); |
|
149 | + if (empty($boards)) { |
|
150 | + fatal_lang_error('error_no_boards_selected'); |
|
151 | + } |
|
145 | 152 | |
146 | 153 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
147 | 154 | $query_parameters['boards'] = $boards; |
@@ -155,12 +162,12 @@ discard block |
||
155 | 162 | } |
156 | 163 | |
157 | 164 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
158 | - } |
|
159 | - elseif (!empty($_REQUEST['boards'])) |
|
165 | + } elseif (!empty($_REQUEST['boards'])) |
|
160 | 166 | { |
161 | 167 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
162 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
163 | - $_REQUEST['boards'][$i] = (int) $b; |
|
168 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
169 | + $_REQUEST['boards'][$i] = (int) $b; |
|
170 | + } |
|
164 | 171 | |
165 | 172 | $request = $smcFunc['db_query']('', ' |
166 | 173 | SELECT b.id_board, b.num_posts |
@@ -184,8 +191,9 @@ discard block |
||
184 | 191 | } |
185 | 192 | $smcFunc['db_free_result']($request); |
186 | 193 | |
187 | - if (empty($boards)) |
|
188 | - fatal_lang_error('error_no_boards_selected'); |
|
194 | + if (empty($boards)) { |
|
195 | + fatal_lang_error('error_no_boards_selected'); |
|
196 | + } |
|
189 | 197 | |
190 | 198 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
191 | 199 | $query_parameters['boards'] = $boards; |
@@ -199,8 +207,7 @@ discard block |
||
199 | 207 | } |
200 | 208 | |
201 | 209 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
202 | - } |
|
203 | - elseif (!empty($board)) |
|
210 | + } elseif (!empty($board)) |
|
204 | 211 | { |
205 | 212 | $request = $smcFunc['db_query']('', ' |
206 | 213 | SELECT num_posts, redirect |
@@ -233,8 +240,7 @@ discard block |
||
233 | 240 | } |
234 | 241 | |
235 | 242 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
236 | - } |
|
237 | - else |
|
243 | + } else |
|
238 | 244 | { |
239 | 245 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
240 | 246 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -269,8 +275,9 @@ discard block |
||
269 | 275 | ); |
270 | 276 | |
271 | 277 | // If you selected a redirection board, don't try getting posts for it... |
272 | - if ($context['is_redirect']) |
|
273 | - $messages = 0; |
|
278 | + if ($context['is_redirect']) { |
|
279 | + $messages = 0; |
|
280 | + } |
|
274 | 281 | |
275 | 282 | $key = 'recent-' . $user_info['id'] . '-' . md5($smcFunc['json_encode'](array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
276 | 283 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -301,16 +308,18 @@ discard block |
||
301 | 308 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
302 | 309 | $cache_results = true; |
303 | 310 | unset($query_parameters['max_id_msg']); |
311 | + } else { |
|
312 | + $done = true; |
|
304 | 313 | } |
305 | - else |
|
306 | - $done = true; |
|
307 | 314 | } |
308 | 315 | $messages = array(); |
309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
310 | - $messages[] = $row['id_msg']; |
|
316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
317 | + $messages[] = $row['id_msg']; |
|
318 | + } |
|
311 | 319 | $smcFunc['db_free_result']($request); |
312 | - if (!empty($cache_results)) |
|
313 | - cache_put_data($key, $messages, 120); |
|
320 | + if (!empty($cache_results)) { |
|
321 | + cache_put_data($key, $messages, 120); |
|
322 | + } |
|
314 | 323 | } |
315 | 324 | |
316 | 325 | // Nothing here... Or at least, nothing you can see... |
@@ -397,8 +406,9 @@ discard block |
||
397 | 406 | 'css_class' => 'windowbg', |
398 | 407 | ); |
399 | 408 | |
400 | - if ($user_info['id'] == $row['id_first_member']) |
|
401 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
409 | + if ($user_info['id'] == $row['id_first_member']) { |
|
410 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
411 | + } |
|
402 | 412 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
403 | 413 | } |
404 | 414 | $smcFunc['db_free_result']($request); |
@@ -424,20 +434,23 @@ discard block |
||
424 | 434 | $boards = boardsAllowedTo($permission); |
425 | 435 | |
426 | 436 | // If 0 is the only thing in the array, they can do it everywhere! |
427 | - if (!empty($boards) && $boards[0] == 0) |
|
428 | - $boards = array_keys($board_ids[$type]); |
|
437 | + if (!empty($boards) && $boards[0] == 0) { |
|
438 | + $boards = array_keys($board_ids[$type]); |
|
439 | + } |
|
429 | 440 | |
430 | 441 | // Go through the boards, and look for posts they can do this on. |
431 | 442 | foreach ($boards as $board_id) |
432 | 443 | { |
433 | 444 | // Hmm, they have permission, but there are no topics from that board on this page. |
434 | - if (!isset($board_ids[$type][$board_id])) |
|
435 | - continue; |
|
445 | + if (!isset($board_ids[$type][$board_id])) { |
|
446 | + continue; |
|
447 | + } |
|
436 | 448 | |
437 | 449 | // Okay, looks like they can do it for these posts. |
438 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
439 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
450 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
451 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
440 | 452 | $context['posts'][$counter][$allowed] = true; |
453 | + } |
|
441 | 454 | } |
442 | 455 | } |
443 | 456 | } |
@@ -480,17 +493,19 @@ discard block |
||
480 | 493 | $context['showing_all_topics'] = isset($_GET['all']); |
481 | 494 | $context['start'] = (int) $_REQUEST['start']; |
482 | 495 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
483 | - if ($_REQUEST['action'] == 'unread') |
|
484 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
485 | - else |
|
486 | - $context['page_title'] = $txt['unread_replies']; |
|
496 | + if ($_REQUEST['action'] == 'unread') { |
|
497 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
498 | + } else { |
|
499 | + $context['page_title'] = $txt['unread_replies']; |
|
500 | + } |
|
487 | 501 | |
488 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
489 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
490 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
491 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
492 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
493 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
502 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
503 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
504 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
505 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
506 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
507 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
508 | + } |
|
494 | 509 | |
495 | 510 | // Parameters for the main query. |
496 | 511 | $query_parameters = array(); |
@@ -503,12 +518,14 @@ discard block |
||
503 | 518 | if (!empty($_REQUEST['boards'])) |
504 | 519 | { |
505 | 520 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
506 | - foreach ($_REQUEST['boards'] as $b) |
|
507 | - $boards[] = (int) $b; |
|
521 | + foreach ($_REQUEST['boards'] as $b) { |
|
522 | + $boards[] = (int) $b; |
|
523 | + } |
|
508 | 524 | } |
509 | 525 | |
510 | - if (!empty($board)) |
|
511 | - $boards[] = (int) $board; |
|
526 | + if (!empty($board)) { |
|
527 | + $boards[] = (int) $board; |
|
528 | + } |
|
512 | 529 | |
513 | 530 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
514 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -525,30 +542,31 @@ discard block |
||
525 | 542 | ) |
526 | 543 | ); |
527 | 544 | |
528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
529 | - if (in_array($row['id_parent'], $boards)) |
|
545 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
546 | + if (in_array($row['id_parent'], $boards)) |
|
530 | 547 | $boards[] = $row['id_board']; |
548 | + } |
|
531 | 549 | |
532 | 550 | $smcFunc['db_free_result']($request); |
533 | 551 | |
534 | - if (empty($boards)) |
|
535 | - fatal_lang_error('error_no_boards_selected'); |
|
552 | + if (empty($boards)) { |
|
553 | + fatal_lang_error('error_no_boards_selected'); |
|
554 | + } |
|
536 | 555 | |
537 | 556 | $query_this_board = 'id_board IN ({array_int:boards})'; |
538 | 557 | $query_parameters['boards'] = $boards; |
539 | 558 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
540 | - } |
|
541 | - elseif (!empty($board)) |
|
559 | + } elseif (!empty($board)) |
|
542 | 560 | { |
543 | 561 | $query_this_board = 'id_board = {int:board}'; |
544 | 562 | $query_parameters['board'] = $board; |
545 | 563 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
546 | - } |
|
547 | - elseif (!empty($_REQUEST['boards'])) |
|
564 | + } elseif (!empty($_REQUEST['boards'])) |
|
548 | 565 | { |
549 | 566 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
550 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
551 | - $_REQUEST['boards'][$i] = (int) $b; |
|
567 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
568 | + $_REQUEST['boards'][$i] = (int) $b; |
|
569 | + } |
|
552 | 570 | |
553 | 571 | $request = $smcFunc['db_query']('', ' |
554 | 572 | SELECT b.id_board |
@@ -560,22 +578,24 @@ discard block |
||
560 | 578 | ) |
561 | 579 | ); |
562 | 580 | $boards = array(); |
563 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
564 | - $boards[] = $row['id_board']; |
|
581 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
582 | + $boards[] = $row['id_board']; |
|
583 | + } |
|
565 | 584 | $smcFunc['db_free_result']($request); |
566 | 585 | |
567 | - if (empty($boards)) |
|
568 | - fatal_lang_error('error_no_boards_selected'); |
|
586 | + if (empty($boards)) { |
|
587 | + fatal_lang_error('error_no_boards_selected'); |
|
588 | + } |
|
569 | 589 | |
570 | 590 | $query_this_board = 'id_board IN ({array_int:boards})'; |
571 | 591 | $query_parameters['boards'] = $boards; |
572 | 592 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
573 | - } |
|
574 | - elseif (!empty($_REQUEST['c'])) |
|
593 | + } elseif (!empty($_REQUEST['c'])) |
|
575 | 594 | { |
576 | 595 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
577 | - foreach ($_REQUEST['c'] as $i => $c) |
|
578 | - $_REQUEST['c'][$i] = (int) $c; |
|
596 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
597 | + $_REQUEST['c'][$i] = (int) $c; |
|
598 | + } |
|
579 | 599 | |
580 | 600 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
581 | 601 | $request = $smcFunc['db_query']('', ' |
@@ -588,18 +608,19 @@ discard block |
||
588 | 608 | ) |
589 | 609 | ); |
590 | 610 | $boards = array(); |
591 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
592 | - $boards[] = $row['id_board']; |
|
611 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
612 | + $boards[] = $row['id_board']; |
|
613 | + } |
|
593 | 614 | $smcFunc['db_free_result']($request); |
594 | 615 | |
595 | - if (empty($boards)) |
|
596 | - fatal_lang_error('error_no_boards_selected'); |
|
616 | + if (empty($boards)) { |
|
617 | + fatal_lang_error('error_no_boards_selected'); |
|
618 | + } |
|
597 | 619 | |
598 | 620 | $query_this_board = 'id_board IN ({array_int:boards})'; |
599 | 621 | $query_parameters['boards'] = $boards; |
600 | 622 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
601 | - } |
|
602 | - else |
|
623 | + } else |
|
603 | 624 | { |
604 | 625 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
605 | 626 | // Don't bother to show deleted posts! |
@@ -613,12 +634,14 @@ discard block |
||
613 | 634 | ) |
614 | 635 | ); |
615 | 636 | $boards = array(); |
616 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
617 | - $boards[] = $row['id_board']; |
|
637 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
638 | + $boards[] = $row['id_board']; |
|
639 | + } |
|
618 | 640 | $smcFunc['db_free_result']($request); |
619 | 641 | |
620 | - if (empty($boards)) |
|
621 | - fatal_lang_error('error_no_boards_available', false); |
|
642 | + if (empty($boards)) { |
|
643 | + fatal_lang_error('error_no_boards_available', false); |
|
644 | + } |
|
622 | 645 | |
623 | 646 | $query_this_board = 'id_board IN ({array_int:boards})'; |
624 | 647 | $query_parameters['boards'] = $boards; |
@@ -680,13 +703,14 @@ discard block |
||
680 | 703 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
681 | 704 | ); |
682 | 705 | |
683 | - if ($context['showing_all_topics']) |
|
684 | - $context['linktree'][] = array( |
|
706 | + if ($context['showing_all_topics']) { |
|
707 | + $context['linktree'][] = array( |
|
685 | 708 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
686 | 709 | 'name' => $txt['unread_topics_all'] |
687 | 710 | ); |
688 | - else |
|
689 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
711 | + } else { |
|
712 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
713 | + } |
|
690 | 714 | |
691 | 715 | loadTemplate('Recent'); |
692 | 716 | loadTemplate('MessageIndex'); |
@@ -694,8 +718,9 @@ discard block |
||
694 | 718 | |
695 | 719 | // Setup the default topic icons... for checking they exist and the like ;) |
696 | 720 | $context['icon_sources'] = array(); |
697 | - foreach ($context['stable_icons'] as $icon) |
|
698 | - $context['icon_sources'][$icon] = 'images_url'; |
|
721 | + foreach ($context['stable_icons'] as $icon) { |
|
722 | + $context['icon_sources'][$icon] = 'images_url'; |
|
723 | + } |
|
699 | 724 | |
700 | 725 | $is_topics = $_REQUEST['action'] == 'unread'; |
701 | 726 | |
@@ -725,8 +750,7 @@ discard block |
||
725 | 750 | ); |
726 | 751 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
727 | 752 | $smcFunc['db_free_result']($request); |
728 | - } |
|
729 | - else |
|
753 | + } else |
|
730 | 754 | { |
731 | 755 | $request = $smcFunc['db_query']('', ' |
732 | 756 | SELECT MIN(lmr.id_msg) |
@@ -742,14 +766,14 @@ discard block |
||
742 | 766 | } |
743 | 767 | |
744 | 768 | // This is needed in case of topics marked unread. |
745 | - if (empty($earliest_msg)) |
|
746 | - $earliest_msg = 0; |
|
747 | - else |
|
769 | + if (empty($earliest_msg)) { |
|
770 | + $earliest_msg = 0; |
|
771 | + } else |
|
748 | 772 | { |
749 | 773 | // Using caching, when possible, to ignore the below slow query. |
750 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
751 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
752 | - else |
|
774 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
775 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
776 | + } else |
|
753 | 777 | { |
754 | 778 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
755 | 779 | $request = $smcFunc['db_query']('', ' |
@@ -764,8 +788,9 @@ discard block |
||
764 | 788 | $smcFunc['db_free_result']($request); |
765 | 789 | |
766 | 790 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
767 | - if ($earliest_msg2 == 0) |
|
768 | - $earliest_msg2 = -1; |
|
791 | + if ($earliest_msg2 == 0) { |
|
792 | + $earliest_msg2 = -1; |
|
793 | + } |
|
769 | 794 | |
770 | 795 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
771 | 796 | } |
@@ -803,9 +828,9 @@ discard block |
||
803 | 828 | 'db_error_skip' => true, |
804 | 829 | )) |
805 | 830 | ) !== false; |
831 | + } else { |
|
832 | + $have_temp_table = false; |
|
806 | 833 | } |
807 | - else |
|
808 | - $have_temp_table = false; |
|
809 | 834 | |
810 | 835 | if ($context['showing_all_topics'] && $have_temp_table) |
811 | 836 | { |
@@ -851,14 +876,15 @@ discard block |
||
851 | 876 | |
852 | 877 | $context['topics'] = array(); |
853 | 878 | $context['no_topic_listing'] = true; |
854 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
855 | - $context['querystring_board_limits'] = ''; |
|
856 | - else |
|
857 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
879 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
880 | + $context['querystring_board_limits'] = ''; |
|
881 | + } else { |
|
882 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
883 | + } |
|
858 | 884 | return; |
885 | + } else { |
|
886 | + $min_message = (int) $min_message; |
|
859 | 887 | } |
860 | - else |
|
861 | - $min_message = (int) $min_message; |
|
862 | 888 | |
863 | 889 | $request = $smcFunc['db_query']('substring', ' |
864 | 890 | SELECT ' . $select_clause . ' |
@@ -887,8 +913,7 @@ discard block |
||
887 | 913 | 'limit' => $context['topics_per_page'], |
888 | 914 | )) |
889 | 915 | ); |
890 | - } |
|
891 | - elseif ($is_topics) |
|
916 | + } elseif ($is_topics) |
|
892 | 917 | { |
893 | 918 | $request = $smcFunc['db_query']('', ' |
894 | 919 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -939,14 +964,15 @@ discard block |
||
939 | 964 | |
940 | 965 | $context['topics'] = array(); |
941 | 966 | $context['no_topic_listing'] = true; |
942 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
943 | - $context['querystring_board_limits'] = ''; |
|
944 | - else |
|
945 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
967 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
968 | + $context['querystring_board_limits'] = ''; |
|
969 | + } else { |
|
970 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
971 | + } |
|
946 | 972 | return; |
973 | + } else { |
|
974 | + $min_message = (int) $min_message; |
|
947 | 975 | } |
948 | - else |
|
949 | - $min_message = (int) $min_message; |
|
950 | 976 | |
951 | 977 | $request = $smcFunc['db_query']('substring', ' |
952 | 978 | SELECT ' . $select_clause . ' |
@@ -976,8 +1002,7 @@ discard block |
||
976 | 1002 | 'limit' => $context['topics_per_page'], |
977 | 1003 | )) |
978 | 1004 | ); |
979 | - } |
|
980 | - else |
|
1005 | + } else |
|
981 | 1006 | { |
982 | 1007 | if ($modSettings['totalMessages'] > 100000) |
983 | 1008 | { |
@@ -1029,8 +1054,8 @@ discard block |
||
1029 | 1054 | ) !== false; |
1030 | 1055 | |
1031 | 1056 | // If that worked, create a sample of the log_topics table too. |
1032 | - if ($have_temp_table) |
|
1033 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
1057 | + if ($have_temp_table) { |
|
1058 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
1034 | 1059 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
1035 | 1060 | PRIMARY KEY (id_topic) |
1036 | 1061 | ) |
@@ -1043,6 +1068,7 @@ discard block |
||
1043 | 1068 | 'db_error_skip' => true, |
1044 | 1069 | ) |
1045 | 1070 | ) !== false; |
1071 | + } |
|
1046 | 1072 | } |
1047 | 1073 | |
1048 | 1074 | if (!empty($have_temp_table)) |
@@ -1058,8 +1084,7 @@ discard block |
||
1058 | 1084 | ); |
1059 | 1085 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
1060 | 1086 | $smcFunc['db_free_result']($request); |
1061 | - } |
|
1062 | - else |
|
1087 | + } else |
|
1063 | 1088 | { |
1064 | 1089 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
1065 | 1090 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1100,15 +1125,16 @@ discard block |
||
1100 | 1125 | { |
1101 | 1126 | $context['topics'] = array(); |
1102 | 1127 | $context['no_topic_listing'] = true; |
1103 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1104 | - $context['querystring_board_limits'] = ''; |
|
1105 | - else |
|
1106 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1128 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1129 | + $context['querystring_board_limits'] = ''; |
|
1130 | + } else { |
|
1131 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1132 | + } |
|
1107 | 1133 | return; |
1108 | 1134 | } |
1109 | 1135 | |
1110 | - if (!empty($have_temp_table)) |
|
1111 | - $request = $smcFunc['db_query']('', ' |
|
1136 | + if (!empty($have_temp_table)) { |
|
1137 | + $request = $smcFunc['db_query']('', ' |
|
1112 | 1138 | SELECT t.id_topic |
1113 | 1139 | FROM {db_prefix}topics_posted_in AS t |
1114 | 1140 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1122,8 +1148,8 @@ discard block |
||
1122 | 1148 | 'limit' => $context['topics_per_page'], |
1123 | 1149 | )) |
1124 | 1150 | ); |
1125 | - else |
|
1126 | - $request = $smcFunc['db_query']('', ' |
|
1151 | + } else { |
|
1152 | + $request = $smcFunc['db_query']('', ' |
|
1127 | 1153 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
1128 | 1154 | FROM {db_prefix}topics AS t |
1129 | 1155 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1147,10 +1173,12 @@ discard block |
||
1147 | 1173 | 'sort' => $_REQUEST['sort'], |
1148 | 1174 | )) |
1149 | 1175 | ); |
1176 | + } |
|
1150 | 1177 | |
1151 | 1178 | $topics = array(); |
1152 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1153 | - $topics[] = $row['id_topic']; |
|
1179 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1180 | + $topics[] = $row['id_topic']; |
|
1181 | + } |
|
1154 | 1182 | $smcFunc['db_free_result']($request); |
1155 | 1183 | |
1156 | 1184 | // Sanity... where have you gone? |
@@ -1158,10 +1186,11 @@ discard block |
||
1158 | 1186 | { |
1159 | 1187 | $context['topics'] = array(); |
1160 | 1188 | $context['no_topic_listing'] = true; |
1161 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1162 | - $context['querystring_board_limits'] = ''; |
|
1163 | - else |
|
1164 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1189 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1190 | + $context['querystring_board_limits'] = ''; |
|
1191 | + } else { |
|
1192 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1193 | + } |
|
1165 | 1194 | return; |
1166 | 1195 | } |
1167 | 1196 | |
@@ -1195,8 +1224,9 @@ discard block |
||
1195 | 1224 | |
1196 | 1225 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1197 | 1226 | { |
1198 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
1199 | - continue; |
|
1227 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
1228 | + continue; |
|
1229 | + } |
|
1200 | 1230 | |
1201 | 1231 | $topic_ids[] = $row['id_topic']; |
1202 | 1232 | |
@@ -1204,11 +1234,13 @@ discard block |
||
1204 | 1234 | { |
1205 | 1235 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
1206 | 1236 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
1207 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
1208 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1237 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
1238 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1239 | + } |
|
1209 | 1240 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
1210 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
1211 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1241 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
1242 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1243 | + } |
|
1212 | 1244 | |
1213 | 1245 | // Censor the subject and message preview. |
1214 | 1246 | censorText($row['first_subject']); |
@@ -1219,23 +1251,22 @@ discard block |
||
1219 | 1251 | { |
1220 | 1252 | $row['last_subject'] = $row['first_subject']; |
1221 | 1253 | $row['last_body'] = $row['first_body']; |
1222 | - } |
|
1223 | - else |
|
1254 | + } else |
|
1224 | 1255 | { |
1225 | 1256 | censorText($row['last_subject']); |
1226 | 1257 | censorText($row['last_body']); |
1227 | 1258 | } |
1228 | - } |
|
1229 | - else |
|
1259 | + } else |
|
1230 | 1260 | { |
1231 | 1261 | $row['first_body'] = ''; |
1232 | 1262 | $row['last_body'] = ''; |
1233 | 1263 | censorText($row['first_subject']); |
1234 | 1264 | |
1235 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
1236 | - $row['last_subject'] = $row['first_subject']; |
|
1237 | - else |
|
1238 | - censorText($row['last_subject']); |
|
1265 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
1266 | + $row['last_subject'] = $row['first_subject']; |
|
1267 | + } else { |
|
1268 | + censorText($row['last_subject']); |
|
1269 | + } |
|
1239 | 1270 | } |
1240 | 1271 | |
1241 | 1272 | // Decide how many pages the topic should have. |
@@ -1247,22 +1278,24 @@ discard block |
||
1247 | 1278 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
1248 | 1279 | |
1249 | 1280 | // If we can use all, show all. |
1250 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
1251 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1281 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
1282 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1283 | + } |
|
1284 | + } else { |
|
1285 | + $pages = ''; |
|
1252 | 1286 | } |
1253 | 1287 | |
1254 | - else |
|
1255 | - $pages = ''; |
|
1256 | - |
|
1257 | 1288 | // We need to check the topic icons exist... you can never be too sure! |
1258 | 1289 | if (!empty($modSettings['messageIconChecks_enable'])) |
1259 | 1290 | { |
1260 | 1291 | // First icon first... as you'd expect. |
1261 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
1262 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1292 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
1293 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1294 | + } |
|
1263 | 1295 | // Last icon... last... duh. |
1264 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
1265 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1296 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
1297 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1298 | + } |
|
1266 | 1299 | } |
1267 | 1300 | |
1268 | 1301 | // Force the recycling icon if appropriate |
@@ -1276,12 +1309,14 @@ discard block |
||
1276 | 1309 | $colorClass = 'windowbg'; |
1277 | 1310 | |
1278 | 1311 | // Sticky topics should get a different color, too. |
1279 | - if ($row['is_sticky']) |
|
1280 | - $colorClass .= ' sticky'; |
|
1312 | + if ($row['is_sticky']) { |
|
1313 | + $colorClass .= ' sticky'; |
|
1314 | + } |
|
1281 | 1315 | |
1282 | 1316 | // Locked topics get special treatment as well. |
1283 | - if ($row['locked']) |
|
1284 | - $colorClass .= ' locked'; |
|
1317 | + if ($row['locked']) { |
|
1318 | + $colorClass .= ' locked'; |
|
1319 | + } |
|
1285 | 1320 | |
1286 | 1321 | // And build the array. |
1287 | 1322 | $context['topics'][$row['id_topic']] = array( |
@@ -1378,8 +1413,9 @@ discard block |
||
1378 | 1413 | ); |
1379 | 1414 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1380 | 1415 | { |
1381 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
1382 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1416 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
1417 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1418 | + } |
|
1383 | 1419 | } |
1384 | 1420 | $smcFunc['db_free_result']($result); |
1385 | 1421 | } |
@@ -1394,28 +1430,30 @@ discard block |
||
1394 | 1430 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
1395 | 1431 | ); |
1396 | 1432 | |
1397 | - if ($context['showCheckboxes']) |
|
1398 | - $context['recent_buttons']['markselectread'] = array( |
|
1433 | + if ($context['showCheckboxes']) { |
|
1434 | + $context['recent_buttons']['markselectread'] = array( |
|
1399 | 1435 | 'text' => 'quick_mod_markread', |
1400 | 1436 | 'image' => 'markselectedread.png', |
1401 | 1437 | 'url' => 'javascript:document.quickModForm.submit();', |
1402 | 1438 | ); |
1439 | + } |
|
1403 | 1440 | |
1404 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
1405 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1406 | - } |
|
1407 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1441 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
1442 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1443 | + } |
|
1444 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1408 | 1445 | { |
1409 | 1446 | $context['recent_buttons'] = array( |
1410 | 1447 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
1411 | 1448 | ); |
1412 | 1449 | |
1413 | - if ($context['showCheckboxes']) |
|
1414 | - $context['recent_buttons']['markselectread'] = array( |
|
1450 | + if ($context['showCheckboxes']) { |
|
1451 | + $context['recent_buttons']['markselectread'] = array( |
|
1415 | 1452 | 'text' => 'quick_mod_markread', |
1416 | 1453 | 'image' => 'markselectedread.png', |
1417 | 1454 | 'url' => 'javascript:document.quickModForm.submit();', |
1418 | 1455 | ); |
1456 | + } |
|
1419 | 1457 | } |
1420 | 1458 | |
1421 | 1459 | // Allow mods to add additional buttons here |
@@ -5370,7 +5370,6 @@ discard block |
||
5370 | 5370 | |
5371 | 5371 | /** |
5372 | 5372 | * Tries different modes to make file/dirs writable. Wrapper function for chmod() |
5373 | - |
|
5374 | 5373 | * @param string $file The file/dir full path. |
5375 | 5374 | * @param int $value Not needed, added for legacy reasons. |
5376 | 5375 | * @return boolean true if the file/dir is already writable or the function was able to make it writable, false if the function couldn't make the file/dir writable. |
@@ -5410,7 +5409,6 @@ discard block |
||
5410 | 5409 | |
5411 | 5410 | /** |
5412 | 5411 | * Wrapper function for json_decode() with error handling. |
5413 | - |
|
5414 | 5412 | * @param string $json The string to decode. |
5415 | 5413 | * @param bool $returnAsArray To return the decoded string as an array or an object, SMF only uses Arrays but to keep on compatibility with json_decode its set to false as default. |
5416 | 5414 | * @param bool $logIt To specify if the error will be logged if theres any. |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | * - caches the formatting data from the setting for optimization. |
677 | 677 | * |
678 | 678 | * @param float $number A number |
679 | - * @param bool|int $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
679 | + * @param integer $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
680 | 680 | * @return string A formatted number |
681 | 681 | */ |
682 | 682 | function comma_format($number, $override_decimal_count = false) |
@@ -5527,7 +5527,7 @@ discard block |
||
5527 | 5527 | * It assumes the data is already a string. |
5528 | 5528 | * @param string $data The data to print |
5529 | 5529 | * @param string $type The content type. Defaults to Json. |
5530 | - * @return void |
|
5530 | + * @return false|null |
|
5531 | 5531 | */ |
5532 | 5532 | function smf_serverResponse($data = '', $type = 'Content-Type: application/json') |
5533 | 5533 | { |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
801 | 801 | if (empty($unsupportedFormats)) |
802 | 802 | { |
803 | - foreach($strftimeFormatSubstitutions as $format => $substitution) |
|
803 | + foreach ($strftimeFormatSubstitutions as $format => $substitution) |
|
804 | 804 | { |
805 | 805 | $value = @strftime('%' . $format); |
806 | 806 | |
@@ -1165,7 +1165,7 @@ discard block |
||
1165 | 1165 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
1166 | 1166 | ), |
1167 | 1167 | 'content' => '$1', |
1168 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1168 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1169 | 1169 | { |
1170 | 1170 | $returnContext = ''; |
1171 | 1171 | |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
1203 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
1203 | + $returnContext .= '<a href="' . $currentAttachment['href'] . ';image" id="link_' . $currentAttachment['id'] . '" onclick="' . $currentAttachment['thumbnail']['javascript'] . '"><img src="' . $currentAttachment['thumbnail']['href'] . '"' . $alt . $title . ' id="thumb_' . $currentAttachment['id'] . '" class="atc_img"></a>'; |
|
1204 | 1204 | else |
1205 | 1205 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
1206 | 1206 | } |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | 'type' => 'unparsed_content', |
1230 | 1230 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
1231 | 1231 | // @todo Maybe this can be simplified? |
1232 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1232 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1233 | 1233 | { |
1234 | 1234 | if (!isset($disabled['code'])) |
1235 | 1235 | { |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | 'type' => 'unparsed_equals_content', |
1267 | 1267 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
1268 | 1268 | // @todo Maybe this can be simplified? |
1269 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1269 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1270 | 1270 | { |
1271 | 1271 | if (!isset($disabled['code'])) |
1272 | 1272 | { |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | 'type' => 'unparsed_content', |
1311 | 1311 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
1312 | 1312 | // @todo Should this respect guest_hideContacts? |
1313 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1313 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1314 | 1314 | { |
1315 | 1315 | $data = strtr($data, array('<br>' => '')); |
1316 | 1316 | }, |
@@ -1329,7 +1329,7 @@ discard block |
||
1329 | 1329 | 'type' => 'unparsed_commas_content', |
1330 | 1330 | 'test' => '\d+,\d+\]', |
1331 | 1331 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1332 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1332 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1333 | 1333 | { |
1334 | 1334 | if (isset($disabled['url'])) |
1335 | 1335 | $tag['content'] = '$1'; |
@@ -1345,7 +1345,7 @@ discard block |
||
1345 | 1345 | 'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]', |
1346 | 1346 | 'before' => '<div $1>', |
1347 | 1347 | 'after' => '</div>', |
1348 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1348 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1349 | 1349 | { |
1350 | 1350 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1351 | 1351 | |
@@ -1394,7 +1394,7 @@ discard block |
||
1394 | 1394 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
1395 | 1395 | ), |
1396 | 1396 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
1397 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1397 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1398 | 1398 | { |
1399 | 1399 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1400 | 1400 | |
@@ -1417,7 +1417,7 @@ discard block |
||
1417 | 1417 | 'tag' => 'img', |
1418 | 1418 | 'type' => 'unparsed_content', |
1419 | 1419 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
1420 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1420 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1421 | 1421 | { |
1422 | 1422 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1423 | 1423 | |
@@ -1440,7 +1440,7 @@ discard block |
||
1440 | 1440 | 'tag' => 'iurl', |
1441 | 1441 | 'type' => 'unparsed_content', |
1442 | 1442 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
1443 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1443 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1444 | 1444 | { |
1445 | 1445 | $data = strtr($data, array('<br>' => '')); |
1446 | 1446 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | 'quoted' => 'optional', |
1455 | 1455 | 'before' => '<a href="$1" class="bbc_link">', |
1456 | 1456 | 'after' => '</a>', |
1457 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1457 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1458 | 1458 | { |
1459 | 1459 | if (substr($data, 0, 1) == '#') |
1460 | 1460 | $data = '#post_' . substr($data, 1); |
@@ -1534,7 +1534,7 @@ discard block |
||
1534 | 1534 | 'tag' => 'php', |
1535 | 1535 | 'type' => 'unparsed_content', |
1536 | 1536 | 'content' => '<span class="phpcode">$1</span>', |
1537 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
1537 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
1538 | 1538 | { |
1539 | 1539 | if (!isset($disabled['php'])) |
1540 | 1540 | { |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | 'test' => '[1-7]\]', |
1633 | 1633 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
1634 | 1634 | 'after' => '</span>', |
1635 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1635 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1636 | 1636 | { |
1637 | 1637 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
1638 | 1638 | $data = $sizes[$data] . 'em'; |
@@ -1670,7 +1670,7 @@ discard block |
||
1670 | 1670 | 'tag' => 'time', |
1671 | 1671 | 'type' => 'unparsed_content', |
1672 | 1672 | 'content' => '$1', |
1673 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1673 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1674 | 1674 | { |
1675 | 1675 | if (is_numeric($data)) |
1676 | 1676 | $data = timeformat($data); |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | 'tag' => 'url', |
1699 | 1699 | 'type' => 'unparsed_content', |
1700 | 1700 | 'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>', |
1701 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1701 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1702 | 1702 | { |
1703 | 1703 | $data = strtr($data, array('<br>' => '')); |
1704 | 1704 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | 'quoted' => 'optional', |
1713 | 1713 | 'before' => '<a href="$1" class="bbc_link" target="_blank">', |
1714 | 1714 | 'after' => '</a>', |
1715 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1715 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1716 | 1716 | { |
1717 | 1717 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1718 | 1718 | if (empty($scheme)) |
@@ -1738,7 +1738,7 @@ discard block |
||
1738 | 1738 | { |
1739 | 1739 | if (isset($temp_bbc)) |
1740 | 1740 | $bbc_codes = $temp_bbc; |
1741 | - usort($codes, function ($a, $b) { |
|
1741 | + usort($codes, function($a, $b) { |
|
1742 | 1742 | return strcmp($a['tag'], $b['tag']); |
1743 | 1743 | }); |
1744 | 1744 | return $codes; |
@@ -1976,7 +1976,7 @@ discard block |
||
1976 | 1976 | # a run of Unicode domain name characters and a dot |
1977 | 1977 | [\p{L}\p{M}\p{N}\-.:@]+\. |
1978 | 1978 | # and then a TLD valid in the DNS or the reserved "local" TLD |
1979 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
1979 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
1980 | 1980 | ) |
1981 | 1981 | # followed by a non-domain character or end of line |
1982 | 1982 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2044,7 +2044,7 @@ discard block |
||
2044 | 2044 | )? |
2045 | 2045 | '; |
2046 | 2046 | |
2047 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
2047 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
2048 | 2048 | $url = array_shift($matches); |
2049 | 2049 | |
2050 | 2050 | $scheme = parse_url($url, PHP_URL_SCHEME); |
@@ -2781,7 +2781,7 @@ discard block |
||
2781 | 2781 | for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) |
2782 | 2782 | { |
2783 | 2783 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
2784 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2784 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2785 | 2785 | |
2786 | 2786 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
2787 | 2787 | |
@@ -2798,7 +2798,7 @@ discard block |
||
2798 | 2798 | |
2799 | 2799 | // Replace away! |
2800 | 2800 | $message = preg_replace_callback($smileyPregSearch, |
2801 | - function ($matches) use ($smileyPregReplacements) |
|
2801 | + function($matches) use ($smileyPregReplacements) |
|
2802 | 2802 | { |
2803 | 2803 | return $smileyPregReplacements[$matches[1]]; |
2804 | 2804 | }, $message); |
@@ -2864,13 +2864,13 @@ discard block |
||
2864 | 2864 | { |
2865 | 2865 | if (defined('SID') && SID != '') |
2866 | 2866 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
2867 | - function ($m) use ($scripturl) |
|
2867 | + function($m) use ($scripturl) |
|
2868 | 2868 | { |
2869 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
2869 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
2870 | 2870 | }, $setLocation); |
2871 | 2871 | else |
2872 | 2872 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
2873 | - function ($m) use ($scripturl) |
|
2873 | + function($m) use ($scripturl) |
|
2874 | 2874 | { |
2875 | 2875 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
2876 | 2876 | }, $setLocation); |
@@ -3193,7 +3193,7 @@ discard block |
||
3193 | 3193 | |
3194 | 3194 | // Add a generic "Are you sure?" confirmation message. |
3195 | 3195 | addInlineJavaScript(' |
3196 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
3196 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
3197 | 3197 | |
3198 | 3198 | // Now add the capping code for avatars. |
3199 | 3199 | if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
@@ -3554,7 +3554,7 @@ discard block |
||
3554 | 3554 | |
3555 | 3555 | else |
3556 | 3556 | echo ' |
3557 | - <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
|
3557 | + <script src="', $settings['theme_url'], '/scripts/minified', ($do_deferred ? '_deferred' : ''), '.js', $minSeed, '"></script>'; |
|
3558 | 3558 | } |
3559 | 3559 | |
3560 | 3560 | // Inline JavaScript - Actually useful some times! |
@@ -3632,14 +3632,14 @@ discard block |
||
3632 | 3632 | |
3633 | 3633 | else |
3634 | 3634 | echo ' |
3635 | - <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
|
3635 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/minified.css', $minSeed, '">'; |
|
3636 | 3636 | } |
3637 | 3637 | |
3638 | 3638 | // Print the rest after the minified files. |
3639 | 3639 | if (!empty($normal)) |
3640 | 3640 | foreach ($normal as $nf) |
3641 | 3641 | echo ' |
3642 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
3642 | + <link rel="stylesheet" href="', $nf, '">'; |
|
3643 | 3643 | |
3644 | 3644 | if ($db_show_debug === true) |
3645 | 3645 | { |
@@ -3655,7 +3655,7 @@ discard block |
||
3655 | 3655 | <style>'; |
3656 | 3656 | |
3657 | 3657 | foreach ($context['css_header'] as $css) |
3658 | - echo $css .' |
|
3658 | + echo $css . ' |
|
3659 | 3659 | '; |
3660 | 3660 | |
3661 | 3661 | echo' |
@@ -3684,27 +3684,27 @@ discard block |
||
3684 | 3684 | return false; |
3685 | 3685 | |
3686 | 3686 | // Did we already did this? |
3687 | - $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
|
3687 | + $toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type, 86400); |
|
3688 | 3688 | |
3689 | 3689 | // Already done? |
3690 | 3690 | if (!empty($toCache)) |
3691 | 3691 | return true; |
3692 | 3692 | |
3693 | 3693 | // No namespaces, sorry! |
3694 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
3694 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
3695 | 3695 | |
3696 | 3696 | // Temp path. |
3697 | - $cTempPath = $settings['theme_dir'] .'/'. ($type == 'css' ? 'css' : 'scripts') .'/'; |
|
3697 | + $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
|
3698 | 3698 | |
3699 | 3699 | // What kind of file are we going to create? |
3700 | - $toCreate = $cTempPath .'minified'. ($do_deferred ? '_deferred' : '') .'.'. $type; |
|
3700 | + $toCreate = $cTempPath . 'minified' . ($do_deferred ? '_deferred' : '') . '.' . $type; |
|
3701 | 3701 | |
3702 | 3702 | // File has to exists, if it isn't try to create it. |
3703 | 3703 | if ((!file_exists($toCreate) && @fopen($toCreate, 'w') === false) || !smf_chmod($toCreate)) |
3704 | 3704 | { |
3705 | 3705 | loadLanguage('Errors'); |
3706 | 3706 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
3707 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
3707 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
3708 | 3708 | |
3709 | 3709 | // The process failed so roll back to print each individual file. |
3710 | 3710 | return $data; |
@@ -3739,14 +3739,14 @@ discard block |
||
3739 | 3739 | { |
3740 | 3740 | loadLanguage('Errors'); |
3741 | 3741 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
3742 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
3742 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
3743 | 3743 | |
3744 | 3744 | // The process failed so roll back to print each individual file. |
3745 | 3745 | return $data; |
3746 | 3746 | } |
3747 | 3747 | |
3748 | 3748 | // And create a long lived cache entry. |
3749 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, $toCreate, 86400); |
|
3749 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, $toCreate, 86400); |
|
3750 | 3750 | |
3751 | 3751 | return true; |
3752 | 3752 | } |
@@ -3806,7 +3806,7 @@ discard block |
||
3806 | 3806 | else |
3807 | 3807 | $path = $modSettings['attachmentUploadDir']; |
3808 | 3808 | |
3809 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
3809 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
3810 | 3810 | } |
3811 | 3811 | |
3812 | 3812 | /** |
@@ -3850,10 +3850,10 @@ discard block |
||
3850 | 3850 | $valid_low = isValidIP($ip_parts[0]); |
3851 | 3851 | $valid_high = isValidIP($ip_parts[1]); |
3852 | 3852 | $count = 0; |
3853 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
3853 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
3854 | 3854 | $max = ($mode == ':' ? 'ffff' : '255'); |
3855 | 3855 | $min = 0; |
3856 | - if(!$valid_low) |
|
3856 | + if (!$valid_low) |
|
3857 | 3857 | { |
3858 | 3858 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
3859 | 3859 | $valid_low = isValidIP($ip_parts[0]); |
@@ -3867,7 +3867,7 @@ discard block |
||
3867 | 3867 | } |
3868 | 3868 | |
3869 | 3869 | $count = 0; |
3870 | - if(!$valid_high) |
|
3870 | + if (!$valid_high) |
|
3871 | 3871 | { |
3872 | 3872 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
3873 | 3873 | $valid_high = isValidIP($ip_parts[1]); |
@@ -3880,7 +3880,7 @@ discard block |
||
3880 | 3880 | } |
3881 | 3881 | } |
3882 | 3882 | |
3883 | - if($valid_high && $valid_low) |
|
3883 | + if ($valid_high && $valid_low) |
|
3884 | 3884 | { |
3885 | 3885 | $ip_array['low'] = $ip_parts[0]; |
3886 | 3886 | $ip_array['high'] = $ip_parts[1]; |
@@ -4062,7 +4062,7 @@ discard block |
||
4062 | 4062 | addInlineJavaScript(' |
4063 | 4063 | var user_menus = new smc_PopupMenu(); |
4064 | 4064 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4065 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
4065 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
4066 | 4066 | if ($context['allow_pm']) |
4067 | 4067 | addInlineJavaScript(' |
4068 | 4068 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4682,7 +4682,7 @@ discard block |
||
4682 | 4682 | // No? try a fallback to $sourcedir |
4683 | 4683 | else |
4684 | 4684 | { |
4685 | - $absPath = $sourcedir .'/'. $file; |
|
4685 | + $absPath = $sourcedir . '/' . $file; |
|
4686 | 4686 | |
4687 | 4687 | if (file_exists($absPath)) |
4688 | 4688 | require_once($absPath); |
@@ -4763,15 +4763,15 @@ discard block |
||
4763 | 4763 | |
4764 | 4764 | // UTF-8 occurences of MS special characters |
4765 | 4765 | $findchars_utf8 = array( |
4766 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
4767 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
4768 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
4769 | - "\xe2\x80\x98", // left single curly quote |
|
4770 | - "\xe2\x80\x99", // right single curly quote |
|
4771 | - "\xe2\x80\x9c", // left double curly quote |
|
4772 | - "\xe2\x80\x9d", // right double curly quote |
|
4773 | - "\xe2\x80\x93", // en dash |
|
4774 | - "\xe2\x80\x94", // em dash |
|
4766 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
4767 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
4768 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
4769 | + "\xe2\x80\x98", // left single curly quote |
|
4770 | + "\xe2\x80\x99", // right single curly quote |
|
4771 | + "\xe2\x80\x9c", // left double curly quote |
|
4772 | + "\xe2\x80\x9d", // right double curly quote |
|
4773 | + "\xe2\x80\x93", // en dash |
|
4774 | + "\xe2\x80\x94", // em dash |
|
4775 | 4775 | ); |
4776 | 4776 | |
4777 | 4777 | // windows 1252 / iso equivalents |
@@ -4789,15 +4789,15 @@ discard block |
||
4789 | 4789 | |
4790 | 4790 | // safe replacements |
4791 | 4791 | $replacechars = array( |
4792 | - ',', // ‚ |
|
4793 | - ',,', // „ |
|
4794 | - '...', // … |
|
4795 | - "'", // ‘ |
|
4796 | - "'", // ’ |
|
4797 | - '"', // “ |
|
4798 | - '"', // ” |
|
4799 | - '-', // – |
|
4800 | - '--', // — |
|
4792 | + ',', // ‚ |
|
4793 | + ',,', // „ |
|
4794 | + '...', // … |
|
4795 | + "'", // ‘ |
|
4796 | + "'", // ’ |
|
4797 | + '"', // “ |
|
4798 | + '"', // ” |
|
4799 | + '-', // – |
|
4800 | + '--', // — |
|
4801 | 4801 | ); |
4802 | 4802 | |
4803 | 4803 | if ($context['utf8']) |
@@ -5216,7 +5216,7 @@ discard block |
||
5216 | 5216 | */ |
5217 | 5217 | function inet_dtop($bin) |
5218 | 5218 | { |
5219 | - if(empty($bin)) |
|
5219 | + if (empty($bin)) |
|
5220 | 5220 | return ''; |
5221 | 5221 | |
5222 | 5222 | global $db_type; |
@@ -5247,28 +5247,28 @@ discard block |
||
5247 | 5247 | */ |
5248 | 5248 | function _safe_serialize($value) |
5249 | 5249 | { |
5250 | - if(is_null($value)) |
|
5250 | + if (is_null($value)) |
|
5251 | 5251 | return 'N;'; |
5252 | 5252 | |
5253 | - if(is_bool($value)) |
|
5254 | - return 'b:'. (int) $value .';'; |
|
5253 | + if (is_bool($value)) |
|
5254 | + return 'b:' . (int) $value . ';'; |
|
5255 | 5255 | |
5256 | - if(is_int($value)) |
|
5257 | - return 'i:'. $value .';'; |
|
5256 | + if (is_int($value)) |
|
5257 | + return 'i:' . $value . ';'; |
|
5258 | 5258 | |
5259 | - if(is_float($value)) |
|
5260 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5259 | + if (is_float($value)) |
|
5260 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
5261 | 5261 | |
5262 | - if(is_string($value)) |
|
5263 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5262 | + if (is_string($value)) |
|
5263 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
5264 | 5264 | |
5265 | - if(is_array($value)) |
|
5265 | + if (is_array($value)) |
|
5266 | 5266 | { |
5267 | 5267 | $out = ''; |
5268 | - foreach($value as $k => $v) |
|
5268 | + foreach ($value as $k => $v) |
|
5269 | 5269 | $out .= _safe_serialize($k) . _safe_serialize($v); |
5270 | 5270 | |
5271 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
5271 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
5272 | 5272 | } |
5273 | 5273 | |
5274 | 5274 | // safe_serialize cannot serialize resources or objects. |
@@ -5310,7 +5310,7 @@ discard block |
||
5310 | 5310 | function _safe_unserialize($str) |
5311 | 5311 | { |
5312 | 5312 | // Input is not a string. |
5313 | - if(empty($str) || !is_string($str)) |
|
5313 | + if (empty($str) || !is_string($str)) |
|
5314 | 5314 | return false; |
5315 | 5315 | |
5316 | 5316 | $stack = array(); |
@@ -5324,40 +5324,40 @@ discard block |
||
5324 | 5324 | * 3 - in array, expecting value or another array |
5325 | 5325 | */ |
5326 | 5326 | $state = 0; |
5327 | - while($state != 1) |
|
5327 | + while ($state != 1) |
|
5328 | 5328 | { |
5329 | 5329 | $type = isset($str[0]) ? $str[0] : ''; |
5330 | - if($type == '}') |
|
5330 | + if ($type == '}') |
|
5331 | 5331 | $str = substr($str, 1); |
5332 | 5332 | |
5333 | - else if($type == 'N' && $str[1] == ';') |
|
5333 | + else if ($type == 'N' && $str[1] == ';') |
|
5334 | 5334 | { |
5335 | 5335 | $value = null; |
5336 | 5336 | $str = substr($str, 2); |
5337 | 5337 | } |
5338 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5338 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5339 | 5339 | { |
5340 | 5340 | $value = $matches[1] == '1' ? true : false; |
5341 | 5341 | $str = substr($str, 4); |
5342 | 5342 | } |
5343 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5343 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5344 | 5344 | { |
5345 | - $value = (int)$matches[1]; |
|
5345 | + $value = (int) $matches[1]; |
|
5346 | 5346 | $str = $matches[2]; |
5347 | 5347 | } |
5348 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5348 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5349 | 5349 | { |
5350 | - $value = (float)$matches[1]; |
|
5350 | + $value = (float) $matches[1]; |
|
5351 | 5351 | $str = $matches[3]; |
5352 | 5352 | } |
5353 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5353 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
5354 | 5354 | { |
5355 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
5356 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
5355 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
5356 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
5357 | 5357 | } |
5358 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5358 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5359 | 5359 | { |
5360 | - $expectedLength = (int)$matches[1]; |
|
5360 | + $expectedLength = (int) $matches[1]; |
|
5361 | 5361 | $str = $matches[2]; |
5362 | 5362 | } |
5363 | 5363 | |
@@ -5365,10 +5365,10 @@ discard block |
||
5365 | 5365 | else |
5366 | 5366 | return false; |
5367 | 5367 | |
5368 | - switch($state) |
|
5368 | + switch ($state) |
|
5369 | 5369 | { |
5370 | 5370 | case 3: // In array, expecting value or another array. |
5371 | - if($type == 'a') |
|
5371 | + if ($type == 'a') |
|
5372 | 5372 | { |
5373 | 5373 | $stack[] = &$list; |
5374 | 5374 | $list[$key] = array(); |
@@ -5377,7 +5377,7 @@ discard block |
||
5377 | 5377 | $state = 2; |
5378 | 5378 | break; |
5379 | 5379 | } |
5380 | - if($type != '}') |
|
5380 | + if ($type != '}') |
|
5381 | 5381 | { |
5382 | 5382 | $list[$key] = $value; |
5383 | 5383 | $state = 2; |
@@ -5388,29 +5388,29 @@ discard block |
||
5388 | 5388 | return false; |
5389 | 5389 | |
5390 | 5390 | case 2: // in array, expecting end of array or a key |
5391 | - if($type == '}') |
|
5391 | + if ($type == '}') |
|
5392 | 5392 | { |
5393 | 5393 | // Array size is less than expected. |
5394 | - if(count($list) < end($expected)) |
|
5394 | + if (count($list) < end($expected)) |
|
5395 | 5395 | return false; |
5396 | 5396 | |
5397 | 5397 | unset($list); |
5398 | - $list = &$stack[count($stack)-1]; |
|
5398 | + $list = &$stack[count($stack) - 1]; |
|
5399 | 5399 | array_pop($stack); |
5400 | 5400 | |
5401 | 5401 | // Go to terminal state if we're at the end of the root array. |
5402 | 5402 | array_pop($expected); |
5403 | 5403 | |
5404 | - if(count($expected) == 0) |
|
5404 | + if (count($expected) == 0) |
|
5405 | 5405 | $state = 1; |
5406 | 5406 | |
5407 | 5407 | break; |
5408 | 5408 | } |
5409 | 5409 | |
5410 | - if($type == 'i' || $type == 's') |
|
5410 | + if ($type == 'i' || $type == 's') |
|
5411 | 5411 | { |
5412 | 5412 | // Array size exceeds expected length. |
5413 | - if(count($list) >= end($expected)) |
|
5413 | + if (count($list) >= end($expected)) |
|
5414 | 5414 | return false; |
5415 | 5415 | |
5416 | 5416 | $key = $value; |
@@ -5423,7 +5423,7 @@ discard block |
||
5423 | 5423 | |
5424 | 5424 | // Expecting array or value. |
5425 | 5425 | case 0: |
5426 | - if($type == 'a') |
|
5426 | + if ($type == 'a') |
|
5427 | 5427 | { |
5428 | 5428 | $data = array(); |
5429 | 5429 | $list = &$data; |
@@ -5432,7 +5432,7 @@ discard block |
||
5432 | 5432 | break; |
5433 | 5433 | } |
5434 | 5434 | |
5435 | - if($type != '}') |
|
5435 | + if ($type != '}') |
|
5436 | 5436 | { |
5437 | 5437 | $data = $value; |
5438 | 5438 | $state = 1; |
@@ -5445,7 +5445,7 @@ discard block |
||
5445 | 5445 | } |
5446 | 5446 | |
5447 | 5447 | // Trailing data in input. |
5448 | - if(!empty($str)) |
|
5448 | + if (!empty($str)) |
|
5449 | 5449 | return false; |
5450 | 5450 | |
5451 | 5451 | return $data; |
@@ -5499,7 +5499,7 @@ discard block |
||
5499 | 5499 | // Set different modes. |
5500 | 5500 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
5501 | 5501 | |
5502 | - foreach($chmodValues as $val) |
|
5502 | + foreach ($chmodValues as $val) |
|
5503 | 5503 | { |
5504 | 5504 | // If it's writable, break out of the loop. |
5505 | 5505 | if (is_writable($file)) |
@@ -5534,13 +5534,13 @@ discard block |
||
5534 | 5534 | $returnArray = @json_decode($json, $returnAsArray); |
5535 | 5535 | |
5536 | 5536 | // PHP 5.3 so no json_last_error_msg() |
5537 | - switch(json_last_error()) |
|
5537 | + switch (json_last_error()) |
|
5538 | 5538 | { |
5539 | 5539 | case JSON_ERROR_NONE: |
5540 | 5540 | $jsonError = false; |
5541 | 5541 | break; |
5542 | 5542 | case JSON_ERROR_DEPTH: |
5543 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
5543 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
5544 | 5544 | break; |
5545 | 5545 | case JSON_ERROR_STATE_MISMATCH: |
5546 | 5546 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5568,10 +5568,10 @@ discard block |
||
5568 | 5568 | loadLanguage('Errors'); |
5569 | 5569 | |
5570 | 5570 | if (!empty($jsonDebug)) |
5571 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5571 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5572 | 5572 | |
5573 | 5573 | else |
5574 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5574 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
5575 | 5575 | |
5576 | 5576 | // Everyone expects an array. |
5577 | 5577 | return array(); |
@@ -5679,7 +5679,7 @@ discard block |
||
5679 | 5679 | }); |
5680 | 5680 | |
5681 | 5681 | // Convert Punycode to Unicode |
5682 | - $tlds = array_map(function ($input) { |
|
5682 | + $tlds = array_map(function($input) { |
|
5683 | 5683 | $prefix = 'xn--'; |
5684 | 5684 | $safe_char = 0xFFFC; |
5685 | 5685 | $base = 36; |
@@ -5695,7 +5695,7 @@ discard block |
||
5695 | 5695 | |
5696 | 5696 | foreach ($enco_parts as $encoded) |
5697 | 5697 | { |
5698 | - if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0) |
|
5698 | + if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0) |
|
5699 | 5699 | { |
5700 | 5700 | $output_parts[] = $encoded; |
5701 | 5701 | continue; |
@@ -5706,7 +5706,7 @@ discard block |
||
5706 | 5706 | $idx = 0; |
5707 | 5707 | $char = 0x80; |
5708 | 5708 | $decoded = array(); |
5709 | - $output=''; |
|
5709 | + $output = ''; |
|
5710 | 5710 | $delim_pos = strrpos($encoded, '-'); |
5711 | 5711 | |
5712 | 5712 | if ($delim_pos > strlen($prefix)) |
@@ -5722,7 +5722,7 @@ discard block |
||
5722 | 5722 | |
5723 | 5723 | for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) |
5724 | 5724 | { |
5725 | - for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base) |
|
5725 | + for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base) |
|
5726 | 5726 | { |
5727 | 5727 | $cp = ord($encoded{$enco_idx++}); |
5728 | 5728 | $digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base)); |
@@ -5763,15 +5763,15 @@ discard block |
||
5763 | 5763 | |
5764 | 5764 | // 2 bytes |
5765 | 5765 | elseif ($v < (1 << 11)) |
5766 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
5766 | + $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); |
|
5767 | 5767 | |
5768 | 5768 | // 3 bytes |
5769 | 5769 | elseif ($v < (1 << 16)) |
5770 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5770 | + $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5771 | 5771 | |
5772 | 5772 | // 4 bytes |
5773 | 5773 | elseif ($v < (1 << 21)) |
5774 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5774 | + $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5775 | 5775 | |
5776 | 5776 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
5777 | 5777 | else |
@@ -5877,7 +5877,7 @@ discard block |
||
5877 | 5877 | } |
5878 | 5878 | |
5879 | 5879 | // This recursive function creates the index array from the strings |
5880 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5880 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5881 | 5881 | { |
5882 | 5882 | static $depth = 0; |
5883 | 5883 | $depth++; |
@@ -5904,7 +5904,7 @@ discard block |
||
5904 | 5904 | }; |
5905 | 5905 | |
5906 | 5906 | // This recursive function turns the index array into a regular expression |
5907 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5907 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5908 | 5908 | { |
5909 | 5909 | static $depth = 0; |
5910 | 5910 | $depth++; |
@@ -5928,11 +5928,11 @@ discard block |
||
5928 | 5928 | |
5929 | 5929 | if (count(array_keys($value)) == 1) |
5930 | 5930 | { |
5931 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
5931 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
5932 | 5932 | $new_key .= $new_key_array[0]; |
5933 | 5933 | } |
5934 | 5934 | else |
5935 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5935 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
5936 | 5936 | } |
5937 | 5937 | |
5938 | 5938 | if ($depth > 1) |
@@ -5972,7 +5972,7 @@ discard block |
||
5972 | 5972 | $index = $add_string_to_index($string, $index); |
5973 | 5973 | |
5974 | 5974 | while (!empty($index)) |
5975 | - $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
5975 | + $regexes[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
5976 | 5976 | |
5977 | 5977 | // Restore PHP's internal character encoding to whatever it was originally |
5978 | 5978 | if (!empty($current_encoding)) |
@@ -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 | * Update some basic statistics. |
@@ -122,10 +123,11 @@ discard block |
||
122 | 123 | $smcFunc['db_free_result']($result); |
123 | 124 | |
124 | 125 | // Add this to the number of unapproved members |
125 | - if (!empty($changes['unapprovedMembers'])) |
|
126 | - $changes['unapprovedMembers'] += $coppa_approvals; |
|
127 | - else |
|
128 | - $changes['unapprovedMembers'] = $coppa_approvals; |
|
126 | + if (!empty($changes['unapprovedMembers'])) { |
|
127 | + $changes['unapprovedMembers'] += $coppa_approvals; |
|
128 | + } else { |
|
129 | + $changes['unapprovedMembers'] = $coppa_approvals; |
|
130 | + } |
|
129 | 131 | } |
130 | 132 | } |
131 | 133 | } |
@@ -133,9 +135,9 @@ discard block |
||
133 | 135 | break; |
134 | 136 | |
135 | 137 | case 'message': |
136 | - if ($parameter1 === true && $parameter2 !== null) |
|
137 | - updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
138 | - else |
|
138 | + if ($parameter1 === true && $parameter2 !== null) { |
|
139 | + updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
140 | + } else |
|
139 | 141 | { |
140 | 142 | // SUM and MAX on a smaller table is better for InnoDB tables. |
141 | 143 | $result = $smcFunc['db_query']('', ' |
@@ -175,23 +177,25 @@ discard block |
||
175 | 177 | $parameter2 = text2words($parameter2); |
176 | 178 | |
177 | 179 | $inserts = array(); |
178 | - foreach ($parameter2 as $word) |
|
179 | - $inserts[] = array($word, $parameter1); |
|
180 | + foreach ($parameter2 as $word) { |
|
181 | + $inserts[] = array($word, $parameter1); |
|
182 | + } |
|
180 | 183 | |
181 | - if (!empty($inserts)) |
|
182 | - $smcFunc['db_insert']('ignore', |
|
184 | + if (!empty($inserts)) { |
|
185 | + $smcFunc['db_insert']('ignore', |
|
183 | 186 | '{db_prefix}log_search_subjects', |
184 | 187 | array('word' => 'string', 'id_topic' => 'int'), |
185 | 188 | $inserts, |
186 | 189 | array('word', 'id_topic') |
187 | 190 | ); |
191 | + } |
|
188 | 192 | } |
189 | 193 | break; |
190 | 194 | |
191 | 195 | case 'topic': |
192 | - if ($parameter1 === true) |
|
193 | - updateSettings(array('totalTopics' => true), true); |
|
194 | - else |
|
196 | + if ($parameter1 === true) { |
|
197 | + updateSettings(array('totalTopics' => true), true); |
|
198 | + } else |
|
195 | 199 | { |
196 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
197 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -212,8 +216,9 @@ discard block |
||
212 | 216 | |
213 | 217 | case 'postgroups': |
214 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
215 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
216 | - return; |
|
219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
220 | + return; |
|
221 | + } |
|
217 | 222 | |
218 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
219 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -228,8 +233,9 @@ discard block |
||
228 | 233 | ) |
229 | 234 | ); |
230 | 235 | $postgroups = array(); |
231 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
232 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
238 | + } |
|
233 | 239 | $smcFunc['db_free_result']($request); |
234 | 240 | |
235 | 241 | // Sort them this way because if it's done with MySQL it causes a filesort :(. |
@@ -239,8 +245,9 @@ discard block |
||
239 | 245 | } |
240 | 246 | |
241 | 247 | // Oh great, they've screwed their post groups. |
242 | - if (empty($postgroups)) |
|
243 | - return; |
|
248 | + if (empty($postgroups)) { |
|
249 | + return; |
|
250 | + } |
|
244 | 251 | |
245 | 252 | // Set all membergroups from most posts to least posts. |
246 | 253 | $conditions = ''; |
@@ -298,10 +305,9 @@ discard block |
||
298 | 305 | { |
299 | 306 | $condition = 'id_member IN ({array_int:members})'; |
300 | 307 | $parameters['members'] = $members; |
301 | - } |
|
302 | - elseif ($members === null) |
|
303 | - $condition = '1=1'; |
|
304 | - else |
|
308 | + } elseif ($members === null) { |
|
309 | + $condition = '1=1'; |
|
310 | + } else |
|
305 | 311 | { |
306 | 312 | $condition = 'id_member = {int:member}'; |
307 | 313 | $parameters['member'] = $members; |
@@ -341,9 +347,9 @@ discard block |
||
341 | 347 | if (count($vars_to_integrate) != 0) |
342 | 348 | { |
343 | 349 | // Fetch a list of member_names if necessary |
344 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
345 | - $member_names = array($user_info['username']); |
|
346 | - else |
|
350 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
351 | + $member_names = array($user_info['username']); |
|
352 | + } else |
|
347 | 353 | { |
348 | 354 | $member_names = array(); |
349 | 355 | $request = $smcFunc['db_query']('', ' |
@@ -352,14 +358,16 @@ discard block |
||
352 | 358 | WHERE ' . $condition, |
353 | 359 | $parameters |
354 | 360 | ); |
355 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
356 | - $member_names[] = $row['member_name']; |
|
361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
362 | + $member_names[] = $row['member_name']; |
|
363 | + } |
|
357 | 364 | $smcFunc['db_free_result']($request); |
358 | 365 | } |
359 | 366 | |
360 | - if (!empty($member_names)) |
|
361 | - foreach ($vars_to_integrate as $var) |
|
367 | + if (!empty($member_names)) { |
|
368 | + foreach ($vars_to_integrate as $var) |
|
362 | 369 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
370 | + } |
|
363 | 371 | } |
364 | 372 | } |
365 | 373 | |
@@ -367,16 +375,17 @@ discard block |
||
367 | 375 | foreach ($data as $var => $val) |
368 | 376 | { |
369 | 377 | $type = 'string'; |
370 | - if (in_array($var, $knownInts)) |
|
371 | - $type = 'int'; |
|
372 | - elseif (in_array($var, $knownFloats)) |
|
373 | - $type = 'float'; |
|
374 | - elseif ($var == 'birthdate') |
|
375 | - $type = 'date'; |
|
376 | - elseif ($var == 'member_ip') |
|
377 | - $type = 'inet'; |
|
378 | - elseif ($var == 'member_ip2') |
|
379 | - $type = 'inet'; |
|
378 | + if (in_array($var, $knownInts)) { |
|
379 | + $type = 'int'; |
|
380 | + } elseif (in_array($var, $knownFloats)) { |
|
381 | + $type = 'float'; |
|
382 | + } elseif ($var == 'birthdate') { |
|
383 | + $type = 'date'; |
|
384 | + } elseif ($var == 'member_ip') { |
|
385 | + $type = 'inet'; |
|
386 | + } elseif ($var == 'member_ip2') { |
|
387 | + $type = 'inet'; |
|
388 | + } |
|
380 | 389 | |
381 | 390 | // Doing an increment? |
382 | 391 | if ($type == 'int' && ($val === '+' || $val === '-')) |
@@ -390,8 +399,9 @@ discard block |
||
390 | 399 | { |
391 | 400 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
392 | 401 | { |
393 | - if ($match[1] != '+ ') |
|
394 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
402 | + if ($match[1] != '+ ') { |
|
403 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
404 | + } |
|
395 | 405 | $type = 'raw'; |
396 | 406 | } |
397 | 407 | } |
@@ -412,8 +422,9 @@ discard block |
||
412 | 422 | // Clear any caching? |
413 | 423 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
414 | 424 | { |
415 | - if (!is_array($members)) |
|
416 | - $members = array($members); |
|
425 | + if (!is_array($members)) { |
|
426 | + $members = array($members); |
|
427 | + } |
|
417 | 428 | |
418 | 429 | foreach ($members as $member) |
419 | 430 | { |
@@ -446,29 +457,32 @@ discard block |
||
446 | 457 | { |
447 | 458 | global $modSettings, $smcFunc; |
448 | 459 | |
449 | - if (empty($changeArray) || !is_array($changeArray)) |
|
450 | - return; |
|
460 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
461 | + return; |
|
462 | + } |
|
451 | 463 | |
452 | 464 | $toRemove = array(); |
453 | 465 | |
454 | 466 | // Go check if there is any setting to be removed. |
455 | - foreach ($changeArray as $k => $v) |
|
456 | - if ($v === null) |
|
467 | + foreach ($changeArray as $k => $v) { |
|
468 | + if ($v === null) |
|
457 | 469 | { |
458 | 470 | // Found some, remove them from the original array and add them to ours. |
459 | 471 | unset($changeArray[$k]); |
472 | + } |
|
460 | 473 | $toRemove[] = $k; |
461 | 474 | } |
462 | 475 | |
463 | 476 | // Proceed with the deletion. |
464 | - if (!empty($toRemove)) |
|
465 | - $smcFunc['db_query']('', ' |
|
477 | + if (!empty($toRemove)) { |
|
478 | + $smcFunc['db_query']('', ' |
|
466 | 479 | DELETE FROM {db_prefix}settings |
467 | 480 | WHERE variable IN ({array_string:remove})', |
468 | 481 | array( |
469 | 482 | 'remove' => $toRemove, |
470 | 483 | ) |
471 | 484 | ); |
485 | + } |
|
472 | 486 | |
473 | 487 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
474 | 488 | if ($update) |
@@ -497,19 +511,22 @@ discard block |
||
497 | 511 | foreach ($changeArray as $variable => $value) |
498 | 512 | { |
499 | 513 | // Don't bother if it's already like that ;). |
500 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
501 | - continue; |
|
514 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
515 | + continue; |
|
516 | + } |
|
502 | 517 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
503 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
504 | - continue; |
|
518 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
519 | + continue; |
|
520 | + } |
|
505 | 521 | |
506 | 522 | $replaceArray[] = array($variable, $value); |
507 | 523 | |
508 | 524 | $modSettings[$variable] = $value; |
509 | 525 | } |
510 | 526 | |
511 | - if (empty($replaceArray)) |
|
512 | - return; |
|
527 | + if (empty($replaceArray)) { |
|
528 | + return; |
|
529 | + } |
|
513 | 530 | |
514 | 531 | $smcFunc['db_insert']('replace', |
515 | 532 | '{db_prefix}settings', |
@@ -555,14 +572,17 @@ discard block |
||
555 | 572 | $start_invalid = $start < 0; |
556 | 573 | |
557 | 574 | // Make sure $start is a proper variable - not less than 0. |
558 | - if ($start_invalid) |
|
559 | - $start = 0; |
|
575 | + if ($start_invalid) { |
|
576 | + $start = 0; |
|
577 | + } |
|
560 | 578 | // Not greater than the upper bound. |
561 | - elseif ($start >= $max_value) |
|
562 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
579 | + elseif ($start >= $max_value) { |
|
580 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
581 | + } |
|
563 | 582 | // And it has to be a multiple of $num_per_page! |
564 | - else |
|
565 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
583 | + else { |
|
584 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
585 | + } |
|
566 | 586 | |
567 | 587 | $context['current_page'] = $start / $num_per_page; |
568 | 588 | |
@@ -592,77 +612,87 @@ discard block |
||
592 | 612 | |
593 | 613 | // Show all the pages. |
594 | 614 | $display_page = 1; |
595 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
596 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
615 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
616 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
617 | + } |
|
597 | 618 | |
598 | 619 | // Show the right arrow. |
599 | 620 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
600 | - if ($start != $counter - $max_value && !$start_invalid) |
|
601 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
602 | - } |
|
603 | - else |
|
621 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
622 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
623 | + } |
|
624 | + } else |
|
604 | 625 | { |
605 | 626 | // If they didn't enter an odd value, pretend they did. |
606 | 627 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
607 | 628 | |
608 | 629 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
609 | - if (!empty($start) && $show_prevnext) |
|
610 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
611 | - else |
|
612 | - $pageindex .= ''; |
|
630 | + if (!empty($start) && $show_prevnext) { |
|
631 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
632 | + } else { |
|
633 | + $pageindex .= ''; |
|
634 | + } |
|
613 | 635 | |
614 | 636 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
615 | - if ($start > $num_per_page * $PageContiguous) |
|
616 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
637 | + if ($start > $num_per_page * $PageContiguous) { |
|
638 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
639 | + } |
|
617 | 640 | |
618 | 641 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
619 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
620 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
642 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
643 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
621 | 644 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
622 | 645 | '{FIRST_PAGE}' => $num_per_page, |
623 | 646 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
624 | 647 | '{PER_PAGE}' => $num_per_page, |
625 | 648 | )); |
649 | + } |
|
626 | 650 | |
627 | 651 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
628 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
629 | - if ($start >= $num_per_page * $nCont) |
|
652 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
653 | + if ($start >= $num_per_page * $nCont) |
|
630 | 654 | { |
631 | 655 | $tmpStart = $start - $num_per_page * $nCont; |
656 | + } |
|
632 | 657 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
633 | 658 | } |
634 | 659 | |
635 | 660 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
636 | - if (!$start_invalid) |
|
637 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
638 | - else |
|
639 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
661 | + if (!$start_invalid) { |
|
662 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
663 | + } else { |
|
664 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
665 | + } |
|
640 | 666 | |
641 | 667 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
642 | 668 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
643 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
644 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
669 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
670 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
645 | 671 | { |
646 | 672 | $tmpStart = $start + $num_per_page * $nCont; |
673 | + } |
|
647 | 674 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
648 | 675 | } |
649 | 676 | |
650 | 677 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
651 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
652 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
678 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
679 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
653 | 680 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
654 | 681 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
655 | 682 | '{LAST_PAGE}' => $tmpMaxPages, |
656 | 683 | '{PER_PAGE}' => $num_per_page, |
657 | 684 | )); |
685 | + } |
|
658 | 686 | |
659 | 687 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
660 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
661 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
688 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
689 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
690 | + } |
|
662 | 691 | |
663 | 692 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
664 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
665 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
693 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
694 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
695 | + } |
|
666 | 696 | } |
667 | 697 | $pageindex .= $settings['page_index']['extra_after']; |
668 | 698 | |
@@ -688,8 +718,9 @@ discard block |
||
688 | 718 | if ($decimal_separator === null) |
689 | 719 | { |
690 | 720 | // Not set for whatever reason? |
691 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
692 | - return $number; |
|
721 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
722 | + return $number; |
|
723 | + } |
|
693 | 724 | |
694 | 725 | // Cache these each load... |
695 | 726 | $thousands_separator = $matches[1]; |
@@ -723,17 +754,20 @@ discard block |
||
723 | 754 | static $unsupportedFormats, $finalizedFormats; |
724 | 755 | |
725 | 756 | // Offset the time. |
726 | - if (!$offset_type) |
|
727 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
757 | + if (!$offset_type) { |
|
758 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
759 | + } |
|
728 | 760 | // Just the forum offset? |
729 | - elseif ($offset_type == 'forum') |
|
730 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
731 | - else |
|
732 | - $time = $log_time; |
|
761 | + elseif ($offset_type == 'forum') { |
|
762 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
763 | + } else { |
|
764 | + $time = $log_time; |
|
765 | + } |
|
733 | 766 | |
734 | 767 | // We can't have a negative date (on Windows, at least.) |
735 | - if ($log_time < 0) |
|
736 | - $log_time = 0; |
|
768 | + if ($log_time < 0) { |
|
769 | + $log_time = 0; |
|
770 | + } |
|
737 | 771 | |
738 | 772 | // Today and Yesterday? |
739 | 773 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -750,24 +784,27 @@ discard block |
||
750 | 784 | { |
751 | 785 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
752 | 786 | $today_fmt = $h . ':%M' . $s . ' %p'; |
787 | + } else { |
|
788 | + $today_fmt = '%H:%M' . $s; |
|
753 | 789 | } |
754 | - else |
|
755 | - $today_fmt = '%H:%M' . $s; |
|
756 | 790 | |
757 | 791 | // Same day of the year, same year.... Today! |
758 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
759 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
792 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
793 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
794 | + } |
|
760 | 795 | |
761 | 796 | // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year... |
762 | - if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) |
|
763 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
797 | + if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) { |
|
798 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
799 | + } |
|
764 | 800 | } |
765 | 801 | |
766 | 802 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
767 | 803 | |
768 | 804 | // Use the cached formats if available |
769 | - if (is_null($finalizedFormats)) |
|
770 | - $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
805 | + if (is_null($finalizedFormats)) { |
|
806 | + $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
807 | + } |
|
771 | 808 | |
772 | 809 | // Make a supported version for this format if we don't already have one |
773 | 810 | if (empty($finalizedFormats[$str])) |
@@ -796,8 +833,9 @@ discard block |
||
796 | 833 | ); |
797 | 834 | |
798 | 835 | // No need to do this part again if we already did it once |
799 | - if (is_null($unsupportedFormats)) |
|
800 | - $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
836 | + if (is_null($unsupportedFormats)) { |
|
837 | + $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
838 | + } |
|
801 | 839 | if (empty($unsupportedFormats)) |
802 | 840 | { |
803 | 841 | foreach($strftimeFormatSubstitutions as $format => $substitution) |
@@ -806,20 +844,23 @@ discard block |
||
806 | 844 | |
807 | 845 | // Windows will return false for unsupported formats |
808 | 846 | // Other operating systems return the format string as a literal |
809 | - if ($value === false || $value === $format) |
|
810 | - $unsupportedFormats[] = $format; |
|
847 | + if ($value === false || $value === $format) { |
|
848 | + $unsupportedFormats[] = $format; |
|
849 | + } |
|
811 | 850 | } |
812 | 851 | cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400); |
813 | 852 | } |
814 | 853 | |
815 | 854 | // Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q' |
816 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
817 | - $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
855 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
856 | + $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
857 | + } |
|
818 | 858 | |
819 | 859 | // Substitute unsupported formats with supported ones |
820 | - if (!empty($unsupportedFormats)) |
|
821 | - while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
860 | + if (!empty($unsupportedFormats)) { |
|
861 | + while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
822 | 862 | $timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat); |
863 | + } |
|
823 | 864 | |
824 | 865 | // Remember this so we don't need to do it again |
825 | 866 | $finalizedFormats[$str] = $timeformat; |
@@ -828,33 +869,39 @@ discard block |
||
828 | 869 | |
829 | 870 | $str = $finalizedFormats[$str]; |
830 | 871 | |
831 | - if (!isset($locale_cache)) |
|
832 | - $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
872 | + if (!isset($locale_cache)) { |
|
873 | + $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
874 | + } |
|
833 | 875 | |
834 | 876 | if ($locale_cache !== false) |
835 | 877 | { |
836 | 878 | // Check if another process changed the locale |
837 | - if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) |
|
838 | - setlocale(LC_TIME, $txt['lang_locale']); |
|
879 | + if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) { |
|
880 | + setlocale(LC_TIME, $txt['lang_locale']); |
|
881 | + } |
|
839 | 882 | |
840 | - if (!isset($non_twelve_hour)) |
|
841 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
842 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
843 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
883 | + if (!isset($non_twelve_hour)) { |
|
884 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
885 | + } |
|
886 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
887 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
888 | + } |
|
844 | 889 | |
845 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
846 | - if (strpos($str, $token) !== false) |
|
890 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
891 | + if (strpos($str, $token) !== false) |
|
847 | 892 | $str = str_replace($token, strftime($token, $time), $str); |
848 | - } |
|
849 | - else |
|
893 | + } |
|
894 | + } else |
|
850 | 895 | { |
851 | 896 | // Do-it-yourself time localization. Fun. |
852 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
853 | - if (strpos($str, $token) !== false) |
|
897 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
898 | + if (strpos($str, $token) !== false) |
|
854 | 899 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
900 | + } |
|
855 | 901 | |
856 | - if (strpos($str, '%p') !== false) |
|
857 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
902 | + if (strpos($str, '%p') !== false) { |
|
903 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
904 | + } |
|
858 | 905 | } |
859 | 906 | |
860 | 907 | // Format the time and then restore any literal percent characters |
@@ -877,16 +924,19 @@ discard block |
||
877 | 924 | static $translation = array(); |
878 | 925 | |
879 | 926 | // Determine the character set... Default to UTF-8 |
880 | - if (empty($context['character_set'])) |
|
881 | - $charset = 'UTF-8'; |
|
927 | + if (empty($context['character_set'])) { |
|
928 | + $charset = 'UTF-8'; |
|
929 | + } |
|
882 | 930 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
883 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
884 | - $charset = 'ISO-8859-1'; |
|
885 | - else |
|
886 | - $charset = $context['character_set']; |
|
931 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
932 | + $charset = 'ISO-8859-1'; |
|
933 | + } else { |
|
934 | + $charset = $context['character_set']; |
|
935 | + } |
|
887 | 936 | |
888 | - if (empty($translation)) |
|
889 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
937 | + if (empty($translation)) { |
|
938 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
939 | + } |
|
890 | 940 | |
891 | 941 | return strtr($string, $translation); |
892 | 942 | } |
@@ -908,8 +958,9 @@ discard block |
||
908 | 958 | global $smcFunc; |
909 | 959 | |
910 | 960 | // It was already short enough! |
911 | - if ($smcFunc['strlen']($subject) <= $len) |
|
912 | - return $subject; |
|
961 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
962 | + return $subject; |
|
963 | + } |
|
913 | 964 | |
914 | 965 | // Shorten it by the length it was too long, and strip off junk from the end. |
915 | 966 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -928,10 +979,11 @@ discard block |
||
928 | 979 | { |
929 | 980 | global $user_info, $modSettings; |
930 | 981 | |
931 | - if ($timestamp === null) |
|
932 | - $timestamp = time(); |
|
933 | - elseif ($timestamp == 0) |
|
934 | - return 0; |
|
982 | + if ($timestamp === null) { |
|
983 | + $timestamp = time(); |
|
984 | + } elseif ($timestamp == 0) { |
|
985 | + return 0; |
|
986 | + } |
|
935 | 987 | |
936 | 988 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
937 | 989 | } |
@@ -960,8 +1012,9 @@ discard block |
||
960 | 1012 | $array[$i] = $array[$j]; |
961 | 1013 | $array[$j] = $temp; |
962 | 1014 | |
963 | - for ($i = 1; $p[$i] == 0; $i++) |
|
964 | - $p[$i] = 1; |
|
1015 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
1016 | + $p[$i] = 1; |
|
1017 | + } |
|
965 | 1018 | |
966 | 1019 | $orders[] = $array; |
967 | 1020 | } |
@@ -993,12 +1046,14 @@ discard block |
||
993 | 1046 | static $disabled; |
994 | 1047 | |
995 | 1048 | // Don't waste cycles |
996 | - if ($message === '') |
|
997 | - return ''; |
|
1049 | + if ($message === '') { |
|
1050 | + return ''; |
|
1051 | + } |
|
998 | 1052 | |
999 | 1053 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
1000 | - if (!isset($context['utf8'])) |
|
1001 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1054 | + if (!isset($context['utf8'])) { |
|
1055 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1056 | + } |
|
1002 | 1057 | |
1003 | 1058 | // Clean up any cut/paste issues we may have |
1004 | 1059 | $message = sanitizeMSCutPaste($message); |
@@ -1010,13 +1065,15 @@ discard block |
||
1010 | 1065 | return $message; |
1011 | 1066 | } |
1012 | 1067 | |
1013 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
1014 | - $smileys = (bool) $smileys; |
|
1068 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
1069 | + $smileys = (bool) $smileys; |
|
1070 | + } |
|
1015 | 1071 | |
1016 | 1072 | if (empty($modSettings['enableBBC']) && $message !== false) |
1017 | 1073 | { |
1018 | - if ($smileys === true) |
|
1019 | - parsesmileys($message); |
|
1074 | + if ($smileys === true) { |
|
1075 | + parsesmileys($message); |
|
1076 | + } |
|
1020 | 1077 | |
1021 | 1078 | return $message; |
1022 | 1079 | } |
@@ -1029,8 +1086,9 @@ discard block |
||
1029 | 1086 | } |
1030 | 1087 | |
1031 | 1088 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
1032 | - if (!empty($modSettings['autoLinkUrls'])) |
|
1033 | - set_tld_regex(); |
|
1089 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
1090 | + set_tld_regex(); |
|
1091 | + } |
|
1034 | 1092 | |
1035 | 1093 | // Allow mods access before entering the main parse_bbc loop |
1036 | 1094 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -1044,12 +1102,14 @@ discard block |
||
1044 | 1102 | |
1045 | 1103 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
1046 | 1104 | |
1047 | - foreach ($temp as $tag) |
|
1048 | - $disabled[trim($tag)] = true; |
|
1105 | + foreach ($temp as $tag) { |
|
1106 | + $disabled[trim($tag)] = true; |
|
1107 | + } |
|
1049 | 1108 | } |
1050 | 1109 | |
1051 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1052 | - $disabled['flash'] = true; |
|
1110 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1111 | + $disabled['flash'] = true; |
|
1112 | + } |
|
1053 | 1113 | |
1054 | 1114 | /* The following bbc are formatted as an array, with keys as follows: |
1055 | 1115 | |
@@ -1170,8 +1230,9 @@ discard block |
||
1170 | 1230 | $returnContext = ''; |
1171 | 1231 | |
1172 | 1232 | // BBC or the entire attachments feature is disabled |
1173 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
1174 | - return $data; |
|
1233 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
1234 | + return $data; |
|
1235 | + } |
|
1175 | 1236 | |
1176 | 1237 | // Save the attach ID. |
1177 | 1238 | $attachID = $data; |
@@ -1182,8 +1243,9 @@ discard block |
||
1182 | 1243 | $currentAttachment = parseAttachBBC($attachID); |
1183 | 1244 | |
1184 | 1245 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
1185 | - if (is_string($currentAttachment)) |
|
1186 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1246 | + if (is_string($currentAttachment)) { |
|
1247 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1248 | + } |
|
1187 | 1249 | |
1188 | 1250 | if (!empty($currentAttachment['is_image'])) |
1189 | 1251 | { |
@@ -1199,15 +1261,17 @@ discard block |
||
1199 | 1261 | $height = ' height="' . $currentAttachment['height'] . '"'; |
1200 | 1262 | } |
1201 | 1263 | |
1202 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
1203 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
1204 | - else |
|
1205 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1264 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
1265 | + $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
1266 | + } else { |
|
1267 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1268 | + } |
|
1206 | 1269 | } |
1207 | 1270 | |
1208 | 1271 | // No image. Show a link. |
1209 | - else |
|
1210 | - $returnContext .= $currentAttachment['link']; |
|
1272 | + else { |
|
1273 | + $returnContext .= $currentAttachment['link']; |
|
1274 | + } |
|
1211 | 1275 | |
1212 | 1276 | // Gotta append what we just did. |
1213 | 1277 | $data = $returnContext; |
@@ -1238,8 +1302,9 @@ discard block |
||
1238 | 1302 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1239 | 1303 | { |
1240 | 1304 | // Do PHP code coloring? |
1241 | - if ($php_parts[$php_i] != '<?php') |
|
1242 | - continue; |
|
1305 | + if ($php_parts[$php_i] != '<?php') { |
|
1306 | + continue; |
|
1307 | + } |
|
1243 | 1308 | |
1244 | 1309 | $php_string = ''; |
1245 | 1310 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1255,8 +1320,9 @@ discard block |
||
1255 | 1320 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
1256 | 1321 | |
1257 | 1322 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1258 | - if ($context['browser']['is_opera']) |
|
1259 | - $data .= ' '; |
|
1323 | + if ($context['browser']['is_opera']) { |
|
1324 | + $data .= ' '; |
|
1325 | + } |
|
1260 | 1326 | } |
1261 | 1327 | }, |
1262 | 1328 | 'block_level' => true, |
@@ -1275,8 +1341,9 @@ discard block |
||
1275 | 1341 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1276 | 1342 | { |
1277 | 1343 | // Do PHP code coloring? |
1278 | - if ($php_parts[$php_i] != '<?php') |
|
1279 | - continue; |
|
1344 | + if ($php_parts[$php_i] != '<?php') { |
|
1345 | + continue; |
|
1346 | + } |
|
1280 | 1347 | |
1281 | 1348 | $php_string = ''; |
1282 | 1349 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1292,8 +1359,9 @@ discard block |
||
1292 | 1359 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
1293 | 1360 | |
1294 | 1361 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1295 | - if ($context['browser']['is_opera']) |
|
1296 | - $data[0] .= ' '; |
|
1362 | + if ($context['browser']['is_opera']) { |
|
1363 | + $data[0] .= ' '; |
|
1364 | + } |
|
1297 | 1365 | } |
1298 | 1366 | }, |
1299 | 1367 | 'block_level' => true, |
@@ -1331,11 +1399,13 @@ discard block |
||
1331 | 1399 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1332 | 1400 | 'validate' => function (&$tag, &$data, $disabled) |
1333 | 1401 | { |
1334 | - if (isset($disabled['url'])) |
|
1335 | - $tag['content'] = '$1'; |
|
1402 | + if (isset($disabled['url'])) { |
|
1403 | + $tag['content'] = '$1'; |
|
1404 | + } |
|
1336 | 1405 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
1337 | - if (empty($scheme)) |
|
1338 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
1406 | + if (empty($scheme)) { |
|
1407 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
1408 | + } |
|
1339 | 1409 | }, |
1340 | 1410 | 'disabled_content' => '<a href="$1" target="_blank" class="new_win">$1</a>', |
1341 | 1411 | ), |
@@ -1349,10 +1419,11 @@ discard block |
||
1349 | 1419 | { |
1350 | 1420 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1351 | 1421 | |
1352 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
1353 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1354 | - else |
|
1355 | - $css = ''; |
|
1422 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
1423 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1424 | + } else { |
|
1425 | + $css = ''; |
|
1426 | + } |
|
1356 | 1427 | |
1357 | 1428 | $data = $class . $css; |
1358 | 1429 | }, |
@@ -1402,14 +1473,16 @@ discard block |
||
1402 | 1473 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1403 | 1474 | if ($image_proxy_enabled) |
1404 | 1475 | { |
1405 | - if (empty($scheme)) |
|
1406 | - $data = 'http://' . ltrim($data, ':/'); |
|
1476 | + if (empty($scheme)) { |
|
1477 | + $data = 'http://' . ltrim($data, ':/'); |
|
1478 | + } |
|
1407 | 1479 | |
1408 | - if ($scheme != 'https') |
|
1409 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1480 | + if ($scheme != 'https') { |
|
1481 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1482 | + } |
|
1483 | + } elseif (empty($scheme)) { |
|
1484 | + $data = '//' . ltrim($data, ':/'); |
|
1410 | 1485 | } |
1411 | - elseif (empty($scheme)) |
|
1412 | - $data = '//' . ltrim($data, ':/'); |
|
1413 | 1486 | }, |
1414 | 1487 | 'disabled_content' => '($1)', |
1415 | 1488 | ), |
@@ -1425,14 +1498,16 @@ discard block |
||
1425 | 1498 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1426 | 1499 | if ($image_proxy_enabled) |
1427 | 1500 | { |
1428 | - if (empty($scheme)) |
|
1429 | - $data = 'http://' . ltrim($data, ':/'); |
|
1501 | + if (empty($scheme)) { |
|
1502 | + $data = 'http://' . ltrim($data, ':/'); |
|
1503 | + } |
|
1430 | 1504 | |
1431 | - if ($scheme != 'https') |
|
1432 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1505 | + if ($scheme != 'https') { |
|
1506 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1507 | + } |
|
1508 | + } elseif (empty($scheme)) { |
|
1509 | + $data = '//' . ltrim($data, ':/'); |
|
1433 | 1510 | } |
1434 | - elseif (empty($scheme)) |
|
1435 | - $data = '//' . ltrim($data, ':/'); |
|
1436 | 1511 | }, |
1437 | 1512 | 'disabled_content' => '($1)', |
1438 | 1513 | ), |
@@ -1444,8 +1519,9 @@ discard block |
||
1444 | 1519 | { |
1445 | 1520 | $data = strtr($data, array('<br>' => '')); |
1446 | 1521 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1447 | - if (empty($scheme)) |
|
1448 | - $data = '//' . ltrim($data, ':/'); |
|
1522 | + if (empty($scheme)) { |
|
1523 | + $data = '//' . ltrim($data, ':/'); |
|
1524 | + } |
|
1449 | 1525 | }, |
1450 | 1526 | ), |
1451 | 1527 | array( |
@@ -1456,13 +1532,14 @@ discard block |
||
1456 | 1532 | 'after' => '</a>', |
1457 | 1533 | 'validate' => function (&$tag, &$data, $disabled) |
1458 | 1534 | { |
1459 | - if (substr($data, 0, 1) == '#') |
|
1460 | - $data = '#post_' . substr($data, 1); |
|
1461 | - else |
|
1535 | + if (substr($data, 0, 1) == '#') { |
|
1536 | + $data = '#post_' . substr($data, 1); |
|
1537 | + } else |
|
1462 | 1538 | { |
1463 | 1539 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1464 | - if (empty($scheme)) |
|
1465 | - $data = '//' . ltrim($data, ':/'); |
|
1540 | + if (empty($scheme)) { |
|
1541 | + $data = '//' . ltrim($data, ':/'); |
|
1542 | + } |
|
1466 | 1543 | } |
1467 | 1544 | }, |
1468 | 1545 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1540,8 +1617,9 @@ discard block |
||
1540 | 1617 | { |
1541 | 1618 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
1542 | 1619 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
1543 | - if ($add_begin) |
|
1544 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1620 | + if ($add_begin) { |
|
1621 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1622 | + } |
|
1545 | 1623 | } |
1546 | 1624 | }, |
1547 | 1625 | 'block_level' => false, |
@@ -1672,10 +1750,11 @@ discard block |
||
1672 | 1750 | 'content' => '$1', |
1673 | 1751 | 'validate' => function (&$tag, &$data, $disabled) |
1674 | 1752 | { |
1675 | - if (is_numeric($data)) |
|
1676 | - $data = timeformat($data); |
|
1677 | - else |
|
1678 | - $tag['content'] = '[time]$1[/time]'; |
|
1753 | + if (is_numeric($data)) { |
|
1754 | + $data = timeformat($data); |
|
1755 | + } else { |
|
1756 | + $tag['content'] = '[time]$1[/time]'; |
|
1757 | + } |
|
1679 | 1758 | }, |
1680 | 1759 | ), |
1681 | 1760 | array( |
@@ -1702,8 +1781,9 @@ discard block |
||
1702 | 1781 | { |
1703 | 1782 | $data = strtr($data, array('<br>' => '')); |
1704 | 1783 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1705 | - if (empty($scheme)) |
|
1706 | - $data = '//' . ltrim($data, ':/'); |
|
1784 | + if (empty($scheme)) { |
|
1785 | + $data = '//' . ltrim($data, ':/'); |
|
1786 | + } |
|
1707 | 1787 | }, |
1708 | 1788 | ), |
1709 | 1789 | array( |
@@ -1715,8 +1795,9 @@ discard block |
||
1715 | 1795 | 'validate' => function (&$tag, &$data, $disabled) |
1716 | 1796 | { |
1717 | 1797 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1718 | - if (empty($scheme)) |
|
1719 | - $data = '//' . ltrim($data, ':/'); |
|
1798 | + if (empty($scheme)) { |
|
1799 | + $data = '//' . ltrim($data, ':/'); |
|
1800 | + } |
|
1720 | 1801 | }, |
1721 | 1802 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
1722 | 1803 | 'disabled_after' => ' ($1)', |
@@ -1736,8 +1817,9 @@ discard block |
||
1736 | 1817 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
1737 | 1818 | if ($message === false) |
1738 | 1819 | { |
1739 | - if (isset($temp_bbc)) |
|
1740 | - $bbc_codes = $temp_bbc; |
|
1820 | + if (isset($temp_bbc)) { |
|
1821 | + $bbc_codes = $temp_bbc; |
|
1822 | + } |
|
1741 | 1823 | usort($codes, function ($a, $b) { |
1742 | 1824 | return strcmp($a['tag'], $b['tag']); |
1743 | 1825 | }); |
@@ -1757,8 +1839,9 @@ discard block |
||
1757 | 1839 | ); |
1758 | 1840 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
1759 | 1841 | { |
1760 | - foreach ($itemcodes as $c => $dummy) |
|
1761 | - $bbc_codes[$c] = array(); |
|
1842 | + foreach ($itemcodes as $c => $dummy) { |
|
1843 | + $bbc_codes[$c] = array(); |
|
1844 | + } |
|
1762 | 1845 | } |
1763 | 1846 | |
1764 | 1847 | // Shhhh! |
@@ -1779,12 +1862,14 @@ discard block |
||
1779 | 1862 | foreach ($codes as $code) |
1780 | 1863 | { |
1781 | 1864 | // Make it easier to process parameters later |
1782 | - if (!empty($code['parameters'])) |
|
1783 | - ksort($code['parameters'], SORT_STRING); |
|
1865 | + if (!empty($code['parameters'])) { |
|
1866 | + ksort($code['parameters'], SORT_STRING); |
|
1867 | + } |
|
1784 | 1868 | |
1785 | 1869 | // If we are not doing every tag only do ones we are interested in. |
1786 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
1787 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1870 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
1871 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1872 | + } |
|
1788 | 1873 | } |
1789 | 1874 | $codes = null; |
1790 | 1875 | } |
@@ -1795,8 +1880,9 @@ discard block |
||
1795 | 1880 | // It's likely this will change if the message is modified. |
1796 | 1881 | $cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . $smcFunc['json_encode']($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']); |
1797 | 1882 | |
1798 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
1799 | - return $temp; |
|
1883 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
1884 | + return $temp; |
|
1885 | + } |
|
1800 | 1886 | |
1801 | 1887 | $cache_t = microtime(); |
1802 | 1888 | } |
@@ -1828,8 +1914,9 @@ discard block |
||
1828 | 1914 | $disabled['flash'] = true; |
1829 | 1915 | |
1830 | 1916 | // @todo Change maybe? |
1831 | - if (!isset($_GET['images'])) |
|
1832 | - $disabled['img'] = true; |
|
1917 | + if (!isset($_GET['images'])) { |
|
1918 | + $disabled['img'] = true; |
|
1919 | + } |
|
1833 | 1920 | |
1834 | 1921 | // @todo Interface/setting to add more? |
1835 | 1922 | } |
@@ -1853,8 +1940,9 @@ discard block |
||
1853 | 1940 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
1854 | 1941 | |
1855 | 1942 | // Failsafe. |
1856 | - if ($pos === false || $last_pos > $pos) |
|
1857 | - $pos = strlen($message) + 1; |
|
1943 | + if ($pos === false || $last_pos > $pos) { |
|
1944 | + $pos = strlen($message) + 1; |
|
1945 | + } |
|
1858 | 1946 | |
1859 | 1947 | // Can't have a one letter smiley, URL, or email! (sorry.) |
1860 | 1948 | if ($last_pos < $pos - 1) |
@@ -1873,8 +1961,9 @@ discard block |
||
1873 | 1961 | |
1874 | 1962 | // <br> should be empty. |
1875 | 1963 | $empty_tags = array('br', 'hr'); |
1876 | - foreach ($empty_tags as $tag) |
|
1877 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
1964 | + foreach ($empty_tags as $tag) { |
|
1965 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
1966 | + } |
|
1878 | 1967 | |
1879 | 1968 | // b, u, i, s, pre... basic tags. |
1880 | 1969 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote'); |
@@ -1883,8 +1972,9 @@ discard block |
||
1883 | 1972 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
1884 | 1973 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
1885 | 1974 | |
1886 | - if ($diff > 0) |
|
1887 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
1975 | + if ($diff > 0) { |
|
1976 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
1977 | + } |
|
1888 | 1978 | } |
1889 | 1979 | |
1890 | 1980 | // Do <img ...> - with security... action= -> action-. |
@@ -1897,8 +1987,9 @@ discard block |
||
1897 | 1987 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
1898 | 1988 | |
1899 | 1989 | // Remove action= from the URL - no funny business, now. |
1900 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
1901 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
1990 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
1991 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
1992 | + } |
|
1902 | 1993 | |
1903 | 1994 | // Check if the image is larger than allowed. |
1904 | 1995 | if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height'])) |
@@ -1919,9 +2010,9 @@ discard block |
||
1919 | 2010 | |
1920 | 2011 | // Set the new image tag. |
1921 | 2012 | $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; |
2013 | + } else { |
|
2014 | + $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
1922 | 2015 | } |
1923 | - else |
|
1924 | - $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
1925 | 2016 | } |
1926 | 2017 | |
1927 | 2018 | $data = strtr($data, $replaces); |
@@ -1934,16 +2025,18 @@ discard block |
||
1934 | 2025 | $no_autolink_area = false; |
1935 | 2026 | if (!empty($open_tags)) |
1936 | 2027 | { |
1937 | - foreach ($open_tags as $open_tag) |
|
1938 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
2028 | + foreach ($open_tags as $open_tag) { |
|
2029 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
1939 | 2030 | $no_autolink_area = true; |
2031 | + } |
|
1940 | 2032 | } |
1941 | 2033 | |
1942 | 2034 | // Don't go backwards. |
1943 | 2035 | // @todo Don't think is the real solution.... |
1944 | 2036 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
1945 | - if ($pos < $lastAutoPos) |
|
1946 | - $no_autolink_area = true; |
|
2037 | + if ($pos < $lastAutoPos) { |
|
2038 | + $no_autolink_area = true; |
|
2039 | + } |
|
1947 | 2040 | $lastAutoPos = $pos; |
1948 | 2041 | |
1949 | 2042 | if (!$no_autolink_area) |
@@ -2052,17 +2145,19 @@ discard block |
||
2052 | 2145 | if ($scheme == 'mailto') |
2053 | 2146 | { |
2054 | 2147 | $email_address = str_replace('mailto:', '', $url); |
2055 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
2056 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2057 | - else |
|
2058 | - return $url; |
|
2148 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
2149 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2150 | + } else { |
|
2151 | + return $url; |
|
2152 | + } |
|
2059 | 2153 | } |
2060 | 2154 | |
2061 | 2155 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
2062 | - if (empty($scheme)) |
|
2063 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
2064 | - else |
|
2065 | - $fullUrl = $url; |
|
2156 | + if (empty($scheme)) { |
|
2157 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
2158 | + } else { |
|
2159 | + $fullUrl = $url; |
|
2160 | + } |
|
2066 | 2161 | |
2067 | 2162 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
2068 | 2163 | }, $data); |
@@ -2111,16 +2206,18 @@ discard block |
||
2111 | 2206 | } |
2112 | 2207 | |
2113 | 2208 | // Are we there yet? Are we there yet? |
2114 | - if ($pos >= strlen($message) - 1) |
|
2115 | - break; |
|
2209 | + if ($pos >= strlen($message) - 1) { |
|
2210 | + break; |
|
2211 | + } |
|
2116 | 2212 | |
2117 | 2213 | $tags = strtolower($message[$pos + 1]); |
2118 | 2214 | |
2119 | 2215 | if ($tags == '/' && !empty($open_tags)) |
2120 | 2216 | { |
2121 | 2217 | $pos2 = strpos($message, ']', $pos + 1); |
2122 | - if ($pos2 == $pos + 2) |
|
2123 | - continue; |
|
2218 | + if ($pos2 == $pos + 2) { |
|
2219 | + continue; |
|
2220 | + } |
|
2124 | 2221 | |
2125 | 2222 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2126 | 2223 | |
@@ -2130,8 +2227,9 @@ discard block |
||
2130 | 2227 | do |
2131 | 2228 | { |
2132 | 2229 | $tag = array_pop($open_tags); |
2133 | - if (!$tag) |
|
2134 | - break; |
|
2230 | + if (!$tag) { |
|
2231 | + break; |
|
2232 | + } |
|
2135 | 2233 | |
2136 | 2234 | if (!empty($tag['block_level'])) |
2137 | 2235 | { |
@@ -2145,10 +2243,11 @@ discard block |
||
2145 | 2243 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
2146 | 2244 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
2147 | 2245 | { |
2148 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2149 | - if ($temp['tag'] == $look_for) |
|
2246 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2247 | + if ($temp['tag'] == $look_for) |
|
2150 | 2248 | { |
2151 | 2249 | $block_level = !empty($temp['block_level']); |
2250 | + } |
|
2152 | 2251 | break; |
2153 | 2252 | } |
2154 | 2253 | } |
@@ -2170,15 +2269,15 @@ discard block |
||
2170 | 2269 | { |
2171 | 2270 | $open_tags = $to_close; |
2172 | 2271 | continue; |
2173 | - } |
|
2174 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2272 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2175 | 2273 | { |
2176 | 2274 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
2177 | 2275 | { |
2178 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2179 | - if ($temp['tag'] == $look_for) |
|
2276 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2277 | + if ($temp['tag'] == $look_for) |
|
2180 | 2278 | { |
2181 | 2279 | $block_level = !empty($temp['block_level']); |
2280 | + } |
|
2182 | 2281 | break; |
2183 | 2282 | } |
2184 | 2283 | } |
@@ -2186,8 +2285,9 @@ discard block |
||
2186 | 2285 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
2187 | 2286 | if (!$block_level) |
2188 | 2287 | { |
2189 | - foreach ($to_close as $tag) |
|
2190 | - array_push($open_tags, $tag); |
|
2288 | + foreach ($to_close as $tag) { |
|
2289 | + array_push($open_tags, $tag); |
|
2290 | + } |
|
2191 | 2291 | continue; |
2192 | 2292 | } |
2193 | 2293 | } |
@@ -2200,14 +2300,17 @@ discard block |
||
2200 | 2300 | |
2201 | 2301 | // See the comment at the end of the big loop - just eating whitespace ;). |
2202 | 2302 | $whitespace_regex = ''; |
2203 | - if (!empty($tag['block_level'])) |
|
2204 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2303 | + if (!empty($tag['block_level'])) { |
|
2304 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2305 | + } |
|
2205 | 2306 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
2206 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2207 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2307 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2308 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2309 | + } |
|
2208 | 2310 | |
2209 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2210 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2311 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2312 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2313 | + } |
|
2211 | 2314 | } |
2212 | 2315 | |
2213 | 2316 | if (!empty($to_close)) |
@@ -2220,8 +2323,9 @@ discard block |
||
2220 | 2323 | } |
2221 | 2324 | |
2222 | 2325 | // No tags for this character, so just keep going (fastest possible course.) |
2223 | - if (!isset($bbc_codes[$tags])) |
|
2224 | - continue; |
|
2326 | + if (!isset($bbc_codes[$tags])) { |
|
2327 | + continue; |
|
2328 | + } |
|
2225 | 2329 | |
2226 | 2330 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
2227 | 2331 | $tag = null; |
@@ -2230,44 +2334,52 @@ discard block |
||
2230 | 2334 | $pt_strlen = strlen($possible['tag']); |
2231 | 2335 | |
2232 | 2336 | // Not a match? |
2233 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
2234 | - continue; |
|
2337 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
2338 | + continue; |
|
2339 | + } |
|
2235 | 2340 | |
2236 | 2341 | $next_c = $message[$pos + 1 + $pt_strlen]; |
2237 | 2342 | |
2238 | 2343 | // A test validation? |
2239 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
2240 | - continue; |
|
2344 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
2345 | + continue; |
|
2346 | + } |
|
2241 | 2347 | // Do we want parameters? |
2242 | 2348 | elseif (!empty($possible['parameters'])) |
2243 | 2349 | { |
2244 | - if ($next_c != ' ') |
|
2245 | - continue; |
|
2246 | - } |
|
2247 | - elseif (isset($possible['type'])) |
|
2350 | + if ($next_c != ' ') { |
|
2351 | + continue; |
|
2352 | + } |
|
2353 | + } elseif (isset($possible['type'])) |
|
2248 | 2354 | { |
2249 | 2355 | // Do we need an equal sign? |
2250 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
2251 | - continue; |
|
2356 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
2357 | + continue; |
|
2358 | + } |
|
2252 | 2359 | // Maybe we just want a /... |
2253 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
2254 | - continue; |
|
2360 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
2361 | + continue; |
|
2362 | + } |
|
2255 | 2363 | // An immediate ]? |
2256 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
2257 | - continue; |
|
2364 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
2365 | + continue; |
|
2366 | + } |
|
2258 | 2367 | } |
2259 | 2368 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
2260 | - elseif ($next_c != ']') |
|
2261 | - continue; |
|
2369 | + elseif ($next_c != ']') { |
|
2370 | + continue; |
|
2371 | + } |
|
2262 | 2372 | |
2263 | 2373 | // Check allowed tree? |
2264 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
2265 | - continue; |
|
2266 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
2267 | - continue; |
|
2374 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
2375 | + continue; |
|
2376 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
2377 | + continue; |
|
2378 | + } |
|
2268 | 2379 | // If this is in the list of disallowed child tags, don't parse it. |
2269 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
2270 | - continue; |
|
2380 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
2381 | + continue; |
|
2382 | + } |
|
2271 | 2383 | |
2272 | 2384 | $pos1 = $pos + 1 + $pt_strlen + 1; |
2273 | 2385 | |
@@ -2279,8 +2391,9 @@ discard block |
||
2279 | 2391 | foreach ($open_tags as $open_quote) |
2280 | 2392 | { |
2281 | 2393 | // Every parent quote this quote has flips the styling |
2282 | - if ($open_quote['tag'] == 'quote') |
|
2283 | - $quote_alt = !$quote_alt; |
|
2394 | + if ($open_quote['tag'] == 'quote') { |
|
2395 | + $quote_alt = !$quote_alt; |
|
2396 | + } |
|
2284 | 2397 | } |
2285 | 2398 | // Add a class to the quote to style alternating blockquotes |
2286 | 2399 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2291,8 +2404,9 @@ discard block |
||
2291 | 2404 | { |
2292 | 2405 | // Build a regular expression for each parameter for the current tag. |
2293 | 2406 | $preg = array(); |
2294 | - foreach ($possible['parameters'] as $p => $info) |
|
2295 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2407 | + foreach ($possible['parameters'] as $p => $info) { |
|
2408 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2409 | + } |
|
2296 | 2410 | |
2297 | 2411 | // Extract the string that potentially holds our parameters. |
2298 | 2412 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2312,24 +2426,27 @@ discard block |
||
2312 | 2426 | |
2313 | 2427 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
2314 | 2428 | |
2315 | - if ($match) |
|
2316 | - $blob_counter = count($blobs) + 1; |
|
2429 | + if ($match) { |
|
2430 | + $blob_counter = count($blobs) + 1; |
|
2431 | + } |
|
2317 | 2432 | } |
2318 | 2433 | |
2319 | 2434 | // Didn't match our parameter list, try the next possible. |
2320 | - if (!$match) |
|
2321 | - continue; |
|
2435 | + if (!$match) { |
|
2436 | + continue; |
|
2437 | + } |
|
2322 | 2438 | |
2323 | 2439 | $params = array(); |
2324 | 2440 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
2325 | 2441 | { |
2326 | 2442 | $key = strtok(ltrim($matches[$i]), '='); |
2327 | - if (isset($possible['parameters'][$key]['value'])) |
|
2328 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2329 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
2330 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2331 | - else |
|
2332 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2443 | + if (isset($possible['parameters'][$key]['value'])) { |
|
2444 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2445 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
2446 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2447 | + } else { |
|
2448 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2449 | + } |
|
2333 | 2450 | |
2334 | 2451 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
2335 | 2452 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2337,23 +2454,26 @@ discard block |
||
2337 | 2454 | |
2338 | 2455 | foreach ($possible['parameters'] as $p => $info) |
2339 | 2456 | { |
2340 | - if (!isset($params['{' . $p . '}'])) |
|
2341 | - $params['{' . $p . '}'] = ''; |
|
2457 | + if (!isset($params['{' . $p . '}'])) { |
|
2458 | + $params['{' . $p . '}'] = ''; |
|
2459 | + } |
|
2342 | 2460 | } |
2343 | 2461 | |
2344 | 2462 | $tag = $possible; |
2345 | 2463 | |
2346 | 2464 | // Put the parameters into the string. |
2347 | - if (isset($tag['before'])) |
|
2348 | - $tag['before'] = strtr($tag['before'], $params); |
|
2349 | - if (isset($tag['after'])) |
|
2350 | - $tag['after'] = strtr($tag['after'], $params); |
|
2351 | - if (isset($tag['content'])) |
|
2352 | - $tag['content'] = strtr($tag['content'], $params); |
|
2465 | + if (isset($tag['before'])) { |
|
2466 | + $tag['before'] = strtr($tag['before'], $params); |
|
2467 | + } |
|
2468 | + if (isset($tag['after'])) { |
|
2469 | + $tag['after'] = strtr($tag['after'], $params); |
|
2470 | + } |
|
2471 | + if (isset($tag['content'])) { |
|
2472 | + $tag['content'] = strtr($tag['content'], $params); |
|
2473 | + } |
|
2353 | 2474 | |
2354 | 2475 | $pos1 += strlen($given_param_string); |
2355 | - } |
|
2356 | - else |
|
2476 | + } else |
|
2357 | 2477 | { |
2358 | 2478 | $tag = $possible; |
2359 | 2479 | $params = array(); |
@@ -2364,8 +2484,9 @@ discard block |
||
2364 | 2484 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
2365 | 2485 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
2366 | 2486 | { |
2367 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
2368 | - continue; |
|
2487 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
2488 | + continue; |
|
2489 | + } |
|
2369 | 2490 | |
2370 | 2491 | $tag = $itemcodes[$message[$pos + 1]]; |
2371 | 2492 | |
@@ -2386,9 +2507,9 @@ discard block |
||
2386 | 2507 | { |
2387 | 2508 | array_pop($open_tags); |
2388 | 2509 | $code = '</li>'; |
2510 | + } else { |
|
2511 | + $code = ''; |
|
2389 | 2512 | } |
2390 | - else |
|
2391 | - $code = ''; |
|
2392 | 2513 | |
2393 | 2514 | // Now we open a new tag. |
2394 | 2515 | $open_tags[] = array( |
@@ -2435,12 +2556,14 @@ discard block |
||
2435 | 2556 | } |
2436 | 2557 | |
2437 | 2558 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
2438 | - if ($tag === null) |
|
2439 | - continue; |
|
2559 | + if ($tag === null) { |
|
2560 | + continue; |
|
2561 | + } |
|
2440 | 2562 | |
2441 | 2563 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
2442 | - if (isset($inside['disallow_children'])) |
|
2443 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2564 | + if (isset($inside['disallow_children'])) { |
|
2565 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2566 | + } |
|
2444 | 2567 | |
2445 | 2568 | // Is this tag disabled? |
2446 | 2569 | if (isset($disabled[$tag['tag']])) |
@@ -2450,14 +2573,13 @@ discard block |
||
2450 | 2573 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
2451 | 2574 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
2452 | 2575 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
2453 | - } |
|
2454 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2576 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2455 | 2577 | { |
2456 | 2578 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
2457 | 2579 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
2580 | + } else { |
|
2581 | + $tag['content'] = $tag['disabled_content']; |
|
2458 | 2582 | } |
2459 | - else |
|
2460 | - $tag['content'] = $tag['disabled_content']; |
|
2461 | 2583 | } |
2462 | 2584 | |
2463 | 2585 | // we use this a lot |
@@ -2467,8 +2589,9 @@ discard block |
||
2467 | 2589 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
2468 | 2590 | { |
2469 | 2591 | $n = count($open_tags) - 1; |
2470 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
2471 | - $n--; |
|
2592 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
2593 | + $n--; |
|
2594 | + } |
|
2472 | 2595 | |
2473 | 2596 | // Close all the non block level tags so this tag isn't surrounded by them. |
2474 | 2597 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2480,12 +2603,15 @@ discard block |
||
2480 | 2603 | |
2481 | 2604 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
2482 | 2605 | $whitespace_regex = ''; |
2483 | - if (!empty($tag['block_level'])) |
|
2484 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2485 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2486 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2487 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2488 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2606 | + if (!empty($tag['block_level'])) { |
|
2607 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2608 | + } |
|
2609 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2610 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2611 | + } |
|
2612 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2613 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2614 | + } |
|
2489 | 2615 | |
2490 | 2616 | array_pop($open_tags); |
2491 | 2617 | } |
@@ -2503,16 +2629,19 @@ discard block |
||
2503 | 2629 | elseif ($tag['type'] == 'unparsed_content') |
2504 | 2630 | { |
2505 | 2631 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
2506 | - if ($pos2 === false) |
|
2507 | - continue; |
|
2632 | + if ($pos2 === false) { |
|
2633 | + continue; |
|
2634 | + } |
|
2508 | 2635 | |
2509 | 2636 | $data = substr($message, $pos1, $pos2 - $pos1); |
2510 | 2637 | |
2511 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
2512 | - $data = substr($data, 4); |
|
2638 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
2639 | + $data = substr($data, 4); |
|
2640 | + } |
|
2513 | 2641 | |
2514 | - if (isset($tag['validate'])) |
|
2515 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2642 | + if (isset($tag['validate'])) { |
|
2643 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2644 | + } |
|
2516 | 2645 | |
2517 | 2646 | $code = strtr($tag['content'], array('$1' => $data)); |
2518 | 2647 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2528,34 +2657,40 @@ discard block |
||
2528 | 2657 | if (isset($tag['quoted'])) |
2529 | 2658 | { |
2530 | 2659 | $quoted = substr($message, $pos1, 6) == '"'; |
2531 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2532 | - continue; |
|
2660 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2661 | + continue; |
|
2662 | + } |
|
2533 | 2663 | |
2534 | - if ($quoted) |
|
2535 | - $pos1 += 6; |
|
2664 | + if ($quoted) { |
|
2665 | + $pos1 += 6; |
|
2666 | + } |
|
2667 | + } else { |
|
2668 | + $quoted = false; |
|
2536 | 2669 | } |
2537 | - else |
|
2538 | - $quoted = false; |
|
2539 | 2670 | |
2540 | 2671 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2541 | - if ($pos2 === false) |
|
2542 | - continue; |
|
2672 | + if ($pos2 === false) { |
|
2673 | + continue; |
|
2674 | + } |
|
2543 | 2675 | |
2544 | 2676 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2545 | - if ($pos3 === false) |
|
2546 | - continue; |
|
2677 | + if ($pos3 === false) { |
|
2678 | + continue; |
|
2679 | + } |
|
2547 | 2680 | |
2548 | 2681 | $data = array( |
2549 | 2682 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
2550 | 2683 | substr($message, $pos1, $pos2 - $pos1) |
2551 | 2684 | ); |
2552 | 2685 | |
2553 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
2554 | - $data[0] = substr($data[0], 4); |
|
2686 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
2687 | + $data[0] = substr($data[0], 4); |
|
2688 | + } |
|
2555 | 2689 | |
2556 | 2690 | // Validation for my parking, please! |
2557 | - if (isset($tag['validate'])) |
|
2558 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2691 | + if (isset($tag['validate'])) { |
|
2692 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2693 | + } |
|
2559 | 2694 | |
2560 | 2695 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
2561 | 2696 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2572,23 +2707,27 @@ discard block |
||
2572 | 2707 | elseif ($tag['type'] == 'unparsed_commas_content') |
2573 | 2708 | { |
2574 | 2709 | $pos2 = strpos($message, ']', $pos1); |
2575 | - if ($pos2 === false) |
|
2576 | - continue; |
|
2710 | + if ($pos2 === false) { |
|
2711 | + continue; |
|
2712 | + } |
|
2577 | 2713 | |
2578 | 2714 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2579 | - if ($pos3 === false) |
|
2580 | - continue; |
|
2715 | + if ($pos3 === false) { |
|
2716 | + continue; |
|
2717 | + } |
|
2581 | 2718 | |
2582 | 2719 | // We want $1 to be the content, and the rest to be csv. |
2583 | 2720 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
2584 | 2721 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
2585 | 2722 | |
2586 | - if (isset($tag['validate'])) |
|
2587 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2723 | + if (isset($tag['validate'])) { |
|
2724 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2725 | + } |
|
2588 | 2726 | |
2589 | 2727 | $code = $tag['content']; |
2590 | - foreach ($data as $k => $d) |
|
2591 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2728 | + foreach ($data as $k => $d) { |
|
2729 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2730 | + } |
|
2592 | 2731 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
2593 | 2732 | $pos += strlen($code) - 1 + 2; |
2594 | 2733 | } |
@@ -2596,24 +2735,28 @@ discard block |
||
2596 | 2735 | elseif ($tag['type'] == 'unparsed_commas') |
2597 | 2736 | { |
2598 | 2737 | $pos2 = strpos($message, ']', $pos1); |
2599 | - if ($pos2 === false) |
|
2600 | - continue; |
|
2738 | + if ($pos2 === false) { |
|
2739 | + continue; |
|
2740 | + } |
|
2601 | 2741 | |
2602 | 2742 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
2603 | 2743 | |
2604 | - if (isset($tag['validate'])) |
|
2605 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2744 | + if (isset($tag['validate'])) { |
|
2745 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2746 | + } |
|
2606 | 2747 | |
2607 | 2748 | // Fix after, for disabled code mainly. |
2608 | - foreach ($data as $k => $d) |
|
2609 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2749 | + foreach ($data as $k => $d) { |
|
2750 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2751 | + } |
|
2610 | 2752 | |
2611 | 2753 | $open_tags[] = $tag; |
2612 | 2754 | |
2613 | 2755 | // Replace them out, $1, $2, $3, $4, etc. |
2614 | 2756 | $code = $tag['before']; |
2615 | - foreach ($data as $k => $d) |
|
2616 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2757 | + foreach ($data as $k => $d) { |
|
2758 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2759 | + } |
|
2617 | 2760 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
2618 | 2761 | $pos += strlen($code) - 1 + 2; |
2619 | 2762 | } |
@@ -2624,28 +2767,33 @@ discard block |
||
2624 | 2767 | if (isset($tag['quoted'])) |
2625 | 2768 | { |
2626 | 2769 | $quoted = substr($message, $pos1, 6) == '"'; |
2627 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2628 | - continue; |
|
2770 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2771 | + continue; |
|
2772 | + } |
|
2629 | 2773 | |
2630 | - if ($quoted) |
|
2631 | - $pos1 += 6; |
|
2774 | + if ($quoted) { |
|
2775 | + $pos1 += 6; |
|
2776 | + } |
|
2777 | + } else { |
|
2778 | + $quoted = false; |
|
2632 | 2779 | } |
2633 | - else |
|
2634 | - $quoted = false; |
|
2635 | 2780 | |
2636 | 2781 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2637 | - if ($pos2 === false) |
|
2638 | - continue; |
|
2782 | + if ($pos2 === false) { |
|
2783 | + continue; |
|
2784 | + } |
|
2639 | 2785 | |
2640 | 2786 | $data = substr($message, $pos1, $pos2 - $pos1); |
2641 | 2787 | |
2642 | 2788 | // Validation for my parking, please! |
2643 | - if (isset($tag['validate'])) |
|
2644 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2789 | + if (isset($tag['validate'])) { |
|
2790 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2791 | + } |
|
2645 | 2792 | |
2646 | 2793 | // For parsed content, we must recurse to avoid security problems. |
2647 | - if ($tag['type'] != 'unparsed_equals') |
|
2648 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2794 | + if ($tag['type'] != 'unparsed_equals') { |
|
2795 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2796 | + } |
|
2649 | 2797 | |
2650 | 2798 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
2651 | 2799 | |
@@ -2657,34 +2805,40 @@ discard block |
||
2657 | 2805 | } |
2658 | 2806 | |
2659 | 2807 | // If this is block level, eat any breaks after it. |
2660 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
2661 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2808 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
2809 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2810 | + } |
|
2662 | 2811 | |
2663 | 2812 | // Are we trimming outside this tag? |
2664 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
2665 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2813 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
2814 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2815 | + } |
|
2666 | 2816 | } |
2667 | 2817 | |
2668 | 2818 | // Close any remaining tags. |
2669 | - while ($tag = array_pop($open_tags)) |
|
2670 | - $message .= "\n" . $tag['after'] . "\n"; |
|
2819 | + while ($tag = array_pop($open_tags)) { |
|
2820 | + $message .= "\n" . $tag['after'] . "\n"; |
|
2821 | + } |
|
2671 | 2822 | |
2672 | 2823 | // Parse the smileys within the parts where it can be done safely. |
2673 | 2824 | if ($smileys === true) |
2674 | 2825 | { |
2675 | 2826 | $message_parts = explode("\n", $message); |
2676 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
2677 | - parsesmileys($message_parts[$i]); |
|
2827 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
2828 | + parsesmileys($message_parts[$i]); |
|
2829 | + } |
|
2678 | 2830 | |
2679 | 2831 | $message = implode('', $message_parts); |
2680 | 2832 | } |
2681 | 2833 | |
2682 | 2834 | // No smileys, just get rid of the markers. |
2683 | - else |
|
2684 | - $message = strtr($message, array("\n" => '')); |
|
2835 | + else { |
|
2836 | + $message = strtr($message, array("\n" => '')); |
|
2837 | + } |
|
2685 | 2838 | |
2686 | - if ($message !== '' && $message[0] === ' ') |
|
2687 | - $message = ' ' . substr($message, 1); |
|
2839 | + if ($message !== '' && $message[0] === ' ') { |
|
2840 | + $message = ' ' . substr($message, 1); |
|
2841 | + } |
|
2688 | 2842 | |
2689 | 2843 | // Cleanup whitespace. |
2690 | 2844 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2693,15 +2847,16 @@ discard block |
||
2693 | 2847 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
2694 | 2848 | |
2695 | 2849 | // Cache the output if it took some time... |
2696 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
2697 | - cache_put_data($cache_key, $message, 240); |
|
2850 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
2851 | + cache_put_data($cache_key, $message, 240); |
|
2852 | + } |
|
2698 | 2853 | |
2699 | 2854 | // If this was a force parse revert if needed. |
2700 | 2855 | if (!empty($parse_tags)) |
2701 | 2856 | { |
2702 | - if (empty($temp_bbc)) |
|
2703 | - $bbc_codes = array(); |
|
2704 | - else |
|
2857 | + if (empty($temp_bbc)) { |
|
2858 | + $bbc_codes = array(); |
|
2859 | + } else |
|
2705 | 2860 | { |
2706 | 2861 | $bbc_codes = $temp_bbc; |
2707 | 2862 | unset($temp_bbc); |
@@ -2728,8 +2883,9 @@ discard block |
||
2728 | 2883 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
2729 | 2884 | |
2730 | 2885 | // No smiley set at all?! |
2731 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
2732 | - return; |
|
2886 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
2887 | + return; |
|
2888 | + } |
|
2733 | 2889 | |
2734 | 2890 | // If smileyPregSearch hasn't been set, do it now. |
2735 | 2891 | if (empty($smileyPregSearch)) |
@@ -2740,8 +2896,7 @@ discard block |
||
2740 | 2896 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
2741 | 2897 | $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif'); |
2742 | 2898 | $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', ''); |
2743 | - } |
|
2744 | - else |
|
2899 | + } else |
|
2745 | 2900 | { |
2746 | 2901 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
2747 | 2902 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2765,9 +2920,9 @@ discard block |
||
2765 | 2920 | $smcFunc['db_free_result']($result); |
2766 | 2921 | |
2767 | 2922 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
2923 | + } else { |
|
2924 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2768 | 2925 | } |
2769 | - else |
|
2770 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2771 | 2926 | } |
2772 | 2927 | |
2773 | 2928 | // The non-breaking-space is a complex thing... |
@@ -2844,35 +2999,41 @@ discard block |
||
2844 | 2999 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
2845 | 3000 | |
2846 | 3001 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
2847 | - if (!empty($context['flush_mail'])) |
|
2848 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3002 | + if (!empty($context['flush_mail'])) { |
|
3003 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2849 | 3004 | AddMailQueue(true); |
3005 | + } |
|
2850 | 3006 | |
2851 | 3007 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
2852 | 3008 | |
2853 | - if ($add) |
|
2854 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3009 | + if ($add) { |
|
3010 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3011 | + } |
|
2855 | 3012 | |
2856 | 3013 | // Put the session ID in. |
2857 | - if (defined('SID') && SID != '') |
|
2858 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3014 | + if (defined('SID') && SID != '') { |
|
3015 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3016 | + } |
|
2859 | 3017 | // Keep that debug in their for template debugging! |
2860 | - elseif (isset($_GET['debug'])) |
|
2861 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3018 | + elseif (isset($_GET['debug'])) { |
|
3019 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3020 | + } |
|
2862 | 3021 | |
2863 | 3022 | if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed']))) |
2864 | 3023 | { |
2865 | - if (defined('SID') && SID != '') |
|
2866 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
3024 | + if (defined('SID') && SID != '') { |
|
3025 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
2867 | 3026 | function ($m) use ($scripturl) |
2868 | 3027 | { |
2869 | 3028 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
3029 | + } |
|
2870 | 3030 | }, $setLocation); |
2871 | - else |
|
2872 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
3031 | + else { |
|
3032 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
2873 | 3033 | function ($m) use ($scripturl) |
2874 | 3034 | { |
2875 | 3035 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
3036 | + } |
|
2876 | 3037 | }, $setLocation); |
2877 | 3038 | } |
2878 | 3039 | |
@@ -2883,8 +3044,9 @@ discard block |
||
2883 | 3044 | header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
2884 | 3045 | |
2885 | 3046 | // Debugging. |
2886 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
2887 | - $_SESSION['debug_redirect'] = $db_cache; |
|
3047 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3048 | + $_SESSION['debug_redirect'] = $db_cache; |
|
3049 | + } |
|
2888 | 3050 | |
2889 | 3051 | obExit(false); |
2890 | 3052 | } |
@@ -2903,51 +3065,60 @@ discard block |
||
2903 | 3065 | |
2904 | 3066 | // Attempt to prevent a recursive loop. |
2905 | 3067 | ++$level; |
2906 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
2907 | - exit; |
|
2908 | - if ($from_fatal_error) |
|
2909 | - $has_fatal_error = true; |
|
3068 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
3069 | + exit; |
|
3070 | + } |
|
3071 | + if ($from_fatal_error) { |
|
3072 | + $has_fatal_error = true; |
|
3073 | + } |
|
2910 | 3074 | |
2911 | 3075 | // Clear out the stat cache. |
2912 | 3076 | trackStats(); |
2913 | 3077 | |
2914 | 3078 | // If we have mail to send, send it. |
2915 | - if (!empty($context['flush_mail'])) |
|
2916 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3079 | + if (!empty($context['flush_mail'])) { |
|
3080 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2917 | 3081 | AddMailQueue(true); |
3082 | + } |
|
2918 | 3083 | |
2919 | 3084 | $do_header = $header === null ? !$header_done : $header; |
2920 | - if ($do_footer === null) |
|
2921 | - $do_footer = $do_header; |
|
3085 | + if ($do_footer === null) { |
|
3086 | + $do_footer = $do_header; |
|
3087 | + } |
|
2922 | 3088 | |
2923 | 3089 | // Has the template/header been done yet? |
2924 | 3090 | if ($do_header) |
2925 | 3091 | { |
2926 | 3092 | // Was the page title set last minute? Also update the HTML safe one. |
2927 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
2928 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3093 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
3094 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3095 | + } |
|
2929 | 3096 | |
2930 | 3097 | // Start up the session URL fixer. |
2931 | 3098 | ob_start('ob_sessrewrite'); |
2932 | 3099 | |
2933 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
2934 | - $buffers = explode(',', $settings['output_buffers']); |
|
2935 | - elseif (!empty($settings['output_buffers'])) |
|
2936 | - $buffers = $settings['output_buffers']; |
|
2937 | - else |
|
2938 | - $buffers = array(); |
|
3100 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
3101 | + $buffers = explode(',', $settings['output_buffers']); |
|
3102 | + } elseif (!empty($settings['output_buffers'])) { |
|
3103 | + $buffers = $settings['output_buffers']; |
|
3104 | + } else { |
|
3105 | + $buffers = array(); |
|
3106 | + } |
|
2939 | 3107 | |
2940 | - if (isset($modSettings['integrate_buffer'])) |
|
2941 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3108 | + if (isset($modSettings['integrate_buffer'])) { |
|
3109 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3110 | + } |
|
2942 | 3111 | |
2943 | - if (!empty($buffers)) |
|
2944 | - foreach ($buffers as $function) |
|
3112 | + if (!empty($buffers)) { |
|
3113 | + foreach ($buffers as $function) |
|
2945 | 3114 | { |
2946 | 3115 | $call = call_helper($function, true); |
3116 | + } |
|
2947 | 3117 | |
2948 | 3118 | // Is it valid? |
2949 | - if (!empty($call)) |
|
2950 | - ob_start($call); |
|
3119 | + if (!empty($call)) { |
|
3120 | + ob_start($call); |
|
3121 | + } |
|
2951 | 3122 | } |
2952 | 3123 | |
2953 | 3124 | // Display the screen in the logical order. |
@@ -2959,8 +3130,9 @@ discard block |
||
2959 | 3130 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
2960 | 3131 | |
2961 | 3132 | // Anything special to put out? |
2962 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
2963 | - echo $context['insert_after_template']; |
|
3133 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
3134 | + echo $context['insert_after_template']; |
|
3135 | + } |
|
2964 | 3136 | |
2965 | 3137 | // Just so we don't get caught in an endless loop of errors from the footer... |
2966 | 3138 | if (!$footer_done) |
@@ -2969,14 +3141,16 @@ discard block |
||
2969 | 3141 | template_footer(); |
2970 | 3142 | |
2971 | 3143 | // (since this is just debugging... it's okay that it's after </html>.) |
2972 | - if (!isset($_REQUEST['xml'])) |
|
2973 | - displayDebug(); |
|
3144 | + if (!isset($_REQUEST['xml'])) { |
|
3145 | + displayDebug(); |
|
3146 | + } |
|
2974 | 3147 | } |
2975 | 3148 | } |
2976 | 3149 | |
2977 | 3150 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
2978 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
2979 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3151 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
3152 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3153 | + } |
|
2980 | 3154 | |
2981 | 3155 | // For session check verification.... don't switch browsers... |
2982 | 3156 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -2985,9 +3159,10 @@ discard block |
||
2985 | 3159 | call_integration_hook('integrate_exit', array($do_footer)); |
2986 | 3160 | |
2987 | 3161 | // Don't exit if we're coming from index.php; that will pass through normally. |
2988 | - if (!$from_index) |
|
2989 | - exit; |
|
2990 | -} |
|
3162 | + if (!$from_index) { |
|
3163 | + exit; |
|
3164 | + } |
|
3165 | + } |
|
2991 | 3166 | |
2992 | 3167 | /** |
2993 | 3168 | * Get the size of a specified image with better error handling. |
@@ -3006,8 +3181,9 @@ discard block |
||
3006 | 3181 | $url = str_replace(' ', '%20', $url); |
3007 | 3182 | |
3008 | 3183 | // Can we pull this from the cache... please please? |
3009 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
3010 | - return $temp; |
|
3184 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
3185 | + return $temp; |
|
3186 | + } |
|
3011 | 3187 | $t = microtime(); |
3012 | 3188 | |
3013 | 3189 | // Get the host to pester... |
@@ -3017,12 +3193,10 @@ discard block |
||
3017 | 3193 | if ($url == '' || $url == 'http://' || $url == 'https://') |
3018 | 3194 | { |
3019 | 3195 | return false; |
3020 | - } |
|
3021 | - elseif (!isset($match[1])) |
|
3196 | + } elseif (!isset($match[1])) |
|
3022 | 3197 | { |
3023 | 3198 | $size = @getimagesize($url); |
3024 | - } |
|
3025 | - else |
|
3199 | + } else |
|
3026 | 3200 | { |
3027 | 3201 | // Try to connect to the server... give it half a second. |
3028 | 3202 | $temp = 0; |
@@ -3061,12 +3235,14 @@ discard block |
||
3061 | 3235 | } |
3062 | 3236 | |
3063 | 3237 | // If we didn't get it, we failed. |
3064 | - if (!isset($size)) |
|
3065 | - $size = false; |
|
3238 | + if (!isset($size)) { |
|
3239 | + $size = false; |
|
3240 | + } |
|
3066 | 3241 | |
3067 | 3242 | // If this took a long time, we may never have to do it again, but then again we might... |
3068 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
3069 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3243 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
3244 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3245 | + } |
|
3070 | 3246 | |
3071 | 3247 | // Didn't work. |
3072 | 3248 | return $size; |
@@ -3084,8 +3260,9 @@ discard block |
||
3084 | 3260 | |
3085 | 3261 | // Under SSI this function can be called more then once. That can cause some problems. |
3086 | 3262 | // So only run the function once unless we are forced to run it again. |
3087 | - if ($loaded && !$forceload) |
|
3088 | - return; |
|
3263 | + if ($loaded && !$forceload) { |
|
3264 | + return; |
|
3265 | + } |
|
3089 | 3266 | |
3090 | 3267 | $loaded = true; |
3091 | 3268 | |
@@ -3097,14 +3274,16 @@ discard block |
||
3097 | 3274 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
3098 | 3275 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
3099 | 3276 | { |
3100 | - if (trim($context['news_lines'][$i]) == '') |
|
3101 | - continue; |
|
3277 | + if (trim($context['news_lines'][$i]) == '') { |
|
3278 | + continue; |
|
3279 | + } |
|
3102 | 3280 | |
3103 | 3281 | // Clean it up for presentation ;). |
3104 | 3282 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
3105 | 3283 | } |
3106 | - if (!empty($context['news_lines'])) |
|
3107 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3284 | + if (!empty($context['news_lines'])) { |
|
3285 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3286 | + } |
|
3108 | 3287 | |
3109 | 3288 | if (!$user_info['is_guest']) |
3110 | 3289 | { |
@@ -3113,40 +3292,48 @@ discard block |
||
3113 | 3292 | $context['user']['alerts'] = &$user_info['alerts']; |
3114 | 3293 | |
3115 | 3294 | // Personal message popup... |
3116 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
3117 | - $context['user']['popup_messages'] = true; |
|
3118 | - else |
|
3119 | - $context['user']['popup_messages'] = false; |
|
3295 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
3296 | + $context['user']['popup_messages'] = true; |
|
3297 | + } else { |
|
3298 | + $context['user']['popup_messages'] = false; |
|
3299 | + } |
|
3120 | 3300 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
3121 | 3301 | |
3122 | - if (allowedTo('moderate_forum')) |
|
3123 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3302 | + if (allowedTo('moderate_forum')) { |
|
3303 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3304 | + } |
|
3124 | 3305 | |
3125 | 3306 | $context['user']['avatar'] = array(); |
3126 | 3307 | |
3127 | 3308 | // Check for gravatar first since we might be forcing them... |
3128 | 3309 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
3129 | 3310 | { |
3130 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
3131 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3132 | - else |
|
3133 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3311 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
3312 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3313 | + } else { |
|
3314 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3315 | + } |
|
3134 | 3316 | } |
3135 | 3317 | // Uploaded? |
3136 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
3137 | - $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
3318 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
3319 | + $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
3320 | + } |
|
3138 | 3321 | // Full URL? |
3139 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
3140 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3322 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
3323 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3324 | + } |
|
3141 | 3325 | // Otherwise we assume it's server stored. |
3142 | - elseif ($user_info['avatar']['url'] != '') |
|
3143 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3326 | + elseif ($user_info['avatar']['url'] != '') { |
|
3327 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3328 | + } |
|
3144 | 3329 | // No avatar at all? Fine, we have a big fat default avatar ;) |
3145 | - else |
|
3146 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3330 | + else { |
|
3331 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3332 | + } |
|
3147 | 3333 | |
3148 | - if (!empty($context['user']['avatar'])) |
|
3149 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3334 | + if (!empty($context['user']['avatar'])) { |
|
3335 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3336 | + } |
|
3150 | 3337 | |
3151 | 3338 | // Figure out how long they've been logged in. |
3152 | 3339 | $context['user']['total_time_logged_in'] = array( |
@@ -3154,8 +3341,7 @@ discard block |
||
3154 | 3341 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
3155 | 3342 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
3156 | 3343 | ); |
3157 | - } |
|
3158 | - else |
|
3344 | + } else |
|
3159 | 3345 | { |
3160 | 3346 | $context['user']['messages'] = 0; |
3161 | 3347 | $context['user']['unread_messages'] = 0; |
@@ -3163,12 +3349,14 @@ discard block |
||
3163 | 3349 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
3164 | 3350 | $context['user']['popup_messages'] = false; |
3165 | 3351 | |
3166 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
3167 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3352 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
3353 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3354 | + } |
|
3168 | 3355 | |
3169 | 3356 | // If we've upgraded recently, go easy on the passwords. |
3170 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
3171 | - $context['disable_login_hashing'] = true; |
|
3357 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
3358 | + $context['disable_login_hashing'] = true; |
|
3359 | + } |
|
3172 | 3360 | } |
3173 | 3361 | |
3174 | 3362 | // Setup the main menu items. |
@@ -3181,8 +3369,8 @@ discard block |
||
3181 | 3369 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
3182 | 3370 | |
3183 | 3371 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
3184 | - if ($context['show_pm_popup']) |
|
3185 | - addInlineJavaScript(' |
|
3372 | + if ($context['show_pm_popup']) { |
|
3373 | + addInlineJavaScript(' |
|
3186 | 3374 | jQuery(document).ready(function($) { |
3187 | 3375 | new smc_Popup({ |
3188 | 3376 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3190,15 +3378,17 @@ discard block |
||
3190 | 3378 | icon_class: \'generic_icons mail_new\' |
3191 | 3379 | }); |
3192 | 3380 | });'); |
3381 | + } |
|
3193 | 3382 | |
3194 | 3383 | // Add a generic "Are you sure?" confirmation message. |
3195 | 3384 | addInlineJavaScript(' |
3196 | 3385 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
3197 | 3386 | |
3198 | 3387 | // Now add the capping code for avatars. |
3199 | - if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
|
3200 | - addInlineCss(' |
|
3388 | + if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') { |
|
3389 | + addInlineCss(' |
|
3201 | 3390 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
3391 | + } |
|
3202 | 3392 | |
3203 | 3393 | // This looks weird, but it's because BoardIndex.php references the variable. |
3204 | 3394 | $context['common_stats']['latest_member'] = array( |
@@ -3215,11 +3405,13 @@ discard block |
||
3215 | 3405 | ); |
3216 | 3406 | $context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']); |
3217 | 3407 | |
3218 | - if (empty($settings['theme_version'])) |
|
3219 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
3408 | + if (empty($settings['theme_version'])) { |
|
3409 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
3410 | + } |
|
3220 | 3411 | |
3221 | - if (!isset($context['page_title'])) |
|
3222 | - $context['page_title'] = ''; |
|
3412 | + if (!isset($context['page_title'])) { |
|
3413 | + $context['page_title'] = ''; |
|
3414 | + } |
|
3223 | 3415 | |
3224 | 3416 | // Set some specific vars. |
3225 | 3417 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3229,21 +3421,23 @@ discard block |
||
3229 | 3421 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
3230 | 3422 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
3231 | 3423 | |
3232 | - if (!empty($context['meta_keywords'])) |
|
3233 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3424 | + if (!empty($context['meta_keywords'])) { |
|
3425 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3426 | + } |
|
3234 | 3427 | |
3235 | - if (!empty($context['canonical_url'])) |
|
3236 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3428 | + if (!empty($context['canonical_url'])) { |
|
3429 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3430 | + } |
|
3237 | 3431 | |
3238 | - if (!empty($settings['og_image'])) |
|
3239 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3432 | + if (!empty($settings['og_image'])) { |
|
3433 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3434 | + } |
|
3240 | 3435 | |
3241 | 3436 | if (!empty($context['meta_description'])) |
3242 | 3437 | { |
3243 | 3438 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
3244 | 3439 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
3245 | - } |
|
3246 | - else |
|
3440 | + } else |
|
3247 | 3441 | { |
3248 | 3442 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
3249 | 3443 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3268,8 +3462,9 @@ discard block |
||
3268 | 3462 | $memory_needed = memoryReturnBytes($needed); |
3269 | 3463 | |
3270 | 3464 | // should we account for how much is currently being used? |
3271 | - if ($in_use) |
|
3272 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3465 | + if ($in_use) { |
|
3466 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3467 | + } |
|
3273 | 3468 | |
3274 | 3469 | // if more is needed, request it |
3275 | 3470 | if ($memory_current < $memory_needed) |
@@ -3292,8 +3487,9 @@ discard block |
||
3292 | 3487 | */ |
3293 | 3488 | function memoryReturnBytes($val) |
3294 | 3489 | { |
3295 | - if (is_integer($val)) |
|
3296 | - return $val; |
|
3490 | + if (is_integer($val)) { |
|
3491 | + return $val; |
|
3492 | + } |
|
3297 | 3493 | |
3298 | 3494 | // Separate the number from the designator |
3299 | 3495 | $val = trim($val); |
@@ -3329,10 +3525,11 @@ discard block |
||
3329 | 3525 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
3330 | 3526 | |
3331 | 3527 | // Are we debugging the template/html content? |
3332 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
3333 | - header('Content-Type: application/xhtml+xml'); |
|
3334 | - elseif (!isset($_REQUEST['xml'])) |
|
3335 | - header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3528 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
3529 | + header('Content-Type: application/xhtml+xml'); |
|
3530 | + } elseif (!isset($_REQUEST['xml'])) { |
|
3531 | + header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3532 | + } |
|
3336 | 3533 | } |
3337 | 3534 | |
3338 | 3535 | header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3341,8 +3538,9 @@ discard block |
||
3341 | 3538 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
3342 | 3539 | { |
3343 | 3540 | $position = array_search('body', $context['template_layers']); |
3344 | - if ($position === false) |
|
3345 | - $position = array_search('main', $context['template_layers']); |
|
3541 | + if ($position === false) { |
|
3542 | + $position = array_search('main', $context['template_layers']); |
|
3543 | + } |
|
3346 | 3544 | |
3347 | 3545 | if ($position !== false) |
3348 | 3546 | { |
@@ -3370,23 +3568,25 @@ discard block |
||
3370 | 3568 | |
3371 | 3569 | foreach ($securityFiles as $i => $securityFile) |
3372 | 3570 | { |
3373 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
3374 | - unset($securityFiles[$i]); |
|
3571 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
3572 | + unset($securityFiles[$i]); |
|
3573 | + } |
|
3375 | 3574 | } |
3376 | 3575 | |
3377 | 3576 | // We are already checking so many files...just few more doesn't make any difference! :P |
3378 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
3379 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3380 | - |
|
3381 | - else |
|
3382 | - $path = $modSettings['attachmentUploadDir']; |
|
3577 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
3578 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3579 | + } else { |
|
3580 | + $path = $modSettings['attachmentUploadDir']; |
|
3581 | + } |
|
3383 | 3582 | |
3384 | 3583 | secureDirectory($path, true); |
3385 | 3584 | secureDirectory($cachedir); |
3386 | 3585 | |
3387 | 3586 | // If agreement is enabled, at least the english version shall exists |
3388 | - if ($modSettings['requireAgreement']) |
|
3389 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3587 | + if ($modSettings['requireAgreement']) { |
|
3588 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3589 | + } |
|
3390 | 3590 | |
3391 | 3591 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
3392 | 3592 | { |
@@ -3401,18 +3601,21 @@ discard block |
||
3401 | 3601 | echo ' |
3402 | 3602 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
3403 | 3603 | |
3404 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
3405 | - echo ' |
|
3604 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
3605 | + echo ' |
|
3406 | 3606 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
3607 | + } |
|
3407 | 3608 | } |
3408 | 3609 | |
3409 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
3410 | - echo ' |
|
3610 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
3611 | + echo ' |
|
3411 | 3612 | <strong>', $txt['cache_writable'], '</strong><br>'; |
3613 | + } |
|
3412 | 3614 | |
3413 | - if (!empty($agreement)) |
|
3414 | - echo ' |
|
3615 | + if (!empty($agreement)) { |
|
3616 | + echo ' |
|
3415 | 3617 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
3618 | + } |
|
3416 | 3619 | |
3417 | 3620 | echo ' |
3418 | 3621 | </p> |
@@ -3427,16 +3630,18 @@ discard block |
||
3427 | 3630 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
3428 | 3631 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
3429 | 3632 | |
3430 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
3431 | - echo ' |
|
3633 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
3634 | + echo ' |
|
3432 | 3635 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
3636 | + } |
|
3433 | 3637 | |
3434 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
3435 | - echo ' |
|
3638 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
3639 | + echo ' |
|
3436 | 3640 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
3437 | - else |
|
3438 | - echo ' |
|
3641 | + } else { |
|
3642 | + echo ' |
|
3439 | 3643 | <div>', $txt['your_ban_expires_never'], '</div>'; |
3644 | + } |
|
3440 | 3645 | |
3441 | 3646 | echo ' |
3442 | 3647 | </div>'; |
@@ -3452,8 +3657,9 @@ discard block |
||
3452 | 3657 | global $forum_copyright, $software_year, $forum_version; |
3453 | 3658 | |
3454 | 3659 | // Don't display copyright for things like SSI. |
3455 | - if (!isset($forum_version) || !isset($software_year)) |
|
3456 | - return; |
|
3660 | + if (!isset($forum_version) || !isset($software_year)) { |
|
3661 | + return; |
|
3662 | + } |
|
3457 | 3663 | |
3458 | 3664 | // Put in the version... |
3459 | 3665 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3471,9 +3677,10 @@ discard block |
||
3471 | 3677 | $context['load_time'] = comma_format(round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3)); |
3472 | 3678 | $context['load_queries'] = $db_count; |
3473 | 3679 | |
3474 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
3475 | - loadSubTemplate($layer . '_below', true); |
|
3476 | -} |
|
3680 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
3681 | + loadSubTemplate($layer . '_below', true); |
|
3682 | + } |
|
3683 | + } |
|
3477 | 3684 | |
3478 | 3685 | /** |
3479 | 3686 | * Output the Javascript files |
@@ -3504,8 +3711,7 @@ discard block |
||
3504 | 3711 | { |
3505 | 3712 | echo ' |
3506 | 3713 | var ', $key, ';'; |
3507 | - } |
|
3508 | - else |
|
3714 | + } else |
|
3509 | 3715 | { |
3510 | 3716 | echo ' |
3511 | 3717 | var ', $key, ' = ', $value, ';'; |
@@ -3520,26 +3726,27 @@ discard block |
||
3520 | 3726 | foreach ($context['javascript_files'] as $id => $js_file) |
3521 | 3727 | { |
3522 | 3728 | // Last minute call! allow theme authors to disable single files. |
3523 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3524 | - continue; |
|
3729 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3730 | + continue; |
|
3731 | + } |
|
3525 | 3732 | |
3526 | 3733 | // By default all files don't get minimized unless the file explicitly says so! |
3527 | 3734 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3528 | 3735 | { |
3529 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
3530 | - $toMinifyDefer[] = $js_file; |
|
3531 | - |
|
3532 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
3533 | - $toMinify[] = $js_file; |
|
3736 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
3737 | + $toMinifyDefer[] = $js_file; |
|
3738 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
3739 | + $toMinify[] = $js_file; |
|
3740 | + } |
|
3534 | 3741 | |
3535 | 3742 | // Grab a random seed. |
3536 | - if (!isset($minSeed)) |
|
3537 | - $minSeed = $js_file['options']['seed']; |
|
3538 | - } |
|
3539 | - |
|
3540 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
3541 | - echo ' |
|
3743 | + if (!isset($minSeed)) { |
|
3744 | + $minSeed = $js_file['options']['seed']; |
|
3745 | + } |
|
3746 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
3747 | + echo ' |
|
3542 | 3748 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
3749 | + } |
|
3543 | 3750 | } |
3544 | 3751 | |
3545 | 3752 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3547,14 +3754,14 @@ discard block |
||
3547 | 3754 | $result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred); |
3548 | 3755 | |
3549 | 3756 | // Minify process couldn't work, print each individual files. |
3550 | - if (!empty($result) && is_array($result)) |
|
3551 | - foreach ($result as $minFailedFile) |
|
3757 | + if (!empty($result) && is_array($result)) { |
|
3758 | + foreach ($result as $minFailedFile) |
|
3552 | 3759 | echo ' |
3553 | 3760 | <script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>'; |
3554 | - |
|
3555 | - else |
|
3556 | - echo ' |
|
3761 | + } else { |
|
3762 | + echo ' |
|
3557 | 3763 | <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
3764 | + } |
|
3558 | 3765 | } |
3559 | 3766 | |
3560 | 3767 | // Inline JavaScript - Actually useful some times! |
@@ -3565,8 +3772,9 @@ discard block |
||
3565 | 3772 | echo ' |
3566 | 3773 | <script>'; |
3567 | 3774 | |
3568 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
3569 | - echo $js_code; |
|
3775 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
3776 | + echo $js_code; |
|
3777 | + } |
|
3570 | 3778 | |
3571 | 3779 | echo ' |
3572 | 3780 | </script>'; |
@@ -3577,8 +3785,9 @@ discard block |
||
3577 | 3785 | echo ' |
3578 | 3786 | <script>'; |
3579 | 3787 | |
3580 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
3581 | - echo $js_code; |
|
3788 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
3789 | + echo $js_code; |
|
3790 | + } |
|
3582 | 3791 | |
3583 | 3792 | echo ' |
3584 | 3793 | </script>'; |
@@ -3603,8 +3812,9 @@ discard block |
||
3603 | 3812 | foreach ($context['css_files'] as $id => $file) |
3604 | 3813 | { |
3605 | 3814 | // Last minute call! allow theme authors to disable single files. |
3606 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3607 | - continue; |
|
3815 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3816 | + continue; |
|
3817 | + } |
|
3608 | 3818 | |
3609 | 3819 | // By default all files don't get minimized unless the file explicitly says so! |
3610 | 3820 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
@@ -3612,12 +3822,12 @@ discard block |
||
3612 | 3822 | $toMinify[] = $file; |
3613 | 3823 | |
3614 | 3824 | // Grab a random seed. |
3615 | - if (!isset($minSeed)) |
|
3616 | - $minSeed = $file['options']['seed']; |
|
3825 | + if (!isset($minSeed)) { |
|
3826 | + $minSeed = $file['options']['seed']; |
|
3827 | + } |
|
3828 | + } else { |
|
3829 | + $normal[] = $file['fileUrl']; |
|
3617 | 3830 | } |
3618 | - |
|
3619 | - else |
|
3620 | - $normal[] = $file['fileUrl']; |
|
3621 | 3831 | } |
3622 | 3832 | |
3623 | 3833 | if (!empty($toMinify)) |
@@ -3625,28 +3835,30 @@ discard block |
||
3625 | 3835 | $result = custMinify($toMinify, 'css'); |
3626 | 3836 | |
3627 | 3837 | // Minify process couldn't work, print each individual files. |
3628 | - if (!empty($result) && is_array($result)) |
|
3629 | - foreach ($result as $minFailedFile) |
|
3838 | + if (!empty($result) && is_array($result)) { |
|
3839 | + foreach ($result as $minFailedFile) |
|
3630 | 3840 | echo ' |
3631 | 3841 | <link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">'; |
3632 | - |
|
3633 | - else |
|
3634 | - echo ' |
|
3842 | + } else { |
|
3843 | + echo ' |
|
3635 | 3844 | <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
3845 | + } |
|
3636 | 3846 | } |
3637 | 3847 | |
3638 | 3848 | // Print the rest after the minified files. |
3639 | - if (!empty($normal)) |
|
3640 | - foreach ($normal as $nf) |
|
3849 | + if (!empty($normal)) { |
|
3850 | + foreach ($normal as $nf) |
|
3641 | 3851 | echo ' |
3642 | 3852 | <link rel="stylesheet" href="', $nf ,'">'; |
3853 | + } |
|
3643 | 3854 | |
3644 | 3855 | if ($db_show_debug === true) |
3645 | 3856 | { |
3646 | 3857 | // Try to keep only what's useful. |
3647 | 3858 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
3648 | - foreach ($context['css_files'] as $file) |
|
3649 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3859 | + foreach ($context['css_files'] as $file) { |
|
3860 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3861 | + } |
|
3650 | 3862 | } |
3651 | 3863 | |
3652 | 3864 | if (!empty($context['css_header'])) |
@@ -3654,9 +3866,10 @@ discard block |
||
3654 | 3866 | echo ' |
3655 | 3867 | <style>'; |
3656 | 3868 | |
3657 | - foreach ($context['css_header'] as $css) |
|
3658 | - echo $css .' |
|
3869 | + foreach ($context['css_header'] as $css) { |
|
3870 | + echo $css .' |
|
3659 | 3871 | '; |
3872 | + } |
|
3660 | 3873 | |
3661 | 3874 | echo' |
3662 | 3875 | </style>'; |
@@ -3680,15 +3893,17 @@ discard block |
||
3680 | 3893 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
3681 | 3894 | $data = !empty($data) ? $data : false; |
3682 | 3895 | |
3683 | - if (empty($type) || empty($data)) |
|
3684 | - return false; |
|
3896 | + if (empty($type) || empty($data)) { |
|
3897 | + return false; |
|
3898 | + } |
|
3685 | 3899 | |
3686 | 3900 | // Did we already did this? |
3687 | 3901 | $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
3688 | 3902 | |
3689 | 3903 | // Already done? |
3690 | - if (!empty($toCache)) |
|
3691 | - return true; |
|
3904 | + if (!empty($toCache)) { |
|
3905 | + return true; |
|
3906 | + } |
|
3692 | 3907 | |
3693 | 3908 | // No namespaces, sorry! |
3694 | 3909 | $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
@@ -3770,8 +3985,9 @@ discard block |
||
3770 | 3985 | global $modSettings, $smcFunc; |
3771 | 3986 | |
3772 | 3987 | // Just make up a nice hash... |
3773 | - if ($new) |
|
3774 | - return sha1(md5($filename . time()) . mt_rand()); |
|
3988 | + if ($new) { |
|
3989 | + return sha1(md5($filename . time()) . mt_rand()); |
|
3990 | + } |
|
3775 | 3991 | |
3776 | 3992 | // Just make sure that attachment id is only a int |
3777 | 3993 | $attachment_id = (int) $attachment_id; |
@@ -3788,23 +4004,25 @@ discard block |
||
3788 | 4004 | 'id_attach' => $attachment_id, |
3789 | 4005 | )); |
3790 | 4006 | |
3791 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
3792 | - return false; |
|
4007 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
4008 | + return false; |
|
4009 | + } |
|
3793 | 4010 | |
3794 | 4011 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
3795 | 4012 | $smcFunc['db_free_result']($request); |
3796 | 4013 | } |
3797 | 4014 | |
3798 | 4015 | // Still no hash? mmm... |
3799 | - if (empty($file_hash)) |
|
3800 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4016 | + if (empty($file_hash)) { |
|
4017 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4018 | + } |
|
3801 | 4019 | |
3802 | 4020 | // Are we using multiple directories? |
3803 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
3804 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
3805 | - |
|
3806 | - else |
|
3807 | - $path = $modSettings['attachmentUploadDir']; |
|
4021 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
4022 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
4023 | + } else { |
|
4024 | + $path = $modSettings['attachmentUploadDir']; |
|
4025 | + } |
|
3808 | 4026 | |
3809 | 4027 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
3810 | 4028 | } |
@@ -3819,8 +4037,9 @@ discard block |
||
3819 | 4037 | function ip2range($fullip) |
3820 | 4038 | { |
3821 | 4039 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
3822 | - if ($fullip == 'unknown') |
|
3823 | - $fullip = '255.255.255.255'; |
|
4040 | + if ($fullip == 'unknown') { |
|
4041 | + $fullip = '255.255.255.255'; |
|
4042 | + } |
|
3824 | 4043 | |
3825 | 4044 | $ip_parts = explode('-', $fullip); |
3826 | 4045 | $ip_array = array(); |
@@ -3844,10 +4063,11 @@ discard block |
||
3844 | 4063 | $ip_array['low'] = $ip_parts[0]; |
3845 | 4064 | $ip_array['high'] = $ip_parts[1]; |
3846 | 4065 | return $ip_array; |
3847 | - } |
|
3848 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
4066 | + } elseif (count($ip_parts) == 2) { |
|
4067 | + // if ip 22.22.*-22.22.* |
|
3849 | 4068 | { |
3850 | 4069 | $valid_low = isValidIP($ip_parts[0]); |
4070 | + } |
|
3851 | 4071 | $valid_high = isValidIP($ip_parts[1]); |
3852 | 4072 | $count = 0; |
3853 | 4073 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3862,7 +4082,9 @@ discard block |
||
3862 | 4082 | $ip_parts[0] .= $mode . $min; |
3863 | 4083 | $valid_low = isValidIP($ip_parts[0]); |
3864 | 4084 | $count++; |
3865 | - if ($count > 9) break; |
|
4085 | + if ($count > 9) { |
|
4086 | + break; |
|
4087 | + } |
|
3866 | 4088 | } |
3867 | 4089 | } |
3868 | 4090 | |
@@ -3876,7 +4098,9 @@ discard block |
||
3876 | 4098 | $ip_parts[1] .= $mode . $max; |
3877 | 4099 | $valid_high = isValidIP($ip_parts[1]); |
3878 | 4100 | $count++; |
3879 | - if ($count > 9) break; |
|
4101 | + if ($count > 9) { |
|
4102 | + break; |
|
4103 | + } |
|
3880 | 4104 | } |
3881 | 4105 | } |
3882 | 4106 | |
@@ -3901,46 +4125,54 @@ discard block |
||
3901 | 4125 | { |
3902 | 4126 | global $modSettings; |
3903 | 4127 | |
3904 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
3905 | - return $host; |
|
4128 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
4129 | + return $host; |
|
4130 | + } |
|
3906 | 4131 | $t = microtime(); |
3907 | 4132 | |
3908 | 4133 | // Try the Linux host command, perhaps? |
3909 | 4134 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
3910 | 4135 | { |
3911 | - if (!isset($modSettings['host_to_dis'])) |
|
3912 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
3913 | - else |
|
3914 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4136 | + if (!isset($modSettings['host_to_dis'])) { |
|
4137 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
4138 | + } else { |
|
4139 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4140 | + } |
|
3915 | 4141 | |
3916 | 4142 | // Did host say it didn't find anything? |
3917 | - if (strpos($test, 'not found') !== false) |
|
3918 | - $host = ''; |
|
4143 | + if (strpos($test, 'not found') !== false) { |
|
4144 | + $host = ''; |
|
4145 | + } |
|
3919 | 4146 | // Invalid server option? |
3920 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
3921 | - updateSettings(array('host_to_dis' => 1)); |
|
4147 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
4148 | + updateSettings(array('host_to_dis' => 1)); |
|
4149 | + } |
|
3922 | 4150 | // Maybe it found something, after all? |
3923 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
3924 | - $host = $match[1]; |
|
4151 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
4152 | + $host = $match[1]; |
|
4153 | + } |
|
3925 | 4154 | } |
3926 | 4155 | |
3927 | 4156 | // This is nslookup; usually only Windows, but possibly some Unix? |
3928 | 4157 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
3929 | 4158 | { |
3930 | 4159 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
3931 | - if (strpos($test, 'Non-existent domain') !== false) |
|
3932 | - $host = ''; |
|
3933 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
3934 | - $host = $match[1]; |
|
4160 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
4161 | + $host = ''; |
|
4162 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
4163 | + $host = $match[1]; |
|
4164 | + } |
|
3935 | 4165 | } |
3936 | 4166 | |
3937 | 4167 | // This is the last try :/. |
3938 | - if (!isset($host) || $host === false) |
|
3939 | - $host = @gethostbyaddr($ip); |
|
4168 | + if (!isset($host) || $host === false) { |
|
4169 | + $host = @gethostbyaddr($ip); |
|
4170 | + } |
|
3940 | 4171 | |
3941 | 4172 | // It took a long time, so let's cache it! |
3942 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
3943 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4173 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
4174 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4175 | + } |
|
3944 | 4176 | |
3945 | 4177 | return $host; |
3946 | 4178 | } |
@@ -3976,20 +4208,21 @@ discard block |
||
3976 | 4208 | { |
3977 | 4209 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
3978 | 4210 | $total = 0; |
3979 | - for ($i = 0; $i < $max_chars; $i++) |
|
3980 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4211 | + for ($i = 0; $i < $max_chars; $i++) { |
|
4212 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4213 | + } |
|
3981 | 4214 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
3982 | 4215 | } |
3983 | 4216 | } |
3984 | 4217 | return array_unique($returned_ints); |
3985 | - } |
|
3986 | - else |
|
4218 | + } else |
|
3987 | 4219 | { |
3988 | 4220 | // Trim characters before and after and add slashes for database insertion. |
3989 | 4221 | $returned_words = array(); |
3990 | - foreach ($words as $word) |
|
3991 | - if (($word = trim($word, '-_\'')) !== '') |
|
4222 | + foreach ($words as $word) { |
|
4223 | + if (($word = trim($word, '-_\'')) !== '') |
|
3992 | 4224 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
4225 | + } |
|
3993 | 4226 | |
3994 | 4227 | // Filter out all words that occur more than once. |
3995 | 4228 | return array_unique($returned_words); |
@@ -4011,16 +4244,18 @@ discard block |
||
4011 | 4244 | global $settings, $txt; |
4012 | 4245 | |
4013 | 4246 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
4014 | - if (function_exists('template_create_button') && !$force_use) |
|
4015 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4247 | + if (function_exists('template_create_button') && !$force_use) { |
|
4248 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4249 | + } |
|
4016 | 4250 | |
4017 | - if (!$settings['use_image_buttons']) |
|
4018 | - return $txt[$alt]; |
|
4019 | - elseif (!empty($settings['use_buttons'])) |
|
4020 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4021 | - else |
|
4022 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4023 | -} |
|
4251 | + if (!$settings['use_image_buttons']) { |
|
4252 | + return $txt[$alt]; |
|
4253 | + } elseif (!empty($settings['use_buttons'])) { |
|
4254 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4255 | + } else { |
|
4256 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4257 | + } |
|
4258 | + } |
|
4024 | 4259 | |
4025 | 4260 | /** |
4026 | 4261 | * Sets up all of the top menu buttons |
@@ -4063,9 +4298,10 @@ discard block |
||
4063 | 4298 | var user_menus = new smc_PopupMenu(); |
4064 | 4299 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4065 | 4300 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
4066 | - if ($context['allow_pm']) |
|
4067 | - addInlineJavaScript(' |
|
4301 | + if ($context['allow_pm']) { |
|
4302 | + addInlineJavaScript(' |
|
4068 | 4303 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
4304 | + } |
|
4069 | 4305 | |
4070 | 4306 | if (!empty($modSettings['enable_ajax_alerts'])) |
4071 | 4307 | { |
@@ -4225,88 +4461,96 @@ discard block |
||
4225 | 4461 | |
4226 | 4462 | // Now we put the buttons in the context so the theme can use them. |
4227 | 4463 | $menu_buttons = array(); |
4228 | - foreach ($buttons as $act => $button) |
|
4229 | - if (!empty($button['show'])) |
|
4464 | + foreach ($buttons as $act => $button) { |
|
4465 | + if (!empty($button['show'])) |
|
4230 | 4466 | { |
4231 | 4467 | $button['active_button'] = false; |
4468 | + } |
|
4232 | 4469 | |
4233 | 4470 | // This button needs some action. |
4234 | - if (isset($button['action_hook'])) |
|
4235 | - $needs_action_hook = true; |
|
4471 | + if (isset($button['action_hook'])) { |
|
4472 | + $needs_action_hook = true; |
|
4473 | + } |
|
4236 | 4474 | |
4237 | 4475 | // Make sure the last button truly is the last button. |
4238 | 4476 | if (!empty($button['is_last'])) |
4239 | 4477 | { |
4240 | - if (isset($last_button)) |
|
4241 | - unset($menu_buttons[$last_button]['is_last']); |
|
4478 | + if (isset($last_button)) { |
|
4479 | + unset($menu_buttons[$last_button]['is_last']); |
|
4480 | + } |
|
4242 | 4481 | $last_button = $act; |
4243 | 4482 | } |
4244 | 4483 | |
4245 | 4484 | // Go through the sub buttons if there are any. |
4246 | - if (!empty($button['sub_buttons'])) |
|
4247 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4485 | + if (!empty($button['sub_buttons'])) { |
|
4486 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4248 | 4487 | { |
4249 | 4488 | if (empty($subbutton['show'])) |
4250 | 4489 | unset($button['sub_buttons'][$key]); |
4490 | + } |
|
4251 | 4491 | |
4252 | 4492 | // 2nd level sub buttons next... |
4253 | 4493 | if (!empty($subbutton['sub_buttons'])) |
4254 | 4494 | { |
4255 | 4495 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
4256 | 4496 | { |
4257 | - if (empty($sub_button2['show'])) |
|
4258 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4497 | + if (empty($sub_button2['show'])) { |
|
4498 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4499 | + } |
|
4259 | 4500 | } |
4260 | 4501 | } |
4261 | 4502 | } |
4262 | 4503 | |
4263 | 4504 | // Does this button have its own icon? |
4264 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
4265 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4266 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
4267 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4268 | - elseif (isset($button['icon'])) |
|
4269 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4270 | - else |
|
4271 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4505 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
4506 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4507 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
4508 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4509 | + } elseif (isset($button['icon'])) { |
|
4510 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4511 | + } else { |
|
4512 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4513 | + } |
|
4272 | 4514 | |
4273 | 4515 | $menu_buttons[$act] = $button; |
4274 | 4516 | } |
4275 | 4517 | |
4276 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
4277 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4518 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
4519 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4520 | + } |
|
4278 | 4521 | } |
4279 | 4522 | |
4280 | 4523 | $context['menu_buttons'] = $menu_buttons; |
4281 | 4524 | |
4282 | 4525 | // Logging out requires the session id in the url. |
4283 | - if (isset($context['menu_buttons']['logout'])) |
|
4284 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4526 | + if (isset($context['menu_buttons']['logout'])) { |
|
4527 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4528 | + } |
|
4285 | 4529 | |
4286 | 4530 | // Figure out which action we are doing so we can set the active tab. |
4287 | 4531 | // Default to home. |
4288 | 4532 | $current_action = 'home'; |
4289 | 4533 | |
4290 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
4291 | - $current_action = $context['current_action']; |
|
4292 | - elseif ($context['current_action'] == 'search2') |
|
4293 | - $current_action = 'search'; |
|
4294 | - elseif ($context['current_action'] == 'theme') |
|
4295 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4296 | - elseif ($context['current_action'] == 'register2') |
|
4297 | - $current_action = 'register'; |
|
4298 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
4299 | - $current_action = 'login'; |
|
4300 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
4301 | - $current_action = 'moderate'; |
|
4534 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
4535 | + $current_action = $context['current_action']; |
|
4536 | + } elseif ($context['current_action'] == 'search2') { |
|
4537 | + $current_action = 'search'; |
|
4538 | + } elseif ($context['current_action'] == 'theme') { |
|
4539 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4540 | + } elseif ($context['current_action'] == 'register2') { |
|
4541 | + $current_action = 'register'; |
|
4542 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
4543 | + $current_action = 'login'; |
|
4544 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
4545 | + $current_action = 'moderate'; |
|
4546 | + } |
|
4302 | 4547 | |
4303 | 4548 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
4304 | 4549 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
4305 | 4550 | { |
4306 | 4551 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
4307 | 4552 | $context[$current_action] = true; |
4308 | - } |
|
4309 | - elseif ($context['current_action'] == 'pm') |
|
4553 | + } elseif ($context['current_action'] == 'pm') |
|
4310 | 4554 | { |
4311 | 4555 | $current_action = 'self_pm'; |
4312 | 4556 | $context['self_pm'] = true; |
@@ -4347,12 +4591,14 @@ discard block |
||
4347 | 4591 | } |
4348 | 4592 | |
4349 | 4593 | // Not all actions are simple. |
4350 | - if (!empty($needs_action_hook)) |
|
4351 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4594 | + if (!empty($needs_action_hook)) { |
|
4595 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4596 | + } |
|
4352 | 4597 | |
4353 | - if (isset($context['menu_buttons'][$current_action])) |
|
4354 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4355 | -} |
|
4598 | + if (isset($context['menu_buttons'][$current_action])) { |
|
4599 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4600 | + } |
|
4601 | + } |
|
4356 | 4602 | |
4357 | 4603 | /** |
4358 | 4604 | * Generate a random seed and ensure it's stored in settings. |
@@ -4376,30 +4622,35 @@ discard block |
||
4376 | 4622 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
4377 | 4623 | global $context, $txt; |
4378 | 4624 | |
4379 | - if ($db_show_debug === true) |
|
4380 | - $context['debug']['hooks'][] = $hook; |
|
4625 | + if ($db_show_debug === true) { |
|
4626 | + $context['debug']['hooks'][] = $hook; |
|
4627 | + } |
|
4381 | 4628 | |
4382 | 4629 | // Need to have some control. |
4383 | - if (!isset($context['instances'])) |
|
4384 | - $context['instances'] = array(); |
|
4630 | + if (!isset($context['instances'])) { |
|
4631 | + $context['instances'] = array(); |
|
4632 | + } |
|
4385 | 4633 | |
4386 | 4634 | $results = array(); |
4387 | - if (empty($modSettings[$hook])) |
|
4388 | - return $results; |
|
4635 | + if (empty($modSettings[$hook])) { |
|
4636 | + return $results; |
|
4637 | + } |
|
4389 | 4638 | |
4390 | 4639 | $functions = explode(',', $modSettings[$hook]); |
4391 | 4640 | // Loop through each function. |
4392 | 4641 | foreach ($functions as $function) |
4393 | 4642 | { |
4394 | 4643 | // Hook has been marked as "disabled". Skip it! |
4395 | - if (strpos($function, '!') !== false) |
|
4396 | - continue; |
|
4644 | + if (strpos($function, '!') !== false) { |
|
4645 | + continue; |
|
4646 | + } |
|
4397 | 4647 | |
4398 | 4648 | $call = call_helper($function, true); |
4399 | 4649 | |
4400 | 4650 | // Is it valid? |
4401 | - if (!empty($call)) |
|
4402 | - $results[$function] = call_user_func_array($call, $parameters); |
|
4651 | + if (!empty($call)) { |
|
4652 | + $results[$function] = call_user_func_array($call, $parameters); |
|
4653 | + } |
|
4403 | 4654 | |
4404 | 4655 | // Whatever it was suppose to call, it failed :( |
4405 | 4656 | elseif (!empty($function)) |
@@ -4415,8 +4666,9 @@ discard block |
||
4415 | 4666 | } |
4416 | 4667 | |
4417 | 4668 | // "Assume" the file resides on $boarddir somewhere... |
4418 | - else |
|
4419 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4669 | + else { |
|
4670 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4671 | + } |
|
4420 | 4672 | } |
4421 | 4673 | } |
4422 | 4674 | |
@@ -4438,12 +4690,14 @@ discard block |
||
4438 | 4690 | global $smcFunc, $modSettings; |
4439 | 4691 | |
4440 | 4692 | // Any objects? |
4441 | - if ($object) |
|
4442 | - $function = $function . '#'; |
|
4693 | + if ($object) { |
|
4694 | + $function = $function . '#'; |
|
4695 | + } |
|
4443 | 4696 | |
4444 | 4697 | // Any files to load? |
4445 | - if (!empty($file) && is_string($file)) |
|
4446 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4698 | + if (!empty($file) && is_string($file)) { |
|
4699 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4700 | + } |
|
4447 | 4701 | |
4448 | 4702 | // Get the correct string. |
4449 | 4703 | $integration_call = $function; |
@@ -4465,13 +4719,14 @@ discard block |
||
4465 | 4719 | if (!empty($current_functions)) |
4466 | 4720 | { |
4467 | 4721 | $current_functions = explode(',', $current_functions); |
4468 | - if (in_array($integration_call, $current_functions)) |
|
4469 | - return; |
|
4722 | + if (in_array($integration_call, $current_functions)) { |
|
4723 | + return; |
|
4724 | + } |
|
4470 | 4725 | |
4471 | 4726 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
4727 | + } else { |
|
4728 | + $permanent_functions = array($integration_call); |
|
4472 | 4729 | } |
4473 | - else |
|
4474 | - $permanent_functions = array($integration_call); |
|
4475 | 4730 | |
4476 | 4731 | updateSettings(array($hook => implode(',', $permanent_functions))); |
4477 | 4732 | } |
@@ -4480,8 +4735,9 @@ discard block |
||
4480 | 4735 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4481 | 4736 | |
4482 | 4737 | // Do nothing, if it's already there. |
4483 | - if (in_array($integration_call, $functions)) |
|
4484 | - return; |
|
4738 | + if (in_array($integration_call, $functions)) { |
|
4739 | + return; |
|
4740 | + } |
|
4485 | 4741 | |
4486 | 4742 | $functions[] = $integration_call; |
4487 | 4743 | $modSettings[$hook] = implode(',', $functions); |
@@ -4504,12 +4760,14 @@ discard block |
||
4504 | 4760 | global $smcFunc, $modSettings; |
4505 | 4761 | |
4506 | 4762 | // Any objects? |
4507 | - if ($object) |
|
4508 | - $function = $function . '#'; |
|
4763 | + if ($object) { |
|
4764 | + $function = $function . '#'; |
|
4765 | + } |
|
4509 | 4766 | |
4510 | 4767 | // Any files to load? |
4511 | - if (!empty($file) && is_string($file)) |
|
4512 | - $function = $file . '|' . $function; |
|
4768 | + if (!empty($file) && is_string($file)) { |
|
4769 | + $function = $file . '|' . $function; |
|
4770 | + } |
|
4513 | 4771 | |
4514 | 4772 | // Get the correct string. |
4515 | 4773 | $integration_call = $function; |
@@ -4530,16 +4788,18 @@ discard block |
||
4530 | 4788 | { |
4531 | 4789 | $current_functions = explode(',', $current_functions); |
4532 | 4790 | |
4533 | - if (in_array($integration_call, $current_functions)) |
|
4534 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4791 | + if (in_array($integration_call, $current_functions)) { |
|
4792 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4793 | + } |
|
4535 | 4794 | } |
4536 | 4795 | |
4537 | 4796 | // Turn the function list into something usable. |
4538 | 4797 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4539 | 4798 | |
4540 | 4799 | // You can only remove it if it's available. |
4541 | - if (!in_array($integration_call, $functions)) |
|
4542 | - return; |
|
4800 | + if (!in_array($integration_call, $functions)) { |
|
4801 | + return; |
|
4802 | + } |
|
4543 | 4803 | |
4544 | 4804 | $functions = array_diff($functions, array($integration_call)); |
4545 | 4805 | $modSettings[$hook] = implode(',', $functions); |
@@ -4560,17 +4820,20 @@ discard block |
||
4560 | 4820 | global $context, $smcFunc, $txt, $db_show_debug; |
4561 | 4821 | |
4562 | 4822 | // Really? |
4563 | - if (empty($string)) |
|
4564 | - return false; |
|
4823 | + if (empty($string)) { |
|
4824 | + return false; |
|
4825 | + } |
|
4565 | 4826 | |
4566 | 4827 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
4567 | 4828 | // A closure? should be a callable one. |
4568 | - if (is_array($string) || $string instanceof Closure) |
|
4569 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4829 | + if (is_array($string) || $string instanceof Closure) { |
|
4830 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4831 | + } |
|
4570 | 4832 | |
4571 | 4833 | // No full objects, sorry! pass a method or a property instead! |
4572 | - if (is_object($string)) |
|
4573 | - return false; |
|
4834 | + if (is_object($string)) { |
|
4835 | + return false; |
|
4836 | + } |
|
4574 | 4837 | |
4575 | 4838 | // Stay vitaminized my friends... |
4576 | 4839 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4579,8 +4842,9 @@ discard block |
||
4579 | 4842 | $string = load_file($string); |
4580 | 4843 | |
4581 | 4844 | // Loaded file failed |
4582 | - if (empty($string)) |
|
4583 | - return false; |
|
4845 | + if (empty($string)) { |
|
4846 | + return false; |
|
4847 | + } |
|
4584 | 4848 | |
4585 | 4849 | // Found a method. |
4586 | 4850 | if (strpos($string, '::') !== false) |
@@ -4601,8 +4865,9 @@ discard block |
||
4601 | 4865 | // Add another one to the list. |
4602 | 4866 | if ($db_show_debug === true) |
4603 | 4867 | { |
4604 | - if (!isset($context['debug']['instances'])) |
|
4605 | - $context['debug']['instances'] = array(); |
|
4868 | + if (!isset($context['debug']['instances'])) { |
|
4869 | + $context['debug']['instances'] = array(); |
|
4870 | + } |
|
4606 | 4871 | |
4607 | 4872 | $context['debug']['instances'][$class] = $class; |
4608 | 4873 | } |
@@ -4612,13 +4877,15 @@ discard block |
||
4612 | 4877 | } |
4613 | 4878 | |
4614 | 4879 | // Right then. This is a call to a static method. |
4615 | - else |
|
4616 | - $func = array($class, $method); |
|
4880 | + else { |
|
4881 | + $func = array($class, $method); |
|
4882 | + } |
|
4617 | 4883 | } |
4618 | 4884 | |
4619 | 4885 | // Nope! just a plain regular function. |
4620 | - else |
|
4621 | - $func = $string; |
|
4886 | + else { |
|
4887 | + $func = $string; |
|
4888 | + } |
|
4622 | 4889 | |
4623 | 4890 | // Right, we got what we need, time to do some checks. |
4624 | 4891 | if (!is_callable($func, false, $callable_name)) |
@@ -4634,17 +4901,18 @@ discard block |
||
4634 | 4901 | else |
4635 | 4902 | { |
4636 | 4903 | // What are we gonna do about it? |
4637 | - if ($return) |
|
4638 | - return $func; |
|
4904 | + if ($return) { |
|
4905 | + return $func; |
|
4906 | + } |
|
4639 | 4907 | |
4640 | 4908 | // If this is a plain function, avoid the heat of calling call_user_func(). |
4641 | 4909 | else |
4642 | 4910 | { |
4643 | - if (is_array($func)) |
|
4644 | - call_user_func($func); |
|
4645 | - |
|
4646 | - else |
|
4647 | - $func(); |
|
4911 | + if (is_array($func)) { |
|
4912 | + call_user_func($func); |
|
4913 | + } else { |
|
4914 | + $func(); |
|
4915 | + } |
|
4648 | 4916 | } |
4649 | 4917 | } |
4650 | 4918 | } |
@@ -4661,31 +4929,34 @@ discard block |
||
4661 | 4929 | { |
4662 | 4930 | global $sourcedir, $txt, $boarddir, $settings; |
4663 | 4931 | |
4664 | - if (empty($string)) |
|
4665 | - return false; |
|
4932 | + if (empty($string)) { |
|
4933 | + return false; |
|
4934 | + } |
|
4666 | 4935 | |
4667 | 4936 | if (strpos($string, '|') !== false) |
4668 | 4937 | { |
4669 | 4938 | list ($file, $string) = explode('|', $string); |
4670 | 4939 | |
4671 | 4940 | // Match the wildcards to their regular vars. |
4672 | - if (empty($settings['theme_dir'])) |
|
4673 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4674 | - |
|
4675 | - else |
|
4676 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
4941 | + if (empty($settings['theme_dir'])) { |
|
4942 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4943 | + } else { |
|
4944 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
4945 | + } |
|
4677 | 4946 | |
4678 | 4947 | // Load the file if it can be loaded. |
4679 | - if (file_exists($absPath)) |
|
4680 | - require_once($absPath); |
|
4948 | + if (file_exists($absPath)) { |
|
4949 | + require_once($absPath); |
|
4950 | + } |
|
4681 | 4951 | |
4682 | 4952 | // No? try a fallback to $sourcedir |
4683 | 4953 | else |
4684 | 4954 | { |
4685 | 4955 | $absPath = $sourcedir .'/'. $file; |
4686 | 4956 | |
4687 | - if (file_exists($absPath)) |
|
4688 | - require_once($absPath); |
|
4957 | + if (file_exists($absPath)) { |
|
4958 | + require_once($absPath); |
|
4959 | + } |
|
4689 | 4960 | |
4690 | 4961 | // Sorry, can't do much for you at this point. |
4691 | 4962 | else |
@@ -4712,8 +4983,9 @@ discard block |
||
4712 | 4983 | global $user_info, $smcFunc; |
4713 | 4984 | |
4714 | 4985 | // Make sure we have something to work with. |
4715 | - if (empty($topic)) |
|
4716 | - return array(); |
|
4986 | + if (empty($topic)) { |
|
4987 | + return array(); |
|
4988 | + } |
|
4717 | 4989 | |
4718 | 4990 | |
4719 | 4991 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -4736,8 +5008,9 @@ discard block |
||
4736 | 5008 | 'topic' => $topic, |
4737 | 5009 | ) |
4738 | 5010 | ); |
4739 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4740 | - $temp[] = (int) $row['content_id']; |
|
5011 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
5012 | + $temp[] = (int) $row['content_id']; |
|
5013 | + } |
|
4741 | 5014 | |
4742 | 5015 | cache_put_data($cache_key, $temp, $ttl); |
4743 | 5016 | } |
@@ -4758,8 +5031,9 @@ discard block |
||
4758 | 5031 | { |
4759 | 5032 | global $context; |
4760 | 5033 | |
4761 | - if (empty($string)) |
|
4762 | - return $string; |
|
5034 | + if (empty($string)) { |
|
5035 | + return $string; |
|
5036 | + } |
|
4763 | 5037 | |
4764 | 5038 | // UTF-8 occurences of MS special characters |
4765 | 5039 | $findchars_utf8 = array( |
@@ -4800,10 +5074,11 @@ discard block |
||
4800 | 5074 | '--', // — |
4801 | 5075 | ); |
4802 | 5076 | |
4803 | - if ($context['utf8']) |
|
4804 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
4805 | - else |
|
4806 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
5077 | + if ($context['utf8']) { |
|
5078 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
5079 | + } else { |
|
5080 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
5081 | + } |
|
4807 | 5082 | |
4808 | 5083 | return $string; |
4809 | 5084 | } |
@@ -4822,49 +5097,59 @@ discard block |
||
4822 | 5097 | { |
4823 | 5098 | global $context; |
4824 | 5099 | |
4825 | - if (!isset($matches[2])) |
|
4826 | - return ''; |
|
5100 | + if (!isset($matches[2])) { |
|
5101 | + return ''; |
|
5102 | + } |
|
4827 | 5103 | |
4828 | 5104 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
4829 | 5105 | |
4830 | 5106 | // remove left to right / right to left overrides |
4831 | - if ($num === 0x202D || $num === 0x202E) |
|
4832 | - return ''; |
|
5107 | + if ($num === 0x202D || $num === 0x202E) { |
|
5108 | + return ''; |
|
5109 | + } |
|
4833 | 5110 | |
4834 | 5111 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
4835 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
4836 | - return '&#' . $num . ';'; |
|
5112 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
5113 | + return '&#' . $num . ';'; |
|
5114 | + } |
|
4837 | 5115 | |
4838 | 5116 | if (empty($context['utf8'])) |
4839 | 5117 | { |
4840 | 5118 | // no control characters |
4841 | - if ($num < 0x20) |
|
4842 | - return ''; |
|
5119 | + if ($num < 0x20) { |
|
5120 | + return ''; |
|
5121 | + } |
|
4843 | 5122 | // text is text |
4844 | - elseif ($num < 0x80) |
|
4845 | - return chr($num); |
|
5123 | + elseif ($num < 0x80) { |
|
5124 | + return chr($num); |
|
5125 | + } |
|
4846 | 5126 | // all others get html-ised |
4847 | - else |
|
4848 | - return '&#' . $matches[2] . ';'; |
|
4849 | - } |
|
4850 | - else |
|
5127 | + else { |
|
5128 | + return '&#' . $matches[2] . ';'; |
|
5129 | + } |
|
5130 | + } else |
|
4851 | 5131 | { |
4852 | 5132 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
4853 | 5133 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
4854 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
4855 | - return ''; |
|
5134 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
5135 | + return ''; |
|
5136 | + } |
|
4856 | 5137 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
4857 | - elseif ($num < 0x80) |
|
4858 | - return chr($num); |
|
5138 | + elseif ($num < 0x80) { |
|
5139 | + return chr($num); |
|
5140 | + } |
|
4859 | 5141 | // <0x800 (2048) |
4860 | - elseif ($num < 0x800) |
|
4861 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5142 | + elseif ($num < 0x800) { |
|
5143 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5144 | + } |
|
4862 | 5145 | // < 0x10000 (65536) |
4863 | - elseif ($num < 0x10000) |
|
4864 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5146 | + elseif ($num < 0x10000) { |
|
5147 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5148 | + } |
|
4865 | 5149 | // <= 0x10FFFF (1114111) |
4866 | - else |
|
4867 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5150 | + else { |
|
5151 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5152 | + } |
|
4868 | 5153 | } |
4869 | 5154 | } |
4870 | 5155 | |
@@ -4880,28 +5165,34 @@ discard block |
||
4880 | 5165 | */ |
4881 | 5166 | function fixchar__callback($matches) |
4882 | 5167 | { |
4883 | - if (!isset($matches[1])) |
|
4884 | - return ''; |
|
5168 | + if (!isset($matches[1])) { |
|
5169 | + return ''; |
|
5170 | + } |
|
4885 | 5171 | |
4886 | 5172 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
4887 | 5173 | |
4888 | 5174 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
4889 | 5175 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
4890 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
4891 | - return ''; |
|
5176 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
5177 | + return ''; |
|
5178 | + } |
|
4892 | 5179 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
4893 | - elseif ($num < 0x80) |
|
4894 | - return chr($num); |
|
5180 | + elseif ($num < 0x80) { |
|
5181 | + return chr($num); |
|
5182 | + } |
|
4895 | 5183 | // <0x800 (2048) |
4896 | - elseif ($num < 0x800) |
|
4897 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5184 | + elseif ($num < 0x800) { |
|
5185 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5186 | + } |
|
4898 | 5187 | // < 0x10000 (65536) |
4899 | - elseif ($num < 0x10000) |
|
4900 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5188 | + elseif ($num < 0x10000) { |
|
5189 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5190 | + } |
|
4901 | 5191 | // <= 0x10FFFF (1114111) |
4902 | - else |
|
4903 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
4904 | -} |
|
5192 | + else { |
|
5193 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5194 | + } |
|
5195 | + } |
|
4905 | 5196 | |
4906 | 5197 | /** |
4907 | 5198 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -4914,17 +5205,19 @@ discard block |
||
4914 | 5205 | */ |
4915 | 5206 | function entity_fix__callback($matches) |
4916 | 5207 | { |
4917 | - if (!isset($matches[2])) |
|
4918 | - return ''; |
|
5208 | + if (!isset($matches[2])) { |
|
5209 | + return ''; |
|
5210 | + } |
|
4919 | 5211 | |
4920 | 5212 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
4921 | 5213 | |
4922 | 5214 | // we don't allow control characters, characters out of range, byte markers, etc |
4923 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
4924 | - return ''; |
|
4925 | - else |
|
4926 | - return '&#' . $num . ';'; |
|
4927 | -} |
|
5215 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
5216 | + return ''; |
|
5217 | + } else { |
|
5218 | + return '&#' . $num . ';'; |
|
5219 | + } |
|
5220 | + } |
|
4928 | 5221 | |
4929 | 5222 | /** |
4930 | 5223 | * Return a Gravatar URL based on |
@@ -4948,18 +5241,23 @@ discard block |
||
4948 | 5241 | $ratings = array('G', 'PG', 'R', 'X'); |
4949 | 5242 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
4950 | 5243 | $url_params = array(); |
4951 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
4952 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
4953 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
4954 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
4955 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
4956 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
4957 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
4958 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5244 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
5245 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5246 | + } |
|
5247 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
5248 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5249 | + } |
|
5250 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
5251 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5252 | + } |
|
5253 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
5254 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
4959 | 5255 | $size_string = $modSettings['avatar_max_height_external']; |
5256 | + } |
|
4960 | 5257 | |
4961 | - if (!empty($size_string)) |
|
4962 | - $url_params[] = 's=' . $size_string; |
|
5258 | + if (!empty($size_string)) { |
|
5259 | + $url_params[] = 's=' . $size_string; |
|
5260 | + } |
|
4963 | 5261 | } |
4964 | 5262 | $http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www'; |
4965 | 5263 | |
@@ -4978,22 +5276,26 @@ discard block |
||
4978 | 5276 | static $timezones = null, $lastwhen = null; |
4979 | 5277 | |
4980 | 5278 | // No point doing this over if we already did it once |
4981 | - if (!empty($timezones) && $when == $lastwhen) |
|
4982 | - return $timezones; |
|
4983 | - else |
|
4984 | - $lastwhen = $when; |
|
5279 | + if (!empty($timezones) && $when == $lastwhen) { |
|
5280 | + return $timezones; |
|
5281 | + } else { |
|
5282 | + $lastwhen = $when; |
|
5283 | + } |
|
4985 | 5284 | |
4986 | 5285 | // Parseable datetime string? |
4987 | - if (is_int($timestamp = strtotime($when))) |
|
4988 | - $when = $timestamp; |
|
5286 | + if (is_int($timestamp = strtotime($when))) { |
|
5287 | + $when = $timestamp; |
|
5288 | + } |
|
4989 | 5289 | |
4990 | 5290 | // A Unix timestamp? |
4991 | - elseif (is_numeric($when)) |
|
4992 | - $when = intval($when); |
|
5291 | + elseif (is_numeric($when)) { |
|
5292 | + $when = intval($when); |
|
5293 | + } |
|
4993 | 5294 | |
4994 | 5295 | // Invalid value? Just get current Unix timestamp. |
4995 | - else |
|
4996 | - $when = time(); |
|
5296 | + else { |
|
5297 | + $when = time(); |
|
5298 | + } |
|
4997 | 5299 | |
4998 | 5300 | // We'll need these too |
4999 | 5301 | $date_when = date_create('@' . $when); |
@@ -5057,8 +5359,9 @@ discard block |
||
5057 | 5359 | foreach ($priority_countries as $country) |
5058 | 5360 | { |
5059 | 5361 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
5060 | - if (!empty($country_tzids)) |
|
5061 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5362 | + if (!empty($country_tzids)) { |
|
5363 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5364 | + } |
|
5062 | 5365 | } |
5063 | 5366 | |
5064 | 5367 | // Process the preferred timezones first, then the rest. |
@@ -5068,8 +5371,9 @@ discard block |
||
5068 | 5371 | foreach ($tzids as $tzid) |
5069 | 5372 | { |
5070 | 5373 | // We don't want UTC right now |
5071 | - if ($tzid == 'UTC') |
|
5072 | - continue; |
|
5374 | + if ($tzid == 'UTC') { |
|
5375 | + continue; |
|
5376 | + } |
|
5073 | 5377 | |
5074 | 5378 | $tz = timezone_open($tzid); |
5075 | 5379 | |
@@ -5084,12 +5388,14 @@ discard block |
||
5084 | 5388 | $tzgeo = timezone_location_get($tz); |
5085 | 5389 | |
5086 | 5390 | // Don't overwrite our preferred tzids |
5087 | - if (empty($zones[$tzkey]['tzid'])) |
|
5088 | - $zones[$tzkey]['tzid'] = $tzid; |
|
5391 | + if (empty($zones[$tzkey]['tzid'])) { |
|
5392 | + $zones[$tzkey]['tzid'] = $tzid; |
|
5393 | + } |
|
5089 | 5394 | |
5090 | 5395 | // A time zone from a prioritized country? |
5091 | - if (in_array($tzid, $priority_tzids)) |
|
5092 | - $priority_zones[$tzkey] = true; |
|
5396 | + if (in_array($tzid, $priority_tzids)) { |
|
5397 | + $priority_zones[$tzkey] = true; |
|
5398 | + } |
|
5093 | 5399 | |
5094 | 5400 | // Keep track of the location and offset for this tzid |
5095 | 5401 | $tzid_parts = explode('/', $tzid); |
@@ -5111,15 +5417,17 @@ discard block |
||
5111 | 5417 | |
5112 | 5418 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
5113 | 5419 | |
5114 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
5115 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5116 | - else |
|
5117 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5420 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
5421 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5422 | + } else { |
|
5423 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5424 | + } |
|
5118 | 5425 | |
5119 | - if (isset($priority_zones[$tzkey])) |
|
5120 | - $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5121 | - else |
|
5122 | - $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5426 | + if (isset($priority_zones[$tzkey])) { |
|
5427 | + $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5428 | + } else { |
|
5429 | + $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5430 | + } |
|
5123 | 5431 | } |
5124 | 5432 | |
5125 | 5433 | $timezones = array_merge( |
@@ -5173,9 +5481,9 @@ discard block |
||
5173 | 5481 | 'Indian/Kerguelen' => 'TFT', |
5174 | 5482 | ); |
5175 | 5483 | |
5176 | - if (!empty($missing_tz_abbrs[$tzid])) |
|
5177 | - $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5178 | - else |
|
5484 | + if (!empty($missing_tz_abbrs[$tzid])) { |
|
5485 | + $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5486 | + } else |
|
5179 | 5487 | { |
5180 | 5488 | // Russia likes to experiment with time zones often, and names them as offsets from Moscow |
5181 | 5489 | $tz_location = timezone_location_get(timezone_open($tzid)); |
@@ -5203,8 +5511,9 @@ discard block |
||
5203 | 5511 | */ |
5204 | 5512 | function inet_ptod($ip_address) |
5205 | 5513 | { |
5206 | - if (!isValidIP($ip_address)) |
|
5207 | - return $ip_address; |
|
5514 | + if (!isValidIP($ip_address)) { |
|
5515 | + return $ip_address; |
|
5516 | + } |
|
5208 | 5517 | |
5209 | 5518 | $bin = inet_pton($ip_address); |
5210 | 5519 | return $bin; |
@@ -5216,13 +5525,15 @@ discard block |
||
5216 | 5525 | */ |
5217 | 5526 | function inet_dtop($bin) |
5218 | 5527 | { |
5219 | - if(empty($bin)) |
|
5220 | - return ''; |
|
5528 | + if(empty($bin)) { |
|
5529 | + return ''; |
|
5530 | + } |
|
5221 | 5531 | |
5222 | 5532 | global $db_type; |
5223 | 5533 | |
5224 | - if ($db_type == 'postgresql') |
|
5225 | - return $bin; |
|
5534 | + if ($db_type == 'postgresql') { |
|
5535 | + return $bin; |
|
5536 | + } |
|
5226 | 5537 | |
5227 | 5538 | $ip_address = inet_ntop($bin); |
5228 | 5539 | |
@@ -5247,26 +5558,32 @@ discard block |
||
5247 | 5558 | */ |
5248 | 5559 | function _safe_serialize($value) |
5249 | 5560 | { |
5250 | - if(is_null($value)) |
|
5251 | - return 'N;'; |
|
5561 | + if(is_null($value)) { |
|
5562 | + return 'N;'; |
|
5563 | + } |
|
5252 | 5564 | |
5253 | - if(is_bool($value)) |
|
5254 | - return 'b:'. (int) $value .';'; |
|
5565 | + if(is_bool($value)) { |
|
5566 | + return 'b:'. (int) $value .';'; |
|
5567 | + } |
|
5255 | 5568 | |
5256 | - if(is_int($value)) |
|
5257 | - return 'i:'. $value .';'; |
|
5569 | + if(is_int($value)) { |
|
5570 | + return 'i:'. $value .';'; |
|
5571 | + } |
|
5258 | 5572 | |
5259 | - if(is_float($value)) |
|
5260 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5573 | + if(is_float($value)) { |
|
5574 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
5575 | + } |
|
5261 | 5576 | |
5262 | - if(is_string($value)) |
|
5263 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5577 | + if(is_string($value)) { |
|
5578 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
5579 | + } |
|
5264 | 5580 | |
5265 | 5581 | if(is_array($value)) |
5266 | 5582 | { |
5267 | 5583 | $out = ''; |
5268 | - foreach($value as $k => $v) |
|
5269 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5584 | + foreach($value as $k => $v) { |
|
5585 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5586 | + } |
|
5270 | 5587 | |
5271 | 5588 | return 'a:'. count($value) .':{'. $out .'}'; |
5272 | 5589 | } |
@@ -5292,8 +5609,9 @@ discard block |
||
5292 | 5609 | |
5293 | 5610 | $out = _safe_serialize($value); |
5294 | 5611 | |
5295 | - if (isset($mbIntEnc)) |
|
5296 | - mb_internal_encoding($mbIntEnc); |
|
5612 | + if (isset($mbIntEnc)) { |
|
5613 | + mb_internal_encoding($mbIntEnc); |
|
5614 | + } |
|
5297 | 5615 | |
5298 | 5616 | return $out; |
5299 | 5617 | } |
@@ -5310,8 +5628,9 @@ discard block |
||
5310 | 5628 | function _safe_unserialize($str) |
5311 | 5629 | { |
5312 | 5630 | // Input is not a string. |
5313 | - if(empty($str) || !is_string($str)) |
|
5314 | - return false; |
|
5631 | + if(empty($str) || !is_string($str)) { |
|
5632 | + return false; |
|
5633 | + } |
|
5315 | 5634 | |
5316 | 5635 | $stack = array(); |
5317 | 5636 | $expected = array(); |
@@ -5327,43 +5646,38 @@ discard block |
||
5327 | 5646 | while($state != 1) |
5328 | 5647 | { |
5329 | 5648 | $type = isset($str[0]) ? $str[0] : ''; |
5330 | - if($type == '}') |
|
5331 | - $str = substr($str, 1); |
|
5332 | - |
|
5333 | - else if($type == 'N' && $str[1] == ';') |
|
5649 | + if($type == '}') { |
|
5650 | + $str = substr($str, 1); |
|
5651 | + } else if($type == 'N' && $str[1] == ';') |
|
5334 | 5652 | { |
5335 | 5653 | $value = null; |
5336 | 5654 | $str = substr($str, 2); |
5337 | - } |
|
5338 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5655 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5339 | 5656 | { |
5340 | 5657 | $value = $matches[1] == '1' ? true : false; |
5341 | 5658 | $str = substr($str, 4); |
5342 | - } |
|
5343 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5659 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5344 | 5660 | { |
5345 | 5661 | $value = (int)$matches[1]; |
5346 | 5662 | $str = $matches[2]; |
5347 | - } |
|
5348 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5663 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5349 | 5664 | { |
5350 | 5665 | $value = (float)$matches[1]; |
5351 | 5666 | $str = $matches[3]; |
5352 | - } |
|
5353 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5667 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5354 | 5668 | { |
5355 | 5669 | $value = substr($matches[2], 0, (int)$matches[1]); |
5356 | 5670 | $str = substr($matches[2], (int)$matches[1] + 2); |
5357 | - } |
|
5358 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5671 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5359 | 5672 | { |
5360 | 5673 | $expectedLength = (int)$matches[1]; |
5361 | 5674 | $str = $matches[2]; |
5362 | 5675 | } |
5363 | 5676 | |
5364 | 5677 | // Object or unknown/malformed type. |
5365 | - else |
|
5366 | - return false; |
|
5678 | + else { |
|
5679 | + return false; |
|
5680 | + } |
|
5367 | 5681 | |
5368 | 5682 | switch($state) |
5369 | 5683 | { |
@@ -5391,8 +5705,9 @@ discard block |
||
5391 | 5705 | if($type == '}') |
5392 | 5706 | { |
5393 | 5707 | // Array size is less than expected. |
5394 | - if(count($list) < end($expected)) |
|
5395 | - return false; |
|
5708 | + if(count($list) < end($expected)) { |
|
5709 | + return false; |
|
5710 | + } |
|
5396 | 5711 | |
5397 | 5712 | unset($list); |
5398 | 5713 | $list = &$stack[count($stack)-1]; |
@@ -5401,8 +5716,9 @@ discard block |
||
5401 | 5716 | // Go to terminal state if we're at the end of the root array. |
5402 | 5717 | array_pop($expected); |
5403 | 5718 | |
5404 | - if(count($expected) == 0) |
|
5405 | - $state = 1; |
|
5719 | + if(count($expected) == 0) { |
|
5720 | + $state = 1; |
|
5721 | + } |
|
5406 | 5722 | |
5407 | 5723 | break; |
5408 | 5724 | } |
@@ -5410,8 +5726,9 @@ discard block |
||
5410 | 5726 | if($type == 'i' || $type == 's') |
5411 | 5727 | { |
5412 | 5728 | // Array size exceeds expected length. |
5413 | - if(count($list) >= end($expected)) |
|
5414 | - return false; |
|
5729 | + if(count($list) >= end($expected)) { |
|
5730 | + return false; |
|
5731 | + } |
|
5415 | 5732 | |
5416 | 5733 | $key = $value; |
5417 | 5734 | $state = 3; |
@@ -5445,8 +5762,9 @@ discard block |
||
5445 | 5762 | } |
5446 | 5763 | |
5447 | 5764 | // Trailing data in input. |
5448 | - if(!empty($str)) |
|
5449 | - return false; |
|
5765 | + if(!empty($str)) { |
|
5766 | + return false; |
|
5767 | + } |
|
5450 | 5768 | |
5451 | 5769 | return $data; |
5452 | 5770 | } |
@@ -5469,8 +5787,9 @@ discard block |
||
5469 | 5787 | |
5470 | 5788 | $out = _safe_unserialize($str); |
5471 | 5789 | |
5472 | - if (isset($mbIntEnc)) |
|
5473 | - mb_internal_encoding($mbIntEnc); |
|
5790 | + if (isset($mbIntEnc)) { |
|
5791 | + mb_internal_encoding($mbIntEnc); |
|
5792 | + } |
|
5474 | 5793 | |
5475 | 5794 | return $out; |
5476 | 5795 | } |
@@ -5485,12 +5804,14 @@ discard block |
||
5485 | 5804 | function smf_chmod($file, $value = 0) |
5486 | 5805 | { |
5487 | 5806 | // No file? no checks! |
5488 | - if (empty($file)) |
|
5489 | - return false; |
|
5807 | + if (empty($file)) { |
|
5808 | + return false; |
|
5809 | + } |
|
5490 | 5810 | |
5491 | 5811 | // Already writable? |
5492 | - if (is_writable($file)) |
|
5493 | - return true; |
|
5812 | + if (is_writable($file)) { |
|
5813 | + return true; |
|
5814 | + } |
|
5494 | 5815 | |
5495 | 5816 | // Do we have a file or a dir? |
5496 | 5817 | $isDir = is_dir($file); |
@@ -5506,10 +5827,9 @@ discard block |
||
5506 | 5827 | { |
5507 | 5828 | $isWritable = true; |
5508 | 5829 | break; |
5830 | + } else { |
|
5831 | + @chmod($file, $val); |
|
5509 | 5832 | } |
5510 | - |
|
5511 | - else |
|
5512 | - @chmod($file, $val); |
|
5513 | 5833 | } |
5514 | 5834 | |
5515 | 5835 | return $isWritable; |
@@ -5528,8 +5848,9 @@ discard block |
||
5528 | 5848 | global $txt; |
5529 | 5849 | |
5530 | 5850 | // Come on... |
5531 | - if (empty($json) || !is_string($json)) |
|
5532 | - return array(); |
|
5851 | + if (empty($json) || !is_string($json)) { |
|
5852 | + return array(); |
|
5853 | + } |
|
5533 | 5854 | |
5534 | 5855 | $returnArray = @json_decode($json, $returnAsArray); |
5535 | 5856 | |
@@ -5567,11 +5888,11 @@ discard block |
||
5567 | 5888 | $jsonDebug = $jsonDebug[0]; |
5568 | 5889 | loadLanguage('Errors'); |
5569 | 5890 | |
5570 | - if (!empty($jsonDebug)) |
|
5571 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5572 | - |
|
5573 | - else |
|
5574 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5891 | + if (!empty($jsonDebug)) { |
|
5892 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5893 | + } else { |
|
5894 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
5895 | + } |
|
5575 | 5896 | |
5576 | 5897 | // Everyone expects an array. |
5577 | 5898 | return array(); |
@@ -5601,8 +5922,9 @@ discard block |
||
5601 | 5922 | global $db_show_debug, $modSettings; |
5602 | 5923 | |
5603 | 5924 | // Defensive programming anyone? |
5604 | - if (empty($data)) |
|
5605 | - return false; |
|
5925 | + if (empty($data)) { |
|
5926 | + return false; |
|
5927 | + } |
|
5606 | 5928 | |
5607 | 5929 | // Don't need extra stuff... |
5608 | 5930 | $db_show_debug = false; |
@@ -5610,11 +5932,11 @@ discard block |
||
5610 | 5932 | // Kill anything else. |
5611 | 5933 | ob_end_clean(); |
5612 | 5934 | |
5613 | - if (!empty($modSettings['CompressedOutput'])) |
|
5614 | - @ob_start('ob_gzhandler'); |
|
5615 | - |
|
5616 | - else |
|
5617 | - ob_start(); |
|
5935 | + if (!empty($modSettings['CompressedOutput'])) { |
|
5936 | + @ob_start('ob_gzhandler'); |
|
5937 | + } else { |
|
5938 | + ob_start(); |
|
5939 | + } |
|
5618 | 5940 | |
5619 | 5941 | // Set the header. |
5620 | 5942 | header($type); |
@@ -5646,8 +5968,9 @@ discard block |
||
5646 | 5968 | static $done = false; |
5647 | 5969 | |
5648 | 5970 | // If we don't need to do anything, don't |
5649 | - if (!$update && $done) |
|
5650 | - return; |
|
5971 | + if (!$update && $done) { |
|
5972 | + return; |
|
5973 | + } |
|
5651 | 5974 | |
5652 | 5975 | // Should we get a new copy of the official list of TLDs? |
5653 | 5976 | if ($update) |
@@ -5656,8 +5979,9 @@ discard block |
||
5656 | 5979 | $tlds = fetch_web_data('https://data.iana.org/TLD/tlds-alpha-by-domain.txt'); |
5657 | 5980 | |
5658 | 5981 | // If the Internet Assigned Numbers Authority can't be reached, the Internet is gone. We're probably running on a server hidden in a bunker deep underground to protect it from marauding bandits roaming on the surface. We don't want to waste precious electricity on pointlessly repeating background tasks, so we'll wait until the next regularly scheduled update to see if civilization has been restored. |
5659 | - if ($tlds === false) |
|
5660 | - $postapocalypticNightmare = true; |
|
5982 | + if ($tlds === false) { |
|
5983 | + $postapocalypticNightmare = true; |
|
5984 | + } |
|
5661 | 5985 | } |
5662 | 5986 | // If we aren't updating and the regex is valid, we're done |
5663 | 5987 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -5672,10 +5996,11 @@ discard block |
||
5672 | 5996 | // Clean $tlds and convert it to an array |
5673 | 5997 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
5674 | 5998 | $line = trim($line); |
5675 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
5676 | - return false; |
|
5677 | - else |
|
5678 | - return true; |
|
5999 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
6000 | + return false; |
|
6001 | + } else { |
|
6002 | + return true; |
|
6003 | + } |
|
5679 | 6004 | }); |
5680 | 6005 | |
5681 | 6006 | // Convert Punycode to Unicode |
@@ -5729,8 +6054,9 @@ discard block |
||
5729 | 6054 | $idx += $digit * $w; |
5730 | 6055 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
5731 | 6056 | |
5732 | - if ($digit < $t) |
|
5733 | - break; |
|
6057 | + if ($digit < $t) { |
|
6058 | + break; |
|
6059 | + } |
|
5734 | 6060 | |
5735 | 6061 | $w = (int) ($w * ($base - $t)); |
5736 | 6062 | } |
@@ -5739,8 +6065,9 @@ discard block |
||
5739 | 6065 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
5740 | 6066 | $delta += intval($delta / ($deco_len + 1)); |
5741 | 6067 | |
5742 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
5743 | - $delta = intval($delta / ($base - $tmin)); |
|
6068 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
6069 | + $delta = intval($delta / ($base - $tmin)); |
|
6070 | + } |
|
5744 | 6071 | |
5745 | 6072 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
5746 | 6073 | $is_first = false; |
@@ -5749,8 +6076,9 @@ discard block |
||
5749 | 6076 | |
5750 | 6077 | if ($deco_len > 0) |
5751 | 6078 | { |
5752 | - for ($i = $deco_len; $i > $idx; $i--) |
|
5753 | - $decoded[$i] = $decoded[($i - 1)]; |
|
6079 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
6080 | + $decoded[$i] = $decoded[($i - 1)]; |
|
6081 | + } |
|
5754 | 6082 | } |
5755 | 6083 | $decoded[$idx++] = $char; |
5756 | 6084 | } |
@@ -5758,24 +6086,29 @@ discard block |
||
5758 | 6086 | foreach ($decoded as $k => $v) |
5759 | 6087 | { |
5760 | 6088 | // 7bit are transferred literally |
5761 | - if ($v < 128) |
|
5762 | - $output .= chr($v); |
|
6089 | + if ($v < 128) { |
|
6090 | + $output .= chr($v); |
|
6091 | + } |
|
5763 | 6092 | |
5764 | 6093 | // 2 bytes |
5765 | - elseif ($v < (1 << 11)) |
|
5766 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6094 | + elseif ($v < (1 << 11)) { |
|
6095 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6096 | + } |
|
5767 | 6097 | |
5768 | 6098 | // 3 bytes |
5769 | - elseif ($v < (1 << 16)) |
|
5770 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6099 | + elseif ($v < (1 << 16)) { |
|
6100 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6101 | + } |
|
5771 | 6102 | |
5772 | 6103 | // 4 bytes |
5773 | - elseif ($v < (1 << 21)) |
|
5774 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6104 | + elseif ($v < (1 << 21)) { |
|
6105 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6106 | + } |
|
5775 | 6107 | |
5776 | 6108 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
5777 | - else |
|
5778 | - $output .= $safe_char; |
|
6109 | + else { |
|
6110 | + $output .= $safe_char; |
|
6111 | + } |
|
5779 | 6112 | } |
5780 | 6113 | |
5781 | 6114 | $output_parts[] = $output; |
@@ -5869,8 +6202,7 @@ discard block |
||
5869 | 6202 | |
5870 | 6203 | $strlen = 'mb_strlen'; |
5871 | 6204 | $substr = 'mb_substr'; |
5872 | - } |
|
5873 | - else |
|
6205 | + } else |
|
5874 | 6206 | { |
5875 | 6207 | $strlen = $smcFunc['strlen']; |
5876 | 6208 | $substr = $smcFunc['substr']; |
@@ -5884,20 +6216,21 @@ discard block |
||
5884 | 6216 | |
5885 | 6217 | $first = $substr($string, 0, 1); |
5886 | 6218 | |
5887 | - if (empty($index[$first])) |
|
5888 | - $index[$first] = array(); |
|
6219 | + if (empty($index[$first])) { |
|
6220 | + $index[$first] = array(); |
|
6221 | + } |
|
5889 | 6222 | |
5890 | 6223 | if ($strlen($string) > 1) |
5891 | 6224 | { |
5892 | 6225 | // Sanity check on recursion |
5893 | - if ($depth > 99) |
|
5894 | - $index[$first][$substr($string, 1)] = ''; |
|
5895 | - |
|
5896 | - else |
|
5897 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6226 | + if ($depth > 99) { |
|
6227 | + $index[$first][$substr($string, 1)] = ''; |
|
6228 | + } else { |
|
6229 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6230 | + } |
|
6231 | + } else { |
|
6232 | + $index[$first][''] = ''; |
|
5898 | 6233 | } |
5899 | - else |
|
5900 | - $index[$first][''] = ''; |
|
5901 | 6234 | |
5902 | 6235 | $depth--; |
5903 | 6236 | return $index; |
@@ -5920,9 +6253,9 @@ discard block |
||
5920 | 6253 | $key_regex = preg_quote($key, $delim); |
5921 | 6254 | $new_key = $key; |
5922 | 6255 | |
5923 | - if (empty($value)) |
|
5924 | - $sub_regex = ''; |
|
5925 | - else |
|
6256 | + if (empty($value)) { |
|
6257 | + $sub_regex = ''; |
|
6258 | + } else |
|
5926 | 6259 | { |
5927 | 6260 | $sub_regex = $index_to_regex($value, $delim); |
5928 | 6261 | |
@@ -5930,22 +6263,22 @@ discard block |
||
5930 | 6263 | { |
5931 | 6264 | $new_key_array = explode('(?'.'>', $sub_regex); |
5932 | 6265 | $new_key .= $new_key_array[0]; |
6266 | + } else { |
|
6267 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5933 | 6268 | } |
5934 | - else |
|
5935 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5936 | 6269 | } |
5937 | 6270 | |
5938 | - if ($depth > 1) |
|
5939 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
5940 | - else |
|
6271 | + if ($depth > 1) { |
|
6272 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
6273 | + } else |
|
5941 | 6274 | { |
5942 | 6275 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
5943 | 6276 | { |
5944 | 6277 | $regex[$new_key] = $key_regex . $sub_regex; |
5945 | 6278 | unset($index[$key]); |
6279 | + } else { |
|
6280 | + break; |
|
5946 | 6281 | } |
5947 | - else |
|
5948 | - break; |
|
5949 | 6282 | } |
5950 | 6283 | } |
5951 | 6284 | |
@@ -5954,10 +6287,11 @@ discard block |
||
5954 | 6287 | $l1 = $strlen($k1); |
5955 | 6288 | $l2 = $strlen($k2); |
5956 | 6289 | |
5957 | - if ($l1 == $l2) |
|
5958 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
5959 | - else |
|
5960 | - return $l1 > $l2 ? -1 : 1; |
|
6290 | + if ($l1 == $l2) { |
|
6291 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6292 | + } else { |
|
6293 | + return $l1 > $l2 ? -1 : 1; |
|
6294 | + } |
|
5961 | 6295 | }); |
5962 | 6296 | |
5963 | 6297 | $depth--; |
@@ -5968,15 +6302,18 @@ discard block |
||
5968 | 6302 | $index = array(); |
5969 | 6303 | $regexes = array(); |
5970 | 6304 | |
5971 | - foreach ($strings as $string) |
|
5972 | - $index = $add_string_to_index($string, $index); |
|
6305 | + foreach ($strings as $string) { |
|
6306 | + $index = $add_string_to_index($string, $index); |
|
6307 | + } |
|
5973 | 6308 | |
5974 | - while (!empty($index)) |
|
5975 | - $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6309 | + while (!empty($index)) { |
|
6310 | + $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6311 | + } |
|
5976 | 6312 | |
5977 | 6313 | // Restore PHP's internal character encoding to whatever it was originally |
5978 | - if (!empty($current_encoding)) |
|
5979 | - mb_internal_encoding($current_encoding); |
|
6314 | + if (!empty($current_encoding)) { |
|
6315 | + mb_internal_encoding($current_encoding); |
|
6316 | + } |
|
5980 | 6317 | |
5981 | 6318 | return $regexes; |
5982 | 6319 | } |
@@ -555,7 +555,7 @@ |
||
555 | 555 | 'subject' => $row_liked_message['subject'], |
556 | 556 | 'num' => $row_liked_message['likes'], |
557 | 557 | 'href' => $scripturl . '?msg=' . $row_liked_message['id_msg'], |
558 | - 'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>' |
|
558 | + 'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] . '">' . $row_liked_message['subject'] . '</a>' |
|
559 | 559 | ); |
560 | 560 | |
561 | 561 | if ($max_liked_message < $row_liked_message['likes']) |
@@ -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 | * Display some useful/interesting board statistics. |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | |
31 | 32 | isAllowedTo('view_stats'); |
32 | 33 | // Page disabled - redirect them out |
33 | - if (empty($modSettings['trackStats'])) |
|
34 | - fatal_lang_error('feature_disabled', true); |
|
34 | + if (empty($modSettings['trackStats'])) { |
|
35 | + fatal_lang_error('feature_disabled', true); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | if (!empty($_REQUEST['expand'])) |
37 | 39 | { |
@@ -39,31 +41,34 @@ discard block |
||
39 | 41 | |
40 | 42 | $month = (int) substr($_REQUEST['expand'], 4); |
41 | 43 | $year = (int) substr($_REQUEST['expand'], 0, 4); |
42 | - if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) |
|
43 | - $_SESSION['expanded_stats'][$year][] = $month; |
|
44 | - } |
|
45 | - elseif (!empty($_REQUEST['collapse'])) |
|
44 | + if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) { |
|
45 | + $_SESSION['expanded_stats'][$year][] = $month; |
|
46 | + } |
|
47 | + } elseif (!empty($_REQUEST['collapse'])) |
|
46 | 48 | { |
47 | 49 | $context['robot_no_index'] = true; |
48 | 50 | |
49 | 51 | $month = (int) substr($_REQUEST['collapse'], 4); |
50 | 52 | $year = (int) substr($_REQUEST['collapse'], 0, 4); |
51 | - if (!empty($_SESSION['expanded_stats'][$year])) |
|
52 | - $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
53 | + if (!empty($_SESSION['expanded_stats'][$year])) { |
|
54 | + $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
55 | + } |
|
53 | 56 | } |
54 | 57 | |
55 | 58 | // Handle the XMLHttpRequest. |
56 | 59 | if (isset($_REQUEST['xml'])) |
57 | 60 | { |
58 | 61 | // Collapsing stats only needs adjustments of the session variables. |
59 | - if (!empty($_REQUEST['collapse'])) |
|
60 | - obExit(false); |
|
62 | + if (!empty($_REQUEST['collapse'])) { |
|
63 | + obExit(false); |
|
64 | + } |
|
61 | 65 | |
62 | 66 | $context['sub_template'] = 'stats'; |
63 | 67 | $context['yearly'] = array(); |
64 | 68 | |
65 | - if (empty($month) || empty($year)) |
|
66 | - return; |
|
69 | + if (empty($month) || empty($year)) { |
|
70 | + return; |
|
71 | + } |
|
67 | 72 | |
68 | 73 | getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month)); |
69 | 74 | $context['yearly'][$year]['months'][$month]['date'] = array( |
@@ -220,8 +225,9 @@ discard block |
||
220 | 225 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
221 | 226 | ); |
222 | 227 | |
223 | - if ($max_num_posts < $row_members['posts']) |
|
224 | - $max_num_posts = $row_members['posts']; |
|
228 | + if ($max_num_posts < $row_members['posts']) { |
|
229 | + $max_num_posts = $row_members['posts']; |
|
230 | + } |
|
225 | 231 | } |
226 | 232 | $smcFunc['db_free_result']($members_result); |
227 | 233 | |
@@ -257,8 +263,9 @@ discard block |
||
257 | 263 | 'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['name'] . '</a>' |
258 | 264 | ); |
259 | 265 | |
260 | - if ($max_num_posts < $row_board['num_posts']) |
|
261 | - $max_num_posts = $row_board['num_posts']; |
|
266 | + if ($max_num_posts < $row_board['num_posts']) { |
|
267 | + $max_num_posts = $row_board['num_posts']; |
|
268 | + } |
|
262 | 269 | } |
263 | 270 | $smcFunc['db_free_result']($boards_result); |
264 | 271 | |
@@ -284,12 +291,13 @@ discard block |
||
284 | 291 | ) |
285 | 292 | ); |
286 | 293 | $topic_ids = array(); |
287 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
288 | - $topic_ids[] = $row['id_topic']; |
|
294 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
295 | + $topic_ids[] = $row['id_topic']; |
|
296 | + } |
|
289 | 297 | $smcFunc['db_free_result']($request); |
298 | + } else { |
|
299 | + $topic_ids = array(); |
|
290 | 300 | } |
291 | - else |
|
292 | - $topic_ids = array(); |
|
293 | 301 | |
294 | 302 | // Topic replies top 10. |
295 | 303 | $topic_reply_result = $smcFunc['db_query']('', ' |
@@ -329,8 +337,9 @@ discard block |
||
329 | 337 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0">' . $row_topic_reply['subject'] . '</a>' |
330 | 338 | ); |
331 | 339 | |
332 | - if ($max_num_replies < $row_topic_reply['num_replies']) |
|
333 | - $max_num_replies = $row_topic_reply['num_replies']; |
|
340 | + if ($max_num_replies < $row_topic_reply['num_replies']) { |
|
341 | + $max_num_replies = $row_topic_reply['num_replies']; |
|
342 | + } |
|
334 | 343 | } |
335 | 344 | $smcFunc['db_free_result']($topic_reply_result); |
336 | 345 | |
@@ -354,12 +363,13 @@ discard block |
||
354 | 363 | ) |
355 | 364 | ); |
356 | 365 | $topic_ids = array(); |
357 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
358 | - $topic_ids[] = $row['id_topic']; |
|
366 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
367 | + $topic_ids[] = $row['id_topic']; |
|
368 | + } |
|
359 | 369 | $smcFunc['db_free_result']($request); |
370 | + } else { |
|
371 | + $topic_ids = array(); |
|
360 | 372 | } |
361 | - else |
|
362 | - $topic_ids = array(); |
|
363 | 373 | |
364 | 374 | // Topic views top 10. |
365 | 375 | $topic_view_result = $smcFunc['db_query']('', ' |
@@ -399,8 +409,9 @@ discard block |
||
399 | 409 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>' |
400 | 410 | ); |
401 | 411 | |
402 | - if ($max_num < $row_topic_views['num_views']) |
|
403 | - $max_num = $row_topic_views['num_views']; |
|
412 | + if ($max_num < $row_topic_views['num_views']) { |
|
413 | + $max_num = $row_topic_views['num_views']; |
|
414 | + } |
|
404 | 415 | } |
405 | 416 | $smcFunc['db_free_result']($topic_view_result); |
406 | 417 | |
@@ -425,15 +436,17 @@ discard block |
||
425 | 436 | ) |
426 | 437 | ); |
427 | 438 | $members = array(); |
428 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
429 | - $members[$row['id_member_started']] = $row['hits']; |
|
439 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
440 | + $members[$row['id_member_started']] = $row['hits']; |
|
441 | + } |
|
430 | 442 | $smcFunc['db_free_result']($request); |
431 | 443 | |
432 | 444 | cache_put_data('stats_top_starters', $members, 360); |
433 | 445 | } |
434 | 446 | |
435 | - if (empty($members)) |
|
436 | - $members = array(0 => 0); |
|
447 | + if (empty($members)) { |
|
448 | + $members = array(0 => 0); |
|
449 | + } |
|
437 | 450 | |
438 | 451 | // Topic poster top 10. |
439 | 452 | $members_result = $smcFunc['db_query']('', ' |
@@ -458,8 +471,9 @@ discard block |
||
458 | 471 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
459 | 472 | ); |
460 | 473 | |
461 | - if ($max_num < $members[$row_members['id_member']]) |
|
462 | - $max_num = $members[$row_members['id_member']]; |
|
474 | + if ($max_num < $members[$row_members['id_member']]) { |
|
475 | + $max_num = $members[$row_members['id_member']]; |
|
476 | + } |
|
463 | 477 | } |
464 | 478 | ksort($context['stats_blocks']['starters']); |
465 | 479 | $smcFunc['db_free_result']($members_result); |
@@ -488,8 +502,9 @@ discard block |
||
488 | 502 | while ($row_members = $smcFunc['db_fetch_assoc']($members_result)) |
489 | 503 | { |
490 | 504 | $temp2[] = (int) $row_members['id_member']; |
491 | - if (count($context['stats_blocks']['time_online']) >= 10) |
|
492 | - continue; |
|
505 | + if (count($context['stats_blocks']['time_online']) >= 10) { |
|
506 | + continue; |
|
507 | + } |
|
493 | 508 | |
494 | 509 | // Figure out the days, hours and minutes. |
495 | 510 | $timeDays = floor($row_members['total_time_logged_in'] / 86400); |
@@ -497,10 +512,12 @@ discard block |
||
497 | 512 | |
498 | 513 | // Figure out which things to show... (days, hours, minutes, etc.) |
499 | 514 | $timelogged = ''; |
500 | - if ($timeDays > 0) |
|
501 | - $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
502 | - if ($timeHours > 0) |
|
503 | - $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
515 | + if ($timeDays > 0) { |
|
516 | + $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
517 | + } |
|
518 | + if ($timeHours > 0) { |
|
519 | + $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
520 | + } |
|
504 | 521 | $timelogged .= floor(($row_members['total_time_logged_in'] % 3600) / 60) . $txt['totalTimeLogged7']; |
505 | 522 | |
506 | 523 | $context['stats_blocks']['time_online'][] = array( |
@@ -512,17 +529,20 @@ discard block |
||
512 | 529 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
513 | 530 | ); |
514 | 531 | |
515 | - if ($max_time_online < $row_members['total_time_logged_in']) |
|
516 | - $max_time_online = $row_members['total_time_logged_in']; |
|
532 | + if ($max_time_online < $row_members['total_time_logged_in']) { |
|
533 | + $max_time_online = $row_members['total_time_logged_in']; |
|
534 | + } |
|
517 | 535 | } |
518 | 536 | $smcFunc['db_free_result']($members_result); |
519 | 537 | |
520 | - foreach ($context['stats_blocks']['time_online'] as $i => $member) |
|
521 | - $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
538 | + foreach ($context['stats_blocks']['time_online'] as $i => $member) { |
|
539 | + $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
540 | + } |
|
522 | 541 | |
523 | 542 | // Cache the ones we found for a bit, just so we don't have to look again. |
524 | - if ($temp !== $temp2) |
|
525 | - cache_put_data('stats_total_time_members', $temp2, 480); |
|
543 | + if ($temp !== $temp2) { |
|
544 | + cache_put_data('stats_total_time_members', $temp2, 480); |
|
545 | + } |
|
526 | 546 | |
527 | 547 | // Likes. |
528 | 548 | if (!empty($modSettings['enable_likes'])) |
@@ -558,13 +578,15 @@ discard block |
||
558 | 578 | 'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>' |
559 | 579 | ); |
560 | 580 | |
561 | - if ($max_liked_message < $row_liked_message['likes']) |
|
562 | - $max_liked_message = $row_liked_message['likes']; |
|
581 | + if ($max_liked_message < $row_liked_message['likes']) { |
|
582 | + $max_liked_message = $row_liked_message['likes']; |
|
583 | + } |
|
563 | 584 | } |
564 | 585 | $smcFunc['db_free_result']($liked_messages); |
565 | 586 | |
566 | - foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) |
|
567 | - $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
587 | + foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) { |
|
588 | + $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
589 | + } |
|
568 | 590 | |
569 | 591 | // Liked users top 10. |
570 | 592 | $context['stats_blocks']['liked_users'] = array(); |
@@ -595,14 +617,16 @@ discard block |
||
595 | 617 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_liked_users['liked_user'] . '">' . $row_liked_users['real_name'] . '</a>', |
596 | 618 | ); |
597 | 619 | |
598 | - if ($max_liked_users < $row_liked_users['count']) |
|
599 | - $max_liked_users = $row_liked_users['count']; |
|
620 | + if ($max_liked_users < $row_liked_users['count']) { |
|
621 | + $max_liked_users = $row_liked_users['count']; |
|
622 | + } |
|
600 | 623 | } |
601 | 624 | |
602 | 625 | $smcFunc['db_free_result']($liked_users); |
603 | 626 | |
604 | - foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) |
|
605 | - $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
627 | + foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) { |
|
628 | + $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
629 | + } |
|
606 | 630 | } |
607 | 631 | |
608 | 632 | // Activity by month. |
@@ -620,8 +644,8 @@ discard block |
||
620 | 644 | $ID_MONTH = $row_months['stats_year'] . sprintf('%02d', $row_months['stats_month']); |
621 | 645 | $expanded = !empty($_SESSION['expanded_stats'][$row_months['stats_year']]) && in_array($row_months['stats_month'], $_SESSION['expanded_stats'][$row_months['stats_year']]); |
622 | 646 | |
623 | - if (!isset($context['yearly'][$row_months['stats_year']])) |
|
624 | - $context['yearly'][$row_months['stats_year']] = array( |
|
647 | + if (!isset($context['yearly'][$row_months['stats_year']])) { |
|
648 | + $context['yearly'][$row_months['stats_year']] = array( |
|
625 | 649 | 'year' => $row_months['stats_year'], |
626 | 650 | 'new_topics' => 0, |
627 | 651 | 'new_posts' => 0, |
@@ -633,6 +657,7 @@ discard block |
||
633 | 657 | 'expanded' => false, |
634 | 658 | 'current_year' => $row_months['stats_year'] == date('Y'), |
635 | 659 | ); |
660 | + } |
|
636 | 661 | |
637 | 662 | $context['yearly'][$row_months['stats_year']]['months'][(int) $row_months['stats_month']] = array( |
638 | 663 | 'id' => $ID_MONTH, |
@@ -678,26 +703,30 @@ discard block |
||
678 | 703 | $context['yearly'][$year]['hits'] = comma_format($data['hits']); |
679 | 704 | |
680 | 705 | // Keep a list of collapsed years. |
681 | - if (!$data['expanded'] && !$data['current_year']) |
|
682 | - $context['collapsed_years'][] = $year; |
|
706 | + if (!$data['expanded'] && !$data['current_year']) { |
|
707 | + $context['collapsed_years'][] = $year; |
|
708 | + } |
|
683 | 709 | } |
684 | 710 | |
685 | - if (empty($_SESSION['expanded_stats'])) |
|
686 | - return; |
|
711 | + if (empty($_SESSION['expanded_stats'])) { |
|
712 | + return; |
|
713 | + } |
|
687 | 714 | |
688 | 715 | $condition_text = array(); |
689 | 716 | $condition_params = array(); |
690 | - foreach ($_SESSION['expanded_stats'] as $year => $months) |
|
691 | - if (!empty($months)) |
|
717 | + foreach ($_SESSION['expanded_stats'] as $year => $months) { |
|
718 | + if (!empty($months)) |
|
692 | 719 | { |
693 | 720 | $condition_text[] = 'YEAR(date) = {int:year_' . $year . '} AND MONTH(date) IN ({array_int:months_' . $year . '})'; |
721 | + } |
|
694 | 722 | $condition_params['year_' . $year] = $year; |
695 | 723 | $condition_params['months_' . $year] = $months; |
696 | 724 | } |
697 | 725 | |
698 | 726 | // No daily stats to even look at? |
699 | - if (empty($condition_text)) |
|
700 | - return; |
|
727 | + if (empty($condition_text)) { |
|
728 | + return; |
|
729 | + } |
|
701 | 730 | |
702 | 731 | getDailyStats(implode(' OR ', $condition_text), $condition_params); |
703 | 732 | |
@@ -723,8 +752,8 @@ discard block |
||
723 | 752 | ORDER BY stats_day ASC', |
724 | 753 | $condition_parameters |
725 | 754 | ); |
726 | - while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) |
|
727 | - $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
755 | + while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) { |
|
756 | + $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
728 | 757 | 'day' => sprintf('%02d', $row_days['stats_day']), |
729 | 758 | 'month' => sprintf('%02d', $row_days['stats_month']), |
730 | 759 | 'year' => $row_days['stats_year'], |
@@ -734,6 +763,7 @@ discard block |
||
734 | 763 | 'most_members_online' => comma_format($row_days['most_on']), |
735 | 764 | 'hits' => comma_format($row_days['hits']) |
736 | 765 | ); |
766 | + } |
|
737 | 767 | $smcFunc['db_free_result']($days_result); |
738 | 768 | } |
739 | 769 | |
@@ -751,16 +781,19 @@ discard block |
||
751 | 781 | global $modSettings, $user_info, $forum_version, $sourcedir; |
752 | 782 | |
753 | 783 | // First, is it disabled? |
754 | - if (empty($modSettings['enable_sm_stats']) || empty($modSettings['sm_stats_key'])) |
|
755 | - die(); |
|
784 | + if (empty($modSettings['enable_sm_stats']) || empty($modSettings['sm_stats_key'])) { |
|
785 | + die(); |
|
786 | + } |
|
756 | 787 | |
757 | 788 | // Are we saying who we are, and are we right? (OR an admin) |
758 | - if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['sm_stats_key'])) |
|
759 | - die(); |
|
789 | + if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['sm_stats_key'])) { |
|
790 | + die(); |
|
791 | + } |
|
760 | 792 | |
761 | 793 | // Verify the referer... |
762 | - if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) |
|
763 | - die(); |
|
794 | + if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) { |
|
795 | + die(); |
|
796 | + } |
|
764 | 797 | |
765 | 798 | // Get some server versions. |
766 | 799 | require_once($sourcedir . '/Subs-Admin.php'); |
@@ -786,16 +819,17 @@ discard block |
||
786 | 819 | ); |
787 | 820 | |
788 | 821 | // Encode all the data, for security. |
789 | - foreach ($stats_to_send as $k => $v) |
|
790 | - $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v); |
|
822 | + foreach ($stats_to_send as $k => $v) { |
|
823 | + $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v); |
|
824 | + } |
|
791 | 825 | |
792 | 826 | // Turn this into the query string! |
793 | 827 | $stats_to_send = implode('&', $stats_to_send); |
794 | 828 | |
795 | 829 | // If we're an admin, just plonk them out. |
796 | - if ($user_info['is_admin']) |
|
797 | - echo $stats_to_send; |
|
798 | - else |
|
830 | + if ($user_info['is_admin']) { |
|
831 | + echo $stats_to_send; |
|
832 | + } else |
|
799 | 833 | { |
800 | 834 | // Connect to the collection script. |
801 | 835 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'class' => 'centercol', |
257 | 257 | ), |
258 | 258 | 'data' => array( |
259 | - 'function' => function ($entry) |
|
259 | + 'function' => function($entry) |
|
260 | 260 | { |
261 | 261 | return '<input type="checkbox" class="input_check" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>'; |
262 | 262 | }, |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | if (empty($entries[$k]['action_text'])) |
639 | 639 | $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
640 | 640 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
641 | - function ($matches) use ($entries, $k) |
|
641 | + function($matches) use ($entries, $k) |
|
642 | 642 | { |
643 | 643 | return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : ''; |
644 | 644 | }, $entries[$k]['action_text']); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
32 | 33 | |
33 | 34 | // Are we looking at the moderation log or the administration log. |
34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
35 | - if ($context['log_type'] == 3) |
|
36 | - isAllowedTo('admin_forum'); |
|
36 | + if ($context['log_type'] == 3) { |
|
37 | + isAllowedTo('admin_forum'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
41 | - else |
|
42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
43 | + } else { |
|
44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
45 | + } |
|
43 | 46 | |
44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
69 | 72 | |
70 | - } |
|
71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
72 | 74 | { |
73 | 75 | checkSession(); |
74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
115 | 117 | ); |
116 | 118 | |
117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
119 | - else |
|
120 | - $search_params_string = $search_params['string']; |
|
119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
121 | + } else { |
|
122 | + $search_params_string = $search_params['string']; |
|
123 | + } |
|
121 | 124 | |
122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
124 | - else |
|
125 | - $search_params_type = $search_params['type']; |
|
125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
127 | + } else { |
|
128 | + $search_params_type = $search_params['type']; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
128 | 132 | $search_params = array( |
@@ -297,13 +301,14 @@ discard block |
||
297 | 301 | $context['sub_template'] = 'show_list'; |
298 | 302 | $context['default_list'] = 'moderation_log_list'; |
299 | 303 | |
300 | - if (isset($context['moderation_menu_name'])) |
|
301 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
304 | + if (isset($context['moderation_menu_name'])) { |
|
305 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
302 | 306 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
303 | 307 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
304 | 308 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
305 | 309 | ); |
306 | -} |
|
310 | + } |
|
311 | + } |
|
307 | 312 | |
308 | 313 | /** |
309 | 314 | * Get the number of mod log entries. |
@@ -407,30 +412,35 @@ discard block |
||
407 | 412 | // Add on some of the column stuff info |
408 | 413 | if (!empty($row['id_board'])) |
409 | 414 | { |
410 | - if ($row['action'] == 'move') |
|
411 | - $row['extra']['board_to'] = $row['id_board']; |
|
412 | - else |
|
413 | - $row['extra']['board'] = $row['id_board']; |
|
415 | + if ($row['action'] == 'move') { |
|
416 | + $row['extra']['board_to'] = $row['id_board']; |
|
417 | + } else { |
|
418 | + $row['extra']['board'] = $row['id_board']; |
|
419 | + } |
|
414 | 420 | } |
415 | 421 | |
416 | - if (!empty($row['id_topic'])) |
|
417 | - $row['extra']['topic'] = $row['id_topic']; |
|
418 | - if (!empty($row['id_msg'])) |
|
419 | - $row['extra']['message'] = $row['id_msg']; |
|
422 | + if (!empty($row['id_topic'])) { |
|
423 | + $row['extra']['topic'] = $row['id_topic']; |
|
424 | + } |
|
425 | + if (!empty($row['id_msg'])) { |
|
426 | + $row['extra']['message'] = $row['id_msg']; |
|
427 | + } |
|
420 | 428 | |
421 | 429 | // Is this associated with a topic? |
422 | - if (isset($row['extra']['topic'])) |
|
423 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
424 | - if (isset($row['extra']['new_topic'])) |
|
425 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
430 | + if (isset($row['extra']['topic'])) { |
|
431 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
432 | + } |
|
433 | + if (isset($row['extra']['new_topic'])) { |
|
434 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
435 | + } |
|
426 | 436 | |
427 | 437 | // How about a member? |
428 | 438 | if (isset($row['extra']['member'])) |
429 | 439 | { |
430 | 440 | // Guests don't have names! |
431 | - if (empty($row['extra']['member'])) |
|
432 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
433 | - else |
|
441 | + if (empty($row['extra']['member'])) { |
|
442 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
443 | + } else |
|
434 | 444 | { |
435 | 445 | // Try to find it... |
436 | 446 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -438,35 +448,42 @@ discard block |
||
438 | 448 | } |
439 | 449 | |
440 | 450 | // Associated with a board? |
441 | - if (isset($row['extra']['board_to'])) |
|
442 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
443 | - if (isset($row['extra']['board_from'])) |
|
444 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
445 | - if (isset($row['extra']['board'])) |
|
446 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
451 | + if (isset($row['extra']['board_to'])) { |
|
452 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
453 | + } |
|
454 | + if (isset($row['extra']['board_from'])) { |
|
455 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
456 | + } |
|
457 | + if (isset($row['extra']['board'])) { |
|
458 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
459 | + } |
|
447 | 460 | |
448 | 461 | // A message? |
449 | - if (isset($row['extra']['message'])) |
|
450 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
462 | + if (isset($row['extra']['message'])) { |
|
463 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
464 | + } |
|
451 | 465 | |
452 | 466 | // IP Info? |
453 | - if (isset($row['extra']['ip_range'])) |
|
454 | - if ($seeIP) |
|
467 | + if (isset($row['extra']['ip_range'])) { |
|
468 | + if ($seeIP) |
|
455 | 469 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
456 | - else |
|
457 | - $row['extra']['ip_range'] = $txt['logged']; |
|
470 | + } else { |
|
471 | + $row['extra']['ip_range'] = $txt['logged']; |
|
472 | + } |
|
458 | 473 | |
459 | 474 | // Email? |
460 | - if (isset($row['extra']['email'])) |
|
461 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
475 | + if (isset($row['extra']['email'])) { |
|
476 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
477 | + } |
|
462 | 478 | |
463 | 479 | // Bans are complex. |
464 | 480 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
465 | 481 | { |
466 | 482 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
467 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
468 | - if (isset($row['extra'][$type])) |
|
483 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
484 | + if (isset($row['extra'][$type])) |
|
469 | 485 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
486 | + } |
|
470 | 487 | } |
471 | 488 | |
472 | 489 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -502,12 +519,13 @@ discard block |
||
502 | 519 | foreach ($boards[$row['id_board']] as $action) |
503 | 520 | { |
504 | 521 | // Make the board number into a link - dealing with moving too. |
505 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
506 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
507 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
508 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
509 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
510 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
522 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
523 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
524 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
525 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
526 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
527 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
528 | + } |
|
511 | 529 | } |
512 | 530 | } |
513 | 531 | $smcFunc['db_free_result']($request); |
@@ -541,10 +559,11 @@ discard block |
||
541 | 559 | ); |
542 | 560 | |
543 | 561 | // Make the topic number into a link - dealing with splitting too. |
544 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
545 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
546 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
547 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
562 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
563 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
564 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
565 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
566 | + } |
|
548 | 567 | } |
549 | 568 | } |
550 | 569 | $smcFunc['db_free_result']($request); |
@@ -577,8 +596,9 @@ discard block |
||
577 | 596 | ); |
578 | 597 | |
579 | 598 | // Make the message number into a link. |
580 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
581 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
599 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
600 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
601 | + } |
|
582 | 602 | } |
583 | 603 | } |
584 | 604 | $smcFunc['db_free_result']($request); |
@@ -618,25 +638,29 @@ discard block |
||
618 | 638 | foreach ($entries as $k => $entry) |
619 | 639 | { |
620 | 640 | // Make any message info links so its easier to go find that message. |
621 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
622 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
641 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
642 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
643 | + } |
|
623 | 644 | |
624 | 645 | // Mark up any deleted members, topics and boards. |
625 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
626 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
646 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
647 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
627 | 648 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
649 | + } |
|
628 | 650 | |
629 | 651 | if (isset($entry['extra']['report'])) |
630 | 652 | { |
631 | 653 | // Member profile reports go in a different area |
632 | - if (stristr($entry['action'], 'user_report')) |
|
633 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
634 | - else |
|
635 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
654 | + if (stristr($entry['action'], 'user_report')) { |
|
655 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
656 | + } else { |
|
657 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
658 | + } |
|
636 | 659 | } |
637 | 660 | |
638 | - if (empty($entries[$k]['action_text'])) |
|
639 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
661 | + if (empty($entries[$k]['action_text'])) { |
|
662 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
663 | + } |
|
640 | 664 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
641 | 665 | function ($matches) use ($entries, $k) |
642 | 666 | { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
94 | 94 | |
95 | - $pg_tables = array('pg_catalog','information_schema'); |
|
95 | + $pg_tables = array('pg_catalog', 'information_schema'); |
|
96 | 96 | |
97 | 97 | $request = $smcFunc['db_query']('', ' |
98 | 98 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | { |
370 | 370 | static $ver; |
371 | 371 | |
372 | - if(!empty($ver)) |
|
372 | + if (!empty($ver)) |
|
373 | 373 | return $ver; |
374 | 374 | |
375 | 375 | global $smcFunc; |
@@ -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 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -32,7 +33,8 @@ discard block |
||
32 | 33 | 'db_get_version' => 'smf_db_get_version', |
33 | 34 | 'db_get_engine' => 'smf_db_get_engine', |
34 | 35 | ); |
35 | -} |
|
36 | + } |
|
37 | + } |
|
36 | 38 | |
37 | 39 | /** |
38 | 40 | * Backup $table to $backup_table. |
@@ -48,13 +50,14 @@ discard block |
||
48 | 50 | |
49 | 51 | // Do we need to drop it first? |
50 | 52 | $tables = smf_db_list_tables(false, $backup_table); |
51 | - if (!empty($tables)) |
|
52 | - $smcFunc['db_query']('', ' |
|
53 | + if (!empty($tables)) { |
|
54 | + $smcFunc['db_query']('', ' |
|
53 | 55 | DROP TABLE {raw:backup_table}', |
54 | 56 | array( |
55 | 57 | 'backup_table' => $backup_table, |
56 | 58 | ) |
57 | 59 | ); |
60 | + } |
|
58 | 61 | |
59 | 62 | /** |
60 | 63 | * @todo Should we create backups of sequences as well? |
@@ -117,8 +120,9 @@ discard block |
||
117 | 120 | ) |
118 | 121 | ); |
119 | 122 | |
120 | - if (!$request) |
|
121 | - return -1; |
|
123 | + if (!$request) { |
|
124 | + return -1; |
|
125 | + } |
|
122 | 126 | |
123 | 127 | $request = $smcFunc['db_query']('', ' |
124 | 128 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -136,11 +140,12 @@ discard block |
||
136 | 140 | $row = $smcFunc['db_fetch_assoc']($request); |
137 | 141 | $smcFunc['db_free_result']($request); |
138 | 142 | |
139 | - if (isset($row['size'])) |
|
140 | - return ($old_size - $row['size']) / 1024; |
|
141 | - else |
|
142 | - return 0; |
|
143 | -} |
|
143 | + if (isset($row['size'])) { |
|
144 | + return ($old_size - $row['size']) / 1024; |
|
145 | + } else { |
|
146 | + return 0; |
|
147 | + } |
|
148 | + } |
|
144 | 149 | |
145 | 150 | /** |
146 | 151 | * This function lists all tables in the database. |
@@ -167,8 +172,9 @@ discard block |
||
167 | 172 | ); |
168 | 173 | |
169 | 174 | $tables = array(); |
170 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
171 | - $tables[] = $row[0]; |
|
175 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
176 | + $tables[] = $row[0]; |
|
177 | + } |
|
172 | 178 | $smcFunc['db_free_result']($request); |
173 | 179 | |
174 | 180 | return $tables; |
@@ -209,12 +215,14 @@ discard block |
||
209 | 215 | ); |
210 | 216 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
211 | 217 | { |
212 | - if ($row['data_type'] == 'character varying') |
|
213 | - $row['data_type'] = 'varchar'; |
|
214 | - elseif ($row['data_type'] == 'character') |
|
215 | - $row['data_type'] = 'char'; |
|
216 | - if ($row['character_maximum_length']) |
|
217 | - $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
218 | + if ($row['data_type'] == 'character varying') { |
|
219 | + $row['data_type'] = 'varchar'; |
|
220 | + } elseif ($row['data_type'] == 'character') { |
|
221 | + $row['data_type'] = 'char'; |
|
222 | + } |
|
223 | + if ($row['character_maximum_length']) { |
|
224 | + $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
225 | + } |
|
218 | 226 | |
219 | 227 | // Make the CREATE for this column. |
220 | 228 | $schema_create .= ' "' . $row['column_name'] . '" ' . $row['data_type'] . ($row['is_nullable'] != 'YES' ? ' NOT NULL' : ''); |
@@ -265,13 +273,14 @@ discard block |
||
265 | 273 | { |
266 | 274 | if ($row['is_primary']) |
267 | 275 | { |
268 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
269 | - continue; |
|
276 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
277 | + continue; |
|
278 | + } |
|
270 | 279 | |
271 | 280 | $index_create .= $crlf . 'ALTER TABLE ' . $tableName . ' ADD PRIMARY KEY ("' . $matches[1] . '");'; |
281 | + } else { |
|
282 | + $index_create .= $crlf . $row['inddef'] . ';'; |
|
272 | 283 | } |
273 | - else |
|
274 | - $index_create .= $crlf . $row['inddef'] . ';'; |
|
275 | 284 | } |
276 | 285 | $smcFunc['db_free_result']($result); |
277 | 286 | |
@@ -289,8 +298,9 @@ discard block |
||
289 | 298 | { |
290 | 299 | static $ver; |
291 | 300 | |
292 | - if(!empty($ver)) |
|
293 | - return $ver; |
|
301 | + if(!empty($ver)) { |
|
302 | + return $ver; |
|
303 | + } |
|
294 | 304 | |
295 | 305 | global $smcFunc; |
296 | 306 |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | - * Determine if the browser is Opera or not |
|
105 | - * @return boolean Whether or not this is Opera |
|
106 | - */ |
|
104 | + * Determine if the browser is Opera or not |
|
105 | + * @return boolean Whether or not this is Opera |
|
106 | + */ |
|
107 | 107 | function isOpera() |
108 | 108 | { |
109 | 109 | if (!isset($this->_browsers['is_opera'])) |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | - * Determine if the browser is IE or not |
|
116 | - * @return boolean true Whether or not the browser is IE |
|
117 | - */ |
|
115 | + * Determine if the browser is IE or not |
|
116 | + * @return boolean true Whether or not the browser is IE |
|
117 | + */ |
|
118 | 118 | function isIe() |
119 | 119 | { |
120 | 120 | // I'm IE, Yes I'm the real IE; All you other IEs are just imitating. |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | - * Determine if the browser is IE11 or not |
|
128 | - * @return boolean Whether or not the browser is IE11 |
|
129 | - */ |
|
127 | + * Determine if the browser is IE11 or not |
|
128 | + * @return boolean Whether or not the browser is IE11 |
|
129 | + */ |
|
130 | 130 | function isIe11() |
131 | 131 | { |
132 | 132 | // IE11 is a bit different than earlier versions |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | - * Determine if the browser is Edge or not |
|
141 | - * @return boolean Whether or not the browser is Edge |
|
142 | - */ |
|
140 | + * Determine if the browser is Edge or not |
|
141 | + * @return boolean Whether or not the browser is Edge |
|
142 | + */ |
|
143 | 143 | function isEdge() |
144 | 144 | { |
145 | 145 | if (!isset($this->_browsers['is_edge'])) |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | - * Determine if the browser is a Webkit based one or not |
|
152 | - * @return boolean Whether or not this is a Webkit-based browser |
|
153 | - */ |
|
151 | + * Determine if the browser is a Webkit based one or not |
|
152 | + * @return boolean Whether or not this is a Webkit-based browser |
|
153 | + */ |
|
154 | 154 | function isWebkit() |
155 | 155 | { |
156 | 156 | if (!isset($this->_browsers['is_webkit'])) |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
162 | - * Determine if the browser is Firefox or one of its variants |
|
163 | - * @return boolean Whether or not this is Firefox (or one of its variants) |
|
164 | - */ |
|
162 | + * Determine if the browser is Firefox or one of its variants |
|
163 | + * @return boolean Whether or not this is Firefox (or one of its variants) |
|
164 | + */ |
|
165 | 165 | function isFirefox() |
166 | 166 | { |
167 | 167 | if (!isset($this->_browsers['is_firefox'])) |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | - * Determine if the browser is WebTv or not |
|
174 | - * @return boolean Whether or not this is WebTV |
|
175 | - */ |
|
173 | + * Determine if the browser is WebTv or not |
|
174 | + * @return boolean Whether or not this is WebTV |
|
175 | + */ |
|
176 | 176 | function isWebTv() |
177 | 177 | { |
178 | 178 | if (!isset($this->_browsers['is_web_tv'])) |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
184 | - * Determine if the browser is konqueror or not |
|
185 | - * @return boolean Whether or not this is Konqueror |
|
186 | - */ |
|
184 | + * Determine if the browser is konqueror or not |
|
185 | + * @return boolean Whether or not this is Konqueror |
|
186 | + */ |
|
187 | 187 | function isKonqueror() |
188 | 188 | { |
189 | 189 | if (!isset($this->_browsers['is_konqueror'])) |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
195 | - * Determine if the browser is Gecko or not |
|
196 | - * @return boolean Whether or not this is a Gecko-based browser |
|
197 | - */ |
|
195 | + * Determine if the browser is Gecko or not |
|
196 | + * @return boolean Whether or not this is a Gecko-based browser |
|
197 | + */ |
|
198 | 198 | function isGecko() |
199 | 199 | { |
200 | 200 | if (!isset($this->_browsers['is_gecko'])) |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | - * Determine if the browser is Opera Mini or not |
|
207 | - * @return boolean Whether or not this is Opera Mini |
|
208 | - */ |
|
206 | + * Determine if the browser is Opera Mini or not |
|
207 | + * @return boolean Whether or not this is Opera Mini |
|
208 | + */ |
|
209 | 209 | function isOperaMini() |
210 | 210 | { |
211 | 211 | if (!isset($this->_browsers['is_opera_mini'])) |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
219 | - * Determine if the browser is Opera Mobile or not |
|
220 | - * @return boolean Whether or not this is Opera Mobile |
|
221 | - */ |
|
219 | + * Determine if the browser is Opera Mobile or not |
|
220 | + * @return boolean Whether or not this is Opera Mobile |
|
221 | + */ |
|
222 | 222 | function isOperaMobi() |
223 | 223 | { |
224 | 224 | if (!isset($this->_browsers['is_opera_mobi'])) |
@@ -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 | * Class browser_detector |
@@ -55,20 +56,25 @@ discard block |
||
55 | 56 | $this->_browsers['needs_size_fix'] = false; |
56 | 57 | |
57 | 58 | // One at a time, one at a time, and in this order too |
58 | - if ($this->isOpera()) |
|
59 | - $this->setupOpera(); |
|
59 | + if ($this->isOpera()) { |
|
60 | + $this->setupOpera(); |
|
61 | + } |
|
60 | 62 | // Meh... |
61 | - elseif ($this->isEdge()) |
|
62 | - $this->setupEdge(); |
|
63 | + elseif ($this->isEdge()) { |
|
64 | + $this->setupEdge(); |
|
65 | + } |
|
63 | 66 | // Them webkits need to be set up too |
64 | - elseif ($this->isWebkit()) |
|
65 | - $this->setupWebkit(); |
|
67 | + elseif ($this->isWebkit()) { |
|
68 | + $this->setupWebkit(); |
|
69 | + } |
|
66 | 70 | // We may have work to do on Firefox... |
67 | - elseif ($this->isFirefox()) |
|
68 | - $this->setupFirefox(); |
|
71 | + elseif ($this->isFirefox()) { |
|
72 | + $this->setupFirefox(); |
|
73 | + } |
|
69 | 74 | // Old friend, old frenemy |
70 | - elseif ($this->isIe()) |
|
71 | - $this->setupIe(); |
|
75 | + elseif ($this->isIe()) { |
|
76 | + $this->setupIe(); |
|
77 | + } |
|
72 | 78 | |
73 | 79 | // Just a few mobile checks |
74 | 80 | $this->isOperaMini(); |
@@ -84,11 +90,12 @@ discard block |
||
84 | 90 | $this->_browsers['possibly_robot'] = !empty($user_info['possibly_robot']); |
85 | 91 | |
86 | 92 | // Robots shouldn't be logging in or registering. So, they aren't a bot. Better to be wrong than sorry (or people won't be able to log in!), anyway. |
87 | - if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) |
|
88 | - $this->_browsers['possibly_robot'] = false; |
|
93 | + if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) { |
|
94 | + $this->_browsers['possibly_robot'] = false; |
|
95 | + } |
|
96 | + } else { |
|
97 | + $this->_browsers['possibly_robot'] = false; |
|
89 | 98 | } |
90 | - else |
|
91 | - $this->_browsers['possibly_robot'] = false; |
|
92 | 99 | |
93 | 100 | // Fill out the historical array as needed to support old mods that don't use isBrowser |
94 | 101 | $this->fillInformation(); |
@@ -106,8 +113,9 @@ discard block |
||
106 | 113 | */ |
107 | 114 | function isOpera() |
108 | 115 | { |
109 | - if (!isset($this->_browsers['is_opera'])) |
|
110 | - $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
116 | + if (!isset($this->_browsers['is_opera'])) { |
|
117 | + $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
118 | + } |
|
111 | 119 | return $this->_browsers['is_opera']; |
112 | 120 | } |
113 | 121 | |
@@ -118,8 +126,9 @@ discard block |
||
118 | 126 | function isIe() |
119 | 127 | { |
120 | 128 | // I'm IE, Yes I'm the real IE; All you other IEs are just imitating. |
121 | - if (!isset($this->_browsers['is_ie'])) |
|
122 | - $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
129 | + if (!isset($this->_browsers['is_ie'])) { |
|
130 | + $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
131 | + } |
|
123 | 132 | return $this->_browsers['is_ie']; |
124 | 133 | } |
125 | 134 | |
@@ -131,8 +140,9 @@ discard block |
||
131 | 140 | { |
132 | 141 | // IE11 is a bit different than earlier versions |
133 | 142 | // The isGecko() part is to ensure we get this right... |
134 | - if (!isset($this->_browsers['is_ie11'])) |
|
135 | - $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
143 | + if (!isset($this->_browsers['is_ie11'])) { |
|
144 | + $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
145 | + } |
|
136 | 146 | return $this->_browsers['is_ie11']; |
137 | 147 | } |
138 | 148 | |
@@ -142,8 +152,9 @@ discard block |
||
142 | 152 | */ |
143 | 153 | function isEdge() |
144 | 154 | { |
145 | - if (!isset($this->_browsers['is_edge'])) |
|
146 | - $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
155 | + if (!isset($this->_browsers['is_edge'])) { |
|
156 | + $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
157 | + } |
|
147 | 158 | return $this->_browsers['is_edge']; |
148 | 159 | } |
149 | 160 | |
@@ -153,8 +164,9 @@ discard block |
||
153 | 164 | */ |
154 | 165 | function isWebkit() |
155 | 166 | { |
156 | - if (!isset($this->_browsers['is_webkit'])) |
|
157 | - $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
167 | + if (!isset($this->_browsers['is_webkit'])) { |
|
168 | + $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
169 | + } |
|
158 | 170 | return $this->_browsers['is_webkit']; |
159 | 171 | } |
160 | 172 | |
@@ -164,8 +176,9 @@ discard block |
||
164 | 176 | */ |
165 | 177 | function isFirefox() |
166 | 178 | { |
167 | - if (!isset($this->_browsers['is_firefox'])) |
|
168 | - $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
179 | + if (!isset($this->_browsers['is_firefox'])) { |
|
180 | + $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
181 | + } |
|
169 | 182 | return $this->_browsers['is_firefox']; |
170 | 183 | } |
171 | 184 | |
@@ -175,8 +188,9 @@ discard block |
||
175 | 188 | */ |
176 | 189 | function isWebTv() |
177 | 190 | { |
178 | - if (!isset($this->_browsers['is_web_tv'])) |
|
179 | - $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
191 | + if (!isset($this->_browsers['is_web_tv'])) { |
|
192 | + $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
193 | + } |
|
180 | 194 | return $this->_browsers['is_web_tv']; |
181 | 195 | } |
182 | 196 | |
@@ -186,8 +200,9 @@ discard block |
||
186 | 200 | */ |
187 | 201 | function isKonqueror() |
188 | 202 | { |
189 | - if (!isset($this->_browsers['is_konqueror'])) |
|
190 | - $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
203 | + if (!isset($this->_browsers['is_konqueror'])) { |
|
204 | + $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
205 | + } |
|
191 | 206 | return $this->_browsers['is_konqueror']; |
192 | 207 | } |
193 | 208 | |
@@ -197,8 +212,9 @@ discard block |
||
197 | 212 | */ |
198 | 213 | function isGecko() |
199 | 214 | { |
200 | - if (!isset($this->_browsers['is_gecko'])) |
|
201 | - $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
215 | + if (!isset($this->_browsers['is_gecko'])) { |
|
216 | + $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
217 | + } |
|
202 | 218 | return $this->_browsers['is_gecko']; |
203 | 219 | } |
204 | 220 | |
@@ -208,10 +224,12 @@ discard block |
||
208 | 224 | */ |
209 | 225 | function isOperaMini() |
210 | 226 | { |
211 | - if (!isset($this->_browsers['is_opera_mini'])) |
|
212 | - $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
213 | - if ($this->_browsers['is_opera_mini']) |
|
214 | - $this->_is_mobile = true; |
|
227 | + if (!isset($this->_browsers['is_opera_mini'])) { |
|
228 | + $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
229 | + } |
|
230 | + if ($this->_browsers['is_opera_mini']) { |
|
231 | + $this->_is_mobile = true; |
|
232 | + } |
|
215 | 233 | return $this->_browsers['is_opera_mini']; |
216 | 234 | } |
217 | 235 | |
@@ -221,10 +239,12 @@ discard block |
||
221 | 239 | */ |
222 | 240 | function isOperaMobi() |
223 | 241 | { |
224 | - if (!isset($this->_browsers['is_opera_mobi'])) |
|
225 | - $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
226 | - if ($this->_browsers['is_opera_mobi']) |
|
227 | - $this->_is_mobile = true; |
|
242 | + if (!isset($this->_browsers['is_opera_mobi'])) { |
|
243 | + $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
244 | + } |
|
245 | + if ($this->_browsers['is_opera_mobi']) { |
|
246 | + $this->_is_mobile = true; |
|
247 | + } |
|
228 | 248 | return $this->_browsers['is_opera_mini']; |
229 | 249 | } |
230 | 250 | |
@@ -244,8 +264,9 @@ discard block |
||
244 | 264 | ); |
245 | 265 | |
246 | 266 | // blackberry, playbook, iphone, nokia, android and ipods set a mobile flag |
247 | - if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) |
|
248 | - $this->_is_mobile = true; |
|
267 | + if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) { |
|
268 | + $this->_is_mobile = true; |
|
269 | + } |
|
249 | 270 | |
250 | 271 | // @todo what to do with the blaPad? ... for now leave it detected as Safari ... |
251 | 272 | $this->_browsers['is_safari'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false && !$this->_browsers['is_chrome'] && !$this->_browsers['is_iphone']; |
@@ -254,15 +275,17 @@ discard block |
||
254 | 275 | // if Chrome, get the major version |
255 | 276 | if ($this->_browsers['is_chrome']) |
256 | 277 | { |
257 | - if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
258 | - $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
278 | + if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
279 | + $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
280 | + } |
|
259 | 281 | } |
260 | 282 | |
261 | 283 | // or if Safari get its major version |
262 | 284 | if ($this->_browsers['is_safari']) |
263 | 285 | { |
264 | - if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
265 | - $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
286 | + if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
287 | + $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
288 | + } |
|
266 | 289 | } |
267 | 290 | } |
268 | 291 | |
@@ -291,8 +314,9 @@ discard block |
||
291 | 314 | $this->_browsers['is_ie' . ((int) $trident_match[1] + 4)] = true; |
292 | 315 | |
293 | 316 | // If trident is set, see the (if any) msie tag in the user agent matches ... if not its in some compatibility view |
294 | - if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) |
|
295 | - $this->_browsers['is_ie_compat_view'] = true; |
|
317 | + if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) { |
|
318 | + $this->_browsers['is_ie_compat_view'] = true; |
|
319 | + } |
|
296 | 320 | } |
297 | 321 | |
298 | 322 | // Detect true IE6 and IE7 and not IE in compat mode. |
@@ -326,8 +350,9 @@ discard block |
||
326 | 350 | */ |
327 | 351 | private function setupFirefox() |
328 | 352 | { |
329 | - if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
330 | - $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
353 | + if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
354 | + $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
355 | + } |
|
331 | 356 | } |
332 | 357 | |
333 | 358 | /** |
@@ -338,11 +363,13 @@ discard block |
||
338 | 363 | private function setupOpera() |
339 | 364 | { |
340 | 365 | // Opera 10+ uses the version tag at the end of the string |
341 | - if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
342 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
366 | + if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
367 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
368 | + } |
|
343 | 369 | // Opera pre 10 is supposed to uses the Opera tag alone, as do some spoofers |
344 | - elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
345 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
370 | + elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
371 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
372 | + } |
|
346 | 373 | |
347 | 374 | // Needs size fix? |
348 | 375 | $this->_browsers['needs_size_fix'] = !empty($this->_browsers['is_opera6']); |
@@ -353,8 +380,9 @@ discard block |
||
353 | 380 | */ |
354 | 381 | private function setupEdge() |
355 | 382 | { |
356 | - if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
357 | - $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
383 | + if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
384 | + $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
385 | + } |
|
358 | 386 | } |
359 | 387 | |
360 | 388 | /** |
@@ -367,9 +395,9 @@ discard block |
||
367 | 395 | { |
368 | 396 | global $context; |
369 | 397 | |
370 | - if ($this->_is_mobile) |
|
371 | - $context['browser_body_id'] = 'mobile'; |
|
372 | - else |
|
398 | + if ($this->_is_mobile) { |
|
399 | + $context['browser_body_id'] = 'mobile'; |
|
400 | + } else |
|
373 | 401 | { |
374 | 402 | // add in any specific detection conversions here if you want a special body id e.g. 'is_opera9' => 'opera9' |
375 | 403 | $browser_priority = array( |