Vergleich inc/class_parser.php - 1.8.9 - 1.8.17

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 146Zeile 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("&lt;mybb-code&gt;\n", "<mybb-code>\n", $message);

		}

if(empty($this->options['allow_html']))
{
$message = $this->parse_html($message);
$message = str_replace("&lt;mybb-code&gt;\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', '&lt;$1$2$3&gt;', $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', '&lt;$1$2$3&gt;', $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 174Zeile 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 294Zeile 313

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


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





			++$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 317Zeile 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 338Zeile 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 423Zeile 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('$', '&#36;', $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('$', '&#36;', $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 477Zeile 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 631Zeile 650
					$badword['replacement'] = "*****";
}


					$badword['replacement'] = "*****";
}


				// Take into account the position offset for our last replacement.
$index = substr_count($badword['badword'], '*')+2;
$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..))
$count = preg_match_all("#(^|\W)".$badword['badword']."(\W|$)#i", $message, $matches);
for($i=0; $i < $count; ++$i)

				if($badword['regex'])







				{

				{

					$message = preg_replace("#(^|\W)".$badword['badword']."(\W|$)#i", "\\1".$badword['replacement'].'\\'.$index, $message);









					$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);

				}
}
}
if(!empty($this->options['strip_tags']))
{
$message = strip_tags($message);

				}
}
}
if(!empty($this->options['strip_tags']))
{
$message = strip_tags($message);

		}
return $message;
}

/**

		}
return $message;
}

/**

	 * Resolves nested CDATA tags in the specified message.
*
* @param string $message The message to be parsed.

	 * Resolves nested CDATA tags in the specified message.
*
* @param string $message The message to be parsed.

Zeile 659Zeile 680
	function parse_cdata($message)
{
$message = str_replace(']]>', ']]]]><![CDATA[>', $message);

	function parse_cdata($message)
{
$message = str_replace(']]>', ']]]]><![CDATA[>', $message);


return $message;
}

/**


return $message;
}

/**

	 * Attempts to move any javascript references in the specified message.
*
* @param string The message to be parsed.

	 * Attempts to move any javascript references in the specified message.
*
* @param string The message to be parsed.

Zeile 741Zeile 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 766Zeile 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 776Zeile 797
		}
return $message;
}

		}
return $message;
}





	/**
* Parses quotes with post id and/or dateline.
*

	/**
* Parses quotes with post id and/or dateline.
*

Zeile 788Zeile 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 808Zeile 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("#(?:&quot;|\"|')? pid=(?:&quot;|\"|')?[0-9]+[\"']?(?:&quot;|\"|')?#i", '', $username);


$username = preg_replace("#(?:&quot;|\"|')? pid=(?:&quot;|\"|')?[0-9]+[\"']?(?:&quot;|\"|')?#i", '', $username);

			$delete_quote = false;

			$delete_quote = false;

		}

unset($match);
preg_match("#dateline=(?:&quot;|\"|')?([0-9]+)(?:&quot;|\"|')?#i", $username, $match);
if((int)$match[1])

		}

unset($match);
preg_match("#dateline=(?:&quot;|\"|')?([0-9]+)(?:&quot;|\"|')?#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("#(?:&quot;|\"|')? dateline=(?:&quot;|\"|')?[0-9]+(?:&quot;|\"|')?#i", '', $username);

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

Zeile 839Zeile 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 854Zeile 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 886Zeile 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 935Zeile 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 983Zeile 1011
		$code = preg_replace("#&amp;\#([0-9]+);#si", "&#$1;", $code);

if($added_open_tag)

		$code = preg_replace("#&amp;\#([0-9]+);#si", "&#$1;", $code);

if($added_open_tag)

		{

		{

			$code = preg_replace("#<code><span style=\"color: \#([A-Z0-9]{6})\">&lt;\?php( |&nbsp;)(<br />?)#", "<code><span style=\"color: #$1\">", $code);
}


			$code = preg_replace("#<code><span style=\"color: \#([A-Z0-9]{6})\">&lt;\?php( |&nbsp;)(<br />?)#", "<code><span style=\"color: #$1\">", $code);
}


Zeile 1046Zeile 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', '&#36;' => '%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("#&amp;\#([0-9]+);#si", "&#$1;", $name); // Fix & but allow unicode



$name = preg_replace("#&amp;\#([0-9]+);#si", "&#$1;", $name); // Fix & but allow unicode


Zeile 1151Zeile 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 1174Zeile 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 1196Zeile 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 1213Zeile 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 1238Zeile 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 1260Zeile 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 1276Zeile 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 1284Zeile 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 1320Zeile 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 1348Zeile 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 1379Zeile 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 1422Zeile 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 1437Zeile 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 1451Zeile 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 1466Zeile 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 1478Zeile 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 1491Zeile 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 1507Zeile 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 1528Zeile 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 1555Zeile 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 1654Zeile 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 1679Zeile 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 1689Zeile 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 1729Zeile 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', '&#36;' => '%24', '^' => '%5E', '`' => '%60', '[' => '%5B', ']' => '%5D', '{' => '%7B', '}' => '%7D', '"' => '%22', '<' => '%3C', '>' => '%3E', ' ' => '%20');

$url = str_replace(array_keys($entities), array_values($entities), $url);

return $url;

	}
}

	}
}