URL Spam Detector Function : sf-active
IMC / INFORMATION WARFARE MUNITIONS
sf-active :: indymedia
english | castellano | italian | Nederlands
download : documentation : support
irc : cvs : bugs : faq : servers
latest articles : sf-active sites
about sf-active
sf-active is a collection of object-oriented classes for content management, open publishing and news syndication. All the pages needed to run an indymedia site are distributed with the code

other links
indymedia codebases
indymedia global tech

software, politica e indymedia





printable version - email this article

URL Spam Detector Function
by johnk Saturday, Oct. 21, 2006 at 1:08 AM

This is a function that returns true if URLs make up a big portion of the post.

Add this to the spam_class.inc

    function too_many_urls( $str ) {
        $sansUrls = preg_replace( '/http:[a-zA-Z0-9.\\/]+?/', '', $str );
        $sansHref = preg_replace( '/href/', '', $sansUrls );
        $sansUrl = preg_replace( '/url/', '', $sansHref );
        $sansWww = preg_replace( '/www[a-zA-Z0-9.\\/]+?/', '', $sansUrl );
        if ((sizeof($sansWww)/sizeof($str)) > 0.5)
            return 1;
        else
            return 0;
    }
You can use it like this, just before return $ret:
        if ($this->too_many_urls( $_POST['article'] ))
            $ret = 1;

add your comments


LATEST COMMENTS ABOUT THIS ARTICLE
Listed below are the 10 latest comments of 1 posted about this article.
These comments are anonymously submitted by SF-IMC website visitors.
TITLE AUTHOR DATE
fix johnk Saturday, Oct. 21, 2006 at 1:44 AM
pick a theme:

Latest Newswire
Publish your news
View Latest Comments