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

过滤UBB代码的php类

PHP中文网
PHP中文网原创
2016-05-25 17:13:51972浏览

[代码][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