help implimenting bad words filter

M

mark r

Hi 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
%>

<div id="scrollingbox">
<%
Do while not amanda_rsShow.EOF
%>
<p><strong><% Response.Write Server.HTMLEncode(amanda_rsShow("Name"))
%> :</strong>
<% Response.Write Server.HTMLEncode(amanda_rsShow("Msg")) %></p>
<%
amanda_rsShow.MoveNext
loop
%>
</div>

<%
'Reset server objects
amanda_rsShow.close
Set amanda_rsShow = Nothing
Set amanda_adocon = Nothing
%>



thanks guys
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top