Forum UBB Code Recommendation

Source: Internet
Author: User
Tags html encode

Copy codeThe Code is as follows:

<%
Dim param, smiles 'Param is the fully available mark of the UBB label. param = full is fully available. Otherwise, smiles, a label with a large footprint, is not supported.
Function UBBCode (content)
Dim n, I
'On error resume next
Set re = new regexp
Re. IgnoreCase = true
Re. global = true

Re. pattern = "\ [code \] (\ r \ n )? ([\ S \ S] + ?) \ [\/Code \]"
Set Matches = re. Execute (content)
Dim code ()
N = 0
If re. test (content) then codeb = true
If codeb then
For Each Match in Matches
Redim Preserve code (n)
Code (n) = Match. Value
N = n + 1
Next
For I = 0 to ubound (code)
If code (I) = "" then exit
Content = replace (content, code (I), "{code" & I &"}")
Next
End if

If param = "full" then
Re. pattern = "\ [html \] (\ r \ n )? ([\ S \ S] + ?) \ [\/Html \]"
Set Matches = re. Execute (content)
Dim html ()
N = 0
If re. test (content) then htmlb = true
If htmlb then
For Each Match in Matches
Redim Preserve html (n)
Html (n) = Match. Value
N = n + 1
Next
For I = 0 to ubound (html)
If html (I) = "" then exit
Content = replace (content, html (I), "{html" & I &"}")
Next
End if
End if
Content = gmt (content) 'ubb


If codeb then
For I = 0 to ubound (code)
If code (I) = "" then exit
Tcode=server.html encode (code (I ))
Content = replace (content, "{code" & I & "}", tcode)
Next
End if
'----- Process [html] in [code]
Re. pattern = "\ [html \] (\ r \ n )? ([\ S \ S] + ?) \ [\/Html \]"
Set Matches = re. Execute (content) 'execute search.
Dim html2 ()
N = 0
If re. test (content) then html2b = true
If html2b then
For Each Match in Matches 'iterate Matches collection.
Redim Preserve html2 (n)
Html2 (n) = Match. Value
N = n + 1
Next
For I = 0 to ubound (html2)
If html2 (I) = "" then exit
Content = replace (content, html2 (I), "{html2" & I &"}")
Next
End if

If param = "full" then
If htmlb then
For I = 0 to ubound (html)
If html (I) = "" then exit
Thtmlw.server.html encode (html (I ))
Content = replace (content, "{html" & I & "}", thtml)
Next
End if
End if

Re. Pattern = "(\ [code \]) (\ r \ n )? ([\ S \ S] + ?) (\ [\/Code \])"
Content = re. Replace (content, "<PRE class = CodeSamp> $3 </PRE> ")

If param = "full" then
Re. Pattern = "(\ [html \]) (\ r \ n )? ([\ S \ S] + ?) (\ [\/Html \])"
Content = re. replace (content, "<span> <TEXTAREA cols = 95 rows = 12> $3 </TEXTAREA> <br> <INPUT onclick = runCode () type = button value = run code> <input onclick = copyCode () type = button value = copy code> [Ctrl + A select all tips: you can modify some code first, then press run] </span> ")
End if

If html2b then
For I = 0 to ubound (html2)
If html2 (I) = "" then exit
Thtml2 = html2 (I)
Content = replace (content, "{html2" & I & "}", thtml2)
Next
End if

UBBCode = content
End function


Function gmt (strContent)

StrContent = HTMLfilter (strContent)

Dim re
Set re = new RegExp
Re. IgnoreCase = true
Re. Global = True


If param = "full" then
If not smiles then' smiley face Conversion

Re. Pattern = "(\ [em (\ d {1, 2}) \])"
StrContent = re. Replace (strContent, " ")

'Re. Pattern = ":\)"
'Strcontent = re. Replace (strContent, " ")
'Re. Pattern = ":\("
'Strcontent = re. Replace (strContent, " ")
'Re. Pattern = ": o"
'Strcontent = re. Replace (strContent, " ")
'Re. Pattern = ": D"
'Strcontent = re. Replace (strContent, " ")
'Re. Pattern = ";\)"
'Strcontent = re. Replace (strContent, " ")
'Re. Pattern = ": p"
'Strcontent = re. Replace (strContent, " ")
'Re. Pattern = ": cool :"
'Strcontent = re. Replace (strContent, " ")
'Re. Pattern = ": rolleyes :"
'Strcontent = re. Replace (strContent, " ")
'Re. Pattern = ": mad :"
'Strcontent = re. Replace (strContent, " ")
'Re. Pattern = ": eek :"
'Strcontent = re. Replace (strContent, " ")
'Re. Pattern = ": confused :"
'Strcontent = re. Replace (strContent, " ")
'Re. Pattern = ": cry :"
'Strcontent = re. Replace (strContent, " ")

End if

 

Re. Pattern = "(\ [IMG \]) (. *?) (\ [\/IMG \])"
StrContent = re. replace (strContent, "<a href = $2 target = _ blank> document. body. clientWidth-300) {this. height = (document. body. clientWidth-300) * this. height/this. width; this. width = document. body. clientWidth-300} "" galleryImg = no> </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 = (\ d +), (\ d +) \] (. *?) \ [\/MP]"
StrContent = re. replace (strContent, "<object align = middle classid = CLSID: required class = OBJECT id = MediaPlayer width = $1 height = $2> <param name = ShowStatusBar value =-1> <param name = playCount value = 10> <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 "" playCount = 10 width = $1 height = $2> </embed> </object> ")

'Mp3
Re. Pattern = "\ [MP3] (. *?) \ [\/MP3]"
StrContent = re. replace (strContent, "<object align = middle classid = CLSID: required class = OBJECT id = MediaPlayer width = 300 height = 180> <param name = ShowStatusBar value =-1> <param name = playCount value = 10> <param name = Filename value = "" $1 ""> <embed type = application/x-oleobject codebase = http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename = mp src = "" $1 "" playCount = 10 width = 300 height = 180> </embed> </object> ")


Re. Pattern = "\ [RM = (\ d +), (\ d +) \] (. *?) \ [\/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 = "(\ [FLASH \]) (. *?) (\ [\/FLASH \])"
StrContent = re. replace (strContent, "<OBJECT codeBase = http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 classid = clsid: d27CDB6E-AE6D-11cf-96B8-444553540000 width = 500 height = 400> <param name = movie VALUE = "" $2 ""> <param name = quality VALUE = high> <embed src = "" $2" "quality = high pluginspage = 'HTTP: // www.macromedia.com/go/getflashplayer' type = 'application/x-shockwave-flash' width = 500 height = 400> $2 </embed> </OBJECT> ")
Re. Pattern = "(\ [FLASH = (\ d +), (\ d +) \]) (. *?) (\ [\/FLASH \])"
StrContent = re. replace (strContent, "<OBJECT codeBase = http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 classid = clsid: d27CDB6E-AE6D-11cf-96B8-444553540000 width = $2 height = $3> <param name = movie VALUE = "" $4 ""> <param name = quality VALUE = high> <param name = menu value = false> <embed src = "" $4 "" quality = high menu = false pluginspage = 'HTTP: // www.macromedia.com/go/getflashplayer' type = 'application/x-shockwave-flash' width = $2 height = $3> $4 </embed> </OBJECT> ")


'Cyclic conversion quote
Re. Pattern = "(\ [QUOTE \]) (. *?) (\ [\/QUOTE \])"
While re. test (strContent)
StrContent = re. replace (strContent, "<blockquote> reference: Wend

Re. Pattern = "(\ [w \]) (. *?) (\ [\/W \])"
StrContent = re. replace (strContent, "<iframe frameborder = 1 ALIGN = CENTER width = 100% HEIGHT = 400 SCROLLING = yes src = $2> </iframe> <br> page: <a href = $2 target = _ blank> click here to visit </A> ")

End if 'large space tag

Re. Pattern = "(\ [ATTACHMENT = (.*?) \]) (. *?) (\ [\/ATTACHMENT \])"
StrContent = re. replace (strContent, "<p> <a href =" "$2" "TARGET = _ blank title =" "tip: "& chr (13) &" you can right-click Save As to download the file to your local machine ""> $3 </a> <p> ")

Re. Pattern = "(\ [URL \]) (. *?) (\ [\/URL \])"
StrContent = re. Replace (strContent, "<a href =" "$2" "TARGET = _ blank> $2 </A> ")
Re. Pattern = "(\ [URL = (http | https | ftp | rtsp | mms )(:\/\/)(.*?) \]) (. *?) (\ [\/URL \])"
StrContent = re. Replace (strContent, "<a href =" "$2 $3 $4" "TARGET = _ blank >$ 5 </A> ")

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

Re. pattern = "(^ | \ s | <br> | <p>) (http | https | ftp | rtsp | mms) (: \/) (\ S +)"
StrContent = re. Replace (strContent, "$1 <a target = _ blank href = $2 $3 $4 >4 4 </a> ")
Re. Pattern = "(^ | \ s | <br> | <p>) (www.) (\ S + )"
StrContent = re. Replace (strContent, "$1 <a target = _ blank href = http: // $2 $3> $2 $3 </a> ")

 

'Text Effect
Re. Pattern = "(\ [list \]) (. + ?) (\ [\/List \])"
StrContent = re. Replace (strContent, "<ul type = SQUARE> $2 </UL> ")
Re. Pattern = "(\ [list =) (A | 1) (\]) (. + ?) (\ [\/List \])"
StrContent = re. Replace (strContent, "<ol type = $2> $4 </OL> ")
Re. Pattern = "(\ [\ * \])"
StrContent = re. Replace (strContent, "<LI> ")

Re. Pattern = "(\ [color = (.*?) \]) (. *?) (\ [\/Color \])"
StrContent = re. Replace (strContent, "<font color = $2> $3 </font> ")
Re. Pattern = "(\ [# (. {6 }?) \]) (. *?) (\ [\/# \])"
StrContent = re. Replace (strContent, "<font color = # $2> $3 </font> ")
Re. Pattern = "(\ [font = (.*?) \]) (. *?) (\ [\/Font \])"
StrContent = re. Replace (strContent, "<font face = $2> $3 </font> ")
Re. Pattern = "(\ [align = (left | center | right) \]) (. *?) (\ [\/Align \])"
StrContent = re. Replace (strContent, "<div align = $2> $3 </div> ")

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 = "(\ [sup \]) (. *?) (\ [\/Sup \])"
StrContent = re. Replace (strContent, "<sup> $2 </sup> ")
Re. Pattern = "(\ [sub \]) (. *?) (\ [\/Sub \])"
StrContent = re. Replace (strContent, "<sub> $2 </sub> ")

Re. Pattern = "\ [size = ([+ |-]? [0-7]) \] (. *?) (\ [\/Size \])"
StrContent = re. Replace (strContent, "<font size = $1> $2 </font> ")

Re. Pattern = "(\ [center \]) (. *?) (\ [\/Center \])"
StrContent = re. Replace (strContent, "<center> $2 </center> ")

Set re = Nothing

Gmt = strContent
End function


Rem filters HTML code
Function HTMLfilter (fString)
If not isnull (fString) then
FString=server.html encode (fString)
FString = Replace (fString, CHR (9), "") 'tab
'Fstring = Replace (fString, CHR (34 ),""")'"
'Fstring = Replace (fString, CHR (39 ),"'")''
FString = Replace (fString, CHR (13), "") 'Carriage return is a 13 + 10
FString = Replace (fString, CHR (10) & CHR (10), "<P> ")'
FString = Replace (fString, CHR (10), "<BR> ")
'Fstring = Replace (fString, CHR (32), "") 'space
HTMLfilter = fString
End if
End function
%>
<%
Function isemail (strng)
Isemail = false
Dim regEx, Match 'create variables.
Set regEx = New RegExp 'create a regular expression object (stupid, huh ?)
RegEx. pattern = "^ \ w + (-\ w +) | (\. \ w +) * \ @ [A-Za-z0-9] + ((\. |-) [A-Za-z0-9] + )*\. [A-Za-z0-9] + $ "'sets pattern.
RegEx. IgnoreCase = true' Set case insensiti.pdf.
Set Match = regEx. Execute (strng) 'execute search.
If match. count then isemail = true
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.