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 923 | Zeile 962 |
---|
if($text_only == true) {
|
if($text_only == true) {
|
return "\n{$lang->code}\n--\n{$code}\n--\n";
| return empty($this->options['signature_parse']) ? "\n{$lang->code}\n--\n{$code}\n--\n" : $code;
|
}
// Clean the string before parsing.
| }
// Clean the string before parsing.
|
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 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 1173 | Zeile 1210 |
---|
{ $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 1370 | Zeile 1407 |
---|
if($parsed_url['fragment']) { $fragments = explode("&", $parsed_url['fragment']);
|
if($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 1460 |
---|
$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 1493 | Zeile 1536 |
---|
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 1551 | Zeile 1594 |
---|
// 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 1607 |
---|
* @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 1618 |
---|
$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 1631 |
---|
}
// 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 1781 |
---|
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.
|