Zeile 165 | Zeile 165 |
---|
$replace = array("\n", "\n"); $message = str_replace($find, $replace, $message); }
|
$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)
|
{
| {
|
global $lang;
|
global $lang;
|
|
|
$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']))
|
Zeile 185 | Zeile 189 |
---|
if(!empty($this->options['allow_mycode'])) { $message = $this->parse_mycode($message);
|
if(!empty($this->options['allow_mycode'])) { $message = $this->parse_mycode($message);
|
}
| }
|
// Parse Highlights if(!empty($this->options['highlight']))
| // Parse Highlights if(!empty($this->options['highlight']))
|
Zeile 244 | Zeile 248 |
---|
* @return string The formatted message. */ function parse_html($message)
|
* @return string The formatted message. */ function parse_html($message)
|
{
| {
|
$message = preg_replace("#&(?!\#[0-9]+;)#si", "&", $message); // fix & but allow unicode $message = str_replace("<","<",$message); $message = str_replace(">",">",$message);
| $message = preg_replace("#&(?!\#[0-9]+;)#si", "&", $message); // fix & but allow unicode $message = str_replace("<","<",$message); $message = str_replace(">",">",$message);
|
Zeile 280 | Zeile 284 |
---|
$standard_mycode['hr']['regex'] = "#\[hr\]#si"; $standard_mycode['hr']['replacement'] = "<hr class=\"mycode_hr\" />";
|
$standard_mycode['hr']['regex'] = "#\[hr\]#si"; $standard_mycode['hr']['replacement'] = "<hr class=\"mycode_hr\" />";
|
++$standard_count; }
| ++$standard_count; }
|
if($mybb->settings['allowsymbolmycode'] == 1) { $standard_mycode['copy']['regex'] = "#\(c\)#i";
| if($mybb->settings['allowsymbolmycode'] == 1) { $standard_mycode['copy']['regex'] = "#\(c\)#i";
|
Zeile 322 | Zeile 326 |
---|
$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']['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_count;
|
++$callback_count;
|
}
| }
|
if($mybb->settings['allowcolormycode'] == 1) { $nestable_mycode['color']['regex'] = "#\[color=([a-zA-Z]*|\#?[\da-fA-F]{3}|\#?[\da-fA-F]{6})](.*?)\[/color\]#si"; $nestable_mycode['color']['replacement'] = "<span style=\"color: $1;\" class=\"mycode_color\">$2</span>";
|
if($mybb->settings['allowcolormycode'] == 1) { $nestable_mycode['color']['regex'] = "#\[color=([a-zA-Z]*|\#?[\da-fA-F]{3}|\#?[\da-fA-F]{6})](.*?)\[/color\]#si"; $nestable_mycode['color']['replacement'] = "<span style=\"color: $1;\" class=\"mycode_color\">$2</span>";
|
++$nestable_count; }
| ++$nestable_count; }
|
if($mybb->settings['allowsizemycode'] == 1) { $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>";
|
if($mybb->settings['allowsizemycode'] == 1) { $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');
|
$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; }
| ++$nestable_count; ++$callback_count; }
|
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 ,\-_'\"]+)\](.*?)\[/font\]#si"; $nestable_mycode['font']['replacement'] = "<span style=\"font-family: $1;\" class=\"mycode_font\">$2</span>";
|
|
|
++$nestable_count; }
| ++$nestable_count; }
|
Zeile 360 | Zeile 364 |
---|
$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");
// If there is custom MyCode, load it.
| $custom_mycode = $cache->read("mycode");
// If there is custom MyCode, load it.
|
Zeile 419 | Zeile 423 |
---|
if(empty($this->options)) { $this->options = $options;
|
if(empty($this->options)) { $this->options = $options;
|
}
| }
|
// 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);
|
| // 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); }
|
$message = $this->mycode_auto_url($message);
| $message = $this->mycode_auto_url($message);
|
Zeile 438 | Zeile 458 |
---|
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['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)
| if($this->mycode_cache['callback_count'] > 0) { foreach($this->mycode_cache['callback'] as $replace)
|
Zeile 459 | Zeile 479 |
---|
} } }
|
} } }
|
|
|
// Reset list cache if($mybb->settings['allowlistmycode'] == 1) {
| // Reset list cache if($mybb->settings['allowlistmycode'] == 1) {
|
Zeile 468 | Zeile 488 |
---|
// Find all lists $message = preg_replace_callback("#(\[list(=(a|A|i|I|1))?\]|\[/list\])#si", array($this, 'mycode_prepare_list'), $message);
|
// Find all lists $message = preg_replace_callback("#(\[list(=(a|A|i|I|1))?\]|\[/list\])#si", array($this, 'mycode_prepare_list'), $message);
|
|
|
// Replace all lists for($i = $this->list_count; $i > 0; $i--) { // Ignores missing end tags $message = preg_replace_callback("#\s?\[list(=(a|A|i|I|1))?&{$i}\](.*?)(\[/list&{$i}\]|$)(\r\n?|\n?)#si", array($this, 'mycode_parse_list_callback'), $message, 1);
|
// Replace all lists for($i = $this->list_count; $i > 0; $i--) { // Ignores missing end tags $message = preg_replace_callback("#\s?\[list(=(a|A|i|I|1))?&{$i}\](.*?)(\[/list&{$i}\]|$)(\r\n?|\n?)#si", array($this, 'mycode_parse_list_callback'), $message, 1);
|
} }
// 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.
| }
// Convert videos when allow.
|
Zeile 790 | Zeile 794 |
---|
$message = preg_replace("#(^<br(\s?)(\/?)>|<br(\s?)(\/?)>$)#i", "", $message);
if(!$message)
|
$message = preg_replace("#(^<br(\s?)(\/?)>|<br(\s?)(\/?)>$)#i", "", $message);
if(!$message)
|
{
| {
|
return ''; }
| return ''; }
|
Zeile 798 | Zeile 802 |
---|
$delete_quote = true;
preg_match("#pid=(?:"|\"|')?([0-9]+)[\"']?(?:"|\"|')?#i", $username, $match);
|
$delete_quote = true;
preg_match("#pid=(?:"|\"|')?([0-9]+)[\"']?(?:"|\"|')?#i", $username, $match);
|
if((int)$match[1])
| if((int)$match[1])
|
{ $pid = (int)$match[1]; $url = $mybb->settings['bburl']."/".get_post_link($pid)."#pid$pid"; if(defined("IN_ARCHIVE")) { $linkback = " <a href=\"{$url}\">[ -> ]</a>";
|
{ $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)."\";");
| else { eval("\$linkback = \" ".$templates->get("postbit_gotopost", 1, 0)."\";");
|
Zeile 821 | Zeile 825 |
---|
{ 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 1061 |
---|
$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 $entities = array('$' => '%24', '$' => '%24', '^' => '%5E', '`' => '%60', '[' => '%5B', ']' => '%5D', '{' => '%7B', '}' => '%7D', '"' => '%22', '<' => '%3C', '>' => '%3E', ' ' => '%20'); $url = str_replace(array_keys($entities), array_values($entities), $url);
$name = preg_replace("#&\#([0-9]+);#si", "&#$1;", $name); // Fix & but allow unicode
|
// 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);
$name = preg_replace("#&\#([0-9]+);#si", "&#$1;", $name); // Fix & but allow unicode
|
|
|
eval("\$mycode_url = \"".$templates->get("mycode_url", 1, 0)."\";"); return $mycode_url;
|
eval("\$mycode_url = \"".$templates->get("mycode_url", 1, 0)."\";"); return $mycode_url;
|
}
/** * Parses URL MyCode.
| }
/** * Parses URL MyCode.
|
* * @param array $matches Matches. * @return string The built-up link.
| * * @param array $matches Matches. * @return string The built-up link.
|
Zeile 1079 | Zeile 1093 |
---|
$matches[3] = ''; } return $this->mycode_parse_url($matches[1].$matches[2], $matches[3]);
|
$matches[3] = ''; } return $this->mycode_parse_url($matches[1].$matches[2], $matches[3]);
|
}
| }
|
/** * Parses URL MyCode. *
| /** * Parses URL MyCode. *
|
Zeile 1105 | Zeile 1119 |
---|
* @return string */ function mycode_parse_img($url, $dimensions=array(), $align='')
|
* @return string */ function mycode_parse_img($url, $dimensions=array(), $align='')
|
{
| {
|
global $lang, $templates; $url = trim($url); $url = str_replace("\n", "", $url);
| global $lang, $templates; $url = trim($url); $url = str_replace("\n", "", $url);
|
Zeile 1417 | Zeile 1431 |
---|
} break; case "twitch":
|
} break; case "twitch":
|
if(isset($path[3]))
| if(count($path) >= 3 && $path[1] == 'videos') { // 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)
|
{
|
{
|
$id = $path[3]; // https://www.twitch.tv/giantbomb/v/100048090
| // Channel (livestream) embed with URL like: https://twitch.tv/waypoint $id = 'channel='.$path[1];
|
} break; default:
| } break; default:
|
Zeile 1487 | Zeile 1512 |
---|
{ $message = " ".$message; // Links should end with slashes, numbers, characters and braces but not with dots, commas or question marks
|
{ $message = " ".$message; // 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);
| $message = preg_replace_callback("#([\>\s\(\)\[]|(?:\[(?!url)(?:.*?)\]))(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\(\)\[]|(?:\[(?!url)(?:.*?)\]))(www|ftp)\.(([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/([^\"\s<\[]|\[\])*)?([\w\/\)]))#iu", array($this, 'mycode_auto_url_callback'), $message);
|
$message = my_substr($message, 1);
return $message;
| $message = my_substr($message, 1);
return $message;
|
Zeile 1525 | Zeile 1550 |
---|
$last_char = my_substr($matches[3], -1); } }
|
$last_char = my_substr($matches[3], -1); } }
|
if($matches[2] == 'www' || $matches[2] == 'ftp')
| if(in_array(strtolower($matches[2]), array('www', 'ftp')))
|
{ return "{$matches[1]}[url]{$matches[2]}.{$matches[3]}[/url]{$external}"; }
| { return "{$matches[1]}[url]{$matches[2]}.{$matches[3]}[/url]{$external}"; }
|