@@ -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> |
@@ -110,9 +113,10 @@ discard block |
||
110 | 113 | ', $txt['package_db_uninstall_actions'], ': |
111 | 114 | <ul>'; |
112 | 115 | |
113 | - foreach ($context['database_changes'] as $change) |
|
114 | - echo ' |
|
116 | + foreach ($context['database_changes'] as $change) { |
|
117 | + echo ' |
|
115 | 118 | <li>', $change, '</li>'; |
119 | + } |
|
116 | 120 | echo ' |
117 | 121 | </ul> |
118 | 122 | </div> |
@@ -122,14 +126,14 @@ discard block |
||
122 | 126 | echo ' |
123 | 127 | <div class="information">'; |
124 | 128 | |
125 | - if (empty($context['actions']) && empty($context['database_changes'])) |
|
126 | - echo ' |
|
129 | + if (empty($context['actions']) && empty($context['database_changes'])) { |
|
130 | + echo ' |
|
127 | 131 | <br> |
128 | 132 | <div class="errorbox"> |
129 | 133 | ', $txt['corrupt_compatible'], ' |
130 | 134 | </div> |
131 | 135 | </div>'; |
132 | - else |
|
136 | + } else |
|
133 | 137 | { |
134 | 138 | echo ' |
135 | 139 | ', $txt['perform_actions'], ' |
@@ -229,9 +233,10 @@ discard block |
||
229 | 233 | <tr class="title_bar"> |
230 | 234 | <td></td> |
231 | 235 | <td>'; |
232 | - if (!empty($context['themes_locked'])) |
|
233 | - echo ' |
|
236 | + if (!empty($context['themes_locked'])) { |
|
237 | + echo ' |
|
234 | 238 | <input type="hidden" name="custom_theme[]" value="', $id, '">'; |
239 | + } |
|
235 | 240 | echo ' |
236 | 241 | <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' : '', '> |
237 | 242 | </td> |
@@ -372,14 +377,15 @@ discard block |
||
372 | 377 | </script>'; |
373 | 378 | |
374 | 379 | // And a bit more for database changes. |
375 | - if (!empty($context['database_changes'])) |
|
376 | - echo ' |
|
380 | + if (!empty($context['database_changes'])) { |
|
381 | + echo ' |
|
377 | 382 | <script> |
378 | 383 | var database_changes_area = document.getElementById(\'db_changes_div\'); |
379 | 384 | var db_vis = false; |
380 | 385 | database_changes_area.style.display = "none"; |
381 | 386 | </script>'; |
382 | -} |
|
387 | + } |
|
388 | + } |
|
383 | 389 | |
384 | 390 | /** |
385 | 391 | * Extract package contents |
@@ -411,12 +417,12 @@ discard block |
||
411 | 417 | <h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3> |
412 | 418 | </div> |
413 | 419 | <div class="information">', $txt['package_installed_extract'], '</div>'; |
414 | - } |
|
415 | - else |
|
416 | - echo ' |
|
420 | + } else { |
|
421 | + echo ' |
|
417 | 422 | <div class="cat_bar"> |
418 | 423 | <h3 class="catbg">', $txt['package_installed_redirecting'], '</h3> |
419 | 424 | </div>'; |
425 | + } |
|
420 | 426 | |
421 | 427 | echo ' |
422 | 428 | <div class="windowbg">'; |
@@ -427,25 +433,25 @@ discard block |
||
427 | 433 | echo ' |
428 | 434 | ', $context['redirect_text'], '<br><br> |
429 | 435 | <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>'; |
430 | - } |
|
431 | - elseif ($context['uninstalling']) |
|
432 | - echo ' |
|
436 | + } elseif ($context['uninstalling']) { |
|
437 | + echo ' |
|
433 | 438 | ', $txt['package_uninstall_done']; |
434 | - elseif ($context['install_finished']) |
|
439 | + } elseif ($context['install_finished']) |
|
435 | 440 | { |
436 | - if ($context['extract_type'] == 'avatar') |
|
437 | - echo ' |
|
441 | + if ($context['extract_type'] == 'avatar') { |
|
442 | + echo ' |
|
438 | 443 | ', $txt['avatars_extracted']; |
439 | - elseif ($context['extract_type'] == 'language') |
|
440 | - echo ' |
|
444 | + } elseif ($context['extract_type'] == 'language') { |
|
445 | + echo ' |
|
441 | 446 | ', $txt['language_extracted']; |
442 | - else |
|
443 | - echo ' |
|
447 | + } else { |
|
448 | + echo ' |
|
444 | 449 | ', $txt['package_installed_done']; |
445 | - } |
|
446 | - else |
|
447 | - echo ' |
|
450 | + } |
|
451 | + } else { |
|
452 | + echo ' |
|
448 | 453 | ', $txt['corrupt_compatible']; |
454 | + } |
|
449 | 455 | |
450 | 456 | echo ' |
451 | 457 | </div>'; |
@@ -479,9 +485,10 @@ discard block |
||
479 | 485 | <div class="windowbg"> |
480 | 486 | <ol>'; |
481 | 487 | |
482 | - foreach ($context['files'] as $fileinfo) |
|
483 | - echo ' |
|
488 | + foreach ($context['files'] as $fileinfo) { |
|
489 | + echo ' |
|
484 | 490 | <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>'; |
491 | + } |
|
485 | 492 | |
486 | 493 | echo ' |
487 | 494 | </ol> |
@@ -545,9 +552,10 @@ discard block |
||
545 | 552 | </script> |
546 | 553 | <div id="yourVersion" style="display:none">', $context['forum_version'], '</div>'; |
547 | 554 | |
548 | - if (empty($modSettings['disable_smf_js'])) |
|
549 | - echo ' |
|
555 | + if (empty($modSettings['disable_smf_js'])) { |
|
556 | + echo ' |
|
550 | 557 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
558 | + } |
|
551 | 559 | |
552 | 560 | // This sets the announcements and current versions themselves ;). |
553 | 561 | echo ' |
@@ -586,12 +594,13 @@ discard block |
||
586 | 594 | } |
587 | 595 | } |
588 | 596 | |
589 | - if (!$mods_available) |
|
590 | - echo ' |
|
597 | + if (!$mods_available) { |
|
598 | + echo ' |
|
591 | 599 | <div class="noticebox">', $txt['no_packages'], '</div>'; |
592 | - else |
|
593 | - echo ' |
|
600 | + } else { |
|
601 | + echo ' |
|
594 | 602 | <br>'; |
603 | + } |
|
595 | 604 | |
596 | 605 | // the advanced (emulation) box, collapsed by default |
597 | 606 | echo ' |
@@ -680,11 +689,12 @@ discard block |
||
680 | 689 | { |
681 | 690 | global $context, $txt, $scripturl; |
682 | 691 | |
683 | - if (!empty($context['package_ftp']['error'])) |
|
684 | - echo ' |
|
692 | + if (!empty($context['package_ftp']['error'])) { |
|
693 | + echo ' |
|
685 | 694 | <div class="errorbox"> |
686 | 695 | <pre>', $context['package_ftp']['error'], '</pre> |
687 | 696 | </div>'; |
697 | + } |
|
688 | 698 | |
689 | 699 | echo ' |
690 | 700 | <div id="admin_form_wrapper"> |
@@ -765,13 +775,14 @@ discard block |
||
765 | 775 | <fieldset> |
766 | 776 | <legend>' . $txt['package_servers'] . '</legend> |
767 | 777 | <ul class="package_servers">'; |
768 | - foreach ($context['servers'] as $server) |
|
769 | - echo ' |
|
778 | + foreach ($context['servers'] as $server) { |
|
779 | + echo ' |
|
770 | 780 | <li class="flow_auto"> |
771 | 781 | <span class="floatleft">' . $server['name'] . '</span> |
772 | 782 | <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> |
773 | 783 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span> |
774 | 784 | </li>'; |
785 | + } |
|
775 | 786 | echo ' |
776 | 787 | </ul> |
777 | 788 | </fieldset> |
@@ -858,11 +869,12 @@ discard block |
||
858 | 869 | <div class="windowbg2">'; |
859 | 870 | |
860 | 871 | // No packages, as yet. |
861 | - if (empty($context['package_list'])) |
|
862 | - echo ' |
|
872 | + if (empty($context['package_list'])) { |
|
873 | + echo ' |
|
863 | 874 | <ul> |
864 | 875 | <li>', $txt['no_packages'], '</li> |
865 | 876 | </ul>'; |
877 | + } |
|
866 | 878 | // List out the packages... |
867 | 879 | else |
868 | 880 | { |
@@ -874,11 +886,12 @@ discard block |
||
874 | 886 | <li> |
875 | 887 | <strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>'; |
876 | 888 | |
877 | - if (!empty($packageSection['text'])) |
|
878 | - echo ' |
|
889 | + if (!empty($packageSection['text'])) { |
|
890 | + echo ' |
|
879 | 891 | <div class="sub_bar"> |
880 | 892 | <h3 class="subbg">', $packageSection['text'], '</h3> |
881 | 893 | </div>'; |
894 | + } |
|
882 | 895 | |
883 | 896 | echo ' |
884 | 897 | <', $context['list_type'], ' id="package_section_', $i, '" class="packages">'; |
@@ -888,13 +901,15 @@ discard block |
||
888 | 901 | echo ' |
889 | 902 | <li>'; |
890 | 903 | // Textual message. Could be empty just for a blank line... |
891 | - if ($package['is_text']) |
|
892 | - echo ' |
|
904 | + if ($package['is_text']) { |
|
905 | + echo ' |
|
893 | 906 | ', empty($package['name']) ? ' ' : $package['name']; |
907 | + } |
|
894 | 908 | // This is supposed to be a rule.. |
895 | - elseif ($package['is_line']) |
|
896 | - echo ' |
|
909 | + elseif ($package['is_line']) { |
|
910 | + echo ' |
|
897 | 911 | <hr>'; |
912 | + } |
|
898 | 913 | // A remote link. |
899 | 914 | elseif ($package['is_remote']) |
900 | 915 | { |
@@ -916,21 +931,25 @@ discard block |
||
916 | 931 | <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">'; |
917 | 932 | |
918 | 933 | // Show the mod type? |
919 | - if ($package['type'] != '') |
|
920 | - echo ' |
|
934 | + if ($package['type'] != '') { |
|
935 | + echo ' |
|
921 | 936 | <li class="package_section">', $txt['package_type'], ': ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '</li>'; |
937 | + } |
|
922 | 938 | // Show the version number? |
923 | - if ($package['version'] != '') |
|
924 | - echo ' |
|
939 | + if ($package['version'] != '') { |
|
940 | + echo ' |
|
925 | 941 | <li class="package_section">', $txt['mod_version'], ': ', $package['version'], '</li>'; |
942 | + } |
|
926 | 943 | // How 'bout the author? |
927 | - if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) |
|
928 | - echo ' |
|
944 | + if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) { |
|
945 | + echo ' |
|
929 | 946 | <li class="package_section">', $txt['mod_author'], ': ', $package['author']['link'], '</li>'; |
947 | + } |
|
930 | 948 | // The homepage.... |
931 | - if ($package['author']['website']['link'] != '') |
|
932 | - echo ' |
|
949 | + if ($package['author']['website']['link'] != '') { |
|
950 | + echo ' |
|
933 | 951 | <li class="package_section">', $txt['author_website'], ': ', $package['author']['website']['link'], '</li>'; |
952 | + } |
|
934 | 953 | |
935 | 954 | // Desciption: bleh bleh! |
936 | 955 | // Location of file: http://someplace/. |
@@ -983,8 +1002,8 @@ discard block |
||
983 | 1002 | |
984 | 1003 | foreach ($ps['items'] as $id => $package) |
985 | 1004 | { |
986 | - if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) |
|
987 | - echo ' |
|
1005 | + if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) { |
|
1006 | + echo ' |
|
988 | 1007 | var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({ |
989 | 1008 | bToggleEnabled: true, |
990 | 1009 | bCurrentlyCollapsed: true, |
@@ -999,6 +1018,7 @@ discard block |
||
999 | 1018 | } |
1000 | 1019 | ] |
1001 | 1020 | });'; |
1021 | + } |
|
1002 | 1022 | } |
1003 | 1023 | } |
1004 | 1024 | echo ' |
@@ -1039,9 +1059,10 @@ discard block |
||
1039 | 1059 | { |
1040 | 1060 | global $context, $txt, $scripturl; |
1041 | 1061 | |
1042 | - if (!empty($context['saved_successful'])) |
|
1043 | - echo ' |
|
1062 | + if (!empty($context['saved_successful'])) { |
|
1063 | + echo ' |
|
1044 | 1064 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1065 | + } |
|
1045 | 1066 | |
1046 | 1067 | echo ' |
1047 | 1068 | <div id="admincenter"> |
@@ -1103,8 +1124,9 @@ discard block |
||
1103 | 1124 | global $context, $txt; |
1104 | 1125 | |
1105 | 1126 | // Nothing to do? Brilliant! |
1106 | - if (empty($context['package_ftp'])) |
|
1107 | - return false; |
|
1127 | + if (empty($context['package_ftp'])) { |
|
1128 | + return false; |
|
1129 | + } |
|
1108 | 1130 | |
1109 | 1131 | if (empty($context['package_ftp']['form_elements_only'])) |
1110 | 1132 | { |
@@ -1113,19 +1135,21 @@ discard block |
||
1113 | 1135 | <div id="need_writable_list" class="smalltext"> |
1114 | 1136 | ', $txt['package_ftp_why_file_list'], ' |
1115 | 1137 | <ul style="display: inline;">'; |
1116 | - if (!empty($context['notwritable_files'])) |
|
1117 | - foreach ($context['notwritable_files'] as $file) |
|
1138 | + if (!empty($context['notwritable_files'])) { |
|
1139 | + foreach ($context['notwritable_files'] as $file) |
|
1118 | 1140 | echo ' |
1119 | 1141 | <li>', $file, '</li>'; |
1142 | + } |
|
1120 | 1143 | |
1121 | 1144 | echo ' |
1122 | 1145 | </ul>'; |
1123 | 1146 | |
1124 | - if (!$context['server']['is_windows']) |
|
1125 | - echo ' |
|
1147 | + if (!$context['server']['is_windows']) { |
|
1148 | + echo ' |
|
1126 | 1149 | <hr> |
1127 | 1150 | ', $txt['package_chmod_linux'], '<br /> |
1128 | 1151 | <tt># chmod a+w ', implode(' ', $context['notwritable_files']), '</tt>'; |
1152 | + } |
|
1129 | 1153 | |
1130 | 1154 | echo ' |
1131 | 1155 | </div>'; |
@@ -1136,9 +1160,10 @@ discard block |
||
1136 | 1160 | <tt id="ftp_error_message">', !empty($context['package_ftp']['error']) ? $context['package_ftp']['error'] : '', '</tt> |
1137 | 1161 | </div></div>'; |
1138 | 1162 | |
1139 | - if (!empty($context['package_ftp']['destination'])) |
|
1140 | - echo ' |
|
1163 | + if (!empty($context['package_ftp']['destination'])) { |
|
1164 | + echo ' |
|
1141 | 1165 | <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">'; |
1166 | + } |
|
1142 | 1167 | |
1143 | 1168 | echo ' |
1144 | 1169 | <fieldset> |
@@ -1171,25 +1196,28 @@ discard block |
||
1171 | 1196 | </dl> |
1172 | 1197 | </fieldset>'; |
1173 | 1198 | |
1174 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
1175 | - echo ' |
|
1199 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
1200 | + echo ' |
|
1176 | 1201 | |
1177 | 1202 | <div class="righttext" style="margin: 1ex;"> |
1178 | 1203 | <span id="test_ftp_placeholder_full"></span> |
1179 | 1204 | <input type="submit" value="', $txt['package_proceed'], '" class="button_submit"> |
1180 | 1205 | </div>'; |
1206 | + } |
|
1181 | 1207 | |
1182 | - if (!empty($context['package_ftp']['destination'])) |
|
1183 | - echo ' |
|
1208 | + if (!empty($context['package_ftp']['destination'])) { |
|
1209 | + echo ' |
|
1184 | 1210 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1185 | 1211 | </form>'; |
1212 | + } |
|
1186 | 1213 | |
1187 | 1214 | // Hide the details of the list. |
1188 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
1189 | - echo ' |
|
1215 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
1216 | + echo ' |
|
1190 | 1217 | <script> |
1191 | 1218 | document.getElementById(\'need_writable_list\').style.display = \'none\'; |
1192 | 1219 | </script>'; |
1220 | + } |
|
1193 | 1221 | |
1194 | 1222 | // Quick generate the test button. |
1195 | 1223 | echo ' |
@@ -1545,9 +1573,10 @@ discard block |
||
1545 | 1573 | <tr class="windowbg"> |
1546 | 1574 | <td width="30%"><strong>'; |
1547 | 1575 | |
1548 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
1549 | - echo ' |
|
1576 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
1577 | + echo ' |
|
1550 | 1578 | <span class="generic_icons folder"></span>'; |
1579 | + } |
|
1551 | 1580 | |
1552 | 1581 | echo ' |
1553 | 1582 | ', $name, ' |
@@ -1564,8 +1593,9 @@ discard block |
||
1564 | 1593 | </tr> |
1565 | 1594 | '; |
1566 | 1595 | |
1567 | - if (!empty($dir['contents'])) |
|
1568 | - template_permission_show_contents($name, $dir['contents'], 1); |
|
1596 | + if (!empty($dir['contents'])) { |
|
1597 | + template_permission_show_contents($name, $dir['contents'], 1); |
|
1598 | + } |
|
1569 | 1599 | } |
1570 | 1600 | |
1571 | 1601 | echo ' |
@@ -1601,13 +1631,14 @@ discard block |
||
1601 | 1631 | </fieldset>'; |
1602 | 1632 | |
1603 | 1633 | // Likely to need FTP? |
1604 | - if (empty($context['ftp_connected'])) |
|
1605 | - echo ' |
|
1634 | + if (empty($context['ftp_connected'])) { |
|
1635 | + echo ' |
|
1606 | 1636 | <p> |
1607 | 1637 | ', $txt['package_file_perms_ftp_details'], ': |
1608 | 1638 | </p> |
1609 | 1639 | ', template_control_chmod(), ' |
1610 | 1640 | <div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>'; |
1641 | + } |
|
1611 | 1642 | |
1612 | 1643 | echo ' |
1613 | 1644 | <span id="test_ftp_placeholder_full"></span> |
@@ -1616,9 +1647,10 @@ discard block |
||
1616 | 1647 | </div>'; |
1617 | 1648 | |
1618 | 1649 | // Any looks fors we've already done? |
1619 | - foreach ($context['look_for'] as $path) |
|
1620 | - echo ' |
|
1650 | + foreach ($context['look_for'] as $path) { |
|
1651 | + echo ' |
|
1621 | 1652 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
1653 | + } |
|
1622 | 1654 | echo ' |
1623 | 1655 | </form><br>'; |
1624 | 1656 | } |
@@ -1657,9 +1689,10 @@ discard block |
||
1657 | 1689 | <td class="smalltext" width="30%">' . str_repeat(' ', $level * 5), ' |
1658 | 1690 | ', (!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, "'\\") . '\');">' : ''; |
1659 | 1691 | |
1660 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
1661 | - echo ' |
|
1692 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
1693 | + echo ' |
|
1662 | 1694 | <span class="generic_icons folder"></span>'; |
1695 | + } |
|
1663 | 1696 | |
1664 | 1697 | echo ' |
1665 | 1698 | ', $name, ' |
@@ -1685,14 +1718,15 @@ discard block |
||
1685 | 1718 | } |
1686 | 1719 | |
1687 | 1720 | // We have more files to show? |
1688 | - if ($has_more) |
|
1689 | - echo ' |
|
1721 | + if ($has_more) { |
|
1722 | + echo ' |
|
1690 | 1723 | <tr class="windowbg" id="content_', $js_ident, '_more"> |
1691 | 1724 | <td class="smalltext" width="40%">' . str_repeat(' ', $level * 5), ' |
1692 | 1725 | « <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> » |
1693 | 1726 | </td> |
1694 | 1727 | <td colspan="6"></td> |
1695 | 1728 | </tr>'; |
1729 | + } |
|
1696 | 1730 | |
1697 | 1731 | if ($drawn_div) |
1698 | 1732 | { |
@@ -1700,15 +1734,17 @@ discard block |
||
1700 | 1734 | $isFound = false; |
1701 | 1735 | foreach ($context['look_for'] as $tree) |
1702 | 1736 | { |
1703 | - if (substr($tree, 0, strlen($ident)) == $ident) |
|
1704 | - $isFound = true; |
|
1737 | + if (substr($tree, 0, strlen($ident)) == $ident) { |
|
1738 | + $isFound = true; |
|
1739 | + } |
|
1705 | 1740 | } |
1706 | 1741 | |
1707 | - if ($level > 1 && !$isFound) |
|
1708 | - echo ' |
|
1742 | + if ($level > 1 && !$isFound) { |
|
1743 | + echo ' |
|
1709 | 1744 | <script> |
1710 | 1745 | expandFolder(\'', $js_ident, '\', \'\'); |
1711 | 1746 | </script>'; |
1747 | + } |
|
1712 | 1748 | } |
1713 | 1749 | } |
1714 | 1750 | |
@@ -1728,11 +1764,12 @@ discard block |
||
1728 | 1764 | <h3 class="catbg">', $txt['package_file_perms_applying'], '</h3> |
1729 | 1765 | </div>'; |
1730 | 1766 | |
1731 | - if (!empty($context['skip_ftp'])) |
|
1732 | - echo ' |
|
1767 | + if (!empty($context['skip_ftp'])) { |
|
1768 | + echo ' |
|
1733 | 1769 | <div class="errorbox"> |
1734 | 1770 | ', $txt['package_file_perms_skipping_ftp'], ' |
1735 | 1771 | </div>'; |
1772 | + } |
|
1736 | 1773 | |
1737 | 1774 | // How many have we done? |
1738 | 1775 | $remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']); |
@@ -1770,28 +1807,31 @@ discard block |
||
1770 | 1807 | <br>'; |
1771 | 1808 | |
1772 | 1809 | // Put out the right hidden data. |
1773 | - if ($context['method'] == 'individual') |
|
1774 | - echo ' |
|
1810 | + if ($context['method'] == 'individual') { |
|
1811 | + echo ' |
|
1775 | 1812 | <input type="hidden" name="custom_value" value="', $context['custom_value'], '"> |
1776 | 1813 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
1777 | 1814 | <input type="hidden" name="toProcess" value="', base64_encode(json_encode($context['to_process'])), '">'; |
1778 | - else |
|
1779 | - echo ' |
|
1815 | + } else { |
|
1816 | + echo ' |
|
1780 | 1817 | <input type="hidden" name="predefined" value="', $context['predefined_type'], '"> |
1781 | 1818 | <input type="hidden" name="fileOffset" value="', $context['file_offset'], '"> |
1782 | 1819 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
1783 | 1820 | <input type="hidden" name="dirList" value="', base64_encode(json_encode($context['directory_list'])), '"> |
1784 | 1821 | <input type="hidden" name="specialFiles" value="', base64_encode(json_encode($context['special_files'])), '">'; |
1822 | + } |
|
1785 | 1823 | |
1786 | 1824 | // Are we not using FTP for whatever reason. |
1787 | - if (!empty($context['skip_ftp'])) |
|
1788 | - echo ' |
|
1825 | + if (!empty($context['skip_ftp'])) { |
|
1826 | + echo ' |
|
1789 | 1827 | <input type="hidden" name="skip_ftp" value="1">'; |
1828 | + } |
|
1790 | 1829 | |
1791 | 1830 | // Retain state. |
1792 | - foreach ($context['back_look_data'] as $path) |
|
1793 | - echo ' |
|
1831 | + foreach ($context['back_look_data'] as $path) { |
|
1832 | + echo ' |
|
1794 | 1833 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
1834 | + } |
|
1795 | 1835 | |
1796 | 1836 | echo ' |
1797 | 1837 | <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 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get the latest posts of a forum. |
@@ -59,8 +60,9 @@ discard block |
||
59 | 60 | censorText($row['body']); |
60 | 61 | |
61 | 62 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
62 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
63 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
63 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
64 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | // Build the array. |
66 | 68 | $posts[] = array( |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | // Just send a generic message. |
77 | 77 | else |
78 | 78 | $this->setResponse(array( |
79 | - 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
79 | + 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
80 | 80 | 'type' => 'error', |
81 | 81 | 'data' => false, |
82 | 82 | )); |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | // Gotta urlencode the filename. |
405 | 405 | if ($this->_attachResults) |
406 | 406 | foreach ($this->_attachResults as $k => $v) |
407 | - $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
407 | + $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
408 | 408 | |
409 | 409 | $this->_response = array( |
410 | 410 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | ob_start(); |
432 | 432 | |
433 | 433 | // Set the header. |
434 | - header('Content-Type: application/json; charset='. $context['character_set'] .''); |
|
434 | + header('Content-Type: application/json; charset=' . $context['character_set'] . ''); |
|
435 | 435 | |
436 | 436 | echo json_encode($this->_response ? $this->_response : array()); |
437 | 437 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | class Attachments |
20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
70 | 71 | |
71 | 72 | $this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false; |
72 | 73 | |
73 | - if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) |
|
74 | - $this->{$this->_sa}(); |
|
74 | + if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) { |
|
75 | + $this->{$this->_sa}(); |
|
76 | + } |
|
75 | 77 | |
76 | 78 | // Just send a generic message. |
77 | - else |
|
78 | - $this->setResponse(array( |
|
79 | + else { |
|
80 | + $this->setResponse(array( |
|
79 | 81 | 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
80 | 82 | 'type' => 'error', |
81 | 83 | 'data' => false, |
82 | 84 | )); |
85 | + } |
|
83 | 86 | |
84 | 87 | // Back to the future, oh, to the browser! |
85 | 88 | $this->sendResponse(); |
@@ -95,12 +98,13 @@ discard block |
||
95 | 98 | $attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0; |
96 | 99 | |
97 | 100 | // Need something to work with. |
98 | - if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) |
|
99 | - return $this->setResponse(array( |
|
101 | + if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) { |
|
102 | + return $this->setResponse(array( |
|
100 | 103 | 'text' => 'attached_file_deleted_error', |
101 | 104 | 'type' => 'error', |
102 | 105 | 'data' => false, |
103 | 106 | )); |
107 | + } |
|
104 | 108 | |
105 | 109 | // Lets pass some params and see what happens :P |
106 | 110 | $affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true); |
@@ -119,19 +123,21 @@ discard block |
||
119 | 123 | public function add() |
120 | 124 | { |
121 | 125 | // You gotta be able to post attachments. |
122 | - if (!$this->_canPostAttachment) |
|
123 | - return $this->setResponse(array( |
|
126 | + if (!$this->_canPostAttachment) { |
|
127 | + return $this->setResponse(array( |
|
124 | 128 | 'text' => 'attached_file_cannot', |
125 | 129 | 'type' => 'error', |
126 | 130 | 'data' => false, |
127 | 131 | )); |
132 | + } |
|
128 | 133 | |
129 | 134 | // Process them at once! |
130 | 135 | $this->processAttachments(); |
131 | 136 | |
132 | 137 | // The attachments was created and moved the the right folder, time to update the DB. |
133 | - if (!empty($_SESSION['temp_attachments'])) |
|
134 | - $this->createAtttach(); |
|
138 | + if (!empty($_SESSION['temp_attachments'])) { |
|
139 | + $this->createAtttach(); |
|
140 | + } |
|
135 | 141 | |
136 | 142 | // Set the response. |
137 | 143 | $this->setResponse(); |
@@ -144,8 +150,9 @@ discard block |
||
144 | 150 | { |
145 | 151 | global $context, $modSettings, $smcFunc, $user_info, $txt; |
146 | 152 | |
147 | - if (!isset($_FILES['attachment']['name'])) |
|
148 | - $_FILES['attachment']['tmp_name'] = array(); |
|
153 | + if (!isset($_FILES['attachment']['name'])) { |
|
154 | + $_FILES['attachment']['tmp_name'] = array(); |
|
155 | + } |
|
149 | 156 | |
150 | 157 | // If there are attachments, calculate the total size and how many. |
151 | 158 | $context['attachments']['total_size'] = 0; |
@@ -155,25 +162,30 @@ discard block |
||
155 | 162 | if (isset($_REQUEST['msg'])) |
156 | 163 | { |
157 | 164 | $context['attachments']['quantity'] = count($context['current_attachments']); |
158 | - foreach ($context['current_attachments'] as $attachment) |
|
159 | - $context['attachments']['total_size'] += $attachment['size']; |
|
165 | + foreach ($context['current_attachments'] as $attachment) { |
|
166 | + $context['attachments']['total_size'] += $attachment['size']; |
|
167 | + } |
|
160 | 168 | } |
161 | 169 | |
162 | 170 | // A bit of house keeping first. |
163 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
164 | - unset($_SESSION['temp_attachments']); |
|
171 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
172 | + unset($_SESSION['temp_attachments']); |
|
173 | + } |
|
165 | 174 | |
166 | 175 | // Our infamous SESSION var, we are gonna have soo much fun with it! |
167 | - if (!isset($_SESSION['temp_attachments'])) |
|
168 | - $_SESSION['temp_attachments'] = array(); |
|
176 | + if (!isset($_SESSION['temp_attachments'])) { |
|
177 | + $_SESSION['temp_attachments'] = array(); |
|
178 | + } |
|
169 | 179 | |
170 | 180 | // Make sure we're uploading to the right place. |
171 | - if (!empty($modSettings['automanage_attachments'])) |
|
172 | - automanage_attachments_check_directory(); |
|
181 | + if (!empty($modSettings['automanage_attachments'])) { |
|
182 | + automanage_attachments_check_directory(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | // Is the attachments folder actually there? |
175 | - if (!empty($context['dir_creation_error'])) |
|
176 | - $this->_generalErrors[] = $context['dir_creation_error']; |
|
186 | + if (!empty($context['dir_creation_error'])) { |
|
187 | + $this->_generalErrors[] = $context['dir_creation_error']; |
|
188 | + } |
|
177 | 189 | |
178 | 190 | // The current attach folder ha some issues... |
179 | 191 | elseif (!is_dir($this->_attchDir)) |
@@ -198,13 +210,12 @@ discard block |
||
198 | 210 | ); |
199 | 211 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
200 | 212 | $smcFunc['db_free_result']($request); |
201 | - } |
|
202 | - |
|
203 | - else |
|
204 | - $context['attachments'] = array( |
|
213 | + } else { |
|
214 | + $context['attachments'] = array( |
|
205 | 215 | 'quantity' => 0, |
206 | 216 | 'total_size' => 0, |
207 | 217 | ); |
218 | + } |
|
208 | 219 | |
209 | 220 | // Check for other general errors here. |
210 | 221 | |
@@ -212,9 +223,10 @@ discard block |
||
212 | 223 | if (!empty($this->_generalErrors)) |
213 | 224 | { |
214 | 225 | // And delete the files 'cos they ain't going nowhere. |
215 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
216 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
226 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
227 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
217 | 228 | unlink($_FILES['attachment']['tmp_name'][$n]); |
229 | + } |
|
218 | 230 | |
219 | 231 | $_FILES['attachment']['tmp_name'] = array(); |
220 | 232 | |
@@ -225,26 +237,29 @@ discard block |
||
225 | 237 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
226 | 238 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
227 | 239 | { |
228 | - if ($_FILES['attachment']['name'][$n] == '') |
|
229 | - continue; |
|
240 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
241 | + continue; |
|
242 | + } |
|
230 | 243 | |
231 | 244 | // First, let's first check for PHP upload errors. |
232 | 245 | $errors = array(); |
233 | 246 | if (!empty($_FILES['attachment']['error'][$n])) |
234 | 247 | { |
235 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
236 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
237 | - |
|
238 | - else |
|
239 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
248 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
249 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
250 | + } else { |
|
251 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
252 | + } |
|
240 | 253 | |
241 | 254 | // Log this one, because... |
242 | - if ($_FILES['attachment']['error'][$n] == 6) |
|
243 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
255 | + if ($_FILES['attachment']['error'][$n] == 6) { |
|
256 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
257 | + } |
|
244 | 258 | |
245 | 259 | // Weird, no errors were cached, still fill out a generic one. |
246 | - if (empty($errors)) |
|
247 | - $errors[] = 'attach_php_error'; |
|
260 | + if (empty($errors)) { |
|
261 | + $errors[] = 'attach_php_error'; |
|
262 | + } |
|
248 | 263 | } |
249 | 264 | |
250 | 265 | // Try to move and rename the file before doing any more checks on it. |
@@ -256,8 +271,9 @@ discard block |
||
256 | 271 | { |
257 | 272 | // The reported MIME type of the attachment might not be reliable. |
258 | 273 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
259 | - if (function_exists('mime_content_type')) |
|
260 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
274 | + if (function_exists('mime_content_type')) { |
|
275 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
276 | + } |
|
261 | 277 | |
262 | 278 | $_SESSION['temp_attachments'][$attachID] = array( |
263 | 279 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -269,16 +285,18 @@ discard block |
||
269 | 285 | ); |
270 | 286 | |
271 | 287 | // Move the file to the attachments folder with a temp name for now. |
272 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
273 | - smf_chmod($destName, 0644); |
|
288 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
289 | + smf_chmod($destName, 0644); |
|
290 | + } |
|
274 | 291 | |
275 | 292 | // This is madness!! |
276 | 293 | else |
277 | 294 | { |
278 | 295 | // File couldn't be moved. |
279 | 296 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
280 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
281 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
297 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
298 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
299 | + } |
|
282 | 300 | } |
283 | 301 | } |
284 | 302 | |
@@ -291,13 +309,15 @@ discard block |
||
291 | 309 | 'errors' => $errors, |
292 | 310 | ); |
293 | 311 | |
294 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
295 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
312 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
313 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
314 | + } |
|
296 | 315 | } |
297 | 316 | |
298 | 317 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
299 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
300 | - attachmentChecks($attachID); |
|
318 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
319 | + attachmentChecks($attachID); |
|
320 | + } |
|
301 | 321 | } |
302 | 322 | |
303 | 323 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
@@ -344,14 +364,15 @@ discard block |
||
344 | 364 | |
345 | 365 | $_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID']; |
346 | 366 | |
347 | - if (!empty($attachmentOptions['thumb'])) |
|
348 | - $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
367 | + if (!empty($attachmentOptions['thumb'])) { |
|
368 | + $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
369 | + } |
|
349 | 370 | |
350 | - if ($this->_msg) |
|
351 | - assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
371 | + if ($this->_msg) { |
|
372 | + assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
373 | + } |
|
352 | 374 | } |
353 | - } |
|
354 | - else |
|
375 | + } else |
|
355 | 376 | { |
356 | 377 | // Sort out the errors for display and delete any associated files. |
357 | 378 | $log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file'); |
@@ -363,14 +384,16 @@ discard block |
||
363 | 384 | if (!is_array($error)) |
364 | 385 | { |
365 | 386 | $attachmentOptions['errors'][] = $txt[$error]; |
366 | - if (in_array($error, $log_these)) |
|
367 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
387 | + if (in_array($error, $log_these)) { |
|
388 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
389 | + } |
|
390 | + } else { |
|
391 | + $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
368 | 392 | } |
369 | - else |
|
370 | - $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
371 | 393 | } |
372 | - if (file_exists($attachment['tmp_name'])) |
|
373 | - unlink($attachment['tmp_name']); |
|
394 | + if (file_exists($attachment['tmp_name'])) { |
|
395 | + unlink($attachment['tmp_name']); |
|
396 | + } |
|
374 | 397 | } |
375 | 398 | |
376 | 399 | // Regardless of errors, pass the results. |
@@ -378,8 +401,9 @@ discard block |
||
378 | 401 | } |
379 | 402 | |
380 | 403 | // Temp save this on the db. |
381 | - if (!empty($_SESSION['already_attached'])) |
|
382 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
404 | + if (!empty($_SESSION['already_attached'])) { |
|
405 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
406 | + } |
|
383 | 407 | |
384 | 408 | unset($_SESSION['temp_attachments']); |
385 | 409 | } |
@@ -399,14 +423,16 @@ discard block |
||
399 | 423 | if ($this->_sa == 'add') |
400 | 424 | { |
401 | 425 | // Is there any generic errors? made some sense out of them! |
402 | - if ($this->_generalErrors) |
|
403 | - foreach ($this->_generalErrors as $k => $v) |
|
426 | + if ($this->_generalErrors) { |
|
427 | + foreach ($this->_generalErrors as $k => $v) |
|
404 | 428 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
429 | + } |
|
405 | 430 | |
406 | 431 | // Gotta urlencode the filename. |
407 | - if ($this->_attachResults) |
|
408 | - foreach ($this->_attachResults as $k => $v) |
|
432 | + if ($this->_attachResults) { |
|
433 | + foreach ($this->_attachResults as $k => $v) |
|
409 | 434 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
435 | + } |
|
410 | 436 | |
411 | 437 | $this->_response = array( |
412 | 438 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -415,9 +441,10 @@ discard block |
||
415 | 441 | } |
416 | 442 | |
417 | 443 | // Rest of us mere mortals gets no special treatment... |
418 | - elseif (!empty($data)) |
|
419 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
444 | + elseif (!empty($data)) { |
|
445 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
420 | 446 | $this->_response['text'] = $txt[$data['text']]; |
447 | + } |
|
421 | 448 | } |
422 | 449 | |
423 | 450 | protected function sendResponse() |
@@ -426,11 +453,11 @@ discard block |
||
426 | 453 | |
427 | 454 | ob_end_clean(); |
428 | 455 | |
429 | - if (!empty($modSettings['CompressedOutput'])) |
|
430 | - @ob_start('ob_gzhandler'); |
|
431 | - |
|
432 | - else |
|
433 | - ob_start(); |
|
456 | + if (!empty($modSettings['CompressedOutput'])) { |
|
457 | + @ob_start('ob_gzhandler'); |
|
458 | + } else { |
|
459 | + ob_start(); |
|
460 | + } |
|
434 | 461 | |
435 | 462 | // Set the header. |
436 | 463 | header('Content-Type: application/json; charset='. $context['character_set'] .''); |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
54 | 55 | return; |
55 | 56 | } |
56 | 57 | |
57 | - if (empty($modSettings['search_custom_index_config'])) |
|
58 | - return; |
|
58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
59 | + return; |
|
60 | + } |
|
59 | 61 | |
60 | 62 | $this->indexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
61 | 63 | |
@@ -118,21 +120,23 @@ discard block |
||
118 | 120 | |
119 | 121 | $subwords = text2words($word, $this->min_word_length, true); |
120 | 122 | |
121 | - if (empty($modSettings['search_force_index'])) |
|
122 | - $wordsSearch['words'][] = $word; |
|
123 | + if (empty($modSettings['search_force_index'])) { |
|
124 | + $wordsSearch['words'][] = $word; |
|
125 | + } |
|
123 | 126 | |
124 | 127 | // Excluded phrases don't benefit from being split into subwords. |
125 | - if (count($subwords) > 1 && $isExcluded) |
|
126 | - return; |
|
127 | - else |
|
128 | + if (count($subwords) > 1 && $isExcluded) { |
|
129 | + return; |
|
130 | + } else |
|
128 | 131 | { |
129 | 132 | foreach ($subwords as $subword) |
130 | 133 | { |
131 | 134 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
132 | 135 | { |
133 | 136 | $wordsSearch['indexed_words'][] = $subword; |
134 | - if ($isExcluded) |
|
135 | - $wordsExclude[] = $subword; |
|
137 | + if ($isExcluded) { |
|
138 | + $wordsExclude[] = $subword; |
|
139 | + } |
|
136 | 140 | } |
137 | 141 | } |
138 | 142 | } |
@@ -153,8 +157,9 @@ discard block |
||
153 | 157 | $query_where = array(); |
154 | 158 | $query_params = $search_data['params']; |
155 | 159 | |
156 | - if ($query_params['id_search']) |
|
157 | - $query_select['id_search'] = '{int:id_search}'; |
|
160 | + if ($query_params['id_search']) { |
|
161 | + $query_select['id_search'] = '{int:id_search}'; |
|
162 | + } |
|
158 | 163 | |
159 | 164 | $count = 0; |
160 | 165 | foreach ($words['words'] as $regularWord) |
@@ -163,30 +168,37 @@ discard block |
||
163 | 168 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
164 | 169 | } |
165 | 170 | |
166 | - if ($query_params['user_query']) |
|
167 | - $query_where[] = '{raw:user_query}'; |
|
168 | - if ($query_params['board_query']) |
|
169 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
171 | + if ($query_params['user_query']) { |
|
172 | + $query_where[] = '{raw:user_query}'; |
|
173 | + } |
|
174 | + if ($query_params['board_query']) { |
|
175 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
176 | + } |
|
170 | 177 | |
171 | - if ($query_params['topic']) |
|
172 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
173 | - if ($query_params['min_msg_id']) |
|
174 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
175 | - if ($query_params['max_msg_id']) |
|
176 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
178 | + if ($query_params['topic']) { |
|
179 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
180 | + } |
|
181 | + if ($query_params['min_msg_id']) { |
|
182 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
183 | + } |
|
184 | + if ($query_params['max_msg_id']) { |
|
185 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
186 | + } |
|
177 | 187 | |
178 | 188 | $count = 0; |
179 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
180 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
189 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
190 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
181 | 191 | { |
182 | 192 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
193 | + } |
|
183 | 194 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
184 | 195 | } |
185 | 196 | $count = 0; |
186 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
187 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
197 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
198 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
188 | 199 | { |
189 | 200 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
201 | + } |
|
190 | 202 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
191 | 203 | } |
192 | 204 | |
@@ -199,8 +211,7 @@ discard block |
||
199 | 211 | { |
200 | 212 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
201 | 213 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
202 | - } |
|
203 | - else |
|
214 | + } else |
|
204 | 215 | { |
205 | 216 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
206 | 217 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -236,16 +247,18 @@ discard block |
||
236 | 247 | $customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
237 | 248 | |
238 | 249 | $inserts = array(); |
239 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
240 | - $inserts[] = array($word, $msgOptions['id']); |
|
250 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
251 | + $inserts[] = array($word, $msgOptions['id']); |
|
252 | + } |
|
241 | 253 | |
242 | - if (!empty($inserts)) |
|
243 | - $smcFunc['db_insert']('ignore', |
|
254 | + if (!empty($inserts)) { |
|
255 | + $smcFunc['db_insert']('ignore', |
|
244 | 256 | '{db_prefix}log_search_words', |
245 | 257 | array('id_word' => 'int', 'id_msg' => 'int'), |
246 | 258 | $inserts, |
247 | 259 | array('id_word', 'id_msg') |
248 | 260 | ); |
261 | + } |
|
249 | 262 | } |
250 | 263 | |
251 | 264 | /** |
@@ -288,8 +301,9 @@ discard block |
||
288 | 301 | if (!empty($inserted_words)) |
289 | 302 | { |
290 | 303 | $inserts = array(); |
291 | - foreach ($inserted_words as $word) |
|
292 | - $inserts[] = array($word, $msgOptions['id']); |
|
304 | + foreach ($inserted_words as $word) { |
|
305 | + $inserts[] = array($word, $msgOptions['id']); |
|
306 | + } |
|
293 | 307 | $smcFunc['db_insert']('insert', |
294 | 308 | '{db_prefix}log_search_words', |
295 | 309 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Redirect to the user help ;). |
@@ -95,12 +96,13 @@ discard block |
||
95 | 96 | ); |
96 | 97 | |
97 | 98 | // Have we got a localized one? |
98 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
99 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
100 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
101 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
102 | - else |
|
103 | - $context['agreement'] = ''; |
|
99 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
100 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
101 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
102 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
103 | + } else { |
|
104 | + $context['agreement'] = ''; |
|
105 | + } |
|
104 | 106 | |
105 | 107 | // Nothing to show, so let's get out of here |
106 | 108 | if (empty($context['agreement'])) |
@@ -128,18 +130,21 @@ discard block |
||
128 | 130 | { |
129 | 131 | global $txt, $helptxt, $context, $scripturl; |
130 | 132 | |
131 | - if (!isset($_GET['help']) || !is_string($_GET['help'])) |
|
132 | - fatal_lang_error('no_access', false); |
|
133 | + if (!isset($_GET['help']) || !is_string($_GET['help'])) { |
|
134 | + fatal_lang_error('no_access', false); |
|
135 | + } |
|
133 | 136 | |
134 | - if (!isset($helptxt)) |
|
135 | - $helptxt = array(); |
|
137 | + if (!isset($helptxt)) { |
|
138 | + $helptxt = array(); |
|
139 | + } |
|
136 | 140 | |
137 | 141 | // Load the admin help language file and template. |
138 | 142 | loadLanguage('Help'); |
139 | 143 | |
140 | 144 | // Permission specific help? |
141 | - if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') |
|
142 | - loadLanguage('ManagePermissions'); |
|
145 | + if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') { |
|
146 | + loadLanguage('ManagePermissions'); |
|
147 | + } |
|
143 | 148 | |
144 | 149 | loadTemplate('Help'); |
145 | 150 | |
@@ -154,16 +159,18 @@ discard block |
||
154 | 159 | $context['sub_template'] = 'popup'; |
155 | 160 | |
156 | 161 | // What help string should be used? |
157 | - if (isset($helptxt[$_GET['help']])) |
|
158 | - $context['help_text'] = $helptxt[$_GET['help']]; |
|
159 | - elseif (isset($txt[$_GET['help']])) |
|
160 | - $context['help_text'] = $txt[$_GET['help']]; |
|
161 | - else |
|
162 | - $context['help_text'] = $_GET['help']; |
|
162 | + if (isset($helptxt[$_GET['help']])) { |
|
163 | + $context['help_text'] = $helptxt[$_GET['help']]; |
|
164 | + } elseif (isset($txt[$_GET['help']])) { |
|
165 | + $context['help_text'] = $txt[$_GET['help']]; |
|
166 | + } else { |
|
167 | + $context['help_text'] = $_GET['help']; |
|
168 | + } |
|
163 | 169 | |
164 | 170 | // Does this text contain a link that we should fill in? |
165 | - if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) |
|
166 | - $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
167 | -} |
|
171 | + if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) { |
|
172 | + $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
173 | + } |
|
174 | + } |
|
168 | 175 | |
169 | 176 | ?> |
170 | 177 | \ No newline at end of file |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function shows the board index. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | $context['canonical_url'] = $scripturl; |
35 | 36 | |
36 | 37 | // Do not let search engines index anything if there is a random thing in $_GET. |
37 | - if (!empty($_GET)) |
|
38 | - $context['robot_no_index'] = true; |
|
38 | + if (!empty($_GET)) { |
|
39 | + $context['robot_no_index'] = true; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Retrieve the categories and boards. |
41 | 43 | require_once($sourcedir . '/Subs-BoardIndex.php'); |
@@ -62,11 +64,12 @@ discard block |
||
62 | 64 | $context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions)); |
63 | 65 | } |
64 | 66 | |
65 | - if (!empty($context['latest_posts']) || !empty($context['latest_post'])) |
|
66 | - $context['info_center'][] = array( |
|
67 | + if (!empty($context['latest_posts']) || !empty($context['latest_post'])) { |
|
68 | + $context['info_center'][] = array( |
|
67 | 69 | 'tpl' => 'recent', |
68 | 70 | 'txt' => 'recent_posts', |
69 | 71 | ); |
72 | + } |
|
70 | 73 | } |
71 | 74 | |
72 | 75 | // Load the calendar? |
@@ -87,20 +90,22 @@ discard block |
||
87 | 90 | // This is used to show the "how-do-I-edit" help. |
88 | 91 | $context['calendar_can_edit'] = allowedTo('calendar_edit_any'); |
89 | 92 | |
90 | - if ($context['show_calendar']) |
|
91 | - $context['info_center'][] = array( |
|
93 | + if ($context['show_calendar']) { |
|
94 | + $context['info_center'][] = array( |
|
92 | 95 | 'tpl' => 'calendar', |
93 | 96 | 'txt' => $context['calendar_only_today'] ? 'calendar_today' : 'calendar_upcoming', |
94 | 97 | ); |
98 | + } |
|
95 | 99 | } |
96 | 100 | |
97 | 101 | // And stats. |
98 | 102 | $context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']); |
99 | - if ($settings['show_stats_index']) |
|
100 | - $context['info_center'][] = array( |
|
103 | + if ($settings['show_stats_index']) { |
|
104 | + $context['info_center'][] = array( |
|
101 | 105 | 'tpl' => 'stats', |
102 | 106 | 'txt' => 'forum_stats', |
103 | 107 | ); |
108 | + } |
|
104 | 109 | |
105 | 110 | // Now the online stuff |
106 | 111 | require_once($sourcedir . '/Subs-MembersOnline.php'); |
@@ -118,12 +123,14 @@ discard block |
||
118 | 123 | ); |
119 | 124 | |
120 | 125 | // Track most online statistics? (Subs-MembersOnline.php) |
121 | - if (!empty($modSettings['trackStats'])) |
|
122 | - trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
126 | + if (!empty($modSettings['trackStats'])) { |
|
127 | + trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
128 | + } |
|
123 | 129 | |
124 | 130 | // Are we showing all membergroups on the board index? |
125 | - if (!empty($settings['show_group_key'])) |
|
126 | - $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
131 | + if (!empty($settings['show_group_key'])) { |
|
132 | + $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
133 | + } |
|
127 | 134 | |
128 | 135 | // And back to normality. |
129 | 136 | $context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Show the database queries for debugging |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | global $scripturl, $settings, $context, $db_connection, $boarddir, $smcFunc, $txt, $db_show_debug; |
31 | 32 | |
32 | 33 | // We should have debug mode enabled, as well as something to display! |
33 | - if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) |
|
34 | - fatal_lang_error('no_access', false); |
|
34 | + if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) { |
|
35 | + fatal_lang_error('no_access', false); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Don't allow except for administrators. |
37 | 39 | isAllowedTo('admin_forum'); |
@@ -41,10 +43,11 @@ discard block |
||
41 | 43 | { |
42 | 44 | $_SESSION['view_queries'] = $_SESSION['view_queries'] == 1 ? 0 : 1; |
43 | 45 | |
44 | - if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) |
|
45 | - redirectexit(); |
|
46 | - else |
|
47 | - redirectexit($_SESSION['old_url']); |
|
46 | + if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) { |
|
47 | + redirectexit(); |
|
48 | + } else { |
|
49 | + redirectexit($_SESSION['old_url']); |
|
50 | + } |
|
48 | 51 | } |
49 | 52 | |
50 | 53 | call_integration_hook('integrate_egg_nog'); |
@@ -83,26 +86,28 @@ discard block |
||
83 | 86 | foreach ($query as $line) |
84 | 87 | { |
85 | 88 | preg_match('/^(\t*)/', $line, $temp); |
86 | - if (strlen($temp[0]) < $min_indent || $min_indent == 0) |
|
87 | - $min_indent = strlen($temp[0]); |
|
89 | + if (strlen($temp[0]) < $min_indent || $min_indent == 0) { |
|
90 | + $min_indent = strlen($temp[0]); |
|
91 | + } |
|
92 | + } |
|
93 | + foreach ($query as $l => $dummy) { |
|
94 | + $query[$l] = substr($dummy, $min_indent); |
|
88 | 95 | } |
89 | - foreach ($query as $l => $dummy) |
|
90 | - $query[$l] = substr($dummy, $min_indent); |
|
91 | 96 | $query_data['q'] = implode("\n", $query); |
92 | 97 | |
93 | 98 | // Make the filenames look a bit better. |
94 | - if (isset($query_data['f'])) |
|
95 | - $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
99 | + if (isset($query_data['f'])) { |
|
100 | + $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
101 | + } |
|
96 | 102 | |
97 | 103 | $is_select_query = substr(trim($query_data['q']), 0, 6) == 'SELECT'; |
98 | - if ($is_select_query) |
|
99 | - $select = $query_data['q']; |
|
100 | - elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
104 | + if ($is_select_query) { |
|
105 | + $select = $query_data['q']; |
|
106 | + } elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
101 | 107 | { |
102 | 108 | $is_select_query = true; |
103 | 109 | $select = $matches[1]; |
104 | - } |
|
105 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
110 | + } elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
106 | 111 | { |
107 | 112 | $is_select_query = true; |
108 | 113 | $select = $matches[1]; |
@@ -110,10 +115,11 @@ discard block |
||
110 | 115 | // Temporary tables created in earlier queries are not explainable. |
111 | 116 | if ($is_select_query) |
112 | 117 | { |
113 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
114 | - if (strpos($select, $tmp) !== false) |
|
118 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
119 | + if (strpos($select, $tmp) !== false) |
|
115 | 120 | { |
116 | 121 | $is_select_query = false; |
122 | + } |
|
117 | 123 | break; |
118 | 124 | } |
119 | 125 | } |
@@ -124,13 +130,15 @@ discard block |
||
124 | 130 | ', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars']($query_data['q']))), ' |
125 | 131 | </a><br>'; |
126 | 132 | |
127 | - if (!empty($query_data['f']) && !empty($query_data['l'])) |
|
128 | - echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
133 | + if (!empty($query_data['f']) && !empty($query_data['l'])) { |
|
134 | + echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
135 | + } |
|
129 | 136 | |
130 | - if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) |
|
131 | - echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
132 | - else |
|
133 | - echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
137 | + if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) { |
|
138 | + echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
139 | + } else { |
|
140 | + echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
141 | + } |
|
134 | 142 | |
135 | 143 | echo ' |
136 | 144 | </div>'; |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Entrance point for the registration center, it checks permissions and forwards |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | global $context, $txt; |
32 | 33 | |
33 | 34 | // Old templates might still request this. |
34 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') |
|
35 | - redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
35 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') { |
|
36 | + redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $subActions = array( |
38 | 40 | 'register' => array('AdminRegister', 'moderate_forum'), |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | checkSession(); |
100 | 102 | validateToken('admin-regc'); |
101 | 103 | |
102 | - foreach ($_POST as $key => $value) |
|
103 | - if (!is_array($_POST[$key])) |
|
104 | + foreach ($_POST as $key => $value) { |
|
105 | + if (!is_array($_POST[$key])) |
|
104 | 106 | $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
107 | + } |
|
105 | 108 | |
106 | 109 | $regOptions = array( |
107 | 110 | 'interface' => 'admin', |
@@ -161,12 +164,13 @@ discard block |
||
161 | 164 | ) |
162 | 165 | ); |
163 | 166 | $context['member_groups'] = array(0 => $txt['admin_register_group_none']); |
164 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
165 | - $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
167 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
168 | + $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
169 | + } |
|
166 | 170 | $smcFunc['db_free_result']($request); |
171 | + } else { |
|
172 | + $context['member_groups'] = array(); |
|
167 | 173 | } |
168 | - else |
|
169 | - $context['member_groups'] = array(); |
|
170 | 174 | |
171 | 175 | // Basic stuff. |
172 | 176 | $context['sub_template'] = 'admin_register'; |
@@ -207,8 +211,9 @@ discard block |
||
207 | 211 | { |
208 | 212 | $context['editable_agreements']['.' . $lang['filename']] = $lang['name']; |
209 | 213 | // Are we editing this? |
210 | - if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) |
|
211 | - $context['current_agreement'] = '.' . $lang['filename']; |
|
214 | + if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) { |
|
215 | + $context['current_agreement'] = '.' . $lang['filename']; |
|
216 | + } |
|
212 | 217 | } |
213 | 218 | } |
214 | 219 | |
@@ -223,10 +228,11 @@ discard block |
||
223 | 228 | |
224 | 229 | updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement']))); |
225 | 230 | |
226 | - if ($bytes == strlen($to_write)) |
|
227 | - $context['saved_successful'] = true; |
|
228 | - else |
|
229 | - $context['could_not_save'] = true; |
|
231 | + if ($bytes == strlen($to_write)) { |
|
232 | + $context['saved_successful'] = true; |
|
233 | + } else { |
|
234 | + $context['could_not_save'] = true; |
|
235 | + } |
|
230 | 236 | } |
231 | 237 | |
232 | 238 | $context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? $smcFunc['htmlspecialchars'](file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : ''; |
@@ -310,8 +316,9 @@ discard block |
||
310 | 316 | |
311 | 317 | call_integration_hook('integrate_modify_registration_settings', array(&$config_vars)); |
312 | 318 | |
313 | - if ($return_config) |
|
314 | - return $config_vars; |
|
319 | + if ($return_config) { |
|
320 | + return $config_vars; |
|
321 | + } |
|
315 | 322 | |
316 | 323 | // Setup the template |
317 | 324 | $context['sub_template'] = 'show_settings'; |
@@ -322,8 +329,9 @@ discard block |
||
322 | 329 | checkSession(); |
323 | 330 | |
324 | 331 | // Are there some contacts missing? |
325 | - if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) |
|
326 | - fatal_lang_error('admin_setting_coppa_require_contact'); |
|
332 | + if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) { |
|
333 | + fatal_lang_error('admin_setting_coppa_require_contact'); |
|
334 | + } |
|
327 | 335 | |
328 | 336 | // Post needs to take into account line breaks. |
329 | 337 | $_POST['coppaPost'] = str_replace("\n", '<br>', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']); |