post_parser.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,500 行 · 第 1/4 页

PHP
1,500
字号
		 		$this->quote_closed++;		 		return "<!--QuoteEnd-->{$this->quote_html['END']}<!--QuoteEEnd-->";	}		/*-------------------------------------------------------------------------*/	// regex_quote_tag: Builds this quote tag HTML	// [QUOTE=Matthew,14 February 2002]	/*-------------------------------------------------------------------------*/		function regex_quote_tag($name="", $date="")	{		global $ibforums;				if ( $date != "" )		{			$default = "\[quote=$name,$date\]";		}		else		{			$default = "\[quote=$name\]";		}				if ( strstr( $name, '<!--c1-->' ) or strstr( $date, '<!--c1-->' ) )		{			//-----------------------------------------			// Code tag detected...			//-----------------------------------------						$this->quote_error++;		 	return $default;		}				$name = str_replace( "+", "&#043;", $name );		$name = str_replace( "-", "&#045;", $name );		$name = str_replace( '[', "&#091;", $name );		$name = str_replace( ']', "&#093;", $name );				$this->quote_open++;			if ($date == "")		{			$html = $this->wrap_style( 'quote', "($name)");		}		else		{			$html = $this->wrap_style( 'quote', "($name &#064; $date)" );		}				$extra = "-".$name.'+'.$date;				return "<!--QuoteBegin".$extra."-->{$html['START']}<!--QuoteEBegin-->";			}				/*-------------------------------------------------------------------------*/	// regex_check_flash: Checks, and builds the <object>	// html.	/*-------------------------------------------------------------------------*/		function regex_check_flash($width="", $height="", $url="")	{		global $ibforums;				$default = "\[flash=$width,$height\]$url\[/flash\]";				if (!$ibforums->vars['allow_flash']) {			return $default;		}				if ($width > $ibforums->vars['max_w_flash']) {			$this->error = 'flash_too_big';			return $default;		}				if ($height > $ibforums->vars['max_h_flash']) {			$this->error = 'flash_too_big';			return $default;		}				if (!preg_match( "/^http:\/\/(\S+)\.swf$/i", $url) ) {			$this->error = 'flash_url';			return $default;		}				return "<!--Flash $width+$height+$url--><OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' WIDTH=$width HEIGHT=$height><PARAM NAME=MOVIE VALUE=$url><PARAM NAME=PLAY VALUE=TRUE><PARAM NAME=LOOP VALUE=TRUE><PARAM NAME=QUALITY VALUE=HIGH><EMBED SRC=$url WIDTH=$width HEIGHT=$height PLAY=TRUE LOOP=TRUE QUALITY=HIGH></EMBED></OBJECT><!--End Flash-->";	}		/*-------------------------------------------------------------------------*/	// regex_check_image: Checks, and builds the <img>	// html.	/*-------------------------------------------------------------------------*/		function regex_check_image($url="")	{		global $ibforums;				if (!$url) return;				$url = trim($url);				$default = "[img]".$url."[/img]";				++$this->image_count;				//-----------------------------------------		// Make sure we've not overriden the set image # limit		//-----------------------------------------				if ($ibforums->vars['max_images'])		{			if ($this->image_count > $ibforums->vars['max_images'])			{				$this->error = 'too_many_img';				return $default;			}		}				//-----------------------------------------		// Are they attempting to post a dynamic image, or JS?		//-----------------------------------------				if ($ibforums->vars['allow_dynamic_img'] != 1)		{			if (preg_match( "/[?&;]/", $url))			{				$this->error = 'no_dynamic';				return $default;			}			if (preg_match( "/javascript(\:|\s)/i", $url ))			{				$this->error = 'no_dynamic';				return $default;			}		}				//-----------------------------------------		// Is the img extension allowed to be posted?		//-----------------------------------------				if ($ibforums->vars['img_ext'])		{			$extension = preg_replace( "#^.*\.(\S+)$#", "\\1", $url );						$extension = strtolower($extension);						if ( (! $extension) OR ( preg_match( "#/#", $extension ) ) )			{				$this->error = 'invalid_ext';				return $default;			}						$ibforums->vars['img_ext'] = strtolower($ibforums->vars['img_ext']);						if ( ! preg_match( "/".preg_quote($extension, '/')."(,|$)/", $ibforums->vars['img_ext'] ))			{				$this->error = 'invalid_ext';				return $default;			}		}				//-----------------------------------------		// Is it a legitimate image?		//-----------------------------------------				if (!preg_match( "/^(http|https|ftp):\/\//i", $url )) {			$this->error = 'no_dynamic';			return $default;		}				//-----------------------------------------		// If we are still here....		//-----------------------------------------				$url = str_replace( " ", "%20", $url );				return "<img src='$url' border='0' alt='用户发表的图片' />";	}			    /*-------------------------------------------------------------------------*/	// regex_font_attr:	// Returns a string for an /e regexp based on the input	/*-------------------------------------------------------------------------*/		function regex_font_attr($IN)	{		if (!is_array($IN)) return "";				//-----------------------------------------		// Trim out stoopid 1337 stuff		// [color=black;font-size:500pt;border:orange 50in solid;]hehe[/color]		//-----------------------------------------				if ( preg_match( "/;/", $IN['1'] ) )		{			$attr = explode( ";", $IN['1'] );						$IN['1'] = $attr[0];		}				$IN['1'] = preg_replace( "/[&\(\)\.\%\[\]<>]/", "", $IN['1'] );				if ($IN['s'] == 'size')		{			$IN['1'] = intval($IN['1']) + 7;						if ($IN['1'] > 30)			{				$IN['1'] = 30;			}						return "<span style='font-size:".$IN['1']."pt;line-height:100%'>".$IN['2']."</span>";		}		else if ($IN['s'] == 'col')		{			$IN[1] = preg_replace( "/[^\d\w\#\s]/s", "", $IN[1] );			return "<span style='color:".$IN[1]."'>".$IN['2']."</span>";		}		else if ($IN['s'] == 'font')		{			$IN['1'] = preg_replace( "/[^\d\w\#\-\_\s]/s", "", $IN['1'] );			return "<span style='font-family:".$IN['1']."'>".$IN['2']."</span>";		}	}		/*-------------------------------------------------------------------------*/	// regex_build_url: Checks, and builds the a href	// html	/*-------------------------------------------------------------------------*/		function regex_build_url($url=array())	{		$skip_it = 0;				//-----------------------------------------		// Make sure the last character isn't punctuation..		// if it is, remove it and add it to the		// end array		//-----------------------------------------				if ( preg_match( "/([\.,\?]|&#33;)$/", $url['html'], $match) )		{			$url['end'] .= $match[1];			$url['html'] = preg_replace( "/([\.,\?]|&#33;)$/", "", $url['html'] );			$url['show'] = preg_replace( "/([\.,\?]|&#33;)$/", "", $url['show'] );		}				//-----------------------------------------		// Make sure it's not being used in a		// closing code/quote/html or sql block		//-----------------------------------------				if (preg_match( "/\[\/(html|quote|code|sql)/i", $url['html']) )		{			return $url['html'];		}				//-----------------------------------------		// clean up the ampersands / brackets		//-----------------------------------------				$url['html'] = str_replace( "&amp;" , "&"   , $url['html'] );		$url['html'] = str_replace( "["     , "%5b" , $url['html'] );		$url['html'] = str_replace( "]"     , "%5d" , $url['html'] );				//-----------------------------------------		// Make sure we don't have a JS link		//-----------------------------------------				$url['html'] = preg_replace( "/javascript:/i", "java script&#58; ", $url['html'] );				//-----------------------------------------		// Do we have http:// at the front?		//-----------------------------------------				if ( ! preg_match("#^(http|news|https|ftp|aim)://#", $url['html'] ) )		{			$url['html'] = 'http://'.$url['html'];		}				//-----------------------------------------		// Tidy up the viewable URL		//-----------------------------------------		if (preg_match( "/^<img src/i", $url['show'] )) $skip_it = 1;		$url['show'] = preg_replace( "/&amp;/" , "&" , $url['show'] );		$url['show'] = preg_replace( "/javascript:/i", "javascript&#58; ", $url['show'] );				if ( (strlen($url['show']) -58 ) < 3 )  $skip_it = 1;				//-----------------------------------------		// Make sure it's a "proper" url		//-----------------------------------------				if (!preg_match( "/^(http|ftp|https|news):\/\//i", $url['show'] )) $skip_it = 1;				$show     = $url['show'];				if ($skip_it != 1)		{			$stripped = preg_replace( "#^(http|ftp|https|news)://(\S+)$#i", "\\2", $url['show'] );			$uri_type = preg_replace( "#^(http|ftp|https|news)://(\S+)$#i", "\\1", $url['show'] );						$show = $uri_type.'://'.substr( $stripped , 0, 35 ).'...'.substr( $stripped , -15   );		}				return $url['st'] . "<a href='".$url['html']."' target='_blank'>".$show."</a>" . $url['end'];			}		function regex_bash_session($start_tok, $end_tok)	{		//-----------------------------------------		// Case 1: index.php?s=0000        :: Return nothing (parses: index.php)		// Case 2: index.php?s=0000&this=1 :: Return ?       (parses: index.php?this=1)		// Case 3: index.php?this=1&s=0000 :: Return nothing (parses: index.php?this=1)		// Case 4: index.php?t=1&s=00&y=2  :: Return &       (parses: index.php?t=1&y=2)		//-----------------------------------------				$start_tok = str_replace( '&amp;', '&', $start_tok );		$end_tok   = str_replace( '&amp;', '&', $end_tok   );				//1:		if ($start_tok == '?' and $end_tok == '')		{			return "";		}		//2:		else if ($start_tok == '?' and $end_tok == '&')		{			return '?';		}		//3:		else if ($start_tok == '&' and $end_tok == '')		{			return "";		}		else if ($start_tok == '&' and $end_tok == '&')		{			return "&";		}		else		{			return $start_tok.$end_tok;		}		}		function smilie_length_sort($a, $b)	{		if ( strlen($a['typed']) == strlen($b['typed']) )		{			return 0;		}		return ( strlen($a['typed']) > strlen($b['typed']) ) ? -1 : 1;	}			function word_length_sort($a, $b)	{		if ( strlen($a['type']) == strlen($b['type']) )		{			return 0;		}		return ( strlen($a['type']) > strlen($b['type']) ) ? -1 : 1;	}	}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?