Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8012
Modified Files:
serendipity_event_spamblock.php
Log Message:
introduced rbl based checking. many "open relays" are also open http proxys,
any spammer to my blog came from an listed proxy. so this may help a little.
Index: serendipity_event_spamblock.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- serendipity_event_spamblock.php 4 Sep 2004 18:56:36 -0000 1.4
+++ serendipity_event_spamblock.php 17 Sep 2004 11:59:29 -0000 1.5
@@ -13,6 +13,9 @@
@define('PLUGIN_EVENT_SPAMBLOCK_KILLSWITCH_NOTICE', 'This blog is in "Emergency Comment Blockage Mode", please come back another time');
@define('PLUGIN_EVENT_SPAMBLOCK_IPFLOOD', 'IP block interval');
@define('PLUGIN_EVENT_SPAMBLOCK_IPFLOOD_DESC', 'Only allow an IP to submit a comment every n minutes. Useful to prevent comment floods.');
+ @define('PLUGIN_EVENT_SPAMBLOCK_RBL', 'Block comments from RBL-listed hosts');
+ @define('PLUGIN_EVENT_SPAMBLOCK_RBL_DESC', 'Be careful with this feature. Avoid to choose an RBL that includes dialup-hosts.');
+ @define('PLUGIN_EVENT_SPAMBLOCK_RBL_NOTICE', 'SPAM Prevention detected that your host is listed as open relay. Comment not added.');
break;
}
@@ -29,7 +32,7 @@
$propbag->add('event_hooks', array(
'frontend_saveComment' => true
));
- $propbag->add('configuration', array('bodyclone', 'killswitch', 'ipflood'));
+ $propbag->add('configuration', array('bodyclone', 'killswitch', 'ipflood', 'rbl'));
}
function introspect_config_item($name, &$propbag)
@@ -56,9 +59,17 @@
$propbag->add('default', 2);
break;
+ case 'rbl':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_RBL);
+ $propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_RBL_DESC);
+ $propbag->add('default', 'bl.spamcop.net, sbl-xbl.spamhaus.org');
+ break;
+
default:
return false;
}
+
return true;
}
@@ -103,9 +114,27 @@
return false;
}
}
- }
- return true;
+ // Check for IP listed in RBL
+ // Partly based on work done bei James Seward (ja...@ja...)
+ if ( $this->get_config('rbl') != '' ) {
+ $rbls = explode(',', $this->get_config('rbl'));
+ // $remote = '81.70.69.193';
+ $remote = $_SERVER['REMOTE_ADDR'];
+ if (preg_match("/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/", $remote, $matches)) {
+ foreach ($rbls as $rbl) {
+ $rblhost = $matches[4] . "." . $matches[3] . "." . $matches[2] . "." . $matches[1] . "." . trim($rbl);
+ $resolved = gethostbyname($rblhost);
+ if ($resolved != $rblhost) {
+ $eventData = array('allow_comments' => false);
+ $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_RBL_NOTICE;
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
break;
default:
|