help implimenting bad words filter

Discussion in 'ASP General' started by mark r, Jun 3, 2007.

  1. mark r

    mark r Guest

    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
     
    mark r, Jun 3, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Java Buai

    Implimenting Interfaces

    Java Buai, Feb 23, 2006, in forum: Java
    Replies:
    4
    Views:
    436
    Ian Shef
    Mar 16, 2006
  2. Richard Heathfield
    Replies:
    7
    Views:
    395
    Barry Schwarz
    Oct 5, 2003
  3. Guest

    Python-implimenting-valueweb

    Guest, Apr 1, 2006, in forum: Python
    Replies:
    0
    Views:
    244
    Guest
    Apr 1, 2006
  4. rantingrick
    Replies:
    44
    Views:
    1,304
    Peter Pearson
    Jul 13, 2010
  5. Bishnu Das
    Replies:
    1
    Views:
    407
    John Mettraux
    Mar 24, 2008
Loading...

Share This Page