Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners Cgi > Re: How to dete...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 9 Topic 1427 of 1496
Post > Topic >>

Re: How to detect if a text body contains forbidden words

by bo.berglund@[EMAIL PROTECTED] (Bo Berglund) Nov 20, 2007 at 06:39 PM

On Tue, 20 Nov 2007 08:25:15 -0500, "Lou Hernsen"
<lhernsen1015@[EMAIL PROTECTED]
> wrote:

>Hallo
>I'm just an amature perl writer..
>but I would think that using the m// (match) would help. somthing like
># $CONFIG{'Feedback'} = the body of the message, change to whatever it is
in
>the program
>if ($CONFIG{'Feedback'} =~  /href=|http:/i ) #i = ignore case
>{
>    # reject code goes here
>    exit;
>}
>
>As to preventing cusswords... good luck...
>you could do a string substitution manure is replaced by fertilizer
>
>s/manure/fertilizer/i;
>
>this way the offender never knows what words are being replaced and is
less
>likely to try to get around this code with words like schist, or phuque
or
>the like.. I think you get my drift.
>
>And I would do the word check right when the words are being parsed.
>Thats how I would do it, but then what do I know..
>I'm sure there are better ways... and that certain people on this list
will
>be quick to shoot me down
>while offering no help of there own... but I wanted to get my "good deed"
>for the day thing out of the way this morning ;)

Appreciated!

>hope it helps.
>Lou

Thanks,
I think it is a help in the right direction! :-)
I thought of adding one more checking function in the middle of the
sequence of the main function like this:

....
# Parse Form Contents
&parse_form;

# Reject spammers <== This is what I like to add
&spam_reject;

# Check Required Fields
&check_required;
....

Then I would have the new function doing something like this using
your example and the existing code for other checks:

sub spam_reject {
  if ($CONFIG{'Feedback'} =~  /href=|http:/i ) #i = ignore case
  {
      # reject code goes here
      push(@[EMAIL PROTECTED]
'*SPAM*');
  }

  if (@[EMAIL PROTECTED]
) {
      &error('spam_contents', @[EMAIL PROTECTED]
);
  }

}

Then I would add something like this to the error subroutine in the
middle of the error causes parsing:

   elsif ($error eq 'spam_contents') {
     print "<html>\n <head>\n <title>Error: SPAM</title>\n </head>\n";
     print "</head>\n <body";

     # Get Body Tag Attributes
     &body_attributes;

     # Close Body Tag
     print ">\n <center>\n\n";
     print " <h1>Error: **** SPAM! ****</h1>\n </center>\n\n";
     print "<p>The data you entered is considered SPAM!</p>\n";
     print "</body></html>\n";
   }

There is an exit at the end of the error subroutine already.

Do you think that this would work?


Bo Berglund
 




 9 Posts in Topic:
How to detect if a text body contains forbidden words
bo.berglund@[EMAIL PROTEC  2007-11-20 07:25:11 
Re: How to detect if a text body contains forbidden words
rcook@[EMAIL PROTECTED]   2007-11-20 19:58:50 
Re: How to detect if a text body contains forbidden words
lhernsen1015@[EMAIL PROTE  2007-11-20 08:25:15 
Re: How to detect if a text body contains forbidden words
bo.berglund@[EMAIL PROTEC  2007-11-20 18:39:25 
Re: How to detect if a text body contains forbidden words
bo.berglund@[EMAIL PROTEC  2007-11-20 19:01:08 
Re: How to detect if a text body contains forbidden words
bo.berglund@[EMAIL PROTEC  2007-11-20 22:15:33 
Re: How to detect if a text body contains forbidden words
bo.berglund@[EMAIL PROTEC  2007-11-20 18:45:10 
Re: How to detect if a text body contains forbidden words
noreply@[EMAIL PROTECTED]  2007-11-20 20:03:38 
Re: How to detect if a text body contains forbidden words
bo.berglund@[EMAIL PROTEC  2007-11-20 20:42:51 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 10:56:15 CST 2008.