|
-
Feb 23rd, 2006, 09:10 AM
#1
Thread Starter
Fanatic Member
Help searching submitted text
Hi, I have had a problem with bots and spammers writing spam and such into my guestbook. I have decided to have my PHP script do a quick run through of key words and if it finds any, it ignores the submission.
Right now my code
PHP Code:
$subject = $mymessage;
$pattern = "/url/";
if (preg_match($pattern, $subject)) {
// Spam filter found something
$thankyou_block = "This message is considered spam>";
} else {
// Spam filter found nothing so enter it
.....
I can only search for the keyword "url", but I want to ba able to make a list and have it search for any of the words on the list, like "url,link,[/". How do I edit the code to do this. I have searched and searched but have not been able to find anything on the web. Please help.
-
Feb 23rd, 2006, 01:21 PM
#2
Re: Help searching submitted text
Unfortunatly mechanisms like yours are easy to circum-navigate. I recommend, that before submitting the post you use image validation. Generating images in PHP uis quite trivial compared to attempting to filter out huge lists of words and potentially produces false positives.
Check out this tutorial: http://www.zend.com/zend/tut/tutorial-mehmet1.php
If you still wnat to go the word search way then I recommend you construct an array of "bad words", loop through the array and search for each word in the string using the stripos() function, or for more powerful matach, (e.g: the word in isolation), use preg_match on each word. To search for a word in isolation you would use a regular expression like this:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|