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

过滤UBB代码的php类

PHP中文网
PHP中文网asal
2016-05-25 17:13:51966semak imbas

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

                   

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:PHP汉字转拼音函数Artikel seterusnya:php随机生成国内ip地址