SoFunction
Updated on 2025-03-03

Ubcode is simple and practical

<%
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
    =true
    =True

    ="\[IMG\](.[^\[]*)\[\/IMG\]"
    strContent=(strContent,"<img src=""$1"" border=""0""></img>")
    ="\[IMG=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/IMG\]"
strContent=(strContent,"<a href=""$3"" title=Click to see the full picture target=_blank><img src=""$3"" width=""$1"" height=""$2"" border=""0""></img></a>")

'Mixed pictures and texts
    ="\[PIC\](.[^\[]*)\[\/PIC\]"
    strContent=(strContent,"<img src=""$1"" border=""0"" align=""left""></img>")
    ="\[PIC=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/PIC\]"
strContent=(strContent,"<a href=""$3"" title=Click to see the full picture target=_blank><img src=""$3"" width=""$1"" height=""$2"" border=""0"" align=""left""></img></a>")

   

    ="\[FLASH=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/FLASH\]"
    strContent= (strContent,"<EMBED SRC=""$3"" width=""$1"" height=""$2""></EMBED>")
    ="\[FLASH\](.[^\[]*)\[\/FLASH\]"
    strContent= (strContent,"<EMBED SRC=""$1""></EMBED>")

    ="(\[URL\])(http:\/\/.[^\[]*)(\[\/URL\])"
    strContent= (strContent,"<A HREF=""$2"" TARGET=""_blank"">$2</A>")
    ="(\[URL\])(.[^\[]*)(\[\/URL\])"
    strContent= (strContent,"<A HREF=""http://$2"" TARGET=""_blank"">$2</A>")

    ="(\[EMAIL\])(mailto:\/\/.[^\[]*)(\[\/EMAIL\])"
    strContent= (strContent,"<A HREF=""$2"" TARGET=""_blank"">$2</A>")
    ="(\[EMAIL\])(.[^\[]*)(\[\/EMAIL\])"
    strContent= (strContent,"<A HREF=""MAILTO:$2"" TARGET=""_blank"">$2</A>")

    ="(\[URL=(http:\/\/.[^\[]*)\])(.[^\[]*)(\[\/URL\])"
    strContent= (strContent,"<A HREF=""$2"" TARGET=""_blank"">$3</A>")
    ="(\[URL=(.[^\[]*)\])(.[^\[]*)(\[\/URL\])"
    strContent= (strContent,"<A HREF=""http://$2"" TARGET=""_blank"">$3</A>")

  = "^(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")
  = "(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")
  = "[^>=""](http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")
  = "^(ftp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")
  = "(ftp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")
  = "[^>=""](ftp://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")
  = "^(rtsp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")
  = "(rtsp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")
  = "[^>=""](rtsp://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")
  = "^(mms://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")
  = "(mms://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")
  = "[^>=""](mms://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
 strContent = (strContent,"<img align=absmiddle src=/images/><a target=_blank href=$1>$1</a>")

 

    ="\[DIR=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/DIR]"
 strContent=(strContent,"<object classid=clsid:166B1BCA-3F9C-11CF-8075-444553540000 codebase=/pub/shockwave/cabs/director/#version=7,0,2,0 width=$1 height=$2><param name=src value=$3><embed src=$3 pluginspage=/shockwave/download/ width=$1 height=$2></embed></object>")
 ="\[QT=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/QT]"
 strContent=(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=/quicktime/>")
 ="\[MP=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/MP]"
 strContent=(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=/activex/controls/mplayer/en/#Version=5,1,52,701 flename=mp src=$3  width=$1 height=$2></embed></object>")
 ="\[RM=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/RM]"
 strContent=(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>")

 


    ="(\[color=(.[^\[]*)\])(.[^\[]*)(\[\/color\])"
    strContent=(strContent,"<font color=""$2"">$3</font>")
    ="(\[face=(.[^\[]*)\])(.[^\[]*)(\[\/face\])"
    strContent=(strContent,"<font face=""$2"">$3</font>")
    ="(\[align=(.[^\[]*)\])(.*)(\[\/align\])"
    strContent=(strContent,"<div align=""$2"">$3</div>")

    ="(\[QUOTE\])(.*)(\[\/QUOTE\])"
    strContent=(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></table><br>")
    ="(\[fly\])(.*)(\[\/fly\])"
    strContent=(strContent,"<marquee width=""90%"" behavior=""alternate"" scrollamount=""3"">$2</marquee>")
    ="(\[move\])(.*)(\[\/move\])"
    strContent=(strContent,"<MARQUEE scrollamount=""3"">$2</marquee>") 
    ="\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/GLOW]"
    strContent=(strContent,"<table width=""$1"" style=""filter:glow(color=$2, strength=$3)"">$4</table>")
    ="\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/SHADOW]"
 strContent=(strContent,"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")

    ="(\[i\])(.[^\[]*)(\[\/i\])"
    strContent=(strContent,"<i>$2</i>")
    ="(\[u\])(.[^\[]*)(\[\/u\])"
    strContent=(strContent,"<u>$2</u>")
    ="(\[b\])(.[^\[]*)(\[\/b\])"
    strContent=(strContent,"<b>$2</b>")
    ="(\[fly\])(.[^\[]*)(\[\/fly\])"
    strContent=(strContent,"<marquee>$2</marquee>")

    ="(\[size=1\])(.[^\[]*)(\[\/size\])"
    strContent=(strContent,"<font size=""1"">$2</font>")
    ="(\[size=2\])(.[^\[]*)(\[\/size\])"
    strContent=(strContent,"<font size=""2"">$2</font>")
    ="(\[size=3\])(.[^\[]*)(\[\/size\])"
    strContent=(strContent,"<font size=""3"">$2</font>")
    ="(\[size=4\])(.[^\[]*)(\[\/size\])"
    strContent=(strContent,"<font size=""4"">$2</font>")
    ="(\[center\])(.[^\[]*)(\[\/center\])"
    strContent=(strContent,"<center>$2</center>")
'The following extensions
    ="(\[li\])(.[^\[]*)(\[\/li\])"
    strContent=(strContent,"<li>$2</li>")
'Font background
    ="(\[fontbg=(.[^\[]*)\])(.[^\[]*)(\[\/fontbg\])"
    strContent=(strContent,"<span style=background-color:""$2"">$3</span>")
'Delete line
    ="(\[strike\])(.[^\[]*)(\[\/strike\])"
    strContent=(strContent,"<strike>$2</strike>")

    ="(\[HTML\])(.[^\[]*)(\[\/HTML\])"
strContent=(strContent,"<table width='100%' border='0' cellpacing='0' cellpadding='6' bgcolor='"&abgcolor&"'><td><b>The following content is the program code:</b><br>$2</td></table>")
 ="(\[code\])(.[^\[]*)(\[\/code\])"
strContent=(strContent,"<table width='100%' border='0' cellpacing='0' cellpadding='6' bgcolor='"&abgcolor&"'><td><b>The following content is the program code:</b><br>$2</td></table>")

 


    strContent=ChkBadWords(strContent)

    set re=Nothing
    UBBCode=strContent
end function
%>