Vergleich inc/class_parser.php - 1.8.17 - 1.8.18

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 141Zeile 141
		}

// If MyCode needs to be replaced, first filter out [code] and [php] tags.

		}

// If MyCode needs to be replaced, first filter out [code] and [php] tags.

 
		$code_matches = array();

		if(!empty($this->options['allow_mycode']) && $mybb->settings['allowcodemycode'] == 1)
{
// This code is reserved and could break codes

		if(!empty($this->options['allow_mycode']) && $mybb->settings['allowcodemycode'] == 1)
{
// This code is reserved and could break codes

Zeile 650Zeile 651
					$badword['replacement'] = "*****";
}


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


				if($badword['regex'])

				if(!$badword['regex'])

				{

				{

					$message = preg_replace('#'.$badword['badword'].'#is', $badword['replacement'], $message);

					$badword['badword'] = $this->generate_regex($badword['badword']);

				}

				}

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








































				$message = preg_replace('#'.$badword['badword'].'#is', $badword['replacement'], $message);
}
}
if(!empty($this->options['strip_tags']))
{
$message = strip_tags($message);
}
return $message;
}

/**
* Generates REGEX patterns based on user defined badword string.
*
* @param string $badword The word defined to replace.
* @return string The regex pattern to match the word or null on error.
*/
function generate_regex($bad_word = "")
{
if($bad_word == "")
{
return;
}

// Neutralize multiple adjacent wildcards and generate pattern
$ptrn = array('/\*\++/', '/\++\*/', '/\*+/');
$rplc = array('*', '*', '[^\s\n]*');
$bad_word = preg_replace($ptrn, $rplc, $bad_word);

// Count + and generate pattern
$bad_word = explode('+', $bad_word);
$trap = "";
$plus = 0;
foreach($bad_word as $bad_piece)
{
if($bad_piece)
{
$trap .= $plus ? '[^\s\n]{'.$plus.'}'.$bad_piece : $bad_piece;
$plus = 1;
}
else
{
$plus++;

			}

			}

		}
if(!empty($this->options['strip_tags']))



		}

// Handle trailing +
if($plus > 1)

		{

		{

			$message = strip_tags($message);

			$trap .= '[^\s\n]{'.($plus-1).'}';

		}

		}

		return $message;


		
return '\b'.$trap.'\b';

	}

/**

	}

/**

Zeile 765Zeile 804
		}
else
{

		}
else
{

			$replace = "\n{$lang->quote}\n--\n$1\n--\n";

			$replace = empty($this->options['signature_parse']) ? "\n{$lang->quote}\n--\n$1\n--\n" : "$1";

			$replace_callback = array($this, 'mycode_parse_post_quotes_callback2');
}


			$replace_callback = array($this, 'mycode_parse_post_quotes_callback2');
}


Zeile 923Zeile 962

if($text_only == true)
{


if($text_only == true)
{

			return "\n{$lang->code}\n--\n{$code}\n--\n";

			return empty($this->options['signature_parse']) ? "\n{$lang->code}\n--\n{$code}\n--\n" : $code;

		}

// Clean the string before parsing.

		}

// Clean the string before parsing.

Zeile 971Zeile 1010

if($text_only == true)
{


if($text_only == true)
{

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

			return empty($this->options['signature_parse']) ? "\n{$lang->php_code}\n--\n{$str}\n--\n" : $str;

		}

// Clean the string before parsing except tab spaces.

		}

// Clean the string before parsing except tab spaces.

Zeile 1063Zeile 1102
			$url = "http://".$url;
}


			$url = "http://".$url;
}


		if(!empty($this->options['allow_html']))
{
$url = $this->parse_html($url);
}


		if(!empty($this->options['allow_html']))
{
$url = $this->parse_html($url);
}


		if(!$name)
{
$name = $url;

		if(!$name)
{
$name = $url;

		}


		}


		if($name == $url && (!isset($this->options['shorten_urls']) || !empty($this->options['shorten_urls'])))
{
$name = htmlspecialchars_decode($name);

		if($name == $url && (!isset($this->options['shorten_urls']) || !empty($this->options['shorten_urls'])))
{
$name = htmlspecialchars_decode($name);

Zeile 1084Zeile 1123
		}

if(!empty($this->options['nofollow_on']))

		}

if(!empty($this->options['nofollow_on']))

		{

		{

			$rel = " rel=\"noopener nofollow\"";
}
else
{
$rel = " rel=\"noopener\"";
}

			$rel = " rel=\"noopener nofollow\"";
}
else
{
$rel = " rel=\"noopener\"";
}





		// Fix some entities in URLs
$url = $this->encode_url($url);

		// Fix some entities in URLs
$url = $this->encode_url($url);



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



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


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


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

	}


	}


	/**
* Parses URL MyCode.
*

	/**
* Parses URL MyCode.
*

Zeile 1115Zeile 1154
			$matches[3] = '';
}
return $this->mycode_parse_url($matches[1].$matches[2], $matches[3]);

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

	}

/**

	}

/**

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

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

Zeile 1130Zeile 1169
			$matches[2] = '';
}
return $this->mycode_parse_url($matches[1], $matches[2]);

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

	}

/**
* Parses IMG MyCode.
*

	}

/**
* Parses IMG MyCode.
*

	 * @param string $url The URL to the image
* @param array $dimensions Optional array of dimensions
* @param string $align

	 * @param string $url The URL to the image
* @param array $dimensions Optional array of dimensions
* @param string $align

Zeile 1150Zeile 1189
		if(!empty($this->options['allow_html']))
{
$url = $this->parse_html($url);

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

		}


		}


		$css_align = '';
if($align == "right")
{

		$css_align = '';
if($align == "right")
{

Zeile 1173Zeile 1212
		{
$alt = my_substr($alt, 0, 40).'...'.my_substr($alt, -10);
}

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

		$alt = htmlspecialchars_uni($alt);

		$alt = $this->encode_url($alt);


$alt = $lang->sprintf($lang->posted_image, $alt);
$width = $height = '';


$alt = $lang->sprintf($lang->posted_image, $alt);
$width = $height = '';

Zeile 1198Zeile 1237
	function mycode_parse_img_callback1($matches)
{
return $this->mycode_parse_img($matches[2]);

	function mycode_parse_img_callback1($matches)
{
return $this->mycode_parse_img($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_callback2($matches)
{

	 */
function mycode_parse_img_callback2($matches)
{

Zeile 1218Zeile 1257
	 * @return string Image code.
*/
function mycode_parse_img_callback3($matches)

	 * @return string Image code.
*/
function mycode_parse_img_callback3($matches)

	{

	{

		return $this->mycode_parse_img($matches[3], array(), $matches[1]);

		return $this->mycode_parse_img($matches[3], array(), $matches[1]);

	}

/**

	}

/**

	 * Parses IMG MyCode.

	 * Parses IMG MyCode.

	 *

	 *

	 * @param array $matches 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]);

	 * @param array $matches 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]);

	}

/**
* Parses IMG MyCode disabled.
*

	}

/**
* Parses IMG MyCode disabled.
*

	 * @param string $url The URL to the image
* @return string
*/

	 * @param string $url The URL to the image
* @return string
*/

Zeile 1249Zeile 1288

$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.
* @return string Image code.

	}

/**
* Parses IMG MyCode disabled.
*
* @param array $matches Matches.
* @return string Image code.

	 */
function mycode_parse_img_disabled_callback1($matches)
{

	 */
function mycode_parse_img_disabled_callback1($matches)
{

Zeile 1269Zeile 1308
	 * @return string Image code.
*/
function mycode_parse_img_disabled_callback2($matches)

	 * @return string Image code.
*/
function mycode_parse_img_disabled_callback2($matches)

	{

	{

		return $this->mycode_parse_img_disabled($matches[4]);
}


		return $this->mycode_parse_img_disabled($matches[4]);
}


Zeile 1303Zeile 1342
	* @return string The built-up email link.
*/
function mycode_parse_email($email, $name="")

	* @return string The built-up email link.
*/
function mycode_parse_email($email, $name="")

	{

	{

		global $templates;

if(!$name)

		global $templates;

if(!$name)

Zeile 1336Zeile 1375
			$matches[2] = '';
}
return $this->mycode_parse_email($matches[1], $matches[2]);

			$matches[2] = '';
}
return $this->mycode_parse_email($matches[1], $matches[2]);

	}

	}


/**
* Parses video MyCode.


/**
* Parses video MyCode.

Zeile 1350Zeile 1389
		global $templates;

if(empty($video) || empty($url))

		global $templates;

if(empty($video) || empty($url))

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

		// Check URL is a valid URL first, as `parse_url` doesn't check validity.
if(false === filter_var($url, FILTER_VALIDATE_URL))
{

Zeile 1364Zeile 1403
		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'])

		{

		{

			$fragments = explode("&", $parsed_url['fragment']);

			$fragments = explode("&", $parsed_url['fragment']);

 
		}

if($video == "liveleak")
{
// The query part can start with any alphabet, but set only 'i' to catch in index key later
$parsed_url['query'] = "i".substr($parsed_url['query'], 1);

		}

$queries = explode("&", $parsed_url['query']);

		}

$queries = explode("&", $parsed_url['query']);

Zeile 1417Zeile 1462
					$id = $path[3]; // https://www.facebook.com/fds/videos/123/
}
break;

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

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

			case "mixer":
$id = $path[1]; // https://mixer.com/streamer

				break;
case "liveleak":
$id = $input['i']; // http://www.liveleak.com/view?i=123

				break;
case "liveleak":
$id = $input['i']; // http://www.liveleak.com/view?i=123

Zeile 1495Zeile 1540

$id = htmlspecialchars_uni($id);



$id = htmlspecialchars_uni($id);


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

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

		return $video_code;
}


		return $video_code;
}


Zeile 1564Zeile 1609
	* @param array $matches Matches
* @return string The parsed message.
*/

	* @param array $matches Matches
* @return string The parsed message.
*/

	function mycode_auto_url_callback($matches)

	function mycode_auto_url_callback($matches=array())

	{
// 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 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.

Zeile 1606Zeile 1651
		}

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

		}

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

	}

/**
* Parses list MyCode.
*

	}

/**
* Parses list MyCode.
*

	* @param string $message The message to be parsed
* @param string $type The list type
* @return string The parsed message.

	* @param string $message The message to be parsed
* @param string $type The list type
* @return string The parsed message.

Zeile 1619Zeile 1664
	{
// No list elements? That's invalid HTML
if(strpos($message, '[*]') === false)

	{
// No list elements? That's invalid HTML
if(strpos($message, '[*]') === false)

		{

		{

			$message = "[*]{$message}";
}


			$message = "[*]{$message}";
}


Zeile 1627Zeile 1672
		if(isset($message[0]) && trim($message[0]) == '')
{
array_shift($message);

		if(isset($message[0]) && trim($message[0]) == '')
{
array_shift($message);

		}

		}

		$message = '<li>'.implode("</li>\n<li>", $message)."</li>\n";

if($type)

		$message = '<li>'.implode("</li>\n<li>", $message)."</li>\n";

if($type)

Zeile 1644Zeile 1689

/**
* Parses list MyCode.


/**
* Parses list MyCode.

	*

	*

	* @param array $matches Matches
* @return string The parsed message.
*/

	* @param array $matches Matches
* @return string The parsed message.
*/

Zeile 1711Zeile 1756

/**
* Highlights a string


/**
* Highlights a string

	 *

	 *

	 * @param string $message The message to be highligted
* @param string $highlight The highlight keywords
* @return string The message with highlight bbcodes

	 * @param string $message The message to be highligted
* @param string $highlight The highlight keywords
* @return string The message with highlight bbcodes

Zeile 1745Zeile 1790
		if(empty($this->options))
{
$this->options = $options;

		if(empty($this->options))
{
$this->options = $options;

 
		}
else
{
foreach($options as $option_name => $option_value)
{
$this->options[$option_name] = $option_value;
}

		}

// Filter bad words if requested.

		}

// Filter bad words if requested.