<?php
/**
- * NP_Blacklist(JP) ($Revision: 1.10 $)
+ * NP_Blacklist(JP) ($Revision: 1.11 $)
* by hsur ( http://blog.cles.jp/np_cles )
- * $Id: NP_Blacklist.php,v 1.10 2007-03-06 20:54:37 hsur Exp $
+ * $Id: NP_Blacklist.php,v 1.11 2007-04-07 05:56:40 hsur Exp $
*
* Based on NP_Blacklist 0.98
* by xiffy
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-include_once(dirname(__FILE__)."/blacklist/blacklist_lib.php");
+require_once(dirname(__FILE__)."/blacklist/blacklist_lib.php");
class NP_Blacklist extends NucleusPlugin {
function getName() {
return 'http://blog.cles.jp/np_cles/category/31/subcatid/11';
}
function getVersion() {
- return '1.1.0';
+ return '1.1.1';
}
function getDescription() {
- return '[$Revision: 1.10 $]<br />'.NP_BLACKLIST_description;
+ return '[$Revision: 1.11 $]<br />'.NP_BLACKLIST_description;
}
function supportsFeature($what) {
switch ($what) {
// handle SpamCheck event
function event_SpamCheck(& $data) {
- global $DIR_PLUGINS;
if (isset ($data['spamcheck']['result']) && $data['spamcheck']['result'] == true) {
// Already checked... and is spam
return;
break;
}
}
- $ipblock = ($data['spamcheck']['ipblock']) || ($data['spamcheck']['live']);
+ $ipblock = ($data['spamcheck']['ipblock'] == true ) || ($data['spamcheck']['live'] == true);
// Check for spam
$result = $this->blacklist($data['spamcheck']['type'], $data['spamcheck']['data'], $ipblock);
}
function blacklist($type, $testString, $ipblock = true) {
- global $DIR_PLUGINS, $member;
+ global $member;
if ($this->resultCache)
return $this->resultCache.'[Cached]';
//
// Modified by hsur
// http://blog.cles.jp
-// $Id: blacklist_lib.php,v 1.9 2007-03-06 20:54:37 hsur Exp $
+// $Id: blacklist_lib.php,v 1.10 2007-04-07 05:56:37 hsur Exp $
define('__WEBLOG_ROOT', dirname(dirname(realpath(__FILE__))));
define('__EXT', '/blacklist');
// check whether a string contains spam
// if it does, we return the rule that was matched first
- // whitelist\r if (pbl_checkIp('white')) {
+ // whitelist
+ if (pbl_checkIp('white')) {
return '';
}
// first line of defense; block notorious spammers
if ($ipblock) {
- if (pbl_checkIp()) {
+ if (pbl_checkIp()){
return "<b>".NP_BLACKLIST_ipBlocked."</b>: ".serverVar('REMOTE_ADDR')." (".serverVar('REMOTE_HOST').")";
}
}
return NP_BLACKLIST_ipListed." {$listedrbl[0]} ".NP_BLACKLIST_found." (Referer:{$ref})";
}
- if ($text && ($listedrbl = check_for_domainrbl($text))) {
+ if ($text && $listedrbl = check_for_domainrbl($text)) {
if ($ipblock) {
pbl_suspectIP($ipthreshold);
}
- return (NP_BLACKLIST_urlListed." {$listedrbl[0]} ({$listedrbl[1]})".NP_BLACKLIST_found);
+ return NP_BLACKLIST_urlListed." {$listedrbl[0]} ({$listedrbl[1]})".NP_BLACKLIST_found;
}
// w00t! it's probably not spam!
function pbl_checkIp($type = 'block') {
$remote_ip = trim(serverVar('REMOTE_ADDR'));
$filename = __WEBLOG_ROOT.__EXT.'/settings/'.$type.'ip.pbl';
- $block = false;
+ $match = false;
// already in ipblock?
if (file_exists($filename)) {
- $fp = fopen(__WEBLOG_ROOT.__EXT."/settings/blockip.pbl", "r");
+ $fp = fopen($filename, "r");
while ($line = trim(fgets($fp, 255))) {
if (pbl_netMatch($line, $remote_ip)) {
- $block = true;
+ $match = true;
}
}
fclose($fp);
fwrite($fp, "");
fclose($fp);
}
- return $block;
+ return $match;
}
function pbl_logRule($expression) {
if($type == 'white'){
$threshold = false;
}
- \r $blockfile = __WEBLOG_ROOT.__EXT.'/settings/'.$type.'ip.pbl';
+
+ $blockfile = __WEBLOG_ROOT.__EXT.'/settings/'.$type.'ip.pbl';
$filename = __WEBLOG_ROOT.__EXT.'/settings/suspects.pbl';
$count = 0;
$files = pbl_getlogfiles();
foreach( $files as $file )
@ unlink($file);
+ @ touch(__WEBLOG_ROOT.__EXT."/settings/blacklist.log");
+ @ chmod(__WEBLOG_ROOT.__EXT."/settings/blacklist.log", 0666);
break;
case 'ip' :
$filename = __WEBLOG_ROOT.__EXT."/settings/blockip.pbl";