Vergleich inc/class_parser.php - 1.2.0 - 1.2.1

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html
*

 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html
*

 * $Id: class_parser.php 2190 2006-09-02 21:33:01Z Tikitiki $

 * $Id: class_parser.php 2271 2006-09-27 02:45:07Z Tikitiki $

 */

/*

 */

/*

Zeile 75Zeile 75

if($this->base_url != "")
{


if($this->base_url != "")
{

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

			if(my_substr($this->base_url, strlen($this->base_url) -1) != "/")

			{
$this->base_url = $this->base_url."/";
}

			{
$this->base_url = $this->base_url."/";
}

Zeile 86Zeile 86

// Get rid of cartridge returns for they are the workings of the devil
$message = str_replace("\r", "", $message);


// Get rid of cartridge returns for they are the workings of the devil
$message = str_replace("\r", "", $message);

 
		$message = $this->strip_rtl($message);


		
// Filter bad words if requested.
if($options['filter_badwords'] != "no")

		
// Filter bad words if requested.
if($options['filter_badwords'] != "no")

		{

		{

			$message = $this->parse_badwords($message);

			$message = $this->parse_badwords($message);

		}

		}





 
		if($options['allow_html'] != "yes")
{
$message = $this->parse_html($message);
}
else
{
// Strip out any script tags if HTML is enabled
if($options['allow_html'] == "yes")
{
while(preg_match("#<script(.*)>(.*)</script(.*)>#is", $message))
{
$message = preg_replace("#<script(.*)>(.*)</script(.*)>#is", "&lt;script$1&gt;$2&lt;/script$3&gt;", $message);
}
$message = preg_replace("#<base(.*)>#is", "&lt;base$1&gt;", $message);
$message = preg_replace("#<meta(.*)>#is", "&lt;meta$1&gt;", $message);
}
}


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

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

Zeile 101Zeile 121
			$message = preg_replace("#\[(code|php)\](.*?)\[/\\1\](\r\n?|\n?)#si", "{{mybb-code}}\n", $message);
}


			$message = preg_replace("#\[(code|php)\](.*?)\[/\\1\](\r\n?|\n?)#si", "{{mybb-code}}\n", $message);
}


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


		// Always fix bad Javascript in the message.
$message = $this->fix_javascript($message);




		// If we can, parse smiliesa
if($options['allow_smilies'] != "no")
{

		// If we can, parse smiliesa
if($options['allow_smilies'] != "no")
{

Zeile 118Zeile 136
			$message = $this->parse_mycode($message, $options);
}


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


		// Strip out any script tags if HTML is enabled
if($options['allow_html'] == "yes")
{
while(preg_match("#<script(.*)>(.*)</script(.*)>#is", $message))
{
$message = preg_replace("#<script(.*)>(.*)</script(.*)>#is", "&lt;script$1&gt;$2&lt;/script$3&gt;", $message);
}
$message = preg_replace("#<base(.*)>#is", "&lt;base$1&gt", $message);
$message = preg_replace("#<meta(.*)>#is", "&lt;meta$1&gt", $message);
}

 
		// Run plugin hooks
$message = $plugins->run_hooks("parse_message", $message);

if($options['allow_mycode'] != "no")

		// Run plugin hooks
$message = $plugins->run_hooks("parse_message", $message);

if($options['allow_mycode'] != "no")

		{

		{

			// Now that we're done, if we split up any code tags, parse them and glue it all back together
if(count($code_matches) > 0)
{
foreach($code_matches as $text)
{
// Fix up HTML inside the code tags so it is clean

			// Now that we're done, if we split up any code tags, parse them and glue it all back together
if(count($code_matches) > 0)
{
foreach($code_matches as $text)
{
// Fix up HTML inside the code tags so it is clean

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




					if($options['allow_html'] != "no")
{
$text[2] = $this->parse_html($text[2]);
}

					
if(strtolower($text[1]) == "code")
{

					
if(strtolower($text[1]) == "code")
{

Zeile 152Zeile 163
					$message = preg_replace("#\{\{mybb-code\}\}\n?#", $code, $message, 1);
}
}

					$message = preg_replace("#\{\{mybb-code\}\}\n?#", $code, $message, 1);
}
}

		}

		}


if($options['nl2br'] != "no")
{
$message = nl2br($message);
$message = str_replace("</div><br />", "</div>", $message);


if($options['nl2br'] != "no")
{
$message = nl2br($message);
$message = str_replace("</div><br />", "</div>", $message);

 
			$message = preg_replace("#<(/?)p>\s*(<br />?)#", "<$1p>", $message);

		}

		}

		// Always fix bad Javascript in the message.
$message = $this->fix_javascript($message);


	



		$message = my_wordwrap($message);

$message = str_replace(" ", "&nbsp;&nbsp;", $message);

$message = $plugins->run_hooks("parse_message_end", $message);


		$message = my_wordwrap($message);

$message = str_replace(" ", "&nbsp;&nbsp;", $message);

$message = $plugins->run_hooks("parse_message_end", $message);


		return $message;
}

/**

		return $message;
}

/**

	 * Converts HTML in a message to their specific entities whilst allowing unicode characters.
*
* @param string The message to be parsed.

	 * Converts HTML in a message to their specific entities whilst allowing unicode characters.
*
* @param string The message to be parsed.

Zeile 317Zeile 327
		if($options['allow_imgcode'] != "no")
{
$message = preg_replace("#\[img\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#ise", "\$this->mycode_parse_img('$2')\n", $message);

		if($options['allow_imgcode'] != "no")
{
$message = preg_replace("#\[img\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#ise", "\$this->mycode_parse_img('$2')\n", $message);

			$message = preg_replace("#\[img=([0-9]{1,3})x([0-9]{1,3})\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#ise", "\$this->mycode_parse_img('$4', array('$2', '$3'));", $message);

			$message = preg_replace("#\[img=([0-9]{1,3})x([0-9]{1,3})\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#ise", "\$this->mycode_parse_img('$4', array('$1', '$2'));", $message);

		}

// Replace "me" code and slaps if we have a username

		}

// Replace "me" code and slaps if we have a username

Zeile 341Zeile 351
		$this->smilies_cache = array();

$smilies = $cache->read("smilies");

		$this->smilies_cache = array();

$smilies = $cache->read("smilies");

		foreach($smilies as $sid => $smilie)

		if(is_array($smilies))

		{

		{

			$this->smilies_cache[$smilie['find']] = "<img src=\"{$this->base_url}{$smilie['image']}\" style=\"vertical-align: middle;\" border=\"0\" alt=\"{$smilie['name']}\" title=\"{$smilie['name']}\" />";




			foreach($smilies as $sid => $smilie)
{
$this->smilies_cache[$smilie['find']] = "<img src=\"{$this->base_url}{$smilie['image']}\" style=\"vertical-align: middle;\" border=\"0\" alt=\"{$smilie['name']}\" title=\"{$smilie['name']}\" />";
}

		}
}


		}
}


Zeile 358Zeile 371
	function parse_smilies($message, $allow_html="no")
{
if($this->smilies_cache == 0)

	function parse_smilies($message, $allow_html="no")
{
if($this->smilies_cache == 0)

		{

		{

			$this->cache_smilies();
}
if(is_array($this->smilies_cache))

			$this->cache_smilies();
}
if(is_array($this->smilies_cache))

Zeile 380Zeile 393
	 * Generates a cache of badwords filters.
*
* @access private

	 * Generates a cache of badwords filters.
*
* @access private

	 */

	 */

	function cache_badwords()
{
global $cache;

	function cache_badwords()
{
global $cache;

Zeile 402Zeile 415
			$this->cache_badwords();
}
if(is_array($this->badwords_cache))

			$this->cache_badwords();
}
if(is_array($this->badwords_cache))

		{

		{

			reset($this->badwords_cache);
foreach($this->badwords_cache as $bid => $badword)
{

			reset($this->badwords_cache);
foreach($this->badwords_cache as $bid => $badword)
{

Zeile 412Zeile 425
			}
}
if($options['strip_tags'] == "yes")

			}
}
if($options['strip_tags'] == "yes")

		{

		{

			$message = strip_tags($message);
}
return $message;

			$message = strip_tags($message);
}
return $message;

Zeile 444Zeile 457
			"#(o)(nselect)#i",
"#(o)(nunload)#i",
"#(o)(nkeypress)#i"

			"#(o)(nselect)#i",
"#(o)(nunload)#i",
"#(o)(nkeypress)#i"

			);

		);

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

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

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


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


		$replace = array("<div class=\"quote_header\">".htmlentities('\\1')." $lang->wrote\n</div><div class=\"quote_body\">$2</div>\n",
"<div class=\"quote_header\">$lang->quote\n</div><div class=\"quote_body\">$1</div>\n");

		$replace = array("</p>\n<div class=\"quote_header\">".htmlentities('\\1')." $lang->wrote\n</div><div class=\"quote_body\">$2</div>\n<p>\n",
"</p>\n<div class=\"quote_header\">$lang->quote\n</div><div class=\"quote_body\">$1</div>\n<p>\n");


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


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

Zeile 480Zeile 493
			"</div>"
);
$message = preg_replace($find, $replace, $message);

			"</div>"
);
$message = preg_replace($find, $replace, $message);

		return $message;

		return $message;


}



}


Zeile 494Zeile 507
	{
global $lang;
$code = trim($code);

	{
global $lang;
$code = trim($code);

		return "<div class=\"code_header\">".$lang->code."\n</div><div class=\"code_body\"><div dir=\"ltr\"><code>".$code."</code></div></div>\n";


		$code = preg_replace('#\$([0-9])#', '\\\$\\1', $code);
return "</p>\n<div class=\"code_header\">".$lang->code."\n</div><div class=\"code_body\"><div dir=\"ltr\"><code>".$code."</code></div></div>\n<p>\n";

	}

/**

	}

/**

Zeile 563Zeile 577

if($added_open_close == true)
{


if($added_open_close == true)
{

			$code = preg_replace("#<code><span style=\"color: \#0000BB\">&lt;\?php( |&nbsp;)(<br />?)#", "<code><span style=\"color: #0000BB\">", $code);

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

			$code = str_replace("?&gt;</span></code>", "</span></code>", $code);
}


			$code = str_replace("?&gt;</span></code>", "</span></code>", $code);
}


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

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

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

		$code = preg_replace("#\s*$#", "", $code);


		$code = preg_replace("# *$#", "", $code);
$code = preg_replace('#\$([0-9])#', '\\\$\\1', $code);


// Send back the code all nice and pretty


// Send back the code all nice and pretty

		return "<div class=\"code_header\">$lang->php_code\n</div><div class=\"code_body\">".$code."</div>\n";

		return "</p>\n<div class=\"code_header\">$lang->php_code\n</div><div class=\"code_body\">".$code."</div>\n<p>\n";

	}

/**

	}

/**

Zeile 606Zeile 622
		$fullurl = stripslashes($fullurl);
if($name == $url && $this->options['shorten_urls'] != "no")
{

		$fullurl = stripslashes($fullurl);
if($name == $url && $this->options['shorten_urls'] != "no")
{

			if(my_strlen($url) > 55)

			if(strlen($url) > 55)

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


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


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

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


		$link = "<a href=\"$fullurl\" target=\"_blank\">$name</a>";
return $link;
}

		$link = "<a href=\"$fullurl\" target=\"_blank\">$name</a>";
return $link;
}

Zeile 631Zeile 646
		$url = str_replace("\r", "", $url);
if($dimensions[0] > 0 && $dimensions[1] > 0)
{

		$url = str_replace("\r", "", $url);
if($dimensions[0] > 0 && $dimensions[1] > 0)
{

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

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

		}
else
{

		}
else
{

Zeile 691Zeile 706

if($type)
{


if($type)
{

			$list = "<ol type=\"$type\">$message</ol>";

			$list = "</p>\n<ol type=\"$type\">$message</ol>\n<p>";

		}
else
{

		}
else
{

			$list = "<ul>$message</ul>";

			$list = "</p>\n<ul>$message</ul>\n</p>";

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

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

Zeile 719Zeile 734
		}
return $message;
}

		}
return $message;
}

 
	
/**
* Strip RTL Unicude
*
*/
function strip_rtl($message)
{
//$message = htmlentities($message);
//$message = preg_replace('/[^\x09\x0A\x0D\x20-\x7F]/e', '"&#".ord($0).";"', $message);
//$message = str_replace('&#226;&#128;&#174;', '', $message);
//$message = str_replace('&#8238;', '', $message);
//$message = str_replace('&#x202E', '', $message);
//$message = html_entity_decode($message);
return $message;
}


/**
* Strips MyCode.


/**
* Strips MyCode.