Ok du kan ligge de to funktioner helt nede i bunden af din fil, eks på den fil som gemmer i db'en dog uden database connection.
<%
'...
str = Trim(Request.Form("tagtekst"))
str = RemoveHTML(str)
str = makeLinks(str)
if len(str) > 500 then
'For lang
end if
str = Replace(str, "'", "''")
SQL = "INSERT INTO tagwall (tekst) VALUES ('" & str & "')"
Conn.Execute(SQL)
' Funtioner her:
Function RemoveHTML( strInputText )
TAGLIST = ";!--;!DOCTYPE;A;ACRONYM;ADDRESS;APPLET;AREA;B;BASE;BASEFONT;" &_
"BGSOUND;BIG;BLOCKQUOTE;BODY;BR;BUTTON;CAPTION;CENTER;CITE;CODE;" &_
"COL;COLGROUP;COMMENT;DD;DEL;DFN;DIR;DIV;DL;DT;EM;EMBED;FIELDSET;" &_
"FONT;FORM;FRAME;FRAMESET;HEAD;H1;H2;H3;H4;H5;H6;HR;HTML;I;IFRAME;IMG;" &_
"INPUT;INS;ISINDEX;KBD;LABEL;LAYER;LAGEND;LI;LINK;LISTING;MAP;MARQUEE;" &_
"MENU;META;NOBR;NOFRAMES;NOSCRIPT;OBJECT;OL;OPTION;P;PARAM;PLAINTEXT;" &_
"PRE;Q;S;SAMP;SCRIPT;SELECT;SMALL;SPAN;STRIKE;STRONG;STYLE;SUB;SUP;" &_
"TABLE;TBODY;TD;TEXTAREA;TFOOT;TH;THEAD;TITLE;TR;TT;U;UL;VAR;WBR;XMP;"
Const BLOCKTAGLIST = ";APPLET;EMBED;FRAMESET;HEAD;NOFRAMES;NOSCRIPT;OBJECT;SCRIPT;STYLE;"
Dim nPos1, nPos2, nPos3
Dim strResult, strTagName, bRemove, bSearchForBlock
Dim runNo, AttackLimit, strRef
runNo = 1
AttackLimit = 5
strResult = strInputText
do
runNo = runNo + 1
strRef = strResult
strText = strRef
strResult = ""
nPos1 = InStr(strText, "<")
Do While nPos1 > 0
nPos2 = InStr(nPos1 + 1, strText, ">")
If nPos2 > 0 Then
strTagName = Mid(strText, nPos1 + 1, nPos2 - nPos1 - 1)
strTagName = Replace(Replace(strTagName, vbCr, " "), vbLf, " ")
nPos3 = InStr(strTagName, " ")
If nPos3 > 0 Then
strTagName = Left(strTagName, nPos3 - 1)
End If
If Left(strTagName, 1) = "/" Then
strTagName = Mid(strTagName, 2)
bSearchForBlock = False
Else
bSearchForBlock = True
End If
If InStr(1, TAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then
bRemove = True
If bSearchForBlock Then
If InStr(1, BLOCKTAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then
nPos2 = Len(strText)
nPos3 = InStr(nPos1 + 1, strText, "</" & strTagName, vbTextCompare)
If nPos3 > 0 Then
nPos3 = InStr(nPos3 + 1, strText, ">")
End If
If nPos3 > 0 Then
nPos2 = nPos3
End If
End If
End If
Else
bRemove = False
End If
If bRemove Then
strResult = strResult & Left(strText, nPos1 - 1)
strText = Mid(strText, nPos2 + 1)
Else
strResult = strResult & Left(strText, nPos1)
strText = Mid(strText, nPos1 + 1)
End If
Else
strResult = strResult & strText
strText = ""
End If
nPos1 = InStr(strText, "<")
Loop
strResult = strResult & strText
loop until (strRef = strResult) OR (runNo = AttackLimit)
if (runNo >= AttackLimit) then
strResult = "...text removed..."
end if
RemoveHTML = strResult
End Function
Function makeLinks(strInput)
Set objRegExpHTTP1 = New RegExp
Set objRegExpHTTP2 = New RegExp
Set objRegExpEMail = New RegExp
objRegExpHTTP1.Pattern = "(http|ftp)(:\/\/[\w\._-]+\.[\w\._-]+\S*)"
objRegExpHTTP2.Pattern = "(^|[^\/])(www[^\.\s]?\.[\w\._-]+\.[A-Za-z]{2,3}[a-z0-9\.\-\/]{0,})"
objRegExpEMail.Pattern = "([\w\._-]+@[\w\._-]+\.[A-Za-z]{2,3}\S*)"
objRegExpHTTP1.Global = True
objRegExpHTTP2.Global = True
objRegExpEMail.Global = True
objRegExpHTTP1.IgnoreCase = True
objRegExpHTTP2.IgnoreCase = True
objRegExpEMail.IgnoreCase = True
strOutput = objRegExpEMail.Replace(strInput, " <a href='mailto:$1'>$1</a> ")
strOutput = objRegExpHTTP1.Replace(strOutput, "<a href='$1$2' target='_blank'>$1$2</a> ")
strOutput = objRegExpHTTP2.Replace(strOutput, " $1<a href='
http://$2' target='_blank'>$2</a>")
Set objRegExpHTTP2 = Nothing
set objRegExpHTTP1 = Nothing
Set objRegExpEMail = Nothing
makeLinks = strOutput
End Function
%>