Zeile 146 | Zeile 146 |
---|
// This code is reserved and could break codes $message = str_replace("<mybb-code>\n", "<mybb_code>\n", $message);
|
// This code is reserved and could break codes $message = str_replace("<mybb-code>\n", "<mybb_code>\n", $message);
|
preg_match_all("#\[(code|php)\](.*?)\[/\\1\](\r\n?|\n?)#si", $message, $code_matches, PREG_SET_ORDER); $message = preg_replace("#\[(code|php)\](.*?)\[/\\1\](\r\n?|\n?)#si", "<mybb-code>\n", $message);
| preg_match_all("#\[(code|php)\](.*?)(\[/\\1\])+(\r\n?|\n?)#si", $message, $code_matches, PREG_SET_ORDER); foreach($code_matches as $point => $part) { if(isset($part[3])) { $part[1] = "[".$part[1]."]"; $code_matches[$point][2] = substr_replace($part[0], "", strrpos($part[0], $part[3]), strlen($part[3])); $code_matches[$point][2] = substr_replace($code_matches[$point][2], "", strpos($code_matches[$point][2], $part[1]), strlen($part[1])); } } $message = preg_replace("#\[(code|php)\](.*?)(\[/\\1\])+(\r\n?|\n?)#si", "<mybb-code>\n", $message);
|
}
if(empty($this->options['allow_html'])) { $message = $this->parse_html($message); $message = str_replace("<mybb-code>\n", "<mybb-code>\n", $message);
|
}
if(empty($this->options['allow_html'])) { $message = $this->parse_html($message); $message = str_replace("<mybb-code>\n", "<mybb-code>\n", $message);
|
}
| }
|
else { // Replace base, meta,script and style tags in our post - these are > dangerous < $message = preg_replace('#<(/?)(base|meta|script|style)([^>]*)>#i', '<$1$2$3>', $message); $message = $this->fix_javascript($message);
|
else { // Replace base, meta,script and style tags in our post - these are > dangerous < $message = preg_replace('#<(/?)(base|meta|script|style)([^>]*)>#i', '<$1$2$3>', $message); $message = $this->fix_javascript($message);
|
|
|
$find = array("<br />\n", "<br>\n"); $replace = array("\n", "\n"); $message = str_replace($find, $replace, $message); }
|
$find = array("<br />\n", "<br>\n"); $replace = array("\n", "\n"); $message = str_replace($find, $replace, $message); }
|
| $message = $plugins->run_hooks("parse_message_htmlsanitized", $message);
|
// Replace "me" code and slaps if we have a username if(!empty($this->options['me_username']) && $mybb->settings['allowmemycode'] == 1)
| // Replace "me" code and slaps if we have a username if(!empty($this->options['me_username']) && $mybb->settings['allowmemycode'] == 1)
|
Zeile 174 | Zeile 185 |
---|
$message = preg_replace('#(>|^|\r|\n)/me ([^\r\n<]*)#i', "\\1<span style=\"color: red;\" class=\"mycode_me\">* {$this->options['me_username']} \\2</span>", $message); $message = preg_replace('#(>|^|\r|\n)/slap ([^\r\n<]*)#i', "\\1<span style=\"color: red;\" class=\"mycode_slap\">* {$this->options['me_username']} {$lang->slaps} \\2 {$lang->with_trout}</span>", $message); }
|
$message = preg_replace('#(>|^|\r|\n)/me ([^\r\n<]*)#i', "\\1<span style=\"color: red;\" class=\"mycode_me\">* {$this->options['me_username']} \\2</span>", $message); $message = preg_replace('#(>|^|\r|\n)/slap ([^\r\n<]*)#i', "\\1<span style=\"color: red;\" class=\"mycode_slap\">* {$this->options['me_username']} {$lang->slaps} \\2 {$lang->with_trout}</span>", $message); }
|
| $message = $plugins->run_hooks("parse_message_me_mycode", $message);
|
// If we can, parse smilies if(!empty($this->options['allow_smilies']))
|
// If we can, parse smilies if(!empty($this->options['allow_smilies']))
|
{
| {
|
$message = $this->parse_smilies($message, $this->options['allow_html']);
|
$message = $this->parse_smilies($message, $this->options['allow_html']);
|
}
| }
|
// Replace MyCode if requested. if(!empty($this->options['allow_mycode']))
|
// Replace MyCode if requested. if(!empty($this->options['allow_mycode']))
|
{
| {
|
$message = $this->parse_mycode($message);
|
$message = $this->parse_mycode($message);
|
| }
// Filter url codes, if disabled. if($mybb->settings['allowlinkmycode'] != 1) { $message = preg_replace("#\[(\/)?url{1}(.*?)\]#i", "", $message);
|
}
// Parse Highlights
| }
// Parse Highlights
|
Zeile 294 | Zeile 313 |
---|
$standard_mycode['reg']['regex'] = "#\(r\)#i"; $standard_mycode['reg']['replacement'] = "®";
|
$standard_mycode['reg']['regex'] = "#\(r\)#i"; $standard_mycode['reg']['replacement'] = "®";
|
|
|
++$standard_count;
|
++$standard_count;
|
}
| }
|
if($mybb->settings['allowlinkmycode'] == 1) { $callback_mycode['url_simple']['regex'] = "#\[url\]((?!javascript)[a-z]+?://)([^\r\n\"<]+?)\[/url\]#si";
| if($mybb->settings['allowlinkmycode'] == 1) { $callback_mycode['url_simple']['regex'] = "#\[url\]((?!javascript)[a-z]+?://)([^\r\n\"<]+?)\[/url\]#si";
|
Zeile 317 | Zeile 336 |
---|
if($mybb->settings['allowemailmycode'] == 1) {
|
if($mybb->settings['allowemailmycode'] == 1) {
|
$callback_mycode['email_simple']['regex'] = "#\[email\](.*?)\[/email\]#i";
| $callback_mycode['email_simple']['regex'] = "#\[email\]((?:[a-zA-Z0-9-_\+\.]+?)@[a-zA-Z0-9-]+\.[a-zA-Z0-9\.-]+(?:\?.*?)?)\[/email\]#i";
|
$callback_mycode['email_simple']['replacement'] = array($this, 'mycode_parse_email_callback');
|
$callback_mycode['email_simple']['replacement'] = array($this, 'mycode_parse_email_callback');
|
$callback_mycode['email_complex']['regex'] = "#\[email=(.*?)\](.*?)\[/email\]#i";
| $callback_mycode['email_complex']['regex'] = "#\[email=((?:[a-zA-Z0-9-_\+\.]+?)@[a-zA-Z0-9-]+\.[a-zA-Z0-9\.-]+(?:\?.*?)?)\](.*?)\[/email\]#i";
|
$callback_mycode['email_complex']['replacement'] = array($this, 'mycode_parse_email_callback');
|
$callback_mycode['email_complex']['replacement'] = array($this, 'mycode_parse_email_callback');
|
++$callback_count;
| ++$callback_count;
|
}
if($mybb->settings['allowcolormycode'] == 1)
| }
if($mybb->settings['allowcolormycode'] == 1)
|
Zeile 338 | Zeile 357 |
---|
{ $nestable_mycode['size']['regex'] = "#\[size=(xx-small|x-small|small|medium|large|x-large|xx-large)\](.*?)\[/size\]#si"; $nestable_mycode['size']['replacement'] = "<span style=\"font-size: $1;\" class=\"mycode_size\">$2</span>";
|
{ $nestable_mycode['size']['regex'] = "#\[size=(xx-small|x-small|small|medium|large|x-large|xx-large)\](.*?)\[/size\]#si"; $nestable_mycode['size']['replacement'] = "<span style=\"font-size: $1;\" class=\"mycode_size\">$2</span>";
|
|
|
$callback_mycode['size_int']['regex'] = "#\[size=([0-9\+\-]+?)\](.*?)\[/size\]#si"; $callback_mycode['size_int']['replacement'] = array($this, 'mycode_handle_size_callback');
++$nestable_count; ++$callback_count;
|
$callback_mycode['size_int']['regex'] = "#\[size=([0-9\+\-]+?)\](.*?)\[/size\]#si"; $callback_mycode['size_int']['replacement'] = array($this, 'mycode_handle_size_callback');
++$nestable_count; ++$callback_count;
|
}
| }
|
if($mybb->settings['allowfontmycode'] == 1) {
| if($mybb->settings['allowfontmycode'] == 1) {
|
Zeile 423 | Zeile 442 |
---|
// Cache the MyCode globally if needed. if($this->mycode_cache == 0)
|
// Cache the MyCode globally if needed. if($this->mycode_cache == 0)
|
{
| {
|
$this->cache_mycode();
|
$this->cache_mycode();
|
}
| }
|
// Parse quotes first $message = $this->mycode_parse_quotes($message);
|
// Parse quotes first $message = $this->mycode_parse_quotes($message);
|
$message = $this->mycode_auto_url($message);
$message = str_replace('$', '$', $message);
| // Convert images when allowed. if(!empty($this->options['allow_imgcode'])) { $message = preg_replace_callback("#\[img\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_callback1'), $message); $message = preg_replace_callback("#\[img=([1-9][0-9]*)x([1-9][0-9]*)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_callback2'), $message); $message = preg_replace_callback("#\[img align=(left|right)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_callback3'), $message); $message = preg_replace_callback("#\[img=([1-9][0-9]*)x([1-9][0-9]*) align=(left|right)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_callback4'), $message); } else { $message = preg_replace_callback("#\[img\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_disabled_callback1'), $message); $message = preg_replace_callback("#\[img=([1-9][0-9]*)x([1-9][0-9]*)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_disabled_callback2'), $message); $message = preg_replace_callback("#\[img align=(left|right)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_disabled_callback3'), $message); $message = preg_replace_callback("#\[img=([1-9][0-9]*)x([1-9][0-9]*) align=(left|right)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_disabled_callback4'), $message); }
// Convert videos when allow. if(!empty($this->options['allow_videocode'])) { $message = preg_replace_callback("#\[video=(.*?)\](.*?)\[/video\]#i", array($this, 'mycode_parse_video_callback'), $message); } else { $message = preg_replace_callback("#\[video=(.*?)\](.*?)\[/video\]#i", array($this, 'mycode_parse_video_disabled_callback'), $message); }
$message = str_replace('$', '$', $message);
|
// Replace the rest if($this->mycode_cache['standard_count'] > 0)
|
// Replace the rest if($this->mycode_cache['standard_count'] > 0)
|
{
| {
|
$message = preg_replace($this->mycode_cache['standard']['find'], $this->mycode_cache['standard']['replacement'], $message); }
if($this->mycode_cache['callback_count'] > 0) { foreach($this->mycode_cache['callback'] as $replace)
|
$message = preg_replace($this->mycode_cache['standard']['find'], $this->mycode_cache['standard']['replacement'], $message); }
if($this->mycode_cache['callback_count'] > 0) { foreach($this->mycode_cache['callback'] as $replace)
|
{
| {
|
$message = preg_replace_callback($replace['find'], $replace['replacement'], $message); } }
| $message = preg_replace_callback($replace['find'], $replace['replacement'], $message); } }
|
Zeile 477 | Zeile 520 |
---|
} }
|
} }
|
// Convert images when allowed. if(!empty($this->options['allow_imgcode'])) { $message = preg_replace_callback("#\[img\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_callback1'), $message); $message = preg_replace_callback("#\[img=([1-9][0-9]*)x([1-9][0-9]*)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_callback2'), $message); $message = preg_replace_callback("#\[img align=(left|right)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_callback3'), $message); $message = preg_replace_callback("#\[img=([1-9][0-9]*)x([1-9][0-9]*) align=(left|right)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_callback4'), $message); } else { $message = preg_replace_callback("#\[img\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_disabled_callback1'), $message); $message = preg_replace_callback("#\[img=([1-9][0-9]*)x([1-9][0-9]*)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_disabled_callback2'), $message); $message = preg_replace_callback("#\[img align=(left|right)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_disabled_callback3'), $message); $message = preg_replace_callback("#\[img=([1-9][0-9]*)x([1-9][0-9]*) align=(left|right)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", array($this, 'mycode_parse_img_disabled_callback4'), $message); }
// Convert videos when allow. if(!empty($this->options['allow_videocode'])) { $message = preg_replace_callback("#\[video=(.*?)\](.*?)\[/video\]#i", array($this, 'mycode_parse_video_callback'), $message); } else { $message = preg_replace_callback("#\[video=(.*?)\](.*?)\[/video\]#i", array($this, 'mycode_parse_video_disabled_callback'), $message); }
| $message = $this->mycode_auto_url($message);
|
return $message; }
| return $message; }
|
Zeile 631 | Zeile 650 |
---|
$badword['replacement'] = "*****"; }
|
$badword['replacement'] = "*****"; }
|
// Take into account the position offset for our last replacement. $badword['badword'] = str_replace('\*', '([a-zA-Z0-9_]{1})', preg_quote($badword['badword'], "#"));
| if($badword['regex']) { $message = preg_replace('#'.$badword['badword'].'#is', $badword['replacement'], $message); } 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);
| // 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); }
|
} } if(!empty($this->options['strip_tags']))
| } } if(!empty($this->options['strip_tags']))
|
Zeile 647 | Zeile 673 |
---|
/** * Resolves nested CDATA tags in the specified message.
|
/** * Resolves nested CDATA tags in the specified message.
|
*
| *
|
* @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 673 | Zeile 699 |
---|
// Add invisible white space $message = preg_replace($js_array, "$1\xE2\x80\x8C$2$6", $message);
|
// Add invisible white space $message = preg_replace($js_array, "$1\xE2\x80\x8C$2$6", $message);
|
|
|
return $message; }
| return $message; }
|
Zeile 699 | Zeile 725 |
---|
{ $size = 50; }
|
{ $size = 50; }
|
|
|
$text = str_replace("\'", "'", $text);
eval("\$mycode_size = \"".$templates->get("mycode_size_int", 1, 0)."\";");
| $text = str_replace("\'", "'", $text);
eval("\$mycode_size = \"".$templates->get("mycode_size_int", 1, 0)."\";");
|
Zeile 736 | Zeile 762 |
---|
{ $replace = "<blockquote class=\"mycode_quote\"><cite>$lang->quote</cite>$1</blockquote>\n"; $replace_callback = array($this, 'mycode_parse_post_quotes_callback1');
|
{ $replace = "<blockquote class=\"mycode_quote\"><cite>$lang->quote</cite>$1</blockquote>\n"; $replace_callback = array($this, 'mycode_parse_post_quotes_callback1');
|
} else
| } else
|
{ $replace = "\n{$lang->quote}\n--\n$1\n--\n"; $replace_callback = array($this, 'mycode_parse_post_quotes_callback2');
| { $replace = "\n{$lang->quote}\n--\n$1\n--\n"; $replace_callback = array($this, 'mycode_parse_post_quotes_callback2');
|
Zeile 810 | Zeile 836 |
---|
{ eval("\$linkback = \" ".$templates->get("postbit_gotopost", 1, 0)."\";"); }
|
{ eval("\$linkback = \" ".$templates->get("postbit_gotopost", 1, 0)."\";"); }
|
|
|
$username = preg_replace("#(?:"|\"|')? pid=(?:"|\"|')?[0-9]+[\"']?(?:"|\"|')?#i", '', $username); $delete_quote = false; }
| $username = preg_replace("#(?:"|\"|')? pid=(?:"|\"|')?[0-9]+[\"']?(?:"|\"|')?#i", '', $username); $delete_quote = false; }
|
Zeile 821 | Zeile 847 |
---|
{ if($match[1] < TIME_NOW) {
|
{ if($match[1] < TIME_NOW) {
|
$postdate = my_date('relative', (int)$match[1]);
| if($text_only) { $postdate = my_date('normal', (int)$match[1]); } else { $postdate = my_date('relative', (int)$match[1]); }
|
$date = " ({$postdate})"; } $username = preg_replace("#(?:"|\"|')? dateline=(?:"|\"|')?[0-9]+(?:"|\"|')?#i", '', $username);
| $date = " ({$postdate})"; } $username = preg_replace("#(?:"|\"|')? dateline=(?:"|\"|')?[0-9]+(?:"|\"|')?#i", '', $username);
|
Zeile 1050 | Zeile 1083 |
---|
$name = htmlspecialchars_uni($name); }
|
$name = htmlspecialchars_uni($name); }
|
$nofollow = '';
| |
if(!empty($this->options['nofollow_on'])) {
|
if(!empty($this->options['nofollow_on'])) {
|
$nofollow = " rel=\"nofollow\"";
| $rel = " rel=\"noopener nofollow\""; } else { $rel = " rel=\"noopener\"";
|
}
// Fix some entities in URLs
|
}
// Fix some entities in URLs
|
$entities = array('$' => '%24', '$' => '%24', '^' => '%5E', '`' => '%60', '[' => '%5B', ']' => '%5D', '{' => '%7B', '}' => '%7D', '"' => '%22', '<' => '%3C', '>' => '%3E', ' ' => '%20'); $url = str_replace(array_keys($entities), array_values($entities), $url);
| $url = $this->encode_url($url);
|
$name = preg_replace("#&\#([0-9]+);#si", "&#$1;", $name); // Fix & but allow unicode
eval("\$mycode_url = \"".$templates->get("mycode_url", 1, 0)."\";"); return $mycode_url;
|
$name = preg_replace("#&\#([0-9]+);#si", "&#$1;", $name); // Fix & but allow unicode
eval("\$mycode_url = \"".$templates->get("mycode_url", 1, 0)."\";"); return $mycode_url;
|
}
| }
|
/** * Parses URL MyCode.
| /** * Parses URL MyCode.
|
Zeile 1073 | Zeile 1109 |
---|
* @return string The built-up link. */ function mycode_parse_url_callback1($matches)
|
* @return string The built-up link. */ function mycode_parse_url_callback1($matches)
|
{
| {
|
if(!isset($matches[3])) { $matches[3] = '';
| if(!isset($matches[3])) { $matches[3] = '';
|
Zeile 1092 | Zeile 1128 |
---|
if(!isset($matches[2])) { $matches[2] = '';
|
if(!isset($matches[2])) { $matches[2] = '';
|
}
| }
|
return $this->mycode_parse_url($matches[1], $matches[2]); }
| return $this->mycode_parse_url($matches[1], $matches[2]); }
|
Zeile 1120 | Zeile 1156 |
---|
if($align == "right") { $css_align = ' style="float: right;"';
|
if($align == "right") { $css_align = ' style="float: right;"';
|
}
| }
|
else if($align == "left")
|
else if($align == "left")
|
{
| {
|
$css_align = ' style="float: left;"'; }
if($align) { $this->clear_needed = true;
|
$css_align = ' style="float: left;"'; }
if($align) { $this->clear_needed = true;
|
}
| }
|
$alt = basename($url); $alt = htmlspecialchars_decode($alt); if(my_strlen($alt) > 55)
|
$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 = $lang->sprintf($lang->posted_image, $alt);
| $alt = htmlspecialchars_uni($alt);
$alt = $lang->sprintf($lang->posted_image, $alt);
|
Zeile 1146 | Zeile 1182 |
---|
$width = " width=\"{$dimensions[0]}\""; $height = " height=\"{$dimensions[1]}\""; }
|
$width = " width=\"{$dimensions[0]}\""; $height = " height=\"{$dimensions[1]}\""; }
|
| $url = $this->encode_url($url);
|
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.
| }
/** * Parses IMG MyCode. * * @param array $matches Matches.
|
* @return string Image code. */ function mycode_parse_img_callback1($matches)
| * @return string Image code. */ function mycode_parse_img_callback1($matches)
|
Zeile 1168 | Zeile 1206 |
---|
* @param array $matches Matches. * @return string Image code. */
|
* @param array $matches Matches. * @return string Image code. */
|
function mycode_parse_img_callback2($matches) { return $this->mycode_parse_img($matches[4], array($matches[1], $matches[2])); }
/** * Parses IMG MyCode. * * @param array $matches Matches. * @return string Image code. */
| function mycode_parse_img_callback2($matches) { return $this->mycode_parse_img($matches[4], array($matches[1], $matches[2])); }
/** * 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]);
|
function mycode_parse_img_callback3($matches) { return $this->mycode_parse_img($matches[3], array(), $matches[1]);
|
}
/**
| }
/**
|
* Parses IMG MyCode. * * @param array $matches Matches.
| * Parses IMG MyCode. * * @param array $matches Matches.
|
Zeile 1202 | Zeile 1240 |
---|
* @return string */ function mycode_parse_img_disabled($url)
|
* @return string */ function mycode_parse_img_disabled($url)
|
{
| {
|
global $lang; $url = trim($url); $url = str_replace("\n", "", $url);
| global $lang; $url = trim($url); $url = str_replace("\n", "", $url);
|
Zeile 1211 | Zeile 1249 |
---|
$image = $lang->sprintf($lang->posted_image, $this->mycode_parse_url($url)); return $image;
|
$image = $lang->sprintf($lang->posted_image, $this->mycode_parse_url($url)); return $image;
|
}
/** * Parses IMG MyCode disabled.
| }
/** * Parses IMG MyCode disabled.
|
* * @param array $matches Matches. * @return string Image code.
| * * @param array $matches Matches. * @return string Image code.
|
Zeile 1222 | Zeile 1260 |
---|
function mycode_parse_img_disabled_callback1($matches) { return $this->mycode_parse_img_disabled($matches[2]);
|
function mycode_parse_img_disabled_callback1($matches) { return $this->mycode_parse_img_disabled($matches[2]);
|
}
/** * Parses IMG MyCode disabled. *
| }
/** * Parses IMG MyCode disabled. *
|
* @param array $matches Matches. * @return string Image code. */
| * @param array $matches Matches. * @return string Image code. */
|
Zeile 1271 | Zeile 1309 |
---|
if(!$name) { $name = $email;
|
if(!$name) { $name = $email;
|
} if(preg_match("/^([a-zA-Z0-9-_\+\.]+?)@[a-zA-Z0-9-]+\.[a-zA-Z0-9\.-]+$/si", $email)) { $email = $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);
| elseif(preg_match("/^([a-zA-Z0-9-_\+\.]+?)@[a-zA-Z0-9-]+\.[a-zA-Z0-9\.-]+\?(.*?)$/si", $email)) { $email = htmlspecialchars_uni($email);
|
Zeile 1299 | Zeile 1337 |
---|
} return $this->mycode_parse_email($matches[1], $matches[2]); }
|
} return $this->mycode_parse_email($matches[1], $matches[2]); }
|
|
|
/** * Parses video MyCode. *
| /** * Parses video MyCode. *
|
Zeile 1312 | Zeile 1350 |
---|
global $templates;
if(empty($video) || empty($url))
|
global $templates;
if(empty($video) || empty($url))
|
{ return "[video={$video}]{$url}[/video]"; }
| { return "[video={$video}]{$url}[/video]"; }
// Check URL is a valid URL first, as `parse_url` doesn't check validity. if(false === filter_var($url, FILTER_VALIDATE_URL)) { return "[video={$video}]{$url}[/video]"; }
|
$parsed_url = @parse_url(urldecode($url));
|
$parsed_url = @parse_url(urldecode($url));
|
if($parsed_url == false)
| if($parsed_url === false)
|
{ return "[video={$video}]{$url}[/video]"; }
$fragments = array(); if($parsed_url['fragment'])
|
{ return "[video={$video}]{$url}[/video]"; }
$fragments = array(); if($parsed_url['fragment'])
|
{
| {
|
$fragments = explode("&", $parsed_url['fragment']);
|
$fragments = explode("&", $parsed_url['fragment']);
|
}
$queries = explode("&", $parsed_url['query']);
| }
$queries = explode("&", $parsed_url['query']);
|
$input = array(); foreach($queries as $query) {
| $input = array(); foreach($queries as $query) {
|
Zeile 1343 | Zeile 1387 |
---|
switch($video) { case "dailymotion":
|
switch($video) { case "dailymotion":
|
list($id) = explode('_', $path[2], 2); // http://www.dailymotion.com/video/fds123_title-goes-here
| if(isset($path[2])) { list($id) = explode('_', $path[2], 2); // http://www.dailymotion.com/video/fds123_title-goes-here } else { $id = $path[1]; // http://dai.ly/fds123 }
|
break; case "metacafe": $id = $path[2]; // http://www.metacafe.com/watch/fds123/title_goes_here/
| break; case "metacafe": $id = $path[2]; // http://www.metacafe.com/watch/fds123/title_goes_here/
|
Zeile 1374 | Zeile 1425 |
---|
break; case "yahoo": if(isset($path[2]))
|
break; case "yahoo": if(isset($path[2]))
|
{
| {
|
$id = $path[2]; // http://xy.screen.yahoo.com/fds/fds-123.html } else
| $id = $path[2]; // http://xy.screen.yahoo.com/fds/fds-123.html } else
|
Zeile 1417 | Zeile 1468 |
---|
} break; case "twitch":
|
} break; case "twitch":
|
if(isset($path[3]))
| if(count($path) >= 3 && $path[1] == 'videos')
|
{
|
{
|
$id = $path[3]; // https://www.twitch.tv/giantbomb/v/100048090
| // Direct video embed with URL like: https://www.twitch.tv/videos/179723472 $id = 'video=v'.$path[2]; } elseif(count($path) >= 4 && $path[2] == 'v') { // Direct video embed with URL like: https://www.twitch.tv/waypoint/v/179723472 $id = 'video=v'.$path[3]; } elseif(count($path) >= 2) { // Channel (livestream) embed with URL like: https://twitch.tv/waypoint $id = 'channel='.$path[1];
|
} break; default: return "[video={$video}]{$url}[/video]";
|
} break; default: return "[video={$video}]{$url}[/video]";
|
}
| }
|
if(empty($id)) {
| if(empty($id)) {
|
Zeile 1432 | Zeile 1494 |
---|
}
$id = htmlspecialchars_uni($id);
|
}
$id = htmlspecialchars_uni($id);
|
|
|
eval("\$video_code = \"".$templates->get("video_{$video}_embed")."\";"); return $video_code;
|
eval("\$video_code = \"".$templates->get("video_{$video}_embed")."\";"); return $video_code;
|
}
/**
| }
/**
|
* Parses video MyCode. * * @param array $matches Matches.
| * Parses video MyCode. * * @param array $matches Matches.
|
Zeile 1446 | Zeile 1508 |
---|
function mycode_parse_video_callback($matches) { return $this->mycode_parse_video($matches[1], $matches[2]);
|
function mycode_parse_video_callback($matches) { return $this->mycode_parse_video($matches[1], $matches[2]);
|
}
/**
| }
/**
|
* Parses video MyCode disabled. * * @param string $url The URL to the video
| * Parses video MyCode disabled. * * @param string $url The URL to the video
|
Zeile 1461 | Zeile 1523 |
---|
$url = str_replace("\n", "", $url); $url = str_replace("\r", "", $url); $url = str_replace("\'", "'", $url);
|
$url = str_replace("\n", "", $url); $url = str_replace("\r", "", $url); $url = str_replace("\'", "'", $url);
|
|
|
$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; }
|
Zeile 1473 | Zeile 1535 |
---|
* @return string The built-up video code. */ function mycode_parse_video_disabled_callback($matches)
|
* @return string The built-up video code. */ function mycode_parse_video_disabled_callback($matches)
|
{
| {
|
return $this->mycode_parse_video_disabled($matches[2]); }
|
return $this->mycode_parse_video_disabled($matches[2]); }
|
|
|
/** * Parses URLs automatically. *
| /** * Parses URLs automatically. *
|
Zeile 1486 | Zeile 1548 |
---|
function mycode_auto_url($message) { $message = " ".$message;
|
function mycode_auto_url($message) { $message = " ".$message;
|
|
|
// Links should end with slashes, numbers, characters and braces but not with dots, commas or question marks
|
// Links should end with slashes, numbers, characters and braces but not with dots, commas or question marks
|
$message = preg_replace_callback("#([\>\s\(\)])(http|https|ftp|news|irc|ircs|irc6){1}://([^\/\"\s\<\[\.]+\.([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/([^\"\s<\[]|\[\])*)?([\w\/\)]))#iu", array($this, 'mycode_auto_url_callback'), $message); $message = preg_replace_callback("#([\>\s\(\)])(www|ftp)\.(([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/([^\"\s<\[]|\[\])*)?([\w\/\)]))#iu", array($this, 'mycode_auto_url_callback'), $message);
| // 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 = my_substr($message, 1);
return $message;
| $message = my_substr($message, 1);
return $message;
|
Zeile 1502 | Zeile 1566 |
---|
*/ function mycode_auto_url_callback($matches) {
|
*/ function mycode_auto_url_callback($matches) {
|
| // 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(count($matches) == 1) { return $matches[0]; }
|
$external = ''; // Allow links like http://en.wikipedia.org/wiki/PHP_(disambiguation) but detect mismatching braces while(my_substr($matches[3], -1) == ')') { if(substr_count($matches[3], ')') > substr_count($matches[3], '('))
|
$external = ''; // Allow links like http://en.wikipedia.org/wiki/PHP_(disambiguation) but detect mismatching braces while(my_substr($matches[3], -1) == ')') { if(substr_count($matches[3], ')') > substr_count($matches[3], '('))
|
{
| {
|
$matches[3] = my_substr($matches[3], 0, -1); $external = ')'.$external;
|
$matches[3] = my_substr($matches[3], 0, -1); $external = ')'.$external;
|
}
| }
|
else
|
else
|
{
| {
|
break; }
| break; }
|
Zeile 1523 | Zeile 1594 |
---|
$matches[3] = my_substr($matches[3], 0, -1); $external = $last_char.$external; $last_char = my_substr($matches[3], -1);
|
$matches[3] = my_substr($matches[3], 0, -1); $external = $last_char.$external; $last_char = my_substr($matches[3], -1);
|
} } if($matches[2] == 'www' || $matches[2] == 'ftp') { return "{$matches[1]}[url]{$matches[2]}.{$matches[3]}[/url]{$external}"; } else
| } } if(in_array(strtolower($matches[2]), array('www', 'ftp')))
|
{
|
{
|
return "{$matches[1]}[url]{$matches[2]}://{$matches[3]}[/url]{$external}";
| $url = "{$matches[2]}.{$matches[3]}";
|
}
|
}
|
| else { $url = "{$matches[2]}://{$matches[3]}"; }
return $matches[1].$this->mycode_parse_url($url, $url).$external;
|
}
/**
| }
/**
|
Zeile 1550 | Zeile 1623 |
---|
$message = "[*]{$message}"; }
|
$message = "[*]{$message}"; }
|
$message = preg_replace("#[^\S\n\r]*\[\*\]\s*#", "</li>\n<li>", $message); $message .= "</li>";
| $message = preg_split("#[^\S\n\r]*\[\*\]\s*#", $message); if(isset($message[0]) && trim($message[0]) == '') { array_shift($message); } $message = '<li>'.implode("</li>\n<li>", $message)."</li>\n";
|
if($type) {
| if($type) {
|
Zeile 1649 | Zeile 1726 |
---|
if(is_array($this->highlight_cache) && !empty($this->highlight_cache)) { $message = preg_replace(array_keys($this->highlight_cache), $this->highlight_cache, $message);
|
if(is_array($this->highlight_cache) && !empty($this->highlight_cache)) { $message = preg_replace(array_keys($this->highlight_cache), $this->highlight_cache, $message);
|
}
| }
|
return $message; }
|
return $message; }
|
|
|
/** * Parses message to plain text equivalents of MyCode. *
| /** * Parses message to plain text equivalents of MyCode. *
|
Zeile 1674 | Zeile 1751 |
---|
if(!empty($this->options['filter_badwords'])) { $message = $this->parse_badwords($message);
|
if(!empty($this->options['filter_badwords'])) { $message = $this->parse_badwords($message);
|
}
| }
|
// Parse quotes first $message = $this->mycode_parse_quotes($message, true);
| // Parse quotes first $message = $this->mycode_parse_quotes($message, true);
|
Zeile 1684 | Zeile 1761 |
---|
$find = array( "#\[(b|u|i|s|url|email|color|img)\](.*?)\[/\\1\]#is",
|
$find = array( "#\[(b|u|i|s|url|email|color|img)\](.*?)\[/\\1\]#is",
|
| "#\[(email|color|size|font|align|video)=[^]]*\](.*?)\[/\\1\]#is",
|
"#\[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", );
$replace = array(
|
"#\[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", );
$replace = array(
|
| "$2",
|
"$2", "$4", "$3 ($1$2)", "$2 ($1)", );
|
"$2", "$4", "$3 ($1$2)", "$2 ($1)", );
|
$message = preg_replace($find, $replace, $message);
| $messageBefore = ""; // The counter limit for this "for" loop is for defensive programming purpose only. It protects against infinite repetition. for($cnt = 1; $cnt < 20 && $message != $messageBefore; $cnt++) { $messageBefore = $message; $message = preg_replace($find, $replace, $messageBefore); }
|
// Replace "me" code and slaps if we have a username if(!empty($this->options['me_username']))
|
// Replace "me" code and slaps if we have a username if(!empty($this->options['me_username']))
|
{
| {
|
global $lang;
$message = preg_replace('#(>|^|\r|\n)/me ([^\r\n<]*)#i', "\\1* {$this->options['me_username']} \\2", $message); $message = preg_replace('#(>|^|\r|\n)/slap ([^\r\n<]*)#i', "\\1* {$this->options['me_username']} {$lang->slaps} \\2 {$lang->with_trout}", $message);
|
global $lang;
$message = preg_replace('#(>|^|\r|\n)/me ([^\r\n<]*)#i', "\\1* {$this->options['me_username']} \\2", $message); $message = preg_replace('#(>|^|\r|\n)/slap ([^\r\n<]*)#i', "\\1* {$this->options['me_username']} {$lang->slaps} \\2 {$lang->with_trout}", $message);
|
}
| }
|
// Reset list cache $this->list_elements = array(); $this->list_count = 0;
| // Reset list cache $this->list_elements = array(); $this->list_count = 0;
|
Zeile 1724 | Zeile 1810 |
---|
$message = $plugins->run_hooks("text_parse_message", $message);
return $message;
|
$message = $plugins->run_hooks("text_parse_message", $message);
return $message;
|
| }
/** * Replaces certain characters with their entities in a URL. * * @param string $url The URL to be escaped. * @return string The escaped URL. */ function encode_url($url) { $entities = array('$' => '%24', '$' => '%24', '^' => '%5E', '`' => '%60', '[' => '%5B', ']' => '%5D', '{' => '%7B', '}' => '%7D', '"' => '%22', '<' => '%3C', '>' => '%3E', ' ' => '%20');
$url = str_replace(array_keys($entities), array_values($entities), $url);
return $url;
|
} }
| } }
|