ubbcode简单实用

<%
function ChkBadWords(fString)
    if not(isnull(BadWords) or isnull(fString)) then
    bwords = split(BadWords, "|")
    for i = 0 to ubound(bwords)
        fString = Replace(fString, bwords(i), string(len(bwords(i)),"*"))
    next
    ChkBadWords = fString
    end if
end function

function HTMLEncode(fString)
if not isnull(fString) then
    'fString = Replace(fString, CHR(38), "&#38;")
    'fString = replace(fString, ">", "&gt;")
    'fString = replace(fString, "<", "&lt;")
    'fString = Replace(fString, CHR(39), "&#39;")
    'fString = Replace(fString, CHR(32), "&nbsp;")
    'fString = Replace(fString, CHR(34), "&quot;")
    'fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10), "<br/>")
    HTMLEncode = fString
end if
end function

function HTMLcode(fString)
if not isnull(fString) then
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10), "<br/>")
    HTMLcode = fString
end if
end function
function HTMLDecode(fString)
if not isnull(fString) then
    'fString = Replace(fString, CHR(38), "&#38;")
    'fString = replace(fString, "&gt;", ">")
    'fString = replace(fString, "&lt;", "<")
    'fString = Replace(fString, CHR(32), "&nbsp;")
    'fString = Replace(fString,"",CHR(13))
    fString = Replace(fString,"<br/>",CHR(10))
    HTMLDecode = fString
end if
end function

function UBBCode(strContent)
    if strAllowHTML <> 1 then
        strContent = HTMLEncode(strContent)
    else
 strContent = HTMLcode(strContent)
    end if
    dim re
    Set re=new RegExp
    re.IgnoreCase =true
    re.Global=True

re.Pattern="\[IMG\](.[^\[]*)\[\/IMG\]"
    strContent=re.Replace(strContent,"<img src=""https://www.jb51.net/article/$1""0""></img>")
    re.Pattern="\[IMG=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/IMG\]"
    strContent=re.Replace(strContent,"<a href=""https://www.jb51.net/article/$3"" title=点击看全图 target=_blank><img src=""https://www.jb51.net/article/$3""https://www.jb51.net/article/$1""https://www.jb51.net/article/$2""0""></img></a>")

        '图文混排
    re.Pattern="\[PIC\](.[^\[]*)\[\/PIC\]"
    strContent=re.Replace(strContent,"<img src=""https://www.jb51.net/article/$1""0""left""></img>")
    re.Pattern="\[PIC=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/PIC\]"
    strContent=re.Replace(strContent,"<a href=""https://www.jb51.net/article/$3"" title=点击看全图 target=_blank><img src=""https://www.jb51.net/article/$3""https://www.jb51.net/article/$1""https://www.jb51.net/article/$2""0""left""></img></a>")



    re.Pattern="\[FLASH=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/FLASH\]"
    strContent= re.Replace(strContent,"<EMBED SRC=""https://www.jb51.net/article/$3""https://www.jb51.net/article/$1""https://www.jb51.net/article/$2""></EMBED>")
    re.Pattern="\[FLASH\](.[^\[]*)\[\/FLASH\]"
    strContent= re.Replace(strContent,"<EMBED SRC=""https://www.jb51.net/article/$1""></EMBED>")

re.Pattern="(\[URL\])(http:\/\/.[^\[]*)(\[\/URL\])"
    strContent= re.Replace(strContent,"<A HREF=""https://www.jb51.net/article/$2"" TARGET=""_blank"">$2</A>")
    re.Pattern="(\[URL\])(.[^\[]*)(\[\/URL\])"
    strContent= re.Replace(strContent,"<A HREF=""https://$2"" TARGET=""_blank"">$2</A>")

re.Pattern="(\[EMAIL\])(mailto:\/\/.[^\[]*)(\[\/EMAIL\])"
    strContent= re.Replace(strContent,"<A HREF=""https://www.jb51.net/article/$2"" TARGET=""_blank"">$2</A>")
    re.Pattern="(\[EMAIL\])(.[^\[]*)(\[\/EMAIL\])"
    strContent= re.Replace(strContent,"<A HREF=""https://www.jb51.net/MAILTO:$2"" TARGET=""_blank"">$2</A>")

re.Pattern="(\[URL=(http:\/\/.[^\[]*)\])(.[^\[]*)(\[\/URL\])"
    strContent= re.Replace(strContent,"<A HREF=""https://www.jb51.net/article/$2"" TARGET=""_blank"">$3</A>")
    re.Pattern="(\[URL=(.[^\[]*)\])(.[^\[]*)(\[\/URL\])"
    strContent= re.Replace(strContent,"<A HREF=""https://$2"" TARGET=""_blank"">$3</A>")

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wfzwpz.html