Vergleich inc/class_parser.php - 1.4.9 - 1.4.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: class_parser.php 4322 2009-02-21 23:00:49Z Tikitiki $

 * $Id: class_parser.php 4538 2009-11-25 08:28:55Z RyanGordon $

 */

/*

 */

/*

Zeile 18Zeile 18
	filter_badwords
me_username
shorten_urls

	filter_badwords
me_username
shorten_urls

 
	highlight

)
*/


)
*/


Zeile 50Zeile 51
	 * @var string
*/
var $base_url;

	 * @var string
*/
var $base_url;

 
	
/**
* Parsed Highlights cache
*
* @access private
* @var array
*/
var $highlight_cache = array();

	
/**
* Options for this parsed message (Private - set by parse_message argument)

	
/**
* Options for this parsed message (Private - set by parse_message argument)

Zeile 58Zeile 67
	 * @var array
*/
var $options;

	 * @var array
*/
var $options;



	 

	/**
* Parses a message with the specified options.
*

	/**
* Parses a message with the specified options.
*

Zeile 96Zeile 105
		}

if($options['allow_html'] != 1)

		}

if($options['allow_html'] != 1)

		{

		{

			$message = $this->parse_html($message);
}
else

			$message = $this->parse_html($message);
}
else

Zeile 109Zeile 118
			$message = preg_replace("#\s*<base[^>]*>\s*#is", "", $message);
$message = preg_replace("#\s*<meta[^>]*>\s*#is", "", $message);
$message = str_replace(array('<?php', '<!--', '-->', '?>', "<br />\n", "<br>\n"), array('&lt;?php', '&lt;!--', '--&gt;', '?&gt;', "\n", "\n"), $message);

			$message = preg_replace("#\s*<base[^>]*>\s*#is", "", $message);
$message = preg_replace("#\s*<meta[^>]*>\s*#is", "", $message);
$message = str_replace(array('<?php', '<!--', '-->', '?>', "<br />\n", "<br>\n"), array('&lt;?php', '&lt;!--', '--&gt;', '?&gt;', "\n", "\n"), $message);

		}


		}


		// If MyCode needs to be replaced, first filter out [code] and [php] tags.
if($options['allow_mycode'])
{

		// If MyCode needs to be replaced, first filter out [code] and [php] tags.
if($options['allow_mycode'])
{

Zeile 141Zeile 150
		if($options['allow_mycode'])
{
$message = $this->parse_mycode($message, $options);

		if($options['allow_mycode'])
{
$message = $this->parse_mycode($message, $options);

 
		}

// Parse Highlights
if($options['highlight'])
{
$message = $this->highlight_message($message, $options['highlight']);

		}

// Run plugin hooks

		}

// Run plugin hooks

Zeile 155Zeile 170
				{
// Fix up HTML inside the code tags so it is clean
if($options['allow_html'] != 0)

				{
// Fix up HTML inside the code tags so it is clean
if($options['allow_html'] != 0)

					{

					{

						$text[2] = $this->parse_html($text[2]);
}


						$text[2] = $this->parse_html($text[2]);
}


Zeile 168Zeile 183
						$code = $this->mycode_parse_php($text[2]);
}
$message = preg_replace("#\<mybb-code>\n?#", $code, $message, 1);

						$code = $this->mycode_parse_php($text[2]);
}
$message = preg_replace("#\<mybb-code>\n?#", $code, $message, 1);

				}
}

				}
}

		}

if($options['nl2br'] !== 0)

		}

if($options['nl2br'] !== 0)

Zeile 403Zeile 418
					if($find{0} == ";")
{
$find = "(?<!&gt|&lt|&amp)".$find;

					if($find{0} == ";")
{
$find = "(?<!&gt|&lt|&amp)".$find;

					}


					}


					$message = @preg_replace("#(?<=[^\"])".$find."(?=.\W|\"|\W.|\W$)#si", $replace, $message, $remaining, $replacements);

if($message == null)

					$message = @preg_replace("#(?<=[^\"])".$find."(?=.\W|\"|\W.|\W$)#si", $replace, $message, $remaining, $replacements);

if($message == null)

					{

					{

						$message = preg_replace("#(?<=[^&;\"])".$orig_find."(?=.\W|\"|\W.|\W$)#si", $replace, $orig_message, $remaining);

						$message = preg_replace("#(?<=[^&;\"])".$orig_find."(?=.\W|\"|\W.|\W$)#si", $replace, $orig_message, $remaining);

					}

					}

					
$remaining -= $replacements;
if($remaining <= 0)

					
$remaining -= $replacements;
if($remaining <= 0)

Zeile 419Zeile 434
					}
}
else

					}
}
else

				{

				{

					$message = preg_replace("#(?<=[^&;\"])".$find."(?=.\W|\"|\W.|\W$)#si", $replace, $message, $remaining);
}

					$message = preg_replace("#(?<=[^&;\"])".$find."(?=.\W|\"|\W.|\W$)#si", $replace, $message, $remaining);
}

			}

			}

			unset($orig_message, $orig_find);

			unset($orig_message, $orig_find);

		}


		}


		// If we matched any tags previously, swap them back in
if(count($bad_matches[0]) > 0)
{
foreach($bad_matches[0] as $match)
{
$message = preg_replace("#<mybb-bad-sm>#", $match, $message, 1);

		// If we matched any tags previously, swap them back in
if(count($bad_matches[0]) > 0)
{
foreach($bad_matches[0] as $match)
{
$message = preg_replace("#<mybb-bad-sm>#", $match, $message, 1);

			}
}


			}
}


		return trim($message);
}


		return trim($message);
}


Zeile 448Zeile 463
		global $cache;
$this->badwords_cache = array();
$this->badwords_cache = $cache->read("badwords");

		global $cache;
$this->badwords_cache = array();
$this->badwords_cache = $cache->read("badwords");

	}

	}


/**
* Parses a list of filtered/badwords in the specified message.


/**
* Parses a list of filtered/badwords in the specified message.

Zeile 521Zeile 536
	* @param string The original size.
* @param string The text within a size tag.
* @return string The parsed text.

	* @param string The original size.
* @param string The text within a size tag.
* @return string The parsed text.

	*/

	*/

	function mycode_handle_size($size, $text)
{
$size = intval($size)+10;

	function mycode_handle_size($size, $text)
{
$size = intval($size)+10;





		if($size > 50)
{
$size = 50;
}

		if($size > 50)
{
$size = 50;
}





		$text = "<span style=\"font-size: {$size}pt;\">".str_replace("\'", "'", $text)."</span>";

		$text = "<span style=\"font-size: {$size}pt;\">".str_replace("\'", "'", $text)."</span>";





		return $text;

		return $text;

	}

/**

	}

/**

	* Parses quote MyCode.
*
* @param string The message to be parsed

	* Parses quote MyCode.
*
* @param string The message to be parsed

Zeile 551Zeile 566
		$pattern = array(
"#\[quote=(?:&quot;|\"|')?(.*?)[\"']?(?:&quot;|\"|')?\](.*?)\[\/quote\](\r\n?|\n?)#esi",
"#\[quote\](.*?)\[\/quote\](\r\n?|\n?)#si"

		$pattern = array(
"#\[quote=(?:&quot;|\"|')?(.*?)[\"']?(?:&quot;|\"|')?\](.*?)\[\/quote\](\r\n?|\n?)#esi",
"#\[quote\](.*?)\[\/quote\](\r\n?|\n?)#si"

		);

		);


if($text_only == false)


if($text_only == false)

		{

		{

			$replace = array(
"\$this->mycode_parse_post_quotes('$2','$1')",
"<blockquote><cite>$lang->quote</cite>$1</blockquote>\n"

			$replace = array(
"\$this->mycode_parse_post_quotes('$2','$1')",
"<blockquote><cite>$lang->quote</cite>$1</blockquote>\n"

			);
}

			);
}

		else
{
$replace = array(
"\$this->mycode_parse_post_quotes('$2', '$1', true)",
"\n{$lang->quote}\n--\n$1\n--\n"

		else
{
$replace = array(
"\$this->mycode_parse_post_quotes('$2', '$1', true)",
"\n{$lang->quote}\n--\n$1\n--\n"

			);
}

			);
}


while(preg_match($pattern[0], $message) || preg_match($pattern[1], $message))
{


while(preg_match($pattern[0], $message) || preg_match($pattern[1], $message))
{

Zeile 639Zeile 654
				$postdate = my_date($mybb->settings['dateformat'], intval($match[1]));
$posttime = my_date($mybb->settings['timeformat'], intval($match[1]));
$date = " ({$postdate} {$posttime})";

				$postdate = my_date($mybb->settings['dateformat'], intval($match[1]));
$posttime = my_date($mybb->settings['timeformat'], intval($match[1]));
$date = " ({$postdate} {$posttime})";

			}

			}

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

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

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

		}

		}


if($text_only)
{
return "\n".htmlspecialchars_uni($username)." $lang->wrote{$date}\n--\n{$message}\n--\n";


if($text_only)
{
return "\n".htmlspecialchars_uni($username)." $lang->wrote{$date}\n--\n{$message}\n--\n";

		}
else

		}
else

		{
$span = "";
if(!$delete_quote)

		{
$span = "";
if(!$delete_quote)

Zeile 667Zeile 682

/**
* Parses code MyCode.


/**
* Parses code MyCode.

	*

	*

	* @param string The message to be parsed
* @param boolean Are we formatting as text?
* @return string The parsed message.

	* @param string The message to be parsed
* @param boolean Are we formatting as text?
* @return string The parsed message.

Zeile 696Zeile 711
		$code = str_replace('\\', '&#92;', $code);
$code = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $code);
$code = str_replace(" ", '&nbsp;&nbsp;', $code);

		$code = str_replace('\\', '&#92;', $code);
$code = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $code);
$code = str_replace(" ", '&nbsp;&nbsp;', $code);





		return "<div class=\"codeblock\">\n<div class=\"title\">".$lang->code."\n</div><div class=\"body\" dir=\"ltr\"><code>".$code."</code></div></div>\n";
}


		return "<div class=\"codeblock\">\n<div class=\"title\">".$lang->code."\n</div><div class=\"body\" dir=\"ltr\"><code>".$code."</code></div></div>\n";
}


Zeile 738Zeile 753
		{
$added_open_tag = true;
$str = "<?php \n".$str;

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

		}


		}


		$added_end_tag = false;
if(!preg_match("#\?>\s*$#si", $str))
{
$added_end_tag = true;
$str = $str." \n?>";

		$added_end_tag = false;
if(!preg_match("#\?>\s*$#si", $str))
{
$added_end_tag = true;
$str = $str." \n?>";

		}

		}


// If the PHP version < 4.2, catch highlight_string() output.
if(version_compare(PHP_VERSION, "4.2.0", "<"))


// If the PHP version < 4.2, catch highlight_string() output.
if(version_compare(PHP_VERSION, "4.2.0", "<"))

Zeile 754Zeile 769
			@highlight_string($str);
$code = ob_get_contents();
ob_end_clean();

			@highlight_string($str);
$code = ob_get_contents();
ob_end_clean();

		}
else
{

		}
else
{

			$code = @highlight_string($str, true);
}


			$code = @highlight_string($str, true);
}


Zeile 786Zeile 801
		$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);

		}

		}


if($added_end_tag)
{


if($added_end_tag)
{

Zeile 801Zeile 816
		$code = str_replace("<code>", "<div dir=\"ltr\"><code>", $code);
$code = str_replace("</code>", "</code></div>", $code);
$code = preg_replace("# *$#", "", $code);

		$code = str_replace("<code>", "<div dir=\"ltr\"><code>", $code);
$code = str_replace("</code>", "</code></div>", $code);
$code = preg_replace("# *$#", "", $code);





		if($bare_return)
{
return $code;

		if($bare_return)
{
return $code;

Zeile 874Zeile 889
		if($align == "right")
{
$css_align = " style=\"float: right;\"";

		if($align == "right")
{
$css_align = " style=\"float: right;\"";

		}

		}

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

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

Zeile 888Zeile 903
		if($dimensions[0] > 0 && $dimensions[1] > 0)
{
return "<img src=\"{$url}\" width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\" border=\"0\" alt=\"{$alt}\"{$css_align} />";

		if($dimensions[0] > 0 && $dimensions[1] > 0)
{
return "<img src=\"{$url}\" width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\" border=\"0\" alt=\"{$alt}\"{$css_align} />";

		}
else

		}
else

		{
return "<img src=\"{$url}\" border=\"0\" alt=\"{$alt}\"{$css_align} />";
}

		{
return "<img src=\"{$url}\" border=\"0\" alt=\"{$alt}\"{$css_align} />";
}

Zeile 917Zeile 932
		else
{
return $email;

		else
{
return $email;

		}
}

		}
}


/**
* Parses URLs automatically.


/**
* Parses URLs automatically.

Zeile 932Zeile 947
	    if(!isset($utf8_pcre_supported))
{
$utf8_pcre_supported = @preg_match('#^.#u', 'a');

	    if(!isset($utf8_pcre_supported))
{
$utf8_pcre_supported = @preg_match('#^.#u', 'a');

	    }


	    }


	    if($utf8_pcre_supported)

	    if($utf8_pcre_supported)

	    {

	    {

	        $utf8_regex_chr = "u";

	        $utf8_regex_chr = "u";

	    }

	    }

	    else
{
$utf8_regex_chr = "";

	    else
{
$utf8_regex_chr = "";

Zeile 947Zeile 962
	    $message = preg_replace("#([\>\s\(\)])(https?|ftp|news){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i".$utf8_regex_chr, "$1[url]$2://$3[/url]", $message);
$message = preg_replace("#([\>\s\(\)])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i".$utf8_regex_chr, "$1[url]$2.$3[/url]", $message);
$message = my_substr($message, 1);

	    $message = preg_replace("#([\>\s\(\)])(https?|ftp|news){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i".$utf8_regex_chr, "$1[url]$2://$3[/url]", $message);
$message = preg_replace("#([\>\s\(\)])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i".$utf8_regex_chr, "$1[url]$2.$3[/url]", $message);
$message = my_substr($message, 1);

		return $message;
}

		return $message;
}


/**
* Parses list MyCode.


/**
* Parses list MyCode.

Zeile 992Zeile 1007
		{
$message = str_replace($this->smilies_cache, array_keys($this->smilies_cache), $message);
}

		{
$message = str_replace($this->smilies_cache, array_keys($this->smilies_cache), $message);
}

 
		return $message;
}

/**
* Highlights a string
*
* @param string The message to be highligted
* @param string The highlight keywords
* @return string The message with highlight bbcodes
*/
function highlight_message($message, $highlight)
{
if(empty($this->highlight_cache))
{
$this->highlight_cache = build_highlight_array($highlight);
}

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;
}