By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,571 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,571 IT Pros & Developers. It's quick & easy.

Smilies filter with swear filter

P: 6
Hey all. I have a filter for my website that control the smilies. That part works lovely but i cant get a swear filter in to it. How do i do this. Here is my code
Expand|Select|Wrap|Line Numbers
  1. <%
  2. sub smilify(chatText) 
  3. dim smileys(10) 
  4. dim smileyGraphics(10) 
  5. smileys(0) = ":)" 
  6. smileys(1) = ":S" 
  7. smileys(2) = ";)"
  8. smileys(3) = [z(edited out profanity)]  
  9. smileyGraphics(0) = "<img src='smiley0.gif'>" 
  10. smileyGraphics(1) = "<img src='smiley1.gif'>" 
  11. smileyGraphics(2) = "<img src='smiley2.gif'>" 
  12. smileyGraphics(2) = "Word Blocked" 
  13. dim fixedText 
  14. fixedText = chatText
  15. for x = 0 to 9 
  16. fixedText = replace(fixedText, smileys(x), smileyGraphics(x)) 
  17. response.write "<!--  -->" & vbNewLine
  18. next 
  19. response.write fixedText & "<br>" & vbnewline
  20. end sub 
  21. %>
  22. </head>
  23.  
  24. <body>
  25. <% 
  26. While ((Repeat1__numRows <> 0) AND (NOT RSm.EOF)) 
  27. %>
  28.     <span class="style1"><strong><%=(RSm.Fields.Item("RSuser").Value)%></strong>:&nbsp;</span>
  29.     <%
  30.     dim chatMsg
  31. chatmsg=(RSm.Fields.Item("RSmessage").Value)
  32.  smilify(chatMsg)%>
  33.   <% 
  34.   Repeat1__index=Repeat1__index+1
  35.   Repeat1__numRows=Repeat1__numRows-1
  36.   RSm.MoveNext()
  37. Wend
  38. %>
Nov 11 '12 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,382
Line 12, you should use index 3, not 2.
Nov 12 '12 #2

P: 6
I had to redo the code but this is how its looking at the moment. its not totally working well.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. sub smilify(chatText) 
  3. dim smileys(10) 
  4. dim smileyGraphics(10)
  5. smileys(0) = ":)" 
  6. smileys(1) = ":S" 
  7. smileys(2) = ";)"
  8. smileys(3) = "8)"
  9. smileys(4) = ":D"
  10. smileys(5) = ":I"
  11. smileys(6) = ":'("
  12. smileys(7) = ":("
  13. smileys(8) = ":O"
  14. smileys(9) = ":P"
  15. smileys(10) = ":8"
  16. smileyGraphics(0) = "<img src='0.png'>" 
  17. smileyGraphics(1) = "<img src='1.png'>" 
  18. smileyGraphics(2) = "<img src='2.png'>" 
  19. smileyGraphics(3) = "<img src='3.png'>"
  20. smileyGraphics(4) = "<img src='4.png'>"
  21. smileyGraphics(5) = "<img src='5.png'>" 
  22. smileyGraphics(6) = "<img src='6.png'>"
  23. smileyGraphics(7) = "<img src='7.png'>" 
  24. smileyGraphics(8) = "<img src='8.png'>"
  25. smileyGraphics(9) = "<img src='9.png'>"
  26. smileyGraphics(10) = "<img src='10.png'>"
  27. dim fixedText 
  28. fixedText = chatText
  29. for x = 0 to 10 
  30. fixedText = replace(fixedText, smileys(x),smileyGraphics(x)) 
  31. response.write "<!--  -->" & vbNewLine
  32. next 
  33. response.write fixedText & "<br>" & vbnewline
  34. end sub 
  35. %>
  36. </head>
  37.  
  38. <body>
  39. <% 
  40. While ((Repeat1__numRows <> 0) AND (NOT RSm.EOF)) 
  41. %>
  42.     <span class="style1"><strong><img src="<%=(RSm.Fields.Item("RSlevel").Value)%>.png" width="20" height="20" /><%=(RSm.Fields.Item("RSuser").Value)%></strong>:</span><%
  43.  
  44.  Function ReplaceBadWords(InputComments) 
  45. Dim badChars, newChars, i
  46.  badChars = array("rubbish", "useless", "Poo") 
  47. newChars = InputComments
  48.  for i = 0 to uBound(badChars) 
  49. newChars = Replace(newChars, badChars(i), "") 
  50. Next 
  51. ReplaceBadWords = newChars 
  52. End function 
  53.  Dim chatMsg
  54.      chatMsg = ReplaceBadWords(RSm.Fields.Item("RSmessage").Value)
  55.  smilify(chatMsg)%>
  56.   <% 
  57.   Repeat1__index=Repeat1__index+1
  58.   Repeat1__numRows=Repeat1__numRows-1
  59.   RSm.MoveNext()
  60. Wend
  61. %>
Nov 12 '12 #3

Rabbit
Expert Mod 10K+
P: 12,382
It's not working well in what sense? Just saying it doesn't work is not very informative.
Nov 13 '12 #4

P: 6
As if some one puts like the 3 letter word that would appear in "Essex" It would block it mid word. I trying to get it so it dont block the word if its part of a word.
Nov 13 '12 #5

Rabbit
Expert Mod 10K+
P: 12,382
Then, you should check that the left character and right character, if there are any, are not letters themselves. One way, of many, to do this is to use a regular expression.
Nov 13 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.