class_bbcode_legacy.php

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

PHP
447
字号
			$txt = ' '.$txt.' ';					usort( $this->ipsclass->cache['emoticons'] , array( 'post_parser', 'smilie_length_sort' ) );						if ( count( $this->ipsclass->cache['emoticons'] ) > 0 )			{				foreach( $this->ipsclass->cache['emoticons']  as $a_id => $row)				{					if ( $row['emo_set'] != $this->ipsclass->skin['_emodir'] )					{						continue;					}										$code  = $row['typed'];					$image = $row['image'];										//-----------------------------------------					// Make safe for regex					//-----------------------------------------										$code = preg_quote($code, "/");										$txt = preg_replace( "!(?<=[^\w&;/])$code(?=.\W|\W.|\W$)!ei", "\$this->convert_emoticon('$code', '$image')", $txt );				}			}						$txt = trim($txt);						if ( $this->ipsclass->vars['max_emos'] )			{				if ($this->emoticon_count > $this->ipsclass->vars['max_emos'])				{					$this->error = 'too_many_emoticons';				}			}		}				//-----------------------------------------		// Badwords		//-----------------------------------------				$txt = $this->bad_words($txt);				//-----------------------------------------		// Check BBcode		//-----------------------------------------				$txt = $this->bbcode_check($txt);				return trim($txt);	}		/*-------------------------------------------------------------------------*/	// This function processes the DB post before printing as output	/*-------------------------------------------------------------------------*/		function pre_display_parse($t="")	{		if ( $this->parse_html )		{			$t = $this->post_db_parse_html( $t );		}		else		{			//$t = $this->my_strip_tags( $t );		}				if ( $this->parse_wordwrap > 0 )		{			$t = $this->my_wordwrap( $t, $this->parse_wordwrap );		}				//-----------------------------------------		// Custom BB code		//-----------------------------------------				if ( strstr( $t, '[/' )  )		{ 			$t = $this->post_db_parse_bbcode($t);		}				return $t;	}		/*-------------------------------------------------------------------------*/	// This function processes the text before showing for editing, etc	/*-------------------------------------------------------------------------*/			function pre_edit_parse($txt="")	{		$txt = preg_replace( "#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1" , $txt );				if ( $this->parse_bbcode )		{			//-----------------------------------------			// SQL			//-----------------------------------------						$txt = preg_replace( "#<!--sql-->(.+?)<!--sql1-->(.+?)<!--sql2-->(.+?)<!--sql3-->#eis", "\$this->unconvert_sql(\"\\2\")", $txt);						//-----------------------------------------			// HTML			//-----------------------------------------						$txt = preg_replace( "#<!--html-->(.+?)<!--html1-->(.+?)<!--html2-->(.+?)<!--html3-->#e", "\$this->unconvert_htm(\"\\2\")", $txt);						//-----------------------------------------			// Images / Flash			//-----------------------------------------						$txt = preg_replace( "#<!--Flash (.+?)-->.+?<!--End Flash-->#e", "\$this->unconvert_flash('\\1')", $txt );			$txt = preg_replace( "#<img src=[\"'](\S+?)['\"].+?".">#"      , "\[img\]\\1\[/img\]"            , $txt );						//-----------------------------------------			// Email, URLs			//-----------------------------------------						$txt = preg_replace( "#<a href=[\"']mailto:(.+?)['\"]>(.+?)</a>#"                                   , "\[email=\\1\]\\2\[/email\]"   , $txt );			$txt = preg_replace( "#<a href=[\"'](http://|https://|ftp://|news://)?(\S+?)['\"].+?".">(.+?)</a>#" , "\[url=\\1\\2\]\\3\[/url\]"  , $txt );						//-----------------------------------------			// Quote			//-----------------------------------------						$txt = preg_replace( "#<!--QuoteBegin-->(.+?)<!--QuoteEBegin-->#"                        , '[quote]'         , $txt );			$txt = preg_replace( "#<!--QuoteBegin-{1,2}([^>]+?)\+([^>]+?)-->(.+?)<!--QuoteEBegin-->#", "[quote=\\1,\\2]" , $txt );			$txt = preg_replace( "#<!--QuoteBegin-{1,2}([^>]+?)\+-->(.+?)<!--QuoteEBegin-->#"        , "[quote=\\1]" , $txt );			$txt = preg_replace( "#<!--QuoteEnd-->(.+?)<!--QuoteEEnd-->#"                            , '[/quote]'        , $txt );						//-----------------------------------------			// CODE			//-----------------------------------------						$txt = preg_replace( "#<!--c1-->(.+?)<!--ec1-->#", '[code]' , $txt );			$txt = preg_replace( "#<!--c2-->(.+?)<!--ec2-->#", '[/code]', $txt );						//-----------------------------------------			// Easy peasy			//-----------------------------------------						$txt = preg_replace( "#<i>(.+?)</i>#is"  , "\[i\]\\1\[/i\]"  , $txt );			$txt = preg_replace( "#<b>(.+?)</b>#is"  , "\[b\]\\1\[/b\]"  , $txt );			$txt = preg_replace( "#<s>(.+?)</s>#is"  , "\[s\]\\1\[/s\]"  , $txt );			$txt = preg_replace( "#<u>(.+?)</u>#is"  , "\[u\]\\1\[/u\]"  , $txt );						//-----------------------------------------			// List headache			//-----------------------------------------						$txt = preg_replace( "#(\n){0,}<ul>#" , "\\1\[list\]"  , $txt );			$txt = preg_replace( "#(\n){0,}<ol type='(a|A|i|I|1)'>#" , "\\1\[list=\\2\]\n"  , $txt );			$txt = preg_replace( "#(\n){0,}<li>#" , "\n\[*\]"     , $txt );			$txt = preg_replace( "#(\n){0,}</ul>(\n){0,}#", "\n\[/list\]\\2" , $txt );			$txt = preg_replace( "#(\n){0,}</ol>(\n){0,}#", "\n\[/list\]\\2" , $txt );						//-----------------------------------------			// SPAN			//-----------------------------------------						while ( preg_match( "#<span style=['\"]font-size:(.+?)pt;line-height:100%['\"]>(.+?)</span>#is", $txt ) )			{				$txt = preg_replace( "#<span style=['\"]font-size:(.+?)pt;line-height:100%['\"]>(.+?)</span>#ise" , "\$this->unconvert_size('\\1', '\\2')", $txt );			}						while ( preg_match( "#<span style=['\"]color:(.+?)['\"]>(.+?)</span>#is", $txt ) )			{				$txt = preg_replace( "#<span style=['\"]color:(.+?)['\"]>(.+?)</span>#is"    , "\[color=\\1\]\\2\[/color\]", $txt );			}						while ( preg_match( "#<span style=['\"]font-family:(.+?)['\"]>(.+?)</span>#is", $txt ) )			{				$txt = preg_replace( "#<span style=['\"]font-family:(.+?)['\"]>(.+?)</span>#is", "\[font=\\1\]\\2\[/font\]", $txt );			}						while ( preg_match( "#<span style=['\"]background-color:(.+?)['\"]>(.+?)</span>#is", $txt ) )			{				$txt = preg_replace( "#<span style=['\"]background-color:(.+?)['\"]>(.+?)</span>#is", "\[background=\\1\]\\2\[/font\]", $txt );			}						//-----------------------------------------			// Tidy up the end quote stuff			//-----------------------------------------						$txt = preg_replace( "#(\[/QUOTE\])\s*?<br />\s*#si", "\\1\n", $txt );			$txt = preg_replace( "#(\[/QUOTE\])\s*?<br>\s*#si"  , "\\1\n", $txt );						$txt = preg_replace( "#<!--EDIT\|.+?\|.+?-->#" , "" , $txt );			$txt = str_replace( "</li>", "", $txt );			$txt = str_replace( "&#153;", "(tm)", $txt );		}				//-----------------------------------------		// Parse html		//-----------------------------------------				if ( $this->parse_html )		{			$txt = str_replace( "&#39;", "'", $txt);		}				//-----------------------------------------		// Clean up BR tags		//-----------------------------------------				$txt = str_replace( "<br>"  , "\n", $txt );		$txt = str_replace( "<br />", "\n", $txt );						return trim(stripslashes($txt));	}								}?>

⌨️ 快捷键说明

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