欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

过滤UBB代码的php类

程序员文章站 2024-04-05 23:10:43
...

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