Vergleich inc/class_parser.php - 1.8.27 - 1.8.30

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 119Zeile 119
	 * @access public
* @var self::VALIDATION_*
*/

	 * @access public
* @var self::VALIDATION_*
*/

	public $output_validation_policy = self::VALIDATION_REPORT_ONLY;

	public $output_validation_policy = self::VALIDATION_REQUIRE;


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


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

Zeile 315Zeile 315
		global $cache, $lang, $mybb;
$this->mycode_cache = array();


		global $cache, $lang, $mybb;
$this->mycode_cache = array();


		$standard_mycode = $callback_mycode = $nestable_mycode = array();
$standard_count = $callback_count = $nestable_count = 0;

		$standard_mycode = $callback_mycode = $nestable_mycode = $nestable_callback_mycode = array();
$standard_count = $callback_count = $nestable_count = $nestable_callback_count = 0;


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


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

Zeile 398Zeile 398

++$nestable_count;
++$callback_count;


++$nestable_count;
++$callback_count;

		}

if($mybb->settings['allowfontmycode'] == 1)
{
$callback_mycode['font']['regex'] = "#\[font=\\s*(\"?)([a-z0-9 ,\-_'\"]+)\\1\\s*\](.*?)\[/font\]#si";
$callback_mycode['font']['replacement'] = array($this, 'mycode_parse_font_callback');

++$nestable_count;

 
		}

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

		}

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

Zeile 414Zeile 406
			$nestable_mycode['align']['replacement'] = "<div style=\"text-align: $1;\" class=\"mycode_align\">$2</div>";

++$nestable_count;

			$nestable_mycode['align']['replacement'] = "<div style=\"text-align: $1;\" class=\"mycode_align\">$2</div>";

++$nestable_count;

 
		}

if($mybb->settings['allowfontmycode'] == 1)
{
$nestable_callback_mycode['font']['regex'] = "#\[font=\\s*(\"?)([a-z0-9 ,\-_'\"]+)\\1\\s*\](.*?)\[/font\]#si";
$nestable_callback_mycode['font']['replacement'] = array($this, 'mycode_parse_font_callback');

++$nestable_callback_count;

		}

$custom_mycode = $cache->read("mycode");

		}

$custom_mycode = $cache->read("mycode");

Zeile 427Zeile 427
				$custom_mycode[$key]['regex'] = "#".$mycode['regex']."#si";

++$standard_count;

				$custom_mycode[$key]['regex'] = "#".$mycode['regex']."#si";

++$standard_count;

			}

			}

			$mycode = array_merge($standard_mycode, $custom_mycode);

			$mycode = array_merge($standard_mycode, $custom_mycode);

		}

		}

		else
{
$mycode = $standard_mycode;

		else
{
$mycode = $standard_mycode;

Zeile 440Zeile 440
		{
$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)

		{

		{

			$this->mycode_cache['nestable'][] = array('find' => $code['regex'], 'replacement' => $code['replacement']);
}


			$this->mycode_cache['nestable'][] = array('find' => $code['regex'], 'replacement' => $code['replacement']);
}


		// Assign the nestable MyCode to the cache.

		// Assign the callback MyCode to the cache.

		foreach($callback_mycode as $code)
{
$this->mycode_cache['callback'][] = array('find' => $code['regex'], 'replacement' => $code['replacement']);

		foreach($callback_mycode as $code)
{
$this->mycode_cache['callback'][] = array('find' => $code['regex'], 'replacement' => $code['replacement']);

		}







		}

// Assign the nestable callback MyCode to the cache.
foreach($nestable_callback_mycode as $code)
{
$this->mycode_cache['nestable_callback'][] = array('find' => $code['regex'], 'replacement' => $code['replacement']);
}


$this->mycode_cache['standard_count'] = $standard_count;
$this->mycode_cache['callback_count'] = $callback_count;
$this->mycode_cache['nestable_count'] = $nestable_count;


$this->mycode_cache['standard_count'] = $standard_count;
$this->mycode_cache['callback_count'] = $callback_count;
$this->mycode_cache['nestable_count'] = $nestable_count;

 
		$this->mycode_cache['nestable_callback_count'] = $nestable_callback_count;

	}

/**

	}

/**

Zeile 477Zeile 484

// Cache the MyCode globally if needed.
if($this->mycode_cache == 0)


// Cache the MyCode globally if needed.
if($this->mycode_cache == 0)

		{

		{

			$this->cache_mycode();
}


			$this->cache_mycode();
}


Zeile 502Zeile 509

// Convert videos when allow.
if(!empty($this->options['allow_videocode']))


// 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_callback'), $message);
}
else

		{

		{

			$message = preg_replace_callback("#\[video=(.*?)\](.*?)\[/video\]#i", array($this, 'mycode_parse_video_disabled_callback'), $message);

			$message = preg_replace_callback("#\[video=(.*?)\](.*?)\[/video\]#i", array($this, 'mycode_parse_video_disabled_callback'), $message);

		}


		}


		$message = str_replace('$', '&#36;', $message);

// Replace the rest

		$message = str_replace('$', '&#36;', $message);

// Replace the rest

Zeile 528Zeile 535

// Replace the nestable mycode's
if($this->mycode_cache['nestable_count'] > 0)


// Replace the nestable mycode's
if($this->mycode_cache['nestable_count'] > 0)

		{

		{

			foreach($this->mycode_cache['nestable'] as $mycode)
{
while(preg_match($mycode['find'], $message))

			foreach($this->mycode_cache['nestable'] as $mycode)
{
while(preg_match($mycode['find'], $message))

				{

				{

					$message = preg_replace($mycode['find'], $mycode['replacement'], $message);

					$message = preg_replace($mycode['find'], $mycode['replacement'], $message);

				}


















				}
}
}

// Replace the nestable callback mycodes
if($this->mycode_cache['nestable_callback_count'] > 0)
{
foreach($this->mycode_cache['nestable_callback'] as $replace)
{
while(preg_match($replace['find'], $message))
{
$message_org = $message;
$message = preg_replace_callback($replace['find'], $replace['replacement'], $message);
if ($message_org == $message)
{
break;
}
}

			}
}


			}
}


Zeile 553Zeile 577
				// Ignores missing end tags
$message = preg_replace_callback("#\s?\[list(=(a|A|i|I|1))?&{$i}\](.*?)(\[/list&{$i}\]|$)(\r\n?|\n?)#si", array($this, 'mycode_parse_list_callback'), $message, 1);
}

				// Ignores missing end tags
$message = preg_replace_callback("#\s?\[list(=(a|A|i|I|1))?&{$i}\](.*?)(\[/list&{$i}\]|$)(\r\n?|\n?)#si", array($this, 'mycode_parse_list_callback'), $message, 1);
}

		}

		}


if(
(!isset($this->options['allow_auto_url']) || $this->options['allow_auto_url'] == 1) &&


if(
(!isset($this->options['allow_auto_url']) || $this->options['allow_auto_url'] == 1) &&

Zeile 582Zeile 606
			$extra_class = $onclick = '';
foreach($smilies as $sid => $smilie)
{

			$extra_class = $onclick = '';
foreach($smilies as $sid => $smilie)
{

 
				if(isset($theme['imgdir']))
{
$imgdir = $theme['imgdir'];
}
else
{
$imgdir = '';
}


				$smilie['find'] = explode("\n", $smilie['find']);

				$smilie['find'] = explode("\n", $smilie['find']);

				$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);

				$smilie['image'] = str_replace("{theme}", $imgdir, $smilie['image']);

				$smilie['image'] = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
$smilie['name'] = htmlspecialchars_uni($smilie['name']);


				$smilie['image'] = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
$smilie['name'] = htmlspecialchars_uni($smilie['name']);


Zeile 601Zeile 634
							"&gt$s" => "&gt$s",
);
}

							"&gt$s" => "&gt$s",
);
}

				}
}
}
}

				}
}
}
}


/**
* Parses smilie code in the specified message.


/**
* Parses smilie code in the specified message.

Zeile 655Zeile 688
	 * Generates a cache of badwords filters.
*
* @access private

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

	 */

	 */

	function cache_badwords()
{
global $cache;
$this->badwords_cache = array();
$this->badwords_cache = $cache->read("badwords");
}

	function cache_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 680Zeile 713
		if($this->badwords_cache == 0)
{
$this->cache_badwords();

		if($this->badwords_cache == 0)
{
$this->cache_badwords();

		}

		}

		if(is_array($this->badwords_cache))

		if(is_array($this->badwords_cache))

		{

		{

			reset($this->badwords_cache);
foreach($this->badwords_cache as $bid => $badword)
{
if(!$badword['replacement'])
{
$badword['replacement'] = "*****";

			reset($this->badwords_cache);
foreach($this->badwords_cache as $bid => $badword)
{
if(!$badword['replacement'])
{
$badword['replacement'] = "*****";

				}


				}


				if(!$badword['regex'])
{
$badword['badword'] = $this->generate_regex($badword['badword']);

				if(!$badword['regex'])
{
$badword['badword'] = $this->generate_regex($badword['badword']);

Zeile 702Zeile 735
		if(!empty($this->options['strip_tags']))
{
$message = strip_tags($message);

		if(!empty($this->options['strip_tags']))
{
$message = strip_tags($message);

		}
return $message;
}


		}
return $message;
}


	/**
* Generates REGEX patterns based on user defined badword string.
*

	/**
* Generates REGEX patterns based on user defined badword string.
*

Zeile 715Zeile 748
	function generate_regex($bad_word = "")
{
if($bad_word == "")

	function generate_regex($bad_word = "")
{
if($bad_word == "")

		{

		{

			return;
}


			return;
}


Zeile 731Zeile 764
		foreach($bad_word as $bad_piece)
{
if($bad_piece)

		foreach($bad_word as $bad_piece)
{
if($bad_piece)

			{

			{

				$trap .= $plus ? '[^\s\n]{'.$plus.'}'.$bad_piece : $bad_piece;
$plus = 1;
}

				$trap .= $plus ? '[^\s\n]{'.$plus.'}'.$bad_piece : $bad_piece;
$plus = 1;
}

Zeile 781Zeile 814

return $message;
}


return $message;
}





	/**
* Handles fontsize.
*

	/**
* Handles fontsize.
*

Zeile 794Zeile 827
		global $templates;

$size = (int)$size;

		global $templates;

$size = (int)$size;





		if($size < 1)
{
$size = 1;

		if($size < 1)
{
$size = 1;

Zeile 806Zeile 839
		}

$text = str_replace("\'", "'", $text);

		}

$text = str_replace("\'", "'", $text);





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

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

Zeile 1209Zeile 1242
			$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.


/**
* Parses URL MyCode.

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

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

		}

		}


$alt = basename($url);
$alt = htmlspecialchars_decode($alt);
if(my_strlen($alt) > 55)


$alt = basename($url);
$alt = htmlspecialchars_decode($alt);
if(my_strlen($alt) > 55)

		{

		{

			$alt = my_substr($alt, 0, 40).'...'.my_substr($alt, -10);
}
$alt = $this->encode_url($alt);

			$alt = my_substr($alt, 0, 40).'...'.my_substr($alt, -10);
}
$alt = $this->encode_url($alt);

Zeile 1279Zeile 1312
		}

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

		}

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

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

	 * @return string Image code.
*/

	 * @return string Image code.
*/

	function mycode_parse_img_callback1($matches)

	function mycode_parse_img_callback2($matches)

	{

	{

		return $this->mycode_parse_img($matches[2]);
}

/**
* Parses IMG MyCode.
*
* @param array $matches Matches.
* @return string Image code.
*/
function mycode_parse_img_callback2($matches)
{
return $this->mycode_parse_img($matches[4], array($matches[1], $matches[2]));

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












	}

/**

	}

/**

Zeile 1355Zeile 1388
	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.
*

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

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

Zeile 1410Zeile 1443

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


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

	}


	}


	/**
* Parses email MyCode.
*

	/**
* Parses email MyCode.
*

Zeile 1437Zeile 1470
	function mycode_parse_video($video, $url)
{
global $templates;

	function mycode_parse_video($video, $url)
{
global $templates;





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

		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 1453Zeile 1486
		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 1462Zeile 1495
		}

if($video == "liveleak")

		}

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

			// 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']);


$input = array();
foreach($queries as $query)


$input = array();
foreach($queries as $query)

Zeile 1476Zeile 1509
			$key = str_replace("amp;", "", $key);
$input[$key] = $value;
}

			$key = str_replace("amp;", "", $key);
$input[$key] = $value;
}





		$path = explode('/', $parsed_url['path']);

switch($video)

		$path = explode('/', $parsed_url['path']);

switch($video)

Zeile 1485Zeile 1518
				if(isset($path[2]))
{
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
{

				}
else
{

					$id = $path[1]; // http://dai.ly/fds123
}
break;

					$id = $path[1]; // http://dai.ly/fds123
}
break;

Zeile 1536Zeile 1569
				else
{
$local = '';

				else
{
$local = '';

				}
break;

				}
break;

			case "vimeo":
if(isset($path[3]))
{

			case "vimeo":
if(isset($path[3]))
{

Zeile 1587Zeile 1620
		{
return "[video={$video}]{$url}[/video]";
}

		{
return "[video={$video}]{$url}[/video]";
}





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

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

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

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

	}

/**

	}

/**

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

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

Zeile 1612Zeile 1645
	 * @return string
*/
function mycode_parse_video_disabled($url)

	 * @return string
*/
function mycode_parse_video_disabled($url)

	{

	{

		global $lang;
$url = trim($url);
$url = str_replace("\n", "", $url);

		global $lang;
$url = trim($url);
$url = str_replace("\n", "", $url);

Zeile 2014Zeile 2047
			$error_message .= var_export($data, true);

$error_handler->error(E_USER_WARNING, $error_message, __FILE__, __LINE__, false);

			$error_message .= var_export($data, true);

$error_handler->error(E_USER_WARNING, $error_message, __FILE__, __LINE__, false);

		}

 




		return empty($errors);




			return false;
} else {
return true;
}

	}
}

	}
}