Zeile 6 | Zeile 6 |
---|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* $Id: class_parser.php 5141 2010-07-29 23:32:11Z RyanGordon $
| * $Id: class_parser.php 5520 2011-07-28 08:56:12Z Tomm $
|
*/
/*
| */
/*
|
Zeile 118 | Zeile 118 |
---|
{ $message = preg_replace("#<script(.*)>(.*)</script(.*)>#is", "<script$1>$2</script$3>", $message); }
|
{ $message = preg_replace("#<script(.*)>(.*)</script(.*)>#is", "<script$1>$2</script$3>", $message); }
|
// Remove these completely $message = preg_replace("#\s*<base[^>]*>\s*#is", "", $message); $message = preg_replace("#\s*<meta[^>]*>\s*#is", "", $message);
|
|
$message = str_replace(array('<?php', '<!--', '-->', '?>', "<br />\n", "<br>\n"), array('<?php', '<!--', '-->', '?>', "\n", "\n"), $message); } // If MyCode needs to be replaced, first filter out [code] and [php] tags. if($this->options['allow_mycode']) {
|
$message = str_replace(array('<?php', '<!--', '-->', '?>', "<br />\n", "<br>\n"), array('<?php', '<!--', '-->', '?>', "\n", "\n"), $message); } // If MyCode needs to be replaced, first filter out [code] and [php] tags. if($this->options['allow_mycode']) {
|
// First we split up the contents of code and php tags to ensure they're not parsed.
| |
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); $message = preg_replace("#\[(code|php)\](.*?)\[/\\1\](\r\n?|\n?)#si", "<mybb-code>\n", $message); }
|
Zeile 137 | Zeile 134 |
---|
// Replace "me" code and slaps if we have a username if($this->options['me_username'])
|
// Replace "me" code and slaps if we have a username if($this->options['me_username'])
|
{
| {
|
global $lang; $message = preg_replace('#(>|^|\r|\n)/me ([^\r\n<]*)#i', "\\1<span style=\"color: red;\">* {$this->options['me_username']} \\2</span>", $message);
| global $lang; $message = preg_replace('#(>|^|\r|\n)/me ([^\r\n<]*)#i', "\\1<span style=\"color: red;\">* {$this->options['me_username']} \\2</span>", $message);
|
Zeile 160 | Zeile 157 |
---|
if($this->options['highlight']) { $message = $this->highlight_message($message, $this->options['highlight']);
|
if($this->options['highlight']) { $message = $this->highlight_message($message, $this->options['highlight']);
|
}
| }
|
// Run plugin hooks $message = $plugins->run_hooks("parse_message", $message);
| // Run plugin hooks $message = $plugins->run_hooks("parse_message", $message);
|
Zeile 172 | Zeile 169 |
---|
{ foreach($code_matches as $text) {
|
{ foreach($code_matches as $text) {
|
// Fix up HTML inside the code tags so it is clean if($options['allow_html'] != 0) { $text[2] = $this->parse_html($text[2]); }
| |
if(my_strtolower($text[1]) == "code") { $code = $this->mycode_parse_code($text[2]);
|
if(my_strtolower($text[1]) == "code") { $code = $this->mycode_parse_code($text[2]);
|
}
| }
|
elseif(my_strtolower($text[1]) == "php") { $code = $this->mycode_parse_php($text[2]);
| elseif(my_strtolower($text[1]) == "php") { $code = $this->mycode_parse_php($text[2]);
|
Zeile 189 | Zeile 180 |
---|
$message = preg_replace("#\<mybb-code>\n?#", $code, $message, 1); } }
|
$message = preg_replace("#\<mybb-code>\n?#", $code, $message, 1); } }
|
| }
// Replace meta and base tags in our post - these are > dangerous < if($this->options['allow_html']) { $message = preg_replace_callback("#<((m[^a])|(b[^diloru>])|(s[^aemptu>]))(\s*[^>]*)>#si", create_function( '$matches', 'return htmlspecialchars($matches[0]);' ), $message);
|
}
if($options['nl2br'] !== 0)
| }
if($options['nl2br'] !== 0)
|
Zeile 379 | Zeile 379 |
---|
if($options['allow_videocode'] != 0) { $message = preg_replace("#\[video=(.*?)\](.*?)\[/video\]#ei", "\$this->mycode_parse_video('$1', '$2');", $message);
|
if($options['allow_videocode'] != 0) { $message = preg_replace("#\[video=(.*?)\](.*?)\[/video\]#ei", "\$this->mycode_parse_video('$1', '$2');", $message);
|
}
| }
|
return $message; }
/** * Generates a cache of smilies
|
return $message; }
/** * Generates a cache of smilies
|
*
| *
|
* @access private */ private function cache_smilies() {
|
* @access private */ private function cache_smilies() {
|
global $cache;
| global $cache, $mybb;
|
$this->smilies_cache = array();
|
$this->smilies_cache = array();
|
|
|
$smilies = $cache->read("smilies"); if(is_array($smilies)) { foreach($smilies as $sid => $smilie) {
|
$smilies = $cache->read("smilies"); if(is_array($smilies)) { foreach($smilies as $sid => $smilie) {
|
| if(defined("IN_ARCHIVE") && substr($smilie['image'], 0, 4) != "http") { // We're in the archive and not using an outside image, add in our address $smilie['image'] = $mybb->settings['bburl']."/".$smilie['image']; }
|
$this->smilies_cache[$smilie['find']] = "<img src=\"{$smilie['image']}\" style=\"vertical-align: middle;\" border=\"0\" alt=\"{$smilie['name']}\" title=\"{$smilie['name']}\" />"; } }
| $this->smilies_cache[$smilie['find']] = "<img src=\"{$smilie['image']}\" style=\"vertical-align: middle;\" border=\"0\" alt=\"{$smilie['name']}\" title=\"{$smilie['name']}\" />"; } }
|
Zeile 422 | Zeile 428 |
---|
$message = ' ' . $message . ' '; // First we take out any of the tags we don't want parsed between (url= etc)
|
$message = ' ' . $message . ' '; // First we take out any of the tags we don't want parsed between (url= etc)
|
preg_match_all("#\[(url(=[^\]]*])?\](.*?)\[\/url\]|quote=([^\]]*)?\])#i", $message, $bad_matches, PREG_PATTERN_ORDER); $message = preg_replace("#\[(url(=[^\]]*])?\](.*?)\[\/url\]|quote=([^\]]*)?\])#si", "<mybb-bad-sm>", $message);
| preg_match_all("#\[(url(=[^\]]*)?\](.*?)\[\/url\]|quote=([^\]]*)?\])#i", $message, $bad_matches, PREG_PATTERN_ORDER); $message = preg_replace("#\[(url(=[^\]]*)?\](.*?)\[\/url\]|quote=([^\]]*)?\])#si", "<mybb-bad-sm>", $message);
|
// Impose a hard limit of 500 smilies per message as to not overload the parser $remaining = 500;
| // Impose a hard limit of 500 smilies per message as to not overload the parser $remaining = 500;
|
Zeile 435 | Zeile 441 |
---|
$orig_message = $message; $find = $this->parse_html($find); $find = preg_quote($find, "#");
|
$orig_message = $message; $find = $this->parse_html($find); $find = preg_quote($find, "#");
|
| $replace = strip_tags($replace, "<img>");
|
// Fix issues for smileys starting with a ";" $orig_find = $find;
| // Fix issues for smileys starting with a ";" $orig_find = $find;
|
Zeile 535 | Zeile 543 |
---|
function fix_javascript($message) { $js_array = array(
|
function fix_javascript($message) { $js_array = array(
|
"#(&\#(0*)106;|&\#(0*)74;|j)((&\#(0*)97;|&\#(0*)65;|a)(&\#(0*)118;|&\#(0*)86;|v)(&\#(0*)97;|&\#(0*)65;|a)(\s)?(&\#(0*)115;|&\#(0*)83;|s)(&\#(0*)99;|&\#(0*)67;|c)(&\#(0*)114;|&\#(0*)82;|r)(&\#(0*)105;|&\#(0*)73;|i)(&\#112;|&\#(0*)80;|p)(&\#(0*)116;|&\#(0*)84;|t)(&\#(0*)58;|\:))#i",
| "#(&\#(0*)106;?|&\#(0*)74;?|&\#x(0*)4a;?|&\#x(0*)6a;?|j)((&\#(0*)97;?|&\#(0*)65;?|a)(&\#(0*)118;?|&\#(0*)86;?|v)(&\#(0*)97;?|&\#(0*)65;?|a)(\s)?(&\#(0*)115;?|&\#(0*)83;?|s)(&\#(0*)99;?|&\#(0*)67;?|c)(&\#(0*)114;?|&\#(0*)82;?|r)(&\#(0*)105;?|&\#(0*)73;?|i)(&\#112;?|&\#(0*)80;?|p)(&\#(0*)116;?|&\#(0*)84;?|t)(&\#(0*)58;?|\:))#i",
|
"#(o)(nmouseover\s?=)#i", "#(o)(nmouseout\s?=)#i", "#(o)(nmousedown\s?=)#i",
| "#(o)(nmouseover\s?=)#i", "#(o)(nmouseout\s?=)#i", "#(o)(nmousedown\s?=)#i",
|
Zeile 592 | Zeile 600 |
---|
// Assign pattern and replace values. $pattern = array(
|
// Assign pattern and replace values. $pattern = array(
|
"#\[quote=(?:"|\"|')?(.*?)[\"']?(?:"|\"|')?\](.*?)\[\/quote\](\r\n?|\n?)#esi",
| "#\[quote=([\"']|"|)(.*?)(?:\\1)(.*?)(?:[\"']|")?\](.*?)\[/quote\](\r\n?|\n?)#esi",
|
"#\[quote\](.*?)\[\/quote\](\r\n?|\n?)#si" );
if($text_only == false) { $replace = array(
|
"#\[quote\](.*?)\[\/quote\](\r\n?|\n?)#si" );
if($text_only == false) { $replace = array(
|
"\$this->mycode_parse_post_quotes('$2','$1')",
| "\$this->mycode_parse_post_quotes('$4','$2$3')",
|
"<blockquote><cite>$lang->quote</cite>$1</blockquote>\n" ); } else { $replace = array(
|
"<blockquote><cite>$lang->quote</cite>$1</blockquote>\n" ); } else { $replace = array(
|
"\$this->mycode_parse_post_quotes('$2', '$1', true)",
| "\$this->mycode_parse_post_quotes('$4','$2$3', true)",
|
"\n{$lang->quote}\n--\n$1\n--\n" ); }
|
"\n{$lang->quote}\n--\n$1\n--\n" ); }
|
while(preg_match($pattern[0], $message) || preg_match($pattern[1], $message))
| do
|
{
|
{
|
$message = preg_replace($pattern, $replace, $message); }
| $message = preg_replace($pattern, $replace, $message, -1, $count); } while($count);
|
if($text_only == false) {
| if($text_only == false) {
|
Zeile 767 | Zeile 775 |
---|
$original = preg_replace('#^\t*#', '', $str);
if(empty($original))
|
$original = preg_replace('#^\t*#', '', $str);
if(empty($original))
|
{
| {
|
return; }
| return; }
|
Zeile 799 | Zeile 807 |
---|
$code = str_replace("\\", '\', $code); $code = str_replace('$', '$', $code); $code = preg_replace("#&\#([0-9]+);#si", "&#$1;", $code);
|
$code = str_replace("\\", '\', $code); $code = str_replace('$', '$', $code); $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);
| if($added_open_tag) { $code = preg_replace("#<code><span style=\"color: \#([A-Z0-9]{6})\"><\?php( | )(<br />?)#", "<code><span style=\"color: #$1\">", $code);
|
Zeile 847 | Zeile 855 |
---|
if(!$name) { $name = $url;
|
if(!$name) { $name = $url;
|
}
| }
|
$name = str_replace("\'", "'", $name); $url = str_replace("\'", "'", $url);
| $name = str_replace("\'", "'", $name); $url = str_replace("\'", "'", $url);
|
Zeile 894 | Zeile 902 |
---|
if(my_strlen($alt) > 55) { $alt = my_substr($alt, 0, 40)."...".my_substr($alt, -10);
|
if(my_strlen($alt) > 55) { $alt = my_substr($alt, 0, 40)."...".my_substr($alt, -10);
|
}
| }
|
$alt = $lang->sprintf($lang->posted_image, $alt); if($dimensions[0] > 0 && $dimensions[1] > 0) {
| $alt = $lang->sprintf($lang->posted_image, $alt); if($dimensions[0] > 0 && $dimensions[1] > 0) {
|
Zeile 944 | Zeile 952 |
---|
if($parsed_url == false) { return "[video={$video}]{$url}[/video]";;
|
if($parsed_url == false) { return "[video={$video}]{$url}[/video]";;
|
}
| }
|
$fragments = array(); if($parsed_url['fragment'])
| $fragments = array(); if($parsed_url['fragment'])
|
Zeile 956 | Zeile 964 |
---|
$input = array(); foreach($queries as $query)
|
$input = array(); foreach($queries as $query)
|
{
| {
|
list($key, $value) = explode("=", $query); $key = str_replace("amp;", "", $key); $input[$key] = $value;
| list($key, $value) = explode("=", $query); $key = str_replace("amp;", "", $key); $input[$key] = $value;
|
Zeile 990 | Zeile 998 |
---|
if($fragments[0]) { $id = str_replace('!v=', '', $fragments[0]); // http://www.youtube.com/watch#!v=fds123
|
if($fragments[0]) { $id = str_replace('!v=', '', $fragments[0]); // http://www.youtube.com/watch#!v=fds123
|
| } elseif($input['v']) { $id = $input['v']; // http://www.youtube.com/watch?v=fds123
|
} else {
|
} else {
|
$id = $input['v']; // http://www.youtube.com/watch?v=fds123
| $id = $path[1]; // http://www.youtu.be/fds123
|
} break; default:
| } break; default:
|
Zeile 1096 | Zeile 1108 |
---|
}
/**
|
}
/**
|
* Parses message to plain text equivilents of MyCode.
| * Parses message to plain text equivalents of MyCode.
|
* * @param string The message to be parsed * @return string The parsed message.
| * * @param string The message to be parsed * @return string The parsed message.
|
Zeile 1116 | Zeile 1128 |
---|
$find = array( "#\[(b|u|i|s|url|email|color|img)\](.*?)\[/\\1\]#is",
|
$find = array( "#\[(b|u|i|s|url|email|color|img)\](.*?)\[/\\1\]#is",
|
"#\[code\](.*?)\[/code\](\r\n?|\n?)#ise",
| |
"#\[php\](.*?)\[/php\](\r\n?|\n?)#ise",
|
"#\[php\](.*?)\[/php\](\r\n?|\n?)#ise",
|
| "#\[code\](.*?)\[/code\](\r\n?|\n?)#ise",
|
"#\[img=([0-9]{1,3})x([0-9]{1,3})\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", "#\[url=([a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#si", "#\[url=([^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#si",
| "#\[img=([0-9]{1,3})x([0-9]{1,3})\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", "#\[url=([a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#si", "#\[url=([^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#si",
|
Zeile 1140 | Zeile 1152 |
---|
$message = preg_replace('#(>|^|\r|\n)/me ([^\r\n<]*)#i', "\\1* {$options['me_username']} \\2", $message); $message = preg_replace('#(>|^|\r|\n)/slap ([^\r\n<]*)#i', "\\1* {$options['me_username']} {$lang->slaps} \\2 {$lang->with_trout}", $message);
|
$message = preg_replace('#(>|^|\r|\n)/me ([^\r\n<]*)#i', "\\1* {$options['me_username']} \\2", $message); $message = preg_replace('#(>|^|\r|\n)/slap ([^\r\n<]*)#i', "\\1* {$options['me_username']} {$lang->slaps} \\2 {$lang->with_trout}", $message);
|
}
| }
|
// Special code requiring special attention
|
// Special code requiring special attention
|
while(preg_match("#\[list\](.*?)\[/list\]#si", $message))
| while(preg_match("#\[list\](.*?)\[/list\]#esi", $message))
|
{
|
{
|
$message = preg_replace("#\[list\](.*?)\[/list\](\r\n?|\n?)#esi", "\$this->mycode_parse_list('$1', '', true)\n", $message);
| $message = preg_replace("#\s?\[list\](.*?)\[/list\](\r\n?|\n?)#esi", "\$this->mycode_parse_list('$1')\n", $message);
|
}
// Replace lists. while(preg_match("#\[list=(a|A|i|I|1)\](.*?)\[/list\](\r\n?|\n?)#esi", $message)) {
|
}
// Replace lists. while(preg_match("#\[list=(a|A|i|I|1)\](.*?)\[/list\](\r\n?|\n?)#esi", $message)) {
|
$message = preg_replace("#\[list=(a|A|i|I|1)\](.*?)\[/list\]#esi", "\$this->mycode_parse_list('$2', '$1', true)\n", $message);
| $message = preg_replace("#\s?\[list=(a|A|i|I|1)\](.*?)\[/list\]#esi", "\$this->mycode_parse_list('$2', '$1')\n", $message);
|
}
// Run plugin hooks
| }
// Run plugin hooks
|