Quote:
Originally Posted by milkman
I have a guestbook on my site in ASP and as you would expect I get a lot of spammers submitting to it. I managed to change the script so that I have to approve every message before it goes on the site, so at least my visitors don't have a page full of Viagra adverts to look at.
To lower my workload in rejecting all these messages I want my submit page to automatically reject any message with a / symbol. This will cut out nearly all the spam as they nearly all post a URL with "http://" or "blahblah.com/viagra.html".
It currently rejects any message where the Name or Message boxes are empty.
Here's the code for that,
If sFirstName="" OR sMessage="" OR sHeard_About_Website="" Then
Response.write "Please click on the browser back button and fill in all required fields."
Is there a simple way to add any message containing / as something to reject?
I appreciate any help.
|
The following is what I use:
fnParse
'Create session variables at bottom of page so that session variables will always be empty on the first pass.
'In the if, and, then, statement name, email and comments must match to be redirected
If strComments = (Session("strComments")) and Session("strFName") = (strFName) and Session("strEmail") = (strEmail) Then Response.Redirect("Display.asp")
'pull our text from the form field, and parse it
'this function parses a string, filtering out the unwanted entries defined by yourself
Private Function fnParse()
'Declare our variable
Dim rex, match, matches
'Create an instance of the regexp object
Set rex = New regexp
'the almighty regexp pattern, put your swear words here, no spaces, seperated by a vertical
'break/bar ( | )
rex.Pattern = "
http://|href|Iraq|pisem|"
'global determines whether we search the whole string, or just
'be satisfied w/ the first hit we come across.
rex.Global = True
'ignorecase, self explanatory
rex.IgnoreCase = True
'execute the regexp on our text string
Set matches = rex.Execute(strComments)
'go thru the matches (unwanted words)
For Each match in matches
strComments = Response.Redirect("reject.asp")
Next
'Clean up
Set rex = Nothing
Exit Function
End Function