@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
| 12 | 12 | header('Location: ' . $boardurl); |
| 13 | 13 | } |
| 14 | 14 | // Can't find it... just forget it. |
| 15 | -else |
|
| 15 | +else { |
|
| 16 | 16 | exit; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | ?> |
| 19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
| 12 | 12 | header('Location: ' . $boardurl); |
| 13 | 13 | } |
| 14 | 14 | // Can't find it... just forget it. |
| 15 | -else |
|
| 15 | +else { |
|
| 16 | 16 | exit; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | ?> |
| 19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
| 12 | 12 | header('Location: ' . $boardurl); |
| 13 | 13 | } |
| 14 | 14 | // Can't find it... just forget it. |
| 15 | -else |
|
| 15 | +else { |
|
| 16 | 16 | exit; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | ?> |
| 19 | 20 | \ No newline at end of file |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * !!!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) |
@@ -382,8 +396,7 @@ discard block |
||
| 382 | 396 | |
| 383 | 397 | // Put the tags back into the body. |
| 384 | 398 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
| 385 | - } |
|
| 386 | - else |
|
| 399 | + } else |
|
| 387 | 400 | { |
| 388 | 401 | // Just get rid of this evil tag. |
| 389 | 402 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -396,8 +409,9 @@ discard block |
||
| 396 | 409 | // Find the position of this again. |
| 397 | 410 | $start_pos = strpos($text, $matches[0]); |
| 398 | 411 | $end_pos = false; |
| 399 | - if ($start_pos === false) |
|
| 400 | - break; |
|
| 412 | + if ($start_pos === false) { |
|
| 413 | + break; |
|
| 414 | + } |
|
| 401 | 415 | |
| 402 | 416 | // This must have an end tag - and we must find the right one. |
| 403 | 417 | $lower_text = strtolower($text); |
@@ -430,8 +444,9 @@ discard block |
||
| 430 | 444 | break; |
| 431 | 445 | } |
| 432 | 446 | } |
| 433 | - if ($end_pos === false) |
|
| 434 | - break; |
|
| 447 | + if ($end_pos === false) { |
|
| 448 | + break; |
|
| 449 | + } |
|
| 435 | 450 | |
| 436 | 451 | // Now work out what the attributes are. |
| 437 | 452 | $attribs = fetchTagAttributes($matches[1]); |
@@ -445,11 +460,11 @@ discard block |
||
| 445 | 460 | $v = (int) trim($v); |
| 446 | 461 | $v = empty($v) ? 1 : $v; |
| 447 | 462 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
| 463 | + } elseif ($s == 'face') { |
|
| 464 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
| 465 | + } elseif ($s == 'color') { |
|
| 466 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
| 448 | 467 | } |
| 449 | - elseif ($s == 'face') |
|
| 450 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
| 451 | - elseif ($s == 'color') |
|
| 452 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
| 453 | 468 | } |
| 454 | 469 | |
| 455 | 470 | // As before add in our tags. |
@@ -457,8 +472,9 @@ discard block |
||
| 457 | 472 | foreach ($tags as $tag) |
| 458 | 473 | { |
| 459 | 474 | $before .= $tag[0]; |
| 460 | - if (isset($tag[1])) |
|
| 461 | - $after = $tag[1] . $after; |
|
| 475 | + if (isset($tag[1])) { |
|
| 476 | + $after = $tag[1] . $after; |
|
| 477 | + } |
|
| 462 | 478 | } |
| 463 | 479 | |
| 464 | 480 | // Remove the tag so it's never checked again. |
@@ -469,8 +485,9 @@ discard block |
||
| 469 | 485 | } |
| 470 | 486 | |
| 471 | 487 | // Almost there, just a little more time. |
| 472 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 473 | - @apache_reset_timeout(); |
|
| 488 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 489 | + @apache_reset_timeout(); |
|
| 490 | + } |
|
| 474 | 491 | |
| 475 | 492 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
| 476 | 493 | { |
@@ -526,12 +543,13 @@ discard block |
||
| 526 | 543 | { |
| 527 | 544 | $inList = true; |
| 528 | 545 | |
| 529 | - if ($tag === 'ol') |
|
| 530 | - $listType = 'decimal'; |
|
| 531 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
| 532 | - $listType = $listTypeMapping[$match[1]]; |
|
| 533 | - else |
|
| 534 | - $listType = null; |
|
| 546 | + if ($tag === 'ol') { |
|
| 547 | + $listType = 'decimal'; |
|
| 548 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
| 549 | + $listType = $listTypeMapping[$match[1]]; |
|
| 550 | + } else { |
|
| 551 | + $listType = null; |
|
| 552 | + } |
|
| 535 | 553 | |
| 536 | 554 | $listDepth++; |
| 537 | 555 | |
@@ -595,9 +613,7 @@ discard block |
||
| 595 | 613 | $parts[$i + 1] = ''; |
| 596 | 614 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
| 597 | 615 | $parts[$i + 3] = ''; |
| 598 | - } |
|
| 599 | - |
|
| 600 | - else |
|
| 616 | + } else |
|
| 601 | 617 | { |
| 602 | 618 | // We're in a list item. |
| 603 | 619 | if ($listDepth > 0) |
@@ -634,9 +650,7 @@ discard block |
||
| 634 | 650 | $parts[$i + 1] = ''; |
| 635 | 651 | $parts[$i + 2] = ''; |
| 636 | 652 | $parts[$i + 3] = ''; |
| 637 | - } |
|
| 638 | - |
|
| 639 | - else |
|
| 653 | + } else |
|
| 640 | 654 | { |
| 641 | 655 | // Remove the trailing breaks from the list item. |
| 642 | 656 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -674,8 +688,9 @@ discard block |
||
| 674 | 688 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
| 675 | 689 | } |
| 676 | 690 | |
| 677 | - for ($i = $listDepth; $i > 0; $i--) |
|
| 678 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
| 691 | + for ($i = $listDepth; $i > 0; $i--) { |
|
| 692 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
| 693 | + } |
|
| 679 | 694 | |
| 680 | 695 | } |
| 681 | 696 | |
@@ -684,8 +699,9 @@ discard block |
||
| 684 | 699 | { |
| 685 | 700 | // Find the position of the image. |
| 686 | 701 | $start_pos = strpos($text, $matches[0]); |
| 687 | - if ($start_pos === false) |
|
| 688 | - break; |
|
| 702 | + if ($start_pos === false) { |
|
| 703 | + break; |
|
| 704 | + } |
|
| 689 | 705 | $end_pos = $start_pos + strlen($matches[0]); |
| 690 | 706 | |
| 691 | 707 | $params = ''; |
@@ -695,12 +711,13 @@ discard block |
||
| 695 | 711 | $attrs = fetchTagAttributes($matches[1]); |
| 696 | 712 | foreach ($attrs as $attrib => $value) |
| 697 | 713 | { |
| 698 | - if (in_array($attrib, array('width', 'height'))) |
|
| 699 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 700 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
| 701 | - $params .= ' alt=' . trim($value); |
|
| 702 | - elseif ($attrib == 'src') |
|
| 703 | - $src = trim($value); |
|
| 714 | + if (in_array($attrib, array('width', 'height'))) { |
|
| 715 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 716 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
| 717 | + $params .= ' alt=' . trim($value); |
|
| 718 | + } elseif ($attrib == 'src') { |
|
| 719 | + $src = trim($value); |
|
| 720 | + } |
|
| 704 | 721 | } |
| 705 | 722 | |
| 706 | 723 | $tag = ''; |
@@ -711,10 +728,11 @@ discard block |
||
| 711 | 728 | { |
| 712 | 729 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 713 | 730 | |
| 714 | - if (substr($src, 0, 1) === '/') |
|
| 715 | - $src = $baseURL . $src; |
|
| 716 | - else |
|
| 717 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 731 | + if (substr($src, 0, 1) === '/') { |
|
| 732 | + $src = $baseURL . $src; |
|
| 733 | + } else { |
|
| 734 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 735 | + } |
|
| 718 | 736 | } |
| 719 | 737 | |
| 720 | 738 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -892,20 +910,23 @@ discard block |
||
| 892 | 910 | }, |
| 893 | 911 | ); |
| 894 | 912 | |
| 895 | - foreach ($tags as $tag => $replace) |
|
| 896 | - $text = preg_replace_callback($tag, $replace, $text); |
|
| 913 | + foreach ($tags as $tag => $replace) { |
|
| 914 | + $text = preg_replace_callback($tag, $replace, $text); |
|
| 915 | + } |
|
| 897 | 916 | |
| 898 | 917 | // Please give us just a little more time. |
| 899 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 900 | - @apache_reset_timeout(); |
|
| 918 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 919 | + @apache_reset_timeout(); |
|
| 920 | + } |
|
| 901 | 921 | |
| 902 | 922 | // What about URL's - the pain in the ass of the tag world. |
| 903 | 923 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
| 904 | 924 | { |
| 905 | 925 | // Find the position of the URL. |
| 906 | 926 | $start_pos = strpos($text, $matches[0]); |
| 907 | - if ($start_pos === false) |
|
| 908 | - break; |
|
| 927 | + if ($start_pos === false) { |
|
| 928 | + break; |
|
| 929 | + } |
|
| 909 | 930 | $end_pos = $start_pos + strlen($matches[0]); |
| 910 | 931 | |
| 911 | 932 | $tag_type = 'url'; |
@@ -919,8 +940,9 @@ discard block |
||
| 919 | 940 | $href = trim($value); |
| 920 | 941 | |
| 921 | 942 | // Are we dealing with an FTP link? |
| 922 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
| 923 | - $tag_type = 'ftp'; |
|
| 943 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
| 944 | + $tag_type = 'ftp'; |
|
| 945 | + } |
|
| 924 | 946 | |
| 925 | 947 | // Or is this a link to an email address? |
| 926 | 948 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -934,28 +956,31 @@ discard block |
||
| 934 | 956 | { |
| 935 | 957 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 936 | 958 | |
| 937 | - if (substr($href, 0, 1) === '/') |
|
| 938 | - $href = $baseURL . $href; |
|
| 939 | - else |
|
| 940 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 959 | + if (substr($href, 0, 1) === '/') { |
|
| 960 | + $href = $baseURL . $href; |
|
| 961 | + } else { |
|
| 962 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 963 | + } |
|
| 941 | 964 | } |
| 942 | 965 | } |
| 943 | 966 | |
| 944 | 967 | // External URL? |
| 945 | 968 | if ($attrib == 'target' && $tag_type == 'url') |
| 946 | 969 | { |
| 947 | - if (trim($value) == '_blank') |
|
| 948 | - $tag_type == 'iurl'; |
|
| 970 | + if (trim($value) == '_blank') { |
|
| 971 | + $tag_type == 'iurl'; |
|
| 972 | + } |
|
| 949 | 973 | } |
| 950 | 974 | } |
| 951 | 975 | |
| 952 | 976 | $tag = ''; |
| 953 | 977 | if ($href != '') |
| 954 | 978 | { |
| 955 | - if ($matches[2] == $href) |
|
| 956 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 957 | - else |
|
| 958 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 979 | + if ($matches[2] == $href) { |
|
| 980 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 981 | + } else { |
|
| 982 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 983 | + } |
|
| 959 | 984 | } |
| 960 | 985 | |
| 961 | 986 | // Replace the tag |
@@ -995,17 +1020,18 @@ discard block |
||
| 995 | 1020 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
| 996 | 1021 | if ($text[$i] == '=') |
| 997 | 1022 | { |
| 998 | - if ($tag_state == 0) |
|
| 999 | - $tag_state = 1; |
|
| 1000 | - elseif ($tag_state == 2) |
|
| 1001 | - $value .= '='; |
|
| 1023 | + if ($tag_state == 0) { |
|
| 1024 | + $tag_state = 1; |
|
| 1025 | + } elseif ($tag_state == 2) { |
|
| 1026 | + $value .= '='; |
|
| 1027 | + } |
|
| 1002 | 1028 | } |
| 1003 | 1029 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
| 1004 | 1030 | elseif ($text[$i] == ' ') |
| 1005 | 1031 | { |
| 1006 | - if ($tag_state == 2) |
|
| 1007 | - $value .= ' '; |
|
| 1008 | - elseif ($tag_state == 1) |
|
| 1032 | + if ($tag_state == 2) { |
|
| 1033 | + $value .= ' '; |
|
| 1034 | + } elseif ($tag_state == 1) |
|
| 1009 | 1035 | { |
| 1010 | 1036 | $attribs[$key] = $value; |
| 1011 | 1037 | $key = $value = ''; |
@@ -1016,24 +1042,27 @@ discard block |
||
| 1016 | 1042 | elseif ($text[$i] == '"') |
| 1017 | 1043 | { |
| 1018 | 1044 | // Must be either going into or out of a string. |
| 1019 | - if ($tag_state == 1) |
|
| 1020 | - $tag_state = 2; |
|
| 1021 | - else |
|
| 1022 | - $tag_state = 1; |
|
| 1045 | + if ($tag_state == 1) { |
|
| 1046 | + $tag_state = 2; |
|
| 1047 | + } else { |
|
| 1048 | + $tag_state = 1; |
|
| 1049 | + } |
|
| 1023 | 1050 | } |
| 1024 | 1051 | // Otherwise it's fine. |
| 1025 | 1052 | else |
| 1026 | 1053 | { |
| 1027 | - if ($tag_state == 0) |
|
| 1028 | - $key .= $text[$i]; |
|
| 1029 | - else |
|
| 1030 | - $value .= $text[$i]; |
|
| 1054 | + if ($tag_state == 0) { |
|
| 1055 | + $key .= $text[$i]; |
|
| 1056 | + } else { |
|
| 1057 | + $value .= $text[$i]; |
|
| 1058 | + } |
|
| 1031 | 1059 | } |
| 1032 | 1060 | } |
| 1033 | 1061 | |
| 1034 | 1062 | // Anything left? |
| 1035 | - if ($key != '' && $value != '') |
|
| 1036 | - $attribs[$key] = $value; |
|
| 1063 | + if ($key != '' && $value != '') { |
|
| 1064 | + $attribs[$key] = $value; |
|
| 1065 | + } |
|
| 1037 | 1066 | |
| 1038 | 1067 | return $attribs; |
| 1039 | 1068 | } |
@@ -1049,8 +1078,9 @@ discard block |
||
| 1049 | 1078 | global $modSettings; |
| 1050 | 1079 | |
| 1051 | 1080 | // Don't care about the texts that are too short. |
| 1052 | - if (strlen($text) < 3) |
|
| 1053 | - return $text; |
|
| 1081 | + if (strlen($text) < 3) { |
|
| 1082 | + return $text; |
|
| 1083 | + } |
|
| 1054 | 1084 | |
| 1055 | 1085 | // We are going to cycle through the BBC and keep track of tags as they arise - in order. If get to a block level tag we're going to make sure it's not in a non-block level tag! |
| 1056 | 1086 | // This will keep the order of tags that are open. |
@@ -1063,8 +1093,9 @@ discard block |
||
| 1063 | 1093 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
| 1064 | 1094 | |
| 1065 | 1095 | // Add flash if it's disabled as embedded tag. |
| 1066 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1067 | - $disabled['flash'] = true; |
|
| 1096 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1097 | + $disabled['flash'] = true; |
|
| 1098 | + } |
|
| 1068 | 1099 | |
| 1069 | 1100 | // Get a list of all the tags that are not disabled. |
| 1070 | 1101 | $all_tags = parse_bbc(false); |
@@ -1072,10 +1103,12 @@ discard block |
||
| 1072 | 1103 | $self_closing_tags = array(); |
| 1073 | 1104 | foreach ($all_tags as $tag) |
| 1074 | 1105 | { |
| 1075 | - if (!isset($disabled[$tag['tag']])) |
|
| 1076 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1077 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
| 1078 | - $self_closing_tags[] = $tag['tag']; |
|
| 1106 | + if (!isset($disabled[$tag['tag']])) { |
|
| 1107 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1108 | + } |
|
| 1109 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
| 1110 | + $self_closing_tags[] = $tag['tag']; |
|
| 1111 | + } |
|
| 1079 | 1112 | } |
| 1080 | 1113 | |
| 1081 | 1114 | // Don't worry if we're in a code/nobbc. |
@@ -1105,16 +1138,19 @@ discard block |
||
| 1105 | 1138 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
| 1106 | 1139 | |
| 1107 | 1140 | // We're closing the exact same tag that we opened. |
| 1108 | - if ($isClosingTag && $insideTag === $tagName) |
|
| 1109 | - $insideTag = null; |
|
| 1141 | + if ($isClosingTag && $insideTag === $tagName) { |
|
| 1142 | + $insideTag = null; |
|
| 1143 | + } |
|
| 1110 | 1144 | |
| 1111 | 1145 | // We're opening a tag and we're not yet inside one either |
| 1112 | - elseif (!$isClosingTag && $insideTag === null) |
|
| 1113 | - $insideTag = $tagName; |
|
| 1146 | + elseif (!$isClosingTag && $insideTag === null) { |
|
| 1147 | + $insideTag = $tagName; |
|
| 1148 | + } |
|
| 1114 | 1149 | |
| 1115 | 1150 | // In all other cases, this tag must be invalid |
| 1116 | - else |
|
| 1117 | - unset($matches[$i]); |
|
| 1151 | + else { |
|
| 1152 | + unset($matches[$i]); |
|
| 1153 | + } |
|
| 1118 | 1154 | } |
| 1119 | 1155 | |
| 1120 | 1156 | // The next one is gonna be the other one. |
@@ -1122,8 +1158,9 @@ discard block |
||
| 1122 | 1158 | } |
| 1123 | 1159 | |
| 1124 | 1160 | // We're still inside a tag and had no chance for closure? |
| 1125 | - if ($insideTag !== null) |
|
| 1126 | - $matches[] = '[/' . $insideTag . ']'; |
|
| 1161 | + if ($insideTag !== null) { |
|
| 1162 | + $matches[] = '[/' . $insideTag . ']'; |
|
| 1163 | + } |
|
| 1127 | 1164 | |
| 1128 | 1165 | // And a complete text string again. |
| 1129 | 1166 | $text = implode('', $matches); |
@@ -1132,8 +1169,9 @@ discard block |
||
| 1132 | 1169 | // Quickly remove any tags which are back to back. |
| 1133 | 1170 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
| 1134 | 1171 | $lastlen = 0; |
| 1135 | - while (strlen($text) !== $lastlen) |
|
| 1136 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1172 | + while (strlen($text) !== $lastlen) { |
|
| 1173 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1174 | + } |
|
| 1137 | 1175 | |
| 1138 | 1176 | // Need to sort the tags my name length. |
| 1139 | 1177 | uksort($valid_tags, 'sort_array_length'); |
@@ -1177,8 +1215,9 @@ discard block |
||
| 1177 | 1215 | $isCompetingTag = in_array($tag, $competing_tags); |
| 1178 | 1216 | |
| 1179 | 1217 | // Check if this might be one of those cleaned out tags. |
| 1180 | - if ($tag === '') |
|
| 1181 | - continue; |
|
| 1218 | + if ($tag === '') { |
|
| 1219 | + continue; |
|
| 1220 | + } |
|
| 1182 | 1221 | |
| 1183 | 1222 | // Special case: inside [code] blocks any code is left untouched. |
| 1184 | 1223 | elseif ($tag === 'code') |
@@ -1189,8 +1228,9 @@ discard block |
||
| 1189 | 1228 | $inCode = false; |
| 1190 | 1229 | |
| 1191 | 1230 | // Reopen tags that were closed before the code block. |
| 1192 | - if (!empty($inlineElements)) |
|
| 1193 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1231 | + if (!empty($inlineElements)) { |
|
| 1232 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1233 | + } |
|
| 1194 | 1234 | } |
| 1195 | 1235 | |
| 1196 | 1236 | // We're outside a coding and nobbc block and opening it. |
@@ -1219,8 +1259,9 @@ discard block |
||
| 1219 | 1259 | $inNoBbc = false; |
| 1220 | 1260 | |
| 1221 | 1261 | // Some inline elements might've been closed that need reopening. |
| 1222 | - if (!empty($inlineElements)) |
|
| 1223 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1262 | + if (!empty($inlineElements)) { |
|
| 1263 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1264 | + } |
|
| 1224 | 1265 | } |
| 1225 | 1266 | |
| 1226 | 1267 | // We're outside a nobbc and coding block and opening it. |
@@ -1240,8 +1281,9 @@ discard block |
||
| 1240 | 1281 | } |
| 1241 | 1282 | |
| 1242 | 1283 | // So, we're inside one of the special blocks: ignore any tag. |
| 1243 | - elseif ($inCode || $inNoBbc) |
|
| 1244 | - continue; |
|
| 1284 | + elseif ($inCode || $inNoBbc) { |
|
| 1285 | + continue; |
|
| 1286 | + } |
|
| 1245 | 1287 | |
| 1246 | 1288 | // We're dealing with an opening tag. |
| 1247 | 1289 | if ($isOpeningTag) |
@@ -1282,8 +1324,9 @@ discard block |
||
| 1282 | 1324 | if ($parts[$j + 3] === $tag) |
| 1283 | 1325 | { |
| 1284 | 1326 | // If it's an opening tag, increase the level. |
| 1285 | - if ($parts[$j + 2] === '') |
|
| 1286 | - $curLevel++; |
|
| 1327 | + if ($parts[$j + 2] === '') { |
|
| 1328 | + $curLevel++; |
|
| 1329 | + } |
|
| 1287 | 1330 | |
| 1288 | 1331 | // A closing tag, decrease the level. |
| 1289 | 1332 | else |
@@ -1306,13 +1349,15 @@ discard block |
||
| 1306 | 1349 | { |
| 1307 | 1350 | if ($isCompetingTag) |
| 1308 | 1351 | { |
| 1309 | - if (!isset($competingElements[$tag])) |
|
| 1310 | - $competingElements[$tag] = array(); |
|
| 1352 | + if (!isset($competingElements[$tag])) { |
|
| 1353 | + $competingElements[$tag] = array(); |
|
| 1354 | + } |
|
| 1311 | 1355 | |
| 1312 | 1356 | $competingElements[$tag][] = $parts[$i + 4]; |
| 1313 | 1357 | |
| 1314 | - if (count($competingElements[$tag]) > 1) |
|
| 1315 | - $parts[$i] .= '[/' . $tag . ']'; |
|
| 1358 | + if (count($competingElements[$tag]) > 1) { |
|
| 1359 | + $parts[$i] .= '[/' . $tag . ']'; |
|
| 1360 | + } |
|
| 1316 | 1361 | } |
| 1317 | 1362 | |
| 1318 | 1363 | $inlineElements[$elementContent] = $tag; |
@@ -1333,15 +1378,17 @@ discard block |
||
| 1333 | 1378 | $addClosingTags = array(); |
| 1334 | 1379 | while ($element = array_pop($blockElements)) |
| 1335 | 1380 | { |
| 1336 | - if ($element === $tag) |
|
| 1337 | - break; |
|
| 1381 | + if ($element === $tag) { |
|
| 1382 | + break; |
|
| 1383 | + } |
|
| 1338 | 1384 | |
| 1339 | 1385 | // Still a block tag was open not equal to this tag. |
| 1340 | 1386 | $addClosingTags[] = $element['type']; |
| 1341 | 1387 | } |
| 1342 | 1388 | |
| 1343 | - if (!empty($addClosingTags)) |
|
| 1344 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1389 | + if (!empty($addClosingTags)) { |
|
| 1390 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1391 | + } |
|
| 1345 | 1392 | |
| 1346 | 1393 | // Apparently the closing tag was not found on the stack. |
| 1347 | 1394 | if (!is_string($element) || $element !== $tag) |
@@ -1351,8 +1398,7 @@ discard block |
||
| 1351 | 1398 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
| 1352 | 1399 | continue; |
| 1353 | 1400 | } |
| 1354 | - } |
|
| 1355 | - else |
|
| 1401 | + } else |
|
| 1356 | 1402 | { |
| 1357 | 1403 | // Get rid of this closing tag! |
| 1358 | 1404 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1381,53 +1427,62 @@ discard block |
||
| 1381 | 1427 | unset($inlineElements[$tagContentToBeClosed]); |
| 1382 | 1428 | |
| 1383 | 1429 | // Was this the tag we were looking for? |
| 1384 | - if ($tagToBeClosed === $tag) |
|
| 1385 | - break; |
|
| 1430 | + if ($tagToBeClosed === $tag) { |
|
| 1431 | + break; |
|
| 1432 | + } |
|
| 1386 | 1433 | |
| 1387 | 1434 | // Nope, close it and look further! |
| 1388 | - else |
|
| 1389 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1435 | + else { |
|
| 1436 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1437 | + } |
|
| 1390 | 1438 | } |
| 1391 | 1439 | |
| 1392 | 1440 | if ($isCompetingTag && !empty($competingElements[$tag])) |
| 1393 | 1441 | { |
| 1394 | 1442 | array_pop($competingElements[$tag]); |
| 1395 | 1443 | |
| 1396 | - if (count($competingElements[$tag]) > 0) |
|
| 1397 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1444 | + if (count($competingElements[$tag]) > 0) { |
|
| 1445 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1446 | + } |
|
| 1398 | 1447 | } |
| 1399 | 1448 | } |
| 1400 | 1449 | |
| 1401 | 1450 | // Unexpected closing tag, ex-ter-mi-nate. |
| 1402 | - else |
|
| 1403 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1451 | + else { |
|
| 1452 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1453 | + } |
|
| 1404 | 1454 | } |
| 1405 | 1455 | } |
| 1406 | 1456 | } |
| 1407 | 1457 | |
| 1408 | 1458 | // Close the code tags. |
| 1409 | - if ($inCode) |
|
| 1410 | - $parts[$i] .= '[/code]'; |
|
| 1459 | + if ($inCode) { |
|
| 1460 | + $parts[$i] .= '[/code]'; |
|
| 1461 | + } |
|
| 1411 | 1462 | |
| 1412 | 1463 | // The same for nobbc tags. |
| 1413 | - elseif ($inNoBbc) |
|
| 1414 | - $parts[$i] .= '[/nobbc]'; |
|
| 1464 | + elseif ($inNoBbc) { |
|
| 1465 | + $parts[$i] .= '[/nobbc]'; |
|
| 1466 | + } |
|
| 1415 | 1467 | |
| 1416 | 1468 | // Still inline tags left unclosed? Close them now, better late than never. |
| 1417 | - elseif (!empty($inlineElements)) |
|
| 1418 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1469 | + elseif (!empty($inlineElements)) { |
|
| 1470 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1471 | + } |
|
| 1419 | 1472 | |
| 1420 | 1473 | // Now close the block elements. |
| 1421 | - if (!empty($blockElements)) |
|
| 1422 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1474 | + if (!empty($blockElements)) { |
|
| 1475 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1476 | + } |
|
| 1423 | 1477 | |
| 1424 | 1478 | $text = implode('', $parts); |
| 1425 | 1479 | } |
| 1426 | 1480 | |
| 1427 | 1481 | // Final clean up of back to back tags. |
| 1428 | 1482 | $lastlen = 0; |
| 1429 | - while (strlen($text) !== $lastlen) |
|
| 1430 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1483 | + while (strlen($text) !== $lastlen) { |
|
| 1484 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1485 | + } |
|
| 1431 | 1486 | |
| 1432 | 1487 | return $text; |
| 1433 | 1488 | } |
@@ -1456,22 +1511,25 @@ discard block |
||
| 1456 | 1511 | $context['template_layers'] = array(); |
| 1457 | 1512 | // Lets make sure we aren't going to output anything nasty. |
| 1458 | 1513 | @ob_end_clean(); |
| 1459 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 1460 | - @ob_start('ob_gzhandler'); |
|
| 1461 | - else |
|
| 1462 | - @ob_start(); |
|
| 1514 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 1515 | + @ob_start('ob_gzhandler'); |
|
| 1516 | + } else { |
|
| 1517 | + @ob_start(); |
|
| 1518 | + } |
|
| 1463 | 1519 | |
| 1464 | 1520 | // If we don't have any locale better avoid broken js |
| 1465 | - if (empty($txt['lang_locale'])) |
|
| 1466 | - die(); |
|
| 1521 | + if (empty($txt['lang_locale'])) { |
|
| 1522 | + die(); |
|
| 1523 | + } |
|
| 1467 | 1524 | |
| 1468 | 1525 | $file_data = '(function ($) { |
| 1469 | 1526 | \'use strict\'; |
| 1470 | 1527 | |
| 1471 | 1528 | $.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {'; |
| 1472 | - foreach ($editortxt as $key => $val) |
|
| 1473 | - $file_data .= ' |
|
| 1529 | + foreach ($editortxt as $key => $val) { |
|
| 1530 | + $file_data .= ' |
|
| 1474 | 1531 | ' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ','; |
| 1532 | + } |
|
| 1475 | 1533 | |
| 1476 | 1534 | $file_data .= ' |
| 1477 | 1535 | dateFormat: "day.month.year" |
@@ -1539,8 +1597,9 @@ discard block |
||
| 1539 | 1597 | ) |
| 1540 | 1598 | ); |
| 1541 | 1599 | $icon_data = array(); |
| 1542 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1543 | - $icon_data[] = $row; |
|
| 1600 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1601 | + $icon_data[] = $row; |
|
| 1602 | + } |
|
| 1544 | 1603 | $smcFunc['db_free_result']($request); |
| 1545 | 1604 | |
| 1546 | 1605 | $icons = array(); |
@@ -1555,9 +1614,9 @@ discard block |
||
| 1555 | 1614 | } |
| 1556 | 1615 | |
| 1557 | 1616 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
| 1617 | + } else { |
|
| 1618 | + $icons = $temp; |
|
| 1558 | 1619 | } |
| 1559 | - else |
|
| 1560 | - $icons = $temp; |
|
| 1561 | 1620 | } |
| 1562 | 1621 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
| 1563 | 1622 | |
@@ -1598,8 +1657,9 @@ discard block |
||
| 1598 | 1657 | { |
| 1599 | 1658 | // Some general stuff. |
| 1600 | 1659 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
| 1601 | - if (!empty($context['drafts_autosave'])) |
|
| 1602 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1660 | + if (!empty($context['drafts_autosave'])) { |
|
| 1661 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1662 | + } |
|
| 1603 | 1663 | |
| 1604 | 1664 | // This really has some WYSIWYG stuff. |
| 1605 | 1665 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1615,8 +1675,9 @@ discard block |
||
| 1615 | 1675 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
| 1616 | 1676 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
| 1617 | 1677 | // editor language file |
| 1618 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
| 1619 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1678 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
| 1679 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1680 | + } |
|
| 1620 | 1681 | |
| 1621 | 1682 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (isBrowser('is_firefox') ? '_firefox' : '')]; |
| 1622 | 1683 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1625,11 +1686,12 @@ discard block |
||
| 1625 | 1686 | loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck'); |
| 1626 | 1687 | |
| 1627 | 1688 | // Some hidden information is needed in order to make the spell checking work. |
| 1628 | - if (!isset($_REQUEST['xml'])) |
|
| 1629 | - $context['insert_after_template'] .= ' |
|
| 1689 | + if (!isset($_REQUEST['xml'])) { |
|
| 1690 | + $context['insert_after_template'] .= ' |
|
| 1630 | 1691 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
| 1631 | 1692 | <input type="hidden" name="spellstring" value=""> |
| 1632 | 1693 | </form>'; |
| 1694 | + } |
|
| 1633 | 1695 | } |
| 1634 | 1696 | } |
| 1635 | 1697 | |
@@ -1786,10 +1848,12 @@ discard block |
||
| 1786 | 1848 | |
| 1787 | 1849 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
| 1788 | 1850 | $disabled_tags = array(); |
| 1789 | - if (!empty($modSettings['disabledBBC'])) |
|
| 1790 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1791 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1792 | - $disabled_tags[] = 'flash'; |
|
| 1851 | + if (!empty($modSettings['disabledBBC'])) { |
|
| 1852 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1853 | + } |
|
| 1854 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1855 | + $disabled_tags[] = 'flash'; |
|
| 1856 | + } |
|
| 1793 | 1857 | |
| 1794 | 1858 | foreach ($disabled_tags as $tag) |
| 1795 | 1859 | { |
@@ -1799,9 +1863,10 @@ discard block |
||
| 1799 | 1863 | $context['disabled_tags']['orderedlist'] = true; |
| 1800 | 1864 | } |
| 1801 | 1865 | |
| 1802 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
| 1803 | - if ($tag === $thisTag) |
|
| 1866 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
| 1867 | + if ($tag === $thisTag) |
|
| 1804 | 1868 | $context['disabled_tags'][$tagNameBBC] = true; |
| 1869 | + } |
|
| 1805 | 1870 | |
| 1806 | 1871 | $context['disabled_tags'][trim($tag)] = true; |
| 1807 | 1872 | } |
@@ -1811,19 +1876,21 @@ discard block |
||
| 1811 | 1876 | $context['bbc_toolbar'] = array(); |
| 1812 | 1877 | foreach ($context['bbc_tags'] as $row => $tagRow) |
| 1813 | 1878 | { |
| 1814 | - if (!isset($context['bbc_toolbar'][$row])) |
|
| 1815 | - $context['bbc_toolbar'][$row] = array(); |
|
| 1879 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
| 1880 | + $context['bbc_toolbar'][$row] = array(); |
|
| 1881 | + } |
|
| 1816 | 1882 | $tagsRow = array(); |
| 1817 | 1883 | foreach ($tagRow as $tag) |
| 1818 | 1884 | { |
| 1819 | 1885 | if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']])) |
| 1820 | 1886 | { |
| 1821 | 1887 | $tagsRow[] = $tag['code']; |
| 1822 | - if (isset($tag['image'])) |
|
| 1823 | - $bbcodes_styles .= ' |
|
| 1888 | + if (isset($tag['image'])) { |
|
| 1889 | + $bbcodes_styles .= ' |
|
| 1824 | 1890 | .sceditor-button-' . $tag['code'] . ' div { |
| 1825 | 1891 | background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\'); |
| 1826 | 1892 | }'; |
| 1893 | + } |
|
| 1827 | 1894 | if (isset($tag['before'])) |
| 1828 | 1895 | { |
| 1829 | 1896 | $context['bbcodes_handlers'] .= ' |
@@ -1837,8 +1904,7 @@ discard block |
||
| 1837 | 1904 | });'; |
| 1838 | 1905 | } |
| 1839 | 1906 | |
| 1840 | - } |
|
| 1841 | - else |
|
| 1907 | + } else |
|
| 1842 | 1908 | { |
| 1843 | 1909 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1844 | 1910 | $tagsRow = array(); |
@@ -1849,14 +1915,16 @@ discard block |
||
| 1849 | 1915 | { |
| 1850 | 1916 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1851 | 1917 | $tagsRow = array(); |
| 1852 | - if (!isset($context['disabled_tags']['font'])) |
|
| 1853 | - $tagsRow[] = 'font'; |
|
| 1854 | - if (!isset($context['disabled_tags']['size'])) |
|
| 1855 | - $tagsRow[] = 'size'; |
|
| 1856 | - if (!isset($context['disabled_tags']['color'])) |
|
| 1857 | - $tagsRow[] = 'color'; |
|
| 1858 | - } |
|
| 1859 | - elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1918 | + if (!isset($context['disabled_tags']['font'])) { |
|
| 1919 | + $tagsRow[] = 'font'; |
|
| 1920 | + } |
|
| 1921 | + if (!isset($context['disabled_tags']['size'])) { |
|
| 1922 | + $tagsRow[] = 'size'; |
|
| 1923 | + } |
|
| 1924 | + if (!isset($context['disabled_tags']['color'])) { |
|
| 1925 | + $tagsRow[] = 'color'; |
|
| 1926 | + } |
|
| 1927 | + } elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1860 | 1928 | { |
| 1861 | 1929 | $tmp = array(); |
| 1862 | 1930 | $tagsRow[] = 'removeformat'; |
@@ -1867,13 +1935,15 @@ discard block |
||
| 1867 | 1935 | } |
| 1868 | 1936 | } |
| 1869 | 1937 | |
| 1870 | - if (!empty($tagsRow)) |
|
| 1871 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1938 | + if (!empty($tagsRow)) { |
|
| 1939 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1940 | + } |
|
| 1872 | 1941 | } |
| 1873 | - if (!empty($bbcodes_styles)) |
|
| 1874 | - $context['html_headers'] .= ' |
|
| 1942 | + if (!empty($bbcodes_styles)) { |
|
| 1943 | + $context['html_headers'] .= ' |
|
| 1875 | 1944 | <style>' . $bbcodes_styles . ' |
| 1876 | 1945 | </style>'; |
| 1946 | + } |
|
| 1877 | 1947 | } |
| 1878 | 1948 | |
| 1879 | 1949 | // Initialize smiley array... if not loaded before. |
@@ -1885,8 +1955,8 @@ discard block |
||
| 1885 | 1955 | ); |
| 1886 | 1956 | |
| 1887 | 1957 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
| 1888 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
| 1889 | - $context['smileys']['postform'][] = array( |
|
| 1958 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
| 1959 | + $context['smileys']['postform'][] = array( |
|
| 1890 | 1960 | 'smileys' => array( |
| 1891 | 1961 | array( |
| 1892 | 1962 | 'code' => ':)', |
@@ -1972,7 +2042,7 @@ discard block |
||
| 1972 | 2042 | ), |
| 1973 | 2043 | 'isLast' => true, |
| 1974 | 2044 | ); |
| 1975 | - elseif ($user_info['smiley_set'] != 'none') |
|
| 2045 | + } elseif ($user_info['smiley_set'] != 'none') |
|
| 1976 | 2046 | { |
| 1977 | 2047 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
| 1978 | 2048 | { |
@@ -1995,17 +2065,19 @@ discard block |
||
| 1995 | 2065 | |
| 1996 | 2066 | foreach ($context['smileys'] as $section => $smileyRows) |
| 1997 | 2067 | { |
| 1998 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
| 1999 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2068 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
| 2069 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2070 | + } |
|
| 2000 | 2071 | |
| 2001 | - if (!empty($smileyRows)) |
|
| 2002 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2072 | + if (!empty($smileyRows)) { |
|
| 2073 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2074 | + } |
|
| 2003 | 2075 | } |
| 2004 | 2076 | |
| 2005 | 2077 | cache_put_data('posting_smileys', $context['smileys'], 480); |
| 2078 | + } else { |
|
| 2079 | + $context['smileys'] = $temp; |
|
| 2006 | 2080 | } |
| 2007 | - else |
|
| 2008 | - $context['smileys'] = $temp; |
|
| 2009 | 2081 | } |
| 2010 | 2082 | } |
| 2011 | 2083 | |
@@ -2031,8 +2103,9 @@ discard block |
||
| 2031 | 2103 | loadTemplate('GenericControls'); |
| 2032 | 2104 | |
| 2033 | 2105 | // Some javascript ma'am? |
| 2034 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
| 2035 | - loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2106 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
| 2107 | + loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2108 | + } |
|
| 2036 | 2109 | |
| 2037 | 2110 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
| 2038 | 2111 | |
@@ -2045,8 +2118,8 @@ discard block |
||
| 2045 | 2118 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
| 2046 | 2119 | |
| 2047 | 2120 | // Log this into our collection. |
| 2048 | - if ($isNew) |
|
| 2049 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2121 | + if ($isNew) { |
|
| 2122 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2050 | 2123 | 'id' => $verificationOptions['id'], |
| 2051 | 2124 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
| 2052 | 2125 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2057,13 +2130,15 @@ discard block |
||
| 2057 | 2130 | 'questions' => array(), |
| 2058 | 2131 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && $modSettings['recaptcha_enabled'] == 1 && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
| 2059 | 2132 | ); |
| 2133 | + } |
|
| 2060 | 2134 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
| 2061 | 2135 | |
| 2062 | 2136 | // Is there actually going to be anything? |
| 2063 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
| 2064 | - return false; |
|
| 2065 | - elseif (!$isNew && !$do_test) |
|
| 2066 | - return true; |
|
| 2137 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
| 2138 | + return false; |
|
| 2139 | + } elseif (!$isNew && !$do_test) { |
|
| 2140 | + return true; |
|
| 2141 | + } |
|
| 2067 | 2142 | |
| 2068 | 2143 | // Sanitize reCAPTCHA fields? |
| 2069 | 2144 | if ($thisVerification['can_recaptcha']) |
@@ -2076,11 +2151,12 @@ discard block |
||
| 2076 | 2151 | } |
| 2077 | 2152 | |
| 2078 | 2153 | // Add javascript for the object. |
| 2079 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
| 2080 | - $context['insert_after_template'] .= ' |
|
| 2154 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
| 2155 | + $context['insert_after_template'] .= ' |
|
| 2081 | 2156 | <script> |
| 2082 | 2157 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
| 2083 | 2158 | </script>'; |
| 2159 | + } |
|
| 2084 | 2160 | |
| 2085 | 2161 | // If we want questions do we have a cache of all the IDs? |
| 2086 | 2162 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2103,8 +2179,9 @@ discard block |
||
| 2103 | 2179 | unset ($row['id_question']); |
| 2104 | 2180 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
| 2105 | 2181 | $row['answers'] = smf_json_decode($row['answers'], true); |
| 2106 | - foreach ($row['answers'] as $k => $v) |
|
| 2107 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2182 | + foreach ($row['answers'] as $k => $v) { |
|
| 2183 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2184 | + } |
|
| 2108 | 2185 | |
| 2109 | 2186 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
| 2110 | 2187 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2115,35 +2192,42 @@ discard block |
||
| 2115 | 2192 | } |
| 2116 | 2193 | } |
| 2117 | 2194 | |
| 2118 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
| 2119 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2195 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
| 2196 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2197 | + } |
|
| 2120 | 2198 | |
| 2121 | 2199 | // Do we need to refresh the verification? |
| 2122 | - 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'])) |
|
| 2123 | - $force_refresh = true; |
|
| 2124 | - else |
|
| 2125 | - $force_refresh = false; |
|
| 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; |
|
| 2204 | + } |
|
| 2126 | 2205 | |
| 2127 | 2206 | // This can also force a fresh, although unlikely. |
| 2128 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2129 | - $force_refresh = true; |
|
| 2207 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2208 | + $force_refresh = true; |
|
| 2209 | + } |
|
| 2130 | 2210 | |
| 2131 | 2211 | $verification_errors = array(); |
| 2132 | 2212 | // Start with any testing. |
| 2133 | 2213 | if ($do_test) |
| 2134 | 2214 | { |
| 2135 | 2215 | // This cannot happen! |
| 2136 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
| 2137 | - fatal_lang_error('no_access', false); |
|
| 2216 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
| 2217 | + fatal_lang_error('no_access', false); |
|
| 2218 | + } |
|
| 2138 | 2219 | // ... nor this! |
| 2139 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2140 | - fatal_lang_error('no_access', false); |
|
| 2220 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2221 | + fatal_lang_error('no_access', false); |
|
| 2222 | + } |
|
| 2141 | 2223 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
| 2142 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
| 2143 | - fatal_lang_error('no_access', false); |
|
| 2224 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
| 2225 | + fatal_lang_error('no_access', false); |
|
| 2226 | + } |
|
| 2144 | 2227 | // While we're here, did the user do something bad? |
| 2145 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
| 2146 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2228 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
| 2229 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2230 | + } |
|
| 2147 | 2231 | |
| 2148 | 2232 | if ($thisVerification['can_recaptcha']) |
| 2149 | 2233 | { |
@@ -2156,22 +2240,25 @@ discard block |
||
| 2156 | 2240 | { |
| 2157 | 2241 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); |
| 2158 | 2242 | |
| 2159 | - if (!$resp->isSuccess()) |
|
| 2160 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2243 | + if (!$resp->isSuccess()) { |
|
| 2244 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2245 | + } |
|
| 2246 | + } else { |
|
| 2247 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2161 | 2248 | } |
| 2162 | - else |
|
| 2163 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2164 | 2249 | } |
| 2165 | - 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'])) |
|
| 2166 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2250 | + 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'])) { |
|
| 2251 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2252 | + } |
|
| 2167 | 2253 | if ($thisVerification['number_questions']) |
| 2168 | 2254 | { |
| 2169 | 2255 | $incorrectQuestions = array(); |
| 2170 | 2256 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
| 2171 | 2257 | { |
| 2172 | 2258 | // We don't have this question any more, thus no answers. |
| 2173 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
| 2174 | - continue; |
|
| 2259 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
| 2260 | + continue; |
|
| 2261 | + } |
|
| 2175 | 2262 | // This is quite complex. We have our question but it might have multiple answers. |
| 2176 | 2263 | // First, did they actually answer this question? |
| 2177 | 2264 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2183,24 +2270,28 @@ discard block |
||
| 2183 | 2270 | else |
| 2184 | 2271 | { |
| 2185 | 2272 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
| 2186 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
| 2187 | - $incorrectQuestions[] = $q; |
|
| 2273 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
| 2274 | + $incorrectQuestions[] = $q; |
|
| 2275 | + } |
|
| 2188 | 2276 | } |
| 2189 | 2277 | } |
| 2190 | 2278 | |
| 2191 | - if (!empty($incorrectQuestions)) |
|
| 2192 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2279 | + if (!empty($incorrectQuestions)) { |
|
| 2280 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2281 | + } |
|
| 2193 | 2282 | } |
| 2194 | 2283 | } |
| 2195 | 2284 | |
| 2196 | 2285 | // Any errors means we refresh potentially. |
| 2197 | 2286 | if (!empty($verification_errors)) |
| 2198 | 2287 | { |
| 2199 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
| 2200 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2288 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
| 2289 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2290 | + } |
|
| 2201 | 2291 | // Too many errors? |
| 2202 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
| 2203 | - $force_refresh = true; |
|
| 2292 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
| 2293 | + $force_refresh = true; |
|
| 2294 | + } |
|
| 2204 | 2295 | |
| 2205 | 2296 | // Keep a track of these. |
| 2206 | 2297 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2233,8 +2324,9 @@ discard block |
||
| 2233 | 2324 | // Are we overriding the range? |
| 2234 | 2325 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
| 2235 | 2326 | |
| 2236 | - for ($i = 0; $i < 6; $i++) |
|
| 2237 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2327 | + for ($i = 0; $i < 6; $i++) { |
|
| 2328 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2329 | + } |
|
| 2238 | 2330 | } |
| 2239 | 2331 | |
| 2240 | 2332 | // Getting some new questions? |
@@ -2242,8 +2334,9 @@ discard block |
||
| 2242 | 2334 | { |
| 2243 | 2335 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
| 2244 | 2336 | $possible_langs = array(); |
| 2245 | - if (isset($_SESSION['language'])) |
|
| 2246 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2337 | + if (isset($_SESSION['language'])) { |
|
| 2338 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2339 | + } |
|
| 2247 | 2340 | if (!empty($user_info['language'])); |
| 2248 | 2341 | $possible_langs[] = $user_info['language']; |
| 2249 | 2342 | $possible_langs[] = $language; |
@@ -2262,8 +2355,7 @@ discard block |
||
| 2262 | 2355 | } |
| 2263 | 2356 | } |
| 2264 | 2357 | } |
| 2265 | - } |
|
| 2266 | - else |
|
| 2358 | + } else |
|
| 2267 | 2359 | { |
| 2268 | 2360 | // Same questions as before. |
| 2269 | 2361 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2273,8 +2365,9 @@ discard block |
||
| 2273 | 2365 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
| 2274 | 2366 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
| 2275 | 2367 | { |
| 2276 | - if (!isset($context['html_headers'])) |
|
| 2277 | - $context['html_headers'] = ''; |
|
| 2368 | + if (!isset($context['html_headers'])) { |
|
| 2369 | + $context['html_headers'] = ''; |
|
| 2370 | + } |
|
| 2278 | 2371 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
| 2279 | 2372 | } |
| 2280 | 2373 | |
@@ -2300,11 +2393,13 @@ discard block |
||
| 2300 | 2393 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
| 2301 | 2394 | |
| 2302 | 2395 | // Return errors if we have them. |
| 2303 | - if (!empty($verification_errors)) |
|
| 2304 | - return $verification_errors; |
|
| 2396 | + if (!empty($verification_errors)) { |
|
| 2397 | + return $verification_errors; |
|
| 2398 | + } |
|
| 2305 | 2399 | // If we had a test that one, make a note. |
| 2306 | - elseif ($do_test) |
|
| 2307 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2400 | + elseif ($do_test) { |
|
| 2401 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2402 | + } |
|
| 2308 | 2403 | |
| 2309 | 2404 | // Say that everything went well chaps. |
| 2310 | 2405 | return true; |
@@ -2329,8 +2424,9 @@ discard block |
||
| 2329 | 2424 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
| 2330 | 2425 | |
| 2331 | 2426 | // If we're just checking the callback function is registered return true or false. |
| 2332 | - if ($checkRegistered != null) |
|
| 2333 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2427 | + if ($checkRegistered != null) { |
|
| 2428 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2429 | + } |
|
| 2334 | 2430 | |
| 2335 | 2431 | checkSession('get'); |
| 2336 | 2432 | loadTemplate('Xml'); |
@@ -2481,24 +2577,27 @@ discard block |
||
| 2481 | 2577 | foreach ($possible_versions as $ver) |
| 2482 | 2578 | { |
| 2483 | 2579 | $ver = trim($ver); |
| 2484 | - if (strpos($ver, 'SMF') === 0) |
|
| 2485 | - $versions[] = $ver; |
|
| 2580 | + if (strpos($ver, 'SMF') === 0) { |
|
| 2581 | + $versions[] = $ver; |
|
| 2582 | + } |
|
| 2486 | 2583 | } |
| 2487 | 2584 | } |
| 2488 | 2585 | $smcFunc['db_free_result']($request); |
| 2489 | 2586 | |
| 2490 | 2587 | // Just in case we don't have ANYthing. |
| 2491 | - if (empty($versions)) |
|
| 2492 | - $versions = array('SMF 2.0'); |
|
| 2588 | + if (empty($versions)) { |
|
| 2589 | + $versions = array('SMF 2.0'); |
|
| 2590 | + } |
|
| 2493 | 2591 | |
| 2494 | - foreach ($versions as $id => $version) |
|
| 2495 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2592 | + foreach ($versions as $id => $version) { |
|
| 2593 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2496 | 2594 | $xml_data['items']['children'][] = array( |
| 2497 | 2595 | 'attributes' => array( |
| 2498 | 2596 | 'id' => $id, |
| 2499 | 2597 | ), |
| 2500 | 2598 | 'value' => $version, |
| 2501 | 2599 | ); |
| 2600 | + } |
|
| 2502 | 2601 | |
| 2503 | 2602 | return $xml_data; |
| 2504 | 2603 | } |