Ubbcode is simple and practical

Source: Internet
Author: User

<%
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 ),"&")
'Fstring = replace (fString, ">", "> ")
'Fstring = replace (fString, "<", "<")
'Fstring = Replace (fString, CHR (39 ),"'")
'Fstring = Replace (fString, CHR (32 ),"")
'Fstring = Replace (fString, CHR (34 ),""")
'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 ),"&")
'Fstring = replace (fString, ">", "> ")
'Fstring = replace (fString, "<", "<")
'Fstring = Replace (fString, CHR (32 ),"")
'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> ")
Re. pattern = "\ [IMG = * ([0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/IMG \]"
StrContent = re. replace (strContent, "<a href =" "$3" "title = click to view the full image target = _ blank> </img> </a> ")

'Text & image Mixing
Re. Pattern = "\ [PIC \] (. [^ \ [] *) \ [\/PIC \]"
StrContent = re. Replace (strContent, " </img> ")
Re. pattern = "\ [PIC = * ([0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/PIC \]"
StrContent = re. replace (strContent, "<a href =" "$3" "title = click to view the full image target = _ blank> </img> </a> ")



Re. pattern = "\ [FLASH = * ([0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/FLASH \]"
StrContent = re. replace (strContent, "<embed src =" "$3" "width =" "$1" "height =" "$2" "> </EMBED> ")
Re. Pattern = "\ [FLASH \] (. [^ \ [] *) \ [\/FLASH \]"
StrContent = re. Replace (strContent, "<embed src =" "$1" "> </EMBED> ")

Re. Pattern = "(\ [URL \]) (http: \/. [^ \ [] *) (\ [\/URL \])"
StrContent = re. Replace (strContent, "<a href =" "$2" "TARGET =" _ blank "" >2 2 </A> ")
Re. Pattern = "(\ [URL \]) (. [^ \ [] *) (\ [\/URL \])"
StrContent = re. Replace (strContent, "<a href =" "http: // $2" "TARGET =" "_ blank" "> $2 </A> ")

Re. Pattern = "(\ [EMAIL \]) (mailto: \/. [^ \ [] *) (\ [\/EMAIL \])"
StrContent = re. Replace (strContent, "<a href =" "$2" "TARGET =" _ blank "" >2 2 </A> ")
Re. Pattern = "(\ [EMAIL \]) (. [^ \ [] *) (\ [\/EMAIL \])"
StrContent = re. Replace (strContent, "<a href =" "MAILTO: $2" "TARGET =" _ blank ""> $2 </A> ")

Re. pattern = "(\ [URL = (http :\/\/. [^ \ [] *) \]) (. [^ \ [] *) (\ [\/URL \])"
StrContent = re. Replace (strContent, "<a href =" "$2" "TARGET =" _ blank "" >3 3 </A> ")
Re. pattern = "(\ [URL = (. [^ \ [] *) \]) (. [^ \ [] *) (\ [\/URL \])"
StrContent = re. Replace (strContent, "<a href =" "http: // $2" "TARGET =" "_ blank" ">3 3 </A> ")

Re. Pattern = "^ (http: // [A-Za-z0-9 \./= \? % \-&_~ '@': +!] + )"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")
Re. Pattern = "(http: // [A-Za-z0-9 \./= \? % \-&_~ '@': +!] +) $"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")
Re. Pattern = "[^> =" "] (http: // [A-Za-z0-9 \./= \? % \-&_~ '@': +!] + )"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")
Re. Pattern = "^ (ftp: // [A-Za-z0-9 \./= \? % \-&_~ '@': +!] + )"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")
Re. Pattern = "(ftp: // [A-Za-z0-9 \./= \? % \-&_~ '@': +!] +) $"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")
Re. Pattern = "[^> =" "] (ftp: // [A-Za-z0-9 \. \/= \? % \-&_~ '@': +!] + )"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")
Re. Pattern = "^ (rtsp: // [A-Za-z0-9 \./= \? % \-&_~ '@': +!] + )"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")
Re. Pattern = "(rtsp: // [A-Za-z0-9 \./= \? % \-&_~ '@': +!] +) $"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")
Re. Pattern = "[^> =" "] (rtsp: // [A-Za-z0-9 \. \/= \? % \-&_~ '@': +!] + )"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")
Re. Pattern = "^ (mms: // [A-Za-z0-9 \./= \? % \-&_~ '@': +!] + )"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")
Re. Pattern = "(mms: // [A-Za-z0-9 \./= \? % \-&_~ '@': +!] +) $"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")
Re. Pattern = "[^> =" "] (mms: // [A-Za-z0-9 \. \/= \? % \-&_~ '@': +!] + )"
StrContent = re. Replace (strContent, " <a target = _ blank href = $1> $1 </a> ")

 

Re. pattern = "\ [DIR = * ([0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/DIR]"
StrContent = re. replace (strContent, "<object classid = clsid: 166B1BCA-3F9C-11CF-8075-444553540000 codebase = http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=7,0,2,0 width = $1 height = $2> <param name = src value = $3> <embed src = $3 pluginspage = http://www.macromedia.com/shockwave/download/ width = $1 height = $2> </embed> </object> ")
Re. pattern = "\ [QT = * ([0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/QT]"
StrContent = re. replace (strContent, "<embed src = $3 width = $1 height = $2 autoplay = true loop = false controller = true playeveryframe = false cache = false scale = TOFIT bgcolor = #000000 kioskmode = false targetcache = false pluginspage = http://www.apple.com/quicktime/> ")
Re. pattern = "\ [MP = * ([0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/MP]"
StrContent = re. replace (strContent, "<object align = middle classid = CLSID: 22d6f312-b0f6-11d0-94ab-0080c74c7e95 class = OBJECT id = MediaPlayer width = $1 height = $2> <param name = ShowStatusBar value =-1> <param name = Filename value = $3> <embed type application/x-oleobject codebase = http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename = mp src = $3 width = $1 height = $2> </embed> </object> ")
Re. pattern = "\ [RM = * ([0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/RM]"
StrContent = re. replace (strContent, "<OBJECT classid = clsid: CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA class = OBJECT id = RAOCX width = $1 height = $2> <param name = src value = $3> <param name = console value = Clip1> <param name = CONTROLS VALUE = imagewindow> <param name = autostart value = true> </OBJECT> <br> <OBJECT classid = CLSID: CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height = 32 id = video2 width = $1> <param name = src value = $3> <param name = autostart value =-1> <param name = controls value = controlpanel> <param name = console value = Clip1> </OBJECT> ")

 


Re. pattern = "(\ [color = (. [^ \ [] *) \]) (. [^ \ [] *) (\ [\/color \])"
StrContent = re. Replace (strContent, "<font color =" "$2" "> $3 </font> ")
Re. pattern = "(\ [face = (. [^ \ [] *) \]) (. [^ \ [] *) (\ [\/face \])"
StrContent = re. Replace (strContent, "<font face =" "$2" "> $3 </font> ")
Re. Pattern = "(\ [align = (. [^ \ [] *) \]) (. *) (\ [\/align \])"
StrContent = re. Replace (strContent, "<div align =" "$2" "> $3 </div> ")

Re. Pattern = "(\ [QUOTE \]) (. *) (\ [\/QUOTE \])"
StrContent = re. replace (strContent, "<table cellpadding =" "0" "cellspacing =" "0" "border =" 0 "" WIDTH = "94%" "bgcolor =" "# D7F0FF" "align = "" center ""> <tr> <td> <table width = "100%" "cellpadding =" "5" "cellspacing =" "1" "border = "" 0 ""> <TR> <td bgcolor = '"& abgcolor &"'> $2 </table> <br> ")
Re. Pattern = "(\ [fly \]) (. *) (\ [\/fly \])"
StrContent = re. replace (strContent, "<marquee width =" "90%" "behavior =" "alternate" "scrollamount =" "3" "> $2 </marquee> ")
Re. Pattern = "(\ [move \]) (. *) (\ [\/move \])"
StrContent = re. Replace (strContent, "<MARQUEE scrollamount =" "3" "> $2 </marquee> ")
Re. pattern = "\ [GLOW = * ([0-9] *), * (# * [a-z0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/GLOW]"
StrContent = re. replace (strContent, "<table width =" "$1" "style =" "filter: glow (color = $2, strength = $3) ""> $4 </table> ")
Re. pattern = "\ [SHADOW = * ([0-9] *), * (# * [a-z0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/SHADOW]"
StrContent = re. replace (strContent, "<table width = $1 style =" "filter: shadow (color = $2, strength = $3)" "> $4 </table> ")

Re. Pattern = "(\ [I \]) (. [^ \ [] *) (\ [\/I \])"
StrContent = re. Replace (strContent, "<I >2 2 </I> ")
Re. Pattern = "(\ [u \]) (. [^ \ [] *) (\ [\/u \])"
StrContent = re. Replace (strContent, "<u> $2 </u> ")
Re. Pattern = "(\ [B \]) (. [^ \ [] *) (\ [\/B \])"
StrContent = re. Replace (strContent, "<B> $2 </B> ")
Re. Pattern = "(\ [fly \]) (. [^ \ [] *) (\ [\/fly \])"
StrContent = re. Replace (strContent, "<marquee> $2 </marquee> ")

Re. Pattern = "(\ [size = 1 \]) (. [^ \ [] *) (\ [\/size \])"
StrContent = re. Replace (strContent, "<font size =" "1" "> $2 </font> ")
Re. Pattern = "(\ [size = 2 \]) (. [^ \ [] *) (\ [\/size \])"
StrContent = re. Replace (strContent, "<font size =" "2" "> $2 </font> ")
Re. Pattern = "(\ [size = 3 \]) (. [^ \ [] *) (\ [\/size \])"
StrContent = re. Replace (strContent, "<font size =" "3" "> $2 </font> ")
Re. Pattern = "(\ [size = 4 \]) (. [^ \ [] *) (\ [\/size \])"
StrContent = re. Replace (strContent, "<font size =" "4" "> $2 </font> ")
Re. Pattern = "(\ [center \]) (. [^ \ [] *) (\ [\/center \])"
StrContent = re. Replace (strContent, "<center> $2 </center> ")
'Extension below
Re. Pattern = "(\ [li \]) (. [^ \ [] *) (\ [\/li \])"
StrContent = re. Replace (strContent, "<li >2 2 </li> ")
'Font background
Re. pattern = "(\ [fontbg = (. [^ \ [] *) \]) (. [^ \ [] *) (\ [\/fontbg \])"
StrContent = re. Replace (strContent, "<span style = background-color:" "$2" ">3 3 </span> ")
'Strikethrough
Re. Pattern = "(\ [strike \]) (. [^ \ [] *) (\ [\/strike \])"
StrContent = re. Replace (strContent, "<strike> $2 </strike> ")

Re. Pattern = "(\ [HTML \]) (. [^ \ [] *) (\ [\/HTML \])"
StrContent = re. replace (strContent, "<table width = '000000' border = '0' cellspacing = '0' cellpadding = '6' bgcolor = '" & abgcolor & "'> <td> <B> the content is the program code: </B> <br> $2 </td> </table> ")
Re. Pattern = "(\ [code \]) (. [^ \ [] *) (\ [\/code \])"
StrContent = re. replace (strContent, "<table width = '000000' border = '0' cellspacing = '0' cellpadding = '6' bgcolor = '" & abgcolor & "'> <td> <B> the content is the program code: </B> <br> $2 </td> </table> ")

 


StrContent = ChkBadWords (strContent)

Set re = Nothing
UBBCode = strContent
End function
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.