Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi there

I hope you are well, Larry.

 

I decided to re-visit my 'Contact us' page and review the spamscrubber.  I was having trouble getting the spamscrubber to fish out the '\n's and '\r's to the extent that I changed the blank spaces to letters:

 

function spam_scrubber($value) 
    {
    //Create spam scrubber array..............
    $very_bad = array('to:' , 'cc:' , 'bcc:' , 'content-type:' , 'mime-version' , 'multipart-mixed' , 'content-transfer-encoding:');
    //For loop comparing email text to bad words.......
    foreach ($very_bad as $v)
        {
        //Look for bad word using stripos to ID the characters in the string.  It will return a blank if found......
        if (stripos($value, $v) !== false)
            {
            return 'AA';
            }
        }
        
    $value = str_replace(array( "\r" , "\n" , "%0a" , "%0d"), 'BB' , $value);
    echo $value;
    return trim($value);
    }
 

which made it easier to see what was going on.  Thus my enquiry that included some '\n's and '\r's went through the email system WITH the '\n's and '\r's.  So I then changed the code to (in red):

function spam_scrubber($value) 
    {
    //Create spam scrubber array..............
    $very_bad = array('to:' , 'cc:' , 'bcc:' , 'content-type:' , 'mime-version' , 'multipart-mixed' , 'content-transfer-encoding:');
    //For loop comparing email text to bad words.......
    foreach ($very_bad as $v)
        {
        //Look for bad word using stripos to ID the characters in the string.  It will return a blank if found......
        if (stripos($value, $v) !== false)
            {
            return 'AA';
            }
        }
        
    $value = str_replace(array(
"\\r" , "\\n" , "%0a" , "%0d"), 'BB' , $value);
  
    return trim($value);
    }

 

and it works just fine.  Thought I should let you know.

 

Regards

 

Max

Share this post


Link to post
Share on other sites

I have also changed the criteria so:

 

$very_bad = array('to:' , 'cc:', 'bcc:', 'content-type:', 'mime-version', 'multipart-mixed', 'content-transfer-encoding:', 'sex', 'bitcoin', 'resource', '$', 'city', 'money', 'traffic', 'GetaBusinessLoan', 'bitcoin', 'ProFunding', 'BusinessLoan', 'einfac');

 

which has cut downthe deluge of spam that I used to get.

Share this post


Link to post
Share on other sites

...and I am killing off any emails in the first category as I don't want to receive them anyway....

$very_bad = array('to:' , 'cc:', 'bcc:', 'content-type:', 'mime-version', 'multipart-mixed', 'content-transfer-encoding:', 'sex', 'bitcoin', 'resource', '$', 'city', 'money', 'traffic', 'GetaBusinessLoan', 'bitcoin', 'ProFunding', 'BusinessLoan', 'einfac');
    foreach ($very_bad as $v)
        {
        if (stripos($value, $v) !== false)
            {
            die();
            }
        }

I don't know it that is bad programming practice to kill a program in mid-flow (like the dreaded BASIC GOTO command), but it does work!

Edited by Max
Spelling

Share this post


Link to post
Share on other sites

Thanks so much for sharing all that, Max! Kudos for your success in stopping more of the dreaded spam. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...