Vergleich inc/class_parser.php - 1.4.4 - 1.4.11

  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 4052 2008-07-29 15:45: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 78Zeile 87
			if(my_substr($this->base_url, my_strlen($this->base_url) -1) != "/")
{
$this->base_url = $this->base_url."/";

			if(my_substr($this->base_url, my_strlen($this->base_url) -1) != "/")
{
$this->base_url = $this->base_url."/";

			}
}


			}
}


		// Set the options		
$this->options = $options;


		// Set the options		
$this->options = $options;


Zeile 93Zeile 102
		if($options['filter_badwords'])
{
$message = $this->parse_badwords($message);

		if($options['filter_badwords'])
{
$message = $this->parse_badwords($message);

		}


		}


		if($options['allow_html'] != 1)
{
$message = $this->parse_html($message);

		if($options['allow_html'] != 1)
{
$message = $this->parse_html($message);

Zeile 135Zeile 144
		if($options['allow_smilies'])
{
$message = $this->parse_smilies($message, $options['allow_html']);

		if($options['allow_smilies'])
{
$message = $this->parse_smilies($message, $options['allow_html']);

		}


		}


		// Replace MyCode if requested.
if($options['allow_mycode'])

		// Replace MyCode if requested.
if($options['allow_mycode'])

		{

		{

			$message = $this->parse_mycode($message, $options);

			$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 164Zeile 179
						$code = $this->mycode_parse_code($text[2]);
}
elseif(my_strtolower($text[1]) == "php")

						$code = $this->mycode_parse_code($text[2]);
}
elseif(my_strtolower($text[1]) == "php")

					{

					{

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

Zeile 219Zeile 234

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


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





		$standard_mycode['s']['regex'] = "#\[s\](.*?)\[/s\]#si";
$standard_mycode['s']['replacement'] = "<del>$1</del>";

		$standard_mycode['s']['regex'] = "#\[s\](.*?)\[/s\]#si";
$standard_mycode['s']['replacement'] = "<del>$1</del>";





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

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





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

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

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

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


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


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

		$standard_mycode['url_simple']['replacement'] = "\$this->mycode_parse_url(\"$1$2\")";

		$standard_mycode['url_simple']['replacement'] = "\$this->mycode_parse_url(\"$1$2\")";


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


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

		$standard_mycode['url_simple2']['replacement'] = "\$this->mycode_parse_url(\"$1\")";


		$standard_mycode['url_simple2']['replacement'] = "\$this->mycode_parse_url(\"$1\")";


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

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

		$standard_mycode['url_complex']['replacement'] = "\$this->mycode_parse_url(\"$1$2\", \"$3\")";


		$standard_mycode['url_complex']['replacement'] = "\$this->mycode_parse_url(\"$1$2\", \"$3\")";


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

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

		$standard_mycode['url_complex2']['replacement'] = "\$this->mycode_parse_url(\"$1\", \"$2\")";

$standard_mycode['email_simple']['regex'] = "#\[email\](.*?)\[/email\]#ei";

		$standard_mycode['url_complex2']['replacement'] = "\$this->mycode_parse_url(\"$1\", \"$2\")";

$standard_mycode['email_simple']['regex'] = "#\[email\](.*?)\[/email\]#ei";

Zeile 279Zeile 294
				$custom_mycode[$key]['regex'] = "#".$mycode['regex']."#si";
}
$mycode = array_merge($standard_mycode, $custom_mycode);

				$custom_mycode[$key]['regex'] = "#".$mycode['regex']."#si";
}
$mycode = array_merge($standard_mycode, $custom_mycode);

		}
else

		}
else

		{
$mycode = $standard_mycode;

		{
$mycode = $standard_mycode;

		}


		}


		// Assign the MyCode to the cache.
foreach($mycode as $code)
{

		// Assign the MyCode to the cache.
foreach($mycode as $code)
{

Zeile 295Zeile 310

/**
* Parses MyCode tags in a specific message with the specified options.


/**
* Parses MyCode tags in a specific message with the specified options.

	 *

	 *

	 * @param string The message to be parsed.
* @param array Array of options in yes/no format. Options are allow_imgcode.
* @return string The parsed message.

	 * @param string The message to be parsed.
* @param array Array of options in yes/no format. Options are allow_imgcode.
* @return string The parsed message.

Zeile 308Zeile 323
		if($this->mycode_cache == 0)
{
$this->cache_mycode();

		if($this->mycode_cache == 0)
{
$this->cache_mycode();

		}


		}


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


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


Zeile 392Zeile 407
		{
foreach($this->smilies_cache as $find => $replace)
{

		{
foreach($this->smilies_cache as $find => $replace)
{

				$find = $this->parse_html($find);

				$find = $this->parse_html($find);				

				$find = preg_quote($find, "#");

				$find = preg_quote($find, "#");

				

				

				if(version_compare(PHP_VERSION, "5.1.0", ">="))
{

				if(version_compare(PHP_VERSION, "5.1.0", ">="))
{

 
					$orig_message = $message;
$orig_find = $find;

					// Fix issues for smileys starting with a ";"
if($find{0} == ";")

					// Fix issues for smileys starting with a ";"
if($find{0} == ";")

					{

					{

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

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

					}



					}

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

				

				

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


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

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

Zeile 415Zeile 438
					$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);

		}

// If we matched any tags previously, swap them back in
if(count($bad_matches[0]) > 0)
{
foreach($bad_matches[0] as $match)

		}

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

				$message = preg_replace("#<mybb-bad-sm>#", $match, $message, 1);
}
}

Zeile 446Zeile 470
	 *
* @param string The message to be parsed.
* @param array Array of parser options in yes/no format.

	 *
* @param string The message to be parsed.
* @param array Array of parser options in yes/no format.

	 * @return string The parsed message.
*/

	 * @return string The parsed message.
*/

	function parse_badwords($message, $options=array())
{
if($this->badwords_cache == 0)

	function parse_badwords($message, $options=array())
{
if($this->badwords_cache == 0)

Zeile 500Zeile 524
			"#(o)(nunload\s?=)#i",
"#(o)(nkeypress\s?=)#i"
);

			"#(o)(nunload\s?=)#i",
"#(o)(nkeypress\s?=)#i"
);

		$message = preg_replace($js_array, "$1<strong></strong>$2", $message);


		
$message = preg_replace($js_array, "$1<strong></strong>$2$4", $message);


return $message;
}


return $message;
}

Zeile 818Zeile 843

$url = str_replace('&amp;', '&', $url);
$name = str_replace('&amp;', '&', $name);


$url = str_replace('&amp;', '&', $url);
$name = str_replace('&amp;', '&', $name);

 



if(!preg_match("#[a-z0-9]+://#i", $fullurl))
{
$fullurl = "http://".$fullurl;
}
if(!$name)


if(!preg_match("#[a-z0-9]+://#i", $fullurl))
{
$fullurl = "http://".$fullurl;
}
if(!$name)

		{

		{

			$name = $url;

			$name = $url;

		}


		}


		$name = str_replace("\'", "'", $name);
$url = str_replace("\'", "'", $url);
$fullurl = str_replace("\'", "'", $fullurl);

		$name = str_replace("\'", "'", $name);
$url = str_replace("\'", "'", $url);
$fullurl = str_replace("\'", "'", $fullurl);

Zeile 839Zeile 865
				$name = my_substr($url, 0, 40)."...".my_substr($url, -10);
}
}

				$name = my_substr($url, 0, 40)."...".my_substr($url, -10);
}
}






		
// fix some entities in URLs
$fullurl = strtr($fullurl, array('$' => '%24', '^' => '%5E', '`' => '%60', '[' => '%5B', ']' => '%5D', '{' => '%7B', '}' => '%7D', '"' => '%22', '<' => '%3C', '>' => '%3E', ' ' => '%20'));


		$name = preg_replace("#&amp;\#([0-9]+);#si", "&#$1;", $name); // Fix & but allow unicode
$link = "<a href=\"$fullurl\" target=\"_blank\">$name</a>";
return $link;

		$name = preg_replace("#&amp;\#([0-9]+);#si", "&#$1;", $name); // Fix & but allow unicode
$link = "<a href=\"$fullurl\" target=\"_blank\">$name</a>";
return $link;

	}

/**

	}

/**

	 * Parses IMG MyCode.
*
* @param string The URL to the image

	 * Parses IMG MyCode.
*
* @param string The URL to the image

Zeile 887Zeile 916
	* @param string The email address to link to.
* @param string The name for the link.
* @return string The built-up email link.

	* @param string The email address to link to.
* @param string The name for the link.
* @return string The built-up email link.

	*/

	*/

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

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

 
		$name = str_replace("\\'", "'", $name);
$email = str_replace("\\'", "'", $email);

		if(!$name)

		if(!$name)

		{

		{

			$name = $email;

			$name = $email;

		}

		}

		if(preg_match("/^([a-zA-Z0-9-_\+\.]+?)@[a-zA-Z0-9-]+\.[a-zA-Z0-9\.-]+$/si", $email))
{
return "<a href=\"mailto:$email\">".$name."</a>";

		if(preg_match("/^([a-zA-Z0-9-_\+\.]+?)@[a-zA-Z0-9-]+\.[a-zA-Z0-9\.-]+$/si", $email))
{
return "<a href=\"mailto:$email\">".$name."</a>";

Zeile 901Zeile 932
		else
{
return $email;

		else
{
return $email;

		}
}


		}
}


	/**
* Parses URLs automatically.
*

	/**
* Parses URLs automatically.
*

Zeile 912Zeile 943
	*/
function mycode_auto_url($message)
{

	*/
function mycode_auto_url($message)
{

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
















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

if($utf8_pcre_supported)
{
$utf8_regex_chr = "u";
}
else
{
$utf8_regex_chr = "";
}

$message = " ".$message;
$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 = my_substr($message, 1);

		return $message;
}


		return $message;
}


	/**
* Parses list MyCode.
*

	/**
* Parses list MyCode.
*

Zeile 932Zeile 978
		$message = str_replace('\"', '"', $message);
$message = preg_replace("#\s*\[\*\]\s*#", "</li>\n<li>", $message);
$message .= "</li>";

		$message = str_replace('\"', '"', $message);
$message = preg_replace("#\s*\[\*\]\s*#", "</li>\n<li>", $message);
$message .= "</li>";





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

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

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