Thread: Spam Checking
View Single Post
  #1 (permalink)  
Old 01-18-2006, 03:17 AM
clancey clancey is offline
New Pligger
 
Join Date: Jan 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Spam Checking

I do not know if I should be posting in this section. . . but I incorporated a routine in the libs/link.php file to do an surbl check on the link for a news article. It can also check the contents of the user-supplied comment for a spam link.

To start, I added the following switch to config.php

Code:
define('CHECK_SPAM', true);
I added the following function to libs/link.php:

Code:
        function check_spam($text ) {
                //get site names found in body of passed text
                $regex_url   = "/(www\.)([^\/\"<\s]*)/im";
                $mk_regex_array = array();
                preg_match_all($regex_url, $text, $mk_regex_array);

                for( $cnt=0; $cnt < count($mk_regex_array[2]); $cnt++ ) {
                        $domain_to_test = rtrim($mk_regex_array[2][$cnt],"\\");

                        if (strlen($domain_to_test) > 3)
                        {
                                $domain_to_test = $domain_to_test . ".multi.surbl.org";
                                if( strstr(gethostbyname($domain_to_test),'127.0.0')) {
                                        return true;
                                }
                        }
                }
                return false;
        }

It can handle the full comment or just the URL being passed. I implemented it to just look at that by adding a check to the get function:

Code:
//              # spam check -- return invalud URL if spam
                if( CHECK_SPAM && $this->check_spam( $url))
                       { $this->valid = false; return; }
This code is adapted from NP_Blacklist which is used by the nucleus CMS. It will be easy to also adapt a local blacklist if this is of interest.

The downside is this takes a little longer to do the domain check on a URL link.
The upside is it reduces the workload for the admin and could lessen the amount of spam being placed in the system.

Should I continue?
Reply With Quote