help implimenting bad words filter
am 03.06.2007 22:04:37 von markrushHi there... im on with my shoutbox again only now i want to add a bad
words filter. ive got the following code off a website and would
appreciate someone showing me how to integrate it into my code...
the bad words filter code is:
<%
Dim sMyString
sMyString = ReplaceBadWords("this is a rubbish crap bad word filter")
response.write sMyString
Function ReplaceBadWords(InputComments)
Dim badChars, newChars, sLength, sAttachtoEnd, x, i
'create an array of bad words that should be filtered
badChars = array("rubbish", "crap", "shit")
newChars = InputComments
'loop through our array of bad words
For i = 0 to uBound(badChars)
'get the length of the bad word
sLength=Len(badChars(i))
'we are going to keep the first letter of the bad word and replace all
the other
'letters with *, so we need to find out how many * to use
For x=1 to sLength-1
sAttachtoEnd=sAttachtoEnd & "*"
Next
'replace any occurences of the bad word with the first letter of it
and the
'rest of the letters replace with *
newChars = Replace(newChars, badChars(i), Left(badChars(i),1) &
sAttachtoEnd)
sAttachtoEnd=""
Next
ReplaceBadWords = newChars
End function
%>
and my shoutbox code is:
<%
'Dimension variables
Dim amanda_adocon
Dim amanda_strcon
Dim amanda_strSql
Dim amanda_rsShow
Dim amanda_rsAdd
'Create an ADO connection object
Set amanda_adocon = Server.CreateObject("ADODB.Connection")
amanda_strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("amanda.mdb")
%>
<%
Set amanda_rsShow = Server.CreateObject("ADODB.Recordset")
amanda_strSQL = "SELECT TOP 15 * FROM tblShoutbox ORDER BY ID DESC;"
amanda_rsShow.Open amanda_strSQL, amanda_strcon
%>
<%
Do while not amanda_rsShow.EOF
%>
<% Response.Write Server.HTMLEncode(amanda_rsShow("Name"))
%> :
<% Response.Write Server.HTMLEncode(amanda_rsShow("Msg")) %>
<%
amanda_rsShow.MoveNext
loop
%>
<%
'Reset server objects
amanda_rsShow.close
Set amanda_rsShow = Nothing
Set amanda_adocon = Nothing
%>
thanks guys