@@ -23,11 +23,13 @@ discard block |
||
23 | 23 | |
24 | 24 | $editor_context = &$context['controls']['richedit'][$editor_id]; |
25 | 25 | |
26 | - if ($smileyContainer === null) |
|
27 | - $editor_context['sce_options']['emoticonsEnabled'] = false; |
|
26 | + if ($smileyContainer === null) { |
|
27 | + $editor_context['sce_options']['emoticonsEnabled'] = false; |
|
28 | + } |
|
28 | 29 | |
29 | - if ($bbcContainer === null) |
|
30 | - $editor_context['sce_options']['toolbar'] = ''; |
|
30 | + if ($bbcContainer === null) { |
|
31 | + $editor_context['sce_options']['toolbar'] = ''; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | echo ' |
33 | 35 | <textarea class="editor" name="', $editor_id, '" id="', $editor_id, '" cols="600" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '" style="width: ', $editor_context['width'], '; height: ', $editor_context['height'], ';', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? 'border: 1px solid red;' : '', '"', !empty($context['editor']['required']) ? ' required' : '', '>', $editor_context['value'], '</textarea> |
@@ -77,42 +79,47 @@ discard block |
||
77 | 79 | |
78 | 80 | $tempTab = $context['tabindex']; |
79 | 81 | |
80 | - if (!empty($context['drafts_pm_save'])) |
|
81 | - $tempTab++; |
|
82 | - elseif (!empty($context['drafts_save'])) |
|
83 | - $tempTab++; |
|
84 | - elseif ($editor_context['preview_type']) |
|
85 | - $tempTab++; |
|
86 | - elseif ($context['show_spellchecking']) |
|
87 | - $tempTab++; |
|
82 | + if (!empty($context['drafts_pm_save'])) { |
|
83 | + $tempTab++; |
|
84 | + } elseif (!empty($context['drafts_save'])) { |
|
85 | + $tempTab++; |
|
86 | + } elseif ($editor_context['preview_type']) { |
|
87 | + $tempTab++; |
|
88 | + } elseif ($context['show_spellchecking']) { |
|
89 | + $tempTab++; |
|
90 | + } |
|
88 | 91 | |
89 | 92 | $tempTab++; |
90 | 93 | $context['tabindex'] = $tempTab; |
91 | 94 | |
92 | - if (!empty($context['drafts_pm_save'])) |
|
93 | - echo ' |
|
95 | + if (!empty($context['drafts_pm_save'])) { |
|
96 | + echo ' |
|
94 | 97 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button"> |
95 | 98 | <input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">'; |
99 | + } |
|
96 | 100 | |
97 | - if (!empty($context['drafts_save'])) |
|
98 | - echo ' |
|
101 | + if (!empty($context['drafts_save'])) { |
|
102 | + echo ' |
|
99 | 103 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button"> |
100 | 104 | <input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">'; |
105 | + } |
|
101 | 106 | |
102 | - if ($context['show_spellchecking']) |
|
103 | - echo ' |
|
107 | + if ($context['show_spellchecking']) { |
|
108 | + echo ' |
|
104 | 109 | <input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">'; |
110 | + } |
|
105 | 111 | |
106 | - if ($editor_context['preview_type']) |
|
107 | - echo ' |
|
112 | + if ($editor_context['preview_type']) { |
|
113 | + echo ' |
|
108 | 114 | <input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? 'return event.ctrlKey || previewPost();' : 'return submitThisOnce(this);', '" accesskey="p" class="button">'; |
115 | + } |
|
109 | 116 | |
110 | 117 | echo ' |
111 | 118 | <input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button">'; |
112 | 119 | |
113 | 120 | // Load in the PM autosaver if it's enabled |
114 | - if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) |
|
115 | - echo ' |
|
121 | + if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) { |
|
122 | + echo ' |
|
116 | 123 | <span class="righttext padding" style="display: block"> |
117 | 124 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span> |
118 | 125 | <span id="draft_lastautosave" ></span> |
@@ -130,10 +137,11 @@ discard block |
||
130 | 137 | iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), ' |
131 | 138 | }); |
132 | 139 | </script>'; |
140 | + } |
|
133 | 141 | |
134 | 142 | // Start an instance of the auto saver if its enabled |
135 | - if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) |
|
136 | - echo ' |
|
143 | + if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) { |
|
144 | + echo ' |
|
137 | 145 | <span class="righttext padding" style="display: block"> |
138 | 146 | <span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span> |
139 | 147 | <span id="draft_lastautosave" ></span> |
@@ -150,7 +158,8 @@ discard block |
||
150 | 158 | iFreq: ', $context['drafts_autosave_frequency'], ' |
151 | 159 | }); |
152 | 160 | </script>'; |
153 | -} |
|
161 | + } |
|
162 | + } |
|
154 | 163 | |
155 | 164 | /** |
156 | 165 | * This template displays a verification form |
@@ -167,51 +176,57 @@ discard block |
||
167 | 176 | $verify_context = &$context['controls']['verification'][$verify_id]; |
168 | 177 | |
169 | 178 | // Keep track of where we are. |
170 | - if (empty($verify_context['tracking']) || $reset) |
|
171 | - $verify_context['tracking'] = 0; |
|
179 | + if (empty($verify_context['tracking']) || $reset) { |
|
180 | + $verify_context['tracking'] = 0; |
|
181 | + } |
|
172 | 182 | |
173 | 183 | // How many items are there to display in total. |
174 | 184 | $total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0); |
175 | 185 | |
176 | 186 | // If we've gone too far, stop. |
177 | - if ($verify_context['tracking'] > $total_items) |
|
178 | - return false; |
|
187 | + if ($verify_context['tracking'] > $total_items) { |
|
188 | + return false; |
|
189 | + } |
|
179 | 190 | |
180 | 191 | // Loop through each item to show them. |
181 | 192 | for ($i = 0; $i < $total_items; $i++) |
182 | 193 | { |
183 | 194 | // If we're after a single item only show it if we're in the right place. |
184 | - if ($display_type == 'single' && $verify_context['tracking'] != $i) |
|
185 | - continue; |
|
195 | + if ($display_type == 'single' && $verify_context['tracking'] != $i) { |
|
196 | + continue; |
|
197 | + } |
|
186 | 198 | |
187 | - if ($display_type != 'single') |
|
188 | - echo ' |
|
199 | + if ($display_type != 'single') { |
|
200 | + echo ' |
|
189 | 201 | <div id="verification_control_', $i, '" class="verification_control">'; |
202 | + } |
|
190 | 203 | |
191 | 204 | // Display empty field, but only if we have one, and it's the first time. |
192 | - if ($verify_context['empty_field'] && empty($i)) |
|
193 | - echo ' |
|
205 | + if ($verify_context['empty_field'] && empty($i)) { |
|
206 | + echo ' |
|
194 | 207 | <div class="smalltext vv_special"> |
195 | 208 | ', $txt['visual_verification_hidden'], ': |
196 | 209 | <input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value=""> |
197 | 210 | </div>'; |
211 | + } |
|
198 | 212 | |
199 | 213 | // Do the actual stuff |
200 | 214 | if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha'])) |
201 | 215 | { |
202 | 216 | if ($verify_context['show_visual']) |
203 | 217 | { |
204 | - if ($context['use_graphic_library']) |
|
205 | - echo ' |
|
218 | + if ($context['use_graphic_library']) { |
|
219 | + echo ' |
|
206 | 220 | <img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">'; |
207 | - else |
|
208 | - echo ' |
|
221 | + } else { |
|
222 | + echo ' |
|
209 | 223 | <img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1"> |
210 | 224 | <img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2"> |
211 | 225 | <img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3"> |
212 | 226 | <img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4"> |
213 | 227 | <img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5"> |
214 | 228 | <img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">'; |
229 | + } |
|
215 | 230 | |
216 | 231 | echo ' |
217 | 232 | <div class="smalltext" style="margin: 4px 0 8px 0;"> |
@@ -229,8 +244,7 @@ discard block |
||
229 | 244 | <br> |
230 | 245 | <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang.'"></script>'; |
231 | 246 | } |
232 | - } |
|
233 | - else |
|
247 | + } else |
|
234 | 248 | { |
235 | 249 | // Where in the question array is this question? |
236 | 250 | $qIndex = $verify_context['show_visual'] ? $i - 1 : $i; |
@@ -242,21 +256,24 @@ discard block |
||
242 | 256 | </div>'; |
243 | 257 | } |
244 | 258 | |
245 | - if ($display_type != 'single') |
|
246 | - echo ' |
|
259 | + if ($display_type != 'single') { |
|
260 | + echo ' |
|
247 | 261 | </div><!-- #verification_control_[i] -->'; |
262 | + } |
|
248 | 263 | |
249 | 264 | // If we were displaying just one and we did it, break. |
250 | - if ($display_type == 'single' && $verify_context['tracking'] == $i) |
|
251 | - break; |
|
265 | + if ($display_type == 'single' && $verify_context['tracking'] == $i) { |
|
266 | + break; |
|
267 | + } |
|
252 | 268 | } |
253 | 269 | |
254 | 270 | // Assume we found something, always. |
255 | 271 | $verify_context['tracking']++; |
256 | 272 | |
257 | 273 | // Tell something displaying piecemeal to keep going. |
258 | - if ($display_type == 'single') |
|
259 | - return true; |
|
260 | -} |
|
274 | + if ($display_type == 'single') { |
|
275 | + return true; |
|
276 | + } |
|
277 | + } |
|
261 | 278 | |
262 | 279 | ?> |
263 | 280 | \ No newline at end of file |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | foreach ($message['custom_fields']['above_member'] as $custom) |
233 | 233 | echo ' |
234 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
234 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
235 | 235 | |
236 | 236 | echo ' |
237 | 237 | </ul> |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | if (!empty($message['custom_fields']['below_avatar'])) |
281 | 281 | foreach ($message['custom_fields']['below_avatar'] as $custom) |
282 | 282 | echo ' |
283 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
283 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
284 | 284 | |
285 | 285 | if (!$message['member']['is_guest']) |
286 | 286 | echo ' |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | foreach ($message['custom_fields']['icons'] as $custom) |
324 | 324 | echo ' |
325 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
325 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
326 | 326 | |
327 | 327 | echo ' |
328 | 328 | </ol> |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | if (!empty($message['custom_fields']['standard'])) |
387 | 387 | foreach ($message['custom_fields']['standard'] as $custom) |
388 | 388 | echo ' |
389 | - <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
|
389 | + <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
|
390 | 390 | |
391 | 391 | // Are we showing the warning status? |
392 | 392 | if ($message['member']['can_see_warning']) |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | if (!empty($message['custom_fields']['bottom_poster'])) |
398 | 398 | foreach ($message['custom_fields']['bottom_poster'] as $custom) |
399 | 399 | echo ' |
400 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
400 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | // Done with the information about the poster... on to the post itself. |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | |
499 | 499 | foreach ($message['custom_fields']['above_signature'] as $custom) |
500 | 500 | echo ' |
501 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
501 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
502 | 502 | |
503 | 503 | echo ' |
504 | 504 | </ul> |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | |
522 | 522 | foreach ($message['custom_fields']['below_signature'] as $custom) |
523 | 523 | echo ' |
524 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
524 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
525 | 525 | |
526 | 526 | echo ' |
527 | 527 | </ul> |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | while ($message = $context['get_pmessage']('subject')) |
658 | 658 | { |
659 | 659 | echo ' |
660 | - <tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '','"> |
|
660 | + <tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '', '"> |
|
661 | 661 | <td class="table_icon"> |
662 | 662 | <script> |
663 | 663 | currentLabels[', $message['id'], '] = {'; |
@@ -946,13 +946,13 @@ discard block |
||
946 | 946 | // You can only reply if they are not a guest... |
947 | 947 | if (!$message['member']['is_guest']) |
948 | 948 | echo ' |
949 | - <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], ' |
|
950 | - <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator']; |
|
949 | + <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button, '</a>', $context['menu_separator'], ' |
|
950 | + <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button, '</a> ', $context['menu_separator']; |
|
951 | 951 | |
952 | 952 | // This is for "forwarding" - even if the member is gone. |
953 | 953 | else |
954 | 954 | echo ' |
955 | - <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator']; |
|
955 | + <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button, '</a>', $context['menu_separator']; |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | echo ' |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | <div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors"> |
1055 | 1055 | <dl> |
1056 | 1056 | <dt> |
1057 | - <strong id="error_serious">', $txt['error_while_submitting'] , '</strong> |
|
1057 | + <strong id="error_serious">', $txt['error_while_submitting'], '</strong> |
|
1058 | 1058 | </dt> |
1059 | 1059 | <dd class="error" id="error_list"> |
1060 | 1060 | ', empty($context['post_error']['messages']) ? '' : implode('<br>', $context['post_error']['messages']), ' |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | <span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</span> |
1111 | 1111 | </dt> |
1112 | 1112 | <dd id="pm_subject"> |
1113 | - <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"',isset($context['post_error']['no_subject']) ? ' class="error"' : '', '> |
|
1113 | + <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : '', '> |
|
1114 | 1114 | </dd> |
1115 | 1115 | </dl>'; |
1116 | 1116 | |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | echo ' |
1464 | 1464 | <div class="padding"> |
1465 | 1465 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
1466 | - <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button you_sure"> |
|
1466 | + <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'], '" class="button you_sure"> |
|
1467 | 1467 | </div>'; |
1468 | 1468 | |
1469 | 1469 | echo ' |
@@ -1628,7 +1628,7 @@ discard block |
||
1628 | 1628 | if (!empty($context['rules'])) |
1629 | 1629 | echo ' |
1630 | 1630 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1631 | - <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button smalltext you_sure">'; |
|
1631 | + <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'], '" class="button smalltext you_sure">'; |
|
1632 | 1632 | |
1633 | 1633 | echo ' |
1634 | 1634 | </div> |
@@ -1871,9 +1871,9 @@ discard block |
||
1871 | 1871 | |
1872 | 1872 | echo ' |
1873 | 1873 | <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();"> |
1874 | - <option value="">', $txt['pm_rule_sel_action'] , ':</option> |
|
1875 | - <option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'] , '</option> |
|
1876 | - <option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'] , '</option> |
|
1874 | + <option value="">', $txt['pm_rule_sel_action'], ':</option> |
|
1875 | + <option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'], '</option> |
|
1876 | + <option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'], '</option> |
|
1877 | 1877 | </select> |
1878 | 1878 | <span id="labdiv', $k, '"> |
1879 | 1879 | <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();"> |
@@ -1985,7 +1985,7 @@ discard block |
||
1985 | 1985 | </div> |
1986 | 1986 | <ul class="quickbuttons"> |
1987 | 1987 | <li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;id_draft=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons modifybutton"></span>', $txt['draft_edit'], '</a></li> |
1988 | - <li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'] ,'?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li> |
|
1988 | + <li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'], '?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li> |
|
1989 | 1989 | </ul> |
1990 | 1990 | </div><!-- .windowbg -->'; |
1991 | 1991 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | <div id="personal_messages">'; |
22 | 22 | |
23 | 23 | // Show the capacity bar, if available. |
24 | - if (!empty($context['limit_bar'])) |
|
25 | - echo ' |
|
24 | + if (!empty($context['limit_bar'])) { |
|
25 | + echo ' |
|
26 | 26 | <div class="cat_bar"> |
27 | 27 | <h3 class="catbg"> |
28 | 28 | <span class="floatleft">', $txt['pm_capacity'], ':</span> |
@@ -32,14 +32,16 @@ discard block |
||
32 | 32 | <span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span> |
33 | 33 | </h3> |
34 | 34 | </div>'; |
35 | + } |
|
35 | 36 | |
36 | 37 | // Message sent? Show a small indication. |
37 | - if (isset($context['pm_sent'])) |
|
38 | - echo ' |
|
38 | + if (isset($context['pm_sent'])) { |
|
39 | + echo ' |
|
39 | 40 | <div class="infobox"> |
40 | 41 | ', $txt['pm_sent'], ' |
41 | 42 | </div>'; |
42 | -} |
|
43 | + } |
|
44 | + } |
|
43 | 45 | |
44 | 46 | /** |
45 | 47 | * Just the end of the index bar, nothing special. |
@@ -68,13 +70,13 @@ discard block |
||
68 | 70 | </div> |
69 | 71 | <div class="pm_unread">'; |
70 | 72 | |
71 | - if (empty($context['unread_pms'])) |
|
72 | - echo ' |
|
73 | + if (empty($context['unread_pms'])) { |
|
74 | + echo ' |
|
73 | 75 | <div class="no_unread">', $txt['pm_no_unread'], '</div>'; |
74 | - else |
|
76 | + } else |
|
75 | 77 | { |
76 | - foreach ($context['unread_pms'] as $id_pm => $pm_details) |
|
77 | - echo ' |
|
78 | + foreach ($context['unread_pms'] as $id_pm => $pm_details) { |
|
79 | + echo ' |
|
78 | 80 | <div class="unread"> |
79 | 81 | ', !empty($pm_details['member']) ? $pm_details['member']['avatar']['image'] : '', ' |
80 | 82 | <div class="details"> |
@@ -85,6 +87,7 @@ discard block |
||
85 | 87 | </div> |
86 | 88 | </div> |
87 | 89 | </div>'; |
90 | + } |
|
88 | 91 | } |
89 | 92 | |
90 | 93 | echo ' |
@@ -193,14 +196,15 @@ discard block |
||
193 | 196 | if ($context['get_pmessage']('message', true)) |
194 | 197 | { |
195 | 198 | // Show the helpful titlebar - generally. |
196 | - if ($context['display_mode'] != 1) |
|
197 | - echo ' |
|
199 | + if ($context['display_mode'] != 1) { |
|
200 | + echo ' |
|
198 | 201 | <div class="cat_bar"> |
199 | 202 | <h3 class="catbg"> |
200 | 203 | <span id="author">', $txt['author'], '</span> |
201 | 204 | <span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span> |
202 | 205 | </h3> |
203 | 206 | </div>'; |
207 | + } |
|
204 | 208 | |
205 | 209 | // Show a few buttons if we are in conversation mode and outputting the first message. |
206 | 210 | if ($context['display_mode'] == 2) |
@@ -229,9 +233,10 @@ discard block |
||
229 | 233 | <div class="custom_fields_above_member"> |
230 | 234 | <ul class="nolist">'; |
231 | 235 | |
232 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
233 | - echo ' |
|
236 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
237 | + echo ' |
|
234 | 238 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
239 | + } |
|
235 | 240 | |
236 | 241 | echo ' |
237 | 242 | </ul> |
@@ -243,25 +248,28 @@ discard block |
||
243 | 248 | <a id="msg', $message['id'], '"></a>'; |
244 | 249 | |
245 | 250 | // Show online and offline buttons? |
246 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
247 | - echo ' |
|
251 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
252 | + echo ' |
|
248 | 253 | <span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>'; |
254 | + } |
|
249 | 255 | |
250 | 256 | // Custom fields BEFORE the username? |
251 | - if (!empty($message['custom_fields']['before_member'])) |
|
252 | - foreach ($message['custom_fields']['before_member'] as $custom) |
|
257 | + if (!empty($message['custom_fields']['before_member'])) { |
|
258 | + foreach ($message['custom_fields']['before_member'] as $custom) |
|
253 | 259 | echo ' |
254 | 260 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
261 | + } |
|
255 | 262 | |
256 | 263 | // Show a link to the member's profile. |
257 | 264 | echo ' |
258 | 265 | ', $message['member']['link']; |
259 | 266 | |
260 | 267 | // Custom fields AFTER the username? |
261 | - if (!empty($message['custom_fields']['after_member'])) |
|
262 | - foreach ($message['custom_fields']['after_member'] as $custom) |
|
268 | + if (!empty($message['custom_fields']['after_member'])) { |
|
269 | + foreach ($message['custom_fields']['after_member'] as $custom) |
|
263 | 270 | echo ' |
264 | 271 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
272 | + } |
|
265 | 273 | |
266 | 274 | echo ' |
267 | 275 | </h4>'; |
@@ -270,48 +278,56 @@ discard block |
||
270 | 278 | <ul class="user_info">'; |
271 | 279 | |
272 | 280 | // Show the user's avatar. |
273 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
274 | - echo ' |
|
281 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
282 | + echo ' |
|
275 | 283 | <li class="avatar"> |
276 | 284 | <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a> |
277 | 285 | </li>'; |
286 | + } |
|
278 | 287 | |
279 | 288 | // Are there any custom fields below the avatar? |
280 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
281 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
289 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
290 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
282 | 291 | echo ' |
283 | 292 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
293 | + } |
|
284 | 294 | |
285 | - if (!$message['member']['is_guest']) |
|
286 | - echo ' |
|
295 | + if (!$message['member']['is_guest']) { |
|
296 | + echo ' |
|
287 | 297 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
298 | + } |
|
288 | 299 | // Show the member's primary group (like 'Administrator') if they have one. |
289 | - if (isset($message['member']['group']) && $message['member']['group'] != '') |
|
290 | - echo ' |
|
300 | + if (isset($message['member']['group']) && $message['member']['group'] != '') { |
|
301 | + echo ' |
|
291 | 302 | <li class="membergroup">', $message['member']['group'], '</li>'; |
303 | + } |
|
292 | 304 | |
293 | 305 | // Show the member's custom title, if they have one. |
294 | - if (isset($message['member']['title']) && $message['member']['title'] != '') |
|
295 | - echo ' |
|
306 | + if (isset($message['member']['title']) && $message['member']['title'] != '') { |
|
307 | + echo ' |
|
296 | 308 | <li class="title">', $message['member']['title'], '</li>'; |
309 | + } |
|
297 | 310 | |
298 | 311 | // Don't show these things for guests. |
299 | 312 | if (!$message['member']['is_guest']) |
300 | 313 | { |
301 | 314 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
302 | - if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') |
|
303 | - echo ' |
|
315 | + if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') { |
|
316 | + echo ' |
|
304 | 317 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
318 | + } |
|
305 | 319 | |
306 | 320 | // Show how many posts they have made. |
307 | - if (!isset($context['disabled_fields']['posts'])) |
|
308 | - echo ' |
|
321 | + if (!isset($context['disabled_fields']['posts'])) { |
|
322 | + echo ' |
|
309 | 323 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
324 | + } |
|
310 | 325 | |
311 | 326 | // Show their personal text? |
312 | - if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') |
|
313 | - echo ' |
|
327 | + if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') { |
|
328 | + echo ' |
|
314 | 329 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
330 | + } |
|
315 | 331 | |
316 | 332 | // Any custom fields to show as icons? |
317 | 333 | if (!empty($message['custom_fields']['icons'])) |
@@ -320,9 +336,10 @@ discard block |
||
320 | 336 | <li class="im_icons"> |
321 | 337 | <ol>'; |
322 | 338 | |
323 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
324 | - echo ' |
|
339 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
340 | + echo ' |
|
325 | 341 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
342 | + } |
|
326 | 343 | |
327 | 344 | echo ' |
328 | 345 | </ol> |
@@ -330,25 +347,28 @@ discard block |
||
330 | 347 | } |
331 | 348 | |
332 | 349 | // Show the IP to this user for this post - because you can moderate? |
333 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
334 | - echo ' |
|
350 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
351 | + echo ' |
|
335 | 352 | <li class="poster_ip"> |
336 | 353 | <a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a> |
337 | 354 | </li>'; |
355 | + } |
|
338 | 356 | |
339 | 357 | // Or, should we show it because this is you? |
340 | - elseif ($message['can_see_ip']) |
|
341 | - echo ' |
|
358 | + elseif ($message['can_see_ip']) { |
|
359 | + echo ' |
|
342 | 360 | <li class="poster_ip"> |
343 | 361 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a> |
344 | 362 | </li>'; |
363 | + } |
|
345 | 364 | |
346 | 365 | // Okay, you are logged in, then we can show something about why IPs are logged... |
347 | - else |
|
348 | - echo ' |
|
366 | + else { |
|
367 | + echo ' |
|
349 | 368 | <li class="poster_ip"> |
350 | 369 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a> |
351 | 370 | </li>'; |
371 | + } |
|
352 | 372 | |
353 | 373 | // Show the profile, website, email address, and personal message buttons. |
354 | 374 | if ($message['member']['show_profile_buttons']) |
@@ -358,24 +378,28 @@ discard block |
||
358 | 378 | <ol class="profile_icons">'; |
359 | 379 | |
360 | 380 | // Show the profile button |
361 | - if ($message['member']['can_view_profile']) |
|
362 | - echo ' |
|
381 | + if ($message['member']['can_view_profile']) { |
|
382 | + echo ' |
|
363 | 383 | <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '">' : $txt['view_profile']), '</a></li>'; |
384 | + } |
|
364 | 385 | |
365 | 386 | // Don't show an icon if they haven't specified a website. |
366 | - if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) |
|
367 | - echo ' |
|
387 | + if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) { |
|
388 | + echo ' |
|
368 | 389 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
390 | + } |
|
369 | 391 | |
370 | 392 | // Don't show the email address if they want it hidden. |
371 | - if ($message['member']['show_email']) |
|
372 | - echo ' |
|
393 | + if ($message['member']['show_email']) { |
|
394 | + echo ' |
|
373 | 395 | <li><a href="mailto:', $message['member']['email'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
396 | + } |
|
374 | 397 | |
375 | 398 | // Since we know this person isn't a guest, you *can* message them. |
376 | - if ($context['can_send_pm']) |
|
377 | - echo ' |
|
399 | + if ($context['can_send_pm']) { |
|
400 | + echo ' |
|
378 | 401 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
402 | + } |
|
379 | 403 | |
380 | 404 | echo ' |
381 | 405 | </ol> |
@@ -383,21 +407,24 @@ discard block |
||
383 | 407 | } |
384 | 408 | |
385 | 409 | // Any custom fields for standard placement? |
386 | - if (!empty($message['custom_fields']['standard'])) |
|
387 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
410 | + if (!empty($message['custom_fields']['standard'])) { |
|
411 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
388 | 412 | echo ' |
389 | 413 | <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
414 | + } |
|
390 | 415 | |
391 | 416 | // Are we showing the warning status? |
392 | - if ($message['member']['can_see_warning']) |
|
393 | - echo ' |
|
417 | + if ($message['member']['can_see_warning']) { |
|
418 | + echo ' |
|
394 | 419 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span>', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
420 | + } |
|
395 | 421 | |
396 | 422 | // Are there any custom fields to show at the bottom of the poster info? |
397 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
398 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
423 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
424 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
399 | 425 | echo ' |
400 | 426 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
427 | + } |
|
401 | 428 | } |
402 | 429 | |
403 | 430 | // Done with the information about the poster... on to the post itself. |
@@ -416,25 +443,29 @@ discard block |
||
416 | 443 | <span class="smalltext">« <strong> ', $txt['sent_to'], ':</strong> '; |
417 | 444 | |
418 | 445 | // People it was sent directly to.... |
419 | - if (!empty($message['recipients']['to'])) |
|
420 | - echo implode(', ', $message['recipients']['to']); |
|
446 | + if (!empty($message['recipients']['to'])) { |
|
447 | + echo implode(', ', $message['recipients']['to']); |
|
448 | + } |
|
421 | 449 | |
422 | 450 | // Otherwise, we're just going to say "some people"... |
423 | - elseif ($context['folder'] != 'sent') |
|
424 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
451 | + elseif ($context['folder'] != 'sent') { |
|
452 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
453 | + } |
|
425 | 454 | |
426 | 455 | echo ' |
427 | 456 | <strong> ', $txt['on'], ':</strong> ', $message['time'], ' » |
428 | 457 | </span>'; |
429 | 458 | |
430 | 459 | // If we're in the sent items, show who it was sent to besides the "To:" people. |
431 | - if (!empty($message['recipients']['bcc'])) |
|
432 | - echo '<br> |
|
460 | + if (!empty($message['recipients']['bcc'])) { |
|
461 | + echo '<br> |
|
433 | 462 | <span class="smalltext">« <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' »</span>'; |
463 | + } |
|
434 | 464 | |
435 | - if (!empty($message['is_replied_to'])) |
|
436 | - echo '<br> |
|
465 | + if (!empty($message['is_replied_to'])) { |
|
466 | + echo '<br> |
|
437 | 467 | <span class="smalltext">« ', $context['folder'] == 'sent' ? $txt['pm_sent_is_replied_to'] : $txt['pm_is_replied_to'], ' »</span>'; |
468 | + } |
|
438 | 469 | |
439 | 470 | echo ' |
440 | 471 | </div><!-- .keyinfo --> |
@@ -444,13 +475,15 @@ discard block |
||
444 | 475 | ', $message['body'], ' |
445 | 476 | </div>'; |
446 | 477 | |
447 | - if ($message['can_report'] || $context['can_send_pm']) |
|
448 | - echo ' |
|
478 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
479 | + echo ' |
|
449 | 480 | <div class="under_message">'; |
481 | + } |
|
450 | 482 | |
451 | - if ($message['can_report']) |
|
452 | - echo ' |
|
483 | + if ($message['can_report']) { |
|
484 | + echo ' |
|
453 | 485 | <a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '" class="floatright">' . $txt['pm_report_to_admin'] . '</a>'; |
486 | + } |
|
454 | 487 | |
455 | 488 | echo ' |
456 | 489 | <ul class="quickbuttons">'; |
@@ -462,32 +495,36 @@ discard block |
||
462 | 495 | if (!$message['member']['is_guest']) |
463 | 496 | { |
464 | 497 | // Is there than more than one recipient you can reply to? |
465 | - if ($message['number_recipients'] > 1) |
|
466 | - echo ' |
|
498 | + if ($message['number_recipients'] > 1) { |
|
499 | + echo ' |
|
467 | 500 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all"><span class="generic_icons reply_all_button"></span>', $txt['reply_to_all'], '</a></li>'; |
501 | + } |
|
468 | 502 | |
469 | 503 | echo ' |
470 | 504 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li> |
471 | 505 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
472 | 506 | } |
473 | 507 | // This is for "forwarding" - even if the member is gone. |
474 | - else |
|
475 | - echo ' |
|
508 | + else { |
|
509 | + echo ' |
|
476 | 510 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote"><span class="generic_icons quote"></span>', $txt['reply_quote'], '</a></li>'; |
511 | + } |
|
477 | 512 | } |
478 | 513 | echo ' |
479 | 514 | <li><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions%5b', $message['id'], '%5D=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', addslashes($txt['remove_message_question']), '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>'; |
480 | 515 | |
481 | - if (empty($context['display_mode'])) |
|
482 | - echo ' |
|
516 | + if (empty($context['display_mode'])) { |
|
517 | + echo ' |
|
483 | 518 | <li><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;"></li>'; |
519 | + } |
|
484 | 520 | |
485 | 521 | echo ' |
486 | 522 | </ul>'; |
487 | 523 | |
488 | - if ($message['can_report'] || $context['can_send_pm']) |
|
489 | - echo ' |
|
524 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
525 | + echo ' |
|
490 | 526 | </div><!-- .under_message -->'; |
527 | + } |
|
491 | 528 | |
492 | 529 | // Are there any custom profile fields for above the signature? |
493 | 530 | if (!empty($message['custom_fields']['above_signature'])) |
@@ -496,9 +533,10 @@ discard block |
||
496 | 533 | <div class="custom_fields_above_signature"> |
497 | 534 | <ul class="nolist">'; |
498 | 535 | |
499 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
500 | - echo ' |
|
536 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
537 | + echo ' |
|
501 | 538 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
539 | + } |
|
502 | 540 | |
503 | 541 | echo ' |
504 | 542 | </ul> |
@@ -506,11 +544,12 @@ discard block |
||
506 | 544 | } |
507 | 545 | |
508 | 546 | // Show the member's signature? |
509 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
510 | - echo ' |
|
547 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
548 | + echo ' |
|
511 | 549 | <div class="signature"> |
512 | 550 | ', $message['member']['signature'], ' |
513 | 551 | </div>'; |
552 | + } |
|
514 | 553 | |
515 | 554 | // Are there any custom profile fields for below the signature? |
516 | 555 | if (!empty($message['custom_fields']['below_signature'])) |
@@ -519,9 +558,10 @@ discard block |
||
519 | 558 | <div class="custom_fields_below_signature"> |
520 | 559 | <ul class="nolist">'; |
521 | 560 | |
522 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
523 | - echo ' |
|
561 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
562 | + echo ' |
|
524 | 563 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
564 | + } |
|
525 | 565 | |
526 | 566 | echo ' |
527 | 567 | </ul> |
@@ -548,10 +588,11 @@ discard block |
||
548 | 588 | echo ' |
549 | 589 | <option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>'; |
550 | 590 | |
551 | - foreach ($context['labels'] as $label) |
|
552 | - if (!isset($message['labels'][$label['id']])) |
|
591 | + foreach ($context['labels'] as $label) { |
|
592 | + if (!isset($message['labels'][$label['id']])) |
|
553 | 593 | echo ' |
554 | 594 | <option value="', $label['id'], '">', $label['name'], '</option>'; |
595 | + } |
|
555 | 596 | } |
556 | 597 | |
557 | 598 | // ... and are there any that can be removed? |
@@ -560,9 +601,10 @@ discard block |
||
560 | 601 | echo ' |
561 | 602 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
562 | 603 | |
563 | - foreach ($message['labels'] as $label) |
|
564 | - echo ' |
|
604 | + foreach ($message['labels'] as $label) { |
|
605 | + echo ' |
|
565 | 606 | <option value="', $label['id'], '"> ', $label['name'], '</option>'; |
607 | + } |
|
566 | 608 | } |
567 | 609 | echo ' |
568 | 610 | </select> |
@@ -581,14 +623,15 @@ discard block |
||
581 | 623 | </div><!-- .windowbg -->'; |
582 | 624 | } |
583 | 625 | |
584 | - if (empty($context['display_mode'])) |
|
585 | - echo ' |
|
626 | + if (empty($context['display_mode'])) { |
|
627 | + echo ' |
|
586 | 628 | <div class="pagesection"> |
587 | 629 | <div class="floatleft">', $context['page_index'], '</div> |
588 | 630 | <div class="floatright"> |
589 | 631 | <input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button"> |
590 | 632 | </div> |
591 | 633 | </div>'; |
634 | + } |
|
592 | 635 | |
593 | 636 | // Show a few buttons if we are in conversation mode and outputting the first message. |
594 | 637 | elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons'])) |
@@ -648,11 +691,12 @@ discard block |
||
648 | 691 | </thead> |
649 | 692 | <tbody>'; |
650 | 693 | |
651 | - if (!$context['show_delete']) |
|
652 | - echo ' |
|
694 | + if (!$context['show_delete']) { |
|
695 | + echo ' |
|
653 | 696 | <tr class="windowbg"> |
654 | 697 | <td colspan="5">', $txt['pm_alert_none'], '</td> |
655 | 698 | </tr>'; |
699 | + } |
|
656 | 700 | |
657 | 701 | while ($message = $context['get_pmessage']('subject')) |
658 | 702 | { |
@@ -710,17 +754,19 @@ discard block |
||
710 | 754 | |
711 | 755 | foreach ($context['labels'] as $label) |
712 | 756 | { |
713 | - if ($label['id'] != $context['current_label_id']) |
|
714 | - echo ' |
|
757 | + if ($label['id'] != $context['current_label_id']) { |
|
758 | + echo ' |
|
715 | 759 | <option value="add_', $label['id'], '"> ', $label['name'], '</option>'; |
760 | + } |
|
716 | 761 | } |
717 | 762 | |
718 | 763 | echo ' |
719 | 764 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
720 | 765 | |
721 | - foreach ($context['labels'] as $label) |
|
722 | - echo ' |
|
766 | + foreach ($context['labels'] as $label) { |
|
767 | + echo ' |
|
723 | 768 | <option value="rem_', $label['id'], '"> ', $label['name'], '</option>'; |
769 | + } |
|
724 | 770 | |
725 | 771 | echo ' |
726 | 772 | </select> |
@@ -751,11 +797,12 @@ discard block |
||
751 | 797 | <h3 class="catbg">', $txt['pm_search_title'], '</h3> |
752 | 798 | </div>'; |
753 | 799 | |
754 | - if (!empty($context['search_errors'])) |
|
755 | - echo ' |
|
800 | + if (!empty($context['search_errors'])) { |
|
801 | + echo ' |
|
756 | 802 | <div class="errorbox"> |
757 | 803 | ', implode('<br>', $context['search_errors']['messages']), ' |
758 | 804 | </div>'; |
805 | + } |
|
759 | 806 | |
760 | 807 | |
761 | 808 | echo ' |
@@ -804,9 +851,10 @@ discard block |
||
804 | 851 | </dd> |
805 | 852 | </dl>'; |
806 | 853 | |
807 | - if (!$context['currently_using_labels']) |
|
808 | - echo ' |
|
854 | + if (!$context['currently_using_labels']) { |
|
855 | + echo ' |
|
809 | 856 | <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button">'; |
857 | + } |
|
810 | 858 | |
811 | 859 | echo ' |
812 | 860 | <br class="clear_right"> |
@@ -827,12 +875,13 @@ discard block |
||
827 | 875 | <div id="advanced_panel_div"> |
828 | 876 | <ul id="searchLabelsExpand">'; |
829 | 877 | |
830 | - foreach ($context['search_labels'] as $label) |
|
831 | - echo ' |
|
878 | + foreach ($context['search_labels'] as $label) { |
|
879 | + echo ' |
|
832 | 880 | <li> |
833 | 881 | <label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '"', $label['checked'] ? ' checked' : '', '> |
834 | 882 | ', $label['name'], '</label> |
835 | 883 | </li>'; |
884 | + } |
|
836 | 885 | |
837 | 886 | echo ' |
838 | 887 | </ul> |
@@ -894,8 +943,8 @@ discard block |
||
894 | 943 | </div>'; |
895 | 944 | |
896 | 945 | // Complete results? |
897 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
898 | - echo ' |
|
946 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
947 | + echo ' |
|
899 | 948 | <table class="table_grid"> |
900 | 949 | <thead> |
901 | 950 | <tr class="title_bar"> |
@@ -905,6 +954,7 @@ discard block |
||
905 | 954 | </tr> |
906 | 955 | </thead> |
907 | 956 | <tbody>'; |
957 | + } |
|
908 | 958 | |
909 | 959 | // Print each message out... |
910 | 960 | foreach ($context['personal_messages'] as $message) |
@@ -924,12 +974,14 @@ discard block |
||
924 | 974 | |
925 | 975 | // Show the recipients. |
926 | 976 | // @todo This doesn't deal with the sent item searching quite right for bcc. |
927 | - if (!empty($message['recipients']['to'])) |
|
928 | - echo implode(', ', $message['recipients']['to']); |
|
977 | + if (!empty($message['recipients']['to'])) { |
|
978 | + echo implode(', ', $message['recipients']['to']); |
|
979 | + } |
|
929 | 980 | |
930 | 981 | // Otherwise, we're just going to say "some people"... |
931 | - elseif ($context['folder'] != 'sent') |
|
932 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
982 | + elseif ($context['folder'] != 'sent') { |
|
983 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
984 | + } |
|
933 | 985 | |
934 | 986 | echo ' |
935 | 987 | </h3> |
@@ -944,15 +996,17 @@ discard block |
||
944 | 996 | $reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"'); |
945 | 997 | |
946 | 998 | // You can only reply if they are not a guest... |
947 | - if (!$message['member']['is_guest']) |
|
948 | - echo ' |
|
999 | + if (!$message['member']['is_guest']) { |
|
1000 | + echo ' |
|
949 | 1001 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], ' |
950 | 1002 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator']; |
1003 | + } |
|
951 | 1004 | |
952 | 1005 | // This is for "forwarding" - even if the member is gone. |
953 | - else |
|
954 | - echo ' |
|
1006 | + else { |
|
1007 | + echo ' |
|
955 | 1008 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator']; |
1009 | + } |
|
956 | 1010 | } |
957 | 1011 | |
958 | 1012 | echo ' |
@@ -961,27 +1015,30 @@ discard block |
||
961 | 1015 | } |
962 | 1016 | // Otherwise just a simple list! |
963 | 1017 | // @todo No context at all of the search? |
964 | - else |
|
965 | - echo ' |
|
1018 | + else { |
|
1019 | + echo ' |
|
966 | 1020 | <tr class="windowbg"> |
967 | 1021 | <td>', $message['time'], '</td> |
968 | 1022 | <td>', $message['link'], '</td> |
969 | 1023 | <td>', $message['member']['link'], '</td> |
970 | 1024 | </tr>'; |
1025 | + } |
|
971 | 1026 | } |
972 | 1027 | |
973 | 1028 | // Finish off the page... |
974 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
975 | - echo ' |
|
1029 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
1030 | + echo ' |
|
976 | 1031 | </tbody> |
977 | 1032 | </table>'; |
1033 | + } |
|
978 | 1034 | |
979 | 1035 | // No results? |
980 | - if (empty($context['personal_messages'])) |
|
981 | - echo ' |
|
1036 | + if (empty($context['personal_messages'])) { |
|
1037 | + echo ' |
|
982 | 1038 | <div class="windowbg"> |
983 | 1039 | <p class="centertext">', $txt['pm_search_none_found'], '</p> |
984 | 1040 | </div>'; |
1041 | + } |
|
985 | 1042 | |
986 | 1043 | echo ' |
987 | 1044 | <div class="pagesection"> |
@@ -1006,15 +1063,17 @@ discard block |
||
1006 | 1063 | </div> |
1007 | 1064 | <div class="windowbg">'; |
1008 | 1065 | |
1009 | - if (!empty($context['send_log']['sent'])) |
|
1010 | - foreach ($context['send_log']['sent'] as $log_entry) |
|
1066 | + if (!empty($context['send_log']['sent'])) { |
|
1067 | + foreach ($context['send_log']['sent'] as $log_entry) |
|
1011 | 1068 | echo ' |
1012 | 1069 | <span class="error">', $log_entry, '</span><br>'; |
1070 | + } |
|
1013 | 1071 | |
1014 | - if (!empty($context['send_log']['failed'])) |
|
1015 | - foreach ($context['send_log']['failed'] as $log_entry) |
|
1072 | + if (!empty($context['send_log']['failed'])) { |
|
1073 | + foreach ($context['send_log']['failed'] as $log_entry) |
|
1016 | 1074 | echo ' |
1017 | 1075 | <span class="error">', $log_entry, '</span><br>'; |
1076 | + } |
|
1018 | 1077 | |
1019 | 1078 | echo ' |
1020 | 1079 | </div> |
@@ -1062,12 +1121,13 @@ discard block |
||
1062 | 1121 | </dl> |
1063 | 1122 | </div>'; |
1064 | 1123 | |
1065 | - if (!empty($modSettings['drafts_pm_enabled'])) |
|
1066 | - echo ' |
|
1124 | + if (!empty($modSettings['drafts_pm_enabled'])) { |
|
1125 | + echo ' |
|
1067 | 1126 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
1068 | 1127 | sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), ' |
1069 | 1128 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
1070 | 1129 | </div>'; |
1130 | + } |
|
1071 | 1131 | |
1072 | 1132 | echo ' |
1073 | 1133 | <dl id="post_header">'; |
@@ -1133,22 +1193,24 @@ discard block |
||
1133 | 1193 | <dt><strong>', $txt['subject'], '</strong></dt> |
1134 | 1194 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
1135 | 1195 | |
1136 | - foreach ($context['drafts'] as $draft) |
|
1137 | - echo ' |
|
1196 | + foreach ($context['drafts'] as $draft) { |
|
1197 | + echo ' |
|
1138 | 1198 | <dt>', $draft['link'], '</dt> |
1139 | 1199 | <dd>', $draft['poster_time'], '</dd>'; |
1200 | + } |
|
1140 | 1201 | echo ' |
1141 | 1202 | </dl> |
1142 | 1203 | </div>'; |
1143 | 1204 | } |
1144 | 1205 | |
1145 | 1206 | // Require an image to be typed to save spamming? |
1146 | - if ($context['require_verification']) |
|
1147 | - echo ' |
|
1207 | + if ($context['require_verification']) { |
|
1208 | + echo ' |
|
1148 | 1209 | <div class="post_verification"> |
1149 | 1210 | <strong>', $txt['pm_visual_verification_label'], ':</strong> |
1150 | 1211 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
1151 | 1212 | </div>'; |
1213 | + } |
|
1152 | 1214 | |
1153 | 1215 | // Send, Preview, spellcheck buttons. |
1154 | 1216 | echo ' |
@@ -1266,8 +1328,8 @@ discard block |
||
1266 | 1328 | }'; |
1267 | 1329 | |
1268 | 1330 | // Code for showing and hiding drafts |
1269 | - if (!empty($context['drafts'])) |
|
1270 | - echo ' |
|
1331 | + if (!empty($context['drafts'])) { |
|
1332 | + echo ' |
|
1271 | 1333 | var oSwapDraftOptions = new smc_Toggle({ |
1272 | 1334 | bToggleEnabled: true, |
1273 | 1335 | bCurrentlyCollapsed: true, |
@@ -1289,13 +1351,14 @@ discard block |
||
1289 | 1351 | } |
1290 | 1352 | ] |
1291 | 1353 | });'; |
1354 | + } |
|
1292 | 1355 | |
1293 | 1356 | echo ' |
1294 | 1357 | </script>'; |
1295 | 1358 | |
1296 | 1359 | // Show the message you're replying to. |
1297 | - if ($context['reply']) |
|
1298 | - echo ' |
|
1360 | + if ($context['reply']) { |
|
1361 | + echo ' |
|
1299 | 1362 | <br><br> |
1300 | 1363 | <div class="cat_bar"> |
1301 | 1364 | <h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3> |
@@ -1309,6 +1372,7 @@ discard block |
||
1309 | 1372 | ', $context['quoted_message']['body'], ' |
1310 | 1373 | </div> |
1311 | 1374 | <br class="clear">'; |
1375 | + } |
|
1312 | 1376 | |
1313 | 1377 | echo ' |
1314 | 1378 | <script> |
@@ -1320,23 +1384,25 @@ discard block |
||
1320 | 1384 | sToControlId: \'to_control\', |
1321 | 1385 | aToRecipients: ['; |
1322 | 1386 | |
1323 | - foreach ($context['recipients']['to'] as $i => $member) |
|
1324 | - echo ' |
|
1387 | + foreach ($context['recipients']['to'] as $i => $member) { |
|
1388 | + echo ' |
|
1325 | 1389 | { |
1326 | 1390 | sItemId: ', JavaScriptEscape($member['id']), ', |
1327 | 1391 | sItemName: ', JavaScriptEscape($member['name']), ' |
1328 | 1392 | }', $i == count($context['recipients']['to']) - 1 ? '' : ','; |
1393 | + } |
|
1329 | 1394 | |
1330 | 1395 | echo ' |
1331 | 1396 | ], |
1332 | 1397 | aBccRecipients: ['; |
1333 | 1398 | |
1334 | - foreach ($context['recipients']['bcc'] as $i => $member) |
|
1335 | - echo ' |
|
1399 | + foreach ($context['recipients']['bcc'] as $i => $member) { |
|
1400 | + echo ' |
|
1336 | 1401 | { |
1337 | 1402 | sItemId: ', JavaScriptEscape($member['id']), ', |
1338 | 1403 | sItemName: ', JavaScriptEscape($member['name']), ' |
1339 | 1404 | }', $i == count($context['recipients']['bcc']) - 1 ? '' : ','; |
1405 | + } |
|
1340 | 1406 | |
1341 | 1407 | echo ' |
1342 | 1408 | ], |
@@ -1425,26 +1491,28 @@ discard block |
||
1425 | 1491 | </th> |
1426 | 1492 | <th class="centertext table_icon">'; |
1427 | 1493 | |
1428 | - if (count($context['labels']) > 2) |
|
1429 | - echo ' |
|
1494 | + if (count($context['labels']) > 2) { |
|
1495 | + echo ' |
|
1430 | 1496 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
1497 | + } |
|
1431 | 1498 | |
1432 | 1499 | echo ' |
1433 | 1500 | </th> |
1434 | 1501 | </tr> |
1435 | 1502 | </thead> |
1436 | 1503 | <tbody>'; |
1437 | - if (count($context['labels']) < 2) |
|
1438 | - echo ' |
|
1504 | + if (count($context['labels']) < 2) { |
|
1505 | + echo ' |
|
1439 | 1506 | <tr class="windowbg"> |
1440 | 1507 | <td colspan="2">', $txt['pm_labels_no_exist'], '</td> |
1441 | 1508 | </tr>'; |
1442 | - else |
|
1509 | + } else |
|
1443 | 1510 | { |
1444 | 1511 | foreach ($context['labels'] as $label) |
1445 | 1512 | { |
1446 | - if ($label['id'] == -1) |
|
1447 | - continue; |
|
1513 | + if ($label['id'] == -1) { |
|
1514 | + continue; |
|
1515 | + } |
|
1448 | 1516 | |
1449 | 1517 | echo ' |
1450 | 1518 | <tr class="windowbg"> |
@@ -1459,12 +1527,13 @@ discard block |
||
1459 | 1527 | </tbody> |
1460 | 1528 | </table>'; |
1461 | 1529 | |
1462 | - if (!count($context['labels']) < 2) |
|
1463 | - echo ' |
|
1530 | + if (!count($context['labels']) < 2) { |
|
1531 | + echo ' |
|
1464 | 1532 | <div class="padding"> |
1465 | 1533 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
1466 | 1534 | <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button you_sure"> |
1467 | 1535 | </div>'; |
1536 | + } |
|
1468 | 1537 | |
1469 | 1538 | echo ' |
1470 | 1539 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1521,9 +1590,10 @@ discard block |
||
1521 | 1590 | <select name="id_admin"> |
1522 | 1591 | <option value="0">', $txt['pm_report_all_admins'], '</option>'; |
1523 | 1592 | |
1524 | - foreach ($context['admins'] as $id => $name) |
|
1525 | - echo ' |
|
1593 | + foreach ($context['admins'] as $id => $name) { |
|
1594 | + echo ' |
|
1526 | 1595 | <option value="', $id, '">', $name, '</option>'; |
1596 | + } |
|
1527 | 1597 | |
1528 | 1598 | echo ' |
1529 | 1599 | </select> |
@@ -1586,9 +1656,10 @@ discard block |
||
1586 | 1656 | </th> |
1587 | 1657 | <th class="centertext table_icon">'; |
1588 | 1658 | |
1589 | - if (!empty($context['rules'])) |
|
1590 | - echo ' |
|
1659 | + if (!empty($context['rules'])) { |
|
1660 | + echo ' |
|
1591 | 1661 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
1662 | + } |
|
1592 | 1663 | |
1593 | 1664 | echo ' |
1594 | 1665 | </th> |
@@ -1596,16 +1667,17 @@ discard block |
||
1596 | 1667 | </thead> |
1597 | 1668 | <tbody>'; |
1598 | 1669 | |
1599 | - if (empty($context['rules'])) |
|
1600 | - echo ' |
|
1670 | + if (empty($context['rules'])) { |
|
1671 | + echo ' |
|
1601 | 1672 | <tr class="windowbg"> |
1602 | 1673 | <td colspan="2"> |
1603 | 1674 | ', $txt['pm_rules_none'], ' |
1604 | 1675 | </td> |
1605 | 1676 | </tr>'; |
1677 | + } |
|
1606 | 1678 | |
1607 | - foreach ($context['rules'] as $rule) |
|
1608 | - echo ' |
|
1679 | + foreach ($context['rules'] as $rule) { |
|
1680 | + echo ' |
|
1609 | 1681 | <tr class="windowbg"> |
1610 | 1682 | <td> |
1611 | 1683 | <a href="', $scripturl, '?action=pm;sa=manrules;add;rid=', $rule['id'], '">', $rule['name'], '</a> |
@@ -1614,6 +1686,7 @@ discard block |
||
1614 | 1686 | <input type="checkbox" name="delrule[', $rule['id'], ']"> |
1615 | 1687 | </td> |
1616 | 1688 | </tr>'; |
1689 | + } |
|
1617 | 1690 | |
1618 | 1691 | echo ' |
1619 | 1692 | </tbody> |
@@ -1621,14 +1694,16 @@ discard block |
||
1621 | 1694 | <div class="righttext"> |
1622 | 1695 | <a class="button" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>'; |
1623 | 1696 | |
1624 | - if (!empty($context['rules'])) |
|
1625 | - echo ' |
|
1697 | + if (!empty($context['rules'])) { |
|
1698 | + echo ' |
|
1626 | 1699 | [<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]'; |
1700 | + } |
|
1627 | 1701 | |
1628 | - if (!empty($context['rules'])) |
|
1629 | - echo ' |
|
1702 | + if (!empty($context['rules'])) { |
|
1703 | + echo ' |
|
1630 | 1704 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1631 | 1705 | <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button smalltext you_sure">'; |
1706 | + } |
|
1632 | 1707 | |
1633 | 1708 | echo ' |
1634 | 1709 | </div> |
@@ -1650,14 +1725,16 @@ discard block |
||
1650 | 1725 | var groups = new Array() |
1651 | 1726 | var labels = new Array()'; |
1652 | 1727 | |
1653 | - foreach ($context['groups'] as $id => $title) |
|
1654 | - echo ' |
|
1728 | + foreach ($context['groups'] as $id => $title) { |
|
1729 | + echo ' |
|
1655 | 1730 | groups[', $id, '] = "', addslashes($title), '";'; |
1731 | + } |
|
1656 | 1732 | |
1657 | - foreach ($context['labels'] as $label) |
|
1658 | - if ($label['id'] != -1) |
|
1733 | + foreach ($context['labels'] as $label) { |
|
1734 | + if ($label['id'] != -1) |
|
1659 | 1735 | echo ' |
1660 | 1736 | labels[', ($label['id']), '] = "', addslashes($label['name']), '";'; |
1737 | + } |
|
1661 | 1738 | |
1662 | 1739 | echo ' |
1663 | 1740 | function addCriteriaOption() |
@@ -1672,8 +1749,9 @@ discard block |
||
1672 | 1749 | |
1673 | 1750 | setOuterHTML(document.getElementById("criteriaAddHere"), \'<br><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select> <span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value=""><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>'; |
1674 | 1751 | |
1675 | - foreach ($context['groups'] as $id => $group) |
|
1676 | - echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
1752 | + foreach ($context['groups'] as $id => $group) { |
|
1753 | + echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
1754 | + } |
|
1677 | 1755 | |
1678 | 1756 | echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\'); |
1679 | 1757 | } |
@@ -1690,9 +1768,10 @@ discard block |
||
1690 | 1768 | |
1691 | 1769 | setOuterHTML(document.getElementById("actionAddHere"), \'<br><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select> <span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>'; |
1692 | 1770 | |
1693 | - foreach ($context['labels'] as $label) |
|
1694 | - if ($label['id'] != -1) |
|
1771 | + foreach ($context['labels'] as $label) { |
|
1772 | + if ($label['id'] != -1) |
|
1695 | 1773 | echo '<option value="', ($label['id']), '">', addslashes($label['name']), '<\' + \'/option>'; |
1774 | + } |
|
1696 | 1775 | |
1697 | 1776 | echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\'); |
1698 | 1777 | } |
@@ -1806,19 +1885,20 @@ discard block |
||
1806 | 1885 | $isFirst = true; |
1807 | 1886 | foreach ($context['rule']['criteria'] as $k => $criteria) |
1808 | 1887 | { |
1809 | - if (!$isFirst && $criteria['t'] == '') |
|
1810 | - echo '<div id="removeonjs1">'; |
|
1811 | - |
|
1812 | - elseif (!$isFirst) |
|
1813 | - echo '<br>'; |
|
1888 | + if (!$isFirst && $criteria['t'] == '') { |
|
1889 | + echo '<div id="removeonjs1">'; |
|
1890 | + } elseif (!$isFirst) { |
|
1891 | + echo '<br>'; |
|
1892 | + } |
|
1814 | 1893 | |
1815 | 1894 | echo ' |
1816 | 1895 | <select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();"> |
1817 | 1896 | <option value="">', $txt['pm_rule_criteria_pick'], ':</option>'; |
1818 | 1897 | |
1819 | - foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) |
|
1820 | - echo ' |
|
1898 | + foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) { |
|
1899 | + echo ' |
|
1821 | 1900 | <option value="', $cr, '"', $criteria['t'] == $cr ? ' selected' : '', '>', $txt['pm_rule_' . $cr], '</option>'; |
1901 | + } |
|
1822 | 1902 | |
1823 | 1903 | echo ' |
1824 | 1904 | </select> |
@@ -1829,19 +1909,20 @@ discard block |
||
1829 | 1909 | <select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();"> |
1830 | 1910 | <option value="">', $txt['pm_rule_sel_group'], '</option>'; |
1831 | 1911 | |
1832 | - foreach ($context['groups'] as $id => $group) |
|
1833 | - echo ' |
|
1912 | + foreach ($context['groups'] as $id => $group) { |
|
1913 | + echo ' |
|
1834 | 1914 | <option value="', $id, '"', $criteria['t'] == 'gid' && $criteria['v'] == $id ? ' selected' : '', '>', $group, '</option>'; |
1915 | + } |
|
1835 | 1916 | echo ' |
1836 | 1917 | </select> |
1837 | 1918 | </span>'; |
1838 | 1919 | |
1839 | 1920 | // If this is the dummy we add a means to hide for non js users. |
1840 | - if ($isFirst) |
|
1841 | - $isFirst = false; |
|
1842 | - |
|
1843 | - elseif ($criteria['t'] == '') |
|
1844 | - echo '</div><!-- .removeonjs1 -->'; |
|
1921 | + if ($isFirst) { |
|
1922 | + $isFirst = false; |
|
1923 | + } elseif ($criteria['t'] == '') { |
|
1924 | + echo '</div><!-- .removeonjs1 -->'; |
|
1925 | + } |
|
1845 | 1926 | } |
1846 | 1927 | |
1847 | 1928 | echo ' |
@@ -1864,10 +1945,11 @@ discard block |
||
1864 | 1945 | $isFirst = true; |
1865 | 1946 | foreach ($context['rule']['actions'] as $k => $action) |
1866 | 1947 | { |
1867 | - if (!$isFirst && $action['t'] == '') |
|
1868 | - echo '<div id="removeonjs2">'; |
|
1869 | - elseif (!$isFirst) |
|
1870 | - echo '<br>'; |
|
1948 | + if (!$isFirst && $action['t'] == '') { |
|
1949 | + echo '<div id="removeonjs2">'; |
|
1950 | + } elseif (!$isFirst) { |
|
1951 | + echo '<br>'; |
|
1952 | + } |
|
1871 | 1953 | |
1872 | 1954 | echo ' |
1873 | 1955 | <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();"> |
@@ -1879,20 +1961,21 @@ discard block |
||
1879 | 1961 | <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();"> |
1880 | 1962 | <option value="">', $txt['pm_rule_sel_label'], '</option>'; |
1881 | 1963 | |
1882 | - foreach ($context['labels'] as $label) |
|
1883 | - if ($label['id'] != -1) |
|
1964 | + foreach ($context['labels'] as $label) { |
|
1965 | + if ($label['id'] != -1) |
|
1884 | 1966 | echo ' |
1885 | 1967 | <option value="', ($label['id']), '"', $action['t'] == 'lab' && $action['v'] == $label['id'] ? ' selected' : '', '>', $label['name'], '</option>'; |
1968 | + } |
|
1886 | 1969 | |
1887 | 1970 | echo ' |
1888 | 1971 | </select> |
1889 | 1972 | </span>'; |
1890 | 1973 | |
1891 | - if ($isFirst) |
|
1892 | - $isFirst = false; |
|
1893 | - |
|
1894 | - elseif ($action['t'] == '') |
|
1895 | - echo '</div><!-- .removeonjs2 -->'; |
|
1974 | + if ($isFirst) { |
|
1975 | + $isFirst = false; |
|
1976 | + } elseif ($action['t'] == '') { |
|
1977 | + echo '</div><!-- .removeonjs2 -->'; |
|
1978 | + } |
|
1896 | 1979 | } |
1897 | 1980 | |
1898 | 1981 | echo ' |
@@ -1916,22 +1999,25 @@ discard block |
||
1916 | 1999 | echo ' |
1917 | 2000 | <script>'; |
1918 | 2001 | |
1919 | - foreach ($context['rule']['criteria'] as $k => $c) |
|
1920 | - echo ' |
|
2002 | + foreach ($context['rule']['criteria'] as $k => $c) { |
|
2003 | + echo ' |
|
1921 | 2004 | updateRuleDef(', $k, ');'; |
2005 | + } |
|
1922 | 2006 | |
1923 | - foreach ($context['rule']['actions'] as $k => $c) |
|
1924 | - echo ' |
|
2007 | + foreach ($context['rule']['actions'] as $k => $c) { |
|
2008 | + echo ' |
|
1925 | 2009 | updateActionDef(', $k, ');'; |
2010 | + } |
|
1926 | 2011 | |
1927 | 2012 | echo ' |
1928 | 2013 | rebuildRuleDesc();'; |
1929 | 2014 | |
1930 | 2015 | // If this isn't a new rule and we have JS enabled remove the JS compatibility stuff. |
1931 | - if ($context['rid']) |
|
1932 | - echo ' |
|
2016 | + if ($context['rid']) { |
|
2017 | + echo ' |
|
1933 | 2018 | document.getElementById("removeonjs1").style.display = "none"; |
1934 | 2019 | document.getElementById("removeonjs2").style.display = "none";'; |
2020 | + } |
|
1935 | 2021 | |
1936 | 2022 | echo ' |
1937 | 2023 | document.getElementById("addonjs1").style.display = ""; |
@@ -1959,12 +2045,12 @@ discard block |
||
1959 | 2045 | </div>'; |
1960 | 2046 | |
1961 | 2047 | // No drafts? Just show an informative message. |
1962 | - if (empty($context['drafts'])) |
|
1963 | - echo ' |
|
2048 | + if (empty($context['drafts'])) { |
|
2049 | + echo ' |
|
1964 | 2050 | <div class="windowbg2 centertext"> |
1965 | 2051 | ', $txt['draft_none'], ' |
1966 | 2052 | </div>'; |
1967 | - else |
|
2053 | + } else |
|
1968 | 2054 | { |
1969 | 2055 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
1970 | 2056 | foreach ($context['drafts'] as $draft) |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Takes a message and parses it, returning nothing. |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | global $user_info, $modSettings, $context, $sourcedir; |
32 | 33 | |
33 | 34 | // This line makes all languages *theoretically* work even with the wrong charset ;). |
34 | - if (empty($context['utf8'])) |
|
35 | - $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
35 | + if (empty($context['utf8'])) { |
|
36 | + $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | // Clean up after nobbc ;). |
38 | 40 | $message = preg_replace_callback('~\[nobbc\](.+?)\[/nobbc\]~is', function($a) |
@@ -47,17 +49,19 @@ discard block |
||
47 | 49 | $message = preg_replace('~\.{100,}~', '...', $message); |
48 | 50 | |
49 | 51 | // Trim off trailing quotes - these often happen by accident. |
50 | - while (substr($message, -7) == '[quote]') |
|
51 | - $message = substr($message, 0, -7); |
|
52 | - while (substr($message, 0, 8) == '[/quote]') |
|
53 | - $message = substr($message, 8); |
|
52 | + while (substr($message, -7) == '[quote]') { |
|
53 | + $message = substr($message, 0, -7); |
|
54 | + } |
|
55 | + while (substr($message, 0, 8) == '[/quote]') { |
|
56 | + $message = substr($message, 8); |
|
57 | + } |
|
54 | 58 | |
55 | 59 | // Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed. |
56 | 60 | $in_tag = false; |
57 | 61 | $had_tag = false; |
58 | 62 | $codeopen = 0; |
59 | - if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) |
|
60 | - foreach ($matches[0] as $index => $dummy) |
|
63 | + if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) { |
|
64 | + foreach ($matches[0] as $index => $dummy) |
|
61 | 65 | { |
62 | 66 | // Closing? |
63 | 67 | if (!empty($matches[2][$index])) |
@@ -65,6 +69,7 @@ discard block |
||
65 | 69 | // If it's closing and we're not in a tag we need to open it... |
66 | 70 | if (!$in_tag) |
67 | 71 | $codeopen = true; |
72 | + } |
|
68 | 73 | // Either way we ain't in one any more. |
69 | 74 | $in_tag = false; |
70 | 75 | } |
@@ -73,17 +78,20 @@ discard block |
||
73 | 78 | { |
74 | 79 | $had_tag = true; |
75 | 80 | // If we're in a tag don't do nought! |
76 | - if (!$in_tag) |
|
77 | - $in_tag = true; |
|
81 | + if (!$in_tag) { |
|
82 | + $in_tag = true; |
|
83 | + } |
|
78 | 84 | } |
79 | 85 | } |
80 | 86 | |
81 | 87 | // If we have an open tag, close it. |
82 | - if ($in_tag) |
|
83 | - $message .= '[/code]'; |
|
88 | + if ($in_tag) { |
|
89 | + $message .= '[/code]'; |
|
90 | + } |
|
84 | 91 | // Open any ones that need to be open, only if we've never had a tag. |
85 | - if ($codeopen && !$had_tag) |
|
86 | - $message = '[code]' . $message; |
|
92 | + if ($codeopen && !$had_tag) { |
|
93 | + $message = '[code]' . $message; |
|
94 | + } |
|
87 | 95 | |
88 | 96 | // Replace code BBC with placeholders. We'll restore them at the end. |
89 | 97 | $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); |
@@ -108,23 +116,26 @@ discard block |
||
108 | 116 | fixTags($message); |
109 | 117 | |
110 | 118 | // Replace /me.+?\n with [me=name]dsf[/me]\n. |
111 | - if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) |
|
112 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
113 | - else |
|
114 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
119 | + if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) { |
|
120 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
121 | + } else { |
|
122 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
123 | + } |
|
115 | 124 | |
116 | 125 | if (!$previewing && strpos($message, '[html]') !== false) |
117 | 126 | { |
118 | - if (allowedTo('admin_forum')) |
|
119 | - $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
127 | + if (allowedTo('admin_forum')) { |
|
128 | + $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
120 | 129 | return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => ' ', ' ' => '  ', '[' => '[', ']' => ']')) . '[/html]'; |
130 | + } |
|
121 | 131 | }, $message); |
122 | 132 | |
123 | 133 | // We should edit them out, or else if an admin edits the message they will get shown... |
124 | 134 | else |
125 | 135 | { |
126 | - while (strpos($message, '[html]') !== false) |
|
127 | - $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
136 | + while (strpos($message, '[html]') !== false) { |
|
137 | + $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
138 | + } |
|
128 | 139 | } |
129 | 140 | } |
130 | 141 | |
@@ -146,10 +157,12 @@ discard block |
||
146 | 157 | |
147 | 158 | $list_open = substr_count($message, '[list]') + substr_count($message, '[list '); |
148 | 159 | $list_close = substr_count($message, '[/list]'); |
149 | - if ($list_close - $list_open > 0) |
|
150 | - $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
151 | - if ($list_open - $list_close > 0) |
|
152 | - $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
160 | + if ($list_close - $list_open > 0) { |
|
161 | + $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
162 | + } |
|
163 | + if ($list_open - $list_close > 0) { |
|
164 | + $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
165 | + } |
|
153 | 166 | |
154 | 167 | $mistake_fixes = array( |
155 | 168 | // Find [table]s not followed by [tr]. |
@@ -198,8 +211,9 @@ discard block |
||
198 | 211 | ); |
199 | 212 | |
200 | 213 | // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) |
201 | - for ($j = 0; $j < 3; $j++) |
|
202 | - $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
214 | + for ($j = 0; $j < 3; $j++) { |
|
215 | + $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
216 | + } |
|
203 | 217 | |
204 | 218 | // Remove empty bbc from the sections outside the code tags |
205 | 219 | $allowedEmpty = array( |
@@ -210,24 +224,28 @@ discard block |
||
210 | 224 | require_once($sourcedir . '/Subs.php'); |
211 | 225 | |
212 | 226 | $alltags = array(); |
213 | - foreach (($codes = parse_bbc(false)) as $code) |
|
214 | - if (!in_array($code['tag'], $allowedEmpty)) |
|
227 | + foreach (($codes = parse_bbc(false)) as $code) { |
|
228 | + if (!in_array($code['tag'], $allowedEmpty)) |
|
215 | 229 | $alltags[] = $code['tag']; |
230 | + } |
|
216 | 231 | |
217 | 232 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
218 | 233 | |
219 | - while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) |
|
220 | - $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
234 | + while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) { |
|
235 | + $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
236 | + } |
|
221 | 237 | |
222 | 238 | // Restore code blocks |
223 | - if (!empty($code_tags)) |
|
224 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
239 | + if (!empty($code_tags)) { |
|
240 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
241 | + } |
|
225 | 242 | |
226 | 243 | // Restore white space entities |
227 | - if (!$previewing) |
|
228 | - $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
229 | - else |
|
230 | - $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
244 | + if (!$previewing) { |
|
245 | + $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
246 | + } else { |
|
247 | + $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
248 | + } |
|
231 | 249 | |
232 | 250 | // Now let's quickly clean up things that will slow our parser (which are common in posted code.) |
233 | 251 | $message = strtr($message, array('[]' => '[]', '['' => '['')); |
@@ -270,8 +288,9 @@ discard block |
||
270 | 288 | return "[time]" . timeformat("$m[1]", false) . "[/time]"; |
271 | 289 | }, $message); |
272 | 290 | |
273 | - if (!empty($code_tags)) |
|
274 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
291 | + if (!empty($code_tags)) { |
|
292 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
293 | + } |
|
275 | 294 | |
276 | 295 | // Change breaks back to \n's and &nsbp; back to spaces. |
277 | 296 | return preg_replace('~<br( /)?' . '>~', "\n", str_replace(' ', ' ', $message)); |
@@ -352,8 +371,9 @@ discard block |
||
352 | 371 | ); |
353 | 372 | |
354 | 373 | // Fix each type of tag. |
355 | - foreach ($fixArray as $param) |
|
356 | - fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
374 | + foreach ($fixArray as $param) { |
|
375 | + fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
376 | + } |
|
357 | 377 | |
358 | 378 | // Now fix possible security problems with images loading links automatically... |
359 | 379 | $message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m) |
@@ -378,10 +398,11 @@ discard block |
||
378 | 398 | { |
379 | 399 | global $boardurl, $scripturl; |
380 | 400 | |
381 | - if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) |
|
382 | - $domain_url = $match[1]; |
|
383 | - else |
|
384 | - $domain_url = $boardurl . '/'; |
|
401 | + if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) { |
|
402 | + $domain_url = $match[1]; |
|
403 | + } else { |
|
404 | + $domain_url = $boardurl . '/'; |
|
405 | + } |
|
385 | 406 | |
386 | 407 | $replaces = array(); |
387 | 408 | |
@@ -389,11 +410,11 @@ discard block |
||
389 | 410 | { |
390 | 411 | $quoted = preg_match('~\[(' . $myTag . ')="~', $message); |
391 | 412 | preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '"(.*?)"' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
413 | + } elseif ($hasEqualSign) { |
|
414 | + preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
415 | + } else { |
|
416 | + preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
392 | 417 | } |
393 | - elseif ($hasEqualSign) |
|
394 | - preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
395 | - else |
|
396 | - preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
397 | 418 | |
398 | 419 | foreach ($matches[0] as $k => $dummy) |
399 | 420 | { |
@@ -406,49 +427,53 @@ discard block |
||
406 | 427 | foreach ($protocols as $protocol) |
407 | 428 | { |
408 | 429 | $found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0; |
409 | - if ($found) |
|
410 | - break; |
|
430 | + if ($found) { |
|
431 | + break; |
|
432 | + } |
|
411 | 433 | } |
412 | 434 | |
413 | 435 | if (!$found && $protocols[0] == 'http') |
414 | 436 | { |
415 | - if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') |
|
416 | - $replace = $domain_url . $replace; |
|
417 | - elseif (substr($replace, 0, 1) == '?') |
|
418 | - $replace = $scripturl . $replace; |
|
419 | - elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
437 | + if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') { |
|
438 | + $replace = $domain_url . $replace; |
|
439 | + } elseif (substr($replace, 0, 1) == '?') { |
|
440 | + $replace = $scripturl . $replace; |
|
441 | + } elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
420 | 442 | { |
421 | 443 | $replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1)); |
422 | 444 | $this_tag = 'iurl'; |
423 | 445 | $this_close = 'iurl'; |
446 | + } elseif (substr($replace, 0, 2) != '//') { |
|
447 | + $replace = $protocols[0] . '://' . $replace; |
|
424 | 448 | } |
425 | - elseif (substr($replace, 0, 2) != '//') |
|
426 | - $replace = $protocols[0] . '://' . $replace; |
|
427 | - } |
|
428 | - elseif (!$found && $protocols[0] == 'ftp') |
|
429 | - $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
430 | - elseif (!$found) |
|
431 | - $replace = $protocols[0] . '://' . $replace; |
|
432 | - |
|
433 | - if ($hasEqualSign && $embeddedUrl) |
|
434 | - $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
435 | - elseif ($hasEqualSign) |
|
436 | - $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
437 | - elseif ($embeddedUrl) |
|
438 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
439 | - else |
|
440 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
449 | + } elseif (!$found && $protocols[0] == 'ftp') { |
|
450 | + $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
451 | + } elseif (!$found) { |
|
452 | + $replace = $protocols[0] . '://' . $replace; |
|
453 | + } |
|
454 | + |
|
455 | + if ($hasEqualSign && $embeddedUrl) { |
|
456 | + $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
457 | + } elseif ($hasEqualSign) { |
|
458 | + $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
459 | + } elseif ($embeddedUrl) { |
|
460 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
461 | + } else { |
|
462 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
463 | + } |
|
441 | 464 | } |
442 | 465 | |
443 | 466 | foreach ($replaces as $k => $v) |
444 | 467 | { |
445 | - if ($k == $v) |
|
446 | - unset($replaces[$k]); |
|
468 | + if ($k == $v) { |
|
469 | + unset($replaces[$k]); |
|
470 | + } |
|
447 | 471 | } |
448 | 472 | |
449 | - if (!empty($replaces)) |
|
450 | - $message = strtr($message, $replaces); |
|
451 | -} |
|
473 | + if (!empty($replaces)) { |
|
474 | + $message = strtr($message, $replaces); |
|
475 | + } |
|
476 | + } |
|
452 | 477 | |
453 | 478 | /** |
454 | 479 | * This function sends an email to the specified recipient(s). |
@@ -492,8 +517,9 @@ discard block |
||
492 | 517 | } |
493 | 518 | |
494 | 519 | // Nothing left? Nothing else to do |
495 | - if (empty($to_array)) |
|
496 | - return true; |
|
520 | + if (empty($to_array)) { |
|
521 | + return true; |
|
522 | + } |
|
497 | 523 | |
498 | 524 | // Once upon a time, Hotmail could not interpret non-ASCII mails. |
499 | 525 | // In honour of those days, it's still called the 'hotmail fix'. |
@@ -510,15 +536,17 @@ discard block |
||
510 | 536 | } |
511 | 537 | |
512 | 538 | // Call this function recursively for the hotmail addresses. |
513 | - if (!empty($hotmail_to)) |
|
514 | - $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
539 | + if (!empty($hotmail_to)) { |
|
540 | + $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
541 | + } |
|
515 | 542 | |
516 | 543 | // The remaining addresses no longer need the fix. |
517 | 544 | $hotmail_fix = false; |
518 | 545 | |
519 | 546 | // No other addresses left? Return instantly. |
520 | - if (empty($to_array)) |
|
521 | - return $mail_result; |
|
547 | + if (empty($to_array)) { |
|
548 | + return $mail_result; |
|
549 | + } |
|
522 | 550 | } |
523 | 551 | |
524 | 552 | // Get rid of entities. |
@@ -543,13 +571,15 @@ discard block |
||
543 | 571 | $headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break; |
544 | 572 | $headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break; |
545 | 573 | |
546 | - if ($message_id !== null && empty($modSettings['mail_no_message_id'])) |
|
547 | - $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
574 | + if ($message_id !== null && empty($modSettings['mail_no_message_id'])) { |
|
575 | + $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
576 | + } |
|
548 | 577 | $headers .= 'X-Mailer: SMF' . $line_break; |
549 | 578 | |
550 | 579 | // Pass this to the integration before we start modifying the output -- it'll make it easier later. |
551 | - if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) |
|
552 | - return false; |
|
580 | + if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) { |
|
581 | + return false; |
|
582 | + } |
|
553 | 583 | |
554 | 584 | // Save the original message... |
555 | 585 | $orig_message = $message; |
@@ -598,17 +628,19 @@ discard block |
||
598 | 628 | } |
599 | 629 | |
600 | 630 | // Are we using the mail queue, if so this is where we butt in... |
601 | - if ($priority != 0) |
|
602 | - return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
631 | + if ($priority != 0) { |
|
632 | + return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
633 | + } |
|
603 | 634 | |
604 | 635 | // If it's a priority mail, send it now - note though that this should NOT be used for sending many at once. |
605 | 636 | elseif (!empty($modSettings['mail_limit'])) |
606 | 637 | { |
607 | 638 | list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']); |
608 | - if (empty($mails_this_minute) || time() > $last_mail_time + 60) |
|
609 | - $new_queue_stat = time() . '|' . 1; |
|
610 | - else |
|
611 | - $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
639 | + if (empty($mails_this_minute) || time() > $last_mail_time + 60) { |
|
640 | + $new_queue_stat = time() . '|' . 1; |
|
641 | + } else { |
|
642 | + $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
643 | + } |
|
612 | 644 | |
613 | 645 | updateSettings(array('mail_recent' => $new_queue_stat)); |
614 | 646 | } |
@@ -642,8 +674,7 @@ discard block |
||
642 | 674 | log_error(sprintf($txt['mail_send_unable'], $to)); |
643 | 675 | $mail_result = false; |
644 | 676 | } |
645 | - } |
|
646 | - catch(ErrorException $e) |
|
677 | + } catch(ErrorException $e) |
|
647 | 678 | { |
648 | 679 | log_error($e->getMessage(), 'general', $e->getFile(), $e->getLine()); |
649 | 680 | log_error(sprintf($txt['mail_send_unable'], $to)); |
@@ -653,12 +684,13 @@ discard block |
||
653 | 684 | |
654 | 685 | // Wait, wait, I'm still sending here! |
655 | 686 | @set_time_limit(300); |
656 | - if (function_exists('apache_reset_timeout')) |
|
657 | - @apache_reset_timeout(); |
|
687 | + if (function_exists('apache_reset_timeout')) { |
|
688 | + @apache_reset_timeout(); |
|
689 | + } |
|
658 | 690 | } |
691 | + } else { |
|
692 | + $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
659 | 693 | } |
660 | - else |
|
661 | - $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
662 | 694 | |
663 | 695 | // Everything go smoothly? |
664 | 696 | return $mail_result; |
@@ -684,8 +716,9 @@ discard block |
||
684 | 716 | static $cur_insert = array(); |
685 | 717 | static $cur_insert_len = 0; |
686 | 718 | |
687 | - if ($cur_insert_len == 0) |
|
688 | - $cur_insert = array(); |
|
719 | + if ($cur_insert_len == 0) { |
|
720 | + $cur_insert = array(); |
|
721 | + } |
|
689 | 722 | |
690 | 723 | // If we're flushing, make the final inserts - also if we're near the MySQL length limit! |
691 | 724 | if (($flush || $cur_insert_len > 800000) && !empty($cur_insert)) |
@@ -760,8 +793,9 @@ discard block |
||
760 | 793 | } |
761 | 794 | |
762 | 795 | // If they are using SSI there is a good chance obExit will never be called. So lets be nice and flush it for them. |
763 | - if (SMF === 'SSI' || SMF === 'BACKGROUND') |
|
764 | - return AddMailQueue(true); |
|
796 | + if (SMF === 'SSI' || SMF === 'BACKGROUND') { |
|
797 | + return AddMailQueue(true); |
|
798 | + } |
|
765 | 799 | |
766 | 800 | return true; |
767 | 801 | } |
@@ -792,23 +826,26 @@ discard block |
||
792 | 826 | 'sent' => array() |
793 | 827 | ); |
794 | 828 | |
795 | - if ($from === null) |
|
796 | - $from = array( |
|
829 | + if ($from === null) { |
|
830 | + $from = array( |
|
797 | 831 | 'id' => $user_info['id'], |
798 | 832 | 'name' => $user_info['name'], |
799 | 833 | 'username' => $user_info['username'] |
800 | 834 | ); |
835 | + } |
|
801 | 836 | |
802 | 837 | // This is the one that will go in their inbox. |
803 | 838 | $htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES); |
804 | 839 | preparsecode($htmlmessage); |
805 | 840 | $htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => '')); |
806 | - if ($smcFunc['strlen']($htmlsubject) > 100) |
|
807 | - $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
841 | + if ($smcFunc['strlen']($htmlsubject) > 100) { |
|
842 | + $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
843 | + } |
|
808 | 844 | |
809 | 845 | // Make sure is an array |
810 | - if (!is_array($recipients)) |
|
811 | - $recipients = array($recipients); |
|
846 | + if (!is_array($recipients)) { |
|
847 | + $recipients = array($recipients); |
|
848 | + } |
|
812 | 849 | |
813 | 850 | // Integrated PMs |
814 | 851 | call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message)); |
@@ -836,21 +873,23 @@ discard block |
||
836 | 873 | 'usernames' => array_keys($usernames), |
837 | 874 | ) |
838 | 875 | ); |
839 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
840 | - if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
876 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
877 | + if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
841 | 878 | $usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member']; |
879 | + } |
|
842 | 880 | $smcFunc['db_free_result']($request); |
843 | 881 | |
844 | 882 | // Replace the usernames with IDs. Drop usernames that couldn't be found. |
845 | - foreach ($recipients as $rec_type => $rec) |
|
846 | - foreach ($rec as $id => $member) |
|
883 | + foreach ($recipients as $rec_type => $rec) { |
|
884 | + foreach ($rec as $id => $member) |
|
847 | 885 | { |
848 | 886 | if (is_numeric($recipients[$rec_type][$id])) |
849 | 887 | continue; |
888 | + } |
|
850 | 889 | |
851 | - if (!empty($usernames[$member])) |
|
852 | - $recipients[$rec_type][$id] = $usernames[$member]; |
|
853 | - else |
|
890 | + if (!empty($usernames[$member])) { |
|
891 | + $recipients[$rec_type][$id] = $usernames[$member]; |
|
892 | + } else |
|
854 | 893 | { |
855 | 894 | $log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]); |
856 | 895 | unset($recipients[$rec_type][$id]); |
@@ -888,8 +927,9 @@ discard block |
||
888 | 927 | $delete = false; |
889 | 928 | foreach ($criteria as $criterium) |
890 | 929 | { |
891 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) |
|
892 | - $delete = true; |
|
930 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) { |
|
931 | + $delete = true; |
|
932 | + } |
|
893 | 933 | // If we're adding and one criteria don't match then we stop! |
894 | 934 | elseif (!$row['is_or']) |
895 | 935 | { |
@@ -897,8 +937,9 @@ discard block |
||
897 | 937 | break; |
898 | 938 | } |
899 | 939 | } |
900 | - if ($delete) |
|
901 | - $deletes[$row['id_member']] = 1; |
|
940 | + if ($delete) { |
|
941 | + $deletes[$row['id_member']] = 1; |
|
942 | + } |
|
902 | 943 | } |
903 | 944 | $smcFunc['db_free_result']($request); |
904 | 945 | |
@@ -913,8 +954,9 @@ discard block |
||
913 | 954 | array( |
914 | 955 | ) |
915 | 956 | ); |
916 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
917 | - $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
957 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
958 | + $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
959 | + } |
|
918 | 960 | $smcFunc['db_free_result']($request); |
919 | 961 | } |
920 | 962 | |
@@ -922,8 +964,9 @@ discard block |
||
922 | 964 | require_once($sourcedir . '/Subs-Members.php'); |
923 | 965 | $pmReadGroups = groupsAllowedTo('pm_read'); |
924 | 966 | |
925 | - if (empty($modSettings['permission_enable_deny'])) |
|
926 | - $pmReadGroups['denied'] = array(); |
|
967 | + if (empty($modSettings['permission_enable_deny'])) { |
|
968 | + $pmReadGroups['denied'] = array(); |
|
969 | + } |
|
927 | 970 | |
928 | 971 | // Load their alert preferences |
929 | 972 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -955,8 +998,9 @@ discard block |
||
955 | 998 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
956 | 999 | { |
957 | 1000 | // Don't do anything for members to be deleted! |
958 | - if (isset($deletes[$row['id_member']])) |
|
959 | - continue; |
|
1001 | + if (isset($deletes[$row['id_member']])) { |
|
1002 | + continue; |
|
1003 | + } |
|
960 | 1004 | |
961 | 1005 | // Load the preferences for this member (if any) |
962 | 1006 | $prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array(); |
@@ -977,8 +1021,9 @@ discard block |
||
977 | 1021 | { |
978 | 1022 | foreach ($groups as $id) |
979 | 1023 | { |
980 | - if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) |
|
981 | - $message_limit = $message_limit_cache[$id]; |
|
1024 | + if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) { |
|
1025 | + $message_limit = $message_limit_cache[$id]; |
|
1026 | + } |
|
982 | 1027 | } |
983 | 1028 | |
984 | 1029 | if ($message_limit > 0 && $message_limit <= $row['instant_messages']) |
@@ -1026,8 +1071,9 @@ discard block |
||
1026 | 1071 | $smcFunc['db_free_result']($request); |
1027 | 1072 | |
1028 | 1073 | // Only 'send' the message if there are any recipients left. |
1029 | - if (empty($all_to)) |
|
1030 | - return $log; |
|
1074 | + if (empty($all_to)) { |
|
1075 | + return $log; |
|
1076 | + } |
|
1031 | 1077 | |
1032 | 1078 | // Insert the message itself and then grab the last insert id. |
1033 | 1079 | $id_pm = $smcFunc['db_insert']('', |
@@ -1048,8 +1094,8 @@ discard block |
||
1048 | 1094 | if (!empty($id_pm)) |
1049 | 1095 | { |
1050 | 1096 | // If this is new we need to set it part of it's own conversation. |
1051 | - if (empty($pm_head)) |
|
1052 | - $smcFunc['db_query']('', ' |
|
1097 | + if (empty($pm_head)) { |
|
1098 | + $smcFunc['db_query']('', ' |
|
1053 | 1099 | UPDATE {db_prefix}personal_messages |
1054 | 1100 | SET id_pm_head = {int:id_pm_head} |
1055 | 1101 | WHERE id_pm = {int:id_pm_head}', |
@@ -1057,6 +1103,7 @@ discard block |
||
1057 | 1103 | 'id_pm_head' => $id_pm, |
1058 | 1104 | ) |
1059 | 1105 | ); |
1106 | + } |
|
1060 | 1107 | |
1061 | 1108 | // Some people think manually deleting personal_messages is fun... it's not. We protect against it though :) |
1062 | 1109 | $smcFunc['db_query']('', ' |
@@ -1072,8 +1119,9 @@ discard block |
||
1072 | 1119 | foreach ($all_to as $to) |
1073 | 1120 | { |
1074 | 1121 | $insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1); |
1075 | - if (!in_array($to, $recipients['bcc'])) |
|
1076 | - $to_list[] = $to; |
|
1122 | + if (!in_array($to, $recipients['bcc'])) { |
|
1123 | + $to_list[] = $to; |
|
1124 | + } |
|
1077 | 1125 | } |
1078 | 1126 | |
1079 | 1127 | $smcFunc['db_insert']('insert', |
@@ -1091,9 +1139,9 @@ discard block |
||
1091 | 1139 | { |
1092 | 1140 | censorText($message); |
1093 | 1141 | $message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']'))))); |
1142 | + } else { |
|
1143 | + $message = ''; |
|
1094 | 1144 | } |
1095 | - else |
|
1096 | - $message = ''; |
|
1097 | 1145 | |
1098 | 1146 | $to_names = array(); |
1099 | 1147 | if (count($to_list) > 1) |
@@ -1106,8 +1154,9 @@ discard block |
||
1106 | 1154 | 'to_members' => $to_list, |
1107 | 1155 | ) |
1108 | 1156 | ); |
1109 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1110 | - $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1158 | + $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1159 | + } |
|
1111 | 1160 | $smcFunc['db_free_result']($request); |
1112 | 1161 | } |
1113 | 1162 | $replacements = array( |
@@ -1135,11 +1184,13 @@ discard block |
||
1135 | 1184 | loadLanguage('index+PersonalMessage'); |
1136 | 1185 | |
1137 | 1186 | // Add one to their unread and read message counts. |
1138 | - foreach ($all_to as $k => $id) |
|
1139 | - if (isset($deletes[$id])) |
|
1187 | + foreach ($all_to as $k => $id) { |
|
1188 | + if (isset($deletes[$id])) |
|
1140 | 1189 | unset($all_to[$k]); |
1141 | - if (!empty($all_to)) |
|
1142 | - updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1190 | + } |
|
1191 | + if (!empty($all_to)) { |
|
1192 | + updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1193 | + } |
|
1143 | 1194 | |
1144 | 1195 | return $log; |
1145 | 1196 | } |
@@ -1169,15 +1220,17 @@ discard block |
||
1169 | 1220 | // Let's, for now, assume there are only 'ish characters. |
1170 | 1221 | $simple = true; |
1171 | 1222 | |
1172 | - foreach ($matches[1] as $entity) |
|
1173 | - if ($entity > 128) |
|
1223 | + foreach ($matches[1] as $entity) { |
|
1224 | + if ($entity > 128) |
|
1174 | 1225 | $simple = false; |
1226 | + } |
|
1175 | 1227 | unset($matches); |
1176 | 1228 | |
1177 | - if ($simple) |
|
1178 | - $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1229 | + if ($simple) { |
|
1230 | + $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1179 | 1231 | { |
1180 | 1232 | return chr("$m[1]"); |
1233 | + } |
|
1181 | 1234 | }, $string); |
1182 | 1235 | else |
1183 | 1236 | { |
@@ -1185,8 +1238,9 @@ discard block |
||
1185 | 1238 | if (!$context['utf8'] && function_exists('iconv')) |
1186 | 1239 | { |
1187 | 1240 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1188 | - if ($newstring) |
|
1189 | - $string = $newstring; |
|
1241 | + if ($newstring) { |
|
1242 | + $string = $newstring; |
|
1243 | + } |
|
1190 | 1244 | } |
1191 | 1245 | |
1192 | 1246 | $string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string); |
@@ -1202,23 +1256,25 @@ discard block |
||
1202 | 1256 | if (!$context['utf8'] && function_exists('iconv')) |
1203 | 1257 | { |
1204 | 1258 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1205 | - if ($newstring) |
|
1206 | - $string = $newstring; |
|
1259 | + if ($newstring) { |
|
1260 | + $string = $newstring; |
|
1261 | + } |
|
1207 | 1262 | } |
1208 | 1263 | |
1209 | 1264 | $entityConvert = function($m) |
1210 | 1265 | { |
1211 | 1266 | $c = $m[1]; |
1212 | - if (strlen($c) === 1 && ord($c[0]) <= 0x7F) |
|
1213 | - return $c; |
|
1214 | - elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) |
|
1215 | - return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1216 | - elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) |
|
1217 | - return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1218 | - elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) |
|
1219 | - return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1220 | - else |
|
1221 | - return ""; |
|
1267 | + if (strlen($c) === 1 && ord($c[0]) <= 0x7F) { |
|
1268 | + return $c; |
|
1269 | + } elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) { |
|
1270 | + return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1271 | + } elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) { |
|
1272 | + return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1273 | + } elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) { |
|
1274 | + return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1275 | + } else { |
|
1276 | + return ""; |
|
1277 | + } |
|
1222 | 1278 | }; |
1223 | 1279 | |
1224 | 1280 | // Convert all 'special' characters to HTML entities. |
@@ -1232,19 +1288,20 @@ discard block |
||
1232 | 1288 | $string = base64_encode($string); |
1233 | 1289 | |
1234 | 1290 | // Show the characterset and the transfer-encoding for header strings. |
1235 | - if ($with_charset) |
|
1236 | - $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1291 | + if ($with_charset) { |
|
1292 | + $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1293 | + } |
|
1237 | 1294 | |
1238 | 1295 | // Break it up in lines (mail body). |
1239 | - else |
|
1240 | - $string = chunk_split($string, 76, $line_break); |
|
1296 | + else { |
|
1297 | + $string = chunk_split($string, 76, $line_break); |
|
1298 | + } |
|
1241 | 1299 | |
1242 | 1300 | return array($charset, $string, 'base64'); |
1301 | + } else { |
|
1302 | + return array($charset, $string, '7bit'); |
|
1303 | + } |
|
1243 | 1304 | } |
1244 | - |
|
1245 | - else |
|
1246 | - return array($charset, $string, '7bit'); |
|
1247 | -} |
|
1248 | 1305 | |
1249 | 1306 | /** |
1250 | 1307 | * Sends mail, like mail() but over SMTP. |
@@ -1268,8 +1325,9 @@ discard block |
||
1268 | 1325 | if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
1269 | 1326 | { |
1270 | 1327 | $socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2); |
1271 | - if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) |
|
1272 | - $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1328 | + if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) { |
|
1329 | + $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1330 | + } |
|
1273 | 1331 | |
1274 | 1332 | if ($socket) |
1275 | 1333 | { |
@@ -1290,8 +1348,9 @@ discard block |
||
1290 | 1348 | // Maybe we can still save this? The port might be wrong. |
1291 | 1349 | if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25)) |
1292 | 1350 | { |
1293 | - if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) |
|
1294 | - log_error($txt['smtp_port_ssl']); |
|
1351 | + if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) { |
|
1352 | + log_error($txt['smtp_port_ssl']); |
|
1353 | + } |
|
1295 | 1354 | } |
1296 | 1355 | |
1297 | 1356 | // Unable to connect! Don't show any error message, but just log one and try to continue anyway. |
@@ -1303,20 +1362,23 @@ discard block |
||
1303 | 1362 | } |
1304 | 1363 | |
1305 | 1364 | // Wait for a response of 220, without "-" continuer. |
1306 | - if (!server_parse(null, $socket, '220')) |
|
1307 | - return false; |
|
1365 | + if (!server_parse(null, $socket, '220')) { |
|
1366 | + return false; |
|
1367 | + } |
|
1308 | 1368 | |
1309 | 1369 | // Try and determine the servers name, fall back to the mail servers if not found |
1310 | 1370 | $helo = false; |
1311 | - if (function_exists('gethostname') && gethostname() !== false) |
|
1312 | - $helo = gethostname(); |
|
1313 | - elseif (function_exists('php_uname')) |
|
1314 | - $helo = php_uname('n'); |
|
1315 | - elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME'])) |
|
1316 | - $helo = $_SERVER['SERVER_NAME']; |
|
1371 | + if (function_exists('gethostname') && gethostname() !== false) { |
|
1372 | + $helo = gethostname(); |
|
1373 | + } elseif (function_exists('php_uname')) { |
|
1374 | + $helo = php_uname('n'); |
|
1375 | + } elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME'])) { |
|
1376 | + $helo = $_SERVER['SERVER_NAME']; |
|
1377 | + } |
|
1317 | 1378 | |
1318 | - if (empty($helo)) |
|
1319 | - $helo = $modSettings['smtp_host']; |
|
1379 | + if (empty($helo)) { |
|
1380 | + $helo = $modSettings['smtp_host']; |
|
1381 | + } |
|
1320 | 1382 | |
1321 | 1383 | // SMTP = 1, SMTP - STARTTLS = 2 |
1322 | 1384 | if (in_array($modSettings['mail_type'], array(1, 2)) && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
@@ -1328,33 +1390,39 @@ discard block |
||
1328 | 1390 | if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response)) |
1329 | 1391 | { |
1330 | 1392 | // Send STARTTLS to enable encryption |
1331 | - if (!server_parse('STARTTLS', $socket, '220')) |
|
1332 | - return false; |
|
1393 | + if (!server_parse('STARTTLS', $socket, '220')) { |
|
1394 | + return false; |
|
1395 | + } |
|
1333 | 1396 | // Enable the encryption |
1334 | - if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) |
|
1335 | - return false; |
|
1397 | + if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
|
1398 | + return false; |
|
1399 | + } |
|
1336 | 1400 | // Send the EHLO command again |
1337 | - if (!server_parse('EHLO ' . $helo, $socket, null) == '250') |
|
1338 | - return false; |
|
1401 | + if (!server_parse('EHLO ' . $helo, $socket, null) == '250') { |
|
1402 | + return false; |
|
1403 | + } |
|
1339 | 1404 | } |
1340 | 1405 | |
1341 | - if (!server_parse('AUTH LOGIN', $socket, '334')) |
|
1342 | - return false; |
|
1406 | + if (!server_parse('AUTH LOGIN', $socket, '334')) { |
|
1407 | + return false; |
|
1408 | + } |
|
1343 | 1409 | // Send the username and password, encoded. |
1344 | - if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) |
|
1345 | - return false; |
|
1410 | + if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) { |
|
1411 | + return false; |
|
1412 | + } |
|
1346 | 1413 | // The password is already encoded ;) |
1347 | - if (!server_parse($modSettings['smtp_password'], $socket, '235')) |
|
1348 | - return false; |
|
1414 | + if (!server_parse($modSettings['smtp_password'], $socket, '235')) { |
|
1415 | + return false; |
|
1416 | + } |
|
1417 | + } elseif (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1418 | + return false; |
|
1349 | 1419 | } |
1350 | - elseif (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1351 | - return false; |
|
1352 | - } |
|
1353 | - else |
|
1420 | + } else |
|
1354 | 1421 | { |
1355 | 1422 | // Just say "helo". |
1356 | - if (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1357 | - return false; |
|
1423 | + if (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1424 | + return false; |
|
1425 | + } |
|
1358 | 1426 | } |
1359 | 1427 | |
1360 | 1428 | // Fix the message for any lines beginning with a period! (the first is ignored, you see.) |
@@ -1367,31 +1435,38 @@ discard block |
||
1367 | 1435 | // Reset the connection to send another email. |
1368 | 1436 | if ($i != 0) |
1369 | 1437 | { |
1370 | - if (!server_parse('RSET', $socket, '250')) |
|
1371 | - return false; |
|
1438 | + if (!server_parse('RSET', $socket, '250')) { |
|
1439 | + return false; |
|
1440 | + } |
|
1372 | 1441 | } |
1373 | 1442 | |
1374 | 1443 | // From, to, and then start the data... |
1375 | - if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) |
|
1376 | - return false; |
|
1377 | - if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) |
|
1378 | - return false; |
|
1379 | - if (!server_parse('DATA', $socket, '354')) |
|
1380 | - return false; |
|
1444 | + if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) { |
|
1445 | + return false; |
|
1446 | + } |
|
1447 | + if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) { |
|
1448 | + return false; |
|
1449 | + } |
|
1450 | + if (!server_parse('DATA', $socket, '354')) { |
|
1451 | + return false; |
|
1452 | + } |
|
1381 | 1453 | fputs($socket, 'Subject: ' . $subject . "\r\n"); |
1382 | - if (strlen($mail_to) > 0) |
|
1383 | - fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1454 | + if (strlen($mail_to) > 0) { |
|
1455 | + fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1456 | + } |
|
1384 | 1457 | fputs($socket, $headers . "\r\n\r\n"); |
1385 | 1458 | fputs($socket, $message . "\r\n"); |
1386 | 1459 | |
1387 | 1460 | // Send a ., or in other words "end of data". |
1388 | - if (!server_parse('.', $socket, '250')) |
|
1389 | - return false; |
|
1461 | + if (!server_parse('.', $socket, '250')) { |
|
1462 | + return false; |
|
1463 | + } |
|
1390 | 1464 | |
1391 | 1465 | // Almost done, almost done... don't stop me just yet! |
1392 | 1466 | @set_time_limit(300); |
1393 | - if (function_exists('apache_reset_timeout')) |
|
1394 | - @apache_reset_timeout(); |
|
1467 | + if (function_exists('apache_reset_timeout')) { |
|
1468 | + @apache_reset_timeout(); |
|
1469 | + } |
|
1395 | 1470 | } |
1396 | 1471 | fputs($socket, 'QUIT' . "\r\n"); |
1397 | 1472 | fclose($socket); |
@@ -1415,8 +1490,9 @@ discard block |
||
1415 | 1490 | { |
1416 | 1491 | global $txt; |
1417 | 1492 | |
1418 | - if ($message !== null) |
|
1419 | - fputs($socket, $message . "\r\n"); |
|
1493 | + if ($message !== null) { |
|
1494 | + fputs($socket, $message . "\r\n"); |
|
1495 | + } |
|
1420 | 1496 | |
1421 | 1497 | // No response yet. |
1422 | 1498 | $server_response = ''; |
@@ -1432,8 +1508,9 @@ discard block |
||
1432 | 1508 | $response .= $server_response; |
1433 | 1509 | } |
1434 | 1510 | |
1435 | - if ($code === null) |
|
1436 | - return substr($server_response, 0, 3); |
|
1511 | + if ($code === null) { |
|
1512 | + return substr($server_response, 0, 3); |
|
1513 | + } |
|
1437 | 1514 | |
1438 | 1515 | if (substr($server_response, 0, 3) != $code) |
1439 | 1516 | { |
@@ -1463,8 +1540,9 @@ discard block |
||
1463 | 1540 | // Create a pspell or enchant dictionary resource |
1464 | 1541 | $dict = spell_init(); |
1465 | 1542 | |
1466 | - if (!isset($_POST['spellstring']) || !$dict) |
|
1467 | - die; |
|
1543 | + if (!isset($_POST['spellstring']) || !$dict) { |
|
1544 | + die; |
|
1545 | + } |
|
1468 | 1546 | |
1469 | 1547 | // Construct a bit of Javascript code. |
1470 | 1548 | $context['spell_js'] = ' |
@@ -1482,8 +1560,9 @@ discard block |
||
1482 | 1560 | $check_word = explode('|', $alphas[$i]); |
1483 | 1561 | |
1484 | 1562 | // If the word is a known word, or spelled right... |
1485 | - if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) |
|
1486 | - continue; |
|
1563 | + if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) { |
|
1564 | + continue; |
|
1565 | + } |
|
1487 | 1566 | |
1488 | 1567 | // Find the word, and move up the "last occurrence" to here. |
1489 | 1568 | $found_words = true; |
@@ -1497,20 +1576,23 @@ discard block |
||
1497 | 1576 | if (!empty($suggestions)) |
1498 | 1577 | { |
1499 | 1578 | // But first check they aren't going to be censored - no naughty words! |
1500 | - foreach ($suggestions as $k => $word) |
|
1501 | - if ($suggestions[$k] != censorText($word)) |
|
1579 | + foreach ($suggestions as $k => $word) { |
|
1580 | + if ($suggestions[$k] != censorText($word)) |
|
1502 | 1581 | unset($suggestions[$k]); |
1582 | + } |
|
1503 | 1583 | |
1504 | - if (!empty($suggestions)) |
|
1505 | - $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1584 | + if (!empty($suggestions)) { |
|
1585 | + $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1586 | + } |
|
1506 | 1587 | } |
1507 | 1588 | |
1508 | 1589 | $context['spell_js'] .= ']),'; |
1509 | 1590 | } |
1510 | 1591 | |
1511 | 1592 | // If words were found, take off the last comma. |
1512 | - if ($found_words) |
|
1513 | - $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1593 | + if ($found_words) { |
|
1594 | + $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1595 | + } |
|
1514 | 1596 | |
1515 | 1597 | $context['spell_js'] .= ' |
1516 | 1598 | );'; |
@@ -1545,11 +1627,13 @@ discard block |
||
1545 | 1627 | global $user_info, $smcFunc; |
1546 | 1628 | |
1547 | 1629 | // Can't do it if there's no topics. |
1548 | - if (empty($topics)) |
|
1549 | - return; |
|
1630 | + if (empty($topics)) { |
|
1631 | + return; |
|
1632 | + } |
|
1550 | 1633 | // It must be an array - it must! |
1551 | - if (!is_array($topics)) |
|
1552 | - $topics = array($topics); |
|
1634 | + if (!is_array($topics)) { |
|
1635 | + $topics = array($topics); |
|
1636 | + } |
|
1553 | 1637 | |
1554 | 1638 | // Get the subject and body... |
1555 | 1639 | $result = $smcFunc['db_query']('', ' |
@@ -1597,14 +1681,15 @@ discard block |
||
1597 | 1681 | } |
1598 | 1682 | $smcFunc['db_free_result']($result); |
1599 | 1683 | |
1600 | - if (!empty($task_rows)) |
|
1601 | - $smcFunc['db_insert']('', |
|
1684 | + if (!empty($task_rows)) { |
|
1685 | + $smcFunc['db_insert']('', |
|
1602 | 1686 | '{db_prefix}background_tasks', |
1603 | 1687 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1604 | 1688 | $task_rows, |
1605 | 1689 | array('id_task') |
1606 | 1690 | ); |
1607 | -} |
|
1691 | + } |
|
1692 | + } |
|
1608 | 1693 | |
1609 | 1694 | /** |
1610 | 1695 | * Create a post, either as new topic (id_topic = 0) or in an existing one. |
@@ -1642,9 +1727,9 @@ discard block |
||
1642 | 1727 | $msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true; |
1643 | 1728 | |
1644 | 1729 | // We need to know if the topic is approved. If we're told that's great - if not find out. |
1645 | - if (!$modSettings['postmod_active']) |
|
1646 | - $topicOptions['is_approved'] = true; |
|
1647 | - elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1730 | + if (!$modSettings['postmod_active']) { |
|
1731 | + $topicOptions['is_approved'] = true; |
|
1732 | + } elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1648 | 1733 | { |
1649 | 1734 | $request = $smcFunc['db_query']('', ' |
1650 | 1735 | SELECT approved |
@@ -1667,8 +1752,7 @@ discard block |
||
1667 | 1752 | $posterOptions['id'] = 0; |
1668 | 1753 | $posterOptions['name'] = $txt['guest_title']; |
1669 | 1754 | $posterOptions['email'] = ''; |
1670 | - } |
|
1671 | - elseif ($posterOptions['id'] != $user_info['id']) |
|
1755 | + } elseif ($posterOptions['id'] != $user_info['id']) |
|
1672 | 1756 | { |
1673 | 1757 | $request = $smcFunc['db_query']('', ' |
1674 | 1758 | SELECT member_name, email_address |
@@ -1686,12 +1770,11 @@ discard block |
||
1686 | 1770 | $posterOptions['id'] = 0; |
1687 | 1771 | $posterOptions['name'] = $txt['guest_title']; |
1688 | 1772 | $posterOptions['email'] = ''; |
1773 | + } else { |
|
1774 | + list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1689 | 1775 | } |
1690 | - else |
|
1691 | - list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1692 | 1776 | $smcFunc['db_free_result']($request); |
1693 | - } |
|
1694 | - else |
|
1777 | + } else |
|
1695 | 1778 | { |
1696 | 1779 | $posterOptions['name'] = $user_info['name']; |
1697 | 1780 | $posterOptions['email'] = $user_info['email']; |
@@ -1701,8 +1784,9 @@ discard block |
||
1701 | 1784 | if (!empty($modSettings['enable_mentions'])) |
1702 | 1785 | { |
1703 | 1786 | $msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']); |
1704 | - if (!empty($msgOptions['mentioned_members'])) |
|
1705 | - $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1787 | + if (!empty($msgOptions['mentioned_members'])) { |
|
1788 | + $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1789 | + } |
|
1706 | 1790 | } |
1707 | 1791 | |
1708 | 1792 | // It's do or die time: forget any user aborts! |
@@ -1735,12 +1819,13 @@ discard block |
||
1735 | 1819 | ); |
1736 | 1820 | |
1737 | 1821 | // Something went wrong creating the message... |
1738 | - if (empty($msgOptions['id'])) |
|
1739 | - return false; |
|
1822 | + if (empty($msgOptions['id'])) { |
|
1823 | + return false; |
|
1824 | + } |
|
1740 | 1825 | |
1741 | 1826 | // Fix the attachments. |
1742 | - if (!empty($msgOptions['attachments'])) |
|
1743 | - $smcFunc['db_query']('', ' |
|
1827 | + if (!empty($msgOptions['attachments'])) { |
|
1828 | + $smcFunc['db_query']('', ' |
|
1744 | 1829 | UPDATE {db_prefix}attachments |
1745 | 1830 | SET id_msg = {int:id_msg} |
1746 | 1831 | WHERE id_attach IN ({array_int:attachment_list})', |
@@ -1749,6 +1834,7 @@ discard block |
||
1749 | 1834 | 'id_msg' => $msgOptions['id'], |
1750 | 1835 | ) |
1751 | 1836 | ); |
1837 | + } |
|
1752 | 1838 | |
1753 | 1839 | // What if we want to export new posts out to a CMS? |
1754 | 1840 | call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); |
@@ -1825,20 +1911,23 @@ discard block |
||
1825 | 1911 | 'id_topic' => $topicOptions['id'], |
1826 | 1912 | 'counter_increment' => 1, |
1827 | 1913 | ); |
1828 | - if ($msgOptions['approved']) |
|
1829 | - $topics_columns = array( |
|
1914 | + if ($msgOptions['approved']) { |
|
1915 | + $topics_columns = array( |
|
1830 | 1916 | 'id_member_updated = {int:poster_id}', |
1831 | 1917 | 'id_last_msg = {int:id_msg}', |
1832 | 1918 | 'num_replies = num_replies + {int:counter_increment}', |
1833 | 1919 | ); |
1834 | - else |
|
1835 | - $topics_columns = array( |
|
1920 | + } else { |
|
1921 | + $topics_columns = array( |
|
1836 | 1922 | 'unapproved_posts = unapproved_posts + {int:counter_increment}', |
1837 | 1923 | ); |
1838 | - if ($topicOptions['lock_mode'] !== null) |
|
1839 | - $topics_columns[] = 'locked = {int:locked}'; |
|
1840 | - if ($topicOptions['sticky_mode'] !== null) |
|
1841 | - $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1924 | + } |
|
1925 | + if ($topicOptions['lock_mode'] !== null) { |
|
1926 | + $topics_columns[] = 'locked = {int:locked}'; |
|
1927 | + } |
|
1928 | + if ($topicOptions['sticky_mode'] !== null) { |
|
1929 | + $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1930 | + } |
|
1842 | 1931 | |
1843 | 1932 | call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); |
1844 | 1933 | |
@@ -1867,8 +1956,8 @@ discard block |
||
1867 | 1956 | ); |
1868 | 1957 | |
1869 | 1958 | // Increase the number of posts and topics on the board. |
1870 | - if ($msgOptions['approved']) |
|
1871 | - $smcFunc['db_query']('', ' |
|
1959 | + if ($msgOptions['approved']) { |
|
1960 | + $smcFunc['db_query']('', ' |
|
1872 | 1961 | UPDATE {db_prefix}boards |
1873 | 1962 | SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . ' |
1874 | 1963 | WHERE id_board = {int:id_board}', |
@@ -1876,7 +1965,7 @@ discard block |
||
1876 | 1965 | 'id_board' => $topicOptions['board'], |
1877 | 1966 | ) |
1878 | 1967 | ); |
1879 | - else |
|
1968 | + } else |
|
1880 | 1969 | { |
1881 | 1970 | $smcFunc['db_query']('', ' |
1882 | 1971 | UPDATE {db_prefix}boards |
@@ -1946,8 +2035,8 @@ discard block |
||
1946 | 2035 | } |
1947 | 2036 | } |
1948 | 2037 | |
1949 | - if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) |
|
1950 | - $smcFunc['db_insert']('', |
|
2038 | + if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) { |
|
2039 | + $smcFunc['db_insert']('', |
|
1951 | 2040 | '{db_prefix}background_tasks', |
1952 | 2041 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1953 | 2042 | array( |
@@ -1959,19 +2048,22 @@ discard block |
||
1959 | 2048 | ), |
1960 | 2049 | array('id_task') |
1961 | 2050 | ); |
2051 | + } |
|
1962 | 2052 | |
1963 | 2053 | // If there's a custom search index, it may need updating... |
1964 | 2054 | require_once($sourcedir . '/Search.php'); |
1965 | 2055 | $searchAPI = findSearchAPI(); |
1966 | - if (is_callable(array($searchAPI, 'postCreated'))) |
|
1967 | - $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2056 | + if (is_callable(array($searchAPI, 'postCreated'))) { |
|
2057 | + $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2058 | + } |
|
1968 | 2059 | |
1969 | 2060 | // Increase the post counter for the user that created the post. |
1970 | 2061 | if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved']) |
1971 | 2062 | { |
1972 | 2063 | // Are you the one that happened to create this post? |
1973 | - if ($user_info['id'] == $posterOptions['id']) |
|
1974 | - $user_info['posts']++; |
|
2064 | + if ($user_info['id'] == $posterOptions['id']) { |
|
2065 | + $user_info['posts']++; |
|
2066 | + } |
|
1975 | 2067 | updateMemberData($posterOptions['id'], array('posts' => '+')); |
1976 | 2068 | } |
1977 | 2069 | |
@@ -1979,19 +2071,21 @@ discard block |
||
1979 | 2071 | $_SESSION['last_read_topic'] = 0; |
1980 | 2072 | |
1981 | 2073 | // Better safe than sorry. |
1982 | - if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) |
|
1983 | - $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2074 | + if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) { |
|
2075 | + $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2076 | + } |
|
1984 | 2077 | |
1985 | 2078 | // Update all the stats so everyone knows about this new topic and message. |
1986 | 2079 | updateStats('message', true, $msgOptions['id']); |
1987 | 2080 | |
1988 | 2081 | // Update the last message on the board assuming it's approved AND the topic is. |
1989 | - if ($msgOptions['approved']) |
|
1990 | - updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2082 | + if ($msgOptions['approved']) { |
|
2083 | + updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2084 | + } |
|
1991 | 2085 | |
1992 | 2086 | // Queue createPost background notification |
1993 | - if ($msgOptions['send_notifications'] && $msgOptions['approved']) |
|
1994 | - $smcFunc['db_insert']('', |
|
2087 | + if ($msgOptions['send_notifications'] && $msgOptions['approved']) { |
|
2088 | + $smcFunc['db_insert']('', |
|
1995 | 2089 | '{db_prefix}background_tasks', |
1996 | 2090 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1997 | 2091 | array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
@@ -2002,6 +2096,7 @@ discard block |
||
2002 | 2096 | )), 0), |
2003 | 2097 | array('id_task') |
2004 | 2098 | ); |
2099 | + } |
|
2005 | 2100 | |
2006 | 2101 | // Alright, done now... we can abort now, I guess... at least this much is done. |
2007 | 2102 | ignore_user_abort($previous_ignore_user_abort); |
@@ -2028,14 +2123,18 @@ discard block |
||
2028 | 2123 | |
2029 | 2124 | // This is longer than it has to be, but makes it so we only set/change what we have to. |
2030 | 2125 | $messages_columns = array(); |
2031 | - if (isset($posterOptions['name'])) |
|
2032 | - $messages_columns['poster_name'] = $posterOptions['name']; |
|
2033 | - if (isset($posterOptions['email'])) |
|
2034 | - $messages_columns['poster_email'] = $posterOptions['email']; |
|
2035 | - if (isset($msgOptions['icon'])) |
|
2036 | - $messages_columns['icon'] = $msgOptions['icon']; |
|
2037 | - if (isset($msgOptions['subject'])) |
|
2038 | - $messages_columns['subject'] = $msgOptions['subject']; |
|
2126 | + if (isset($posterOptions['name'])) { |
|
2127 | + $messages_columns['poster_name'] = $posterOptions['name']; |
|
2128 | + } |
|
2129 | + if (isset($posterOptions['email'])) { |
|
2130 | + $messages_columns['poster_email'] = $posterOptions['email']; |
|
2131 | + } |
|
2132 | + if (isset($msgOptions['icon'])) { |
|
2133 | + $messages_columns['icon'] = $msgOptions['icon']; |
|
2134 | + } |
|
2135 | + if (isset($msgOptions['subject'])) { |
|
2136 | + $messages_columns['subject'] = $msgOptions['subject']; |
|
2137 | + } |
|
2039 | 2138 | if (isset($msgOptions['body'])) |
2040 | 2139 | { |
2041 | 2140 | $messages_columns['body'] = $msgOptions['body']; |
@@ -2062,8 +2161,9 @@ discard block |
||
2062 | 2161 | $messages_columns['modified_reason'] = $msgOptions['modify_reason']; |
2063 | 2162 | $messages_columns['id_msg_modified'] = $modSettings['maxMsgID']; |
2064 | 2163 | } |
2065 | - if (isset($msgOptions['smileys_enabled'])) |
|
2066 | - $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2164 | + if (isset($msgOptions['smileys_enabled'])) { |
|
2165 | + $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2166 | + } |
|
2067 | 2167 | |
2068 | 2168 | // Which columns need to be ints? |
2069 | 2169 | $messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled'); |
@@ -2081,23 +2181,27 @@ discard block |
||
2081 | 2181 | { |
2082 | 2182 | preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match); |
2083 | 2183 | |
2084 | - if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) |
|
2085 | - foreach ($match[1] as $i => $oldID) |
|
2184 | + if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) { |
|
2185 | + foreach ($match[1] as $i => $oldID) |
|
2086 | 2186 | $oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]); |
2187 | + } |
|
2087 | 2188 | |
2088 | - if (empty($modSettings['search_custom_index_config'])) |
|
2089 | - unset($msgOptions['old_body']); |
|
2189 | + if (empty($modSettings['search_custom_index_config'])) { |
|
2190 | + unset($msgOptions['old_body']); |
|
2191 | + } |
|
2090 | 2192 | } |
2091 | 2193 | |
2092 | 2194 | $mentions = Mentions::getMentionedMembers($msgOptions['body']); |
2093 | 2195 | $messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions); |
2094 | 2196 | |
2095 | 2197 | // Remove the poster. |
2096 | - if (isset($mentions[$user_info['id']])) |
|
2097 | - unset($mentions[$user_info['id']]); |
|
2198 | + if (isset($mentions[$user_info['id']])) { |
|
2199 | + unset($mentions[$user_info['id']]); |
|
2200 | + } |
|
2098 | 2201 | |
2099 | - if (isset($oldmentions[$user_info['id']])) |
|
2100 | - unset($oldmentions[$user_info['id']]); |
|
2202 | + if (isset($oldmentions[$user_info['id']])) { |
|
2203 | + unset($oldmentions[$user_info['id']]); |
|
2204 | + } |
|
2101 | 2205 | |
2102 | 2206 | if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions)) |
2103 | 2207 | { |
@@ -2127,8 +2231,9 @@ discard block |
||
2127 | 2231 | } |
2128 | 2232 | |
2129 | 2233 | // Nothing to do? |
2130 | - if (empty($messages_columns)) |
|
2131 | - return true; |
|
2234 | + if (empty($messages_columns)) { |
|
2235 | + return true; |
|
2236 | + } |
|
2132 | 2237 | |
2133 | 2238 | // Change the post. |
2134 | 2239 | $smcFunc['db_query']('', ' |
@@ -2189,8 +2294,9 @@ discard block |
||
2189 | 2294 | // If there's a custom search index, it needs to be modified... |
2190 | 2295 | require_once($sourcedir . '/Search.php'); |
2191 | 2296 | $searchAPI = findSearchAPI(); |
2192 | - if (is_callable(array($searchAPI, 'postModified'))) |
|
2193 | - $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2297 | + if (is_callable(array($searchAPI, 'postModified'))) { |
|
2298 | + $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2299 | + } |
|
2194 | 2300 | |
2195 | 2301 | if (isset($msgOptions['subject'])) |
2196 | 2302 | { |
@@ -2204,14 +2310,16 @@ discard block |
||
2204 | 2310 | 'id_first_msg' => $msgOptions['id'], |
2205 | 2311 | ) |
2206 | 2312 | ); |
2207 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
2208 | - updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2313 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
2314 | + updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2315 | + } |
|
2209 | 2316 | $smcFunc['db_free_result']($request); |
2210 | 2317 | } |
2211 | 2318 | |
2212 | 2319 | // Finally, if we are setting the approved state we need to do much more work :( |
2213 | - if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) |
|
2214 | - approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2320 | + if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) { |
|
2321 | + approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2322 | + } |
|
2215 | 2323 | |
2216 | 2324 | return true; |
2217 | 2325 | } |
@@ -2228,11 +2336,13 @@ discard block |
||
2228 | 2336 | { |
2229 | 2337 | global $smcFunc; |
2230 | 2338 | |
2231 | - if (!is_array($msgs)) |
|
2232 | - $msgs = array($msgs); |
|
2339 | + if (!is_array($msgs)) { |
|
2340 | + $msgs = array($msgs); |
|
2341 | + } |
|
2233 | 2342 | |
2234 | - if (empty($msgs)) |
|
2235 | - return false; |
|
2343 | + if (empty($msgs)) { |
|
2344 | + return false; |
|
2345 | + } |
|
2236 | 2346 | |
2237 | 2347 | // May as well start at the beginning, working out *what* we need to change. |
2238 | 2348 | $request = $smcFunc['db_query']('', ' |
@@ -2264,20 +2374,22 @@ discard block |
||
2264 | 2374 | $topics[] = $row['id_topic']; |
2265 | 2375 | |
2266 | 2376 | // Ensure our change array exists already. |
2267 | - if (!isset($topic_changes[$row['id_topic']])) |
|
2268 | - $topic_changes[$row['id_topic']] = array( |
|
2377 | + if (!isset($topic_changes[$row['id_topic']])) { |
|
2378 | + $topic_changes[$row['id_topic']] = array( |
|
2269 | 2379 | 'id_last_msg' => $row['id_last_msg'], |
2270 | 2380 | 'approved' => $row['topic_approved'], |
2271 | 2381 | 'replies' => 0, |
2272 | 2382 | 'unapproved_posts' => 0, |
2273 | 2383 | ); |
2274 | - if (!isset($board_changes[$row['id_board']])) |
|
2275 | - $board_changes[$row['id_board']] = array( |
|
2384 | + } |
|
2385 | + if (!isset($board_changes[$row['id_board']])) { |
|
2386 | + $board_changes[$row['id_board']] = array( |
|
2276 | 2387 | 'posts' => 0, |
2277 | 2388 | 'topics' => 0, |
2278 | 2389 | 'unapproved_posts' => 0, |
2279 | 2390 | 'unapproved_topics' => 0, |
2280 | 2391 | ); |
2392 | + } |
|
2281 | 2393 | |
2282 | 2394 | // If it's the first message then the topic state changes! |
2283 | 2395 | if ($row['id_msg'] == $row['id_first_msg']) |
@@ -2298,14 +2410,13 @@ discard block |
||
2298 | 2410 | 'poster' => $row['id_member'], |
2299 | 2411 | 'new_topic' => true, |
2300 | 2412 | ); |
2301 | - } |
|
2302 | - else |
|
2413 | + } else |
|
2303 | 2414 | { |
2304 | 2415 | $topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1; |
2305 | 2416 | |
2306 | 2417 | // This will be a post... but don't notify unless it's not followed by approved ones. |
2307 | - if ($row['id_msg'] > $row['id_last_msg']) |
|
2308 | - $notification_posts[$row['id_topic']] = array( |
|
2418 | + if ($row['id_msg'] > $row['id_last_msg']) { |
|
2419 | + $notification_posts[$row['id_topic']] = array( |
|
2309 | 2420 | 'id' => $row['id_msg'], |
2310 | 2421 | 'body' => $row['body'], |
2311 | 2422 | 'subject' => $row['subject'], |
@@ -2316,28 +2427,33 @@ discard block |
||
2316 | 2427 | 'new_topic' => false, |
2317 | 2428 | 'msg' => $row['id_msg'], |
2318 | 2429 | ); |
2430 | + } |
|
2319 | 2431 | } |
2320 | 2432 | |
2321 | 2433 | // If this is being approved and id_msg is higher than the current id_last_msg then it changes. |
2322 | - if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) |
|
2323 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2434 | + if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) { |
|
2435 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2436 | + } |
|
2324 | 2437 | // If this is being unapproved, and it's equal to the id_last_msg we need to find a new one! |
2325 | - elseif (!$approve) |
|
2326 | - // Default to the first message and then we'll override in a bit ;) |
|
2438 | + elseif (!$approve) { |
|
2439 | + // Default to the first message and then we'll override in a bit ;) |
|
2327 | 2440 | $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg']; |
2441 | + } |
|
2328 | 2442 | |
2329 | 2443 | $topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1; |
2330 | 2444 | $board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1; |
2331 | 2445 | $board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1; |
2332 | 2446 | |
2333 | 2447 | // Post count for the user? |
2334 | - if ($row['id_member'] && empty($row['count_posts'])) |
|
2335 | - $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2448 | + if ($row['id_member'] && empty($row['count_posts'])) { |
|
2449 | + $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2450 | + } |
|
2336 | 2451 | } |
2337 | 2452 | $smcFunc['db_free_result']($request); |
2338 | 2453 | |
2339 | - if (empty($msgs)) |
|
2340 | - return; |
|
2454 | + if (empty($msgs)) { |
|
2455 | + return; |
|
2456 | + } |
|
2341 | 2457 | |
2342 | 2458 | // Now we have the differences make the changes, first the easy one. |
2343 | 2459 | $smcFunc['db_query']('', ' |
@@ -2364,14 +2480,15 @@ discard block |
||
2364 | 2480 | 'approved' => 1, |
2365 | 2481 | ) |
2366 | 2482 | ); |
2367 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2368 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2483 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2484 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2485 | + } |
|
2369 | 2486 | $smcFunc['db_free_result']($request); |
2370 | 2487 | } |
2371 | 2488 | |
2372 | 2489 | // ... next the topics... |
2373 | - foreach ($topic_changes as $id => $changes) |
|
2374 | - $smcFunc['db_query']('', ' |
|
2490 | + foreach ($topic_changes as $id => $changes) { |
|
2491 | + $smcFunc['db_query']('', ' |
|
2375 | 2492 | UPDATE {db_prefix}topics |
2376 | 2493 | SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2377 | 2494 | num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg} |
@@ -2384,10 +2501,11 @@ discard block |
||
2384 | 2501 | 'id_topic' => $id, |
2385 | 2502 | ) |
2386 | 2503 | ); |
2504 | + } |
|
2387 | 2505 | |
2388 | 2506 | // ... finally the boards... |
2389 | - foreach ($board_changes as $id => $changes) |
|
2390 | - $smcFunc['db_query']('', ' |
|
2507 | + foreach ($board_changes as $id => $changes) { |
|
2508 | + $smcFunc['db_query']('', ' |
|
2391 | 2509 | UPDATE {db_prefix}boards |
2392 | 2510 | SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2393 | 2511 | num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics} |
@@ -2400,13 +2518,14 @@ discard block |
||
2400 | 2518 | 'id_board' => $id, |
2401 | 2519 | ) |
2402 | 2520 | ); |
2521 | + } |
|
2403 | 2522 | |
2404 | 2523 | // Finally, least importantly, notifications! |
2405 | 2524 | if ($approve) |
2406 | 2525 | { |
2407 | 2526 | $task_rows = array(); |
2408 | - foreach (array_merge($notification_topics, $notification_posts) as $topic) |
|
2409 | - $task_rows[] = array( |
|
2527 | + foreach (array_merge($notification_topics, $notification_posts) as $topic) { |
|
2528 | + $task_rows[] = array( |
|
2410 | 2529 | '$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
2411 | 2530 | 'msgOptions' => array( |
2412 | 2531 | 'id' => $topic['msg'], |
@@ -2424,14 +2543,16 @@ discard block |
||
2424 | 2543 | 'type' => $topic['new_topic'] ? 'topic' : 'reply', |
2425 | 2544 | )), 0 |
2426 | 2545 | ); |
2546 | + } |
|
2427 | 2547 | |
2428 | - if ($notify) |
|
2429 | - $smcFunc['db_insert']('', |
|
2548 | + if ($notify) { |
|
2549 | + $smcFunc['db_insert']('', |
|
2430 | 2550 | '{db_prefix}background_tasks', |
2431 | 2551 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
2432 | 2552 | $task_rows, |
2433 | 2553 | array('id_task') |
2434 | 2554 | ); |
2555 | + } |
|
2435 | 2556 | |
2436 | 2557 | $smcFunc['db_query']('', ' |
2437 | 2558 | DELETE FROM {db_prefix}approval_queue |
@@ -2447,8 +2568,9 @@ discard block |
||
2447 | 2568 | else |
2448 | 2569 | { |
2449 | 2570 | $msgInserts = array(); |
2450 | - foreach ($msgs as $msg) |
|
2451 | - $msgInserts[] = array($msg); |
|
2571 | + foreach ($msgs as $msg) { |
|
2572 | + $msgInserts[] = array($msg); |
|
2573 | + } |
|
2452 | 2574 | |
2453 | 2575 | $smcFunc['db_insert']('ignore', |
2454 | 2576 | '{db_prefix}approval_queue', |
@@ -2462,9 +2584,10 @@ discard block |
||
2462 | 2584 | updateLastMessages(array_keys($board_changes)); |
2463 | 2585 | |
2464 | 2586 | // Post count for the members? |
2465 | - if (!empty($member_post_changes)) |
|
2466 | - foreach ($member_post_changes as $id_member => $count_change) |
|
2587 | + if (!empty($member_post_changes)) { |
|
2588 | + foreach ($member_post_changes as $id_member => $count_change) |
|
2467 | 2589 | updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change)); |
2590 | + } |
|
2468 | 2591 | |
2469 | 2592 | return true; |
2470 | 2593 | } |
@@ -2481,11 +2604,13 @@ discard block |
||
2481 | 2604 | { |
2482 | 2605 | global $smcFunc; |
2483 | 2606 | |
2484 | - if (!is_array($topics)) |
|
2485 | - $topics = array($topics); |
|
2607 | + if (!is_array($topics)) { |
|
2608 | + $topics = array($topics); |
|
2609 | + } |
|
2486 | 2610 | |
2487 | - if (empty($topics)) |
|
2488 | - return false; |
|
2611 | + if (empty($topics)) { |
|
2612 | + return false; |
|
2613 | + } |
|
2489 | 2614 | |
2490 | 2615 | $approve_type = $approve ? 0 : 1; |
2491 | 2616 | |
@@ -2501,8 +2626,9 @@ discard block |
||
2501 | 2626 | ) |
2502 | 2627 | ); |
2503 | 2628 | $msgs = array(); |
2504 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2505 | - $msgs[] = $row['id_msg']; |
|
2629 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2630 | + $msgs[] = $row['id_msg']; |
|
2631 | + } |
|
2506 | 2632 | $smcFunc['db_free_result']($request); |
2507 | 2633 | |
2508 | 2634 | return approvePosts($msgs, $approve); |
@@ -2525,11 +2651,13 @@ discard block |
||
2525 | 2651 | global $board_info, $board, $smcFunc; |
2526 | 2652 | |
2527 | 2653 | // Please - let's be sane. |
2528 | - if (empty($setboards)) |
|
2529 | - return false; |
|
2654 | + if (empty($setboards)) { |
|
2655 | + return false; |
|
2656 | + } |
|
2530 | 2657 | |
2531 | - if (!is_array($setboards)) |
|
2532 | - $setboards = array($setboards); |
|
2658 | + if (!is_array($setboards)) { |
|
2659 | + $setboards = array($setboards); |
|
2660 | + } |
|
2533 | 2661 | |
2534 | 2662 | // If we don't know the id_msg we need to find it. |
2535 | 2663 | if (!$id_msg) |
@@ -2547,15 +2675,16 @@ discard block |
||
2547 | 2675 | ) |
2548 | 2676 | ); |
2549 | 2677 | $lastMsg = array(); |
2550 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2551 | - $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2678 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2679 | + $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2680 | + } |
|
2552 | 2681 | $smcFunc['db_free_result']($request); |
2553 | - } |
|
2554 | - else |
|
2682 | + } else |
|
2555 | 2683 | { |
2556 | 2684 | // Just to note - there should only be one board passed if we are doing this. |
2557 | - foreach ($setboards as $id_board) |
|
2558 | - $lastMsg[$id_board] = $id_msg; |
|
2685 | + foreach ($setboards as $id_board) { |
|
2686 | + $lastMsg[$id_board] = $id_msg; |
|
2687 | + } |
|
2559 | 2688 | } |
2560 | 2689 | |
2561 | 2690 | $parent_boards = array(); |
@@ -2570,10 +2699,11 @@ discard block |
||
2570 | 2699 | $lastModified[$id_board] = 0; |
2571 | 2700 | } |
2572 | 2701 | |
2573 | - if (!empty($board) && $id_board == $board) |
|
2574 | - $parents = $board_info['parent_boards']; |
|
2575 | - else |
|
2576 | - $parents = getBoardParents($id_board); |
|
2702 | + if (!empty($board) && $id_board == $board) { |
|
2703 | + $parents = $board_info['parent_boards']; |
|
2704 | + } else { |
|
2705 | + $parents = getBoardParents($id_board); |
|
2706 | + } |
|
2577 | 2707 | |
2578 | 2708 | // Ignore any parents on the top child level. |
2579 | 2709 | // @todo Why? |
@@ -2582,10 +2712,11 @@ discard block |
||
2582 | 2712 | if ($parent['level'] != 0) |
2583 | 2713 | { |
2584 | 2714 | // If we're already doing this one as a board, is this a higher last modified? |
2585 | - if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) |
|
2586 | - $lastModified[$id] = $lastModified[$id_board]; |
|
2587 | - elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) |
|
2588 | - $parent_boards[$id] = $lastModified[$id_board]; |
|
2715 | + if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) { |
|
2716 | + $lastModified[$id] = $lastModified[$id_board]; |
|
2717 | + } elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) { |
|
2718 | + $parent_boards[$id] = $lastModified[$id_board]; |
|
2719 | + } |
|
2589 | 2720 | } |
2590 | 2721 | } |
2591 | 2722 | } |
@@ -2598,23 +2729,24 @@ discard block |
||
2598 | 2729 | // Finally, to save on queries make the changes... |
2599 | 2730 | foreach ($parent_boards as $id => $msg) |
2600 | 2731 | { |
2601 | - if (!isset($parent_updates[$msg])) |
|
2602 | - $parent_updates[$msg] = array($id); |
|
2603 | - else |
|
2604 | - $parent_updates[$msg][] = $id; |
|
2732 | + if (!isset($parent_updates[$msg])) { |
|
2733 | + $parent_updates[$msg] = array($id); |
|
2734 | + } else { |
|
2735 | + $parent_updates[$msg][] = $id; |
|
2736 | + } |
|
2605 | 2737 | } |
2606 | 2738 | |
2607 | 2739 | foreach ($lastMsg as $id => $msg) |
2608 | 2740 | { |
2609 | - if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) |
|
2610 | - $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2741 | + if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) { |
|
2742 | + $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2611 | 2743 | 'id' => $msg, |
2612 | 2744 | 'updated' => $lastModified[$id], |
2613 | 2745 | 'boards' => array($id) |
2614 | 2746 | ); |
2615 | - |
|
2616 | - else |
|
2617 | - $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2747 | + } else { |
|
2748 | + $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2749 | + } |
|
2618 | 2750 | } |
2619 | 2751 | |
2620 | 2752 | // Now commit the changes! |
@@ -2706,11 +2838,13 @@ discard block |
||
2706 | 2838 | global $txt, $mbname, $scripturl, $settings; |
2707 | 2839 | |
2708 | 2840 | // First things first, load up the email templates language file, if we need to. |
2709 | - if ($loadLang) |
|
2710 | - loadLanguage('EmailTemplates', $lang); |
|
2841 | + if ($loadLang) { |
|
2842 | + loadLanguage('EmailTemplates', $lang); |
|
2843 | + } |
|
2711 | 2844 | |
2712 | - if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) |
|
2713 | - fatal_lang_error('email_no_template', 'template', array($template)); |
|
2845 | + if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) { |
|
2846 | + fatal_lang_error('email_no_template', 'template', array($template)); |
|
2847 | + } |
|
2714 | 2848 | |
2715 | 2849 | $ret = array( |
2716 | 2850 | 'subject' => $txt[$template . '_subject'], |
@@ -2760,17 +2894,18 @@ discard block |
||
2760 | 2894 | function user_info_callback($matches) |
2761 | 2895 | { |
2762 | 2896 | global $user_info; |
2763 | - if (empty($matches[1])) |
|
2764 | - return ''; |
|
2897 | + if (empty($matches[1])) { |
|
2898 | + return ''; |
|
2899 | + } |
|
2765 | 2900 | |
2766 | 2901 | $use_ref = true; |
2767 | 2902 | $ref = &$user_info; |
2768 | 2903 | |
2769 | 2904 | foreach (explode('.', $matches[1]) as $index) |
2770 | 2905 | { |
2771 | - if ($use_ref && isset($ref[$index])) |
|
2772 | - $ref = &$ref[$index]; |
|
2773 | - else |
|
2906 | + if ($use_ref && isset($ref[$index])) { |
|
2907 | + $ref = &$ref[$index]; |
|
2908 | + } else |
|
2774 | 2909 | { |
2775 | 2910 | $use_ref = false; |
2776 | 2911 | break; |
@@ -2807,8 +2942,7 @@ discard block |
||
2807 | 2942 | if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale)) |
2808 | 2943 | { |
2809 | 2944 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale); |
2810 | - } |
|
2811 | - elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2945 | + } elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2812 | 2946 | { |
2813 | 2947 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']); |
2814 | 2948 | } |
@@ -2818,8 +2952,7 @@ discard block |
||
2818 | 2952 | { |
2819 | 2953 | $context['provider'] = 'enchant'; |
2820 | 2954 | return $enchant_link; |
2821 | - } |
|
2822 | - else |
|
2955 | + } else |
|
2823 | 2956 | { |
2824 | 2957 | // Free up any resources used... |
2825 | 2958 | @enchant_broker_free($context['enchant_broker']); |
@@ -2840,8 +2973,9 @@ discard block |
||
2840 | 2973 | $pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER); |
2841 | 2974 | |
2842 | 2975 | // Most people don't have anything but English installed... So we use English as a last resort. |
2843 | - if (!$pspell_link) |
|
2844 | - $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
2976 | + if (!$pspell_link) { |
|
2977 | + $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
2978 | + } |
|
2845 | 2979 | |
2846 | 2980 | error_reporting($old); |
2847 | 2981 | ob_end_clean(); |
@@ -2881,8 +3015,7 @@ discard block |
||
2881 | 3015 | $word = iconv($txt['lang_character_set'], 'UTF-8', $word); |
2882 | 3016 | } |
2883 | 3017 | return enchant_dict_check($dict, $word); |
2884 | - } |
|
2885 | - elseif ($context['provider'] == 'pspell') |
|
3018 | + } elseif ($context['provider'] == 'pspell') |
|
2886 | 3019 | { |
2887 | 3020 | return pspell_check($dict, $word); |
2888 | 3021 | } |
@@ -2918,13 +3051,11 @@ discard block |
||
2918 | 3051 | } |
2919 | 3052 | |
2920 | 3053 | return $suggestions; |
2921 | - } |
|
2922 | - else |
|
3054 | + } else |
|
2923 | 3055 | { |
2924 | 3056 | return enchant_dict_suggest($dict, $word); |
2925 | 3057 | } |
2926 | - } |
|
2927 | - elseif ($context['provider'] == 'pspell') |
|
3058 | + } elseif ($context['provider'] == 'pspell') |
|
2928 | 3059 | { |
2929 | 3060 | return pspell_suggest($dict, $word); |
2930 | 3061 | } |
@@ -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 | * !!!Compatibility!!! |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | { |
31 | 32 | global $modSettings; |
32 | 33 | |
33 | - if (!$compat_mode) |
|
34 | - return $text; |
|
34 | + if (!$compat_mode) { |
|
35 | + return $text; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Turn line breaks back into br's. |
37 | 39 | $text = strtr($text, array("\r" => '', "\n" => '<br>')); |
@@ -48,8 +50,9 @@ discard block |
||
48 | 50 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
49 | 51 | { |
50 | 52 | // Value of 2 means we're inside the tag. |
51 | - if ($i % 4 == 2) |
|
52 | - $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
53 | + if ($i % 4 == 2) { |
|
54 | + $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
55 | + } |
|
53 | 56 | } |
54 | 57 | // Put our humpty dumpty message back together again. |
55 | 58 | $text = implode('', $parts); |
@@ -107,8 +110,9 @@ discard block |
||
107 | 110 | $text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text); |
108 | 111 | |
109 | 112 | // Safari/webkit wraps lines in Wysiwyg in <div>'s. |
110 | - if (isBrowser('webkit')) |
|
111 | - $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
113 | + if (isBrowser('webkit')) { |
|
114 | + $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
115 | + } |
|
112 | 116 | |
113 | 117 | // If there's a trailing break get rid of it - Firefox tends to add one. |
114 | 118 | $text = preg_replace('~<br\s?/?' . '>$~i', '', $text); |
@@ -123,8 +127,9 @@ discard block |
||
123 | 127 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
124 | 128 | { |
125 | 129 | // Value of 2 means we're inside the tag. |
126 | - if ($i % 4 == 2) |
|
127 | - $parts[$i] = strip_tags($parts[$i]); |
|
130 | + if ($i % 4 == 2) { |
|
131 | + $parts[$i] = strip_tags($parts[$i]); |
|
132 | + } |
|
128 | 133 | } |
129 | 134 | |
130 | 135 | $text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>')); |
@@ -150,18 +155,19 @@ discard block |
||
150 | 155 | { |
151 | 156 | $found = array_search($file, $smileysto); |
152 | 157 | // Note the weirdness here is to stop double spaces between smileys. |
153 | - if ($found) |
|
154 | - $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
155 | - else |
|
156 | - $matches[1][$k] = ''; |
|
158 | + if ($found) { |
|
159 | + $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
160 | + } else { |
|
161 | + $matches[1][$k] = ''; |
|
162 | + } |
|
157 | 163 | } |
158 | - } |
|
159 | - else |
|
164 | + } else |
|
160 | 165 | { |
161 | 166 | // Load all the smileys. |
162 | 167 | $names = array(); |
163 | - foreach ($matches[1] as $file) |
|
164 | - $names[] = $file; |
|
168 | + foreach ($matches[1] as $file) { |
|
169 | + $names[] = $file; |
|
170 | + } |
|
165 | 171 | $names = array_unique($names); |
166 | 172 | |
167 | 173 | if (!empty($names)) |
@@ -175,13 +181,15 @@ discard block |
||
175 | 181 | ) |
176 | 182 | ); |
177 | 183 | $mappings = array(); |
178 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
179 | - $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
185 | + $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
186 | + } |
|
180 | 187 | $smcFunc['db_free_result']($request); |
181 | 188 | |
182 | - foreach ($matches[1] as $k => $file) |
|
183 | - if (isset($mappings[$file])) |
|
189 | + foreach ($matches[1] as $k => $file) { |
|
190 | + if (isset($mappings[$file])) |
|
184 | 191 | $matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#'; |
192 | + } |
|
185 | 193 | } |
186 | 194 | } |
187 | 195 | |
@@ -193,8 +201,9 @@ discard block |
||
193 | 201 | } |
194 | 202 | |
195 | 203 | // Only try to buy more time if the client didn't quit. |
196 | - if (connection_aborted() && $context['server']['is_apache']) |
|
197 | - @apache_reset_timeout(); |
|
204 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
205 | + @apache_reset_timeout(); |
|
206 | + } |
|
198 | 207 | |
199 | 208 | $parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
200 | 209 | $replacement = ''; |
@@ -205,9 +214,9 @@ discard block |
||
205 | 214 | if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) |
206 | 215 | { |
207 | 216 | // If it's being closed instantly, we can't deal with it...yet. |
208 | - if ($matches[5] === '/') |
|
209 | - continue; |
|
210 | - else |
|
217 | + if ($matches[5] === '/') { |
|
218 | + continue; |
|
219 | + } else |
|
211 | 220 | { |
212 | 221 | // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.) |
213 | 222 | $styles = explode(';', strtr($matches[3], array('"' => ''))); |
@@ -223,8 +232,9 @@ discard block |
||
223 | 232 | $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':')); |
224 | 233 | |
225 | 234 | // Something like 'font-weight: bold' is expected here. |
226 | - if (strpos($clean_type_value_pair, ':') === false) |
|
227 | - continue; |
|
235 | + if (strpos($clean_type_value_pair, ':') === false) { |
|
236 | + continue; |
|
237 | + } |
|
228 | 238 | |
229 | 239 | // Capture the elements of a single style item (e.g. 'font-weight' and 'bold'). |
230 | 240 | list ($style_type, $style_value) = explode(':', $type_value_pair); |
@@ -246,8 +256,7 @@ discard block |
||
246 | 256 | { |
247 | 257 | $curCloseTags .= '[/u]'; |
248 | 258 | $replacement .= '[u]'; |
249 | - } |
|
250 | - elseif ($style_value == 'line-through') |
|
259 | + } elseif ($style_value == 'line-through') |
|
251 | 260 | { |
252 | 261 | $curCloseTags .= '[/s]'; |
253 | 262 | $replacement .= '[s]'; |
@@ -259,13 +268,11 @@ discard block |
||
259 | 268 | { |
260 | 269 | $curCloseTags .= '[/left]'; |
261 | 270 | $replacement .= '[left]'; |
262 | - } |
|
263 | - elseif ($style_value == 'center') |
|
271 | + } elseif ($style_value == 'center') |
|
264 | 272 | { |
265 | 273 | $curCloseTags .= '[/center]'; |
266 | 274 | $replacement .= '[center]'; |
267 | - } |
|
268 | - elseif ($style_value == 'right') |
|
275 | + } elseif ($style_value == 'right') |
|
269 | 276 | { |
270 | 277 | $curCloseTags .= '[/right]'; |
271 | 278 | $replacement .= '[right]'; |
@@ -287,8 +294,9 @@ discard block |
||
287 | 294 | |
288 | 295 | case 'font-size': |
289 | 296 | // Sometimes people put decimals where decimals should not be. |
290 | - if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) |
|
291 | - $style_value = $dec_matches[1] . $dec_matches[2]; |
|
297 | + if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) { |
|
298 | + $style_value = $dec_matches[1] . $dec_matches[2]; |
|
299 | + } |
|
292 | 300 | |
293 | 301 | $curCloseTags .= '[/size]'; |
294 | 302 | $replacement .= '[size=' . $style_value . ']'; |
@@ -296,8 +304,9 @@ discard block |
||
296 | 304 | |
297 | 305 | case 'font-family': |
298 | 306 | // Only get the first freaking font if there's a list! |
299 | - if (strpos($style_value, ',') !== false) |
|
300 | - $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
307 | + if (strpos($style_value, ',') !== false) { |
|
308 | + $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
309 | + } |
|
301 | 310 | |
302 | 311 | $curCloseTags .= '[/font]'; |
303 | 312 | $replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']'; |
@@ -306,13 +315,15 @@ discard block |
||
306 | 315 | // This is a hack for images with dimensions embedded. |
307 | 316 | case 'width': |
308 | 317 | case 'height': |
309 | - if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) |
|
310 | - $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
318 | + if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) { |
|
319 | + $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
320 | + } |
|
311 | 321 | break; |
312 | 322 | |
313 | 323 | case 'list-style-type': |
314 | - if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) |
|
315 | - $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
324 | + if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) { |
|
325 | + $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
326 | + } |
|
316 | 327 | break; |
317 | 328 | } |
318 | 329 | } |
@@ -325,18 +336,17 @@ discard block |
||
325 | 336 | } |
326 | 337 | |
327 | 338 | // If there's something that still needs closing, push it to the stack. |
328 | - if (!empty($curCloseTags)) |
|
329 | - array_push($stack, array( |
|
339 | + if (!empty($curCloseTags)) { |
|
340 | + array_push($stack, array( |
|
330 | 341 | 'element' => strtolower($curElement), |
331 | 342 | 'closeTags' => $curCloseTags |
332 | 343 | ) |
333 | 344 | ); |
334 | - elseif (!empty($extra_attr)) |
|
335 | - $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
345 | + } elseif (!empty($extra_attr)) { |
|
346 | + $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
347 | + } |
|
336 | 348 | } |
337 | - } |
|
338 | - |
|
339 | - elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
349 | + } elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
340 | 350 | { |
341 | 351 | // Is this the element that we've been waiting for to be closed? |
342 | 352 | if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element']) |
@@ -346,28 +356,32 @@ discard block |
||
346 | 356 | } |
347 | 357 | |
348 | 358 | // Must've been something else. |
349 | - else |
|
350 | - $replacement .= $part; |
|
359 | + else { |
|
360 | + $replacement .= $part; |
|
361 | + } |
|
351 | 362 | } |
352 | 363 | // In all other cases, just add the part to the replacement. |
353 | - else |
|
354 | - $replacement .= $part; |
|
364 | + else { |
|
365 | + $replacement .= $part; |
|
366 | + } |
|
355 | 367 | } |
356 | 368 | |
357 | 369 | // Now put back the replacement in the text. |
358 | 370 | $text = $replacement; |
359 | 371 | |
360 | 372 | // We are not finished yet, request more time. |
361 | - if (connection_aborted() && $context['server']['is_apache']) |
|
362 | - @apache_reset_timeout(); |
|
373 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
374 | + @apache_reset_timeout(); |
|
375 | + } |
|
363 | 376 | |
364 | 377 | // Let's pull out any legacy alignments. |
365 | 378 | while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1) |
366 | 379 | { |
367 | 380 | // Find the position in the text of this tag over again. |
368 | 381 | $start_pos = strpos($text, $matches[0]); |
369 | - if ($start_pos === false) |
|
370 | - break; |
|
382 | + if ($start_pos === false) { |
|
383 | + break; |
|
384 | + } |
|
371 | 385 | |
372 | 386 | // End tag? |
373 | 387 | if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false) |
@@ -381,8 +395,7 @@ discard block |
||
381 | 395 | |
382 | 396 | // Put the tags back into the body. |
383 | 397 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
384 | - } |
|
385 | - else |
|
398 | + } else |
|
386 | 399 | { |
387 | 400 | // Just get rid of this evil tag. |
388 | 401 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -395,8 +408,9 @@ discard block |
||
395 | 408 | // Find the position of this again. |
396 | 409 | $start_pos = strpos($text, $matches[0]); |
397 | 410 | $end_pos = false; |
398 | - if ($start_pos === false) |
|
399 | - break; |
|
411 | + if ($start_pos === false) { |
|
412 | + break; |
|
413 | + } |
|
400 | 414 | |
401 | 415 | // This must have an end tag - and we must find the right one. |
402 | 416 | $lower_text = strtolower($text); |
@@ -429,8 +443,9 @@ discard block |
||
429 | 443 | break; |
430 | 444 | } |
431 | 445 | } |
432 | - if ($end_pos === false) |
|
433 | - break; |
|
446 | + if ($end_pos === false) { |
|
447 | + break; |
|
448 | + } |
|
434 | 449 | |
435 | 450 | // Now work out what the attributes are. |
436 | 451 | $attribs = fetchTagAttributes($matches[1]); |
@@ -444,11 +459,11 @@ discard block |
||
444 | 459 | $v = (int) trim($v); |
445 | 460 | $v = empty($v) ? 1 : $v; |
446 | 461 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
462 | + } elseif ($s == 'face') { |
|
463 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
464 | + } elseif ($s == 'color') { |
|
465 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
447 | 466 | } |
448 | - elseif ($s == 'face') |
|
449 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
450 | - elseif ($s == 'color') |
|
451 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
452 | 467 | } |
453 | 468 | |
454 | 469 | // As before add in our tags. |
@@ -456,8 +471,9 @@ discard block |
||
456 | 471 | foreach ($tags as $tag) |
457 | 472 | { |
458 | 473 | $before .= $tag[0]; |
459 | - if (isset($tag[1])) |
|
460 | - $after = $tag[1] . $after; |
|
474 | + if (isset($tag[1])) { |
|
475 | + $after = $tag[1] . $after; |
|
476 | + } |
|
461 | 477 | } |
462 | 478 | |
463 | 479 | // Remove the tag so it's never checked again. |
@@ -468,8 +484,9 @@ discard block |
||
468 | 484 | } |
469 | 485 | |
470 | 486 | // Almost there, just a little more time. |
471 | - if (connection_aborted() && $context['server']['is_apache']) |
|
472 | - @apache_reset_timeout(); |
|
487 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
488 | + @apache_reset_timeout(); |
|
489 | + } |
|
473 | 490 | |
474 | 491 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
475 | 492 | { |
@@ -525,12 +542,13 @@ discard block |
||
525 | 542 | { |
526 | 543 | $inList = true; |
527 | 544 | |
528 | - if ($tag === 'ol') |
|
529 | - $listType = 'decimal'; |
|
530 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
531 | - $listType = $listTypeMapping[$match[1]]; |
|
532 | - else |
|
533 | - $listType = null; |
|
545 | + if ($tag === 'ol') { |
|
546 | + $listType = 'decimal'; |
|
547 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
548 | + $listType = $listTypeMapping[$match[1]]; |
|
549 | + } else { |
|
550 | + $listType = null; |
|
551 | + } |
|
534 | 552 | |
535 | 553 | $listDepth++; |
536 | 554 | |
@@ -594,9 +612,7 @@ discard block |
||
594 | 612 | $parts[$i + 1] = ''; |
595 | 613 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
596 | 614 | $parts[$i + 3] = ''; |
597 | - } |
|
598 | - |
|
599 | - else |
|
615 | + } else |
|
600 | 616 | { |
601 | 617 | // We're in a list item. |
602 | 618 | if ($listDepth > 0) |
@@ -633,9 +649,7 @@ discard block |
||
633 | 649 | $parts[$i + 1] = ''; |
634 | 650 | $parts[$i + 2] = ''; |
635 | 651 | $parts[$i + 3] = ''; |
636 | - } |
|
637 | - |
|
638 | - else |
|
652 | + } else |
|
639 | 653 | { |
640 | 654 | // Remove the trailing breaks from the list item. |
641 | 655 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -673,8 +687,9 @@ discard block |
||
673 | 687 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
674 | 688 | } |
675 | 689 | |
676 | - for ($i = $listDepth; $i > 0; $i--) |
|
677 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
690 | + for ($i = $listDepth; $i > 0; $i--) { |
|
691 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
692 | + } |
|
678 | 693 | |
679 | 694 | } |
680 | 695 | |
@@ -683,8 +698,9 @@ discard block |
||
683 | 698 | { |
684 | 699 | // Find the position of the image. |
685 | 700 | $start_pos = strpos($text, $matches[0]); |
686 | - if ($start_pos === false) |
|
687 | - break; |
|
701 | + if ($start_pos === false) { |
|
702 | + break; |
|
703 | + } |
|
688 | 704 | $end_pos = $start_pos + strlen($matches[0]); |
689 | 705 | |
690 | 706 | $params = ''; |
@@ -693,12 +709,13 @@ discard block |
||
693 | 709 | $attrs = fetchTagAttributes($matches[1]); |
694 | 710 | foreach ($attrs as $attrib => $value) |
695 | 711 | { |
696 | - if (in_array($attrib, array('width', 'height'))) |
|
697 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
698 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
699 | - $params .= ' alt=' . trim($value); |
|
700 | - elseif ($attrib == 'src') |
|
701 | - $src = trim($value); |
|
712 | + if (in_array($attrib, array('width', 'height'))) { |
|
713 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
714 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
715 | + $params .= ' alt=' . trim($value); |
|
716 | + } elseif ($attrib == 'src') { |
|
717 | + $src = trim($value); |
|
718 | + } |
|
702 | 719 | } |
703 | 720 | |
704 | 721 | $tag = ''; |
@@ -709,10 +726,11 @@ discard block |
||
709 | 726 | { |
710 | 727 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
711 | 728 | |
712 | - if (substr($src, 0, 1) === '/') |
|
713 | - $src = $baseURL . $src; |
|
714 | - else |
|
715 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
729 | + if (substr($src, 0, 1) === '/') { |
|
730 | + $src = $baseURL . $src; |
|
731 | + } else { |
|
732 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
733 | + } |
|
716 | 734 | } |
717 | 735 | |
718 | 736 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -890,20 +908,23 @@ discard block |
||
890 | 908 | }, |
891 | 909 | ); |
892 | 910 | |
893 | - foreach ($tags as $tag => $replace) |
|
894 | - $text = preg_replace_callback($tag, $replace, $text); |
|
911 | + foreach ($tags as $tag => $replace) { |
|
912 | + $text = preg_replace_callback($tag, $replace, $text); |
|
913 | + } |
|
895 | 914 | |
896 | 915 | // Please give us just a little more time. |
897 | - if (connection_aborted() && $context['server']['is_apache']) |
|
898 | - @apache_reset_timeout(); |
|
916 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
917 | + @apache_reset_timeout(); |
|
918 | + } |
|
899 | 919 | |
900 | 920 | // What about URL's - the pain in the ass of the tag world. |
901 | 921 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
902 | 922 | { |
903 | 923 | // Find the position of the URL. |
904 | 924 | $start_pos = strpos($text, $matches[0]); |
905 | - if ($start_pos === false) |
|
906 | - break; |
|
925 | + if ($start_pos === false) { |
|
926 | + break; |
|
927 | + } |
|
907 | 928 | $end_pos = $start_pos + strlen($matches[0]); |
908 | 929 | |
909 | 930 | $tag_type = 'url'; |
@@ -917,8 +938,9 @@ discard block |
||
917 | 938 | $href = trim($value); |
918 | 939 | |
919 | 940 | // Are we dealing with an FTP link? |
920 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
921 | - $tag_type = 'ftp'; |
|
941 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
942 | + $tag_type = 'ftp'; |
|
943 | + } |
|
922 | 944 | |
923 | 945 | // Or is this a link to an email address? |
924 | 946 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -932,28 +954,31 @@ discard block |
||
932 | 954 | { |
933 | 955 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
934 | 956 | |
935 | - if (substr($href, 0, 1) === '/') |
|
936 | - $href = $baseURL . $href; |
|
937 | - else |
|
938 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
957 | + if (substr($href, 0, 1) === '/') { |
|
958 | + $href = $baseURL . $href; |
|
959 | + } else { |
|
960 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
961 | + } |
|
939 | 962 | } |
940 | 963 | } |
941 | 964 | |
942 | 965 | // External URL? |
943 | 966 | if ($attrib == 'target' && $tag_type == 'url') |
944 | 967 | { |
945 | - if (trim($value) == '_blank') |
|
946 | - $tag_type == 'iurl'; |
|
968 | + if (trim($value) == '_blank') { |
|
969 | + $tag_type == 'iurl'; |
|
970 | + } |
|
947 | 971 | } |
948 | 972 | } |
949 | 973 | |
950 | 974 | $tag = ''; |
951 | 975 | if ($href != '') |
952 | 976 | { |
953 | - if ($matches[2] == $href) |
|
954 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
955 | - else |
|
956 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
977 | + if ($matches[2] == $href) { |
|
978 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
979 | + } else { |
|
980 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
981 | + } |
|
957 | 982 | } |
958 | 983 | |
959 | 984 | // Replace the tag |
@@ -992,17 +1017,18 @@ discard block |
||
992 | 1017 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
993 | 1018 | if ($text[$i] == '=') |
994 | 1019 | { |
995 | - if ($tag_state == 0) |
|
996 | - $tag_state = 1; |
|
997 | - elseif ($tag_state == 2) |
|
998 | - $value .= '='; |
|
1020 | + if ($tag_state == 0) { |
|
1021 | + $tag_state = 1; |
|
1022 | + } elseif ($tag_state == 2) { |
|
1023 | + $value .= '='; |
|
1024 | + } |
|
999 | 1025 | } |
1000 | 1026 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
1001 | 1027 | elseif ($text[$i] == ' ') |
1002 | 1028 | { |
1003 | - if ($tag_state == 2) |
|
1004 | - $value .= ' '; |
|
1005 | - elseif ($tag_state == 1) |
|
1029 | + if ($tag_state == 2) { |
|
1030 | + $value .= ' '; |
|
1031 | + } elseif ($tag_state == 1) |
|
1006 | 1032 | { |
1007 | 1033 | $attribs[$key] = $value; |
1008 | 1034 | $key = $value = ''; |
@@ -1013,24 +1039,27 @@ discard block |
||
1013 | 1039 | elseif ($text[$i] == '"') |
1014 | 1040 | { |
1015 | 1041 | // Must be either going into or out of a string. |
1016 | - if ($tag_state == 1) |
|
1017 | - $tag_state = 2; |
|
1018 | - else |
|
1019 | - $tag_state = 1; |
|
1042 | + if ($tag_state == 1) { |
|
1043 | + $tag_state = 2; |
|
1044 | + } else { |
|
1045 | + $tag_state = 1; |
|
1046 | + } |
|
1020 | 1047 | } |
1021 | 1048 | // Otherwise it's fine. |
1022 | 1049 | else |
1023 | 1050 | { |
1024 | - if ($tag_state == 0) |
|
1025 | - $key .= $text[$i]; |
|
1026 | - else |
|
1027 | - $value .= $text[$i]; |
|
1051 | + if ($tag_state == 0) { |
|
1052 | + $key .= $text[$i]; |
|
1053 | + } else { |
|
1054 | + $value .= $text[$i]; |
|
1055 | + } |
|
1028 | 1056 | } |
1029 | 1057 | } |
1030 | 1058 | |
1031 | 1059 | // Anything left? |
1032 | - if ($key != '' && $value != '') |
|
1033 | - $attribs[$key] = $value; |
|
1060 | + if ($key != '' && $value != '') { |
|
1061 | + $attribs[$key] = $value; |
|
1062 | + } |
|
1034 | 1063 | |
1035 | 1064 | return $attribs; |
1036 | 1065 | } |
@@ -1046,15 +1075,17 @@ discard block |
||
1046 | 1075 | global $modSettings; |
1047 | 1076 | |
1048 | 1077 | // Don't care about the texts that are too short. |
1049 | - if (strlen($text) < 3) |
|
1050 | - return $text; |
|
1078 | + if (strlen($text) < 3) { |
|
1079 | + return $text; |
|
1080 | + } |
|
1051 | 1081 | |
1052 | 1082 | // A list of tags that's disabled by the admin. |
1053 | 1083 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
1054 | 1084 | |
1055 | 1085 | // Add flash if it's disabled as embedded tag. |
1056 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1057 | - $disabled['flash'] = true; |
|
1086 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1087 | + $disabled['flash'] = true; |
|
1088 | + } |
|
1058 | 1089 | |
1059 | 1090 | // Get a list of all the tags that are not disabled. |
1060 | 1091 | $all_tags = parse_bbc(false); |
@@ -1062,10 +1093,12 @@ discard block |
||
1062 | 1093 | $self_closing_tags = array(); |
1063 | 1094 | foreach ($all_tags as $tag) |
1064 | 1095 | { |
1065 | - if (!isset($disabled[$tag['tag']])) |
|
1066 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1067 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
1068 | - $self_closing_tags[] = $tag['tag']; |
|
1096 | + if (!isset($disabled[$tag['tag']])) { |
|
1097 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1098 | + } |
|
1099 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
1100 | + $self_closing_tags[] = $tag['tag']; |
|
1101 | + } |
|
1069 | 1102 | } |
1070 | 1103 | |
1071 | 1104 | // Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid! |
@@ -1092,16 +1125,19 @@ discard block |
||
1092 | 1125 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
1093 | 1126 | |
1094 | 1127 | // We're closing the exact same tag that we opened. |
1095 | - if ($isClosingTag && $insideTag === $tagName) |
|
1096 | - $insideTag = null; |
|
1128 | + if ($isClosingTag && $insideTag === $tagName) { |
|
1129 | + $insideTag = null; |
|
1130 | + } |
|
1097 | 1131 | |
1098 | 1132 | // We're opening a tag and we're not yet inside one either |
1099 | - elseif (!$isClosingTag && $insideTag === null) |
|
1100 | - $insideTag = $tagName; |
|
1133 | + elseif (!$isClosingTag && $insideTag === null) { |
|
1134 | + $insideTag = $tagName; |
|
1135 | + } |
|
1101 | 1136 | |
1102 | 1137 | // In all other cases, this tag must be invalid |
1103 | - else |
|
1104 | - unset($matches[$i]); |
|
1138 | + else { |
|
1139 | + unset($matches[$i]); |
|
1140 | + } |
|
1105 | 1141 | } |
1106 | 1142 | |
1107 | 1143 | // The next one is gonna be the other one. |
@@ -1109,8 +1145,9 @@ discard block |
||
1109 | 1145 | } |
1110 | 1146 | |
1111 | 1147 | // We're still inside a tag and had no chance for closure? |
1112 | - if ($insideTag !== null) |
|
1113 | - $matches[] = '[/' . $insideTag . ']'; |
|
1148 | + if ($insideTag !== null) { |
|
1149 | + $matches[] = '[/' . $insideTag . ']'; |
|
1150 | + } |
|
1114 | 1151 | |
1115 | 1152 | // And a complete text string again. |
1116 | 1153 | $text = implode('', $matches); |
@@ -1119,8 +1156,9 @@ discard block |
||
1119 | 1156 | // Quickly remove any tags which are back to back. |
1120 | 1157 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
1121 | 1158 | $lastlen = 0; |
1122 | - while (strlen($text) !== $lastlen) |
|
1123 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1159 | + while (strlen($text) !== $lastlen) { |
|
1160 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1161 | + } |
|
1124 | 1162 | |
1125 | 1163 | // Need to sort the tags my name length. |
1126 | 1164 | uksort($valid_tags, 'sort_array_length'); |
@@ -1157,8 +1195,9 @@ discard block |
||
1157 | 1195 | $isCompetingTag = in_array($tag, $competing_tags); |
1158 | 1196 | |
1159 | 1197 | // Check if this might be one of those cleaned out tags. |
1160 | - if ($tag === '') |
|
1161 | - continue; |
|
1198 | + if ($tag === '') { |
|
1199 | + continue; |
|
1200 | + } |
|
1162 | 1201 | |
1163 | 1202 | // Special case: inside [code] blocks any code is left untouched. |
1164 | 1203 | elseif ($tag === 'code') |
@@ -1169,8 +1208,9 @@ discard block |
||
1169 | 1208 | $inCode = false; |
1170 | 1209 | |
1171 | 1210 | // Reopen tags that were closed before the code block. |
1172 | - if (!empty($inlineElements)) |
|
1173 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1211 | + if (!empty($inlineElements)) { |
|
1212 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1213 | + } |
|
1174 | 1214 | } |
1175 | 1215 | |
1176 | 1216 | // We're outside a coding and nobbc block and opening it. |
@@ -1199,8 +1239,9 @@ discard block |
||
1199 | 1239 | $inNoBbc = false; |
1200 | 1240 | |
1201 | 1241 | // Some inline elements might've been closed that need reopening. |
1202 | - if (!empty($inlineElements)) |
|
1203 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1242 | + if (!empty($inlineElements)) { |
|
1243 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1244 | + } |
|
1204 | 1245 | } |
1205 | 1246 | |
1206 | 1247 | // We're outside a nobbc and coding block and opening it. |
@@ -1220,8 +1261,9 @@ discard block |
||
1220 | 1261 | } |
1221 | 1262 | |
1222 | 1263 | // So, we're inside one of the special blocks: ignore any tag. |
1223 | - elseif ($inCode || $inNoBbc) |
|
1224 | - continue; |
|
1264 | + elseif ($inCode || $inNoBbc) { |
|
1265 | + continue; |
|
1266 | + } |
|
1225 | 1267 | |
1226 | 1268 | // We're dealing with an opening tag. |
1227 | 1269 | if ($isOpeningTag) |
@@ -1262,8 +1304,9 @@ discard block |
||
1262 | 1304 | if ($parts[$j + 3] === $tag) |
1263 | 1305 | { |
1264 | 1306 | // If it's an opening tag, increase the level. |
1265 | - if ($parts[$j + 2] === '') |
|
1266 | - $curLevel++; |
|
1307 | + if ($parts[$j + 2] === '') { |
|
1308 | + $curLevel++; |
|
1309 | + } |
|
1267 | 1310 | |
1268 | 1311 | // A closing tag, decrease the level. |
1269 | 1312 | else |
@@ -1286,13 +1329,15 @@ discard block |
||
1286 | 1329 | { |
1287 | 1330 | if ($isCompetingTag) |
1288 | 1331 | { |
1289 | - if (!isset($competingElements[$tag])) |
|
1290 | - $competingElements[$tag] = array(); |
|
1332 | + if (!isset($competingElements[$tag])) { |
|
1333 | + $competingElements[$tag] = array(); |
|
1334 | + } |
|
1291 | 1335 | |
1292 | 1336 | $competingElements[$tag][] = $parts[$i + 4]; |
1293 | 1337 | |
1294 | - if (count($competingElements[$tag]) > 1) |
|
1295 | - $parts[$i] .= '[/' . $tag . ']'; |
|
1338 | + if (count($competingElements[$tag]) > 1) { |
|
1339 | + $parts[$i] .= '[/' . $tag . ']'; |
|
1340 | + } |
|
1296 | 1341 | } |
1297 | 1342 | |
1298 | 1343 | $inlineElements[$elementContent] = $tag; |
@@ -1313,15 +1358,17 @@ discard block |
||
1313 | 1358 | $addClosingTags = array(); |
1314 | 1359 | while ($element = array_pop($blockElements)) |
1315 | 1360 | { |
1316 | - if ($element === $tag) |
|
1317 | - break; |
|
1361 | + if ($element === $tag) { |
|
1362 | + break; |
|
1363 | + } |
|
1318 | 1364 | |
1319 | 1365 | // Still a block tag was open not equal to this tag. |
1320 | 1366 | $addClosingTags[] = $element['type']; |
1321 | 1367 | } |
1322 | 1368 | |
1323 | - if (!empty($addClosingTags)) |
|
1324 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1369 | + if (!empty($addClosingTags)) { |
|
1370 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1371 | + } |
|
1325 | 1372 | |
1326 | 1373 | // Apparently the closing tag was not found on the stack. |
1327 | 1374 | if (!is_string($element) || $element !== $tag) |
@@ -1331,8 +1378,7 @@ discard block |
||
1331 | 1378 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
1332 | 1379 | continue; |
1333 | 1380 | } |
1334 | - } |
|
1335 | - else |
|
1381 | + } else |
|
1336 | 1382 | { |
1337 | 1383 | // Get rid of this closing tag! |
1338 | 1384 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1361,53 +1407,62 @@ discard block |
||
1361 | 1407 | unset($inlineElements[$tagContentToBeClosed]); |
1362 | 1408 | |
1363 | 1409 | // Was this the tag we were looking for? |
1364 | - if ($tagToBeClosed === $tag) |
|
1365 | - break; |
|
1410 | + if ($tagToBeClosed === $tag) { |
|
1411 | + break; |
|
1412 | + } |
|
1366 | 1413 | |
1367 | 1414 | // Nope, close it and look further! |
1368 | - else |
|
1369 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1415 | + else { |
|
1416 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1417 | + } |
|
1370 | 1418 | } |
1371 | 1419 | |
1372 | 1420 | if ($isCompetingTag && !empty($competingElements[$tag])) |
1373 | 1421 | { |
1374 | 1422 | array_pop($competingElements[$tag]); |
1375 | 1423 | |
1376 | - if (count($competingElements[$tag]) > 0) |
|
1377 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1424 | + if (count($competingElements[$tag]) > 0) { |
|
1425 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1426 | + } |
|
1378 | 1427 | } |
1379 | 1428 | } |
1380 | 1429 | |
1381 | 1430 | // Unexpected closing tag, ex-ter-mi-nate. |
1382 | - else |
|
1383 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1431 | + else { |
|
1432 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1433 | + } |
|
1384 | 1434 | } |
1385 | 1435 | } |
1386 | 1436 | } |
1387 | 1437 | |
1388 | 1438 | // Close the code tags. |
1389 | - if ($inCode) |
|
1390 | - $parts[$i] .= '[/code]'; |
|
1439 | + if ($inCode) { |
|
1440 | + $parts[$i] .= '[/code]'; |
|
1441 | + } |
|
1391 | 1442 | |
1392 | 1443 | // The same for nobbc tags. |
1393 | - elseif ($inNoBbc) |
|
1394 | - $parts[$i] .= '[/nobbc]'; |
|
1444 | + elseif ($inNoBbc) { |
|
1445 | + $parts[$i] .= '[/nobbc]'; |
|
1446 | + } |
|
1395 | 1447 | |
1396 | 1448 | // Still inline tags left unclosed? Close them now, better late than never. |
1397 | - elseif (!empty($inlineElements)) |
|
1398 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1449 | + elseif (!empty($inlineElements)) { |
|
1450 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1451 | + } |
|
1399 | 1452 | |
1400 | 1453 | // Now close the block elements. |
1401 | - if (!empty($blockElements)) |
|
1402 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1454 | + if (!empty($blockElements)) { |
|
1455 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1456 | + } |
|
1403 | 1457 | |
1404 | 1458 | $text = implode('', $parts); |
1405 | 1459 | } |
1406 | 1460 | |
1407 | 1461 | // Final clean up of back to back tags. |
1408 | 1462 | $lastlen = 0; |
1409 | - while (strlen($text) !== $lastlen) |
|
1410 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1463 | + while (strlen($text) !== $lastlen) { |
|
1464 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1465 | + } |
|
1411 | 1466 | |
1412 | 1467 | return $text; |
1413 | 1468 | } |
@@ -1436,22 +1491,25 @@ discard block |
||
1436 | 1491 | $context['template_layers'] = array(); |
1437 | 1492 | // Lets make sure we aren't going to output anything nasty. |
1438 | 1493 | @ob_end_clean(); |
1439 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
1440 | - @ob_start('ob_gzhandler'); |
|
1441 | - else |
|
1442 | - @ob_start(); |
|
1494 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
1495 | + @ob_start('ob_gzhandler'); |
|
1496 | + } else { |
|
1497 | + @ob_start(); |
|
1498 | + } |
|
1443 | 1499 | |
1444 | 1500 | // If we don't have any locale better avoid broken js |
1445 | - if (empty($txt['lang_locale'])) |
|
1446 | - die(); |
|
1501 | + if (empty($txt['lang_locale'])) { |
|
1502 | + die(); |
|
1503 | + } |
|
1447 | 1504 | |
1448 | 1505 | $file_data = '(function ($) { |
1449 | 1506 | \'use strict\'; |
1450 | 1507 | |
1451 | 1508 | $.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {'; |
1452 | - foreach ($editortxt as $key => $val) |
|
1453 | - $file_data .= ' |
|
1509 | + foreach ($editortxt as $key => $val) { |
|
1510 | + $file_data .= ' |
|
1454 | 1511 | ' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ','; |
1512 | + } |
|
1455 | 1513 | |
1456 | 1514 | $file_data .= ' |
1457 | 1515 | dateFormat: "day.month.year" |
@@ -1519,8 +1577,9 @@ discard block |
||
1519 | 1577 | ) |
1520 | 1578 | ); |
1521 | 1579 | $icon_data = array(); |
1522 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1523 | - $icon_data[] = $row; |
|
1580 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1581 | + $icon_data[] = $row; |
|
1582 | + } |
|
1524 | 1583 | $smcFunc['db_free_result']($request); |
1525 | 1584 | |
1526 | 1585 | $icons = array(); |
@@ -1535,9 +1594,9 @@ discard block |
||
1535 | 1594 | } |
1536 | 1595 | |
1537 | 1596 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
1597 | + } else { |
|
1598 | + $icons = $temp; |
|
1538 | 1599 | } |
1539 | - else |
|
1540 | - $icons = $temp; |
|
1541 | 1600 | } |
1542 | 1601 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
1543 | 1602 | |
@@ -1579,8 +1638,9 @@ discard block |
||
1579 | 1638 | { |
1580 | 1639 | // Some general stuff. |
1581 | 1640 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
1582 | - if (!empty($context['drafts_autosave'])) |
|
1583 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1641 | + if (!empty($context['drafts_autosave'])) { |
|
1642 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1643 | + } |
|
1584 | 1644 | |
1585 | 1645 | // This really has some WYSIWYG stuff. |
1586 | 1646 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1598,8 +1658,9 @@ discard block |
||
1598 | 1658 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
1599 | 1659 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
1600 | 1660 | // editor language file |
1601 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
1602 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1661 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
1662 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1663 | + } |
|
1603 | 1664 | |
1604 | 1665 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))]; |
1605 | 1666 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1608,11 +1669,12 @@ discard block |
||
1608 | 1669 | loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck'); |
1609 | 1670 | |
1610 | 1671 | // Some hidden information is needed in order to make the spell checking work. |
1611 | - if (!isset($_REQUEST['xml'])) |
|
1612 | - $context['insert_after_template'] .= ' |
|
1672 | + if (!isset($_REQUEST['xml'])) { |
|
1673 | + $context['insert_after_template'] .= ' |
|
1613 | 1674 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
1614 | 1675 | <input type="hidden" name="spellstring" value=""> |
1615 | 1676 | </form>'; |
1677 | + } |
|
1616 | 1678 | } |
1617 | 1679 | } |
1618 | 1680 | |
@@ -1803,10 +1865,12 @@ discard block |
||
1803 | 1865 | |
1804 | 1866 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
1805 | 1867 | $disabled_tags = array(); |
1806 | - if (!empty($modSettings['disabledBBC'])) |
|
1807 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1808 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1809 | - $disabled_tags[] = 'flash'; |
|
1868 | + if (!empty($modSettings['disabledBBC'])) { |
|
1869 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1870 | + } |
|
1871 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1872 | + $disabled_tags[] = 'flash'; |
|
1873 | + } |
|
1810 | 1874 | |
1811 | 1875 | foreach ($disabled_tags as $tag) |
1812 | 1876 | { |
@@ -1818,9 +1882,10 @@ discard block |
||
1818 | 1882 | $context['disabled_tags']['orderedlist'] = true; |
1819 | 1883 | } |
1820 | 1884 | |
1821 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
1822 | - if ($tag === $thisTag) |
|
1885 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
1886 | + if ($tag === $thisTag) |
|
1823 | 1887 | $context['disabled_tags'][$tagNameBBC] = true; |
1888 | + } |
|
1824 | 1889 | |
1825 | 1890 | $context['disabled_tags'][$tag] = true; |
1826 | 1891 | } |
@@ -1831,8 +1896,9 @@ discard block |
||
1831 | 1896 | |
1832 | 1897 | foreach ($context['bbc_tags'] as $row => $tagRow) |
1833 | 1898 | { |
1834 | - if (!isset($context['bbc_toolbar'][$row])) |
|
1835 | - $context['bbc_toolbar'][$row] = array(); |
|
1899 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
1900 | + $context['bbc_toolbar'][$row] = array(); |
|
1901 | + } |
|
1836 | 1902 | |
1837 | 1903 | $tagsRow = array(); |
1838 | 1904 | |
@@ -1868,20 +1934,21 @@ discard block |
||
1868 | 1934 | |
1869 | 1935 | $context['bbcodes_handlers'] .= ' |
1870 | 1936 | });'; |
1871 | - } |
|
1872 | - else |
|
1937 | + } else |
|
1873 | 1938 | { |
1874 | 1939 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1875 | 1940 | $tagsRow = array(); |
1876 | 1941 | } |
1877 | 1942 | } |
1878 | 1943 | |
1879 | - if (!empty($tagsRow)) |
|
1880 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1944 | + if (!empty($tagsRow)) { |
|
1945 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1946 | + } |
|
1881 | 1947 | } |
1882 | 1948 | |
1883 | - if (!empty($bbcodes_styles)) |
|
1884 | - addInlineCss($bbcodes_styles); |
|
1949 | + if (!empty($bbcodes_styles)) { |
|
1950 | + addInlineCss($bbcodes_styles); |
|
1951 | + } |
|
1885 | 1952 | } |
1886 | 1953 | |
1887 | 1954 | // Initialize smiley array... if not loaded before. |
@@ -1893,8 +1960,8 @@ discard block |
||
1893 | 1960 | ); |
1894 | 1961 | |
1895 | 1962 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
1896 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
1897 | - $context['smileys']['postform'][] = array( |
|
1963 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
1964 | + $context['smileys']['postform'][] = array( |
|
1898 | 1965 | 'smileys' => array( |
1899 | 1966 | array( |
1900 | 1967 | 'code' => ':)', |
@@ -1980,7 +2047,7 @@ discard block |
||
1980 | 2047 | ), |
1981 | 2048 | 'isLast' => true, |
1982 | 2049 | ); |
1983 | - elseif ($user_info['smiley_set'] != 'none') |
|
2050 | + } elseif ($user_info['smiley_set'] != 'none') |
|
1984 | 2051 | { |
1985 | 2052 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
1986 | 2053 | { |
@@ -2003,17 +2070,19 @@ discard block |
||
2003 | 2070 | |
2004 | 2071 | foreach ($context['smileys'] as $section => $smileyRows) |
2005 | 2072 | { |
2006 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
2007 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2073 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
2074 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2075 | + } |
|
2008 | 2076 | |
2009 | - if (!empty($smileyRows)) |
|
2010 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2077 | + if (!empty($smileyRows)) { |
|
2078 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2079 | + } |
|
2011 | 2080 | } |
2012 | 2081 | |
2013 | 2082 | cache_put_data('posting_smileys', $context['smileys'], 480); |
2083 | + } else { |
|
2084 | + $context['smileys'] = $temp; |
|
2014 | 2085 | } |
2015 | - else |
|
2016 | - $context['smileys'] = $temp; |
|
2017 | 2086 | } |
2018 | 2087 | } |
2019 | 2088 | |
@@ -2029,12 +2098,15 @@ discard block |
||
2029 | 2098 | 'plugins' => 'undo' . (empty($modSettings['disabledBBC']) || strpos($modSettings['disabledBBC'], 'youtube') === false ? ',autoyoutube' : ''), |
2030 | 2099 | 'bbcodeTrim' => true, |
2031 | 2100 | ); |
2032 | - if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) |
|
2033 | - $sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale']; |
|
2034 | - if (!empty($context['right_to_left'])) |
|
2035 | - $sce_options['rtl'] = true; |
|
2036 | - if ($editorOptions['id'] != 'quickReply') |
|
2037 | - $sce_options['autofocus'] = true; |
|
2101 | + if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) { |
|
2102 | + $sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale']; |
|
2103 | + } |
|
2104 | + if (!empty($context['right_to_left'])) { |
|
2105 | + $sce_options['rtl'] = true; |
|
2106 | + } |
|
2107 | + if ($editorOptions['id'] != 'quickReply') { |
|
2108 | + $sce_options['autofocus'] = true; |
|
2109 | + } |
|
2038 | 2110 | |
2039 | 2111 | $sce_options['emoticons'] = array(); |
2040 | 2112 | $sce_options['emoticonsEnabled'] = false; |
@@ -2050,10 +2122,11 @@ discard block |
||
2050 | 2122 | $countLocations--; |
2051 | 2123 | |
2052 | 2124 | unset($smiley_location); |
2053 | - if ($location == 'postform') |
|
2054 | - $smiley_location = &$sce_options['emoticons']['dropdown']; |
|
2055 | - elseif ($location == 'popup') |
|
2056 | - $smiley_location = &$sce_options['emoticons']['popup']; |
|
2125 | + if ($location == 'postform') { |
|
2126 | + $smiley_location = &$sce_options['emoticons']['dropdown']; |
|
2127 | + } elseif ($location == 'popup') { |
|
2128 | + $smiley_location = &$sce_options['emoticons']['popup']; |
|
2129 | + } |
|
2057 | 2130 | |
2058 | 2131 | $numRows = count($smileyRows); |
2059 | 2132 | |
@@ -2061,11 +2134,13 @@ discard block |
||
2061 | 2134 | $emptyPlaceholder = 0; |
2062 | 2135 | foreach ($smileyRows as $smileyRow) |
2063 | 2136 | { |
2064 | - foreach ($smileyRow['smileys'] as $smiley) |
|
2065 | - $smiley_location[$smiley['code']] = $settings['smileys_url'] . '/' . $smiley['filename']; |
|
2137 | + foreach ($smileyRow['smileys'] as $smiley) { |
|
2138 | + $smiley_location[$smiley['code']] = $settings['smileys_url'] . '/' . $smiley['filename']; |
|
2139 | + } |
|
2066 | 2140 | |
2067 | - if (empty($smileyRow['isLast']) && $numRows != 1) |
|
2068 | - $smiley_location['-' . $emptyPlaceholder++] = ''; |
|
2141 | + if (empty($smileyRow['isLast']) && $numRows != 1) { |
|
2142 | + $smiley_location['-' . $emptyPlaceholder++] = ''; |
|
2143 | + } |
|
2069 | 2144 | } |
2070 | 2145 | } |
2071 | 2146 | } |
@@ -2080,8 +2155,9 @@ discard block |
||
2080 | 2155 | |
2081 | 2156 | $count_tags--; |
2082 | 2157 | |
2083 | - if (!empty($count_tags)) |
|
2084 | - $sce_options['toolbar'] .= '||'; |
|
2158 | + if (!empty($count_tags)) { |
|
2159 | + $sce_options['toolbar'] .= '||'; |
|
2160 | + } |
|
2085 | 2161 | } |
2086 | 2162 | } |
2087 | 2163 | |
@@ -2109,8 +2185,9 @@ discard block |
||
2109 | 2185 | loadTemplate('GenericControls'); |
2110 | 2186 | |
2111 | 2187 | // Some javascript ma'am? |
2112 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
2113 | - loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
2188 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
2189 | + loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
2190 | + } |
|
2114 | 2191 | |
2115 | 2192 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
2116 | 2193 | |
@@ -2123,8 +2200,8 @@ discard block |
||
2123 | 2200 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
2124 | 2201 | |
2125 | 2202 | // Log this into our collection. |
2126 | - if ($isNew) |
|
2127 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2203 | + if ($isNew) { |
|
2204 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2128 | 2205 | 'id' => $verificationOptions['id'], |
2129 | 2206 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
2130 | 2207 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2135,13 +2212,15 @@ discard block |
||
2135 | 2212 | 'questions' => array(), |
2136 | 2213 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
2137 | 2214 | ); |
2215 | + } |
|
2138 | 2216 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
2139 | 2217 | |
2140 | 2218 | // Is there actually going to be anything? |
2141 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
2142 | - return false; |
|
2143 | - elseif (!$isNew && !$do_test) |
|
2144 | - return true; |
|
2219 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
2220 | + return false; |
|
2221 | + } elseif (!$isNew && !$do_test) { |
|
2222 | + return true; |
|
2223 | + } |
|
2145 | 2224 | |
2146 | 2225 | // Sanitize reCAPTCHA fields? |
2147 | 2226 | if ($thisVerification['can_recaptcha']) |
@@ -2154,11 +2233,12 @@ discard block |
||
2154 | 2233 | } |
2155 | 2234 | |
2156 | 2235 | // Add javascript for the object. |
2157 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
2158 | - $context['insert_after_template'] .= ' |
|
2236 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
2237 | + $context['insert_after_template'] .= ' |
|
2159 | 2238 | <script> |
2160 | 2239 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
2161 | 2240 | </script>'; |
2241 | + } |
|
2162 | 2242 | |
2163 | 2243 | // If we want questions do we have a cache of all the IDs? |
2164 | 2244 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2181,8 +2261,9 @@ discard block |
||
2181 | 2261 | unset ($row['id_question']); |
2182 | 2262 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
2183 | 2263 | $row['answers'] = $smcFunc['json_decode']($row['answers'], true); |
2184 | - foreach ($row['answers'] as $k => $v) |
|
2185 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2264 | + foreach ($row['answers'] as $k => $v) { |
|
2265 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2266 | + } |
|
2186 | 2267 | |
2187 | 2268 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
2188 | 2269 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2193,35 +2274,42 @@ discard block |
||
2193 | 2274 | } |
2194 | 2275 | } |
2195 | 2276 | |
2196 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
2197 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2277 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
2278 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2279 | + } |
|
2198 | 2280 | |
2199 | 2281 | // Do we need to refresh the verification? |
2200 | - if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) |
|
2201 | - $force_refresh = true; |
|
2202 | - else |
|
2203 | - $force_refresh = false; |
|
2282 | + if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) { |
|
2283 | + $force_refresh = true; |
|
2284 | + } else { |
|
2285 | + $force_refresh = false; |
|
2286 | + } |
|
2204 | 2287 | |
2205 | 2288 | // This can also force a fresh, although unlikely. |
2206 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
2207 | - $force_refresh = true; |
|
2289 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
2290 | + $force_refresh = true; |
|
2291 | + } |
|
2208 | 2292 | |
2209 | 2293 | $verification_errors = array(); |
2210 | 2294 | // Start with any testing. |
2211 | 2295 | if ($do_test) |
2212 | 2296 | { |
2213 | 2297 | // This cannot happen! |
2214 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
2215 | - fatal_lang_error('no_access', false); |
|
2298 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
2299 | + fatal_lang_error('no_access', false); |
|
2300 | + } |
|
2216 | 2301 | // ... nor this! |
2217 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
2218 | - fatal_lang_error('no_access', false); |
|
2302 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
2303 | + fatal_lang_error('no_access', false); |
|
2304 | + } |
|
2219 | 2305 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
2220 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
2221 | - fatal_lang_error('no_access', false); |
|
2306 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
2307 | + fatal_lang_error('no_access', false); |
|
2308 | + } |
|
2222 | 2309 | // While we're here, did the user do something bad? |
2223 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
2224 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2310 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
2311 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2312 | + } |
|
2225 | 2313 | |
2226 | 2314 | if ($thisVerification['can_recaptcha']) |
2227 | 2315 | { |
@@ -2232,22 +2320,25 @@ discard block |
||
2232 | 2320 | { |
2233 | 2321 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
2234 | 2322 | |
2235 | - if (!$resp->isSuccess()) |
|
2236 | - $verification_errors[] = 'wrong_verification_code'; |
|
2323 | + if (!$resp->isSuccess()) { |
|
2324 | + $verification_errors[] = 'wrong_verification_code'; |
|
2325 | + } |
|
2326 | + } else { |
|
2327 | + $verification_errors[] = 'wrong_verification_code'; |
|
2237 | 2328 | } |
2238 | - else |
|
2239 | - $verification_errors[] = 'wrong_verification_code'; |
|
2240 | 2329 | } |
2241 | - if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) |
|
2242 | - $verification_errors[] = 'wrong_verification_code'; |
|
2330 | + if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) { |
|
2331 | + $verification_errors[] = 'wrong_verification_code'; |
|
2332 | + } |
|
2243 | 2333 | if ($thisVerification['number_questions']) |
2244 | 2334 | { |
2245 | 2335 | $incorrectQuestions = array(); |
2246 | 2336 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
2247 | 2337 | { |
2248 | 2338 | // We don't have this question any more, thus no answers. |
2249 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
2250 | - continue; |
|
2339 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
2340 | + continue; |
|
2341 | + } |
|
2251 | 2342 | // This is quite complex. We have our question but it might have multiple answers. |
2252 | 2343 | // First, did they actually answer this question? |
2253 | 2344 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2259,24 +2350,28 @@ discard block |
||
2259 | 2350 | else |
2260 | 2351 | { |
2261 | 2352 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
2262 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
2263 | - $incorrectQuestions[] = $q; |
|
2353 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
2354 | + $incorrectQuestions[] = $q; |
|
2355 | + } |
|
2264 | 2356 | } |
2265 | 2357 | } |
2266 | 2358 | |
2267 | - if (!empty($incorrectQuestions)) |
|
2268 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2359 | + if (!empty($incorrectQuestions)) { |
|
2360 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2361 | + } |
|
2269 | 2362 | } |
2270 | 2363 | } |
2271 | 2364 | |
2272 | 2365 | // Any errors means we refresh potentially. |
2273 | 2366 | if (!empty($verification_errors)) |
2274 | 2367 | { |
2275 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
2276 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2368 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
2369 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2370 | + } |
|
2277 | 2371 | // Too many errors? |
2278 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
2279 | - $force_refresh = true; |
|
2372 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
2373 | + $force_refresh = true; |
|
2374 | + } |
|
2280 | 2375 | |
2281 | 2376 | // Keep a track of these. |
2282 | 2377 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2309,8 +2404,9 @@ discard block |
||
2309 | 2404 | // Are we overriding the range? |
2310 | 2405 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
2311 | 2406 | |
2312 | - for ($i = 0; $i < 6; $i++) |
|
2313 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2407 | + for ($i = 0; $i < 6; $i++) { |
|
2408 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2409 | + } |
|
2314 | 2410 | } |
2315 | 2411 | |
2316 | 2412 | // Getting some new questions? |
@@ -2318,8 +2414,9 @@ discard block |
||
2318 | 2414 | { |
2319 | 2415 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
2320 | 2416 | $possible_langs = array(); |
2321 | - if (isset($_SESSION['language'])) |
|
2322 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2417 | + if (isset($_SESSION['language'])) { |
|
2418 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2419 | + } |
|
2323 | 2420 | if (!empty($user_info['language'])); |
2324 | 2421 | $possible_langs[] = $user_info['language']; |
2325 | 2422 | $possible_langs[] = $language; |
@@ -2338,8 +2435,7 @@ discard block |
||
2338 | 2435 | } |
2339 | 2436 | } |
2340 | 2437 | } |
2341 | - } |
|
2342 | - else |
|
2438 | + } else |
|
2343 | 2439 | { |
2344 | 2440 | // Same questions as before. |
2345 | 2441 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2349,8 +2445,9 @@ discard block |
||
2349 | 2445 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
2350 | 2446 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
2351 | 2447 | { |
2352 | - if (!isset($context['html_headers'])) |
|
2353 | - $context['html_headers'] = ''; |
|
2448 | + if (!isset($context['html_headers'])) { |
|
2449 | + $context['html_headers'] = ''; |
|
2450 | + } |
|
2354 | 2451 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
2355 | 2452 | } |
2356 | 2453 | |
@@ -2376,11 +2473,13 @@ discard block |
||
2376 | 2473 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
2377 | 2474 | |
2378 | 2475 | // Return errors if we have them. |
2379 | - if (!empty($verification_errors)) |
|
2380 | - return $verification_errors; |
|
2476 | + if (!empty($verification_errors)) { |
|
2477 | + return $verification_errors; |
|
2478 | + } |
|
2381 | 2479 | // If we had a test that one, make a note. |
2382 | - elseif ($do_test) |
|
2383 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2480 | + elseif ($do_test) { |
|
2481 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2482 | + } |
|
2384 | 2483 | |
2385 | 2484 | // Say that everything went well chaps. |
2386 | 2485 | return true; |
@@ -2405,8 +2504,9 @@ discard block |
||
2405 | 2504 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
2406 | 2505 | |
2407 | 2506 | // If we're just checking the callback function is registered return true or false. |
2408 | - if ($checkRegistered != null) |
|
2409 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2507 | + if ($checkRegistered != null) { |
|
2508 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2509 | + } |
|
2410 | 2510 | |
2411 | 2511 | checkSession('get'); |
2412 | 2512 | loadTemplate('Xml'); |
@@ -2557,24 +2657,27 @@ discard block |
||
2557 | 2657 | foreach ($possible_versions as $ver) |
2558 | 2658 | { |
2559 | 2659 | $ver = trim($ver); |
2560 | - if (strpos($ver, 'SMF') === 0) |
|
2561 | - $versions[] = $ver; |
|
2660 | + if (strpos($ver, 'SMF') === 0) { |
|
2661 | + $versions[] = $ver; |
|
2662 | + } |
|
2562 | 2663 | } |
2563 | 2664 | } |
2564 | 2665 | $smcFunc['db_free_result']($request); |
2565 | 2666 | |
2566 | 2667 | // Just in case we don't have ANYthing. |
2567 | - if (empty($versions)) |
|
2568 | - $versions = array('SMF 2.0'); |
|
2668 | + if (empty($versions)) { |
|
2669 | + $versions = array('SMF 2.0'); |
|
2670 | + } |
|
2569 | 2671 | |
2570 | - foreach ($versions as $id => $version) |
|
2571 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2672 | + foreach ($versions as $id => $version) { |
|
2673 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2572 | 2674 | $xml_data['items']['children'][] = array( |
2573 | 2675 | 'attributes' => array( |
2574 | 2676 | 'id' => $id, |
2575 | 2677 | ), |
2576 | 2678 | 'value' => $version, |
2577 | 2679 | ); |
2680 | + } |
|
2578 | 2681 | |
2579 | 2682 | return $xml_data; |
2580 | 2683 | } |
@@ -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 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
35 | 36 | global $sourcedir, $smcFunc, $language; |
36 | 37 | |
37 | 38 | loadLanguage('Post'); |
38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
39 | - loadLanguage('Drafts'); |
|
39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
40 | + loadLanguage('Drafts'); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // You can't reply with a poll... hacker. |
42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
43 | - unset($_REQUEST['poll']); |
|
44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
45 | + unset($_REQUEST['poll']); |
|
46 | + } |
|
44 | 47 | |
45 | 48 | // Posting an event? |
46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -58,12 +61,14 @@ discard block |
||
58 | 61 | { |
59 | 62 | // Get ids of all the boards they can post in. |
60 | 63 | $post_permissions = array('post_new'); |
61 | - if ($modSettings['postmod_active']) |
|
62 | - $post_permissions[] = 'post_unapproved_topics'; |
|
64 | + if ($modSettings['postmod_active']) { |
|
65 | + $post_permissions[] = 'post_unapproved_topics'; |
|
66 | + } |
|
63 | 67 | |
64 | 68 | $boards = boardsAllowedTo($post_permissions); |
65 | - if (empty($boards)) |
|
66 | - fatal_lang_error('cannot_post_new', false); |
|
69 | + if (empty($boards)) { |
|
70 | + fatal_lang_error('cannot_post_new', false); |
|
71 | + } |
|
67 | 72 | |
68 | 73 | // Get a list of boards for the select menu |
69 | 74 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -76,8 +81,9 @@ discard block |
||
76 | 81 | $board_list = getBoardList($boardListOptions); |
77 | 82 | } |
78 | 83 | // Let's keep things simple for ourselves below |
79 | - else |
|
80 | - $boards = array($board); |
|
84 | + else { |
|
85 | + $boards = array($board); |
|
86 | + } |
|
81 | 87 | |
82 | 88 | require_once($sourcedir . '/Subs-Post.php'); |
83 | 89 | |
@@ -100,10 +106,11 @@ discard block |
||
100 | 106 | array( |
101 | 107 | 'msg' => (int) $_REQUEST['msg'], |
102 | 108 | )); |
103 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
104 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
105 | - else |
|
106 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
109 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
110 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
111 | + } else { |
|
112 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
113 | + } |
|
107 | 114 | $smcFunc['db_free_result']($request); |
108 | 115 | } |
109 | 116 | |
@@ -130,33 +137,36 @@ discard block |
||
130 | 137 | $smcFunc['db_free_result']($request); |
131 | 138 | |
132 | 139 | // If this topic already has a poll, they sure can't add another. |
133 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
134 | - unset($_REQUEST['poll']); |
|
140 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
141 | + unset($_REQUEST['poll']); |
|
142 | + } |
|
135 | 143 | |
136 | 144 | if (empty($_REQUEST['msg'])) |
137 | 145 | { |
138 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
139 | - is_not_guest(); |
|
146 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
147 | + is_not_guest(); |
|
148 | + } |
|
140 | 149 | |
141 | 150 | // By default the reply will be approved... |
142 | 151 | $context['becomes_approved'] = true; |
143 | 152 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
144 | 153 | { |
145 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
146 | - $context['becomes_approved'] = false; |
|
147 | - else |
|
148 | - isAllowedTo('post_reply_any'); |
|
149 | - } |
|
150 | - elseif (!allowedTo('post_reply_any')) |
|
154 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
155 | + $context['becomes_approved'] = false; |
|
156 | + } else { |
|
157 | + isAllowedTo('post_reply_any'); |
|
158 | + } |
|
159 | + } elseif (!allowedTo('post_reply_any')) |
|
151 | 160 | { |
152 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
153 | - $context['becomes_approved'] = false; |
|
154 | - else |
|
155 | - isAllowedTo('post_reply_own'); |
|
161 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
162 | + $context['becomes_approved'] = false; |
|
163 | + } else { |
|
164 | + isAllowedTo('post_reply_own'); |
|
165 | + } |
|
156 | 166 | } |
167 | + } else { |
|
168 | + $context['becomes_approved'] = true; |
|
157 | 169 | } |
158 | - else |
|
159 | - $context['becomes_approved'] = true; |
|
160 | 170 | |
161 | 171 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
162 | 172 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -171,17 +181,18 @@ discard block |
||
171 | 181 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
172 | 182 | |
173 | 183 | // Check whether this is a really old post being bumped... |
174 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
175 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
176 | - } |
|
177 | - else |
|
184 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
185 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
186 | + } |
|
187 | + } else |
|
178 | 188 | { |
179 | 189 | // @todo Should use JavaScript to hide and show the warning based on the selection in the board select menu |
180 | 190 | $context['becomes_approved'] = true; |
181 | - if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) |
|
182 | - $context['becomes_approved'] = false; |
|
183 | - else |
|
184 | - isAllowedTo('post_new', $boards, true); |
|
191 | + if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) { |
|
192 | + $context['becomes_approved'] = false; |
|
193 | + } else { |
|
194 | + isAllowedTo('post_new', $boards, true); |
|
195 | + } |
|
185 | 196 | |
186 | 197 | $locked = 0; |
187 | 198 | $context['already_locked'] = 0; |
@@ -211,27 +222,32 @@ discard block |
||
211 | 222 | if (empty($_REQUEST['message']) && empty($_REQUEST['preview']) && !empty($_SESSION['already_attached'])) |
212 | 223 | { |
213 | 224 | require_once($sourcedir . '/ManageAttachments.php'); |
214 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
215 | - removeAttachments(array('id_attach' => $attachID)); |
|
225 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
226 | + removeAttachments(array('id_attach' => $attachID)); |
|
227 | + } |
|
216 | 228 | |
217 | 229 | unset($_SESSION['already_attached']); |
218 | 230 | } |
219 | 231 | |
220 | 232 | // Don't allow a post if it's locked and you aren't all powerful. |
221 | - if ($locked && !allowedTo('moderate_board')) |
|
222 | - fatal_lang_error('topic_locked', false); |
|
233 | + if ($locked && !allowedTo('moderate_board')) { |
|
234 | + fatal_lang_error('topic_locked', false); |
|
235 | + } |
|
223 | 236 | // Check the users permissions - is the user allowed to add or post a poll? |
224 | 237 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
225 | 238 | { |
226 | 239 | // New topic, new poll. |
227 | - if (empty($topic)) |
|
228 | - isAllowedTo('poll_post'); |
|
240 | + if (empty($topic)) { |
|
241 | + isAllowedTo('poll_post'); |
|
242 | + } |
|
229 | 243 | // This is an old topic - but it is yours! Can you add to it? |
230 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
231 | - isAllowedTo('poll_add_own'); |
|
244 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
245 | + isAllowedTo('poll_add_own'); |
|
246 | + } |
|
232 | 247 | // If you're not the owner, can you add to any poll? |
233 | - else |
|
234 | - isAllowedTo('poll_add_any'); |
|
248 | + else { |
|
249 | + isAllowedTo('poll_add_any'); |
|
250 | + } |
|
235 | 251 | |
236 | 252 | if (!empty($board)) |
237 | 253 | { |
@@ -240,8 +256,9 @@ discard block |
||
240 | 256 | $guest_vote_enabled = in_array(-1, $allowedVoteGroups['allowed']); |
241 | 257 | } |
242 | 258 | // No board, so we'll have to check this again in Post2 |
243 | - else |
|
244 | - $guest_vote_enabled = true; |
|
259 | + else { |
|
260 | + $guest_vote_enabled = true; |
|
261 | + } |
|
245 | 262 | |
246 | 263 | // Set up the poll options. |
247 | 264 | $context['poll_options'] = array( |
@@ -267,8 +284,9 @@ discard block |
||
267 | 284 | if ($context['make_event']) |
268 | 285 | { |
269 | 286 | // They might want to pick a board. |
270 | - if (!isset($context['current_board'])) |
|
271 | - $context['current_board'] = 0; |
|
287 | + if (!isset($context['current_board'])) { |
|
288 | + $context['current_board'] = 0; |
|
289 | + } |
|
272 | 290 | |
273 | 291 | // Start loading up the event info. |
274 | 292 | $context['event'] = array(); |
@@ -282,10 +300,11 @@ discard block |
||
282 | 300 | isAllowedTo('calendar_post'); |
283 | 301 | |
284 | 302 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
285 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
286 | - $time_string = '%k:%M'; |
|
287 | - else |
|
288 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
303 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
304 | + $time_string = '%k:%M'; |
|
305 | + } else { |
|
306 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
307 | + } |
|
289 | 308 | |
290 | 309 | $js_time_string = str_replace( |
291 | 310 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -307,8 +326,7 @@ discard block |
||
307 | 326 | require_once($sourcedir . '/Subs-Calendar.php'); |
308 | 327 | $eventProperties = getEventProperties($context['event']['id']); |
309 | 328 | $context['event'] = array_merge($context['event'], $eventProperties); |
310 | - } |
|
311 | - else |
|
329 | + } else |
|
312 | 330 | { |
313 | 331 | // Get the current event information. |
314 | 332 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -316,10 +334,12 @@ discard block |
||
316 | 334 | $context['event'] = array_merge($context['event'], $eventProperties); |
317 | 335 | |
318 | 336 | // Make sure the year and month are in the valid range. |
319 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
320 | - fatal_lang_error('invalid_month', false); |
|
321 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
322 | - fatal_lang_error('invalid_year', false); |
|
337 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
338 | + fatal_lang_error('invalid_month', false); |
|
339 | + } |
|
340 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
341 | + fatal_lang_error('invalid_year', false); |
|
342 | + } |
|
323 | 343 | |
324 | 344 | $context['event']['categories'] = $board_list; |
325 | 345 | } |
@@ -430,10 +450,11 @@ discard block |
||
430 | 450 | |
431 | 451 | if (!empty($context['new_replies'])) |
432 | 452 | { |
433 | - if ($context['new_replies'] == 1) |
|
434 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
435 | - else |
|
436 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
453 | + if ($context['new_replies'] == 1) { |
|
454 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
455 | + } else { |
|
456 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
457 | + } |
|
437 | 458 | |
438 | 459 | $post_errors[] = 'new_replies'; |
439 | 460 | |
@@ -445,9 +466,9 @@ discard block |
||
445 | 466 | // Get a response prefix (like 'Re:') in the default forum language. |
446 | 467 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
447 | 468 | { |
448 | - if ($language === $user_info['language']) |
|
449 | - $context['response_prefix'] = $txt['response_prefix']; |
|
450 | - else |
|
469 | + if ($language === $user_info['language']) { |
|
470 | + $context['response_prefix'] = $txt['response_prefix']; |
|
471 | + } else |
|
451 | 472 | { |
452 | 473 | loadLanguage('index', $language, false); |
453 | 474 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -460,23 +481,26 @@ discard block |
||
460 | 481 | // Do we have a body, but an error happened. |
461 | 482 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
462 | 483 | { |
463 | - if (isset($_REQUEST['quickReply'])) |
|
464 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
484 | + if (isset($_REQUEST['quickReply'])) { |
|
485 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
486 | + } |
|
465 | 487 | |
466 | 488 | // Validate inputs. |
467 | 489 | if (empty($context['post_error'])) |
468 | 490 | { |
469 | 491 | // This means they didn't click Post and get an error. |
470 | 492 | $really_previewing = true; |
471 | - } |
|
472 | - else |
|
493 | + } else |
|
473 | 494 | { |
474 | - if (!isset($_REQUEST['subject'])) |
|
475 | - $_REQUEST['subject'] = ''; |
|
476 | - if (!isset($_REQUEST['message'])) |
|
477 | - $_REQUEST['message'] = ''; |
|
478 | - if (!isset($_REQUEST['icon'])) |
|
479 | - $_REQUEST['icon'] = 'xx'; |
|
495 | + if (!isset($_REQUEST['subject'])) { |
|
496 | + $_REQUEST['subject'] = ''; |
|
497 | + } |
|
498 | + if (!isset($_REQUEST['message'])) { |
|
499 | + $_REQUEST['message'] = ''; |
|
500 | + } |
|
501 | + if (!isset($_REQUEST['icon'])) { |
|
502 | + $_REQUEST['icon'] = 'xx'; |
|
503 | + } |
|
480 | 504 | |
481 | 505 | // They are previewing if they asked to preview (i.e. came from quick reply). |
482 | 506 | $really_previewing = !empty($_POST['preview']); |
@@ -492,8 +516,9 @@ discard block |
||
492 | 516 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
493 | 517 | |
494 | 518 | // Make sure the subject isn't too long - taking into account special characters. |
495 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
496 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
519 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
520 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
521 | + } |
|
497 | 522 | |
498 | 523 | if (isset($_REQUEST['poll'])) |
499 | 524 | { |
@@ -505,8 +530,9 @@ discard block |
||
505 | 530 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
506 | 531 | foreach ($_POST['options'] as $option) |
507 | 532 | { |
508 | - if (trim($option) == '') |
|
509 | - continue; |
|
533 | + if (trim($option) == '') { |
|
534 | + continue; |
|
535 | + } |
|
510 | 536 | |
511 | 537 | $context['choices'][] = array( |
512 | 538 | 'id' => $choice_id++, |
@@ -568,13 +594,14 @@ discard block |
||
568 | 594 | $context['preview_subject'] = $form_subject; |
569 | 595 | |
570 | 596 | censorText($context['preview_subject']); |
597 | + } else { |
|
598 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
571 | 599 | } |
572 | - else |
|
573 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
574 | 600 | |
575 | 601 | // Protect any CDATA blocks. |
576 | - if (isset($_REQUEST['xml'])) |
|
577 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
602 | + if (isset($_REQUEST['xml'])) { |
|
603 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
617 | - fatal_lang_error('no_board', false); |
|
643 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
644 | + fatal_lang_error('no_board', false); |
|
645 | + } |
|
618 | 646 | $row = $smcFunc['db_fetch_assoc']($request); |
619 | 647 | |
620 | 648 | $attachment_stuff = array($row); |
621 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
622 | - $attachment_stuff[] = $row2; |
|
649 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
650 | + $attachment_stuff[] = $row2; |
|
651 | + } |
|
623 | 652 | $smcFunc['db_free_result']($request); |
624 | 653 | |
625 | 654 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
626 | 655 | { |
627 | 656 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
628 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
629 | - fatal_lang_error('modify_post_time_passed', false); |
|
630 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
631 | - isAllowedTo('modify_replies'); |
|
632 | - else |
|
633 | - isAllowedTo('modify_own'); |
|
657 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
658 | + fatal_lang_error('modify_post_time_passed', false); |
|
659 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
660 | + isAllowedTo('modify_replies'); |
|
661 | + } else { |
|
662 | + isAllowedTo('modify_own'); |
|
663 | + } |
|
664 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
665 | + isAllowedTo('modify_replies'); |
|
666 | + } else { |
|
667 | + isAllowedTo('modify_any'); |
|
634 | 668 | } |
635 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
636 | - isAllowedTo('modify_replies'); |
|
637 | - else |
|
638 | - isAllowedTo('modify_any'); |
|
639 | 669 | |
640 | 670 | if ($context['can_announce'] && !empty($row['id_action'])) |
641 | 671 | { |
@@ -659,8 +689,9 @@ discard block |
||
659 | 689 | |
660 | 690 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
661 | 691 | { |
662 | - if ($row['filesize'] <= 0) |
|
663 | - continue; |
|
692 | + if ($row['filesize'] <= 0) { |
|
693 | + continue; |
|
694 | + } |
|
664 | 695 | $context['current_attachments'][$row['id_attach']] = array( |
665 | 696 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
666 | 697 | 'size' => $row['filesize'], |
@@ -730,29 +761,32 @@ discard block |
||
730 | 761 | ) |
731 | 762 | ); |
732 | 763 | // The message they were trying to edit was most likely deleted. |
733 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
734 | - fatal_lang_error('no_message', false); |
|
764 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
765 | + fatal_lang_error('no_message', false); |
|
766 | + } |
|
735 | 767 | $row = $smcFunc['db_fetch_assoc']($request); |
736 | 768 | |
737 | 769 | $attachment_stuff = array($row); |
738 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
739 | - $attachment_stuff[] = $row2; |
|
770 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
771 | + $attachment_stuff[] = $row2; |
|
772 | + } |
|
740 | 773 | $smcFunc['db_free_result']($request); |
741 | 774 | |
742 | 775 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
743 | 776 | { |
744 | 777 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
745 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
746 | - fatal_lang_error('modify_post_time_passed', false); |
|
747 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
748 | - isAllowedTo('modify_replies'); |
|
749 | - else |
|
750 | - isAllowedTo('modify_own'); |
|
778 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
779 | + fatal_lang_error('modify_post_time_passed', false); |
|
780 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
781 | + isAllowedTo('modify_replies'); |
|
782 | + } else { |
|
783 | + isAllowedTo('modify_own'); |
|
784 | + } |
|
785 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
786 | + isAllowedTo('modify_replies'); |
|
787 | + } else { |
|
788 | + isAllowedTo('modify_any'); |
|
751 | 789 | } |
752 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
753 | - isAllowedTo('modify_replies'); |
|
754 | - else |
|
755 | - isAllowedTo('modify_any'); |
|
756 | 790 | |
757 | 791 | if ($context['can_announce'] && !empty($row['id_action'])) |
758 | 792 | { |
@@ -779,15 +813,17 @@ discard block |
||
779 | 813 | $context['icon'] = $row['icon']; |
780 | 814 | |
781 | 815 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
782 | - if (!$row['approved'] && !$context['show_approval']) |
|
783 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
816 | + if (!$row['approved'] && !$context['show_approval']) { |
|
817 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
818 | + } |
|
784 | 819 | |
785 | 820 | // Sort the attachments so they are in the order saved |
786 | 821 | $temp = array(); |
787 | 822 | foreach ($attachment_stuff as $attachment) |
788 | 823 | { |
789 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
790 | - $temp[$attachment['id_attach']] = $attachment; |
|
824 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
825 | + $temp[$attachment['id_attach']] = $attachment; |
|
826 | + } |
|
791 | 827 | |
792 | 828 | } |
793 | 829 | ksort($temp); |
@@ -849,14 +885,16 @@ discard block |
||
849 | 885 | 'is_approved' => 1, |
850 | 886 | ) |
851 | 887 | ); |
852 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
853 | - fatal_lang_error('quoted_post_deleted', false); |
|
888 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
889 | + fatal_lang_error('quoted_post_deleted', false); |
|
890 | + } |
|
854 | 891 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
855 | 892 | $smcFunc['db_free_result']($request); |
856 | 893 | |
857 | 894 | // Add 'Re: ' to the front of the quoted subject. |
858 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
859 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
895 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
896 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
897 | + } |
|
860 | 898 | |
861 | 899 | // Censor the message and subject. |
862 | 900 | censorText($form_message); |
@@ -869,10 +907,11 @@ discard block |
||
869 | 907 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
870 | 908 | { |
871 | 909 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
872 | - if ($i % 4 == 0) |
|
873 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
910 | + if ($i % 4 == 0) { |
|
911 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
874 | 912 | { |
875 | 913 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
914 | + } |
|
876 | 915 | }, $parts[$i]); |
877 | 916 | } |
878 | 917 | $form_message = implode('', $parts); |
@@ -881,8 +920,9 @@ discard block |
||
881 | 920 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
882 | 921 | |
883 | 922 | // Remove any nested quotes, if necessary. |
884 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
885 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
923 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
924 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
925 | + } |
|
886 | 926 | |
887 | 927 | // Add a quote string on the front and end. |
888 | 928 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -894,15 +934,15 @@ discard block |
||
894 | 934 | $form_subject = $first_subject; |
895 | 935 | |
896 | 936 | // Add 'Re: ' to the front of the subject. |
897 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
898 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
937 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
938 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
939 | + } |
|
899 | 940 | |
900 | 941 | // Censor the subject. |
901 | 942 | censorText($form_subject); |
902 | 943 | |
903 | 944 | $form_message = ''; |
904 | - } |
|
905 | - else |
|
945 | + } else |
|
906 | 946 | { |
907 | 947 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
908 | 948 | $form_message = ''; |
@@ -921,13 +961,15 @@ discard block |
||
921 | 961 | if (isset($_REQUEST['msg'])) |
922 | 962 | { |
923 | 963 | $context['attachments']['quantity'] = count($context['current_attachments']); |
924 | - foreach ($context['current_attachments'] as $attachment) |
|
925 | - $context['attachments']['total_size'] += $attachment['size']; |
|
964 | + foreach ($context['current_attachments'] as $attachment) { |
|
965 | + $context['attachments']['total_size'] += $attachment['size']; |
|
966 | + } |
|
926 | 967 | } |
927 | 968 | |
928 | 969 | // A bit of house keeping first. |
929 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
930 | - unset($_SESSION['temp_attachments']); |
|
970 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
971 | + unset($_SESSION['temp_attachments']); |
|
972 | + } |
|
931 | 973 | |
932 | 974 | if (!empty($_SESSION['temp_attachments'])) |
933 | 975 | { |
@@ -936,9 +978,10 @@ discard block |
||
936 | 978 | { |
937 | 979 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
938 | 980 | { |
939 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
940 | - if (file_exists($attachment['tmp_name'])) |
|
981 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
982 | + if (file_exists($attachment['tmp_name'])) |
|
941 | 983 | unlink($attachment['tmp_name']); |
984 | + } |
|
942 | 985 | } |
943 | 986 | $post_errors[] = 'temp_attachments_gone'; |
944 | 987 | $_SESSION['temp_attachments'] = array(); |
@@ -952,8 +995,9 @@ discard block |
||
952 | 995 | // See if any files still exist before showing the warning message and the files attached. |
953 | 996 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
954 | 997 | { |
955 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
956 | - continue; |
|
998 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
999 | + continue; |
|
1000 | + } |
|
957 | 1001 | |
958 | 1002 | if (file_exists($attachment['tmp_name'])) |
959 | 1003 | { |
@@ -963,20 +1007,21 @@ discard block |
||
963 | 1007 | break; |
964 | 1008 | } |
965 | 1009 | } |
966 | - } |
|
967 | - else |
|
1010 | + } else |
|
968 | 1011 | { |
969 | 1012 | // Since, they don't belong here. Let's inform the user that they exist.. |
970 | - if (!empty($topic)) |
|
971 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
972 | - else |
|
973 | - $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
1013 | + if (!empty($topic)) { |
|
1014 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
1015 | + } else { |
|
1016 | + $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
1017 | + } |
|
974 | 1018 | |
975 | 1019 | // Compile a list of the files to show the user. |
976 | 1020 | $file_list = array(); |
977 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
978 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
1021 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
1022 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
979 | 1023 | $file_list[] = $attachment['name']; |
1024 | + } |
|
980 | 1025 | |
981 | 1026 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
982 | 1027 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -988,8 +1033,7 @@ discard block |
||
988 | 1033 | |
989 | 1034 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
990 | 1035 | $context['ignore_temp_attachments'] = true; |
991 | - } |
|
992 | - else |
|
1036 | + } else |
|
993 | 1037 | { |
994 | 1038 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
995 | 1039 | $context['ignore_temp_attachments'] = true; |
@@ -997,16 +1041,19 @@ discard block |
||
997 | 1041 | } |
998 | 1042 | } |
999 | 1043 | |
1000 | - if (!empty($context['we_are_history'])) |
|
1001 | - $post_errors[] = $context['we_are_history']; |
|
1044 | + if (!empty($context['we_are_history'])) { |
|
1045 | + $post_errors[] = $context['we_are_history']; |
|
1046 | + } |
|
1002 | 1047 | |
1003 | 1048 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1004 | 1049 | { |
1005 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
1006 | - break; |
|
1050 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
1051 | + break; |
|
1052 | + } |
|
1007 | 1053 | |
1008 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1009 | - continue; |
|
1054 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
1055 | + continue; |
|
1056 | + } |
|
1010 | 1057 | |
1011 | 1058 | if ($attachID == 'initial_error') |
1012 | 1059 | { |
@@ -1021,15 +1068,17 @@ discard block |
||
1021 | 1068 | { |
1022 | 1069 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
1023 | 1070 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
1024 | - foreach ($attachment['errors'] as $error) |
|
1025 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1071 | + foreach ($attachment['errors'] as $error) { |
|
1072 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1073 | + } |
|
1026 | 1074 | $txt['error_attach_errors'] .= '</div>'; |
1027 | 1075 | $post_errors[] = 'attach_errors'; |
1028 | 1076 | |
1029 | 1077 | // Take out the trash. |
1030 | 1078 | unset($_SESSION['temp_attachments'][$attachID]); |
1031 | - if (file_exists($attachment['tmp_name'])) |
|
1032 | - unlink($attachment['tmp_name']); |
|
1079 | + if (file_exists($attachment['tmp_name'])) { |
|
1080 | + unlink($attachment['tmp_name']); |
|
1081 | + } |
|
1033 | 1082 | continue; |
1034 | 1083 | } |
1035 | 1084 | |
@@ -1042,8 +1091,9 @@ discard block |
||
1042 | 1091 | |
1043 | 1092 | $context['attachments']['quantity']++; |
1044 | 1093 | $context['attachments']['total_size'] += $attachment['size']; |
1045 | - if (!isset($context['files_in_session_warning'])) |
|
1046 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1094 | + if (!isset($context['files_in_session_warning'])) { |
|
1095 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1096 | + } |
|
1047 | 1097 | |
1048 | 1098 | $context['current_attachments'][$attachID] = array( |
1049 | 1099 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1071,8 +1121,9 @@ discard block |
||
1071 | 1121 | } |
1072 | 1122 | |
1073 | 1123 | // If they came from quick reply, and have to enter verification details, give them some notice. |
1074 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
1075 | - $post_errors[] = 'need_qr_verification'; |
|
1124 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
1125 | + $post_errors[] = 'need_qr_verification'; |
|
1126 | + } |
|
1076 | 1127 | |
1077 | 1128 | /* |
1078 | 1129 | * There are two error types: serious and minor. Serious errors |
@@ -1089,52 +1140,56 @@ discard block |
||
1089 | 1140 | { |
1090 | 1141 | loadLanguage('Errors'); |
1091 | 1142 | $context['error_type'] = 'minor'; |
1092 | - foreach ($post_errors as $post_error) |
|
1093 | - if (is_array($post_error)) |
|
1143 | + foreach ($post_errors as $post_error) { |
|
1144 | + if (is_array($post_error)) |
|
1094 | 1145 | { |
1095 | 1146 | $post_error_id = $post_error[0]; |
1147 | + } |
|
1096 | 1148 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
1097 | 1149 | |
1098 | 1150 | // If it's not a minor error flag it as such. |
1099 | - if (!in_array($post_error_id, $minor_errors)) |
|
1100 | - $context['error_type'] = 'serious'; |
|
1101 | - } |
|
1102 | - else |
|
1151 | + if (!in_array($post_error_id, $minor_errors)) { |
|
1152 | + $context['error_type'] = 'serious'; |
|
1153 | + } |
|
1154 | + } else |
|
1103 | 1155 | { |
1104 | 1156 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
1105 | 1157 | |
1106 | 1158 | // If it's not a minor error flag it as such. |
1107 | - if (!in_array($post_error, $minor_errors)) |
|
1108 | - $context['error_type'] = 'serious'; |
|
1159 | + if (!in_array($post_error, $minor_errors)) { |
|
1160 | + $context['error_type'] = 'serious'; |
|
1161 | + } |
|
1109 | 1162 | } |
1110 | 1163 | } |
1111 | 1164 | |
1112 | 1165 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
1113 | - if (isset($_REQUEST['poll'])) |
|
1114 | - $context['page_title'] = $txt['new_poll']; |
|
1115 | - elseif ($context['make_event']) |
|
1116 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1117 | - elseif (isset($_REQUEST['msg'])) |
|
1118 | - $context['page_title'] = $txt['modify_msg']; |
|
1119 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
1120 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1121 | - elseif (empty($topic)) |
|
1122 | - $context['page_title'] = $txt['start_new_topic']; |
|
1123 | - else |
|
1124 | - $context['page_title'] = $txt['post_reply']; |
|
1166 | + if (isset($_REQUEST['poll'])) { |
|
1167 | + $context['page_title'] = $txt['new_poll']; |
|
1168 | + } elseif ($context['make_event']) { |
|
1169 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1170 | + } elseif (isset($_REQUEST['msg'])) { |
|
1171 | + $context['page_title'] = $txt['modify_msg']; |
|
1172 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
1173 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1174 | + } elseif (empty($topic)) { |
|
1175 | + $context['page_title'] = $txt['start_new_topic']; |
|
1176 | + } else { |
|
1177 | + $context['page_title'] = $txt['post_reply']; |
|
1178 | + } |
|
1125 | 1179 | |
1126 | 1180 | // Build the link tree. |
1127 | - if (empty($topic)) |
|
1128 | - $context['linktree'][] = array( |
|
1181 | + if (empty($topic)) { |
|
1182 | + $context['linktree'][] = array( |
|
1129 | 1183 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
1130 | 1184 | ); |
1131 | - else |
|
1132 | - $context['linktree'][] = array( |
|
1185 | + } else { |
|
1186 | + $context['linktree'][] = array( |
|
1133 | 1187 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
1134 | 1188 | 'name' => $form_subject, |
1135 | 1189 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
1136 | 1190 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
1137 | 1191 | ); |
1192 | + } |
|
1138 | 1193 | |
1139 | 1194 | $context['subject'] = addcslashes($form_subject, '"'); |
1140 | 1195 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1178,8 +1233,9 @@ discard block |
||
1178 | 1233 | // Message icons - customized icons are off? |
1179 | 1234 | $context['icons'] = getMessageIcons(!empty($board) ? $board : 0); |
1180 | 1235 | |
1181 | - if (!empty($context['icons'])) |
|
1182 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1236 | + if (!empty($context['icons'])) { |
|
1237 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1238 | + } |
|
1183 | 1239 | |
1184 | 1240 | // Are we starting a poll? if set the poll icon as selected if its available |
1185 | 1241 | if (isset($_REQUEST['poll'])) |
@@ -1199,8 +1255,9 @@ discard block |
||
1199 | 1255 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
1200 | 1256 | { |
1201 | 1257 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
1202 | - if ($context['icons'][$i]['selected']) |
|
1203 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
1258 | + if ($context['icons'][$i]['selected']) { |
|
1259 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
1260 | + } |
|
1204 | 1261 | } |
1205 | 1262 | if (empty($context['icon_url'])) |
1206 | 1263 | { |
@@ -1214,8 +1271,9 @@ discard block |
||
1214 | 1271 | )); |
1215 | 1272 | } |
1216 | 1273 | |
1217 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
1218 | - getTopic(); |
|
1274 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
1275 | + getTopic(); |
|
1276 | + } |
|
1219 | 1277 | |
1220 | 1278 | // If the user can post attachments prepare the warning labels. |
1221 | 1279 | if ($context['can_post_attachment']) |
@@ -1226,12 +1284,13 @@ discard block |
||
1226 | 1284 | $context['attachment_restrictions'] = array(); |
1227 | 1285 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
1228 | 1286 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
1229 | - foreach ($attachmentRestrictionTypes as $type) |
|
1230 | - if (!empty($modSettings[$type])) |
|
1287 | + foreach ($attachmentRestrictionTypes as $type) { |
|
1288 | + if (!empty($modSettings[$type])) |
|
1231 | 1289 | { |
1232 | 1290 | // Show the max number of attachments if not 0. |
1233 | 1291 | if ($type == 'attachmentNumPerPostLimit') |
1234 | 1292 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
1293 | + } |
|
1235 | 1294 | } |
1236 | 1295 | } |
1237 | 1296 | |
@@ -1265,8 +1324,8 @@ discard block |
||
1265 | 1324 | |
1266 | 1325 | if (!empty($context['current_attachments'])) |
1267 | 1326 | { |
1268 | - foreach ($context['current_attachments'] as $key => $mock) |
|
1269 | - addInlineJavaScript(' |
|
1327 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
1328 | + addInlineJavaScript(' |
|
1270 | 1329 | current_attachments.push({ |
1271 | 1330 | name: '. JavaScriptEscape($mock['name']) . ', |
1272 | 1331 | size: '. $mock['size'] . ', |
@@ -1275,6 +1334,7 @@ discard block |
||
1275 | 1334 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
1276 | 1335 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
1277 | 1336 | });', true); |
1337 | + } |
|
1278 | 1338 | } |
1279 | 1339 | |
1280 | 1340 | // File Upload. |
@@ -1349,9 +1409,10 @@ discard block |
||
1349 | 1409 | $context['posting_fields']['board']['dd'] .= ' |
1350 | 1410 | <optgroup label="' . $category['name'] . '">'; |
1351 | 1411 | |
1352 | - foreach ($category['boards'] as $brd) |
|
1353 | - $context['posting_fields']['board']['dd'] .= ' |
|
1412 | + foreach ($category['boards'] as $brd) { |
|
1413 | + $context['posting_fields']['board']['dd'] .= ' |
|
1354 | 1414 | <option value="' . $brd['id'] . '"' . ($brd['selected'] ? ' selected' : '') . '>' . ($brd['child_level'] > 0 ? str_repeat('==', $brd['child_level'] - 1) . '=>' : '') . ' ' . $brd['name'] . '</option>'; |
1415 | + } |
|
1355 | 1416 | |
1356 | 1417 | $context['posting_fields']['board']['dd'] .= ' |
1357 | 1418 | </optgroup>'; |
@@ -1382,8 +1443,9 @@ discard block |
||
1382 | 1443 | |
1383 | 1444 | |
1384 | 1445 | // Finally, load the template. |
1385 | - if (!isset($_REQUEST['xml'])) |
|
1386 | - loadTemplate('Post'); |
|
1446 | + if (!isset($_REQUEST['xml'])) { |
|
1447 | + loadTemplate('Post'); |
|
1448 | + } |
|
1387 | 1449 | |
1388 | 1450 | call_integration_hook('integrate_post_end'); |
1389 | 1451 | } |
@@ -1404,13 +1466,14 @@ discard block |
||
1404 | 1466 | // Sneaking off, are we? |
1405 | 1467 | if (empty($_POST) && empty($topic)) |
1406 | 1468 | { |
1407 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
1408 | - redirectexit('action=post;board=' . $board . '.0'); |
|
1409 | - else |
|
1410 | - fatal_lang_error('post_upload_error', false); |
|
1469 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
1470 | + redirectexit('action=post;board=' . $board . '.0'); |
|
1471 | + } else { |
|
1472 | + fatal_lang_error('post_upload_error', false); |
|
1473 | + } |
|
1474 | + } elseif (empty($_POST) && !empty($topic)) { |
|
1475 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
1411 | 1476 | } |
1412 | - elseif (empty($_POST) && !empty($topic)) |
|
1413 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
1414 | 1477 | |
1415 | 1478 | // No need! |
1416 | 1479 | $context['robot_no_index'] = true; |
@@ -1422,8 +1485,9 @@ discard block |
||
1422 | 1485 | $post_errors = array(); |
1423 | 1486 | |
1424 | 1487 | // If the session has timed out, let the user re-submit their form. |
1425 | - if (checkSession('post', '', false) != '') |
|
1426 | - $post_errors[] = 'session_timeout'; |
|
1488 | + if (checkSession('post', '', false) != '') { |
|
1489 | + $post_errors[] = 'session_timeout'; |
|
1490 | + } |
|
1427 | 1491 | |
1428 | 1492 | // Wrong verification code? |
1429 | 1493 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1433,33 +1497,38 @@ discard block |
||
1433 | 1497 | 'id' => 'post', |
1434 | 1498 | ); |
1435 | 1499 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
1436 | - if (is_array($context['require_verification'])) |
|
1437 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1500 | + if (is_array($context['require_verification'])) { |
|
1501 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1502 | + } |
|
1438 | 1503 | } |
1439 | 1504 | |
1440 | 1505 | require_once($sourcedir . '/Subs-Post.php'); |
1441 | 1506 | loadLanguage('Post'); |
1442 | 1507 | |
1443 | 1508 | // Drafts enabled and needed? |
1444 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
1445 | - require_once($sourcedir . '/Drafts.php'); |
|
1509 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
1510 | + require_once($sourcedir . '/Drafts.php'); |
|
1511 | + } |
|
1446 | 1512 | |
1447 | 1513 | // First check to see if they are trying to delete any current attachments. |
1448 | 1514 | if (isset($_POST['attach_del'])) |
1449 | 1515 | { |
1450 | 1516 | $keep_temp = array(); |
1451 | 1517 | $keep_ids = array(); |
1452 | - foreach ($_POST['attach_del'] as $dummy) |
|
1453 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1518 | + foreach ($_POST['attach_del'] as $dummy) { |
|
1519 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1454 | 1520 | $keep_temp[] = $dummy; |
1455 | - else |
|
1456 | - $keep_ids[] = (int) $dummy; |
|
1521 | + } |
|
1522 | + else { |
|
1523 | + $keep_ids[] = (int) $dummy; |
|
1524 | + } |
|
1457 | 1525 | |
1458 | - if (isset($_SESSION['temp_attachments'])) |
|
1459 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1526 | + if (isset($_SESSION['temp_attachments'])) { |
|
1527 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1460 | 1528 | { |
1461 | 1529 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
1462 | 1530 | continue; |
1531 | + } |
|
1463 | 1532 | |
1464 | 1533 | unset($_SESSION['temp_attachments'][$attachID]); |
1465 | 1534 | unlink($attachment['tmp_name']); |
@@ -1491,8 +1560,9 @@ discard block |
||
1491 | 1560 | { |
1492 | 1561 | require_once($sourcedir . '/ManageAttachments.php'); |
1493 | 1562 | |
1494 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
1495 | - removeAttachments(array('id_attach' => $attachID)); |
|
1563 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
1564 | + removeAttachments(array('id_attach' => $attachID)); |
|
1565 | + } |
|
1496 | 1566 | |
1497 | 1567 | unset($_SESSION['already_attached']); |
1498 | 1568 | |
@@ -1515,12 +1585,14 @@ discard block |
||
1515 | 1585 | $smcFunc['db_free_result']($request); |
1516 | 1586 | |
1517 | 1587 | // Though the topic should be there, it might have vanished. |
1518 | - if (!is_array($topic_info)) |
|
1519 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
1588 | + if (!is_array($topic_info)) { |
|
1589 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
1590 | + } |
|
1520 | 1591 | |
1521 | 1592 | // Did this topic suddenly move? Just checking... |
1522 | - if ($topic_info['id_board'] != $board) |
|
1523 | - fatal_lang_error('not_a_topic'); |
|
1593 | + if ($topic_info['id_board'] != $board) { |
|
1594 | + fatal_lang_error('not_a_topic'); |
|
1595 | + } |
|
1524 | 1596 | |
1525 | 1597 | // Do the permissions and approval stuff... |
1526 | 1598 | $becomesApproved = true; |
@@ -1543,49 +1615,50 @@ discard block |
||
1543 | 1615 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
1544 | 1616 | { |
1545 | 1617 | // Don't allow a post if it's locked. |
1546 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
1547 | - fatal_lang_error('topic_locked', false); |
|
1618 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
1619 | + fatal_lang_error('topic_locked', false); |
|
1620 | + } |
|
1548 | 1621 | |
1549 | 1622 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
1550 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
1551 | - unset($_REQUEST['poll']); |
|
1552 | - |
|
1553 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1554 | - { |
|
1555 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
1556 | - $becomesApproved = false; |
|
1557 | - |
|
1558 | - else |
|
1559 | - isAllowedTo('post_reply_any'); |
|
1560 | - } |
|
1561 | - elseif (!allowedTo('post_reply_any')) |
|
1623 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
1624 | + unset($_REQUEST['poll']); |
|
1625 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1626 | + { |
|
1627 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
1628 | + $becomesApproved = false; |
|
1629 | + } else { |
|
1630 | + isAllowedTo('post_reply_any'); |
|
1631 | + } |
|
1632 | + } elseif (!allowedTo('post_reply_any')) |
|
1562 | 1633 | { |
1563 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
1564 | - $becomesApproved = false; |
|
1565 | - |
|
1566 | - else |
|
1567 | - isAllowedTo('post_reply_own'); |
|
1634 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
1635 | + $becomesApproved = false; |
|
1636 | + } else { |
|
1637 | + isAllowedTo('post_reply_own'); |
|
1638 | + } |
|
1568 | 1639 | } |
1569 | 1640 | |
1570 | 1641 | if (isset($_POST['lock'])) |
1571 | 1642 | { |
1572 | 1643 | // Nothing is changed to the lock. |
1573 | - if (empty($topic_info['locked']) == empty($_POST['lock'])) |
|
1574 | - unset($_POST['lock']); |
|
1644 | + if (empty($topic_info['locked']) == empty($_POST['lock'])) { |
|
1645 | + unset($_POST['lock']); |
|
1646 | + } |
|
1575 | 1647 | |
1576 | 1648 | // You're have no permission to lock this topic. |
1577 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1578 | - unset($_POST['lock']); |
|
1649 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1650 | + unset($_POST['lock']); |
|
1651 | + } |
|
1579 | 1652 | |
1580 | 1653 | // You are allowed to (un)lock your own topic only. |
1581 | 1654 | elseif (!allowedTo('lock_any')) |
1582 | 1655 | { |
1583 | 1656 | // You cannot override a moderator lock. |
1584 | - if ($topic_info['locked'] == 1) |
|
1585 | - unset($_POST['lock']); |
|
1586 | - |
|
1587 | - else |
|
1588 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1657 | + if ($topic_info['locked'] == 1) { |
|
1658 | + unset($_POST['lock']); |
|
1659 | + } else { |
|
1660 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1661 | + } |
|
1589 | 1662 | } |
1590 | 1663 | // Hail mighty moderator, (un)lock this topic immediately. |
1591 | 1664 | else |
@@ -1593,19 +1666,21 @@ discard block |
||
1593 | 1666 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1594 | 1667 | |
1595 | 1668 | // Did someone (un)lock this while you were posting? |
1596 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1597 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1669 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1670 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1671 | + } |
|
1598 | 1672 | } |
1599 | 1673 | } |
1600 | 1674 | |
1601 | 1675 | // So you wanna (un)sticky this...let's see. |
1602 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
1603 | - unset($_POST['sticky']); |
|
1604 | - elseif (isset($_POST['sticky'])) |
|
1676 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
1677 | + unset($_POST['sticky']); |
|
1678 | + } elseif (isset($_POST['sticky'])) |
|
1605 | 1679 | { |
1606 | 1680 | // Did someone (un)sticky this while you were posting? |
1607 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1608 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1681 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1682 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1683 | + } |
|
1609 | 1684 | } |
1610 | 1685 | |
1611 | 1686 | // If drafts are enabled, then pass this off |
@@ -1632,26 +1707,31 @@ discard block |
||
1632 | 1707 | |
1633 | 1708 | // Do like, the permissions, for safety and stuff... |
1634 | 1709 | $becomesApproved = true; |
1635 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
1636 | - $becomesApproved = false; |
|
1637 | - else |
|
1638 | - isAllowedTo('post_new'); |
|
1710 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
1711 | + $becomesApproved = false; |
|
1712 | + } else { |
|
1713 | + isAllowedTo('post_new'); |
|
1714 | + } |
|
1639 | 1715 | |
1640 | 1716 | if (isset($_POST['lock'])) |
1641 | 1717 | { |
1642 | 1718 | // New topics are by default not locked. |
1643 | - if (empty($_POST['lock'])) |
|
1644 | - unset($_POST['lock']); |
|
1719 | + if (empty($_POST['lock'])) { |
|
1720 | + unset($_POST['lock']); |
|
1721 | + } |
|
1645 | 1722 | // Besides, you need permission. |
1646 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
1647 | - unset($_POST['lock']); |
|
1723 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
1724 | + unset($_POST['lock']); |
|
1725 | + } |
|
1648 | 1726 | // A moderator-lock (1) can override a user-lock (2). |
1649 | - else |
|
1650 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1727 | + else { |
|
1728 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1729 | + } |
|
1651 | 1730 | } |
1652 | 1731 | |
1653 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
1654 | - unset($_POST['sticky']); |
|
1732 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
1733 | + unset($_POST['sticky']); |
|
1734 | + } |
|
1655 | 1735 | |
1656 | 1736 | // Saving your new topic as a draft first? |
1657 | 1737 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1676,31 +1756,37 @@ discard block |
||
1676 | 1756 | 'id_msg' => $_REQUEST['msg'], |
1677 | 1757 | ) |
1678 | 1758 | ); |
1679 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1680 | - fatal_lang_error('cant_find_messages', false); |
|
1759 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1760 | + fatal_lang_error('cant_find_messages', false); |
|
1761 | + } |
|
1681 | 1762 | $row = $smcFunc['db_fetch_assoc']($request); |
1682 | 1763 | $smcFunc['db_free_result']($request); |
1683 | 1764 | |
1684 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
1685 | - fatal_lang_error('topic_locked', false); |
|
1765 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
1766 | + fatal_lang_error('topic_locked', false); |
|
1767 | + } |
|
1686 | 1768 | |
1687 | 1769 | if (isset($_POST['lock'])) |
1688 | 1770 | { |
1689 | 1771 | // Nothing changes to the lock status. |
1690 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1691 | - unset($_POST['lock']); |
|
1772 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1773 | + unset($_POST['lock']); |
|
1774 | + } |
|
1692 | 1775 | // You're simply not allowed to (un)lock this. |
1693 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1694 | - unset($_POST['lock']); |
|
1776 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1777 | + unset($_POST['lock']); |
|
1778 | + } |
|
1695 | 1779 | // You're only allowed to lock your own topics. |
1696 | 1780 | elseif (!allowedTo('lock_any')) |
1697 | 1781 | { |
1698 | 1782 | // You're not allowed to break a moderator's lock. |
1699 | - if ($topic_info['locked'] == 1) |
|
1700 | - unset($_POST['lock']); |
|
1783 | + if ($topic_info['locked'] == 1) { |
|
1784 | + unset($_POST['lock']); |
|
1785 | + } |
|
1701 | 1786 | // Lock it with a soft lock or unlock it. |
1702 | - else |
|
1703 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1787 | + else { |
|
1788 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1789 | + } |
|
1704 | 1790 | } |
1705 | 1791 | // You must be the moderator. |
1706 | 1792 | else |
@@ -1708,44 +1794,46 @@ discard block |
||
1708 | 1794 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1709 | 1795 | |
1710 | 1796 | // Did someone (un)lock this while you were posting? |
1711 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1712 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1797 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1798 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1799 | + } |
|
1713 | 1800 | } |
1714 | 1801 | } |
1715 | 1802 | |
1716 | 1803 | // Change the sticky status of this topic? |
1717 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
1718 | - unset($_POST['sticky']); |
|
1719 | - elseif (isset($_POST['sticky'])) |
|
1804 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
1805 | + unset($_POST['sticky']); |
|
1806 | + } elseif (isset($_POST['sticky'])) |
|
1720 | 1807 | { |
1721 | 1808 | // Did someone (un)sticky this while you were posting? |
1722 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1723 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1809 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1810 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1811 | + } |
|
1724 | 1812 | } |
1725 | 1813 | |
1726 | 1814 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
1727 | 1815 | { |
1728 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
1729 | - fatal_lang_error('modify_post_time_passed', false); |
|
1730 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
1731 | - isAllowedTo('modify_replies'); |
|
1732 | - else |
|
1733 | - isAllowedTo('modify_own'); |
|
1734 | - } |
|
1735 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1816 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
1817 | + fatal_lang_error('modify_post_time_passed', false); |
|
1818 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
1819 | + isAllowedTo('modify_replies'); |
|
1820 | + } else { |
|
1821 | + isAllowedTo('modify_own'); |
|
1822 | + } |
|
1823 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1736 | 1824 | { |
1737 | 1825 | isAllowedTo('modify_replies'); |
1738 | 1826 | |
1739 | 1827 | // If you're modifying a reply, I say it better be logged... |
1740 | 1828 | $moderationAction = true; |
1741 | - } |
|
1742 | - else |
|
1829 | + } else |
|
1743 | 1830 | { |
1744 | 1831 | isAllowedTo('modify_any'); |
1745 | 1832 | |
1746 | 1833 | // Log it, assuming you're not modifying your own post. |
1747 | - if ($row['id_member'] != $user_info['id']) |
|
1748 | - $moderationAction = true; |
|
1834 | + if ($row['id_member'] != $user_info['id']) { |
|
1835 | + $moderationAction = true; |
|
1836 | + } |
|
1749 | 1837 | } |
1750 | 1838 | |
1751 | 1839 | // If drafts are enabled, then lets send this off to save |
@@ -1784,20 +1872,24 @@ discard block |
||
1784 | 1872 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
1785 | 1873 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
1786 | 1874 | |
1787 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
1788 | - $post_errors[] = 'no_name'; |
|
1789 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
1790 | - $post_errors[] = 'long_name'; |
|
1875 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
1876 | + $post_errors[] = 'no_name'; |
|
1877 | + } |
|
1878 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
1879 | + $post_errors[] = 'long_name'; |
|
1880 | + } |
|
1791 | 1881 | |
1792 | 1882 | if (empty($modSettings['guest_post_no_email'])) |
1793 | 1883 | { |
1794 | 1884 | // Only check if they changed it! |
1795 | 1885 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
1796 | 1886 | { |
1797 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
1798 | - $post_errors[] = 'no_email'; |
|
1799 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
1800 | - $post_errors[] = 'bad_email'; |
|
1887 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
1888 | + $post_errors[] = 'no_email'; |
|
1889 | + } |
|
1890 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
1891 | + $post_errors[] = 'bad_email'; |
|
1892 | + } |
|
1801 | 1893 | } |
1802 | 1894 | |
1803 | 1895 | // Now make sure this email address is not banned from posting. |
@@ -1813,81 +1905,95 @@ discard block |
||
1813 | 1905 | } |
1814 | 1906 | |
1815 | 1907 | // Coming from the quickReply? |
1816 | - if (isset($_POST['quickReply'])) |
|
1817 | - $_POST['message'] = $_POST['quickReply']; |
|
1908 | + if (isset($_POST['quickReply'])) { |
|
1909 | + $_POST['message'] = $_POST['quickReply']; |
|
1910 | + } |
|
1818 | 1911 | |
1819 | 1912 | // Check the subject and message. |
1820 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
1821 | - $post_errors[] = 'no_subject'; |
|
1822 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
1823 | - $post_errors[] = 'no_message'; |
|
1824 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
1825 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1826 | - else |
|
1913 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
1914 | + $post_errors[] = 'no_subject'; |
|
1915 | + } |
|
1916 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
1917 | + $post_errors[] = 'no_message'; |
|
1918 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
1919 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1920 | + } else |
|
1827 | 1921 | { |
1828 | 1922 | // Prepare the message a bit for some additional testing. |
1829 | 1923 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
1830 | 1924 | |
1831 | 1925 | // Preparse code. (Zef) |
1832 | - if ($user_info['is_guest']) |
|
1833 | - $user_info['name'] = $_POST['guestname']; |
|
1926 | + if ($user_info['is_guest']) { |
|
1927 | + $user_info['name'] = $_POST['guestname']; |
|
1928 | + } |
|
1834 | 1929 | preparsecode($_POST['message']); |
1835 | 1930 | |
1836 | 1931 | // Youtube BBC would be stripped out in the next check without this |
1837 | 1932 | $context['allowed_html_tags'][] = '<iframe>'; |
1838 | 1933 | |
1839 | 1934 | // Let's see if there's still some content left without the tags. |
1840 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
1841 | - $post_errors[] = 'no_message'; |
|
1935 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
1936 | + $post_errors[] = 'no_message'; |
|
1937 | + } |
|
1842 | 1938 | |
1843 | 1939 | // Remove iframe from the list |
1844 | 1940 | array_pop($context['allowed_html_tags']); |
1845 | 1941 | } |
1846 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
1847 | - $post_errors[] = 'no_event'; |
|
1942 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1943 | + $post_errors[] = 'no_event'; |
|
1944 | + } |
|
1848 | 1945 | // You are not! |
1849 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
1850 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1946 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
1947 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1948 | + } |
|
1851 | 1949 | |
1852 | 1950 | // Validate the poll... |
1853 | 1951 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
1854 | 1952 | { |
1855 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
1856 | - fatal_lang_error('no_access', false); |
|
1953 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
1954 | + fatal_lang_error('no_access', false); |
|
1955 | + } |
|
1857 | 1956 | |
1858 | 1957 | // This is a new topic... so it's a new poll. |
1859 | - if (empty($topic)) |
|
1860 | - isAllowedTo('poll_post'); |
|
1958 | + if (empty($topic)) { |
|
1959 | + isAllowedTo('poll_post'); |
|
1960 | + } |
|
1861 | 1961 | // Can you add to your own topics? |
1862 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
1863 | - isAllowedTo('poll_add_own'); |
|
1962 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
1963 | + isAllowedTo('poll_add_own'); |
|
1964 | + } |
|
1864 | 1965 | // Can you add polls to any topic, then? |
1865 | - else |
|
1866 | - isAllowedTo('poll_add_any'); |
|
1966 | + else { |
|
1967 | + isAllowedTo('poll_add_any'); |
|
1968 | + } |
|
1867 | 1969 | |
1868 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
1869 | - $post_errors[] = 'no_question'; |
|
1970 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
1971 | + $post_errors[] = 'no_question'; |
|
1972 | + } |
|
1870 | 1973 | |
1871 | 1974 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
1872 | 1975 | |
1873 | 1976 | // Get rid of empty ones. |
1874 | - foreach ($_POST['options'] as $k => $option) |
|
1875 | - if ($option == '') |
|
1977 | + foreach ($_POST['options'] as $k => $option) { |
|
1978 | + if ($option == '') |
|
1876 | 1979 | unset($_POST['options'][$k], $_POST['options'][$k]); |
1980 | + } |
|
1877 | 1981 | |
1878 | 1982 | // What are you going to vote between with one choice?!? |
1879 | - if (count($_POST['options']) < 2) |
|
1880 | - $post_errors[] = 'poll_few'; |
|
1881 | - elseif (count($_POST['options']) > 256) |
|
1882 | - $post_errors[] = 'poll_many'; |
|
1983 | + if (count($_POST['options']) < 2) { |
|
1984 | + $post_errors[] = 'poll_few'; |
|
1985 | + } elseif (count($_POST['options']) > 256) { |
|
1986 | + $post_errors[] = 'poll_many'; |
|
1987 | + } |
|
1883 | 1988 | } |
1884 | 1989 | |
1885 | 1990 | if ($posterIsGuest) |
1886 | 1991 | { |
1887 | 1992 | // If user is a guest, make sure the chosen name isn't taken. |
1888 | 1993 | require_once($sourcedir . '/Subs-Members.php'); |
1889 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
1890 | - $post_errors[] = 'bad_name'; |
|
1994 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
1995 | + $post_errors[] = 'bad_name'; |
|
1996 | + } |
|
1891 | 1997 | } |
1892 | 1998 | // If the user isn't a guest, get his or her name and email. |
1893 | 1999 | elseif (!isset($_REQUEST['msg'])) |
@@ -1918,8 +2024,9 @@ discard block |
||
1918 | 2024 | } |
1919 | 2025 | |
1920 | 2026 | // Make sure the user isn't spamming the board. |
1921 | - if (!isset($_REQUEST['msg'])) |
|
1922 | - spamProtection('post'); |
|
2027 | + if (!isset($_REQUEST['msg'])) { |
|
2028 | + spamProtection('post'); |
|
2029 | + } |
|
1923 | 2030 | |
1924 | 2031 | // At about this point, we're posting and that's that. |
1925 | 2032 | ignore_user_abort(true); |
@@ -1932,32 +2039,36 @@ discard block |
||
1932 | 2039 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
1933 | 2040 | |
1934 | 2041 | // At this point, we want to make sure the subject isn't too long. |
1935 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
1936 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2042 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2043 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2044 | + } |
|
1937 | 2045 | |
1938 | 2046 | // Same with the "why did you edit this" text. |
1939 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
1940 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2047 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
2048 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2049 | + } |
|
1941 | 2050 | |
1942 | 2051 | // Make the poll... |
1943 | 2052 | if (isset($_REQUEST['poll'])) |
1944 | 2053 | { |
1945 | 2054 | // Make sure that the user has not entered a ridiculous number of options.. |
1946 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
1947 | - $_POST['poll_max_votes'] = 1; |
|
1948 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
1949 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
1950 | - else |
|
1951 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
2055 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
2056 | + $_POST['poll_max_votes'] = 1; |
|
2057 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
2058 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
2059 | + } else { |
|
2060 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
2061 | + } |
|
1952 | 2062 | |
1953 | 2063 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
1954 | 2064 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
1955 | 2065 | |
1956 | 2066 | // Just set it to zero if it's not there.. |
1957 | - if (!isset($_POST['poll_hide'])) |
|
1958 | - $_POST['poll_hide'] = 0; |
|
1959 | - else |
|
1960 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
2067 | + if (!isset($_POST['poll_hide'])) { |
|
2068 | + $_POST['poll_hide'] = 0; |
|
2069 | + } else { |
|
2070 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
2071 | + } |
|
1961 | 2072 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
1962 | 2073 | |
1963 | 2074 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1966,16 +2077,19 @@ discard block |
||
1966 | 2077 | { |
1967 | 2078 | require_once($sourcedir . '/Subs-Members.php'); |
1968 | 2079 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
1969 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
1970 | - $_POST['poll_guest_vote'] = 0; |
|
2080 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
2081 | + $_POST['poll_guest_vote'] = 0; |
|
2082 | + } |
|
1971 | 2083 | } |
1972 | 2084 | |
1973 | 2085 | // If the user tries to set the poll too far in advance, don't let them. |
1974 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
1975 | - fatal_lang_error('poll_range_error', false); |
|
2086 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
2087 | + fatal_lang_error('poll_range_error', false); |
|
2088 | + } |
|
1976 | 2089 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
1977 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
1978 | - $_POST['poll_hide'] = 1; |
|
2090 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
2091 | + $_POST['poll_hide'] = 1; |
|
2092 | + } |
|
1979 | 2093 | |
1980 | 2094 | // Clean up the question and answers. |
1981 | 2095 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1989,13 +2103,15 @@ discard block |
||
1989 | 2103 | { |
1990 | 2104 | $attachIDs = array(); |
1991 | 2105 | $attach_errors = array(); |
1992 | - if (!empty($context['we_are_history'])) |
|
1993 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2106 | + if (!empty($context['we_are_history'])) { |
|
2107 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2108 | + } |
|
1994 | 2109 | |
1995 | 2110 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1996 | 2111 | { |
1997 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1998 | - continue; |
|
2112 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
2113 | + continue; |
|
2114 | + } |
|
1999 | 2115 | |
2000 | 2116 | // If there was an initial error just show that message. |
2001 | 2117 | if ($attachID == 'initial_error') |
@@ -2024,12 +2140,13 @@ discard block |
||
2024 | 2140 | if (createAttachment($attachmentOptions)) |
2025 | 2141 | { |
2026 | 2142 | $attachIDs[] = $attachmentOptions['id']; |
2027 | - if (!empty($attachmentOptions['thumb'])) |
|
2028 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
2143 | + if (!empty($attachmentOptions['thumb'])) { |
|
2144 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
2145 | + } |
|
2029 | 2146 | } |
2147 | + } else { |
|
2148 | + $attach_errors[] = '<dt> </dt>'; |
|
2030 | 2149 | } |
2031 | - else |
|
2032 | - $attach_errors[] = '<dt> </dt>'; |
|
2033 | 2150 | |
2034 | 2151 | if (!empty($attachmentOptions['errors'])) |
2035 | 2152 | { |
@@ -2041,14 +2158,16 @@ discard block |
||
2041 | 2158 | if (!is_array($error)) |
2042 | 2159 | { |
2043 | 2160 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
2044 | - if (in_array($error, $log_these)) |
|
2045 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2161 | + if (in_array($error, $log_these)) { |
|
2162 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2163 | + } |
|
2164 | + } else { |
|
2165 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
2046 | 2166 | } |
2047 | - else |
|
2048 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
2049 | 2167 | } |
2050 | - if (file_exists($attachment['tmp_name'])) |
|
2051 | - unlink($attachment['tmp_name']); |
|
2168 | + if (file_exists($attachment['tmp_name'])) { |
|
2169 | + unlink($attachment['tmp_name']); |
|
2170 | + } |
|
2052 | 2171 | } |
2053 | 2172 | } |
2054 | 2173 | unset($_SESSION['temp_attachments']); |
@@ -2089,24 +2208,24 @@ discard block |
||
2089 | 2208 | ); |
2090 | 2209 | |
2091 | 2210 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
2211 | + } else { |
|
2212 | + $id_poll = 0; |
|
2092 | 2213 | } |
2093 | - else |
|
2094 | - $id_poll = 0; |
|
2095 | 2214 | |
2096 | 2215 | // Creating a new topic? |
2097 | 2216 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
2098 | 2217 | |
2099 | 2218 | // Check the icon. |
2100 | - if (!isset($_POST['icon'])) |
|
2101 | - $_POST['icon'] = 'xx'; |
|
2102 | - |
|
2103 | - else |
|
2219 | + if (!isset($_POST['icon'])) { |
|
2220 | + $_POST['icon'] = 'xx'; |
|
2221 | + } else |
|
2104 | 2222 | { |
2105 | 2223 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
2106 | 2224 | |
2107 | 2225 | // Need to figure it out if this is a valid icon name. |
2108 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
2109 | - $_POST['icon'] = 'xx'; |
|
2226 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
2227 | + $_POST['icon'] = 'xx'; |
|
2228 | + } |
|
2110 | 2229 | } |
2111 | 2230 | |
2112 | 2231 | // Collect all parameters for the creation or modification of a post. |
@@ -2147,8 +2266,9 @@ discard block |
||
2147 | 2266 | } |
2148 | 2267 | |
2149 | 2268 | // This will save some time... |
2150 | - if (empty($approve_has_changed)) |
|
2151 | - unset($msgOptions['approved']); |
|
2269 | + if (empty($approve_has_changed)) { |
|
2270 | + unset($msgOptions['approved']); |
|
2271 | + } |
|
2152 | 2272 | |
2153 | 2273 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2154 | 2274 | } |
@@ -2157,8 +2277,9 @@ discard block |
||
2157 | 2277 | { |
2158 | 2278 | createPost($msgOptions, $topicOptions, $posterOptions); |
2159 | 2279 | |
2160 | - if (isset($topicOptions['id'])) |
|
2161 | - $topic = $topicOptions['id']; |
|
2280 | + if (isset($topicOptions['id'])) { |
|
2281 | + $topic = $topicOptions['id']; |
|
2282 | + } |
|
2162 | 2283 | } |
2163 | 2284 | |
2164 | 2285 | // Are there attachments already uploaded and waiting to be assigned? |
@@ -2170,8 +2291,9 @@ discard block |
||
2170 | 2291 | } |
2171 | 2292 | |
2172 | 2293 | // If we had a draft for this, its time to remove it since it was just posted |
2173 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
2174 | - DeleteDraft($_POST['id_draft']); |
|
2294 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
2295 | + DeleteDraft($_POST['id_draft']); |
|
2296 | + } |
|
2175 | 2297 | |
2176 | 2298 | // Editing or posting an event? |
2177 | 2299 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2190,8 +2312,7 @@ discard block |
||
2190 | 2312 | 'member' => $user_info['id'], |
2191 | 2313 | ); |
2192 | 2314 | insertEvent($eventOptions); |
2193 | - } |
|
2194 | - elseif (isset($_POST['calendar'])) |
|
2315 | + } elseif (isset($_POST['calendar'])) |
|
2195 | 2316 | { |
2196 | 2317 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
2197 | 2318 | |
@@ -2219,14 +2340,15 @@ discard block |
||
2219 | 2340 | } |
2220 | 2341 | |
2221 | 2342 | // Delete it? |
2222 | - if (isset($_REQUEST['deleteevent'])) |
|
2223 | - $smcFunc['db_query']('', ' |
|
2343 | + if (isset($_REQUEST['deleteevent'])) { |
|
2344 | + $smcFunc['db_query']('', ' |
|
2224 | 2345 | DELETE FROM {db_prefix}calendar |
2225 | 2346 | WHERE id_event = {int:id_event}', |
2226 | 2347 | array( |
2227 | 2348 | 'id_event' => $_REQUEST['eventid'], |
2228 | 2349 | ) |
2229 | 2350 | ); |
2351 | + } |
|
2230 | 2352 | // ... or just update it? |
2231 | 2353 | else |
2232 | 2354 | { |
@@ -2268,9 +2390,8 @@ discard block |
||
2268 | 2390 | array($user_info['id'], $topic, 0), |
2269 | 2391 | array('id_member', 'id_topic', 'id_board') |
2270 | 2392 | ); |
2271 | - } |
|
2272 | - elseif (!$newTopic) |
|
2273 | - $smcFunc['db_query']('', ' |
|
2393 | + } elseif (!$newTopic) { |
|
2394 | + $smcFunc['db_query']('', ' |
|
2274 | 2395 | DELETE FROM {db_prefix}log_notify |
2275 | 2396 | WHERE id_member = {int:current_member} |
2276 | 2397 | AND id_topic = {int:current_topic}', |
@@ -2279,16 +2400,20 @@ discard block |
||
2279 | 2400 | 'current_topic' => $topic, |
2280 | 2401 | ) |
2281 | 2402 | ); |
2403 | + } |
|
2282 | 2404 | |
2283 | 2405 | // Log an act of moderation - modifying. |
2284 | - if (!empty($moderationAction)) |
|
2285 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2406 | + if (!empty($moderationAction)) { |
|
2407 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2408 | + } |
|
2286 | 2409 | |
2287 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
2288 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2410 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
2411 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2412 | + } |
|
2289 | 2413 | |
2290 | - if (isset($_POST['sticky'])) |
|
2291 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2414 | + if (isset($_POST['sticky'])) { |
|
2415 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2416 | + } |
|
2292 | 2417 | |
2293 | 2418 | // Returning to the topic? |
2294 | 2419 | if (!empty($_REQUEST['goback'])) |
@@ -2307,26 +2432,31 @@ discard block |
||
2307 | 2432 | ); |
2308 | 2433 | } |
2309 | 2434 | |
2310 | - if ($board_info['num_topics'] == 0) |
|
2311 | - cache_put_data('board-' . $board, null, 120); |
|
2435 | + if ($board_info['num_topics'] == 0) { |
|
2436 | + cache_put_data('board-' . $board, null, 120); |
|
2437 | + } |
|
2312 | 2438 | |
2313 | 2439 | call_integration_hook('integrate_post2_end'); |
2314 | 2440 | |
2315 | - if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) |
|
2316 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2441 | + if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) { |
|
2442 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2443 | + } |
|
2317 | 2444 | |
2318 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
2319 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2445 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
2446 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2447 | + } |
|
2320 | 2448 | |
2321 | 2449 | // Return to post if the mod is on. |
2322 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
2323 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2324 | - elseif (!empty($_REQUEST['goback'])) |
|
2325 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2450 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
2451 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2452 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2453 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2454 | + } |
|
2326 | 2455 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
2327 | - else |
|
2328 | - redirectexit('board=' . $board . '.0'); |
|
2329 | -} |
|
2456 | + else { |
|
2457 | + redirectexit('board=' . $board . '.0'); |
|
2458 | + } |
|
2459 | + } |
|
2330 | 2460 | |
2331 | 2461 | /** |
2332 | 2462 | * Handle the announce topic function (action=announce). |
@@ -2344,8 +2474,9 @@ discard block |
||
2344 | 2474 | |
2345 | 2475 | validateSession(); |
2346 | 2476 | |
2347 | - if (empty($topic)) |
|
2348 | - fatal_lang_error('topic_gone', false); |
|
2477 | + if (empty($topic)) { |
|
2478 | + fatal_lang_error('topic_gone', false); |
|
2479 | + } |
|
2349 | 2480 | |
2350 | 2481 | loadLanguage('Post'); |
2351 | 2482 | loadTemplate('Post'); |
@@ -2372,8 +2503,9 @@ discard block |
||
2372 | 2503 | global $txt, $context, $topic, $board_info, $smcFunc; |
2373 | 2504 | |
2374 | 2505 | $groups = array_merge($board_info['groups'], array(1)); |
2375 | - foreach ($groups as $id => $group) |
|
2376 | - $groups[$id] = (int) $group; |
|
2506 | + foreach ($groups as $id => $group) { |
|
2507 | + $groups[$id] = (int) $group; |
|
2508 | + } |
|
2377 | 2509 | |
2378 | 2510 | $context['groups'] = array(); |
2379 | 2511 | if (in_array(0, $groups)) |
@@ -2416,8 +2548,9 @@ discard block |
||
2416 | 2548 | 'group_list' => $groups, |
2417 | 2549 | ) |
2418 | 2550 | ); |
2419 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2420 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2551 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2552 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2553 | + } |
|
2421 | 2554 | $smcFunc['db_free_result']($request); |
2422 | 2555 | |
2423 | 2556 | // Get the subject of the topic we're about to announce. |
@@ -2459,16 +2592,19 @@ discard block |
||
2459 | 2592 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
2460 | 2593 | $groups = array_merge($board_info['groups'], array(1)); |
2461 | 2594 | |
2462 | - if (isset($_POST['membergroups'])) |
|
2463 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2595 | + if (isset($_POST['membergroups'])) { |
|
2596 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2597 | + } |
|
2464 | 2598 | |
2465 | 2599 | // Check whether at least one membergroup was selected. |
2466 | - if (empty($_POST['who'])) |
|
2467 | - fatal_lang_error('no_membergroup_selected'); |
|
2600 | + if (empty($_POST['who'])) { |
|
2601 | + fatal_lang_error('no_membergroup_selected'); |
|
2602 | + } |
|
2468 | 2603 | |
2469 | 2604 | // Make sure all membergroups are integers and can access the board of the announcement. |
2470 | - foreach ($_POST['who'] as $id => $mg) |
|
2471 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2605 | + foreach ($_POST['who'] as $id => $mg) { |
|
2606 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2607 | + } |
|
2472 | 2608 | |
2473 | 2609 | // Get the topic subject and censor it. |
2474 | 2610 | $request = $smcFunc['db_query']('', ' |
@@ -2514,12 +2650,13 @@ discard block |
||
2514 | 2650 | if ($smcFunc['db_num_rows']($request) == 0) |
2515 | 2651 | { |
2516 | 2652 | logAction('announce_topic', array('topic' => $topic), 'user'); |
2517 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
2518 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2519 | - elseif (!empty($_REQUEST['goback'])) |
|
2520 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2521 | - else |
|
2522 | - redirectexit('board=' . $board . '.0'); |
|
2653 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
2654 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2655 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2656 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2657 | + } else { |
|
2658 | + redirectexit('board=' . $board . '.0'); |
|
2659 | + } |
|
2523 | 2660 | } |
2524 | 2661 | |
2525 | 2662 | $announcements = array(); |
@@ -2538,8 +2675,9 @@ discard block |
||
2538 | 2675 | foreach ($rows as $row) |
2539 | 2676 | { |
2540 | 2677 | // Force them to have it? |
2541 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
2542 | - continue; |
|
2678 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
2679 | + continue; |
|
2680 | + } |
|
2543 | 2681 | |
2544 | 2682 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
2545 | 2683 | |
@@ -2567,8 +2705,9 @@ discard block |
||
2567 | 2705 | } |
2568 | 2706 | |
2569 | 2707 | // For each language send a different mail - low priority... |
2570 | - foreach ($announcements as $lang => $mail) |
|
2571 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2708 | + foreach ($announcements as $lang => $mail) { |
|
2709 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2710 | + } |
|
2572 | 2711 | |
2573 | 2712 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
2574 | 2713 | |
@@ -2578,9 +2717,10 @@ discard block |
||
2578 | 2717 | $context['sub_template'] = 'announcement_send'; |
2579 | 2718 | |
2580 | 2719 | // Go back to the correct language for the user ;). |
2581 | - if (!empty($modSettings['userLanguage'])) |
|
2582 | - loadLanguage('Post'); |
|
2583 | -} |
|
2720 | + if (!empty($modSettings['userLanguage'])) { |
|
2721 | + loadLanguage('Post'); |
|
2722 | + } |
|
2723 | + } |
|
2584 | 2724 | |
2585 | 2725 | /** |
2586 | 2726 | * Get the topic for display purposes. |
@@ -2593,12 +2733,13 @@ discard block |
||
2593 | 2733 | { |
2594 | 2734 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
2595 | 2735 | |
2596 | - if (isset($_REQUEST['xml'])) |
|
2597 | - $limit = ' |
|
2736 | + if (isset($_REQUEST['xml'])) { |
|
2737 | + $limit = ' |
|
2598 | 2738 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
2599 | - else |
|
2600 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2739 | + } else { |
|
2740 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2601 | 2741 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
2742 | + } |
|
2602 | 2743 | |
2603 | 2744 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
2604 | 2745 | $request = $smcFunc['db_query']('', ' |
@@ -2636,8 +2777,9 @@ discard block |
||
2636 | 2777 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
2637 | 2778 | ); |
2638 | 2779 | |
2639 | - if (!empty($context['new_replies'])) |
|
2640 | - $context['new_replies']--; |
|
2780 | + if (!empty($context['new_replies'])) { |
|
2781 | + $context['new_replies']--; |
|
2782 | + } |
|
2641 | 2783 | } |
2642 | 2784 | $smcFunc['db_free_result']($request); |
2643 | 2785 | } |
@@ -2654,8 +2796,9 @@ discard block |
||
2654 | 2796 | global $sourcedir, $smcFunc; |
2655 | 2797 | |
2656 | 2798 | loadLanguage('Post'); |
2657 | - if (!isset($_REQUEST['xml'])) |
|
2658 | - loadTemplate('Post'); |
|
2799 | + if (!isset($_REQUEST['xml'])) { |
|
2800 | + loadTemplate('Post'); |
|
2801 | + } |
|
2659 | 2802 | |
2660 | 2803 | include_once($sourcedir . '/Subs-Post.php'); |
2661 | 2804 | |
@@ -2686,8 +2829,9 @@ discard block |
||
2686 | 2829 | $smcFunc['db_free_result']($request); |
2687 | 2830 | |
2688 | 2831 | $context['sub_template'] = 'quotefast'; |
2689 | - if (!empty($row)) |
|
2690 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2832 | + if (!empty($row)) { |
|
2833 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2834 | + } |
|
2691 | 2835 | |
2692 | 2836 | if (!empty($can_view_post)) |
2693 | 2837 | { |
@@ -2720,8 +2864,9 @@ discard block |
||
2720 | 2864 | } |
2721 | 2865 | |
2722 | 2866 | // Remove any nested quotes. |
2723 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
2724 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2867 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
2868 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2869 | + } |
|
2725 | 2870 | |
2726 | 2871 | $lb = "\n"; |
2727 | 2872 | |
@@ -2747,14 +2892,14 @@ discard block |
||
2747 | 2892 | 'time' => '', |
2748 | 2893 | ), |
2749 | 2894 | ); |
2750 | - } |
|
2751 | - else |
|
2752 | - $context['quote'] = array( |
|
2895 | + } else { |
|
2896 | + $context['quote'] = array( |
|
2753 | 2897 | 'xml' => '', |
2754 | 2898 | 'mozilla' => '', |
2755 | 2899 | 'text' => '', |
2756 | 2900 | ); |
2757 | -} |
|
2901 | + } |
|
2902 | + } |
|
2758 | 2903 | |
2759 | 2904 | /** |
2760 | 2905 | * Used to edit the body or subject of a message inline |
@@ -2766,8 +2911,9 @@ discard block |
||
2766 | 2911 | global $user_info, $context, $smcFunc, $language, $board_info; |
2767 | 2912 | |
2768 | 2913 | // We have to have a topic! |
2769 | - if (empty($topic)) |
|
2770 | - obExit(false); |
|
2914 | + if (empty($topic)) { |
|
2915 | + obExit(false); |
|
2916 | + } |
|
2771 | 2917 | |
2772 | 2918 | checkSession('get'); |
2773 | 2919 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2793,31 +2939,35 @@ discard block |
||
2793 | 2939 | 'guest_id' => 0, |
2794 | 2940 | ) |
2795 | 2941 | ); |
2796 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
2797 | - fatal_lang_error('no_board', false); |
|
2942 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
2943 | + fatal_lang_error('no_board', false); |
|
2944 | + } |
|
2798 | 2945 | $row = $smcFunc['db_fetch_assoc']($request); |
2799 | 2946 | $smcFunc['db_free_result']($request); |
2800 | 2947 | |
2801 | 2948 | // Change either body or subject requires permissions to modify messages. |
2802 | 2949 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
2803 | 2950 | { |
2804 | - if (!empty($row['locked'])) |
|
2805 | - isAllowedTo('moderate_board'); |
|
2951 | + if (!empty($row['locked'])) { |
|
2952 | + isAllowedTo('moderate_board'); |
|
2953 | + } |
|
2806 | 2954 | |
2807 | 2955 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
2808 | 2956 | { |
2809 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
2810 | - fatal_lang_error('modify_post_time_passed', false); |
|
2811 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
2812 | - isAllowedTo('modify_replies'); |
|
2813 | - else |
|
2814 | - isAllowedTo('modify_own'); |
|
2957 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
2958 | + fatal_lang_error('modify_post_time_passed', false); |
|
2959 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
2960 | + isAllowedTo('modify_replies'); |
|
2961 | + } else { |
|
2962 | + isAllowedTo('modify_own'); |
|
2963 | + } |
|
2815 | 2964 | } |
2816 | 2965 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
2817 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
2818 | - isAllowedTo('modify_replies'); |
|
2819 | - else |
|
2820 | - isAllowedTo('modify_any'); |
|
2966 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
2967 | + isAllowedTo('modify_replies'); |
|
2968 | + } else { |
|
2969 | + isAllowedTo('modify_any'); |
|
2970 | + } |
|
2821 | 2971 | |
2822 | 2972 | // Only log this action if it wasn't your message. |
2823 | 2973 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2829,10 +2979,10 @@ discard block |
||
2829 | 2979 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
2830 | 2980 | |
2831 | 2981 | // Maximum number of characters. |
2832 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
2833 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2834 | - } |
|
2835 | - elseif (isset($_POST['subject'])) |
|
2982 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2983 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2984 | + } |
|
2985 | + } elseif (isset($_POST['subject'])) |
|
2836 | 2986 | { |
2837 | 2987 | $post_errors[] = 'no_subject'; |
2838 | 2988 | unset($_POST['subject']); |
@@ -2844,13 +2994,11 @@ discard block |
||
2844 | 2994 | { |
2845 | 2995 | $post_errors[] = 'no_message'; |
2846 | 2996 | unset($_POST['message']); |
2847 | - } |
|
2848 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2997 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2849 | 2998 | { |
2850 | 2999 | $post_errors[] = 'long_message'; |
2851 | 3000 | unset($_POST['message']); |
2852 | - } |
|
2853 | - else |
|
3001 | + } else |
|
2854 | 3002 | { |
2855 | 3003 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
2856 | 3004 | |
@@ -2866,31 +3014,34 @@ discard block |
||
2866 | 3014 | |
2867 | 3015 | if (isset($_POST['lock'])) |
2868 | 3016 | { |
2869 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
2870 | - unset($_POST['lock']); |
|
2871 | - elseif (!allowedTo('lock_any')) |
|
3017 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
3018 | + unset($_POST['lock']); |
|
3019 | + } elseif (!allowedTo('lock_any')) |
|
2872 | 3020 | { |
2873 | - if ($row['locked'] == 1) |
|
2874 | - unset($_POST['lock']); |
|
2875 | - else |
|
2876 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
3021 | + if ($row['locked'] == 1) { |
|
3022 | + unset($_POST['lock']); |
|
3023 | + } else { |
|
3024 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
3025 | + } |
|
3026 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
3027 | + unset($_POST['lock']); |
|
3028 | + } else { |
|
3029 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2877 | 3030 | } |
2878 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
2879 | - unset($_POST['lock']); |
|
2880 | - else |
|
2881 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2882 | 3031 | } |
2883 | 3032 | |
2884 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
2885 | - unset($_POST['sticky']); |
|
3033 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
3034 | + unset($_POST['sticky']); |
|
3035 | + } |
|
2886 | 3036 | |
2887 | 3037 | if (isset($_POST['modify_reason'])) |
2888 | 3038 | { |
2889 | 3039 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
2890 | 3040 | |
2891 | 3041 | // Maximum number of characters. |
2892 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
2893 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
3042 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
3043 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
3044 | + } |
|
2894 | 3045 | } |
2895 | 3046 | |
2896 | 3047 | if (empty($post_errors)) |
@@ -2927,8 +3078,9 @@ discard block |
||
2927 | 3078 | } |
2928 | 3079 | } |
2929 | 3080 | // If nothing was changed there's no need to add an entry to the moderation log. |
2930 | - else |
|
2931 | - $moderationAction = false; |
|
3081 | + else { |
|
3082 | + $moderationAction = false; |
|
3083 | + } |
|
2932 | 3084 | |
2933 | 3085 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2934 | 3086 | |
@@ -2946,9 +3098,9 @@ discard block |
||
2946 | 3098 | // Get the proper (default language) response prefix first. |
2947 | 3099 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
2948 | 3100 | { |
2949 | - if ($language === $user_info['language']) |
|
2950 | - $context['response_prefix'] = $txt['response_prefix']; |
|
2951 | - else |
|
3101 | + if ($language === $user_info['language']) { |
|
3102 | + $context['response_prefix'] = $txt['response_prefix']; |
|
3103 | + } else |
|
2952 | 3104 | { |
2953 | 3105 | loadLanguage('index', $language, false); |
2954 | 3106 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2970,8 +3122,9 @@ discard block |
||
2970 | 3122 | ); |
2971 | 3123 | } |
2972 | 3124 | |
2973 | - if (!empty($moderationAction)) |
|
2974 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3125 | + if (!empty($moderationAction)) { |
|
3126 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3127 | + } |
|
2975 | 3128 | } |
2976 | 3129 | |
2977 | 3130 | if (isset($_REQUEST['xml'])) |
@@ -3012,8 +3165,7 @@ discard block |
||
3012 | 3165 | ); |
3013 | 3166 | |
3014 | 3167 | censorText($context['message']['subject']); |
3015 | - } |
|
3016 | - else |
|
3168 | + } else |
|
3017 | 3169 | { |
3018 | 3170 | $context['message'] = array( |
3019 | 3171 | 'id' => $row['id_msg'], |
@@ -3025,15 +3177,16 @@ discard block |
||
3025 | 3177 | loadLanguage('Errors'); |
3026 | 3178 | foreach ($post_errors as $post_error) |
3027 | 3179 | { |
3028 | - if ($post_error == 'long_message') |
|
3029 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3030 | - else |
|
3031 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3180 | + if ($post_error == 'long_message') { |
|
3181 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3182 | + } else { |
|
3183 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3184 | + } |
|
3032 | 3185 | } |
3033 | 3186 | } |
3187 | + } else { |
|
3188 | + obExit(false); |
|
3189 | + } |
|
3034 | 3190 | } |
3035 | - else |
|
3036 | - obExit(false); |
|
3037 | -} |
|
3038 | 3191 | |
3039 | 3192 | ?> |
3040 | 3193 | \ No newline at end of file |