<%
function UBBCode(strContent)
strContent= FilterJS(strContent)
strContent=replace(replace(strContent,"""",""),"'","")
strContent=nohtml(strContent)
strContent=server.htmlencode(strContent)
strContent=dvHTMLCode(strContent)
strContent=replace(strContent,"&amp;nbsp;"," ")
UBBCode=replace(strContent,vbcrlf,"<BR>")
end function

Function FilterJS(v)
if not isnull(v) then
dim t
dim re
dim reContent
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="(&#)"
t=re.Replace(v,"")
re.Pattern="(javascript)"
t=re.Replace(t,"&#106avascript")
re.Pattern="(jscript:)"
t=re.Replace(t,"&#106script:")
re.Pattern="(js:)"
t=re.Replace(t,"&#106s:")
're.Pattern="(value)"
't=re.Replace(t,"&#118alue")
re.Pattern="(about:)"
t=re.Replace(t,"about&#58")
re.Pattern="(file:)"
t=re.Replace(t,"file&#58")
re.Pattern="(document.cookie)"
t=re.Replace(t,"documents&#46cookie")
re.Pattern="(vbscript:)"
t=re.Replace(t,"&#118bscript:")
re.Pattern="(vbs:)"
t=re.Replace(t,"&#118bs:")
re.Pattern="(on(mouse|exit|error|click|key))"
t=re.Replace(t,"&#111n$2")
re.Pattern="(<script)"
t=re.Replace(t,"<&#115cript")
re.Pattern="(select)"
t=re.Replace(t,"&#115elect")
re.Pattern="(delete)"
t=re.Replace(t,"&#100elete")
re.Pattern="(update)"
t=re.Replace(t,"&#117pdate")
re.Pattern="(insert)"
t=re.Replace(t,"in&#115ert")
re.Pattern="( and )"
t=re.Replace(t,"")
re.Pattern="( or )"
t=re.Replace(t,"")
're.Pattern="(&#)"
't=re.Replace(t,"£¦#")
t= replace(t, ">", "&gt;",1,-1,1)
t = replace(t, "<", "&lt;",1,-1,1)
t = Replace(t, """", "",1,-1,1)
t = Replace(t, "%", "",1,-1,1)
t = Replace(t, "request", "",1,-1,1)
t = Replace(t, "=", "=",1,-1,1)
FilterJS=replace(t,"'","''")
set re=nothing
end if
End Function

function dvHTMLEncode(fString)
if not isnull(fString) then
    fString = replace(fString, ">", "&gt;")
    fString = replace(fString, "<", "&lt;")
    fString = Replace(fString, CHR(32), "&nbsp;")
    fString = Replace(fString, CHR(9), "&nbsp;")
    fString = Replace(fString, CHR(34), "&quot;")
    fString = Replace(fString, CHR(39), "&#39;")
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
    fString = Replace(fString, CHR(10), "<BR> ")

    dvHTMLEncode = fString
end if
end function

function dvHTMLCode(fString)
if not isnull(fString) then
    fString = replace(fString, "&gt;", "")
    fString = replace(fString, "&lt;", "")

    fString = Replace(fString,  "&nbsp;"," ")
    fString = Replace(fString, "&quot;", "")
    fString = Replace(fString, "&#39;", "")
    fString = Replace(fString, "</P><P> ","")
    fString = Replace(fString, "<BR> ", "")

    dvHTMLCode = fString
end if
end function

function nohtml(str)
  If Trim(str)<>"" then
    dim re
    Set re=new RegExp
    re.IgnoreCase =true
    re.Global=True
    re.Pattern="(\<.[^\<]*\>)"
    str=re.replace(str," ")
    re.Pattern="(\<\/[^\<]*\>)"
    str=re.replace(str," ")
    nohtml=str
    set re=Nothing
  Else
	nohtml=""
  End if
end function

%>
