Topic: [Extension] URL Checker

URL Checker

Download Release 0.5.2  (DB @ http://keydogbb.info)
Download Release 0.5.3 (DB @ http://url-checker.org)

This extension queries an online database of URLs used  by spammers. Currently in use on a forum with 20k users.


http://keydogbb.info/img/urlchecker.png

<extension engine="1.0">
    <id>url_spam</id>
    <title>Disallowing spammers urls</title>
    <version>0.5.2</version>
    <description>Disallows users to use urls that are used by spammers and delete users which try to use these urls if they have less then 5 posts.</description>
    <author>Grez &amp; KeyDog</author>
    <minversion>1.3.4</minversion>
    <maxtestedon>1.4.1</maxtestedon>
    <install>
        <![CDATA[
if (!$forum_db->table_exists('url_spam'))
{
    $schema = array(
        'FIELDS'    =>    array(
            'user_id'        =>    array(
                'datatype'        =>    'int(7)',
                'allow_null'    =>    false
            ),
            'ip'        =>    array(
                'datatype'        =>    'VARCHAR(15)',
                'allow_null'    =>    false,
                'default'        =>    '\'0.0.0.0\'',
            ),
            'url'        =>    array(
                'datatype'        =>    'VARCHAR(150)',
                'allow_null'    =>    true,
                'default'        =>    '\'\''
            ),
            'time'        =>    array(
                'datatype'        =>    'DATETIME',
                'allow_null'    =>    false
            ),
            'type'        =>    array(
                'datatype'        =>    'VARCHAR(4)',
                'allow_null'    =>    false
            ),
        ),
        'PRIMARY KEY'    =>    array('url', 'type')
    );
    $forum_db->create_table('url_spam', $schema);
}
        ]]>
    </install>
    
    <uninstall>
        <![CDATA[
$forum_db->drop_table('url_spam');
        ]]>
    </uninstall>
    <hooks>
    <hook id="po_end_validation"><![CDATA[
if(!isset($_POST['preview'])) {

    function urlcheck($url, &$errors, $text = "") {
        global $ext_info, $forum_user, $forum_db, $forum_url;
    
        $query = 'http://www.keydogbb.info/url_spam.php?url='.urlencode($url);
        $remote_file = get_remote_file($query, 3);
        if($remote_file['content'] == "Y") {
            if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
                include $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
            else
                include $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';

            $query = array(
                'SELECT'    =>    'url',
                'FROM'        =>    'url_spam',
                'WHERE'        =>    'url = \''.$url.'\' AND type = \'post\''
            );
            $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
            if($forum_db->num_rows($result) == 0) {
                $query = array(
                   'INSERT'   => 'user_id, ip, url, time, type',
                   'INTO'     => 'url_spam',
                   'VALUES'   => '\''.$forum_user['id'].'\', \''.get_remote_address().'\', \''.$url.'\', NOW(), \'post\''
                );
                $forum_db->query_build($query) or error(__FILE__, __LINE__);
            }
            
            if($forum_user['num_posts'] < 5 && $forum_user['group_id'] != 2) {
                delete_user($forum_user['id'], true);
                message($lang_url_spam['User deleted']);
            } else {
                $errors[] = sprintf($lang_url_spam['URL disallowed'], $url, $url);
            }
        } else {
            $url = str_replace('"', '', $url);
        }

        if(!empty($text)) {
            return '[url='.$url.']'.$text.'[/url]';
        } else {
            return '[url]'.$url.'[/url]';
        }
    }

    $pattern = array();
    $pattern[] = '#\[url\]([^\[]*?)\[/url\]#e';
    $pattern[] = '#\[url=([^\[]+?)\](.*?)\[/url\]#e';

    $replace = array();
    $replace[] = 'urlcheck(\'$1\', $errors)';
    $replace[] = 'urlcheck(\'$1\', $errors, \'$2\')';

    $message = preg_replace($pattern, $replace, $message);

}
    ]]></hook>
    <hook id="pf_change_details_signature_validation"><![CDATA[
    $pattern = array();
    $pattern[] = '#\[url\]([^\[]*?)\[/url\]#e';
    $pattern[] = '#\[url=([^\[]+?)\](.*?)\[/url\]#e';

    $replace = array();
    $replace[] = 'urlcheck(\'$1\', $errors)';
    $replace[] = 'urlcheck(\'$1\', $errors, \'$2\')';

    if ($forum_config['o_make_links'] == '1')
    {
        if (!defined('FORUM_PARSER_LOADED')) {
            require FORUM_ROOT.'include/parser.php';
        }
        $_POST['signature'] = do_clickable($_POST['signature']);
    }
    
    $_POST['signature'] = preg_replace($pattern, $replace, $_POST['signature']);

    function urlcheck($url, &$errors, $text = "") {
        global $ext_info, $forum_user, $forum_db, $forum_url;

        $query = 'http://www.keydogbb.info/url_spam.php?url='.urlencode($url);
        $remote_file = get_remote_file($query, 3);
        if($remote_file['content'] == "Y") {
            if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
                include $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
            else
                include $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
        
            $query = array(
                'SELECT'    =>    'url',
                'FROM'        =>    'url_spam',
                'WHERE'        =>    'url = \''.$url.'\' AND type = \'sig\''
            );
            $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
            if($forum_db->num_rows($result) == 0) {
                $query = array(
                   'INSERT'   => 'user_id, ip, url, time, type',
                   'INTO'     => 'url_spam',
                   'VALUES'   => '\''.$forum_user['id'].'\', \''.get_remote_address().'\', \''.$url.'\', NOW(), \'sig\''
                );
                $forum_db->query_build($query) or error(__FILE__, __LINE__);
            }
            
            if($forum_user['num_posts'] < 5 && $forum_user['group_id'] != 2) {
                delete_user($forum_user['id'], true);
                message($lang_url_spam['User deleted']);
            } else {
                $errors[] = sprintf($lang_url_spam['URL disallowed'], $url, $url);
            }
        } else {
            $url = str_replace('"', '', $url);
        }

        if(!empty($text)) {
            return '[url='.$url.']'.$text.'[/url]';
        } else {
            return '[url]'.$url.'[/url]';
        }
    }
    ]]></hook>
    <hook id="ain_items_end"><![CDATA[
    ?>
    <div class="ct-set group-item<?php echo ++$forum_page['item_count'] ?>">
        <div class="ct-box">
            <h3 class="ct-legend hn"><span>URL spam checker</span></h3>
                <ul class="data-list">
     
    <?php
        $query = array(
            'SELECT'    => 'us.user_id, u.username, us.ip, us.url, DATE_FORMAT(us.time, \'%Y-%m-%d %H:%i:%s\') AS date, us.type',
            'FROM'        => 'url_spam AS us',
            'JOINS'        => array(
                array(
                    'LEFT JOIN'    => 'users AS u',
                    'ON'        => 'u.id = us.user_id',
                ),
            ),
            'ORDER BY'    => 'time DESC',
            'LIMIT'        => '50',
        );
        $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
        ?>
                            <li><table>
                            <tr><th style="width: 70px;">User</th><th style="width: 120px;">IP</th><th style="width: 200px;">URL</th><th style="width: 100px;">Date</th><th style="width: 50px;">Type</th></tr>
                            <?php
                            while($spam = $forum_db->fetch_assoc($result)) {
                                echo "<tr>";
                                    echo "<td><small>".((!empty($spam['username'])) ? "<a href=\"".forum_link($forum_url['user'], $spam['user_id'])."\">".forum_htmlencode($spam['username'])."</a>" : "DELETED")."</small></td>";
                                    echo "<td><small>".$spam['ip']."</small></td>";
                                    echo "<td><small>".$spam['url']."</small></td>";
                                    echo "<td><small>".$spam['date']."</small></td>";
                                    echo "<td><small>".$spam['type']."</small></td>";
                                echo "</tr>";
                            }
                            ?>
                            </table>
                            <center><small><i>Last 25 entries. Ordered by date.</i></small></center></li>
                        </ul>
                    </div>
                </div>
    <?php
    ]]></hooks>
</extension>
Extension Directory
Over 1.8 Million URLs checked in September 2012 with URL Checker extension.
Is your website being spammed? Send me the URL (entire post). Or post at http://url-checker.org

Re: [Extension] URL Checker

wow!!

Re: [Extension] URL Checker

Instruction:

If you have a persistent spammer who keeps posting spam links send me the whole code block (retrieved by 'edit' function) of the post/s to keydog@keydogbb.info and - depending on further occurences found in the web - it will be added to the database.

Extension Directory
Over 1.8 Million URLs checked in September 2012 with URL Checker extension.
Is your website being spammed? Send me the URL (entire post). Or post at http://url-checker.org

Re: [Extension] URL Checker

Over 1.3 Million URLs checked this month with this extension web-wide.

Extension Directory
Over 1.8 Million URLs checked in September 2012 with URL Checker extension.
Is your website being spammed? Send me the URL (entire post). Or post at http://url-checker.org

5

Re: [Extension] URL Checker

This extension checks over 1.3 Milion URLs. Is it lite for the server? Is this MOD charging heavily the server?

If you see any mistake in my posts, please PM me.