@@ -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 = ''; |
@@ -694,12 +710,13 @@ discard block |
||
| 694 | 710 | $attrs = fetchTagAttributes($matches[1]); |
| 695 | 711 | foreach ($attrs as $attrib => $value) |
| 696 | 712 | { |
| 697 | - if (in_array($attrib, array('width', 'height'))) |
|
| 698 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 699 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
| 700 | - $params .= ' alt=' . trim($value); |
|
| 701 | - elseif ($attrib == 'src') |
|
| 702 | - $src = trim($value); |
|
| 713 | + if (in_array($attrib, array('width', 'height'))) { |
|
| 714 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 715 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
| 716 | + $params .= ' alt=' . trim($value); |
|
| 717 | + } elseif ($attrib == 'src') { |
|
| 718 | + $src = trim($value); |
|
| 719 | + } |
|
| 703 | 720 | } |
| 704 | 721 | |
| 705 | 722 | $tag = ''; |
@@ -710,10 +727,11 @@ discard block |
||
| 710 | 727 | { |
| 711 | 728 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 712 | 729 | |
| 713 | - if (substr($src, 0, 1) === '/') |
|
| 714 | - $src = $baseURL . $src; |
|
| 715 | - else |
|
| 716 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 730 | + if (substr($src, 0, 1) === '/') { |
|
| 731 | + $src = $baseURL . $src; |
|
| 732 | + } else { |
|
| 733 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 734 | + } |
|
| 717 | 735 | } |
| 718 | 736 | |
| 719 | 737 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -891,20 +909,23 @@ discard block |
||
| 891 | 909 | }, |
| 892 | 910 | ); |
| 893 | 911 | |
| 894 | - foreach ($tags as $tag => $replace) |
|
| 895 | - $text = preg_replace_callback($tag, $replace, $text); |
|
| 912 | + foreach ($tags as $tag => $replace) { |
|
| 913 | + $text = preg_replace_callback($tag, $replace, $text); |
|
| 914 | + } |
|
| 896 | 915 | |
| 897 | 916 | // Please give us just a little more time. |
| 898 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 899 | - @apache_reset_timeout(); |
|
| 917 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 918 | + @apache_reset_timeout(); |
|
| 919 | + } |
|
| 900 | 920 | |
| 901 | 921 | // What about URL's - the pain in the ass of the tag world. |
| 902 | 922 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
| 903 | 923 | { |
| 904 | 924 | // Find the position of the URL. |
| 905 | 925 | $start_pos = strpos($text, $matches[0]); |
| 906 | - if ($start_pos === false) |
|
| 907 | - break; |
|
| 926 | + if ($start_pos === false) { |
|
| 927 | + break; |
|
| 928 | + } |
|
| 908 | 929 | $end_pos = $start_pos + strlen($matches[0]); |
| 909 | 930 | |
| 910 | 931 | $tag_type = 'url'; |
@@ -918,8 +939,9 @@ discard block |
||
| 918 | 939 | $href = trim($value); |
| 919 | 940 | |
| 920 | 941 | // Are we dealing with an FTP link? |
| 921 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
| 922 | - $tag_type = 'ftp'; |
|
| 942 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
| 943 | + $tag_type = 'ftp'; |
|
| 944 | + } |
|
| 923 | 945 | |
| 924 | 946 | // Or is this a link to an email address? |
| 925 | 947 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -933,28 +955,31 @@ discard block |
||
| 933 | 955 | { |
| 934 | 956 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 935 | 957 | |
| 936 | - if (substr($href, 0, 1) === '/') |
|
| 937 | - $href = $baseURL . $href; |
|
| 938 | - else |
|
| 939 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 958 | + if (substr($href, 0, 1) === '/') { |
|
| 959 | + $href = $baseURL . $href; |
|
| 960 | + } else { |
|
| 961 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 962 | + } |
|
| 940 | 963 | } |
| 941 | 964 | } |
| 942 | 965 | |
| 943 | 966 | // External URL? |
| 944 | 967 | if ($attrib == 'target' && $tag_type == 'url') |
| 945 | 968 | { |
| 946 | - if (trim($value) == '_blank') |
|
| 947 | - $tag_type == 'iurl'; |
|
| 969 | + if (trim($value) == '_blank') { |
|
| 970 | + $tag_type == 'iurl'; |
|
| 971 | + } |
|
| 948 | 972 | } |
| 949 | 973 | } |
| 950 | 974 | |
| 951 | 975 | $tag = ''; |
| 952 | 976 | if ($href != '') |
| 953 | 977 | { |
| 954 | - if ($matches[2] == $href) |
|
| 955 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 956 | - else |
|
| 957 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 978 | + if ($matches[2] == $href) { |
|
| 979 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 980 | + } else { |
|
| 981 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 982 | + } |
|
| 958 | 983 | } |
| 959 | 984 | |
| 960 | 985 | // Replace the tag |
@@ -993,17 +1018,18 @@ discard block |
||
| 993 | 1018 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
| 994 | 1019 | if ($text[$i] == '=') |
| 995 | 1020 | { |
| 996 | - if ($tag_state == 0) |
|
| 997 | - $tag_state = 1; |
|
| 998 | - elseif ($tag_state == 2) |
|
| 999 | - $value .= '='; |
|
| 1021 | + if ($tag_state == 0) { |
|
| 1022 | + $tag_state = 1; |
|
| 1023 | + } elseif ($tag_state == 2) { |
|
| 1024 | + $value .= '='; |
|
| 1025 | + } |
|
| 1000 | 1026 | } |
| 1001 | 1027 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
| 1002 | 1028 | elseif ($text[$i] == ' ') |
| 1003 | 1029 | { |
| 1004 | - if ($tag_state == 2) |
|
| 1005 | - $value .= ' '; |
|
| 1006 | - elseif ($tag_state == 1) |
|
| 1030 | + if ($tag_state == 2) { |
|
| 1031 | + $value .= ' '; |
|
| 1032 | + } elseif ($tag_state == 1) |
|
| 1007 | 1033 | { |
| 1008 | 1034 | $attribs[$key] = $value; |
| 1009 | 1035 | $key = $value = ''; |
@@ -1014,24 +1040,27 @@ discard block |
||
| 1014 | 1040 | elseif ($text[$i] == '"') |
| 1015 | 1041 | { |
| 1016 | 1042 | // Must be either going into or out of a string. |
| 1017 | - if ($tag_state == 1) |
|
| 1018 | - $tag_state = 2; |
|
| 1019 | - else |
|
| 1020 | - $tag_state = 1; |
|
| 1043 | + if ($tag_state == 1) { |
|
| 1044 | + $tag_state = 2; |
|
| 1045 | + } else { |
|
| 1046 | + $tag_state = 1; |
|
| 1047 | + } |
|
| 1021 | 1048 | } |
| 1022 | 1049 | // Otherwise it's fine. |
| 1023 | 1050 | else |
| 1024 | 1051 | { |
| 1025 | - if ($tag_state == 0) |
|
| 1026 | - $key .= $text[$i]; |
|
| 1027 | - else |
|
| 1028 | - $value .= $text[$i]; |
|
| 1052 | + if ($tag_state == 0) { |
|
| 1053 | + $key .= $text[$i]; |
|
| 1054 | + } else { |
|
| 1055 | + $value .= $text[$i]; |
|
| 1056 | + } |
|
| 1029 | 1057 | } |
| 1030 | 1058 | } |
| 1031 | 1059 | |
| 1032 | 1060 | // Anything left? |
| 1033 | - if ($key != '' && $value != '') |
|
| 1034 | - $attribs[$key] = $value; |
|
| 1061 | + if ($key != '' && $value != '') { |
|
| 1062 | + $attribs[$key] = $value; |
|
| 1063 | + } |
|
| 1035 | 1064 | |
| 1036 | 1065 | return $attribs; |
| 1037 | 1066 | } |
@@ -1047,15 +1076,17 @@ discard block |
||
| 1047 | 1076 | global $modSettings; |
| 1048 | 1077 | |
| 1049 | 1078 | // Don't care about the texts that are too short. |
| 1050 | - if (strlen($text) < 3) |
|
| 1051 | - return $text; |
|
| 1079 | + if (strlen($text) < 3) { |
|
| 1080 | + return $text; |
|
| 1081 | + } |
|
| 1052 | 1082 | |
| 1053 | 1083 | // A list of tags that's disabled by the admin. |
| 1054 | 1084 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
| 1055 | 1085 | |
| 1056 | 1086 | // Add flash if it's disabled as embedded tag. |
| 1057 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1058 | - $disabled['flash'] = true; |
|
| 1087 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1088 | + $disabled['flash'] = true; |
|
| 1089 | + } |
|
| 1059 | 1090 | |
| 1060 | 1091 | // Get a list of all the tags that are not disabled. |
| 1061 | 1092 | $all_tags = parse_bbc(false); |
@@ -1063,10 +1094,12 @@ discard block |
||
| 1063 | 1094 | $self_closing_tags = array(); |
| 1064 | 1095 | foreach ($all_tags as $tag) |
| 1065 | 1096 | { |
| 1066 | - if (!isset($disabled[$tag['tag']])) |
|
| 1067 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1068 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
| 1069 | - $self_closing_tags[] = $tag['tag']; |
|
| 1097 | + if (!isset($disabled[$tag['tag']])) { |
|
| 1098 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1099 | + } |
|
| 1100 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
| 1101 | + $self_closing_tags[] = $tag['tag']; |
|
| 1102 | + } |
|
| 1070 | 1103 | } |
| 1071 | 1104 | |
| 1072 | 1105 | // 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! |
@@ -1093,16 +1126,19 @@ discard block |
||
| 1093 | 1126 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
| 1094 | 1127 | |
| 1095 | 1128 | // We're closing the exact same tag that we opened. |
| 1096 | - if ($isClosingTag && $insideTag === $tagName) |
|
| 1097 | - $insideTag = null; |
|
| 1129 | + if ($isClosingTag && $insideTag === $tagName) { |
|
| 1130 | + $insideTag = null; |
|
| 1131 | + } |
|
| 1098 | 1132 | |
| 1099 | 1133 | // We're opening a tag and we're not yet inside one either |
| 1100 | - elseif (!$isClosingTag && $insideTag === null) |
|
| 1101 | - $insideTag = $tagName; |
|
| 1134 | + elseif (!$isClosingTag && $insideTag === null) { |
|
| 1135 | + $insideTag = $tagName; |
|
| 1136 | + } |
|
| 1102 | 1137 | |
| 1103 | 1138 | // In all other cases, this tag must be invalid |
| 1104 | - else |
|
| 1105 | - unset($matches[$i]); |
|
| 1139 | + else { |
|
| 1140 | + unset($matches[$i]); |
|
| 1141 | + } |
|
| 1106 | 1142 | } |
| 1107 | 1143 | |
| 1108 | 1144 | // The next one is gonna be the other one. |
@@ -1110,8 +1146,9 @@ discard block |
||
| 1110 | 1146 | } |
| 1111 | 1147 | |
| 1112 | 1148 | // We're still inside a tag and had no chance for closure? |
| 1113 | - if ($insideTag !== null) |
|
| 1114 | - $matches[] = '[/' . $insideTag . ']'; |
|
| 1149 | + if ($insideTag !== null) { |
|
| 1150 | + $matches[] = '[/' . $insideTag . ']'; |
|
| 1151 | + } |
|
| 1115 | 1152 | |
| 1116 | 1153 | // And a complete text string again. |
| 1117 | 1154 | $text = implode('', $matches); |
@@ -1120,8 +1157,9 @@ discard block |
||
| 1120 | 1157 | // Quickly remove any tags which are back to back. |
| 1121 | 1158 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
| 1122 | 1159 | $lastlen = 0; |
| 1123 | - while (strlen($text) !== $lastlen) |
|
| 1124 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1160 | + while (strlen($text) !== $lastlen) { |
|
| 1161 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1162 | + } |
|
| 1125 | 1163 | |
| 1126 | 1164 | // Need to sort the tags my name length. |
| 1127 | 1165 | uksort($valid_tags, 'sort_array_length'); |
@@ -1158,8 +1196,9 @@ discard block |
||
| 1158 | 1196 | $isCompetingTag = in_array($tag, $competing_tags); |
| 1159 | 1197 | |
| 1160 | 1198 | // Check if this might be one of those cleaned out tags. |
| 1161 | - if ($tag === '') |
|
| 1162 | - continue; |
|
| 1199 | + if ($tag === '') { |
|
| 1200 | + continue; |
|
| 1201 | + } |
|
| 1163 | 1202 | |
| 1164 | 1203 | // Special case: inside [code] blocks any code is left untouched. |
| 1165 | 1204 | elseif ($tag === 'code') |
@@ -1170,8 +1209,9 @@ discard block |
||
| 1170 | 1209 | $inCode = false; |
| 1171 | 1210 | |
| 1172 | 1211 | // Reopen tags that were closed before the code block. |
| 1173 | - if (!empty($inlineElements)) |
|
| 1174 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1212 | + if (!empty($inlineElements)) { |
|
| 1213 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1214 | + } |
|
| 1175 | 1215 | } |
| 1176 | 1216 | |
| 1177 | 1217 | // We're outside a coding and nobbc block and opening it. |
@@ -1200,8 +1240,9 @@ discard block |
||
| 1200 | 1240 | $inNoBbc = false; |
| 1201 | 1241 | |
| 1202 | 1242 | // Some inline elements might've been closed that need reopening. |
| 1203 | - if (!empty($inlineElements)) |
|
| 1204 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1243 | + if (!empty($inlineElements)) { |
|
| 1244 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1245 | + } |
|
| 1205 | 1246 | } |
| 1206 | 1247 | |
| 1207 | 1248 | // We're outside a nobbc and coding block and opening it. |
@@ -1221,8 +1262,9 @@ discard block |
||
| 1221 | 1262 | } |
| 1222 | 1263 | |
| 1223 | 1264 | // So, we're inside one of the special blocks: ignore any tag. |
| 1224 | - elseif ($inCode || $inNoBbc) |
|
| 1225 | - continue; |
|
| 1265 | + elseif ($inCode || $inNoBbc) { |
|
| 1266 | + continue; |
|
| 1267 | + } |
|
| 1226 | 1268 | |
| 1227 | 1269 | // We're dealing with an opening tag. |
| 1228 | 1270 | if ($isOpeningTag) |
@@ -1263,8 +1305,9 @@ discard block |
||
| 1263 | 1305 | if ($parts[$j + 3] === $tag) |
| 1264 | 1306 | { |
| 1265 | 1307 | // If it's an opening tag, increase the level. |
| 1266 | - if ($parts[$j + 2] === '') |
|
| 1267 | - $curLevel++; |
|
| 1308 | + if ($parts[$j + 2] === '') { |
|
| 1309 | + $curLevel++; |
|
| 1310 | + } |
|
| 1268 | 1311 | |
| 1269 | 1312 | // A closing tag, decrease the level. |
| 1270 | 1313 | else |
@@ -1287,13 +1330,15 @@ discard block |
||
| 1287 | 1330 | { |
| 1288 | 1331 | if ($isCompetingTag) |
| 1289 | 1332 | { |
| 1290 | - if (!isset($competingElements[$tag])) |
|
| 1291 | - $competingElements[$tag] = array(); |
|
| 1333 | + if (!isset($competingElements[$tag])) { |
|
| 1334 | + $competingElements[$tag] = array(); |
|
| 1335 | + } |
|
| 1292 | 1336 | |
| 1293 | 1337 | $competingElements[$tag][] = $parts[$i + 4]; |
| 1294 | 1338 | |
| 1295 | - if (count($competingElements[$tag]) > 1) |
|
| 1296 | - $parts[$i] .= '[/' . $tag . ']'; |
|
| 1339 | + if (count($competingElements[$tag]) > 1) { |
|
| 1340 | + $parts[$i] .= '[/' . $tag . ']'; |
|
| 1341 | + } |
|
| 1297 | 1342 | } |
| 1298 | 1343 | |
| 1299 | 1344 | $inlineElements[$elementContent] = $tag; |
@@ -1314,15 +1359,17 @@ discard block |
||
| 1314 | 1359 | $addClosingTags = array(); |
| 1315 | 1360 | while ($element = array_pop($blockElements)) |
| 1316 | 1361 | { |
| 1317 | - if ($element === $tag) |
|
| 1318 | - break; |
|
| 1362 | + if ($element === $tag) { |
|
| 1363 | + break; |
|
| 1364 | + } |
|
| 1319 | 1365 | |
| 1320 | 1366 | // Still a block tag was open not equal to this tag. |
| 1321 | 1367 | $addClosingTags[] = $element['type']; |
| 1322 | 1368 | } |
| 1323 | 1369 | |
| 1324 | - if (!empty($addClosingTags)) |
|
| 1325 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1370 | + if (!empty($addClosingTags)) { |
|
| 1371 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1372 | + } |
|
| 1326 | 1373 | |
| 1327 | 1374 | // Apparently the closing tag was not found on the stack. |
| 1328 | 1375 | if (!is_string($element) || $element !== $tag) |
@@ -1332,8 +1379,7 @@ discard block |
||
| 1332 | 1379 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
| 1333 | 1380 | continue; |
| 1334 | 1381 | } |
| 1335 | - } |
|
| 1336 | - else |
|
| 1382 | + } else |
|
| 1337 | 1383 | { |
| 1338 | 1384 | // Get rid of this closing tag! |
| 1339 | 1385 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1362,53 +1408,62 @@ discard block |
||
| 1362 | 1408 | unset($inlineElements[$tagContentToBeClosed]); |
| 1363 | 1409 | |
| 1364 | 1410 | // Was this the tag we were looking for? |
| 1365 | - if ($tagToBeClosed === $tag) |
|
| 1366 | - break; |
|
| 1411 | + if ($tagToBeClosed === $tag) { |
|
| 1412 | + break; |
|
| 1413 | + } |
|
| 1367 | 1414 | |
| 1368 | 1415 | // Nope, close it and look further! |
| 1369 | - else |
|
| 1370 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1416 | + else { |
|
| 1417 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1418 | + } |
|
| 1371 | 1419 | } |
| 1372 | 1420 | |
| 1373 | 1421 | if ($isCompetingTag && !empty($competingElements[$tag])) |
| 1374 | 1422 | { |
| 1375 | 1423 | array_pop($competingElements[$tag]); |
| 1376 | 1424 | |
| 1377 | - if (count($competingElements[$tag]) > 0) |
|
| 1378 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1425 | + if (count($competingElements[$tag]) > 0) { |
|
| 1426 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1427 | + } |
|
| 1379 | 1428 | } |
| 1380 | 1429 | } |
| 1381 | 1430 | |
| 1382 | 1431 | // Unexpected closing tag, ex-ter-mi-nate. |
| 1383 | - else |
|
| 1384 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1432 | + else { |
|
| 1433 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1434 | + } |
|
| 1385 | 1435 | } |
| 1386 | 1436 | } |
| 1387 | 1437 | } |
| 1388 | 1438 | |
| 1389 | 1439 | // Close the code tags. |
| 1390 | - if ($inCode) |
|
| 1391 | - $parts[$i] .= '[/code]'; |
|
| 1440 | + if ($inCode) { |
|
| 1441 | + $parts[$i] .= '[/code]'; |
|
| 1442 | + } |
|
| 1392 | 1443 | |
| 1393 | 1444 | // The same for nobbc tags. |
| 1394 | - elseif ($inNoBbc) |
|
| 1395 | - $parts[$i] .= '[/nobbc]'; |
|
| 1445 | + elseif ($inNoBbc) { |
|
| 1446 | + $parts[$i] .= '[/nobbc]'; |
|
| 1447 | + } |
|
| 1396 | 1448 | |
| 1397 | 1449 | // Still inline tags left unclosed? Close them now, better late than never. |
| 1398 | - elseif (!empty($inlineElements)) |
|
| 1399 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1450 | + elseif (!empty($inlineElements)) { |
|
| 1451 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1452 | + } |
|
| 1400 | 1453 | |
| 1401 | 1454 | // Now close the block elements. |
| 1402 | - if (!empty($blockElements)) |
|
| 1403 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1455 | + if (!empty($blockElements)) { |
|
| 1456 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1457 | + } |
|
| 1404 | 1458 | |
| 1405 | 1459 | $text = implode('', $parts); |
| 1406 | 1460 | } |
| 1407 | 1461 | |
| 1408 | 1462 | // Final clean up of back to back tags. |
| 1409 | 1463 | $lastlen = 0; |
| 1410 | - while (strlen($text) !== $lastlen) |
|
| 1411 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1464 | + while (strlen($text) !== $lastlen) { |
|
| 1465 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1466 | + } |
|
| 1412 | 1467 | |
| 1413 | 1468 | return $text; |
| 1414 | 1469 | } |
@@ -1437,22 +1492,25 @@ discard block |
||
| 1437 | 1492 | $context['template_layers'] = array(); |
| 1438 | 1493 | // Lets make sure we aren't going to output anything nasty. |
| 1439 | 1494 | @ob_end_clean(); |
| 1440 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 1441 | - @ob_start('ob_gzhandler'); |
|
| 1442 | - else |
|
| 1443 | - @ob_start(); |
|
| 1495 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 1496 | + @ob_start('ob_gzhandler'); |
|
| 1497 | + } else { |
|
| 1498 | + @ob_start(); |
|
| 1499 | + } |
|
| 1444 | 1500 | |
| 1445 | 1501 | // If we don't have any locale better avoid broken js |
| 1446 | - if (empty($txt['lang_locale'])) |
|
| 1447 | - die(); |
|
| 1502 | + if (empty($txt['lang_locale'])) { |
|
| 1503 | + die(); |
|
| 1504 | + } |
|
| 1448 | 1505 | |
| 1449 | 1506 | $file_data = '(function ($) { |
| 1450 | 1507 | \'use strict\'; |
| 1451 | 1508 | |
| 1452 | 1509 | $.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {'; |
| 1453 | - foreach ($editortxt as $key => $val) |
|
| 1454 | - $file_data .= ' |
|
| 1510 | + foreach ($editortxt as $key => $val) { |
|
| 1511 | + $file_data .= ' |
|
| 1455 | 1512 | ' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ','; |
| 1513 | + } |
|
| 1456 | 1514 | |
| 1457 | 1515 | $file_data .= ' |
| 1458 | 1516 | dateFormat: "day.month.year" |
@@ -1520,8 +1578,9 @@ discard block |
||
| 1520 | 1578 | ) |
| 1521 | 1579 | ); |
| 1522 | 1580 | $icon_data = array(); |
| 1523 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1524 | - $icon_data[] = $row; |
|
| 1581 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1582 | + $icon_data[] = $row; |
|
| 1583 | + } |
|
| 1525 | 1584 | $smcFunc['db_free_result']($request); |
| 1526 | 1585 | |
| 1527 | 1586 | $icons = array(); |
@@ -1536,9 +1595,9 @@ discard block |
||
| 1536 | 1595 | } |
| 1537 | 1596 | |
| 1538 | 1597 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
| 1598 | + } else { |
|
| 1599 | + $icons = $temp; |
|
| 1539 | 1600 | } |
| 1540 | - else |
|
| 1541 | - $icons = $temp; |
|
| 1542 | 1601 | } |
| 1543 | 1602 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
| 1544 | 1603 | |
@@ -1579,8 +1638,9 @@ discard block |
||
| 1579 | 1638 | { |
| 1580 | 1639 | // Some general stuff. |
| 1581 | 1640 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
| 1582 | - if (!empty($context['drafts_autosave'])) |
|
| 1583 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1641 | + if (!empty($context['drafts_autosave'])) { |
|
| 1642 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1643 | + } |
|
| 1584 | 1644 | |
| 1585 | 1645 | // This really has some WYSIWYG stuff. |
| 1586 | 1646 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -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' : '') . (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(), '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 | |
@@ -1767,10 +1829,12 @@ discard block |
||
| 1767 | 1829 | |
| 1768 | 1830 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
| 1769 | 1831 | $disabled_tags = array(); |
| 1770 | - if (!empty($modSettings['disabledBBC'])) |
|
| 1771 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1772 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1773 | - $disabled_tags[] = 'flash'; |
|
| 1832 | + if (!empty($modSettings['disabledBBC'])) { |
|
| 1833 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1834 | + } |
|
| 1835 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1836 | + $disabled_tags[] = 'flash'; |
|
| 1837 | + } |
|
| 1774 | 1838 | |
| 1775 | 1839 | foreach ($disabled_tags as $tag) |
| 1776 | 1840 | { |
@@ -1780,9 +1844,10 @@ discard block |
||
| 1780 | 1844 | $context['disabled_tags']['orderedlist'] = true; |
| 1781 | 1845 | } |
| 1782 | 1846 | |
| 1783 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
| 1784 | - if ($tag === $thisTag) |
|
| 1847 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
| 1848 | + if ($tag === $thisTag) |
|
| 1785 | 1849 | $context['disabled_tags'][$tagNameBBC] = true; |
| 1850 | + } |
|
| 1786 | 1851 | |
| 1787 | 1852 | $context['disabled_tags'][trim($tag)] = true; |
| 1788 | 1853 | } |
@@ -1792,19 +1857,21 @@ discard block |
||
| 1792 | 1857 | $context['bbc_toolbar'] = array(); |
| 1793 | 1858 | foreach ($context['bbc_tags'] as $row => $tagRow) |
| 1794 | 1859 | { |
| 1795 | - if (!isset($context['bbc_toolbar'][$row])) |
|
| 1796 | - $context['bbc_toolbar'][$row] = array(); |
|
| 1860 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
| 1861 | + $context['bbc_toolbar'][$row] = array(); |
|
| 1862 | + } |
|
| 1797 | 1863 | $tagsRow = array(); |
| 1798 | 1864 | foreach ($tagRow as $tag) |
| 1799 | 1865 | { |
| 1800 | 1866 | if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']])) |
| 1801 | 1867 | { |
| 1802 | 1868 | $tagsRow[] = $tag['code']; |
| 1803 | - if (isset($tag['image'])) |
|
| 1804 | - $bbcodes_styles .= ' |
|
| 1869 | + if (isset($tag['image'])) { |
|
| 1870 | + $bbcodes_styles .= ' |
|
| 1805 | 1871 | .sceditor-button-' . $tag['code'] . ' div { |
| 1806 | 1872 | background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\'); |
| 1807 | 1873 | }'; |
| 1874 | + } |
|
| 1808 | 1875 | if (isset($tag['before'])) |
| 1809 | 1876 | { |
| 1810 | 1877 | $context['bbcodes_handlers'] .= ' |
@@ -1818,8 +1885,7 @@ discard block |
||
| 1818 | 1885 | });'; |
| 1819 | 1886 | } |
| 1820 | 1887 | |
| 1821 | - } |
|
| 1822 | - else |
|
| 1888 | + } else |
|
| 1823 | 1889 | { |
| 1824 | 1890 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1825 | 1891 | $tagsRow = array(); |
@@ -1830,14 +1896,16 @@ discard block |
||
| 1830 | 1896 | { |
| 1831 | 1897 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1832 | 1898 | $tagsRow = array(); |
| 1833 | - if (!isset($context['disabled_tags']['font'])) |
|
| 1834 | - $tagsRow[] = 'font'; |
|
| 1835 | - if (!isset($context['disabled_tags']['size'])) |
|
| 1836 | - $tagsRow[] = 'size'; |
|
| 1837 | - if (!isset($context['disabled_tags']['color'])) |
|
| 1838 | - $tagsRow[] = 'color'; |
|
| 1839 | - } |
|
| 1840 | - elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1899 | + if (!isset($context['disabled_tags']['font'])) { |
|
| 1900 | + $tagsRow[] = 'font'; |
|
| 1901 | + } |
|
| 1902 | + if (!isset($context['disabled_tags']['size'])) { |
|
| 1903 | + $tagsRow[] = 'size'; |
|
| 1904 | + } |
|
| 1905 | + if (!isset($context['disabled_tags']['color'])) { |
|
| 1906 | + $tagsRow[] = 'color'; |
|
| 1907 | + } |
|
| 1908 | + } elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1841 | 1909 | { |
| 1842 | 1910 | $tmp = array(); |
| 1843 | 1911 | $tagsRow[] = 'removeformat'; |
@@ -1848,13 +1916,15 @@ discard block |
||
| 1848 | 1916 | } |
| 1849 | 1917 | } |
| 1850 | 1918 | |
| 1851 | - if (!empty($tagsRow)) |
|
| 1852 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1919 | + if (!empty($tagsRow)) { |
|
| 1920 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1921 | + } |
|
| 1853 | 1922 | } |
| 1854 | - if (!empty($bbcodes_styles)) |
|
| 1855 | - $context['html_headers'] .= ' |
|
| 1923 | + if (!empty($bbcodes_styles)) { |
|
| 1924 | + $context['html_headers'] .= ' |
|
| 1856 | 1925 | <style>' . $bbcodes_styles . ' |
| 1857 | 1926 | </style>'; |
| 1927 | + } |
|
| 1858 | 1928 | } |
| 1859 | 1929 | |
| 1860 | 1930 | // Initialize smiley array... if not loaded before. |
@@ -1866,8 +1936,8 @@ discard block |
||
| 1866 | 1936 | ); |
| 1867 | 1937 | |
| 1868 | 1938 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
| 1869 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
| 1870 | - $context['smileys']['postform'][] = array( |
|
| 1939 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
| 1940 | + $context['smileys']['postform'][] = array( |
|
| 1871 | 1941 | 'smileys' => array( |
| 1872 | 1942 | array( |
| 1873 | 1943 | 'code' => ':)', |
@@ -1953,7 +2023,7 @@ discard block |
||
| 1953 | 2023 | ), |
| 1954 | 2024 | 'isLast' => true, |
| 1955 | 2025 | ); |
| 1956 | - elseif ($user_info['smiley_set'] != 'none') |
|
| 2026 | + } elseif ($user_info['smiley_set'] != 'none') |
|
| 1957 | 2027 | { |
| 1958 | 2028 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
| 1959 | 2029 | { |
@@ -1976,17 +2046,19 @@ discard block |
||
| 1976 | 2046 | |
| 1977 | 2047 | foreach ($context['smileys'] as $section => $smileyRows) |
| 1978 | 2048 | { |
| 1979 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
| 1980 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2049 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
| 2050 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2051 | + } |
|
| 1981 | 2052 | |
| 1982 | - if (!empty($smileyRows)) |
|
| 1983 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2053 | + if (!empty($smileyRows)) { |
|
| 2054 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2055 | + } |
|
| 1984 | 2056 | } |
| 1985 | 2057 | |
| 1986 | 2058 | cache_put_data('posting_smileys', $context['smileys'], 480); |
| 2059 | + } else { |
|
| 2060 | + $context['smileys'] = $temp; |
|
| 1987 | 2061 | } |
| 1988 | - else |
|
| 1989 | - $context['smileys'] = $temp; |
|
| 1990 | 2062 | } |
| 1991 | 2063 | } |
| 1992 | 2064 | |
@@ -2012,8 +2084,9 @@ discard block |
||
| 2012 | 2084 | loadTemplate('GenericControls'); |
| 2013 | 2085 | |
| 2014 | 2086 | // Some javascript ma'am? |
| 2015 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
| 2016 | - loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2087 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
| 2088 | + loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2089 | + } |
|
| 2017 | 2090 | |
| 2018 | 2091 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
| 2019 | 2092 | |
@@ -2026,8 +2099,8 @@ discard block |
||
| 2026 | 2099 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
| 2027 | 2100 | |
| 2028 | 2101 | // Log this into our collection. |
| 2029 | - if ($isNew) |
|
| 2030 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2102 | + if ($isNew) { |
|
| 2103 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2031 | 2104 | 'id' => $verificationOptions['id'], |
| 2032 | 2105 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
| 2033 | 2106 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2038,13 +2111,15 @@ discard block |
||
| 2038 | 2111 | 'questions' => array(), |
| 2039 | 2112 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
| 2040 | 2113 | ); |
| 2114 | + } |
|
| 2041 | 2115 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
| 2042 | 2116 | |
| 2043 | 2117 | // Is there actually going to be anything? |
| 2044 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
| 2045 | - return false; |
|
| 2046 | - elseif (!$isNew && !$do_test) |
|
| 2047 | - return true; |
|
| 2118 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
| 2119 | + return false; |
|
| 2120 | + } elseif (!$isNew && !$do_test) { |
|
| 2121 | + return true; |
|
| 2122 | + } |
|
| 2048 | 2123 | |
| 2049 | 2124 | // Sanitize reCAPTCHA fields? |
| 2050 | 2125 | if ($thisVerification['can_recaptcha']) |
@@ -2057,11 +2132,12 @@ discard block |
||
| 2057 | 2132 | } |
| 2058 | 2133 | |
| 2059 | 2134 | // Add javascript for the object. |
| 2060 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
| 2061 | - $context['insert_after_template'] .= ' |
|
| 2135 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
| 2136 | + $context['insert_after_template'] .= ' |
|
| 2062 | 2137 | <script> |
| 2063 | 2138 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
| 2064 | 2139 | </script>'; |
| 2140 | + } |
|
| 2065 | 2141 | |
| 2066 | 2142 | // If we want questions do we have a cache of all the IDs? |
| 2067 | 2143 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2084,8 +2160,9 @@ discard block |
||
| 2084 | 2160 | unset ($row['id_question']); |
| 2085 | 2161 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
| 2086 | 2162 | $row['answers'] = smf_json_decode($row['answers'], true); |
| 2087 | - foreach ($row['answers'] as $k => $v) |
|
| 2088 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2163 | + foreach ($row['answers'] as $k => $v) { |
|
| 2164 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2165 | + } |
|
| 2089 | 2166 | |
| 2090 | 2167 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
| 2091 | 2168 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2096,35 +2173,42 @@ discard block |
||
| 2096 | 2173 | } |
| 2097 | 2174 | } |
| 2098 | 2175 | |
| 2099 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
| 2100 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2176 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
| 2177 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2178 | + } |
|
| 2101 | 2179 | |
| 2102 | 2180 | // Do we need to refresh the verification? |
| 2103 | - 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'])) |
|
| 2104 | - $force_refresh = true; |
|
| 2105 | - else |
|
| 2106 | - $force_refresh = false; |
|
| 2181 | + 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'])) { |
|
| 2182 | + $force_refresh = true; |
|
| 2183 | + } else { |
|
| 2184 | + $force_refresh = false; |
|
| 2185 | + } |
|
| 2107 | 2186 | |
| 2108 | 2187 | // This can also force a fresh, although unlikely. |
| 2109 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2110 | - $force_refresh = true; |
|
| 2188 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2189 | + $force_refresh = true; |
|
| 2190 | + } |
|
| 2111 | 2191 | |
| 2112 | 2192 | $verification_errors = array(); |
| 2113 | 2193 | // Start with any testing. |
| 2114 | 2194 | if ($do_test) |
| 2115 | 2195 | { |
| 2116 | 2196 | // This cannot happen! |
| 2117 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
| 2118 | - fatal_lang_error('no_access', false); |
|
| 2197 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
| 2198 | + fatal_lang_error('no_access', false); |
|
| 2199 | + } |
|
| 2119 | 2200 | // ... nor this! |
| 2120 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2121 | - fatal_lang_error('no_access', false); |
|
| 2201 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2202 | + fatal_lang_error('no_access', false); |
|
| 2203 | + } |
|
| 2122 | 2204 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
| 2123 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
| 2124 | - fatal_lang_error('no_access', false); |
|
| 2205 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
| 2206 | + fatal_lang_error('no_access', false); |
|
| 2207 | + } |
|
| 2125 | 2208 | // While we're here, did the user do something bad? |
| 2126 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
| 2127 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2209 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
| 2210 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2211 | + } |
|
| 2128 | 2212 | |
| 2129 | 2213 | if ($thisVerification['can_recaptcha']) |
| 2130 | 2214 | { |
@@ -2135,22 +2219,25 @@ discard block |
||
| 2135 | 2219 | { |
| 2136 | 2220 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
| 2137 | 2221 | |
| 2138 | - if (!$resp->isSuccess()) |
|
| 2139 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2222 | + if (!$resp->isSuccess()) { |
|
| 2223 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2224 | + } |
|
| 2225 | + } else { |
|
| 2226 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2140 | 2227 | } |
| 2141 | - else |
|
| 2142 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2143 | 2228 | } |
| 2144 | - 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'])) |
|
| 2145 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2229 | + 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'])) { |
|
| 2230 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2231 | + } |
|
| 2146 | 2232 | if ($thisVerification['number_questions']) |
| 2147 | 2233 | { |
| 2148 | 2234 | $incorrectQuestions = array(); |
| 2149 | 2235 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
| 2150 | 2236 | { |
| 2151 | 2237 | // We don't have this question any more, thus no answers. |
| 2152 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
| 2153 | - continue; |
|
| 2238 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
| 2239 | + continue; |
|
| 2240 | + } |
|
| 2154 | 2241 | // This is quite complex. We have our question but it might have multiple answers. |
| 2155 | 2242 | // First, did they actually answer this question? |
| 2156 | 2243 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2162,24 +2249,28 @@ discard block |
||
| 2162 | 2249 | else |
| 2163 | 2250 | { |
| 2164 | 2251 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
| 2165 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
| 2166 | - $incorrectQuestions[] = $q; |
|
| 2252 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
| 2253 | + $incorrectQuestions[] = $q; |
|
| 2254 | + } |
|
| 2167 | 2255 | } |
| 2168 | 2256 | } |
| 2169 | 2257 | |
| 2170 | - if (!empty($incorrectQuestions)) |
|
| 2171 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2258 | + if (!empty($incorrectQuestions)) { |
|
| 2259 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2260 | + } |
|
| 2172 | 2261 | } |
| 2173 | 2262 | } |
| 2174 | 2263 | |
| 2175 | 2264 | // Any errors means we refresh potentially. |
| 2176 | 2265 | if (!empty($verification_errors)) |
| 2177 | 2266 | { |
| 2178 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
| 2179 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2267 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
| 2268 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2269 | + } |
|
| 2180 | 2270 | // Too many errors? |
| 2181 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
| 2182 | - $force_refresh = true; |
|
| 2271 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
| 2272 | + $force_refresh = true; |
|
| 2273 | + } |
|
| 2183 | 2274 | |
| 2184 | 2275 | // Keep a track of these. |
| 2185 | 2276 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2212,8 +2303,9 @@ discard block |
||
| 2212 | 2303 | // Are we overriding the range? |
| 2213 | 2304 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
| 2214 | 2305 | |
| 2215 | - for ($i = 0; $i < 6; $i++) |
|
| 2216 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2306 | + for ($i = 0; $i < 6; $i++) { |
|
| 2307 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2308 | + } |
|
| 2217 | 2309 | } |
| 2218 | 2310 | |
| 2219 | 2311 | // Getting some new questions? |
@@ -2221,8 +2313,9 @@ discard block |
||
| 2221 | 2313 | { |
| 2222 | 2314 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
| 2223 | 2315 | $possible_langs = array(); |
| 2224 | - if (isset($_SESSION['language'])) |
|
| 2225 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2316 | + if (isset($_SESSION['language'])) { |
|
| 2317 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2318 | + } |
|
| 2226 | 2319 | if (!empty($user_info['language'])); |
| 2227 | 2320 | $possible_langs[] = $user_info['language']; |
| 2228 | 2321 | $possible_langs[] = $language; |
@@ -2241,8 +2334,7 @@ discard block |
||
| 2241 | 2334 | } |
| 2242 | 2335 | } |
| 2243 | 2336 | } |
| 2244 | - } |
|
| 2245 | - else |
|
| 2337 | + } else |
|
| 2246 | 2338 | { |
| 2247 | 2339 | // Same questions as before. |
| 2248 | 2340 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2252,8 +2344,9 @@ discard block |
||
| 2252 | 2344 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
| 2253 | 2345 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
| 2254 | 2346 | { |
| 2255 | - if (!isset($context['html_headers'])) |
|
| 2256 | - $context['html_headers'] = ''; |
|
| 2347 | + if (!isset($context['html_headers'])) { |
|
| 2348 | + $context['html_headers'] = ''; |
|
| 2349 | + } |
|
| 2257 | 2350 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
| 2258 | 2351 | } |
| 2259 | 2352 | |
@@ -2279,11 +2372,13 @@ discard block |
||
| 2279 | 2372 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
| 2280 | 2373 | |
| 2281 | 2374 | // Return errors if we have them. |
| 2282 | - if (!empty($verification_errors)) |
|
| 2283 | - return $verification_errors; |
|
| 2375 | + if (!empty($verification_errors)) { |
|
| 2376 | + return $verification_errors; |
|
| 2377 | + } |
|
| 2284 | 2378 | // If we had a test that one, make a note. |
| 2285 | - elseif ($do_test) |
|
| 2286 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2379 | + elseif ($do_test) { |
|
| 2380 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2381 | + } |
|
| 2287 | 2382 | |
| 2288 | 2383 | // Say that everything went well chaps. |
| 2289 | 2384 | return true; |
@@ -2308,8 +2403,9 @@ discard block |
||
| 2308 | 2403 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
| 2309 | 2404 | |
| 2310 | 2405 | // If we're just checking the callback function is registered return true or false. |
| 2311 | - if ($checkRegistered != null) |
|
| 2312 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2406 | + if ($checkRegistered != null) { |
|
| 2407 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2408 | + } |
|
| 2313 | 2409 | |
| 2314 | 2410 | checkSession('get'); |
| 2315 | 2411 | loadTemplate('Xml'); |
@@ -2460,24 +2556,27 @@ discard block |
||
| 2460 | 2556 | foreach ($possible_versions as $ver) |
| 2461 | 2557 | { |
| 2462 | 2558 | $ver = trim($ver); |
| 2463 | - if (strpos($ver, 'SMF') === 0) |
|
| 2464 | - $versions[] = $ver; |
|
| 2559 | + if (strpos($ver, 'SMF') === 0) { |
|
| 2560 | + $versions[] = $ver; |
|
| 2561 | + } |
|
| 2465 | 2562 | } |
| 2466 | 2563 | } |
| 2467 | 2564 | $smcFunc['db_free_result']($request); |
| 2468 | 2565 | |
| 2469 | 2566 | // Just in case we don't have ANYthing. |
| 2470 | - if (empty($versions)) |
|
| 2471 | - $versions = array('SMF 2.0'); |
|
| 2567 | + if (empty($versions)) { |
|
| 2568 | + $versions = array('SMF 2.0'); |
|
| 2569 | + } |
|
| 2472 | 2570 | |
| 2473 | - foreach ($versions as $id => $version) |
|
| 2474 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2571 | + foreach ($versions as $id => $version) { |
|
| 2572 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2475 | 2573 | $xml_data['items']['children'][] = array( |
| 2476 | 2574 | 'attributes' => array( |
| 2477 | 2575 | 'id' => $id, |
| 2478 | 2576 | ), |
| 2479 | 2577 | 'value' => $version, |
| 2480 | 2578 | ); |
| 2579 | + } |
|
| 2481 | 2580 | |
| 2482 | 2581 | return $xml_data; |
| 2483 | 2582 | } |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | * @version 2.1 Beta 3 |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if (!defined('SMF')) |
|
| 15 | +if (!defined('SMF')) { |
|
| 16 | 16 | die('No direct access...'); |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Report a post or profile to the moderator... ask for a comment. |
@@ -35,10 +36,11 @@ discard block |
||
| 35 | 36 | |
| 36 | 37 | // You can't use this if it's off or you are not allowed to do it. |
| 37 | 38 | // If we don't have the ID of something to report, we'll die with a no_access error below |
| 38 | - if (isset($_REQUEST['msg'])) |
|
| 39 | - isAllowedTo('report_any'); |
|
| 40 | - elseif (isset($_REQUEST['u'])) |
|
| 41 | - isAllowedTo('report_user'); |
|
| 39 | + if (isset($_REQUEST['msg'])) { |
|
| 40 | + isAllowedTo('report_any'); |
|
| 41 | + } elseif (isset($_REQUEST['u'])) { |
|
| 42 | + isAllowedTo('report_user'); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | // Previewing or modifying? |
| 44 | 46 | if (isset($_POST['preview']) && !isset($_POST['save'])) |
@@ -56,19 +58,23 @@ discard block |
||
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | // If they're posting, it should be processed by ReportToModerator2. |
| 59 | - if ((isset($_POST[$context['session_var']]) || isset($_POST['save'])) && empty($context['post_errors']) && !isset($_POST['preview'])) |
|
| 60 | - ReportToModerator2(); |
|
| 61 | + if ((isset($_POST[$context['session_var']]) || isset($_POST['save'])) && empty($context['post_errors']) && !isset($_POST['preview'])) { |
|
| 62 | + ReportToModerator2(); |
|
| 63 | + } |
|
| 61 | 64 | |
| 62 | 65 | // We need a message ID or user ID to check! |
| 63 | - if (empty($_REQUEST['msg']) && empty($_REQUEST['mid']) && empty($_REQUEST['u'])) |
|
| 64 | - fatal_lang_error('no_access', false); |
|
| 66 | + if (empty($_REQUEST['msg']) && empty($_REQUEST['mid']) && empty($_REQUEST['u'])) { |
|
| 67 | + fatal_lang_error('no_access', false); |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | // For compatibility, accept mid, but we should be using msg. (not the flavor kind!) |
| 67 | - if (!empty($_REQUEST['msg']) || !empty($_REQUEST['mid'])) |
|
| 68 | - $_REQUEST['msg'] = empty($_REQUEST['msg']) ? (int) $_REQUEST['mid'] : (int) $_REQUEST['msg']; |
|
| 71 | + if (!empty($_REQUEST['msg']) || !empty($_REQUEST['mid'])) { |
|
| 72 | + $_REQUEST['msg'] = empty($_REQUEST['msg']) ? (int) $_REQUEST['mid'] : (int) $_REQUEST['msg']; |
|
| 73 | + } |
|
| 69 | 74 | // msg and mid empty - assume we're reporting a user |
| 70 | - elseif (!empty($_REQUEST['u'])) |
|
| 71 | - $_REQUEST['u'] = (int) $_REQUEST['u']; |
|
| 75 | + elseif (!empty($_REQUEST['u'])) { |
|
| 76 | + $_REQUEST['u'] = (int) $_REQUEST['u']; |
|
| 77 | + } |
|
| 72 | 78 | |
| 73 | 79 | // Set up some form values |
| 74 | 80 | $context['report_type'] = isset($_REQUEST['msg']) ? 'msg' : 'u'; |
@@ -89,8 +95,9 @@ discard block |
||
| 89 | 95 | 'id_msg' => $_REQUEST['msg'], |
| 90 | 96 | ) |
| 91 | 97 | ); |
| 92 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 93 | - fatal_lang_error('no_board', false); |
|
| 98 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 99 | + fatal_lang_error('no_board', false); |
|
| 100 | + } |
|
| 94 | 101 | list ($_REQUEST['msg'], $member, $starter) = $smcFunc['db_fetch_row']($result); |
| 95 | 102 | $smcFunc['db_free_result']($result); |
| 96 | 103 | |
@@ -101,8 +108,7 @@ discard block |
||
| 101 | 108 | |
| 102 | 109 | // The submit URL is different for users than it is for posts |
| 103 | 110 | $context['submit_url'] = $scripturl . '?action=reporttm;msg=' . $_REQUEST['msg'] . ';topic=' . $topic; |
| 104 | - } |
|
| 105 | - else |
|
| 111 | + } else |
|
| 106 | 112 | { |
| 107 | 113 | // Check the user's ID |
| 108 | 114 | $result = $smcFunc['db_query']('', ' |
@@ -114,8 +120,9 @@ discard block |
||
| 114 | 120 | ) |
| 115 | 121 | ); |
| 116 | 122 | |
| 117 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 118 | - fatal_lang_error('no_user', false); |
|
| 123 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 124 | + fatal_lang_error('no_user', false); |
|
| 125 | + } |
|
| 119 | 126 | list($_REQUEST['u'], $display_name, $username) = $smcFunc['db_fetch_row']($result); |
| 120 | 127 | |
| 121 | 128 | $context['current_user'] = $_REQUEST['u']; |
@@ -170,10 +177,11 @@ discard block |
||
| 170 | 177 | is_not_guest(); |
| 171 | 178 | |
| 172 | 179 | // You must have the proper permissions! |
| 173 | - if (isset($_REQUEST['msg'])) |
|
| 174 | - isAllowedTo('report_any'); |
|
| 175 | - else |
|
| 176 | - isAllowedTo('report_user'); |
|
| 180 | + if (isset($_REQUEST['msg'])) { |
|
| 181 | + isAllowedTo('report_any'); |
|
| 182 | + } else { |
|
| 183 | + isAllowedTo('report_user'); |
|
| 184 | + } |
|
| 177 | 185 | |
| 178 | 186 | // Make sure they aren't spamming. |
| 179 | 187 | spamProtection('reporttm'); |
@@ -187,17 +195,20 @@ discard block |
||
| 187 | 195 | $post_errors = array(); |
| 188 | 196 | |
| 189 | 197 | // Check their session. |
| 190 | - if (checkSession('post', '', false) != '') |
|
| 191 | - $post_errors[] = 'session_timeout'; |
|
| 198 | + if (checkSession('post', '', false) != '') { |
|
| 199 | + $post_errors[] = 'session_timeout'; |
|
| 200 | + } |
|
| 192 | 201 | |
| 193 | 202 | // Make sure we have a comment and it's clean. |
| 194 | - if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '') |
|
| 195 | - $post_errors[] = 'no_comment'; |
|
| 203 | + if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '') { |
|
| 204 | + $post_errors[] = 'no_comment'; |
|
| 205 | + } |
|
| 196 | 206 | |
| 197 | 207 | $poster_comment = strtr($smcFunc['htmlspecialchars']($_POST['comment']), array("\r" => '', "\t" => '')); |
| 198 | 208 | |
| 199 | - if ($smcFunc['strlen']($poster_comment) > 254) |
|
| 200 | - $post_errors[] = 'post_too_long'; |
|
| 209 | + if ($smcFunc['strlen']($poster_comment) > 254) { |
|
| 210 | + $post_errors[] = 'post_too_long'; |
|
| 211 | + } |
|
| 201 | 212 | |
| 202 | 213 | // Any errors? |
| 203 | 214 | if (!empty($post_errors)) |
@@ -205,8 +216,9 @@ discard block |
||
| 205 | 216 | loadLanguage('Errors'); |
| 206 | 217 | |
| 207 | 218 | $context['post_errors'] = array(); |
| 208 | - foreach ($post_errors as $post_error) |
|
| 209 | - $context['post_errors'][$post_error] = $txt['error_' . $post_error]; |
|
| 219 | + foreach ($post_errors as $post_error) { |
|
| 220 | + $context['post_errors'][$post_error] = $txt['error_' . $post_error]; |
|
| 221 | + } |
|
| 210 | 222 | |
| 211 | 223 | return ReportToModerator(); |
| 212 | 224 | } |
@@ -215,8 +227,7 @@ discard block |
||
| 215 | 227 | { |
| 216 | 228 | // Handle this elsewhere to keep things from getting too long |
| 217 | 229 | reportPost($_POST['msg'], $poster_comment); |
| 218 | - } |
|
| 219 | - else |
|
| 230 | + } else |
|
| 220 | 231 | { |
| 221 | 232 | reportUser($_POST['u'], $poster_comment); |
| 222 | 233 | } |
@@ -247,8 +258,9 @@ discard block |
||
| 247 | 258 | 'id_msg' => $_POST['msg'], |
| 248 | 259 | ) |
| 249 | 260 | ); |
| 250 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 251 | - fatal_lang_error('no_board', false); |
|
| 261 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 262 | + fatal_lang_error('no_board', false); |
|
| 263 | + } |
|
| 252 | 264 | $message = $smcFunc['db_fetch_assoc']($request); |
| 253 | 265 | $smcFunc['db_free_result']($request); |
| 254 | 266 | |
@@ -264,18 +276,20 @@ discard block |
||
| 264 | 276 | 'ignored' => 1, |
| 265 | 277 | ) |
| 266 | 278 | ); |
| 267 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 268 | - list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 279 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 280 | + list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 281 | + } |
|
| 269 | 282 | |
| 270 | 283 | $smcFunc['db_free_result']($request); |
| 271 | 284 | |
| 272 | 285 | // If we're just going to ignore these, then who gives a monkeys... |
| 273 | - if (!empty($ignore)) |
|
| 274 | - redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']); |
|
| 286 | + if (!empty($ignore)) { |
|
| 287 | + redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']); |
|
| 288 | + } |
|
| 275 | 289 | |
| 276 | 290 | // Already reported? My god, we could be dealing with a real rogue here... |
| 277 | - if (!empty($id_report)) |
|
| 278 | - $smcFunc['db_query']('', ' |
|
| 291 | + if (!empty($id_report)) { |
|
| 292 | + $smcFunc['db_query']('', ' |
|
| 279 | 293 | UPDATE {db_prefix}log_reported |
| 280 | 294 | SET num_reports = num_reports + 1, time_updated = {int:current_time} |
| 281 | 295 | WHERE id_report = {int:id_report}', |
@@ -284,11 +298,13 @@ discard block |
||
| 284 | 298 | 'id_report' => $id_report, |
| 285 | 299 | ) |
| 286 | 300 | ); |
| 301 | + } |
|
| 287 | 302 | // Otherwise, we shall make one! |
| 288 | 303 | else |
| 289 | 304 | { |
| 290 | - if (empty($message['real_name'])) |
|
| 291 | - $message['real_name'] = $message['poster_name']; |
|
| 305 | + if (empty($message['real_name'])) { |
|
| 306 | + $message['real_name'] = $message['poster_name']; |
|
| 307 | + } |
|
| 292 | 308 | |
| 293 | 309 | $id_report = $smcFunc['db_insert']('', |
| 294 | 310 | '{db_prefix}log_reported', |
@@ -367,8 +383,9 @@ discard block |
||
| 367 | 383 | 'id_member' => $_POST['u'] |
| 368 | 384 | ) |
| 369 | 385 | ); |
| 370 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 371 | - fatal_lang_error('no_user', false); |
|
| 386 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 387 | + fatal_lang_error('no_user', false); |
|
| 388 | + } |
|
| 372 | 389 | $user = $smcFunc['db_fetch_assoc']($request); |
| 373 | 390 | $smcFunc['db_free_result']($request); |
| 374 | 391 | |
@@ -388,18 +405,20 @@ discard block |
||
| 388 | 405 | 'ignored' => 1, |
| 389 | 406 | ) |
| 390 | 407 | ); |
| 391 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 392 | - list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 408 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 409 | + list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 410 | + } |
|
| 393 | 411 | |
| 394 | 412 | $smcFunc['db_free_result']($request); |
| 395 | 413 | |
| 396 | 414 | // If we're just going to ignore these, then who gives a monkeys... |
| 397 | - if (!empty($ignore)) |
|
| 398 | - redirectexit('action=profile;u=' . $_POST['u']); |
|
| 415 | + if (!empty($ignore)) { |
|
| 416 | + redirectexit('action=profile;u=' . $_POST['u']); |
|
| 417 | + } |
|
| 399 | 418 | |
| 400 | 419 | // Already reported? My god, we could be dealing with a real rogue here... |
| 401 | - if (!empty($id_report)) |
|
| 402 | - $smcFunc['db_query']('', ' |
|
| 420 | + if (!empty($id_report)) { |
|
| 421 | + $smcFunc['db_query']('', ' |
|
| 403 | 422 | UPDATE {db_prefix}log_reported |
| 404 | 423 | SET num_reports = num_reports + 1, time_updated = {int:current_time} |
| 405 | 424 | WHERE id_report = {int:id_report}', |
@@ -408,6 +427,7 @@ discard block |
||
| 408 | 427 | 'id_report' => $id_report, |
| 409 | 428 | ) |
| 410 | 429 | ); |
| 430 | + } |
|
| 411 | 431 | // Otherwise, we shall make one! |
| 412 | 432 | else |
| 413 | 433 | { |
@@ -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 |
@@ -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 |