Function ReplaceBadWords(InputComments)
Dim badChars, newChars, i
Const Filename = "../Styles/arraytest.asp" ' file to read
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim FSO
set FSO = server.createObject("Scripting.FileSystemObject")
Dim Filepath
Filepath = Server.MapPath(Filename)
if FSO.FileExists(Filepath) Then
Set TextStream = FSO.OpenTextFile(Filepath, ForReading, False,TristateUseDefault)
Dim Contents
Contents = TextStream.ReadAll
Contents = LCase(Replace(Contents,vbCrlf,""))
'badChars = array(Contents)
badChars = Split(Contents, vbCrLf)
TextStream.Close
Set TextStream = nothing
end if
Set FSO = nothing
'create our array of bad words
'badChars = array("svordom1","svordom2","svordom3")
'**************
'**************
newChars = Lcase(InputComments)
for i = 0 to uBound(badChars)
newChars = Replace(newChars, badChars(i), "<Img Src=""../Bild/censur.gif"" >")
Next
ReplaceBadWords = newChars
End function
Textfilen:
fan
djävla
djävlar
Det bör väll inte ha någon skillnad om jag kallar filen txt eller asp?