首頁 >php教程 >PHP源码 >过滤UBB代码的php类

过滤UBB代码的php类

PHP中文网
PHP中文网原創
2016-05-25 17:13:51966瀏覽

[代码][PHP]代码 

class Day{
   function ubb($Text) {      /// UBB代码转换
        //$Text=htmlspecialchars($Text);
        //$Text=ereg_replace("\r\n","
",$Text);
        $Text=ereg_replace("\[br\]","
",$Text);
        $Text=nl2br($Text);
        $Text=stripslashes($Text);
        $Text=preg_replace("/\\t/is"," ",$Text);
        $Text=preg_replace("/\[url\](http:\/\/.+?)\[\/url\]/is","",$Text);
        $Text=preg_replace("/\[url\](.+?)\[\/url\]/is","",$Text);
        $Text=preg_replace("/\[url=(http:\/\/.+?)\](.+?)\[\/url\]/is","",$Text);
        $Text=preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is","",$Text);
        $Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","",$Text);
        $Text=preg_replace("/\[font=(.+?)\](.+?)\[\/font\]/is","",$Text);
        $Text=preg_replace("/\[email=(.+?)\](.+?)\[\/email\]/is","",$Text);
        $Text=preg_replace("/\[email\](.+?)\[\/email\]/is","",$Text);
        $Text=preg_replace("/\[i\](.+?)\[\/i\]/is","",$Text);
        $Text=preg_replace("/\[u\](.+?)\[\/u\]/is","",$Text);
        $Text=preg_replace("/\[b\](.+?)\[\/b\]/is","",$Text);
        $Text=preg_replace("/\[fly\](.+?)\[\/fly\]/is","",$Text);
        $Text=preg_replace("/\[move\](.+?)\[\/move\]/is","",$Text);
        $Text=preg_replace("/\[shadow=([#0-9a-z]{1,10})\,([0-9]{1,3})\,([0-9]{1,2})\](.+?)\[\/shadow\]/is","",$Text);
        return $Text;
        }
 
 }

                   

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn