Re: comments function being spammed, how do I stop it?
| From: | tedd | Date: | Tue, 26 Aug 2008 14:23:24 +0000 |
| Subject: | Re: comments function being spammed, how do I stop it? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-278720@lists.php.net to get a copy of this message | ||
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.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com