Donate / Donar / Doar / Donner / Spende | http://www.sfccp.net/wiki/Join
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
View article without comments

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


fix
by johnk Saturday, Oct. 21, 2006 at 1:44 AM

Sorry, I messed it up. Here's one that works:

    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 ((strlen($sansWww)/strlen($str)) < 0.5)
            return 1;
        else
            return 0;
    }

add your comments


pick a theme:

Latest Newswire
Publish your news
View Latest Comments