class_bbcode_legacy.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 447 行 · 第 1/2 页
PHP
447 行
<?php/*+--------------------------------------------------------------------------| Invision Power Board v2.1.5| =============================================| by Matthew Mecham| (c) 2001 - 2005 Invision Power Services, Inc.| | =============================================| Web: | Time: Wed, 01 Mar 2006 19:11:28 GMT| Release: | Licence Info: +---------------------------------------------------------------------------| > $Date: 2005-10-24 22:17:00 +0100 (Mon, 24 Oct 2005) $| > $Revision: 64 $| > $Author: bfarber $+---------------------------------------------------------------------------|| > BB Code LEGACY Module| > Module written by Matt Mecham| > Date started: Wednesday 9th March 2005 11:31|+--------------------------------------------------------------------------*//*** BBCode Parsing: Legacy sub class** Sub class** @package InvisionPowerBoard* @subpackage BBCodeParser* @author Matt Mecham* @version 2.1* @ignore*//****//*** BBCode Parsing: Legacy sub class** Sub class** @package InvisionPowerBoard* @subpackage BBCodeParser* @author Matt Mecham* @version 2.1* @ignore*/class class_bbcode extends class_bbcode_core{ /*-------------------------------------------------------------------------*/ // CONSTRUCTOR /*-------------------------------------------------------------------------*/ function class_bbcode( ) { $this->strip_quotes = $this->ipsclass->vars['strip_quotes']; } /*-------------------------------------------------------------------------*/ // Manage the raw text before inserting into the DB /*-------------------------------------------------------------------------*/ function pre_db_parse( $txt="" ) { //----------------------------------------- // Remove session id's from any post //----------------------------------------- $txt = preg_replace( "#(\?|&|;|&)s=([0-9a-zA-Z]){32}(&|;|&|$)?#e", "\$this->regex_bash_session('\\1', '\\3')", $txt ); //----------------------------------------- // convert <br> to \n //----------------------------------------- $txt = preg_replace( "/<br>|<br \/>/", "\n", $txt ); //----------------------------------------- // Are we parsing bbcode? //----------------------------------------- if ( $this->parse_bbcode ) { //----------------------------------------- // Do [CODE] tag //----------------------------------------- $txt = preg_replace( "#\[code\](.+?)\[/code\]#ies", "\$this->regex_code_tag( '\\1' )", $txt ); //----------------------------------------- // Auto parse URLs //----------------------------------------- $txt = preg_replace( "#(^|\s)((http|https|news|ftp)://\w+[^\s\[\]]+)#ie" , "\$this->regex_build_url(array('html' => '\\2', 'show' => '\\2', 'st' => '\\1'))", $txt ); //----------------------------------------- // Do [QUOTE(name,date)] tags //----------------------------------------- $txt = preg_replace( "#(\[quote(.+?)?\].*\[/quote\])#ies" , "\$this->regex_parse_quotes('\\1')" , $txt ); /*-------------------------------------------------------------------------*/ // If we are not parsing a siggie, lets have a bash // at the [PHP] [SQL] and [HTML] tags. /*-------------------------------------------------------------------------*/ $txt = preg_replace( "#\[sql\](.+?)\[/sql\]#ies" , "\$this->regex_sql_tag('\\1')" , $txt ); $txt = preg_replace( "#\[html\](.+?)\[/html\]#ies" , "\$this->regex_html_tag('\\1')" , $txt ); //----------------------------------------- // [LIST] [*] [/LIST] //----------------------------------------- while( preg_match( "#\n?\[list\](.+?)\[/list\]\n?#ies" , $txt ) ) { $txt = preg_replace( "#\n?\[list\](.+?)\[/list\]\n?#ies", "\$this->regex_list('\\1')" , $txt ); } while( preg_match( "#\n?\[list=(a|A|i|I|1)\](.+?)\[/list\]\n?#ies" , $txt ) ) { $txt = preg_replace( "#\n?\[list=(a|A|i|I|1)\](.+?)\[/list\]\n?#ies", "\$this->regex_list('\\2','\\1')" , $txt ); } //----------------------------------------- // Do [IMG] [FLASH] tags //----------------------------------------- if ( $this->ipsclass->vars['allow_images'] ) { $txt = preg_replace( "#\[img\](.+?)\[/img\]#ie" , "\$this->regex_check_image('\\1')" , $txt ); $txt = preg_replace( "#(\[flash=)(\S+?)(\,)(\S+?)(\])(\S+?)(\[\/flash\])#ie", "\$this->regex_check_flash('\\2','\\4','\\6')", $txt ); } //----------------------------------------- // Start off with the easy stuff //----------------------------------------- $txt = preg_replace( "#\[b\](.+?)\[/b\]#is", "<b>\\1</b>", $txt ); $txt = preg_replace( "#\[i\](.+?)\[/i\]#is", "<i>\\1</i>", $txt ); $txt = preg_replace( "#\[u\](.+?)\[/u\]#is", "<u>\\1</u>", $txt ); $txt = preg_replace( "#\[s\](.+?)\[/s\]#is", "<s>\\1</s>", $txt ); //----------------------------------------- // (c) (r) and (tm) //----------------------------------------- $txt = preg_replace( "#\(c\)#i" , "©" , $txt ); $txt = preg_replace( "#\(tm\)#i" , "™" , $txt ); $txt = preg_replace( "#\(r\)#i" , "®" , $txt ); //----------------------------------------- // [email]matt@index.com[/email] // [email=matt@index.com]Email me[/email] //----------------------------------------- $txt = preg_replace( "#\[email\](\S+?)\[/email\]#i" , "<a href='mailto:\\1'>\\1</a>", $txt ); $txt = preg_replace( "#\[email\s*=\s*\"\;([\.\w\-]+\@[\.\w\-]+\.[\.\w\-]+)\s*\"\;\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\\1'>\\2</a>", $txt ); $txt = preg_replace( "#\[email\s*=\s*([\.\w\-]+\@[\.\w\-]+\.[\w\-]+)\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\\1'>\\2</a>", $txt ); //----------------------------------------- // [url]http://www.index.com[/url] // [url=http://www.index.com]ibforums![/url] //----------------------------------------- $txt = preg_replace( "#\[url\](\S+?)\[/url\]#ie" , "\$this->regex_build_url(array('html' => '\\1', 'show' => '\\1'))", $txt ); $txt = preg_replace( "#\[url\s*=\s*\"\;\s*(\S+?)\s*\"\;\s*\](.*?)\[\/url\]#ie" , "\$this->regex_build_url(array('html' => '\\1', 'show' => '\\2'))", $txt ); $txt = preg_replace( "#\[url\s*=\s*(\S+?)\s*\](.*?)\[\/url\]#ie" , "\$this->regex_build_url(array('html' => '\\1', 'show' => '\\2'))", $txt ); //----------------------------------------- // font size, colour and font style // [font=courier]Text here[/font] // [size=6]Text here[/size] // [color=red]Text here[/color] //----------------------------------------- while ( preg_match( "#\[size=([^\]]+)\](.+?)\[/size\]#ies", $txt ) ) { $txt = preg_replace( "#\[size=([^\]]+)\](.+?)\[/size\]#ies" , "\$this->regex_font_attr(array('s'=>'size','1'=>'\\1','2'=>'\\2'))", $txt ); } while ( preg_match( "#\[font=([^\]]+)\](.*?)\[/font\]#ies", $txt ) ) { $txt = preg_replace( "#\[font=([^\]]+)\](.*?)\[/font\]#ies" , "\$this->regex_font_attr(array('s'=>'font','1'=>'\\1','2'=>'\\2'))", $txt ); } while( preg_match( "#\[color=([^\]]+)\](.+?)\[/color\]#ies", $txt ) ) { $txt = preg_replace( "#\[color=([^\]]+)\](.+?)\[/color\]#ies" , "\$this->regex_font_attr(array('s'=>'col' ,'1'=>'\\1','2'=>'\\2'))", $txt ); } while( preg_match( "#\[background=([^\]]+)\](.+?)\[/background\]#ies", $txt ) ) { $txt = preg_replace( "#\[background=([^\]]+)\](.+?)\[/background\]#ies" , "\$this->regex_font_attr(array('s'=>'background' ,'1'=>'\\1','2'=>'\\2'))", $txt ); } } //----------------------------------------- // Swap \n back to <br> //----------------------------------------- $txt = preg_replace( "/\n/", "<br />", $txt ); //----------------------------------------- // Unicode? //----------------------------------------- if ( $this->allow_unicode ) { $txt = preg_replace("/&#([0-9]+);/s", "&#\\1;", $txt ); } //----------------------------------------- // Parse smilies (disallow smilies in siggies, or we'll have to query the DB for each post // and each signature when viewing a topic, not something that we really want to do. //----------------------------------------- if ( $this->parse_smilies ) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?