Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - ASP Advice Please
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ASP Advice Please

 Post Reply Post Reply
Author
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Topic: ASP Advice Please
    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
Back to Top
C.P.A. View Drop Down
Newbie
Newbie


Joined: 26 April 2005
Location: Netherlands
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote C.P.A. Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Lofty View Drop Down
Newbie
Newbie
Avatar

Joined: 03 April 2005
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lofty Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post 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)

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.