本文实例讲述了PHP实现过滤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","\\1",$Text); $Text=preg_replace("/\[url\](.+?)\[\/url\]/is","\\1",$Text); $Text=preg_replace("/\[url=(http:\/\/.+?)\](.+?)\[\/url\]/is","\\2",$Text); $Text=preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is","\\2",$Text); $Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","",$Text); $Text=preg_replace("/\[font=(.+?)\](.+?)\[\/font\]/is","",$Text); $Text=preg_replace("/\[email=(.+?)\](.+?)\[\/email\]/is","\\2",$Text); $Text=preg_replace("/\[email\](.+?)\[\/email\]/is","\\1",$Text); $Text=preg_replace("/\[i\](.+?)\[\/i\]/is","\\1@H_301_10@",$Text); $Text=preg_replace("/\[u\](.+?)\[\/u\]/is","\\1",$Text); $Text=preg_replace("/\[b\](.+?)\[\/b\]/is","\\1",$Text); $Text=preg_replace("/\[fly\](.+?)\[\/fly\]/is","
",$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","\\1",$Text); $Text=preg_replace("/\[url\](.+?)\[\/url\]/is","\\1",$Text); $Text=preg_replace("/\[url=(http:\/\/.+?)\](.+?)\[\/url\]/is","\\2",$Text); $Text=preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is","\\2",$Text); $Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","",$Text); $Text=preg_replace("/\[font=(.+?)\](.+?)\[\/font\]/is","",$Text); $Text=preg_replace("/\[email=(.+?)\](.+?)\[\/email\]/is","\\2",$Text); $Text=preg_replace("/\[email\](.+?)\[\/email\]/is","\\1",$Text); $Text=preg_replace("/\[i\](.+?)\[\/i\]/is","\\1@H_301_10@",$Text); $Text=preg_replace("/\[u\](.+?)\[\/u\]/is","\\1",$Text); $Text=preg_replace("/\[b\](.+?)\[\/b\]/is","\\1",$Text); $Text=preg_replace("/\[fly\](.+?)\[\/fly\]/is","