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; }
|
Zeile 341 | Zeile 360 |
---|
$callback_mycode['size_int']['regex'] = "#\[size=([0-9\+\-]+?)\](.*?)\[/size\]#si"; $callback_mycode['size_int']['replacement'] = array($this, 'mycode_handle_size_callback');
|
$callback_mycode['size_int']['regex'] = "#\[size=([0-9\+\-]+?)\](.*?)\[/size\]#si"; $callback_mycode['size_int']['replacement'] = array($this, 'mycode_handle_size_callback');
|
++$nestable_count;
| ++$nestable_count;
|
++$callback_count;
|
++$callback_count;
|
}
| }
|
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>";
|
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_count; }
| ++$nestable_count; }
|
if($mybb->settings['allowalignmycode'] == 1) {
| if($mybb->settings['allowalignmycode'] == 1) {
|
Zeile 360 | Zeile 379 |
---|
$nestable_mycode['align']['replacement'] = "<div style=\"text-align: $1;\" class=\"mycode_align\">$2</div>";
++$nestable_count;
|
$nestable_mycode['align']['replacement'] = "<div style=\"text-align: $1;\" class=\"mycode_align\">$2</div>";
++$nestable_count;
|
}
$custom_mycode = $cache->read("mycode");
| }
$custom_mycode = $cache->read("mycode");
|
// If there is custom MyCode, load it. if(is_array($custom_mycode))
| // If there is custom MyCode, load it. if(is_array($custom_mycode))
|
Zeile 430 | Zeile 449 |
---|
// Parse quotes first $message = $this->mycode_parse_quotes($message);
|
// Parse quotes first $message = $this->mycode_parse_quotes($message);
|
$message = $this->mycode_auto_url($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);
| $message = str_replace('$', '$', $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 685 | Zeile 711 |
---|
* @return string The parsed text. */ function mycode_handle_size($size, $text)
|
* @return string The parsed text. */ function mycode_handle_size($size, $text)
|
{
| {
|
global $templates;
$size = (int)$size;
| global $templates;
$size = (int)$size;
|
Zeile 711 | Zeile 737 |
---|
* * @param array $matches Matches. * @return string The parsed text.
|
* * @param array $matches Matches. * @return string The parsed text.
|
*/
| */
|
function mycode_handle_size_callback($matches) { return $this->mycode_handle_size($matches[1], $matches[2]);
| function mycode_handle_size_callback($matches) { return $this->mycode_handle_size($matches[1], $matches[2]);
|
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 { $replace = "\n{$lang->quote}\n--\n$1\n--\n";
| else { $replace = "\n{$lang->quote}\n--\n$1\n--\n";
|
Zeile 761 | Zeile 787 |
---|
$find = array( "#(\r\n*|\n*)<\/cite>(\r\n*|\n*)#", "#(\r\n*|\n*)<\/blockquote>#"
|
$find = array( "#(\r\n*|\n*)<\/cite>(\r\n*|\n*)#", "#(\r\n*|\n*)<\/blockquote>#"
|
);
| );
|
$replace = array( "</cite><br />",
| $replace = array( "</cite><br />",
|
Zeile 771 | Zeile 797 |
---|
} return $message; }
|
} return $message; }
|
|
|
/** * Parses quotes with post id and/or dateline. *
| /** * Parses quotes with post id and/or dateline. *
|
Zeile 783 | Zeile 809 |
---|
function mycode_parse_post_quotes($message, $username, $text_only=false) { global $lang, $templates, $theme, $mybb;
|
function mycode_parse_post_quotes($message, $username, $text_only=false) { global $lang, $templates, $theme, $mybb;
|
$linkback = $date = "";
| $linkback = $date = "";
|
$message = trim($message); $message = preg_replace("#(^<br(\s?)(\/?)>|<br(\s?)(\/?)>$)#i", "", $message);
|
$message = trim($message); $message = preg_replace("#(^<br(\s?)(\/?)>|<br(\s?)(\/?)>$)#i", "", $message);
|
|
|
if(!$message) { return '';
| if(!$message) { return '';
|
Zeile 803 | Zeile 829 |
---|
$pid = (int)$match[1]; $url = $mybb->settings['bburl']."/".get_post_link($pid)."#pid$pid"; if(defined("IN_ARCHIVE"))
|
$pid = (int)$match[1]; $url = $mybb->settings['bburl']."/".get_post_link($pid)."#pid$pid"; if(defined("IN_ARCHIVE"))
|
{
| {
|
$linkback = " <a href=\"{$url}\">[ -> ]</a>"; } else { eval("\$linkback = \" ".$templates->get("postbit_gotopost", 1, 0)."\";");
|
$linkback = " <a href=\"{$url}\">[ -> ]</a>"; } else { eval("\$linkback = \" ".$templates->get("postbit_gotopost", 1, 0)."\";");
|
}
| }
|
$username = preg_replace("#(?:"|\"|')? pid=(?:"|\"|')?[0-9]+[\"']?(?:"|\"|')?#i", '', $username);
|
$username = preg_replace("#(?:"|\"|')? pid=(?:"|\"|')?[0-9]+[\"']?(?:"|\"|')?#i", '', $username);
|
$delete_quote = false;
| $delete_quote = false;
|
}
unset($match); preg_match("#dateline=(?:"|\"|')?([0-9]+)(?:"|\"|')?#i", $username, $match); if((int)$match[1])
|
}
unset($match); preg_match("#dateline=(?:"|\"|')?([0-9]+)(?:"|\"|')?#i", $username, $match); if((int)$match[1])
|
{
| {
|
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 834 | Zeile 867 |
---|
}
if(!empty($this->options['allow_html']))
|
}
if(!empty($this->options['allow_html']))
|
{
| {
|
$username = htmlspecialchars_uni($username);
|
$username = htmlspecialchars_uni($username);
|
}
| }
|
if($text_only) {
| if($text_only) {
|
Zeile 849 | Zeile 882 |
---|
{ $span = "<span>{$date}</span>"; }
|
{ $span = "<span>{$date}</span>"; }
|
|
|
eval("\$mycode_quote = \"".$templates->get("mycode_quote_post", 1, 0)."\";"); return $mycode_quote;
|
eval("\$mycode_quote = \"".$templates->get("mycode_quote_post", 1, 0)."\";"); return $mycode_quote;
|
} }
/** * Parses quotes with post id and/or dateline. * * @param array $matches Matches. * @return string The parsed message.
| } }
/** * Parses quotes with post id and/or dateline. * * @param array $matches Matches. * @return string The parsed message.
|
*/ function mycode_parse_post_quotes_callback1($matches)
|
*/ function mycode_parse_post_quotes_callback1($matches)
|
{
| {
|
return $this->mycode_parse_post_quotes($matches[4],$matches[2].$matches[3]);
|
return $this->mycode_parse_post_quotes($matches[4],$matches[2].$matches[3]);
|
}
| }
|
/** * Parses quotes with post id and/or dateline.
|
/** * Parses quotes with post id and/or dateline.
|
*
| *
|
* @param array $matches Matches. * @return string The parsed message. */
| * @param array $matches Matches. * @return string The parsed message. */
|
Zeile 881 | Zeile 914 |
---|
* Parses code MyCode. * * @param string $code The message to be parsed
|
* Parses code MyCode. * * @param string $code The message to be parsed
|
* @param boolean $text_only Are we formatting as text? * @return string The parsed message. */
| * @param boolean $text_only Are we formatting as text? * @return string The parsed message. */
|
function mycode_parse_code($code, $text_only=false) { global $lang, $templates;
| function mycode_parse_code($code, $text_only=false) { global $lang, $templates;
|
Zeile 930 | Zeile 963 |
---|
* @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?
|
* @return string The parsed message. */
| * @return string The parsed message. */
|
function mycode_parse_php($str, $bare_return = false, $text_only = false) { global $lang, $templates;
| function mycode_parse_php($str, $bare_return = false, $text_only = false) { global $lang, $templates;
|
Zeile 978 | Zeile 1011 |
---|
$code = preg_replace("#&\#([0-9]+);#si", "&#$1;", $code);
if($added_open_tag)
|
$code = preg_replace("#&\#([0-9]+);#si", "&#$1;", $code);
if($added_open_tag)
|
{
| {
|
$code = preg_replace("#<code><span style=\"color: \#([A-Z0-9]{6})\"><\?php( | )(<br />?)#", "<code><span style=\"color: #$1\">", $code); }
| $code = preg_replace("#<code><span style=\"color: \#([A-Z0-9]{6})\"><\?php( | )(<br />?)#", "<code><span style=\"color: #$1\">", $code); }
|
Zeile 1041 | Zeile 1074 |
---|
}
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 = my_substr($name , 0, 40).'...'.my_substr($name , -10); } $name = htmlspecialchars_uni($name);
|
$name = htmlspecialchars_decode($name); if(my_strlen($name) > 55) { $name = my_substr($name , 0, 40).'...'.my_substr($name , -10); } $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
| $name = preg_replace("#&\#([0-9]+);#si", "&#$1;", $name); // Fix & but allow unicode
|
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. * @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) {
|
Zeile 1169 | Zeile 1207 |
---|
* @return string Image code. */ function mycode_parse_img_callback2($matches)
|
* @return string Image code. */ function mycode_parse_img_callback2($matches)
|
{
| {
|
return $this->mycode_parse_img($matches[4], array($matches[1], $matches[2]));
|
return $this->mycode_parse_img($matches[4], array($matches[1], $matches[2]));
|
}
/** * 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_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]);
|
Zeile 1191 | Zeile 1229 |
---|
* @return string Image code. */ function mycode_parse_img_callback4($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]);
|
return $this->mycode_parse_img($matches[5], array($matches[1], $matches[2]), $matches[3]);
|
}
/**
| }
/**
|
* Parses IMG MyCode disabled. * * @param string $url The URL to the image
| * Parses IMG MyCode disabled. * * @param string $url The URL to the image
|
Zeile 1208 | Zeile 1246 |
---|
$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);
|
|
|
$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. * * @param array $matches Matches.
| }
/** * Parses IMG MyCode disabled. * * @param array $matches Matches.
|
* @return string Image code. */ function mycode_parse_img_disabled_callback1($matches)
| * @return string Image code. */ function mycode_parse_img_disabled_callback1($matches)
|
Zeile 1233 | Zeile 1271 |
---|
function mycode_parse_img_disabled_callback2($matches) { return $this->mycode_parse_img_disabled($matches[4]);
|
function mycode_parse_img_disabled_callback2($matches) { return $this->mycode_parse_img_disabled($matches[4]);
|
}
/** * Parses IMG MyCode disabled. * * @param array $matches Matches.
| }
/** * Parses IMG MyCode disabled. * * @param array $matches Matches.
|
* @return string Image code. */ function mycode_parse_img_disabled_callback3($matches)
| * @return string Image code. */ function mycode_parse_img_disabled_callback3($matches)
|
Zeile 1255 | Zeile 1293 |
---|
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. * * @param string $email The email address to link to.
| * Parses email MyCode. * * @param string $email The email address to link to.
|
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;
|
Zeile 1279 | Zeile 1317 |
---|
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);
|
}
| }
|
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 1315 | Zeile 1353 |
---|
{ 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;
|
} }
| } }
|