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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.