Barnaby Walters wrote:

Hi there!

my comments function for my website (at www.waterpigs.co.uk/php/phpTest.php) is being spammed, what would be your sugguestions of a way to deal with it? I was thinking of something to do with searching the strings of comments contained in the database for rude words, etc, but I'm unsure as to how to do it.

Any help would be appreciated greatly.

Thanks,
Barnaby
_____________________
www.waterpigs.co.uk
[EMAIL PROTECTED]





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

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


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

Reply via email to