On 26 Aug 2008, at 15:23, tedd wrote:
At 3:14 PM -0700 8/25/08, Jim Lucas wrote:
Here is the function that I added to a generic guest book script. It works great for me. I have a predefined list of sexual, pharmaceutical, rude, vulgar, etc... words that I have in the spamwords.dat file.

function is_spam($str) {
 $data = './data/spamwords.dat';
 $spamword = file($data);
 $str = strtolower($str);
 foreach ($spamword AS $word) {
   $word = trim($word);
   if ( ! empty($word) &&                             // Blank line
        strpos($word, 0, 1) != '#' &&                 // Comment line
        strpos($str, strtolower($word)) !== false ) { // Compare
     return true;
   }
 }
 return false;
}

Just setup the spamwords.dat file to have each word/string that you want to reject for separated on each line.

--
Jim Lucas


Will you share your spamwords.dat file? I get too excited trying to type them in myself. :-)

This reminds me (if I have my story correct) that recently a Christian web site had a similar filter except it filtered news they scrubbed off other site/sources. One of their routines checked for offensive words and then replaced them with PC words.

This receive national attention when their site changed Tyson Gay's name to Tyson Homosexual.

In my experience most spam can be blocked by case-insensitively checking for "[url" and "<a". There ain't many spam comments out there that don't include URLs.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to