Vergleich inc/class_parser.php - 1.8.10 - 1.8.15

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 165Zeile 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 185Zeile 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 204Zeile 208
				foreach($code_matches as $text)
{
if(my_strtolower($text[1]) == "code")

				foreach($code_matches as $text)
{
if(my_strtolower($text[1]) == "code")

					{

					{

						// Fix up HTML inside the code tags so it is clean
$text[2] = $this->parse_html($text[2]);


						// Fix up HTML inside the code tags so it is clean
$text[2] = $this->parse_html($text[2]);


Zeile 263Zeile 267

$standard_mycode = $callback_mycode = $nestable_mycode = array();
$standard_count = $callback_count = $nestable_count = 0;


$standard_mycode = $callback_mycode = $nestable_mycode = array();
$standard_count = $callback_count = $nestable_count = 0;





		if($mybb->settings['allowbasicmycode'] == 1)
{
$standard_mycode['b']['regex'] = "#\[b\](.*?)\[/b\]#si";

		if($mybb->settings['allowbasicmycode'] == 1)
{
$standard_mycode['b']['regex'] = "#\[b\](.*?)\[/b\]#si";

Zeile 271Zeile 275

$standard_mycode['u']['regex'] = "#\[u\](.*?)\[/u\]#si";
$standard_mycode['u']['replacement'] = "<span style=\"text-decoration: underline;\" class=\"mycode_u\">$1</span>";


$standard_mycode['u']['regex'] = "#\[u\](.*?)\[/u\]#si";
$standard_mycode['u']['replacement'] = "<span style=\"text-decoration: underline;\" class=\"mycode_u\">$1</span>";





			$standard_mycode['i']['regex'] = "#\[i\](.*?)\[/i\]#si";
$standard_mycode['i']['replacement'] = "<span style=\"font-style: italic;\" class=\"mycode_i\">$1</span>";

$standard_mycode['s']['regex'] = "#\[s\](.*?)\[/s\]#si";
$standard_mycode['s']['replacement'] = "<span style=\"text-decoration: line-through;\" class=\"mycode_s\">$1</span>";

			$standard_mycode['i']['regex'] = "#\[i\](.*?)\[/i\]#si";
$standard_mycode['i']['replacement'] = "<span style=\"font-style: italic;\" class=\"mycode_i\">$1</span>";

$standard_mycode['s']['regex'] = "#\[s\](.*?)\[/s\]#si";
$standard_mycode['s']['replacement'] = "<span style=\"text-decoration: line-through;\" class=\"mycode_s\">$1</span>";





			$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";
$standard_mycode['copy']['replacement'] = "&copy;";

		if($mybb->settings['allowsymbolmycode'] == 1)
{
$standard_mycode['copy']['regex'] = "#\(c\)#i";
$standard_mycode['copy']['replacement'] = "&copy;";





			$standard_mycode['tm']['regex'] = "#\(tm\)#i";
$standard_mycode['tm']['replacement'] = "&#153;";

			$standard_mycode['tm']['regex'] = "#\(tm\)#i";
$standard_mycode['tm']['replacement'] = "&#153;";





			$standard_mycode['reg']['regex'] = "#\(r\)#i";
$standard_mycode['reg']['replacement'] = "&reg;";


			$standard_mycode['reg']['regex'] = "#\(r\)#i";
$standard_mycode['reg']['replacement'] = "&reg;";


Zeile 302Zeile 306
		{
$callback_mycode['url_simple']['regex'] = "#\[url\]((?!javascript)[a-z]+?://)([^\r\n\"<]+?)\[/url\]#si";
$callback_mycode['url_simple']['replacement'] = array($this, 'mycode_parse_url_callback1');

		{
$callback_mycode['url_simple']['regex'] = "#\[url\]((?!javascript)[a-z]+?://)([^\r\n\"<]+?)\[/url\]#si";
$callback_mycode['url_simple']['replacement'] = array($this, 'mycode_parse_url_callback1');





			$callback_mycode['url_simple2']['regex'] = "#\[url\]((?!javascript:)[^\r\n\"<]+?)\[/url\]#i";
$callback_mycode['url_simple2']['replacement'] = array($this, 'mycode_parse_url_callback2');

$callback_mycode['url_complex']['regex'] = "#\[url=((?!javascript)[a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#si";
$callback_mycode['url_complex']['replacement'] = array($this, 'mycode_parse_url_callback1');

			$callback_mycode['url_simple2']['regex'] = "#\[url\]((?!javascript:)[^\r\n\"<]+?)\[/url\]#i";
$callback_mycode['url_simple2']['replacement'] = array($this, 'mycode_parse_url_callback2');

$callback_mycode['url_complex']['regex'] = "#\[url=((?!javascript)[a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#si";
$callback_mycode['url_complex']['replacement'] = array($this, 'mycode_parse_url_callback1');





			$callback_mycode['url_complex2']['regex'] = "#\[url=((?!javascript:)[^\r\n\"<]+?)\](.+?)\[/url\]#si";
$callback_mycode['url_complex2']['replacement'] = array($this, 'mycode_parse_url_callback2');


			$callback_mycode['url_complex2']['regex'] = "#\[url=((?!javascript:)[^\r\n\"<]+?)\](.+?)\[/url\]#si";
$callback_mycode['url_complex2']['replacement'] = array($this, 'mycode_parse_url_callback2');


Zeile 317Zeile 321

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 360Zeile 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");

		}

$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 429Zeile 433

// 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 474Zeile 494
			{
// 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);

			{
// 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 821Zeile 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("#(?:&quot;|\"|')? dateline=(?:&quot;|\"|')?[0-9]+(?:&quot;|\"|')?#i", '', $username);
$delete_quote = false;

				$date = " ({$postdate})";
}
$username = preg_replace("#(?:&quot;|\"|')? dateline=(?:&quot;|\"|')?[0-9]+(?:&quot;|\"|')?#i", '', $username);
$delete_quote = false;

		}


		}


		if($delete_quote)

		if($delete_quote)

		{

		{

			$username = my_substr($username, 0, my_strlen($username)-1);
}

if(!empty($this->options['allow_html']))
{
$username = htmlspecialchars_uni($username);

			$username = my_substr($username, 0, my_strlen($username)-1);
}

if(!empty($this->options['allow_html']))
{
$username = htmlspecialchars_uni($username);

		}


		}


		if($text_only)

		if($text_only)

		{

		{

			return "\n{$username} {$lang->wrote}{$date}\n--\n{$message}\n--\n";
}
else

			return "\n{$username} {$lang->wrote}{$date}\n--\n{$message}\n--\n";
}
else

Zeile 852Zeile 863

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.

	* Parses quotes with post id and/or dateline.
*
* @param array $matches Matches.

Zeile 868Zeile 879

/**
* 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.
*/

	function mycode_parse_post_quotes_callback2($matches)
{
return $this->mycode_parse_post_quotes($matches[4],$matches[2].$matches[3], true);

	function mycode_parse_post_quotes_callback2($matches)
{
return $this->mycode_parse_post_quotes($matches[4],$matches[2].$matches[3], true);

Zeile 885Zeile 896
	* @return string The parsed message.
*/
function mycode_parse_code($code, $text_only=false)

	* @return string The parsed message.
*/
function mycode_parse_code($code, $text_only=false)

	{

	{

		global $lang, $templates;

if($text_only == true)

		global $lang, $templates;

if($text_only == true)

Zeile 917Zeile 928
	* Parses code MyCode.
*
* @param array $matches Matches.

	* Parses code MyCode.
*
* @param array $matches Matches.

	* @return string The parsed message.

	* @return string The parsed message.

	*/
function mycode_parse_code_callback($matches)
{

	*/
function mycode_parse_code_callback($matches)
{

Zeile 948Zeile 959
		$original = preg_replace('#^\t*#', '', $str);

if(empty($original))

		$original = preg_replace('#^\t*#', '', $str);

if(empty($original))

		{

		{

			return;
}


			return;
}


Zeile 987Zeile 998
			$code = str_replace("?&gt;</span></code>", "</span></code>", $code);
// Wait a minute. It fails highlighting? Stupid highlighter.
$code = str_replace("?&gt;</code>", "</code>", $code);

			$code = str_replace("?&gt;</span></code>", "</span></code>", $code);
// Wait a minute. It fails highlighting? Stupid highlighter.
$code = str_replace("?&gt;</code>", "</code>", $code);

		}

		}


$code = preg_replace("#<span style=\"color: \#([A-Z0-9]{6})\"></span>#", "", $code);
$code = str_replace("<code>", "<div dir=\"ltr\"><code>", $code);


$code = preg_replace("#<span style=\"color: \#([A-Z0-9]{6})\"></span>#", "", $code);
$code = str_replace("<code>", "<div dir=\"ltr\"><code>", $code);

Zeile 1038Zeile 1049
		if(!$name)
{
$name = $url;

		if(!$name)
{
$name = $url;

		}

		}


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 = htmlspecialchars_decode($name);
if(my_strlen($name) > 55)
{

Zeile 1050Zeile 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

		}

// Fix some entities in URLs

Zeile 1262Zeile 1276
	*
* @param string $email The email address to link to.
* @param string $name The name for the link.

	*
* @param string $email The email address to link to.
* @param string $name The name for the link.

	* @return string The built-up email link.

	* @return string The built-up email link.

	*/
function mycode_parse_email($email, $name="")
{

	*/
function mycode_parse_email($email, $name="")
{

Zeile 1320Zeile 1334
		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 1397Zeile 1411
				{
$id = $path[3]; // http://vimeo.com/fds/fds/fds123
}

				{
$id = $path[3]; // http://vimeo.com/fds/fds/fds123
}

				else
{
$id = $path[1]; // http://vimeo.com/fds123
}
break;

				else
{
$id = $path[1]; // http://vimeo.com/fds123
}
break;

			case "youtube":
if($fragments[0])
{
$id = str_replace('!v=', '', $fragments[0]); // http://www.youtube.com/watch#!v=fds123

			case "youtube":
if($fragments[0])
{
$id = str_replace('!v=', '', $fragments[0]); // http://www.youtube.com/watch#!v=fds123

				}

				}

				elseif($input['v'])

				elseif($input['v'])

				{

				{

					$id = $input['v']; // http://www.youtube.com/watch?v=fds123

					$id = $input['v']; // http://www.youtube.com/watch?v=fds123

				}

				}

				else
{
$id = $path[1]; // http://www.youtu.be/fds123
}
break;
case "twitch":

				else
{
$id = $path[1]; // http://www.youtu.be/fds123
}
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 1487Zeile 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 1525Zeile 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}";
}