OSDN Git Service

v1.1.1
authorhsur <hsur@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Sat, 7 Apr 2007 05:56:40 +0000 (05:56 +0000)
committerhsur <hsur@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Sat, 7 Apr 2007 05:56:40 +0000 (05:56 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@552 1ca29b6e-896d-4ea0-84a5-967f57386b96

trunk/NP_Blacklist/NP_Blacklist.php
trunk/NP_Blacklist/blacklist/blacklist_lib.php
trunk/NP_Blacklist/blacklist/help.html
trunk/NP_Blacklist/blacklist/index.php

index 0803f9a..7b2b57a 100644 (file)
@@ -1,9 +1,9 @@
 <?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
@@ -28,7 +28,7 @@
   * 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() {
@@ -41,10 +41,10 @@ class NP_Blacklist extends NucleusPlugin {
                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) {
@@ -108,7 +108,6 @@ class NP_Blacklist extends NucleusPlugin {
 
        // 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;
@@ -137,7 +136,7 @@ class NP_Blacklist extends NucleusPlugin {
                                        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);
@@ -159,7 +158,7 @@ class NP_Blacklist extends NucleusPlugin {
        }
 
        function blacklist($type, $testString, $ipblock = true) {
-               global $DIR_PLUGINS, $member;
+               global $member;
                if ($this->resultCache)
                        return $this->resultCache.'[Cached]';
 
index a13767e..c789fbf 100644 (file)
@@ -19,7 +19,7 @@
 //
 // 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');
@@ -52,13 +52,14 @@ function pbl_checkforspam($text, $ipblock = false, $ipthreshold = 10, $logrule =
        // 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').")";
                }
        }
@@ -117,11 +118,11 @@ function pbl_checkforspam($text, $ipblock = false, $ipthreshold = 10, $logrule =
                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!
@@ -390,13 +391,13 @@ function check_for_domainrbl($comment_text) {
 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);
@@ -405,7 +406,7 @@ function pbl_checkIp($type = 'block') {
                fwrite($fp, "");
                fclose($fp);
        }
-       return $block;
+       return $match;
 }
 
 function pbl_logRule($expression) {
@@ -440,7 +441,8 @@ function pbl_suspectIP($threshold, $remote_ip = '', $type = 'block') {
        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;
 
@@ -585,6 +587,8 @@ function pbl_resetfile($type) {
                        $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";
index c223a1e..51ed680 100644 (file)
@@ -6,6 +6,9 @@
        <li> [Fixed] IPアドレスの判定が不適切であった問題を修正</li>
        <li> [Changed] 正規表現判定の/m修飾子を削除</li>
        <li> [Changed] ソースコードから不要部分を削除</li>
+       
+       <li> [Fixed] 一部環境において管理画面でエラーが出る問題を修正</li>
+       <li> [Fixed] IPブロックがきちんと働いていなかったバグを修正</li>        
 </ul>
 
 <ul>
index 6406ebd..0625f86 100644 (file)
@@ -1,6 +1,4 @@
 <?php
-    require_once("blacklist_lib.php");
-       
     //
     // Nucleus Admin section;
     // Created by Xiffy