php實(shí)現(xiàn)過濾UBB代碼的類
更新時(shí)間:2015年03月12日 12:08:24 作者:鑒客
這篇文章主要介紹了php實(shí)現(xiàn)過濾UBB代碼的類,涉及php正則表達(dá)式的操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了php實(shí)現(xiàn)過濾UBB代碼的類。分享給大家供大家參考。具體如下:
PHP代碼如下:
復(fù)制代碼 代碼如下:
class Day{
function ubb($Text) { /// UBB代碼轉(zhuǎn)換
//$Text=htmlspecialchars($Text);
//$Text=ereg_replace("\r\n","<br>",$Text);
$Text=ereg_replace("\[br\]","<br />",$Text);
$Text=nl2br($Text);
$Text=stripslashes($Text);
$Text=preg_replace("/\\t/is"," ",$Text);
$Text=preg_replace("/\[url\](http:\/\/.+?)\[\/url\]/is","<a href=\"\\1\" target=\"new\"><u>\\1</u></a>",$Text);
$Text=preg_replace("/\[url\](.+?)\[\/url\]/is","<a href=\"http://\\1\" target=\"new\"><u>\\1</u></a>",$Text);
$Text=preg_replace("/\[url=(http:\/\/.+?)\](.+?)\[\/url\]/is","<a href=\"\\1\" target=\"new\"><u>\\2</u></a>",$Text);
$Text=preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is","<a href=\"http://\\1\" target=\"new\"><u>\\2</u></a>",$Text);
$Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","<font color=\"\\1\">\\2</font>",$Text);
$Text=preg_replace("/\[font=(.+?)\](.+?)\[\/font\]/is","<font face=\"\\1\">\\2</font>",$Text);
$Text=preg_replace("/\[email=(.+?)\](.+?)\[\/email\]/is","<a href=\"mailto:\\1\"><u>\\2</u></a>",$Text);
$Text=preg_replace("/\[email\](.+?)\[\/email\]/is","<a href=\"mailto:\\1\"><u>\\1</u></a>",$Text);
$Text=preg_replace("/\[i\](.+?)\[\/i\]/is","<i>\\1</i>",$Text);
$Text=preg_replace("/\[u\](.+?)\[\/u\]/is","<u>\\1</u>",$Text);
$Text=preg_replace("/\[b\](.+?)\[\/b\]/is","<b>\\1</b>",$Text);
$Text=preg_replace("/\[fly\](.+?)\[\/fly\]/is","<marquee width=\"98%\" behavior=\"alternate\" scrollamount=\"3\">\\1</marquee>",$Text);
$Text=preg_replace("/\[move\](.+?)\[\/move\]/is","<marquee width=\"98%\" scrollamount=\"3\">\\1</marquee>",$Text);
$Text=preg_replace("/\[shadow=([#0-9a-z]{1,10})\,([0-9]{1,3})\,([0-9]{1,2})\](.+?)\[\/shadow\]/is","<table width=\"*\"><tr><td style=\"filter:shadow(color=\\1, direction=\\2 ,strength=\\3)\">\\4</td></tr></table>",$Text);
return $Text;
}
}
function ubb($Text) { /// UBB代碼轉(zhuǎn)換
//$Text=htmlspecialchars($Text);
//$Text=ereg_replace("\r\n","<br>",$Text);
$Text=ereg_replace("\[br\]","<br />",$Text);
$Text=nl2br($Text);
$Text=stripslashes($Text);
$Text=preg_replace("/\\t/is"," ",$Text);
$Text=preg_replace("/\[url\](http:\/\/.+?)\[\/url\]/is","<a href=\"\\1\" target=\"new\"><u>\\1</u></a>",$Text);
$Text=preg_replace("/\[url\](.+?)\[\/url\]/is","<a href=\"http://\\1\" target=\"new\"><u>\\1</u></a>",$Text);
$Text=preg_replace("/\[url=(http:\/\/.+?)\](.+?)\[\/url\]/is","<a href=\"\\1\" target=\"new\"><u>\\2</u></a>",$Text);
$Text=preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is","<a href=\"http://\\1\" target=\"new\"><u>\\2</u></a>",$Text);
$Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","<font color=\"\\1\">\\2</font>",$Text);
$Text=preg_replace("/\[font=(.+?)\](.+?)\[\/font\]/is","<font face=\"\\1\">\\2</font>",$Text);
$Text=preg_replace("/\[email=(.+?)\](.+?)\[\/email\]/is","<a href=\"mailto:\\1\"><u>\\2</u></a>",$Text);
$Text=preg_replace("/\[email\](.+?)\[\/email\]/is","<a href=\"mailto:\\1\"><u>\\1</u></a>",$Text);
$Text=preg_replace("/\[i\](.+?)\[\/i\]/is","<i>\\1</i>",$Text);
$Text=preg_replace("/\[u\](.+?)\[\/u\]/is","<u>\\1</u>",$Text);
$Text=preg_replace("/\[b\](.+?)\[\/b\]/is","<b>\\1</b>",$Text);
$Text=preg_replace("/\[fly\](.+?)\[\/fly\]/is","<marquee width=\"98%\" behavior=\"alternate\" scrollamount=\"3\">\\1</marquee>",$Text);
$Text=preg_replace("/\[move\](.+?)\[\/move\]/is","<marquee width=\"98%\" scrollamount=\"3\">\\1</marquee>",$Text);
$Text=preg_replace("/\[shadow=([#0-9a-z]{1,10})\,([0-9]{1,3})\,([0-9]{1,2})\](.+?)\[\/shadow\]/is","<table width=\"*\"><tr><td style=\"filter:shadow(color=\\1, direction=\\2 ,strength=\\3)\">\\4</td></tr></table>",$Text);
return $Text;
}
}
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
相關(guān)文章
新安裝的MySQL數(shù)據(jù)庫(kù)需要注意的安全知識(shí)
在你自己安裝了一個(gè)新的MySQL服務(wù)器后,你需要為MySQL的root用戶指定一個(gè)目錄(缺省無口令),否則如果你忘記這點(diǎn),你將你的MySQL處于極不安全的狀態(tài)(至少在一段時(shí)間內(nèi))。2008-07-07
PHP實(shí)現(xiàn)15位身份證號(hào)轉(zhuǎn)18位的方法分析
這篇文章主要介紹了PHP實(shí)現(xiàn)15位身份證號(hào)轉(zhuǎn)18位的方法,結(jié)合實(shí)例形式分析了15位身份證號(hào)轉(zhuǎn)18位的相關(guān)原理與php實(shí)現(xiàn)技巧,需要的朋友可以參考下2019-10-10
PHP實(shí)現(xiàn)從PostgreSQL數(shù)據(jù)庫(kù)檢索數(shù)據(jù)分頁(yè)顯示及根據(jù)條件查找數(shù)據(jù)示例
這篇文章主要介紹了PHP實(shí)現(xiàn)從PostgreSQL數(shù)據(jù)庫(kù)檢索數(shù)據(jù)分頁(yè)顯示及根據(jù)條件查找數(shù)據(jù)操作,涉及PHP操作PostgreSQL數(shù)據(jù)庫(kù)的SQL條件查詢、分頁(yè)、顯示等相關(guān)操作技巧,需要的朋友可以參考下
2018-06-06
php基于協(xié)程實(shí)現(xiàn)異步的方法分析
這篇文章主要介紹了php基于協(xié)程實(shí)現(xiàn)異步的方法,結(jié)合實(shí)例形式分析了php基于協(xié)程調(diào)度的異步操作實(shí)現(xiàn)方法,需要的朋友可以參考下
2019-07-07
幾個(gè)有用的php字符串過濾,轉(zhuǎn)換函數(shù)代碼
幾個(gè)有用的php字符串過濾,轉(zhuǎn)換函數(shù),主要是一些字符的安全處理與字符串處理
2012-05-05 
