Jump to content

String searching


carlg

Recommended Posts

One of my websites allows public users to fill out a web based form and the form information gets sent on in an email.  This is totally getting spammed.  I figure I could create my own little spam filter.

 

All I need is a "Dirty word" list which I can easily make myself and the ability to use grep.

 

Let's say I place all of my dirty words in a file called dw.txt

 

The message part of the mail is stored in a variable called $message

 

If I was writing a shell script I could do something like the following:

 

if [ $(grep -f dw.txt $message) -ne "" ]
then
#THIS IS SPAM
fi

 

The only way I see to do this with php is to read the contents of the file into an array with the file command.

Loop through the array of dirty words and use preg_grep for each iteration.

 

Does anyone have a better way to do this than to loop through each line of the file?

 

Thanks for the help!

 

Carl

 

Link to comment
https://forums.phpfreaks.com/topic/118358-string-searching/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.