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

[email protected] (Bo Berglund)
Newsgroups perl.beginners.cgi
Message-ID <[email protected]>
On Tue, 20 Nov 2007 18:39:25 +0100, Bo Berglund
<[email protected]> wrote:

>On Tue, 20 Nov 2007 08:25:15 -0500, "Lou Hernsen"
><[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(@ERROR,'*SPAM*');
>  }
>
>  if (@ERROR) {
>      &error('spam_contents', @ERROR);
>  }
>
>}
>
>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?
>

I tested it now but it did not work, I got the email out anyway....
What did I do wrong in the syntax above?

Bo Berglund
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.