Zeile 141 | Zeile 141 |
---|
}
// If MyCode needs to be replaced, first filter out [code] and [php] tags.
|
}
// If MyCode needs to be replaced, first filter out [code] and [php] tags.
|
| $code_matches = array();
|
if(!empty($this->options['allow_mycode']) && $mybb->settings['allowcodemycode'] == 1) { // This code is reserved and could break codes
| if(!empty($this->options['allow_mycode']) && $mybb->settings['allowcodemycode'] == 1) { // This code is reserved and could break codes
|
Zeile 367 | Zeile 368 |
---|
if($mybb->settings['allowfontmycode'] == 1) {
|
if($mybb->settings['allowfontmycode'] == 1) {
|
$nestable_mycode['font']['regex'] = "#\[font=([a-z0-9 ,\-_'\"]+)\](.*?)\[/font\]#si"; $nestable_mycode['font']['replacement'] = "<span style=\"font-family: $1;\" class=\"mycode_font\">$2</span>";
| $nestable_mycode['font']['regex'] = "#\[font=(\"?)([a-z0-9 ,\-_']+)\\1\](.*?)\[/font\]#si"; $nestable_mycode['font']['replacement'] = "<span style=\"font-family: $2;\" class=\"mycode_font\">$3</span>";
|
++$nestable_count; }
| ++$nestable_count; }
|
Zeile 650 | Zeile 651 |
---|
$badword['replacement'] = "*****"; }
|
$badword['replacement'] = "*****"; }
|
if($badword['regex'])
| if(!$badword['regex'])
|
{
|
{
|
$message = preg_replace('#'.$badword['badword'].'#is', $badword['replacement'], $message);
| $badword['badword'] = $this->generate_regex($badword['badword']);
|
}
|
}
|
else { // Take into account the position offset for our last replacement. $badword['badword'] = str_replace('\*', '([a-zA-Z0-9_\*]{1})', preg_quote($badword['badword'], "#"));
| |
|
|
// Ensure we run the replacement enough times but not recursively (i.e. not while(preg_match..)) $message = preg_replace("#(^|\W)".$badword['badword']."(?=\W|$)#i", '\1'.$badword['replacement'], $message); }
| $message = preg_replace('#'.$badword['badword'].'#is', $badword['replacement'], $message); } } if(!empty($this->options['strip_tags'])) { $message = strip_tags($message); } return $message; }
/** * Generates REGEX patterns based on user defined badword string. * * @param string $badword The word defined to replace. * @return string The regex pattern to match the word or null on error. */ function generate_regex($bad_word = "") { if($bad_word == "") { return; }
// Neutralize escape character, regex operators, multiple adjacent wildcards and generate pattern $ptrn = array('/\\\\/', '/([\[\^\$\.\|\?\(\)\{\}]{1})/', '/\*\++/', '/\++\*/', '/\*+/'); $rplc = array('\\\\\\\\','\\\\${1}', '*', '*', '[^\s\n]*'); $bad_word = preg_replace($ptrn, $rplc, $bad_word); // Count + and generate pattern $bad_word = explode('+', $bad_word); $trap = ""; $plus = 0; foreach($bad_word as $bad_piece) { if($bad_piece) { $trap .= $plus ? '[^\s\n]{'.$plus.'}'.$bad_piece : $bad_piece; $plus = 1; } else { $plus++;
|
}
|
}
|
} if(!empty($this->options['strip_tags']))
| } // Handle trailing + if($plus > 1)
|
{
|
{
|
$message = strip_tags($message);
| $trap .= '[^\s\n]{'.($plus-1).'}';
|
}
|
}
|
return $message;
| return '\b'.$trap.'\b';
|
}
/**
| }
/**
|
Zeile 765 | Zeile 804 |
---|
} else {
|
} else {
|
$replace = "\n{$lang->quote}\n--\n$1\n--\n";
| $replace = empty($this->options['signature_parse']) ? "\n{$lang->quote}\n--\n$1\n--\n" : "$1";
|
$replace_callback = array($this, 'mycode_parse_post_quotes_callback2'); }
| $replace_callback = array($this, 'mycode_parse_post_quotes_callback2'); }
|
Zeile 918 | Zeile 957 |
---|
* @return string The parsed message. */ function mycode_parse_code($code, $text_only=false)
|
* @return string The parsed message. */ function mycode_parse_code($code, $text_only=false)
|
{ global $lang, $templates;
if($text_only == true) { return "\n{$lang->code}\n--\n{$code}\n--\n"; }
| { global $lang, $templates;
if($text_only == true) { return empty($this->options['signature_parse']) ? "\n{$lang->code}\n--\n{$code}\n--\n" : $code; }
|
// Clean the string before parsing. $code = preg_replace('#^(\t*)(\n|\r|\0|\x0B| )*#', '\\1', $code); $code = rtrim($code);
| // Clean the string before parsing. $code = preg_replace('#^(\t*)(\n|\r|\0|\x0B| )*#', '\\1', $code); $code = rtrim($code);
|
Zeile 955 | Zeile 994 |
---|
function mycode_parse_code_callback($matches) { return $this->mycode_parse_code($matches[1], true);
|
function mycode_parse_code_callback($matches) { return $this->mycode_parse_code($matches[1], true);
|
}
/** * Parses PHP code MyCode. *
| }
/** * Parses PHP code MyCode. *
|
* @param string $str The message to be parsed * @param boolean $bare_return Whether or not it should return it as pre-wrapped in a div or not. * @param boolean $text_only Are we formatting as text?
| * @param string $str The message to be parsed * @param boolean $bare_return Whether or not it should return it as pre-wrapped in a div or not. * @param boolean $text_only Are we formatting as text?
|
Zeile 971 | Zeile 1010 |
---|
if($text_only == true) {
|
if($text_only == true) {
|
return "\n{$lang->php_code}\n--\n$str\n--\n";
| return empty($this->options['signature_parse']) ? "\n{$lang->php_code}\n--\n{$str}\n--\n" : $str;
|
}
// Clean the string before parsing except tab spaces.
| }
// Clean the string before parsing except tab spaces.
|
Zeile 1026 | Zeile 1065 |
---|
$code = str_replace("<code>", "<div dir=\"ltr\"><code>", $code); $code = str_replace("</code>", "</code></div>", $code); $code = preg_replace("# *$#", "", $code);
|
$code = str_replace("<code>", "<div dir=\"ltr\"><code>", $code); $code = str_replace("</code>", "</code></div>", $code); $code = preg_replace("# *$#", "", $code);
|
|
|
if($bare_return) { return $code;
| if($bare_return) { return $code;
|
Zeile 1059 | Zeile 1098 |
---|
{ global $templates; if(!preg_match("#^[a-z0-9]+://#i", $url))
|
{ global $templates; if(!preg_match("#^[a-z0-9]+://#i", $url))
|
{
| {
|
$url = "http://".$url;
|
$url = "http://".$url;
|
}
| }
|
if(!empty($this->options['allow_html'])) { $url = $this->parse_html($url);
|
if(!empty($this->options['allow_html'])) { $url = $this->parse_html($url);
|
}
| }
|
if(!$name) {
| if(!$name) {
|
Zeile 1074 | Zeile 1113 |
---|
}
if($name == $url && (!isset($this->options['shorten_urls']) || !empty($this->options['shorten_urls'])))
|
}
if($name == $url && (!isset($this->options['shorten_urls']) || !empty($this->options['shorten_urls'])))
|
{
| {
|
$name = htmlspecialchars_decode($name); if(my_strlen($name) > 55) {
| $name = htmlspecialchars_decode($name); if(my_strlen($name) > 55) {
|
Zeile 1094 | Zeile 1133 |
---|
// Fix some entities in URLs $url = $this->encode_url($url);
|
// Fix some entities in URLs $url = $this->encode_url($url);
|
$name = preg_replace("#&\#([0-9]+);#si", "&#$1;", $name); // Fix & but allow unicode
| $name = $this->parse_badwords(preg_replace("#&\#([0-9]+);#si", "&#$1;", $name)); // Fix & but allow unicode, filter bad words
|
eval("\$mycode_url = \"".$templates->get("mycode_url", 1, 0)."\";"); return $mycode_url;
| eval("\$mycode_url = \"".$templates->get("mycode_url", 1, 0)."\";"); return $mycode_url;
|
Zeile 1154 | Zeile 1191 |
---|
$css_align = ''; if($align == "right")
|
$css_align = ''; if($align == "right")
|
{
| {
|
$css_align = ' style="float: right;"'; } else if($align == "left") { $css_align = ' style="float: left;"';
|
$css_align = ' style="float: right;"'; } else if($align == "left") { $css_align = ' style="float: left;"';
|
}
| }
|
if($align)
|
if($align)
|
{
| {
|
$this->clear_needed = true; }
$alt = basename($url); $alt = htmlspecialchars_decode($alt); if(my_strlen($alt) > 55)
|
$this->clear_needed = true; }
$alt = basename($url); $alt = htmlspecialchars_decode($alt); if(my_strlen($alt) > 55)
|
{
| {
|
$alt = my_substr($alt, 0, 40).'...'.my_substr($alt, -10);
|
$alt = my_substr($alt, 0, 40).'...'.my_substr($alt, -10);
|
} $alt = htmlspecialchars_uni($alt);
| } $alt = $this->encode_url($alt);
|
$alt = $lang->sprintf($lang->posted_image, $alt); $width = $height = '';
| $alt = $lang->sprintf($lang->posted_image, $alt); $width = $height = '';
|
Zeile 1187 | Zeile 1224 |
---|
eval("\$mycode_img = \"".$templates->get("mycode_img", 1, 0)."\";"); return $mycode_img;
|
eval("\$mycode_img = \"".$templates->get("mycode_img", 1, 0)."\";"); return $mycode_img;
|
}
/** * Parses IMG MyCode. * * @param array $matches Matches. * @return string Image code.
| }
/** * Parses IMG MyCode. * * @param array $matches Matches. * @return string Image code.
|
*/ function mycode_parse_img_callback1($matches)
|
*/ function mycode_parse_img_callback1($matches)
|
{
| {
|
return $this->mycode_parse_img($matches[2]); }
| return $this->mycode_parse_img($matches[2]); }
|
Zeile 1217 | Zeile 1254 |
---|
* @param array $matches Matches. * @return string Image code. */
|
* @param array $matches Matches. * @return string Image code. */
|
function mycode_parse_img_callback3($matches) { return $this->mycode_parse_img($matches[3], array(), $matches[1]); }
/** * Parses IMG MyCode. * * @param array $matches Matches. * @return string Image code. */
| function mycode_parse_img_callback3($matches) { return $this->mycode_parse_img($matches[3], array(), $matches[1]); }
/** * Parses IMG MyCode. * * @param array $matches Matches. * @return string Image code. */
|
function mycode_parse_img_callback4($matches) { return $this->mycode_parse_img($matches[5], array($matches[1], $matches[2]), $matches[3]);
| function mycode_parse_img_callback4($matches) { return $this->mycode_parse_img($matches[5], array($matches[1], $matches[2]), $matches[3]);
|
Zeile 1267 | Zeile 1304 |
---|
* * @param array $matches Matches. * @return string Image code.
|
* * @param array $matches Matches. * @return string Image code.
|
*/ function mycode_parse_img_disabled_callback2($matches) { return $this->mycode_parse_img_disabled($matches[4]); }
/** * Parses IMG MyCode disabled. * * @param array $matches Matches. * @return string Image code.
| */ function mycode_parse_img_disabled_callback2($matches) { return $this->mycode_parse_img_disabled($matches[4]); }
/** * Parses IMG MyCode disabled. * * @param array $matches Matches. * @return string Image code.
|
*/ function mycode_parse_img_disabled_callback3($matches) {
| */ function mycode_parse_img_disabled_callback3($matches) {
|
Zeile 1293 | Zeile 1330 |
---|
function mycode_parse_img_disabled_callback4($matches) { return $this->mycode_parse_img_disabled($matches[5]);
|
function mycode_parse_img_disabled_callback4($matches) { return $this->mycode_parse_img_disabled($matches[5]);
|
}
| }
|
/** * Parses email MyCode.
| /** * Parses email MyCode.
|
Zeile 1310 | Zeile 1347 |
---|
{ $name = $email; }
|
{ $name = $email; }
|
if(preg_match("/^([a-zA-Z0-9-_\+\.]+?)@[a-zA-Z0-9-]+\.[a-zA-Z0-9\.-]+$/si", $email)) { $email = $email; } elseif(preg_match("/^([a-zA-Z0-9-_\+\.]+?)@[a-zA-Z0-9-]+\.[a-zA-Z0-9\.-]+\?(.*?)$/si", $email)) { $email = htmlspecialchars_uni($email); }
| $email = $this->encode_url($email);
|
eval("\$mycode_email = \"".$templates->get("mycode_email", 1, 0)."\";"); return $mycode_email;
| eval("\$mycode_email = \"".$templates->get("mycode_email", 1, 0)."\";"); return $mycode_email;
|
Zeile 1330 | Zeile 1361 |
---|
* @return string The built-up email link. */ function mycode_parse_email_callback($matches)
|
* @return string The built-up email link. */ function mycode_parse_email_callback($matches)
|
{
| {
|
if(!isset($matches[2])) { $matches[2] = '';
| if(!isset($matches[2])) { $matches[2] = '';
|
Zeile 1364 | Zeile 1395 |
---|
if($parsed_url === false) { return "[video={$video}]{$url}[/video]";
|
if($parsed_url === false) { return "[video={$video}]{$url}[/video]";
|
}
| }
|
$fragments = array(); if($parsed_url['fragment'])
|
$fragments = array(); if($parsed_url['fragment'])
|
{
| {
|
$fragments = explode("&", $parsed_url['fragment']);
|
$fragments = explode("&", $parsed_url['fragment']);
|
| }
if($video == "liveleak") { // The query part can start with any alphabet, but set only 'i' to catch in index key later $parsed_url['query'] = "i".substr($parsed_url['query'], 1);
|
}
$queries = explode("&", $parsed_url['query']);
| }
$queries = explode("&", $parsed_url['query']);
|
Zeile 1417 | Zeile 1454 |
---|
$id = $path[3]; // https://www.facebook.com/fds/videos/123/ } break;
|
$id = $path[3]; // https://www.facebook.com/fds/videos/123/ } break;
|
case "veoh": $id = $path[2]; // http://www.veoh.com/watch/123
| case "mixer": $id = $path[1]; // https://mixer.com/streamer
|
break; case "liveleak": $id = $input['i']; // http://www.liveleak.com/view?i=123
| break; case "liveleak": $id = $input['i']; // http://www.liveleak.com/view?i=123
|
Zeile 1448 | Zeile 1485 |
---|
{ $id = $path[3]; // http://vimeo.com/fds/fds/fds123 }
|
{ $id = $path[3]; // http://vimeo.com/fds/fds/fds123 }
|
else { $id = $path[1]; // http://vimeo.com/fds123 }
| else { $id = $path[1]; // http://vimeo.com/fds123 }
|
break; case "youtube": if($fragments[0])
|
break; case "youtube": if($fragments[0])
|
{
| {
|
$id = str_replace('!v=', '', $fragments[0]); // http://www.youtube.com/watch#!v=fds123
|
$id = str_replace('!v=', '', $fragments[0]); // http://www.youtube.com/watch#!v=fds123
|
}
| }
|
elseif($input['v'])
|
elseif($input['v'])
|
{
| {
|
$id = $input['v']; // http://www.youtube.com/watch?v=fds123 } else { $id = $path[1]; // http://www.youtu.be/fds123
|
$id = $input['v']; // http://www.youtube.com/watch?v=fds123 } else { $id = $path[1]; // http://www.youtu.be/fds123
|
}
| }
|
break; case "twitch": if(count($path) >= 3 && $path[1] == 'videos')
| break; case "twitch": if(count($path) >= 3 && $path[1] == 'videos')
|
Zeile 1493 | Zeile 1530 |
---|
return "[video={$video}]{$url}[/video]"; }
|
return "[video={$video}]{$url}[/video]"; }
|
$id = htmlspecialchars_uni($id);
| $id = $this->encode_url($id);
|
|
|
eval("\$video_code = \"".$templates->get("video_{$video}_embed")."\";");
| eval("\$video_code = \"".$templates->get("video_{$video}_embed", 1, 0)."\";");
|
return $video_code; }
| return $video_code; }
|
Zeile 1526 | Zeile 1563 |
---|
$video = $lang->sprintf($lang->posted_video, $this->mycode_parse_url($url)); return $video;
|
$video = $lang->sprintf($lang->posted_video, $this->mycode_parse_url($url)); return $video;
|
}
/**
| }
/**
|
* Parses video MyCode disabled.
|
* Parses video MyCode disabled.
|
*
| *
|
* @param array $matches Matches. * @return string The built-up video code. */ function mycode_parse_video_disabled_callback($matches) { return $this->mycode_parse_video_disabled($matches[2]);
|
* @param array $matches Matches. * @return string The built-up video code. */ function mycode_parse_video_disabled_callback($matches) { return $this->mycode_parse_video_disabled($matches[2]);
|
}
/** * Parses URLs automatically. *
| }
/** * Parses URLs automatically. *
|
* @param string $message The message to be parsed * @return string The parsed message. */
| * @param string $message The message to be parsed * @return string The parsed message. */
|
Zeile 1551 | Zeile 1588 |
---|
// Links should end with slashes, numbers, characters and braces but not with dots, commas or question marks // Don't create links within existing links (handled up-front in the callback function).
|
// Links should end with slashes, numbers, characters and braces but not with dots, commas or question marks // Don't create links within existing links (handled up-front in the callback function).
|
$message = preg_replace_callback("#<a\\s[^>]*>.*?</a>|([\s\(\)\[\>])(http|https|ftp|news|irc|ircs|irc6){1}://([^\/\"\s\<\[\.]+\.([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/([^\"\s<\[]|\[\])*)?([\w\/\)]))#ius", array($this, 'mycode_auto_url_callback'), $message); $message = preg_replace_callback("#<a\\s[^>]*>.*?</a>|([\s\(\)\[\>])(www|ftp)\.(([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/([^\"\s<\[]|\[\])*)?([\w\/\)]))#ius", array($this, 'mycode_auto_url_callback'), $message);
| $message = preg_replace_callback("#<a\\s[^>]*>.*?</a>|([\s\(\)\[\>])(http|https|ftp|news|irc|ircs|irc6){1}(://)([^\/\"\s\<\[\.]+\.([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/([^\"\s<\[]|\[\])*)?([\w\/\)]))(?![^<>]*?>)#ius", array($this, 'mycode_auto_url_callback'), $message); $message = preg_replace_callback("#<a\\s[^>]*>.*?</a>|([\s\(\)\[\>])(www|ftp)(\.)(([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/([^\"\s<\[]|\[\])*)?([\w\/\)]))(?![^<>]*?>)#ius", array($this, 'mycode_auto_url_callback'), $message);
|
$message = my_substr($message, 1);
return $message;
| $message = my_substr($message, 1);
return $message;
|
Zeile 1564 | Zeile 1601 |
---|
* @param array $matches Matches * @return string The parsed message. */
|
* @param array $matches Matches * @return string The parsed message. */
|
function mycode_auto_url_callback($matches)
| function mycode_auto_url_callback($matches=array())
|
{ // If we matched a preexisting link (the part of the regexes in mycode_auto_url() before the pipe symbol), // then simply return it - we don't create links within existing links.
| { // If we matched a preexisting link (the part of the regexes in mycode_auto_url() before the pipe symbol), // then simply return it - we don't create links within existing links.
|
Zeile 1575 | Zeile 1612 |
---|
$external = ''; // Allow links like http://en.wikipedia.org/wiki/PHP_(disambiguation) but detect mismatching braces
|
$external = ''; // Allow links like http://en.wikipedia.org/wiki/PHP_(disambiguation) but detect mismatching braces
|
while(my_substr($matches[3], -1) == ')')
| while(my_substr($matches[4], -1) == ')')
|
{
|
{
|
if(substr_count($matches[3], ')') > substr_count($matches[3], '('))
| if(substr_count($matches[4], ')') > substr_count($matches[4], '('))
|
{
|
{
|
$matches[3] = my_substr($matches[3], 0, -1);
| $matches[4] = my_substr($matches[4], 0, -1);
|
$external = ')'.$external; } else
| $external = ')'.$external; } else
|
Zeile 1588 | Zeile 1625 |
---|
}
// Example: ([...] http://en.wikipedia.org/Example_(disambiguation).)
|
}
// Example: ([...] http://en.wikipedia.org/Example_(disambiguation).)
|
$last_char = my_substr($matches[3], -1);
| $last_char = my_substr($matches[4], -1);
|
while($last_char == '.' || $last_char == ',' || $last_char == '?' || $last_char == '!') {
|
while($last_char == '.' || $last_char == ',' || $last_char == '?' || $last_char == '!') {
|
$matches[3] = my_substr($matches[3], 0, -1);
| $matches[4] = my_substr($matches[4], 0, -1);
|
$external = $last_char.$external;
|
$external = $last_char.$external;
|
$last_char = my_substr($matches[3], -1);
| $last_char = my_substr($matches[4], -1);
|
} }
|
} }
|
if(in_array(strtolower($matches[2]), array('www', 'ftp'))) { $url = "{$matches[2]}.{$matches[3]}"; } else { $url = "{$matches[2]}://{$matches[3]}"; }
| $url = "{$matches[2]}{$matches[3]}{$matches[4]}";
|
return $matches[1].$this->mycode_parse_url($url, $url).$external; }
| return $matches[1].$this->mycode_parse_url($url, $url).$external; }
|
Zeile 1745 | Zeile 1775 |
---|
if(empty($this->options)) { $this->options = $options;
|
if(empty($this->options)) { $this->options = $options;
|
| } else { foreach($options as $option_name => $option_value) { $this->options[$option_name] = $option_value; }
|
}
// Filter bad words if requested.
| }
// Filter bad words if requested.
|
Zeile 1765 | Zeile 1802 |
---|
"#\[img=([1-9][0-9]*)x([1-9][0-9]*)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", "#\[url=((?!javascript)[a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#si", "#\[url=((?!javascript:)[^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#si",
|
"#\[img=([1-9][0-9]*)x([1-9][0-9]*)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", "#\[url=((?!javascript)[a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#si", "#\[url=((?!javascript:)[^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#si",
|
| "#\[attachment=([0-9]+?)\]#i",
|
);
$replace = array(
| );
$replace = array(
|
Zeile 1773 | Zeile 1811 |
---|
"$4", "$3 ($1$2)", "$2 ($1)",
|
"$4", "$3 ($1$2)", "$2 ($1)",
|
| "",
|
); $messageBefore = "";
| ); $messageBefore = "";
|