Spam-X Ban Module

Friday, October 28 2005 @ 01:07 PM EDT

Contributed by: tomw

I created a little Spam-X action module that adds the IP of spammers to the Ban Plugin list thus blocking them from the site.

To use it just copy the code below and save it to a file called Ban.Action.class.php in your spam-x directory. Then add 256 to the Spam-x action variable.

This is aimed at those spammers who like to post hundreds of spams. The first will get caught and the rest of the attempts will result in a blank page.

<?php

/**
* File: Ban.Action.class.php
* This is the Ban Action for the Geeklog Spam-X Plug-in!
*
* Copyright (C) 2004-2005 by the following authors:
* Author Tom Willett tomw AT pigstye DOT net
*
* Licensed under GNU General Public License
*
*/

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

/**
* Action Class which just discards comment
*
* @author Tom Willett tomw@pigstye.net
*/
class Ban extends BaseCommand {
/**
* Constructor
*/
function Ban()
{
global $num;

$num = 256;
}

function execute($comment)
{
global $reslut, $_TABLES;

$result = db_query('INSERT INTO ' . $_TABLES['ban'] . ' SET bantype="REMOTE_ADDR", data="' . $_SERVER['REMOTE_ADDR'] . '"')
$result = 256;
SPAMX_log ('IP ' . $_SERVER['REMOTE_ADDR'] . ' added to ban list');
return 0;
}
}

?>

2 comments



http://gplugs.pigstye.net/article.php/20051028130736877