Print Page | Close Window

ASP Advice Please

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=14677
Printed Date: 30 March 2026 at 6:24am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP Advice Please
Posted By: bootcom
Subject: ASP Advice Please
Date Posted: 13 April 2005 at 3:06pm
Hi all,
 
I'm looking at creating a swear filter for my chat MOD. Usually I would get all of the swear filters from the database, convert them into an Array using .getRows() and looping through the array doing a replace on the message like so:
 

' Our user may not have specified any bad words or they may have
' deleted all words from the database. If this is the case then we
' need to make sure we check for it so we don't crash the system
' when the user writes a new chat line
 
' If there are no swear words to replace
If rsCommon.eof then
 
' Do whatever is needed here
 
' There are records to return so pull them out of the db and convert
' into an array using getRows()
Else
 
swearFilterArray = rsCommon.getRows()
 
For x = 0 to uBound(swearFilterArray, 2)
 
msg = replace(msg, swearFilterArray(1, x), swearFilterArray(2, x))
 
Next
 
' End the db record check
End If
 
' Close the recordset
rsCommon.close
 
That would replace the message no problem, however I want to log it in the system if the user tries to write swear words. With performance being key to this chat system I need to make sure I am doing everything I can to maintain its speed.
 
Would the following affect performance or is there a better way to search?
 

' Our user may not have specified any bad words or they may have
' deleted all words from the database. If this is the case then we
' need to make sure we check for it so we don't crash the system
' when the user writes a new chat line
 
' If there are no swear words to replace
If rsCommon.eof then
 
' Do whatever is needed here
 
' There are records to return so pull them out of the db and convert
' into an array using getRows()
Else
 
' Set a variable to hold the current msg value
strTempMsg = msg
 
swearFilterArray = rsCommon.getRows()
 
For x = 0 to uBound(swearFilterArray, 2)
 
msg = replace(msg, swearFilterArray(1, x), swearFilterArray(2, x))
 
Next
 
' End the db record check
End If
 
' Close the recordset
rsCommon.close
 
' Now we can do a check to see whether or not the message contained
' any swear words.
' If the variables differ, this means a swear word has been replaced.
' This means that we can update the database to say that the user
' entered a swear word
 
If strTempMsg <> msg then
' Do the update here
End If



Replies:
Posted By: C.P.A.
Date Posted: 27 April 2005 at 5:47pm
Nah don't worry too much, it won't have a too large affect, there is a better way though, however, that also depends on the rest of your script.

-------------
C.P.A. » The more you find out about the world, the more opportunities warmly welcome you.


Posted By: Lofty
Date Posted: 28 April 2005 at 3:04am
chats are only small bits of text.
the code you have above wont have any noticeable performance issues.
comparing text strings is almost as slow as comparing dates. but with an average of say 120-150 characters per string..  wont be a problem at all.


Posted By: bootcom
Date Posted: 04 May 2005 at 12:08am

If there is a better way I would like to hear it. I've created the chat so that each section is independent of each other but they all work together (if that makes sense)




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net