@@ -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> |
@@ -40,18 +42,21 @@ discard block |
||
| 40 | 42 | var textarea = $("#', $editor_id, '").get(0); |
| 41 | 43 | sceditor.create(textarea, ', $smcFunc['json_encode']($editor_context['sce_options'], JSON_PRETTY_PRINT), ');'; |
| 42 | 44 | |
| 43 | - if ($editor_context['sce_options']['emoticonsEnabled']) |
|
| 44 | - echo ' |
|
| 45 | + if ($editor_context['sce_options']['emoticonsEnabled']) { |
|
| 46 | + echo ' |
|
| 45 | 47 | sceditor.instance(textarea).createPermanentDropDown();'; |
| 48 | + } |
|
| 46 | 49 | |
| 47 | - if (empty($editor_context['rich_active'])) |
|
| 48 | - echo ' |
|
| 50 | + if (empty($editor_context['rich_active'])) { |
|
| 51 | + echo ' |
|
| 49 | 52 | sceditor.instance(textarea).toggleSourceMode();'; |
| 53 | + } |
|
| 50 | 54 | |
| 51 | - if (isset($context['post_error']['no_message']) || isset($context['post_error']['long_message'])) |
|
| 52 | - echo ' |
|
| 55 | + if (isset($context['post_error']['no_message']) || isset($context['post_error']['long_message'])) { |
|
| 56 | + echo ' |
|
| 53 | 57 | $(".sceditor-container").find("textarea").each(function() {$(this).css({border: "1px solid red"})}); |
| 54 | 58 | $(".sceditor-container").find("iframe").each(function() {$(this).css({border: "1px solid red"})});'; |
| 59 | + } |
|
| 55 | 60 | |
| 56 | 61 | echo ' |
| 57 | 62 | });'; |
@@ -88,42 +93,47 @@ discard block |
||
| 88 | 93 | |
| 89 | 94 | $tempTab = $context['tabindex']; |
| 90 | 95 | |
| 91 | - if (!empty($context['drafts_pm_save'])) |
|
| 92 | - $tempTab++; |
|
| 93 | - elseif (!empty($context['drafts_save'])) |
|
| 94 | - $tempTab++; |
|
| 95 | - elseif ($editor_context['preview_type']) |
|
| 96 | - $tempTab++; |
|
| 97 | - elseif ($context['show_spellchecking']) |
|
| 98 | - $tempTab++; |
|
| 96 | + if (!empty($context['drafts_pm_save'])) { |
|
| 97 | + $tempTab++; |
|
| 98 | + } elseif (!empty($context['drafts_save'])) { |
|
| 99 | + $tempTab++; |
|
| 100 | + } elseif ($editor_context['preview_type']) { |
|
| 101 | + $tempTab++; |
|
| 102 | + } elseif ($context['show_spellchecking']) { |
|
| 103 | + $tempTab++; |
|
| 104 | + } |
|
| 99 | 105 | |
| 100 | 106 | $tempTab++; |
| 101 | 107 | $context['tabindex'] = $tempTab; |
| 102 | 108 | |
| 103 | - if (!empty($context['drafts_pm_save'])) |
|
| 104 | - echo ' |
|
| 109 | + if (!empty($context['drafts_pm_save'])) { |
|
| 110 | + echo ' |
|
| 105 | 111 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button"> |
| 106 | 112 | <input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">'; |
| 113 | + } |
|
| 107 | 114 | |
| 108 | - if (!empty($context['drafts_save'])) |
|
| 109 | - echo ' |
|
| 115 | + if (!empty($context['drafts_save'])) { |
|
| 116 | + echo ' |
|
| 110 | 117 | <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"> |
| 111 | 118 | <input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">'; |
| 119 | + } |
|
| 112 | 120 | |
| 113 | - if ($context['show_spellchecking']) |
|
| 114 | - echo ' |
|
| 121 | + if ($context['show_spellchecking']) { |
|
| 122 | + echo ' |
|
| 115 | 123 | <input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">'; |
| 124 | + } |
|
| 116 | 125 | |
| 117 | - if ($editor_context['preview_type']) |
|
| 118 | - echo ' |
|
| 126 | + if ($editor_context['preview_type']) { |
|
| 127 | + echo ' |
|
| 119 | 128 | <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">'; |
| 129 | + } |
|
| 120 | 130 | |
| 121 | 131 | echo ' |
| 122 | 132 | <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">'; |
| 123 | 133 | |
| 124 | 134 | // Load in the PM autosaver if it's enabled |
| 125 | - if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) |
|
| 126 | - echo ' |
|
| 135 | + if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) { |
|
| 136 | + echo ' |
|
| 127 | 137 | <span class="righttext padding" style="display: block"> |
| 128 | 138 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span> |
| 129 | 139 | <span id="draft_lastautosave" ></span> |
@@ -141,10 +151,11 @@ discard block |
||
| 141 | 151 | iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), ' |
| 142 | 152 | }); |
| 143 | 153 | </script>'; |
| 154 | + } |
|
| 144 | 155 | |
| 145 | 156 | // Start an instance of the auto saver if its enabled |
| 146 | - if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) |
|
| 147 | - echo ' |
|
| 157 | + if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) { |
|
| 158 | + echo ' |
|
| 148 | 159 | <span class="righttext padding" style="display: block"> |
| 149 | 160 | <span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span> |
| 150 | 161 | <span id="draft_lastautosave" ></span> |
@@ -161,7 +172,8 @@ discard block |
||
| 161 | 172 | iFreq: ', $context['drafts_autosave_frequency'], ' |
| 162 | 173 | }); |
| 163 | 174 | </script>'; |
| 164 | -} |
|
| 175 | + } |
|
| 176 | + } |
|
| 165 | 177 | |
| 166 | 178 | /** |
| 167 | 179 | * This template displays a verification form |
@@ -178,51 +190,57 @@ discard block |
||
| 178 | 190 | $verify_context = &$context['controls']['verification'][$verify_id]; |
| 179 | 191 | |
| 180 | 192 | // Keep track of where we are. |
| 181 | - if (empty($verify_context['tracking']) || $reset) |
|
| 182 | - $verify_context['tracking'] = 0; |
|
| 193 | + if (empty($verify_context['tracking']) || $reset) { |
|
| 194 | + $verify_context['tracking'] = 0; |
|
| 195 | + } |
|
| 183 | 196 | |
| 184 | 197 | // How many items are there to display in total. |
| 185 | 198 | $total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0); |
| 186 | 199 | |
| 187 | 200 | // If we've gone too far, stop. |
| 188 | - if ($verify_context['tracking'] > $total_items) |
|
| 189 | - return false; |
|
| 201 | + if ($verify_context['tracking'] > $total_items) { |
|
| 202 | + return false; |
|
| 203 | + } |
|
| 190 | 204 | |
| 191 | 205 | // Loop through each item to show them. |
| 192 | 206 | for ($i = 0; $i < $total_items; $i++) |
| 193 | 207 | { |
| 194 | 208 | // If we're after a single item only show it if we're in the right place. |
| 195 | - if ($display_type == 'single' && $verify_context['tracking'] != $i) |
|
| 196 | - continue; |
|
| 209 | + if ($display_type == 'single' && $verify_context['tracking'] != $i) { |
|
| 210 | + continue; |
|
| 211 | + } |
|
| 197 | 212 | |
| 198 | - if ($display_type != 'single') |
|
| 199 | - echo ' |
|
| 213 | + if ($display_type != 'single') { |
|
| 214 | + echo ' |
|
| 200 | 215 | <div id="verification_control_', $i, '" class="verification_control">'; |
| 216 | + } |
|
| 201 | 217 | |
| 202 | 218 | // Display empty field, but only if we have one, and it's the first time. |
| 203 | - if ($verify_context['empty_field'] && empty($i)) |
|
| 204 | - echo ' |
|
| 219 | + if ($verify_context['empty_field'] && empty($i)) { |
|
| 220 | + echo ' |
|
| 205 | 221 | <div class="smalltext vv_special"> |
| 206 | 222 | ', $txt['visual_verification_hidden'], ': |
| 207 | 223 | <input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value=""> |
| 208 | 224 | </div>'; |
| 225 | + } |
|
| 209 | 226 | |
| 210 | 227 | // Do the actual stuff |
| 211 | 228 | if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha'])) |
| 212 | 229 | { |
| 213 | 230 | if ($verify_context['show_visual']) |
| 214 | 231 | { |
| 215 | - if ($context['use_graphic_library']) |
|
| 216 | - echo ' |
|
| 232 | + if ($context['use_graphic_library']) { |
|
| 233 | + echo ' |
|
| 217 | 234 | <img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">'; |
| 218 | - else |
|
| 219 | - echo ' |
|
| 235 | + } else { |
|
| 236 | + echo ' |
|
| 220 | 237 | <img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1"> |
| 221 | 238 | <img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2"> |
| 222 | 239 | <img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3"> |
| 223 | 240 | <img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4"> |
| 224 | 241 | <img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5"> |
| 225 | 242 | <img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">'; |
| 243 | + } |
|
| 226 | 244 | |
| 227 | 245 | echo ' |
| 228 | 246 | <div class="smalltext" style="margin: 4px 0 8px 0;"> |
@@ -240,8 +258,7 @@ discard block |
||
| 240 | 258 | <br> |
| 241 | 259 | <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang.'"></script>'; |
| 242 | 260 | } |
| 243 | - } |
|
| 244 | - else |
|
| 261 | + } else |
|
| 245 | 262 | { |
| 246 | 263 | // Where in the question array is this question? |
| 247 | 264 | $qIndex = $verify_context['show_visual'] ? $i - 1 : $i; |
@@ -253,21 +270,24 @@ discard block |
||
| 253 | 270 | </div>'; |
| 254 | 271 | } |
| 255 | 272 | |
| 256 | - if ($display_type != 'single') |
|
| 257 | - echo ' |
|
| 273 | + if ($display_type != 'single') { |
|
| 274 | + echo ' |
|
| 258 | 275 | </div><!-- #verification_control_[i] -->'; |
| 276 | + } |
|
| 259 | 277 | |
| 260 | 278 | // If we were displaying just one and we did it, break. |
| 261 | - if ($display_type == 'single' && $verify_context['tracking'] == $i) |
|
| 262 | - break; |
|
| 279 | + if ($display_type == 'single' && $verify_context['tracking'] == $i) { |
|
| 280 | + break; |
|
| 281 | + } |
|
| 263 | 282 | } |
| 264 | 283 | |
| 265 | 284 | // Assume we found something, always. |
| 266 | 285 | $verify_context['tracking']++; |
| 267 | 286 | |
| 268 | 287 | // Tell something displaying piecemeal to keep going. |
| 269 | - if ($display_type == 'single') |
|
| 270 | - return true; |
|
| 271 | -} |
|
| 288 | + if ($display_type == 'single') { |
|
| 289 | + return true; |
|
| 290 | + } |
|
| 291 | + } |
|
| 272 | 292 | |
| 273 | 293 | ?> |
| 274 | 294 | \ No newline at end of file |
@@ -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 | // I love my own image... |
@@ -682,8 +697,9 @@ discard block |
||
| 682 | 697 | { |
| 683 | 698 | // Find the position of the image. |
| 684 | 699 | $start_pos = strpos($text, $matches[0]); |
| 685 | - if ($start_pos === false) |
|
| 686 | - break; |
|
| 700 | + if ($start_pos === false) { |
|
| 701 | + break; |
|
| 702 | + } |
|
| 687 | 703 | $end_pos = $start_pos + strlen($matches[0]); |
| 688 | 704 | |
| 689 | 705 | $params = ''; |
@@ -692,12 +708,13 @@ discard block |
||
| 692 | 708 | $attrs = fetchTagAttributes($matches[1]); |
| 693 | 709 | foreach ($attrs as $attrib => $value) |
| 694 | 710 | { |
| 695 | - if (in_array($attrib, array('width', 'height'))) |
|
| 696 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 697 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
| 698 | - $params .= ' alt=' . trim($value); |
|
| 699 | - elseif ($attrib == 'src') |
|
| 700 | - $src = trim($value); |
|
| 711 | + if (in_array($attrib, array('width', 'height'))) { |
|
| 712 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 713 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
| 714 | + $params .= ' alt=' . trim($value); |
|
| 715 | + } elseif ($attrib == 'src') { |
|
| 716 | + $src = trim($value); |
|
| 717 | + } |
|
| 701 | 718 | } |
| 702 | 719 | |
| 703 | 720 | $tag = ''; |
@@ -708,10 +725,11 @@ discard block |
||
| 708 | 725 | { |
| 709 | 726 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 710 | 727 | |
| 711 | - if (substr($src, 0, 1) === '/') |
|
| 712 | - $src = $baseURL . $src; |
|
| 713 | - else |
|
| 714 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 728 | + if (substr($src, 0, 1) === '/') { |
|
| 729 | + $src = $baseURL . $src; |
|
| 730 | + } else { |
|
| 731 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 732 | + } |
|
| 715 | 733 | } |
| 716 | 734 | |
| 717 | 735 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -889,20 +907,23 @@ discard block |
||
| 889 | 907 | }, |
| 890 | 908 | ); |
| 891 | 909 | |
| 892 | - foreach ($tags as $tag => $replace) |
|
| 893 | - $text = preg_replace_callback($tag, $replace, $text); |
|
| 910 | + foreach ($tags as $tag => $replace) { |
|
| 911 | + $text = preg_replace_callback($tag, $replace, $text); |
|
| 912 | + } |
|
| 894 | 913 | |
| 895 | 914 | // Please give us just a little more time. |
| 896 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 897 | - @apache_reset_timeout(); |
|
| 915 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 916 | + @apache_reset_timeout(); |
|
| 917 | + } |
|
| 898 | 918 | |
| 899 | 919 | // What about URL's - the pain in the ass of the tag world. |
| 900 | 920 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
| 901 | 921 | { |
| 902 | 922 | // Find the position of the URL. |
| 903 | 923 | $start_pos = strpos($text, $matches[0]); |
| 904 | - if ($start_pos === false) |
|
| 905 | - break; |
|
| 924 | + if ($start_pos === false) { |
|
| 925 | + break; |
|
| 926 | + } |
|
| 906 | 927 | $end_pos = $start_pos + strlen($matches[0]); |
| 907 | 928 | |
| 908 | 929 | $tag_type = 'url'; |
@@ -916,8 +937,9 @@ discard block |
||
| 916 | 937 | $href = trim($value); |
| 917 | 938 | |
| 918 | 939 | // Are we dealing with an FTP link? |
| 919 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
| 920 | - $tag_type = 'ftp'; |
|
| 940 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
| 941 | + $tag_type = 'ftp'; |
|
| 942 | + } |
|
| 921 | 943 | |
| 922 | 944 | // Or is this a link to an email address? |
| 923 | 945 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -931,28 +953,31 @@ discard block |
||
| 931 | 953 | { |
| 932 | 954 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 933 | 955 | |
| 934 | - if (substr($href, 0, 1) === '/') |
|
| 935 | - $href = $baseURL . $href; |
|
| 936 | - else |
|
| 937 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 956 | + if (substr($href, 0, 1) === '/') { |
|
| 957 | + $href = $baseURL . $href; |
|
| 958 | + } else { |
|
| 959 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 960 | + } |
|
| 938 | 961 | } |
| 939 | 962 | } |
| 940 | 963 | |
| 941 | 964 | // External URL? |
| 942 | 965 | if ($attrib == 'target' && $tag_type == 'url') |
| 943 | 966 | { |
| 944 | - if (trim($value) == '_blank') |
|
| 945 | - $tag_type == 'iurl'; |
|
| 967 | + if (trim($value) == '_blank') { |
|
| 968 | + $tag_type == 'iurl'; |
|
| 969 | + } |
|
| 946 | 970 | } |
| 947 | 971 | } |
| 948 | 972 | |
| 949 | 973 | $tag = ''; |
| 950 | 974 | if ($href != '') |
| 951 | 975 | { |
| 952 | - if ($matches[2] == $href) |
|
| 953 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 954 | - else |
|
| 955 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 976 | + if ($matches[2] == $href) { |
|
| 977 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 978 | + } else { |
|
| 979 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 980 | + } |
|
| 956 | 981 | } |
| 957 | 982 | |
| 958 | 983 | // Replace the tag |
@@ -991,17 +1016,18 @@ discard block |
||
| 991 | 1016 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
| 992 | 1017 | if ($text[$i] == '=') |
| 993 | 1018 | { |
| 994 | - if ($tag_state == 0) |
|
| 995 | - $tag_state = 1; |
|
| 996 | - elseif ($tag_state == 2) |
|
| 997 | - $value .= '='; |
|
| 1019 | + if ($tag_state == 0) { |
|
| 1020 | + $tag_state = 1; |
|
| 1021 | + } elseif ($tag_state == 2) { |
|
| 1022 | + $value .= '='; |
|
| 1023 | + } |
|
| 998 | 1024 | } |
| 999 | 1025 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
| 1000 | 1026 | elseif ($text[$i] == ' ') |
| 1001 | 1027 | { |
| 1002 | - if ($tag_state == 2) |
|
| 1003 | - $value .= ' '; |
|
| 1004 | - elseif ($tag_state == 1) |
|
| 1028 | + if ($tag_state == 2) { |
|
| 1029 | + $value .= ' '; |
|
| 1030 | + } elseif ($tag_state == 1) |
|
| 1005 | 1031 | { |
| 1006 | 1032 | $attribs[$key] = $value; |
| 1007 | 1033 | $key = $value = ''; |
@@ -1012,24 +1038,27 @@ discard block |
||
| 1012 | 1038 | elseif ($text[$i] == '"') |
| 1013 | 1039 | { |
| 1014 | 1040 | // Must be either going into or out of a string. |
| 1015 | - if ($tag_state == 1) |
|
| 1016 | - $tag_state = 2; |
|
| 1017 | - else |
|
| 1018 | - $tag_state = 1; |
|
| 1041 | + if ($tag_state == 1) { |
|
| 1042 | + $tag_state = 2; |
|
| 1043 | + } else { |
|
| 1044 | + $tag_state = 1; |
|
| 1045 | + } |
|
| 1019 | 1046 | } |
| 1020 | 1047 | // Otherwise it's fine. |
| 1021 | 1048 | else |
| 1022 | 1049 | { |
| 1023 | - if ($tag_state == 0) |
|
| 1024 | - $key .= $text[$i]; |
|
| 1025 | - else |
|
| 1026 | - $value .= $text[$i]; |
|
| 1050 | + if ($tag_state == 0) { |
|
| 1051 | + $key .= $text[$i]; |
|
| 1052 | + } else { |
|
| 1053 | + $value .= $text[$i]; |
|
| 1054 | + } |
|
| 1027 | 1055 | } |
| 1028 | 1056 | } |
| 1029 | 1057 | |
| 1030 | 1058 | // Anything left? |
| 1031 | - if ($key != '' && $value != '') |
|
| 1032 | - $attribs[$key] = $value; |
|
| 1059 | + if ($key != '' && $value != '') { |
|
| 1060 | + $attribs[$key] = $value; |
|
| 1061 | + } |
|
| 1033 | 1062 | |
| 1034 | 1063 | return $attribs; |
| 1035 | 1064 | } |
@@ -1045,15 +1074,17 @@ discard block |
||
| 1045 | 1074 | global $modSettings; |
| 1046 | 1075 | |
| 1047 | 1076 | // Don't care about the texts that are too short. |
| 1048 | - if (strlen($text) < 3) |
|
| 1049 | - return $text; |
|
| 1077 | + if (strlen($text) < 3) { |
|
| 1078 | + return $text; |
|
| 1079 | + } |
|
| 1050 | 1080 | |
| 1051 | 1081 | // A list of tags that's disabled by the admin. |
| 1052 | 1082 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
| 1053 | 1083 | |
| 1054 | 1084 | // Add flash if it's disabled as embedded tag. |
| 1055 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1056 | - $disabled['flash'] = true; |
|
| 1085 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1086 | + $disabled['flash'] = true; |
|
| 1087 | + } |
|
| 1057 | 1088 | |
| 1058 | 1089 | // Get a list of all the tags that are not disabled. |
| 1059 | 1090 | $all_tags = parse_bbc(false); |
@@ -1061,10 +1092,12 @@ discard block |
||
| 1061 | 1092 | $self_closing_tags = array(); |
| 1062 | 1093 | foreach ($all_tags as $tag) |
| 1063 | 1094 | { |
| 1064 | - if (!isset($disabled[$tag['tag']])) |
|
| 1065 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1066 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
| 1067 | - $self_closing_tags[] = $tag['tag']; |
|
| 1095 | + if (!isset($disabled[$tag['tag']])) { |
|
| 1096 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1097 | + } |
|
| 1098 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
| 1099 | + $self_closing_tags[] = $tag['tag']; |
|
| 1100 | + } |
|
| 1068 | 1101 | } |
| 1069 | 1102 | |
| 1070 | 1103 | // 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! |
@@ -1091,16 +1124,19 @@ discard block |
||
| 1091 | 1124 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
| 1092 | 1125 | |
| 1093 | 1126 | // We're closing the exact same tag that we opened. |
| 1094 | - if ($isClosingTag && $insideTag === $tagName) |
|
| 1095 | - $insideTag = null; |
|
| 1127 | + if ($isClosingTag && $insideTag === $tagName) { |
|
| 1128 | + $insideTag = null; |
|
| 1129 | + } |
|
| 1096 | 1130 | |
| 1097 | 1131 | // We're opening a tag and we're not yet inside one either |
| 1098 | - elseif (!$isClosingTag && $insideTag === null) |
|
| 1099 | - $insideTag = $tagName; |
|
| 1132 | + elseif (!$isClosingTag && $insideTag === null) { |
|
| 1133 | + $insideTag = $tagName; |
|
| 1134 | + } |
|
| 1100 | 1135 | |
| 1101 | 1136 | // In all other cases, this tag must be invalid |
| 1102 | - else |
|
| 1103 | - unset($matches[$i]); |
|
| 1137 | + else { |
|
| 1138 | + unset($matches[$i]); |
|
| 1139 | + } |
|
| 1104 | 1140 | } |
| 1105 | 1141 | |
| 1106 | 1142 | // The next one is gonna be the other one. |
@@ -1108,8 +1144,9 @@ discard block |
||
| 1108 | 1144 | } |
| 1109 | 1145 | |
| 1110 | 1146 | // We're still inside a tag and had no chance for closure? |
| 1111 | - if ($insideTag !== null) |
|
| 1112 | - $matches[] = '[/' . $insideTag . ']'; |
|
| 1147 | + if ($insideTag !== null) { |
|
| 1148 | + $matches[] = '[/' . $insideTag . ']'; |
|
| 1149 | + } |
|
| 1113 | 1150 | |
| 1114 | 1151 | // And a complete text string again. |
| 1115 | 1152 | $text = implode('', $matches); |
@@ -1118,8 +1155,9 @@ discard block |
||
| 1118 | 1155 | // Quickly remove any tags which are back to back. |
| 1119 | 1156 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
| 1120 | 1157 | $lastlen = 0; |
| 1121 | - while (strlen($text) !== $lastlen) |
|
| 1122 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1158 | + while (strlen($text) !== $lastlen) { |
|
| 1159 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1160 | + } |
|
| 1123 | 1161 | |
| 1124 | 1162 | // Need to sort the tags my name length. |
| 1125 | 1163 | uksort($valid_tags, 'sort_array_length'); |
@@ -1156,8 +1194,9 @@ discard block |
||
| 1156 | 1194 | $isCompetingTag = in_array($tag, $competing_tags); |
| 1157 | 1195 | |
| 1158 | 1196 | // Check if this might be one of those cleaned out tags. |
| 1159 | - if ($tag === '') |
|
| 1160 | - continue; |
|
| 1197 | + if ($tag === '') { |
|
| 1198 | + continue; |
|
| 1199 | + } |
|
| 1161 | 1200 | |
| 1162 | 1201 | // Special case: inside [code] blocks any code is left untouched. |
| 1163 | 1202 | elseif ($tag === 'code') |
@@ -1168,8 +1207,9 @@ discard block |
||
| 1168 | 1207 | $inCode = false; |
| 1169 | 1208 | |
| 1170 | 1209 | // Reopen tags that were closed before the code block. |
| 1171 | - if (!empty($inlineElements)) |
|
| 1172 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1210 | + if (!empty($inlineElements)) { |
|
| 1211 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1212 | + } |
|
| 1173 | 1213 | } |
| 1174 | 1214 | |
| 1175 | 1215 | // We're outside a coding and nobbc block and opening it. |
@@ -1198,8 +1238,9 @@ discard block |
||
| 1198 | 1238 | $inNoBbc = false; |
| 1199 | 1239 | |
| 1200 | 1240 | // Some inline elements might've been closed that need reopening. |
| 1201 | - if (!empty($inlineElements)) |
|
| 1202 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1241 | + if (!empty($inlineElements)) { |
|
| 1242 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1243 | + } |
|
| 1203 | 1244 | } |
| 1204 | 1245 | |
| 1205 | 1246 | // We're outside a nobbc and coding block and opening it. |
@@ -1219,8 +1260,9 @@ discard block |
||
| 1219 | 1260 | } |
| 1220 | 1261 | |
| 1221 | 1262 | // So, we're inside one of the special blocks: ignore any tag. |
| 1222 | - elseif ($inCode || $inNoBbc) |
|
| 1223 | - continue; |
|
| 1263 | + elseif ($inCode || $inNoBbc) { |
|
| 1264 | + continue; |
|
| 1265 | + } |
|
| 1224 | 1266 | |
| 1225 | 1267 | // We're dealing with an opening tag. |
| 1226 | 1268 | if ($isOpeningTag) |
@@ -1261,8 +1303,9 @@ discard block |
||
| 1261 | 1303 | if ($parts[$j + 3] === $tag) |
| 1262 | 1304 | { |
| 1263 | 1305 | // If it's an opening tag, increase the level. |
| 1264 | - if ($parts[$j + 2] === '') |
|
| 1265 | - $curLevel++; |
|
| 1306 | + if ($parts[$j + 2] === '') { |
|
| 1307 | + $curLevel++; |
|
| 1308 | + } |
|
| 1266 | 1309 | |
| 1267 | 1310 | // A closing tag, decrease the level. |
| 1268 | 1311 | else |
@@ -1285,13 +1328,15 @@ discard block |
||
| 1285 | 1328 | { |
| 1286 | 1329 | if ($isCompetingTag) |
| 1287 | 1330 | { |
| 1288 | - if (!isset($competingElements[$tag])) |
|
| 1289 | - $competingElements[$tag] = array(); |
|
| 1331 | + if (!isset($competingElements[$tag])) { |
|
| 1332 | + $competingElements[$tag] = array(); |
|
| 1333 | + } |
|
| 1290 | 1334 | |
| 1291 | 1335 | $competingElements[$tag][] = $parts[$i + 4]; |
| 1292 | 1336 | |
| 1293 | - if (count($competingElements[$tag]) > 1) |
|
| 1294 | - $parts[$i] .= '[/' . $tag . ']'; |
|
| 1337 | + if (count($competingElements[$tag]) > 1) { |
|
| 1338 | + $parts[$i] .= '[/' . $tag . ']'; |
|
| 1339 | + } |
|
| 1295 | 1340 | } |
| 1296 | 1341 | |
| 1297 | 1342 | $inlineElements[$elementContent] = $tag; |
@@ -1311,15 +1356,17 @@ discard block |
||
| 1311 | 1356 | $addClosingTags = array(); |
| 1312 | 1357 | while ($element = array_pop($blockElements)) |
| 1313 | 1358 | { |
| 1314 | - if ($element === $tag) |
|
| 1315 | - break; |
|
| 1359 | + if ($element === $tag) { |
|
| 1360 | + break; |
|
| 1361 | + } |
|
| 1316 | 1362 | |
| 1317 | 1363 | // Still a block tag was open not equal to this tag. |
| 1318 | 1364 | $addClosingTags[] = $element['type']; |
| 1319 | 1365 | } |
| 1320 | 1366 | |
| 1321 | - if (!empty($addClosingTags)) |
|
| 1322 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1367 | + if (!empty($addClosingTags)) { |
|
| 1368 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1369 | + } |
|
| 1323 | 1370 | |
| 1324 | 1371 | // Apparently the closing tag was not found on the stack. |
| 1325 | 1372 | if (!is_string($element) || $element !== $tag) |
@@ -1329,8 +1376,7 @@ discard block |
||
| 1329 | 1376 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
| 1330 | 1377 | continue; |
| 1331 | 1378 | } |
| 1332 | - } |
|
| 1333 | - else |
|
| 1379 | + } else |
|
| 1334 | 1380 | { |
| 1335 | 1381 | // Get rid of this closing tag! |
| 1336 | 1382 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1359,53 +1405,62 @@ discard block |
||
| 1359 | 1405 | unset($inlineElements[$tagContentToBeClosed]); |
| 1360 | 1406 | |
| 1361 | 1407 | // Was this the tag we were looking for? |
| 1362 | - if ($tagToBeClosed === $tag) |
|
| 1363 | - break; |
|
| 1408 | + if ($tagToBeClosed === $tag) { |
|
| 1409 | + break; |
|
| 1410 | + } |
|
| 1364 | 1411 | |
| 1365 | 1412 | // Nope, close it and look further! |
| 1366 | - else |
|
| 1367 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1413 | + else { |
|
| 1414 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1415 | + } |
|
| 1368 | 1416 | } |
| 1369 | 1417 | |
| 1370 | 1418 | if ($isCompetingTag && !empty($competingElements[$tag])) |
| 1371 | 1419 | { |
| 1372 | 1420 | array_pop($competingElements[$tag]); |
| 1373 | 1421 | |
| 1374 | - if (count($competingElements[$tag]) > 0) |
|
| 1375 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1422 | + if (count($competingElements[$tag]) > 0) { |
|
| 1423 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1424 | + } |
|
| 1376 | 1425 | } |
| 1377 | 1426 | } |
| 1378 | 1427 | |
| 1379 | 1428 | // Unexpected closing tag, ex-ter-mi-nate. |
| 1380 | - else |
|
| 1381 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1429 | + else { |
|
| 1430 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1431 | + } |
|
| 1382 | 1432 | } |
| 1383 | 1433 | } |
| 1384 | 1434 | } |
| 1385 | 1435 | |
| 1386 | 1436 | // Close the code tags. |
| 1387 | - if ($inCode) |
|
| 1388 | - $parts[$i] .= '[/code]'; |
|
| 1437 | + if ($inCode) { |
|
| 1438 | + $parts[$i] .= '[/code]'; |
|
| 1439 | + } |
|
| 1389 | 1440 | |
| 1390 | 1441 | // The same for nobbc tags. |
| 1391 | - elseif ($inNoBbc) |
|
| 1392 | - $parts[$i] .= '[/nobbc]'; |
|
| 1442 | + elseif ($inNoBbc) { |
|
| 1443 | + $parts[$i] .= '[/nobbc]'; |
|
| 1444 | + } |
|
| 1393 | 1445 | |
| 1394 | 1446 | // Still inline tags left unclosed? Close them now, better late than never. |
| 1395 | - elseif (!empty($inlineElements)) |
|
| 1396 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1447 | + elseif (!empty($inlineElements)) { |
|
| 1448 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1449 | + } |
|
| 1397 | 1450 | |
| 1398 | 1451 | // Now close the block elements. |
| 1399 | - if (!empty($blockElements)) |
|
| 1400 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1452 | + if (!empty($blockElements)) { |
|
| 1453 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1454 | + } |
|
| 1401 | 1455 | |
| 1402 | 1456 | $text = implode('', $parts); |
| 1403 | 1457 | } |
| 1404 | 1458 | |
| 1405 | 1459 | // Final clean up of back to back tags. |
| 1406 | 1460 | $lastlen = 0; |
| 1407 | - while (strlen($text) !== $lastlen) |
|
| 1408 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1461 | + while (strlen($text) !== $lastlen) { |
|
| 1462 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1463 | + } |
|
| 1409 | 1464 | |
| 1410 | 1465 | return $text; |
| 1411 | 1466 | } |
@@ -1434,22 +1489,25 @@ discard block |
||
| 1434 | 1489 | $context['template_layers'] = array(); |
| 1435 | 1490 | // Lets make sure we aren't going to output anything nasty. |
| 1436 | 1491 | @ob_end_clean(); |
| 1437 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 1438 | - @ob_start('ob_gzhandler'); |
|
| 1439 | - else |
|
| 1440 | - @ob_start(); |
|
| 1492 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 1493 | + @ob_start('ob_gzhandler'); |
|
| 1494 | + } else { |
|
| 1495 | + @ob_start(); |
|
| 1496 | + } |
|
| 1441 | 1497 | |
| 1442 | 1498 | // If we don't have any locale better avoid broken js |
| 1443 | - if (empty($txt['lang_locale'])) |
|
| 1444 | - die(); |
|
| 1499 | + if (empty($txt['lang_locale'])) { |
|
| 1500 | + die(); |
|
| 1501 | + } |
|
| 1445 | 1502 | |
| 1446 | 1503 | $file_data = '(function ($) { |
| 1447 | 1504 | \'use strict\'; |
| 1448 | 1505 | |
| 1449 | 1506 | $.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {'; |
| 1450 | - foreach ($editortxt as $key => $val) |
|
| 1451 | - $file_data .= ' |
|
| 1507 | + foreach ($editortxt as $key => $val) { |
|
| 1508 | + $file_data .= ' |
|
| 1452 | 1509 | ' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ','; |
| 1510 | + } |
|
| 1453 | 1511 | |
| 1454 | 1512 | $file_data .= ' |
| 1455 | 1513 | dateFormat: "day.month.year" |
@@ -1517,8 +1575,9 @@ discard block |
||
| 1517 | 1575 | ) |
| 1518 | 1576 | ); |
| 1519 | 1577 | $icon_data = array(); |
| 1520 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1521 | - $icon_data[] = $row; |
|
| 1578 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1579 | + $icon_data[] = $row; |
|
| 1580 | + } |
|
| 1522 | 1581 | $smcFunc['db_free_result']($request); |
| 1523 | 1582 | |
| 1524 | 1583 | $icons = array(); |
@@ -1533,9 +1592,9 @@ discard block |
||
| 1533 | 1592 | } |
| 1534 | 1593 | |
| 1535 | 1594 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
| 1595 | + } else { |
|
| 1596 | + $icons = $temp; |
|
| 1536 | 1597 | } |
| 1537 | - else |
|
| 1538 | - $icons = $temp; |
|
| 1539 | 1598 | } |
| 1540 | 1599 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
| 1541 | 1600 | |
@@ -1577,8 +1636,9 @@ discard block |
||
| 1577 | 1636 | { |
| 1578 | 1637 | // Some general stuff. |
| 1579 | 1638 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
| 1580 | - if (!empty($context['drafts_autosave'])) |
|
| 1581 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1639 | + if (!empty($context['drafts_autosave'])) { |
|
| 1640 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1641 | + } |
|
| 1582 | 1642 | |
| 1583 | 1643 | // This really has some WYSIWYG stuff. |
| 1584 | 1644 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1596,8 +1656,9 @@ discard block |
||
| 1596 | 1656 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
| 1597 | 1657 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
| 1598 | 1658 | // editor language file |
| 1599 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
| 1600 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1659 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
| 1660 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1661 | + } |
|
| 1601 | 1662 | |
| 1602 | 1663 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))]; |
| 1603 | 1664 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1606,11 +1667,12 @@ discard block |
||
| 1606 | 1667 | loadJavaScriptFile('spellcheck.js', array('minimize' => true), 'smf_spellcheck'); |
| 1607 | 1668 | |
| 1608 | 1669 | // Some hidden information is needed in order to make the spell checking work. |
| 1609 | - if (!isset($_REQUEST['xml'])) |
|
| 1610 | - $context['insert_after_template'] .= ' |
|
| 1670 | + if (!isset($_REQUEST['xml'])) { |
|
| 1671 | + $context['insert_after_template'] .= ' |
|
| 1611 | 1672 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
| 1612 | 1673 | <input type="hidden" name="spellstring" value=""> |
| 1613 | 1674 | </form>'; |
| 1675 | + } |
|
| 1614 | 1676 | } |
| 1615 | 1677 | } |
| 1616 | 1678 | |
@@ -1802,10 +1864,12 @@ discard block |
||
| 1802 | 1864 | |
| 1803 | 1865 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
| 1804 | 1866 | $disabled_tags = array(); |
| 1805 | - if (!empty($modSettings['disabledBBC'])) |
|
| 1806 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1807 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1808 | - $disabled_tags[] = 'flash'; |
|
| 1867 | + if (!empty($modSettings['disabledBBC'])) { |
|
| 1868 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1869 | + } |
|
| 1870 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1871 | + $disabled_tags[] = 'flash'; |
|
| 1872 | + } |
|
| 1809 | 1873 | |
| 1810 | 1874 | foreach ($disabled_tags as $tag) |
| 1811 | 1875 | { |
@@ -1817,9 +1881,10 @@ discard block |
||
| 1817 | 1881 | $context['disabled_tags']['orderedlist'] = true; |
| 1818 | 1882 | } |
| 1819 | 1883 | |
| 1820 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
| 1821 | - if ($tag === $thisTag) |
|
| 1884 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
| 1885 | + if ($tag === $thisTag) |
|
| 1822 | 1886 | $context['disabled_tags'][$tagNameBBC] = true; |
| 1887 | + } |
|
| 1823 | 1888 | |
| 1824 | 1889 | $context['disabled_tags'][$tag] = true; |
| 1825 | 1890 | } |
@@ -1830,8 +1895,9 @@ discard block |
||
| 1830 | 1895 | |
| 1831 | 1896 | foreach ($context['bbc_tags'] as $row => $tagRow) |
| 1832 | 1897 | { |
| 1833 | - if (!isset($context['bbc_toolbar'][$row])) |
|
| 1834 | - $context['bbc_toolbar'][$row] = array(); |
|
| 1898 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
| 1899 | + $context['bbc_toolbar'][$row] = array(); |
|
| 1900 | + } |
|
| 1835 | 1901 | |
| 1836 | 1902 | $tagsRow = array(); |
| 1837 | 1903 | |
@@ -1867,20 +1933,21 @@ discard block |
||
| 1867 | 1933 | |
| 1868 | 1934 | $context['bbcodes_handlers'] .= ' |
| 1869 | 1935 | });'; |
| 1870 | - } |
|
| 1871 | - else |
|
| 1936 | + } else |
|
| 1872 | 1937 | { |
| 1873 | 1938 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1874 | 1939 | $tagsRow = array(); |
| 1875 | 1940 | } |
| 1876 | 1941 | } |
| 1877 | 1942 | |
| 1878 | - if (!empty($tagsRow)) |
|
| 1879 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1943 | + if (!empty($tagsRow)) { |
|
| 1944 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1945 | + } |
|
| 1880 | 1946 | } |
| 1881 | 1947 | |
| 1882 | - if (!empty($bbcodes_styles)) |
|
| 1883 | - addInlineCss($bbcodes_styles); |
|
| 1948 | + if (!empty($bbcodes_styles)) { |
|
| 1949 | + addInlineCss($bbcodes_styles); |
|
| 1950 | + } |
|
| 1884 | 1951 | } |
| 1885 | 1952 | |
| 1886 | 1953 | // Initialize smiley array... if not loaded before. |
@@ -1892,8 +1959,8 @@ discard block |
||
| 1892 | 1959 | ); |
| 1893 | 1960 | |
| 1894 | 1961 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
| 1895 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
| 1896 | - $context['smileys']['postform'][] = array( |
|
| 1962 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
| 1963 | + $context['smileys']['postform'][] = array( |
|
| 1897 | 1964 | 'smileys' => array( |
| 1898 | 1965 | array( |
| 1899 | 1966 | 'code' => ':)', |
@@ -1979,7 +2046,7 @@ discard block |
||
| 1979 | 2046 | ), |
| 1980 | 2047 | 'isLast' => true, |
| 1981 | 2048 | ); |
| 1982 | - elseif ($user_info['smiley_set'] != 'none') |
|
| 2049 | + } elseif ($user_info['smiley_set'] != 'none') |
|
| 1983 | 2050 | { |
| 1984 | 2051 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
| 1985 | 2052 | { |
@@ -2002,17 +2069,19 @@ discard block |
||
| 2002 | 2069 | |
| 2003 | 2070 | foreach ($context['smileys'] as $section => $smileyRows) |
| 2004 | 2071 | { |
| 2005 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
| 2006 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2072 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
| 2073 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2074 | + } |
|
| 2007 | 2075 | |
| 2008 | - if (!empty($smileyRows)) |
|
| 2009 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2076 | + if (!empty($smileyRows)) { |
|
| 2077 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2078 | + } |
|
| 2010 | 2079 | } |
| 2011 | 2080 | |
| 2012 | 2081 | cache_put_data('posting_smileys', $context['smileys'], 480); |
| 2082 | + } else { |
|
| 2083 | + $context['smileys'] = $temp; |
|
| 2013 | 2084 | } |
| 2014 | - else |
|
| 2015 | - $context['smileys'] = $temp; |
|
| 2016 | 2085 | } |
| 2017 | 2086 | } |
| 2018 | 2087 | |
@@ -2028,12 +2097,15 @@ discard block |
||
| 2028 | 2097 | 'plugins' => 'undo', |
| 2029 | 2098 | 'bbcodeTrim' => true, |
| 2030 | 2099 | ); |
| 2031 | - if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) |
|
| 2032 | - $sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale']; |
|
| 2033 | - if (!empty($context['right_to_left'])) |
|
| 2034 | - $sce_options['rtl'] = true; |
|
| 2035 | - if ($editorOptions['id'] != 'quickReply') |
|
| 2036 | - $sce_options['autofocus'] = true; |
|
| 2100 | + if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) { |
|
| 2101 | + $sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale']; |
|
| 2102 | + } |
|
| 2103 | + if (!empty($context['right_to_left'])) { |
|
| 2104 | + $sce_options['rtl'] = true; |
|
| 2105 | + } |
|
| 2106 | + if ($editorOptions['id'] != 'quickReply') { |
|
| 2107 | + $sce_options['autofocus'] = true; |
|
| 2108 | + } |
|
| 2037 | 2109 | |
| 2038 | 2110 | $sce_options['emoticons'] = array(); |
| 2039 | 2111 | $sce_options['emoticonsDescriptions'] = array(); |
@@ -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 | |
@@ -2067,8 +2140,9 @@ discard block |
||
| 2067 | 2140 | $sce_options['emoticonsDescriptions'][$smiley['code']] = $smiley['description']; |
| 2068 | 2141 | } |
| 2069 | 2142 | |
| 2070 | - if (empty($smileyRow['isLast']) && $numRows != 1) |
|
| 2071 | - $smiley_location['-' . $emptyPlaceholder++] = ''; |
|
| 2143 | + if (empty($smileyRow['isLast']) && $numRows != 1) { |
|
| 2144 | + $smiley_location['-' . $emptyPlaceholder++] = ''; |
|
| 2145 | + } |
|
| 2072 | 2146 | } |
| 2073 | 2147 | } |
| 2074 | 2148 | } |
@@ -2083,8 +2157,9 @@ discard block |
||
| 2083 | 2157 | |
| 2084 | 2158 | $count_tags--; |
| 2085 | 2159 | |
| 2086 | - if (!empty($count_tags)) |
|
| 2087 | - $sce_options['toolbar'] .= '||'; |
|
| 2160 | + if (!empty($count_tags)) { |
|
| 2161 | + $sce_options['toolbar'] .= '||'; |
|
| 2162 | + } |
|
| 2088 | 2163 | } |
| 2089 | 2164 | } |
| 2090 | 2165 | |
@@ -2112,8 +2187,9 @@ discard block |
||
| 2112 | 2187 | loadTemplate('GenericControls'); |
| 2113 | 2188 | |
| 2114 | 2189 | // Some javascript ma'am? |
| 2115 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
| 2116 | - loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha'); |
|
| 2190 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
| 2191 | + loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha'); |
|
| 2192 | + } |
|
| 2117 | 2193 | |
| 2118 | 2194 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
| 2119 | 2195 | |
@@ -2126,8 +2202,8 @@ discard block |
||
| 2126 | 2202 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
| 2127 | 2203 | |
| 2128 | 2204 | // Log this into our collection. |
| 2129 | - if ($isNew) |
|
| 2130 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2205 | + if ($isNew) { |
|
| 2206 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2131 | 2207 | 'id' => $verificationOptions['id'], |
| 2132 | 2208 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
| 2133 | 2209 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2138,13 +2214,15 @@ discard block |
||
| 2138 | 2214 | 'questions' => array(), |
| 2139 | 2215 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
| 2140 | 2216 | ); |
| 2217 | + } |
|
| 2141 | 2218 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
| 2142 | 2219 | |
| 2143 | 2220 | // Is there actually going to be anything? |
| 2144 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
| 2145 | - return false; |
|
| 2146 | - elseif (!$isNew && !$do_test) |
|
| 2147 | - return true; |
|
| 2221 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
| 2222 | + return false; |
|
| 2223 | + } elseif (!$isNew && !$do_test) { |
|
| 2224 | + return true; |
|
| 2225 | + } |
|
| 2148 | 2226 | |
| 2149 | 2227 | // Sanitize reCAPTCHA fields? |
| 2150 | 2228 | if ($thisVerification['can_recaptcha']) |
@@ -2157,11 +2235,12 @@ discard block |
||
| 2157 | 2235 | } |
| 2158 | 2236 | |
| 2159 | 2237 | // Add javascript for the object. |
| 2160 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
| 2161 | - $context['insert_after_template'] .= ' |
|
| 2238 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
| 2239 | + $context['insert_after_template'] .= ' |
|
| 2162 | 2240 | <script> |
| 2163 | 2241 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
| 2164 | 2242 | </script>'; |
| 2243 | + } |
|
| 2165 | 2244 | |
| 2166 | 2245 | // If we want questions do we have a cache of all the IDs? |
| 2167 | 2246 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2184,8 +2263,9 @@ discard block |
||
| 2184 | 2263 | unset ($row['id_question']); |
| 2185 | 2264 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
| 2186 | 2265 | $row['answers'] = $smcFunc['json_decode']($row['answers'], true); |
| 2187 | - foreach ($row['answers'] as $k => $v) |
|
| 2188 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2266 | + foreach ($row['answers'] as $k => $v) { |
|
| 2267 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2268 | + } |
|
| 2189 | 2269 | |
| 2190 | 2270 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
| 2191 | 2271 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2196,35 +2276,42 @@ discard block |
||
| 2196 | 2276 | } |
| 2197 | 2277 | } |
| 2198 | 2278 | |
| 2199 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
| 2200 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2279 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
| 2280 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2281 | + } |
|
| 2201 | 2282 | |
| 2202 | 2283 | // Do we need to refresh the verification? |
| 2203 | - 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'])) |
|
| 2204 | - $force_refresh = true; |
|
| 2205 | - else |
|
| 2206 | - $force_refresh = false; |
|
| 2284 | + 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'])) { |
|
| 2285 | + $force_refresh = true; |
|
| 2286 | + } else { |
|
| 2287 | + $force_refresh = false; |
|
| 2288 | + } |
|
| 2207 | 2289 | |
| 2208 | 2290 | // This can also force a fresh, although unlikely. |
| 2209 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2210 | - $force_refresh = true; |
|
| 2291 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2292 | + $force_refresh = true; |
|
| 2293 | + } |
|
| 2211 | 2294 | |
| 2212 | 2295 | $verification_errors = array(); |
| 2213 | 2296 | // Start with any testing. |
| 2214 | 2297 | if ($do_test) |
| 2215 | 2298 | { |
| 2216 | 2299 | // This cannot happen! |
| 2217 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
| 2218 | - fatal_lang_error('no_access', false); |
|
| 2300 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
| 2301 | + fatal_lang_error('no_access', false); |
|
| 2302 | + } |
|
| 2219 | 2303 | // ... nor this! |
| 2220 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2221 | - fatal_lang_error('no_access', false); |
|
| 2304 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2305 | + fatal_lang_error('no_access', false); |
|
| 2306 | + } |
|
| 2222 | 2307 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
| 2223 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
| 2224 | - fatal_lang_error('no_access', false); |
|
| 2308 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
| 2309 | + fatal_lang_error('no_access', false); |
|
| 2310 | + } |
|
| 2225 | 2311 | // While we're here, did the user do something bad? |
| 2226 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
| 2227 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2312 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
| 2313 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2314 | + } |
|
| 2228 | 2315 | |
| 2229 | 2316 | if ($thisVerification['can_recaptcha']) |
| 2230 | 2317 | { |
@@ -2235,22 +2322,25 @@ discard block |
||
| 2235 | 2322 | { |
| 2236 | 2323 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
| 2237 | 2324 | |
| 2238 | - if (!$resp->isSuccess()) |
|
| 2239 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2325 | + if (!$resp->isSuccess()) { |
|
| 2326 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2327 | + } |
|
| 2328 | + } else { |
|
| 2329 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2240 | 2330 | } |
| 2241 | - else |
|
| 2242 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2243 | 2331 | } |
| 2244 | - 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'])) |
|
| 2245 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2332 | + 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'])) { |
|
| 2333 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2334 | + } |
|
| 2246 | 2335 | if ($thisVerification['number_questions']) |
| 2247 | 2336 | { |
| 2248 | 2337 | $incorrectQuestions = array(); |
| 2249 | 2338 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
| 2250 | 2339 | { |
| 2251 | 2340 | // We don't have this question any more, thus no answers. |
| 2252 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
| 2253 | - continue; |
|
| 2341 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
| 2342 | + continue; |
|
| 2343 | + } |
|
| 2254 | 2344 | // This is quite complex. We have our question but it might have multiple answers. |
| 2255 | 2345 | // First, did they actually answer this question? |
| 2256 | 2346 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2262,24 +2352,28 @@ discard block |
||
| 2262 | 2352 | else |
| 2263 | 2353 | { |
| 2264 | 2354 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
| 2265 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
| 2266 | - $incorrectQuestions[] = $q; |
|
| 2355 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
| 2356 | + $incorrectQuestions[] = $q; |
|
| 2357 | + } |
|
| 2267 | 2358 | } |
| 2268 | 2359 | } |
| 2269 | 2360 | |
| 2270 | - if (!empty($incorrectQuestions)) |
|
| 2271 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2361 | + if (!empty($incorrectQuestions)) { |
|
| 2362 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2363 | + } |
|
| 2272 | 2364 | } |
| 2273 | 2365 | } |
| 2274 | 2366 | |
| 2275 | 2367 | // Any errors means we refresh potentially. |
| 2276 | 2368 | if (!empty($verification_errors)) |
| 2277 | 2369 | { |
| 2278 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
| 2279 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2370 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
| 2371 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2372 | + } |
|
| 2280 | 2373 | // Too many errors? |
| 2281 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
| 2282 | - $force_refresh = true; |
|
| 2374 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
| 2375 | + $force_refresh = true; |
|
| 2376 | + } |
|
| 2283 | 2377 | |
| 2284 | 2378 | // Keep a track of these. |
| 2285 | 2379 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2312,8 +2406,9 @@ discard block |
||
| 2312 | 2406 | // Are we overriding the range? |
| 2313 | 2407 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
| 2314 | 2408 | |
| 2315 | - for ($i = 0; $i < 6; $i++) |
|
| 2316 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2409 | + for ($i = 0; $i < 6; $i++) { |
|
| 2410 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2411 | + } |
|
| 2317 | 2412 | } |
| 2318 | 2413 | |
| 2319 | 2414 | // Getting some new questions? |
@@ -2321,8 +2416,9 @@ discard block |
||
| 2321 | 2416 | { |
| 2322 | 2417 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
| 2323 | 2418 | $possible_langs = array(); |
| 2324 | - if (isset($_SESSION['language'])) |
|
| 2325 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2419 | + if (isset($_SESSION['language'])) { |
|
| 2420 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2421 | + } |
|
| 2326 | 2422 | if (!empty($user_info['language'])); |
| 2327 | 2423 | $possible_langs[] = $user_info['language']; |
| 2328 | 2424 | $possible_langs[] = $language; |
@@ -2341,8 +2437,7 @@ discard block |
||
| 2341 | 2437 | } |
| 2342 | 2438 | } |
| 2343 | 2439 | } |
| 2344 | - } |
|
| 2345 | - else |
|
| 2440 | + } else |
|
| 2346 | 2441 | { |
| 2347 | 2442 | // Same questions as before. |
| 2348 | 2443 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2352,8 +2447,9 @@ discard block |
||
| 2352 | 2447 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
| 2353 | 2448 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
| 2354 | 2449 | { |
| 2355 | - if (!isset($context['html_headers'])) |
|
| 2356 | - $context['html_headers'] = ''; |
|
| 2450 | + if (!isset($context['html_headers'])) { |
|
| 2451 | + $context['html_headers'] = ''; |
|
| 2452 | + } |
|
| 2357 | 2453 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
| 2358 | 2454 | } |
| 2359 | 2455 | |
@@ -2379,11 +2475,13 @@ discard block |
||
| 2379 | 2475 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
| 2380 | 2476 | |
| 2381 | 2477 | // Return errors if we have them. |
| 2382 | - if (!empty($verification_errors)) |
|
| 2383 | - return $verification_errors; |
|
| 2478 | + if (!empty($verification_errors)) { |
|
| 2479 | + return $verification_errors; |
|
| 2480 | + } |
|
| 2384 | 2481 | // If we had a test that one, make a note. |
| 2385 | - elseif ($do_test) |
|
| 2386 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2482 | + elseif ($do_test) { |
|
| 2483 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2484 | + } |
|
| 2387 | 2485 | |
| 2388 | 2486 | // Say that everything went well chaps. |
| 2389 | 2487 | return true; |
@@ -2408,8 +2506,9 @@ discard block |
||
| 2408 | 2506 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
| 2409 | 2507 | |
| 2410 | 2508 | // If we're just checking the callback function is registered return true or false. |
| 2411 | - if ($checkRegistered != null) |
|
| 2412 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2509 | + if ($checkRegistered != null) { |
|
| 2510 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2511 | + } |
|
| 2413 | 2512 | |
| 2414 | 2513 | checkSession('get'); |
| 2415 | 2514 | loadTemplate('Xml'); |
@@ -2560,24 +2659,27 @@ discard block |
||
| 2560 | 2659 | foreach ($possible_versions as $ver) |
| 2561 | 2660 | { |
| 2562 | 2661 | $ver = trim($ver); |
| 2563 | - if (strpos($ver, 'SMF') === 0) |
|
| 2564 | - $versions[] = $ver; |
|
| 2662 | + if (strpos($ver, 'SMF') === 0) { |
|
| 2663 | + $versions[] = $ver; |
|
| 2664 | + } |
|
| 2565 | 2665 | } |
| 2566 | 2666 | } |
| 2567 | 2667 | $smcFunc['db_free_result']($request); |
| 2568 | 2668 | |
| 2569 | 2669 | // Just in case we don't have ANYthing. |
| 2570 | - if (empty($versions)) |
|
| 2571 | - $versions = array('SMF 2.0'); |
|
| 2670 | + if (empty($versions)) { |
|
| 2671 | + $versions = array('SMF 2.0'); |
|
| 2672 | + } |
|
| 2572 | 2673 | |
| 2573 | - foreach ($versions as $id => $version) |
|
| 2574 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2674 | + foreach ($versions as $id => $version) { |
|
| 2675 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2575 | 2676 | $xml_data['items']['children'][] = array( |
| 2576 | 2677 | 'attributes' => array( |
| 2577 | 2678 | 'id' => $id, |
| 2578 | 2679 | ), |
| 2579 | 2680 | 'value' => $version, |
| 2580 | 2681 | ); |
| 2682 | + } |
|
| 2581 | 2683 | |
| 2582 | 2684 | return $xml_data; |
| 2583 | 2685 | } |