[geeklog-cvs] geeklog-1.3/plugins/spamx EditIP.Admin.class.php,NONE,1.1 EditIPofURL.Admin.class.php,NONE,1.1 IP.Examine.class.php,NONE,1.1 IPofUrl.Examine.class.php,NONE,1.1

dhaun at iowaoutdoors.org dhaun at iowaoutdoors.org
Wed Jan 26 05:27:49 EST 2005


Update of /var/cvs/geeklog-1.3/plugins/spamx
In directory www:/tmp/cvs-serv8091

Added Files:
	EditIP.Admin.class.php EditIPofURL.Admin.class.php 
	IP.Examine.class.php IPofUrl.Examine.class.php 
Log Message:
Added Tom's new SpamX modules for IP-based spam blocking.


--- NEW FILE: IP.Examine.class.php ---
<?php
/**
* File: BlackList.Examine.class.php
* This is the Personal BlackList Examine class for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
* Author        Tom Willett        tomw at pigstye.net
*
* Licensed under GNU General Public License
*/

/**
* Include Abstract Examine Class
*/
require_once($_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php');

/**
* Examines Comment according to Personal BLacklist
*
* @author Tom Willett tomw AT pigstye DOT net
*/

class IP extends BaseCommand {
    /**
     * No Constructor Use BaseCommand constructor
     */
    /**
     * Here we do the work
     */
    function execute($comment)
    {
        global $_CONF, $_TABLES, $_USER, $LANG_SX00, $result;

        /**
         * Include Blacklist Data
         */
        $result = DB_query("SELECT * FROM {$_TABLES['spamx']} WHERE name='IP'", 1);
        $nrows = DB_numRows($result);

        $ans = 0;
        for($i = 1;$i <= $nrows;$i++) {
            $A = DB_fetchArray($result);
            $val = $A['value'];
            if ($val = $_SERVER['REMOTE_ADDR'])) {
                $ans = 1; // quit on first positive match
                SPAMX_log($LANG_SX00['foundspam'] . $val . $LANG_SX00['foundspam2'] . $_USER['uid'] . $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR']);
                break;
            }
        }
        return $ans;
    }
}

?>
--- NEW FILE: IPofUrl.Examine.class.php ---
<?php
/**
* File: BlackList.Examine.class.php
* This is the Personal BlackList Examine class for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
* Author        Tom Willett        tomw at pigstye.net
*
* Licensed under GNU General Public License
*/

/**
* Include Abstract Examine Class
*/
require_once($_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php');

/**
* Examines Comment according to Personal BLacklist
*
* @author Tom Willett tomw AT pigstye DOT net
*/

class IPofUrl extends BaseCommand {
    /**
     * No Constructor Use BaseCommand constructor
     */
    /**
     * Here we do the work
     */
    function execute($comment)
    {
        global $_CONF, $_TABLES, $_USER, $LANG_SX00, $result;

        /**
         * Check for IP of url in blacklist
         */
        /*
        * regex to find urls $2 = fqd
        */
        $regx = '(ftp|http|file)://([^/\\s]+)';
        $num = preg_match_all("#{$regx}#",$comment,$urls);

        $result = DB_query("SELECT * FROM {$_TABLES['spamx']} WHERE name='IPofUrl'", 1);
        $nrows = DB_numRows($result);

        $ans = 0;
        for($j = 1;$j <= $nrows;$j++) {
            $A = DB_fetchArray($result);
            $val = $A['value'];
            for ($i=0;$i<$num;$i++) {
              $ip = gethostbyname($urls[2][$i]);
              if ($val == $ip) {
                $ans = 1; // quit on first positive match
                SPAMX_log($LANG_SX00['foundspam'] . $urls[2][$i] . $LANG_SX00['foundspam2'] . $_USER['uid'] . $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR']);
                break;
              }
            }
            if ($ans == 1) {
              break;
            }
        }
        return $ans;
    }
}

?>
--- NEW FILE: EditIP.Admin.class.php ---
<?php
/**
* File: EditIP.Admin.class.php
* This is the Edit IPBlacklist Module for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
* Author        Tom Willett        tomw at pigstye.net
*
* Licensed under GNU General Public License
*/

/**
* Personal Black List Editor
*/

require_once($_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php');

class EditIP extends BaseAdmin {
    /**
     * Constructor
     */
    function display()
    {
        global $_CONF, $_GET, $_POST, $_TABLES, $LANG_SX00;

        require_once $_CONF['path'] . 'plugins/spamx/rss.inc.php';

        $action = COM_applyFilter($_GET['action']);
        if (empty($action)) {
            $action = COM_applyFilter($_POST['paction']);
        }

        $entry = COM_applyFilter($_GET['entry']);
        if (empty($entry)) {
            $entry = COM_applyFilter($_POST['pentry']);
        }

        if ($action == 'delete') {
            $result = DB_query('DELETE FROM ' . $_TABLES['spamx'] . ' where name="IP" AND value="' . $entry . '"');
        } elseif ($action == $LANG_SX00['addentry']) {
            if ($entry != "") {
                $result = DB_query('INSERT INTO ' . $_TABLES['spamx'] . ' VALUES ("IP","' . $entry . '")');
            }
        } elseif ($action == $LANG_SX00['addcen']) {
            foreach($_CONF['censorlist'] as $entry) {
                $result = DB_query('INSERT INTO ' . $_TABLES['spamx'] . ' VALUES ("IP","' . $entry . '")');
            }
        }

        $display = '<hr><p><b>';
        $display .= $LANG_SX00['pblack'];
        $display .= '</b></p><ul>';
        $result = DB_query('SELECT * FROM ' . $_TABLES['spamx'] . ' WHERE name="IP"');
        $nrows = DB_numRows($result);
        for($i = 1;$i <= $nrows;$i++) {
            $A = DB_fetchArray($result);
            $e = $A['value'];
            $display .= '<li><a href="' . $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=EditIP&action=delete&entry=' . urlencode($e) . '">' . $e . '</a></li>';
        }
        $display .= '</ul><p>' . $LANG_SX00['e1'] . '</p>';
        $display .= '<p>' . $LANG_SX00['e2'] . '</p>';
        $display .= '<form method="post" action="' . $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=EditIP">';
        $display .= '<input type="text" size ="30" name="pentry">   ';
        $display .= '<input type="Submit" name="paction" value="' . $LANG_SX00['addentry'] . '">';
        $display .= '</form>';
        return $display;
    }

    function link()
    {
        return "Edit IP Blacklist";
    }
}

?>
--- NEW FILE: EditIPofURL.Admin.class.php ---
<?php
/**
* File: EditIP.Admin.class.php
* This is the Edit IPBlacklist Module for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
* Author        Tom Willett        tomw at pigstye.net
*
* Licensed under GNU General Public License
*/

/**
* Personal Black List Editor
*/

require_once($_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php');

class EditIPofUrl extends BaseAdmin {
    /**
     * Constructor
     */
    function display()
    {
        global $_CONF, $_GET, $_POST, $_TABLES, $LANG_SX00;

        require_once $_CONF['path'] . 'plugins/spamx/rss.inc.php';

        $action = COM_applyFilter($_GET['action']);
        if (empty($action)) {
            $action = COM_applyFilter($_POST['paction']);
        }

        $entry = COM_applyFilter($_GET['entry']);
        if (empty($entry)) {
            $entry = COM_applyFilter($_POST['pentry']);
        }

        if ($action == 'delete') {
            $result = DB_query('DELETE FROM ' . $_TABLES['spamx'] . ' where name="IPofUrl" AND value="' . $entry . '"');
        } elseif ($action == $LANG_SX00['addentry']) {
            if ($entry != "") {
                $result = DB_query('INSERT INTO ' . $_TABLES['spamx'] . ' VALUES ("IPofUrl","' . $entry . '")');
            }
        } elseif ($action == $LANG_SX00['addcen']) {
            foreach($_CONF['censorlist'] as $entry) {
                $result = DB_query('INSERT INTO ' . $_TABLES['spamx'] . ' VALUES ("IPofUrl","' . $entry . '")');
            }
        }

        $display = '<hr><p><b>';
        $display .= $LANG_SX00['pblack'];
        $display .= '</b></p><ul>';
        $result = DB_query('SELECT * FROM ' . $_TABLES['spamx'] . ' WHERE name="IPofUrl"');
        $nrows = DB_numRows($result);
        for($i = 1;$i <= $nrows;$i++) {
            $A = DB_fetchArray($result);
            $e = $A['value'];
            $display .= '<li><a href="' . $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=EditIPofUrl&action=delete&entry=' . urlencode($e) . '">' . $e . '</a></li>';
        }
        $display .= '</ul><p>' . $LANG_SX00['e1'] . '</p>';
        $display .= '<p>' . $LANG_SX00['e2'] . '</p>';
        $display .= '<form method="post" action="' . $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=EditIPofUrl">';
        $display .= '<input type="text" size ="30" name="pentry">   ';
        $display .= '<input type="Submit" name="paction" value="' . $LANG_SX00['addentry'] . '">';
        $display .= '</form>';
        return $display;
    }

    function link()
    {
        return "Edit IP of Url Blacklist";
    }
}

?>



More information about the geeklog-cvs mailing list