Help me fight SPAM!!

Discussion in 'PHP' started by sitefever, Sep 13, 2007.

  1. #1
    Would using "eregi" be the right way to do this?

    I am using this code to stop spammers from sending emails to me through a comment form on my site. Here's what I have:

    if (eregi('cialis', $tf_message)) {
        echo "<p><strong>Go get a real job and spam someone else!</strong></p>\n";
        $send = 0;
    }
    Code (markup):
    So far, with the code above, if the word "cialis" is anywhere in the message, it will not let them submit the form.

    How do I enter multiple values to trigger the form not to send? For example, if the message contains "cialis", "viagra" or "porn", the message should not be send.

    Even better, I would like to create a text file with all the triggers. I would like the code to check the values contained in file.txt, and if any of those values are found, the form will not send.

    Any ideas at all would be appreciated!!

    Thanks,

    John
     
    sitefever, Sep 13, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    
    $blacklist = 'file.txt';
    
    if (preg_match('/(' . implode('|', array_map('trim', file($blacklist))) . ')/i', $tf_message))
    {
        echo "<p><strong>Go get a real job and spam someone  else!</strong></p>\n";
        $send = 0;
    }
    
    
    PHP:

    Put each word in a new line.
     
    nico_swd, Sep 13, 2007 IP
    sitefever likes this.
  3. sitefever

    sitefever Banned

    Messages:
    782
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Awesome! Works like a charm. +rep added. I really appreciate the help.

    -J
     
    sitefever, Sep 13, 2007 IP