Vergleich inc/class_parser.php - 1.8.8 - 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 220Zeile 239
		}

if(!isset($this->options['nl2br']) || $this->options['nl2br'] != 0)

		}

if(!isset($this->options['nl2br']) || $this->options['nl2br'] != 0)

		{

		{

			$message = nl2br($message);
// Fix up new lines and block level elements
$message = preg_replace("#(</?(?:html|head|body|div|p|form|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p|blockquote|cite|hr)[^>]*>)\s*<br />#i", "$1", $message);
$message = preg_replace("#(&nbsp;)+(</?(?:html|head|body|div|p|form|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p|blockquote|cite|hr)[^>]*>)#i", "$2", $message);

			$message = nl2br($message);
// Fix up new lines and block level elements
$message = preg_replace("#(</?(?:html|head|body|div|p|form|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p|blockquote|cite|hr)[^>]*>)\s*<br />#i", "$1", $message);
$message = preg_replace("#(&nbsp;)+(</?(?:html|head|body|div|p|form|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p|blockquote|cite|hr)[^>]*>)#i", "$2", $message);

		}


		}


		if($this->clear_needed)
{
$message .= '<br class="clear" />';

		if($this->clear_needed)
{
$message .= '<br class="clear" />';

Zeile 244Zeile 263
	 * @return string The formatted message.
*/
function parse_html($message)

	 * @return string The formatted message.
*/
function parse_html($message)

	{

	{

		$message = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $message); // fix & but allow unicode
$message = str_replace("<","&lt;",$message);
$message = str_replace(">","&gt;",$message);

		$message = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $message); // fix & but allow unicode
$message = str_replace("<","&lt;",$message);
$message = str_replace(">","&gt;",$message);

Zeile 300Zeile 319

if($mybb->settings['allowlinkmycode'] == 1)
{


if($mybb->settings['allowlinkmycode'] == 1)
{

			$callback_mycode['url_simple']['regex'] = "#\[url\]([a-z]+?://)([^\r\n\"<]+?)\[/url\]#si";

			$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']['replacement'] = array($this, 'mycode_parse_url_callback1');


			$callback_mycode['url_simple2']['regex'] = "#\[url\]([^\r\n\"<]+?)\[/url\]#i";

			$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_simple2']['replacement'] = array($this, 'mycode_parse_url_callback2');


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

			$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_complex']['replacement'] = array($this, 'mycode_parse_url_callback1');


			$callback_mycode['url_complex2']['regex'] = "#\[url=([^\r\n\"<]+?)\](.+?)\[/url\]#si";

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

			$callback_mycode['url_complex2']['replacement'] = array($this, 'mycode_parse_url_callback2');

++$callback_count;

			$callback_mycode['url_complex2']['replacement'] = array($this, 'mycode_parse_url_callback2');

++$callback_count;

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 331Zeile 350
			$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_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;
}

if($mybb->settings['allowfontmycode'] == 1)

			++$nestable_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>";


			$nestable_mycode['font']['regex'] = "#\[font=([a-z0-9 ,\-_'\"]+)\](.*?)\[/font\]#si";
$nestable_mycode['font']['replacement'] = "<span style=\"font-family: $1;\" class=\"mycode_font\">$2</span>";


Zeile 386Zeile 405
		{
$this->mycode_cache['standard']['find'][] = $code['regex'];
$this->mycode_cache['standard']['replacement'][] = $code['replacement'];

		{
$this->mycode_cache['standard']['find'][] = $code['regex'];
$this->mycode_cache['standard']['replacement'][] = $code['replacement'];

		}

		}


// Assign the nestable MyCode to the cache.
foreach($nestable_mycode as $code)


// Assign the nestable MyCode to the cache.
foreach($nestable_mycode as $code)

Zeile 430Zeile 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('$', '&#36;', $message);



$message = str_replace('$', '&#36;', $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.

		}
}

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

	* @return string The parsed message.
*/
function mycode_parse_post_quotes_callback1($matches)
{
return $this->mycode_parse_post_quotes($matches[4],$matches[2].$matches[3]);

	* @return string The parsed message.
*/
function mycode_parse_post_quotes_callback1($matches)
{
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.

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)
{

	*/
function mycode_parse_code($code, $text_only=false)
{

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;

if($text_only == true)

	*/
function mycode_parse_php($str, $bare_return = false, $text_only = false)
{
global $lang, $templates;

if($text_only == true)

		{

		{

			return "\n{$lang->php_code}\n--\n$str\n--\n";

			return "\n{$lang->php_code}\n--\n$str\n--\n";

		}


		}


		// Clean the string before parsing except tab spaces.
$str = preg_replace('#^(\t*)(\n|\r|\0|\x0B| )*#', '\\1', $str);
$str = rtrim($str);

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

		// Clean the string before parsing except tab spaces.
$str = preg_replace('#^(\t*)(\n|\r|\0|\x0B| )*#', '\\1', $str);
$str = rtrim($str);

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





		if(empty($original))
{
return;

		if(empty($original))
{
return;

Zeile 960Zeile 988
		// See if open and close tags are provided.
$added_open_tag = false;
if(!preg_match("#^\s*<\?#si", $str))

		// See if open and close tags are provided.
$added_open_tag = false;
if(!preg_match("#^\s*<\?#si", $str))

		{

		{

			$added_open_tag = true;
$str = "<?php \n".$str;
}

			$added_open_tag = true;
$str = "<?php \n".$str;
}

Zeile 1007Zeile 1035
		// Send back the code all nice and pretty
eval("\$mycode_php = \"".$templates->get("mycode_php", 1, 0)."\";");
return $mycode_php;

		// Send back the code all nice and pretty
eval("\$mycode_php = \"".$templates->get("mycode_php", 1, 0)."\";");
return $mycode_php;

	}


	}


	/**
* Parses PHP code MyCode.
*

	/**
* Parses PHP code MyCode.
*

Zeile 1055Zeile 1083
			$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

		$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

eval("\$mycode_url = \"".$templates->get("mycode_url", 1, 0)."\";");

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

eval("\$mycode_url = \"".$templates->get("mycode_url", 1, 0)."\";");

Zeile 1082Zeile 1113
		if(!isset($matches[3]))
{
$matches[3] = '';

		if(!isset($matches[3]))
{
$matches[3] = '';

		}

		}

		return $this->mycode_parse_url($matches[1].$matches[2], $matches[3]);
}


		return $this->mycode_parse_url($matches[1].$matches[2], $matches[3]);
}


Zeile 1129Zeile 1160
		else if($align == "left")
{
$css_align = ' style="float: left;"';

		else if($align == "left")
{
$css_align = ' style="float: left;"';

		}


		}


		if($align)
{
$this->clear_needed = true;

		if($align)
{
$this->clear_needed = true;

		}

		}


$alt = basename($url);
$alt = htmlspecialchars_decode($alt);


$alt = basename($url);
$alt = htmlspecialchars_decode($alt);

Zeile 1143Zeile 1174
			$alt = my_substr($alt, 0, 40).'...'.my_substr($alt, -10);
}
$alt = htmlspecialchars_uni($alt);

			$alt = my_substr($alt, 0, 40).'...'.my_substr($alt, -10);
}
$alt = htmlspecialchars_uni($alt);





		$alt = $lang->sprintf($lang->posted_image, $alt);
$width = $height = '';
if(isset($dimensions[0]) && $dimensions[0] > 0 && isset($dimensions[1]) && $dimensions[1] > 0)

		$alt = $lang->sprintf($lang->posted_image, $alt);
$width = $height = '';
if(isset($dimensions[0]) && $dimensions[0] > 0 && isset($dimensions[1]) && $dimensions[1] > 0)

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.

	}

/**
* Parses IMG MyCode.
*
* @param array $matches Matches.

	 * @return string Image code.
*/
function mycode_parse_img_callback1($matches)
{
return $this->mycode_parse_img($matches[2]);

	 * @return string Image code.
*/
function mycode_parse_img_callback1($matches)
{
return $this->mycode_parse_img($matches[2]);

	}

/**

	}

/**

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

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

Zeile 1176Zeile 1209
	function mycode_parse_img_callback2($matches)
{
return $this->mycode_parse_img($matches[4], array($matches[1], $matches[2]));

	function mycode_parse_img_callback2($matches)
{
return $this->mycode_parse_img($matches[4], array($matches[1], $matches[2]));

	}

/**
* Parses IMG MyCode.

	}

/**
* Parses IMG MyCode.

	 *
* @param array $matches Matches.
* @return string Image code.

	 *
* @param array $matches Matches.
* @return string Image code.

Zeile 1227Zeile 1260
	function mycode_parse_img_disabled_callback1($matches)
{
return $this->mycode_parse_img_disabled($matches[2]);

	function mycode_parse_img_disabled_callback1($matches)
{
return $this->mycode_parse_img_disabled($matches[2]);

	}

	}


/**
* Parses IMG MyCode disabled.


/**
* Parses IMG MyCode disabled.

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 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)
{
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 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 1359Zeile 1405
				break;
case "facebook":
if(isset($input['v']))

				break;
case "facebook":
if(isset($input['v']))

				{

				{

					$id = $input['v']; // http://www.facebook.com/video/video.php?v=123
}
elseif(substr($path[3], 0, 3) == 'vb.')

					$id = $input['v']; // http://www.facebook.com/video/video.php?v=123
}
elseif(substr($path[3], 0, 3) == 'vb.')

Zeile 1369Zeile 1415
				else
{
$id = $path[3]; // https://www.facebook.com/fds/videos/123/

				else
{
$id = $path[3]; // https://www.facebook.com/fds/videos/123/

				}

				}

				break;
case "veoh":
$id = $path[2]; // http://www.veoh.com/watch/123

				break;
case "veoh":
$id = $path[2]; // http://www.veoh.com/watch/123

Zeile 1383Zeile 1429
					$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

				{

				{

					$id = $path[1]; // http://xy.screen.yahoo.com/fds-123.html
}
// Support for localized portals

					$id = $path[1]; // http://xy.screen.yahoo.com/fds-123.html
}
// Support for localized portals

Zeile 1391Zeile 1437
				if($domain[0] != 'screen' && preg_match('#^([a-z-]+)$#', $domain[0]))
{
$local = "{$domain[0]}.";

				if($domain[0] != 'screen' && preg_match('#^([a-z-]+)$#', $domain[0]))
{
$local = "{$domain[0]}.";

				}

				}

				else
{
$local = '';

				else
{
$local = '';

Zeile 1419Zeile 1465
				else
{
$id = $path[1]; // http://www.youtu.be/fds123

				else
{
$id = $path[1]; // http://www.youtu.be/fds123

 
				}
break;
case "twitch":
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)
{
// 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))
{
return "[video={$video}]{$url}[/video]";
}

		if(empty($id))
{
return "[video={$video}]{$url}[/video]";
}





		$id = htmlspecialchars_uni($id);

eval("\$video_code = \"".$templates->get("video_{$video}_embed")."\";");
return $video_code;

		$id = htmlspecialchars_uni($id);

eval("\$video_code = \"".$templates->get("video_{$video}_embed")."\";");
return $video_code;

	}

	}


/**
* Parses video MyCode.


/**
* Parses video MyCode.

Zeile 1474Zeile 1537
	function mycode_parse_video_disabled_callback($matches)
{
return $this->mycode_parse_video_disabled($matches[2]);

	function mycode_parse_video_disabled_callback($matches)
{
return $this->mycode_parse_video_disabled($matches[2]);

	}

/**
* Parses URLs automatically.

	}

/**
* Parses URLs automatically.

	*
* @param string $message The message to be parsed

	*
* @param string $message The message to be parsed

	* @return string The parsed message.

	* @return string The parsed message.

	*/
function mycode_auto_url($message)

	*/
function mycode_auto_url($message)

	{

	{

		$message = " ".$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 1501Zeile 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) == ')')

		$external = '';
// Allow links like http://en.wikipedia.org/wiki/PHP_(disambiguation) but detect mismatching braces
while(my_substr($matches[3], -1) == ')')

Zeile 1524Zeile 1596
				$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}";

			$url = "{$matches[2]}.{$matches[3]}";

		}
else
{

		}
else
{

			return "{$matches[1]}[url]{$matches[2]}://{$matches[3]}[/url]{$external}";

			$url = "{$matches[2]}://{$matches[3]}";

		}

		}

 

return $matches[1].$this->mycode_parse_url($url, $url).$external;

	}

/**

	}

/**

Zeile 1549Zeile 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)
{
$list = "\n<ol type=\"$type\" class=\"mycode_list\">$message</ol>\n";


if($type)
{
$list = "\n<ol type=\"$type\" class=\"mycode_list\">$message</ol>\n";

		}
else
{

		}
else
{

			$list = "<ul class=\"mycode_list\">$message</ul>\n";
}
$list = preg_replace("#<(ol type=\"$type\"|ul)>\s*</li>#", "<$1>", $list);

			$list = "<ul class=\"mycode_list\">$message</ul>\n";
}
$list = preg_replace("#<(ol type=\"$type\"|ul)>\s*</li>#", "<$1>", $list);

Zeile 1648Zeile 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;

	}

/**

	}

/**

Zeile 1665Zeile 1743
		global $plugins;

if(empty($this->options))

		global $plugins;

if(empty($this->options))

		{

		{

			$this->options = $options;
}


			$this->options = $options;
}


Zeile 1673Zeile 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);

$message = preg_replace_callback("#\[php\](.*?)\[/php\](\r\n?|\n?)#is", array($this, 'mycode_parse_php_callback'), $message);
$message = preg_replace_callback("#\[code\](.*?)\[/code\](\r\n?|\n?)#is", array($this, 'mycode_parse_code_callback'), $message);


// Parse quotes first
$message = $this->mycode_parse_quotes($message, true);

$message = preg_replace_callback("#\[php\](.*?)\[/php\](\r\n?|\n?)#is", array($this, 'mycode_parse_php_callback'), $message);
$message = preg_replace_callback("#\[code\](.*?)\[/code\](\r\n?|\n?)#is", array($this, 'mycode_parse_code_callback'), $message);





		$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",

			"#\[img=([1-9][0-9]*)x([1-9][0-9]*)\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is",

			"#\[url=([a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#si",
"#\[url=([^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#si",

			"#\[url=((?!javascript)[a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#si",
"#\[url=((?!javascript:)[^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#si",

		);

$replace = array(

		);

$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']))

Zeile 1723Zeile 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;

	}
}

	}
}