OSDN Git Service

List => Multiple lists
authorhenoheno <henoheno>
Sun, 22 Apr 2007 08:04:19 +0000 (17:04 +0900)
committerhenoheno <henoheno>
Sun, 22 Apr 2007 08:04:19 +0000 (17:04 +0900)
spam/spam.ini.php
spam/spam.php

index cb95155..7729484 100644 (file)
@@ -1,15 +1,31 @@
 <?php
-// $Id: spam.ini.php,v 1.82 2007/04/12 14:31:53 henoheno Exp $
+// $Id: spam.ini.php,v 1.83 2007/04/22 08:04:19 henoheno Exp $
 // Spam-related setting
 //
 // Reference:
 //   Spamdexing http://en.wikipedia.org/wiki/Spamdexing
 
-// NOTE for goodhost and badhost:
+// NOTE:
 //  'example.org' prohibits both 'example.org' AND 'www.example.org'.
 //  '*.example.org' prohibits all subdomains and hosts EXCEPT 'www.example.org'.
 //  '.example.org' prohibits ALL FQDN related 'example.org'.
 
+// NOTE for badhost (only):
+//  'unique_name' = array('a.example.org', 'b.example.org') is treated as a group 'unique_name'.
+
+
+// List of the lists
+$blocklist['list'] = array(
+       'goodhost'              => FALSE,
+       'badhost A-1'   => TRUE,
+       'badhost A-2'   => TRUE,
+       'badhost B-1'   => TRUE,
+       'badhost B-2'   => TRUE,
+       'badhost C'             => TRUE,
+       'badhost'               => TRUE,
+);
+
+
 $blocklist['goodhost'] = array(
        'IANA-examples' => '#^(?:.*\.)?example\.(?:com|net|org)$#',
 
@@ -25,12 +41,10 @@ $blocklist['goodhost'] = array(
 
 );
 
-// NOTE for badhost (only):
-//  'unique_name' = array('a.example.org', 'b.example.org') is treated as a group 'unique_name'.
-$blocklist['badhost'] = array(
+// A: Sample setting of
+// Existing URI redirection or masking services
 
-       // A: Sample setting of
-       // Existing URI redirection or masking services
+$blocklist['badhost A-1'] = array(
 
        // A-1: General redirection services -- by HTML meta, HTML frame, JavaScript,
        // web-based proxy, DNS subdomains, etc
@@ -1212,6 +1226,9 @@ $blocklist['badhost'] = array(
        '*.zu5.net',
        'zuso.tw',
        '*.zwap.to',
+);
+
+$blocklist['badhost A-2'] = array(
 
        // A-2: Dynamic DNS, Dynamic IP services, DNS vulnerabilities, or another DNS cases
        //
@@ -1234,13 +1251,16 @@ $blocklist['badhost'] = array(
        //'*.zenno.info',
        //'.cm',        // 'Cameroon' ccTLD, sometimes used as typo of '.com'
                                // and all non-recorded domains redirect to 'agoga.com' now
+);
 
 
-       // B: Sample setting of:
-       // Jacked (taken advantage of) and cleaning-less sites
-       //
-       // Please notify us about this list with reason:
-       // http://pukiwiki.sourceforge.jp/dev/?BugTrack2%2F208
+// B: Sample setting of:
+// Jacked (taken advantage of) and cleaning-less sites
+//
+// Please notify us about this list with reason:
+// http://pukiwiki.sourceforge.jp/dev/?BugTrack2%2F208
+
+$blocklist['badhost B-1'] = array(
 
        // B-1: Web spaces
        //
@@ -1797,6 +1817,10 @@ $blocklist['badhost'] = array(
                '*.your-websites.net',
                '*.web-space.ws',
        ),
+);
+
+
+$blocklist['badhost B-2'] = array(
 
        // B-2: Jacked contents, something implanted
        // (e.g. some sort of blog comments, BBSes, forums, wikis)
@@ -1948,7 +1972,10 @@ $blocklist['badhost'] = array(
        'yasushi.site.ne.jp',   // One of mixedmedia.net'
        'youthpeer.org',
        '*.zenburger.com',
+);
+
 
+$blocklist['badhost C'] = array(
 
        // C: Sample setting of:
        // Exclusive spam domains
@@ -3568,7 +3595,6 @@ $blocklist['badhost'] = array(
        ),
 
 
-
        // C-2: Lonely domains (buddies not found yet)
        '.0721-4404.com',
        '.0nline-porno.info',   // by Timyr (timyr at narod.ru)
@@ -3721,7 +3747,10 @@ $blocklist['badhost'] = array(
                '.nana.co.il',
        ),
        '.mylexus.info',                // by Homer Simpson (simhomer12300 at mail.com), Redirect to Google
+);
+
 
+$blocklist['badhost'] = array(
        // D: Sample setting of
        // "third party in good faith"s
        //
index 547a481..0850859 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// $Id: spam.php,v 1.130 2007/04/11 13:13:33 henoheno Exp $
+// $Id: spam.php,v 1.131 2007/04/22 08:04:19 henoheno Exp $
 // Copyright (C) 2006-2007 PukiWiki Developers Team
 // License: GPL v2 or (at your option) any later version
 //
@@ -878,7 +878,16 @@ function get_blocklist($list = '')
                        //              '*.blogspot.com',       // Blog services's subdomains (only)
                        //              'IANA-examples' => '#^(?:.*\.)?example\.(?:com|net|org)$#',
                        //      );
-                       foreach(array('goodhost', 'badhost') as $_list) {
+                       if (isset($blocklist['list'])) {
+                               $regexs['list'] = & $blocklist['list'];
+                       } else {
+                               // Default
+                               $blocklist['list'] = array(
+                                       'goodhost' => FALSE,
+                                       'badhost'  => TRUE,
+                               );
+                       }
+                       foreach(array_keys($blocklist['list']) as $_list) {
                                if (! isset($blocklist[$_list])) continue;
                                foreach ($blocklist[$_list] as $key => $value) {
                                        if (is_array($value)) {
@@ -890,6 +899,7 @@ function get_blocklist($list = '')
                                                get_blocklist_add($regexs[$_list], $key, $value);
                                        }
                                }
+                               unset($blocklist[$_list]);
                        }
                }
        }
@@ -911,7 +921,7 @@ function get_blocklist_add(& $array, $key = 0, $value = '*.example.org')
        } else {
                $array[$value] = '/^' . generate_host_regex($value, '/') . '$/i';
        }
-} 
+}
 
 function is_badhost($hosts = array(), $asap = TRUE, & $remains)
 {
@@ -924,29 +934,32 @@ function is_badhost($hosts = array(), $asap = TRUE, & $remains)
        }
        if (empty($hosts)) return $result;
 
-       foreach (get_blocklist('goodhost') as $regex) {
-               $hosts = preg_grep_invert($regex, $hosts);
-       }
-       if (empty($hosts)) return $result;
-
-       foreach (get_blocklist('badhost') as $label => $regex) {
-               if (is_array($regex)) {
-                       $result[$label] = array();
-                       foreach($regex as $_label => $_regex) {
-                               if (is_badhost_avail($_label, $_regex, $hosts, $result[$label]) && $asap) {
-                                       break;
+       foreach(get_blocklist('list') as $key=>$value){
+               if ($value) {
+                       foreach (get_blocklist($key) as $label => $regex) {
+                               if (is_array($regex)) {
+                                       $result[$label] = array();
+                                       foreach($regex as $_label => $_regex) {
+                                               if (is_badhost_avail($_label, $_regex, $hosts, $result[$label]) && $asap) {
+                                                       break;
+                                               }
+                                       }
+                                       if (empty($result[$label])) unset($result[$label]);
+                               } else {
+                                       if (is_badhost_avail($label, $regex, $hosts, $result) && $asap) {
+                                               break;
+                                       }
                                }
                        }
-                       if (empty($result[$label])) unset($result[$label]);
                } else {
-                       if (is_badhost_avail($label, $regex, $hosts, $result) && $asap) {
-                               break;
+                       foreach (get_blocklist($key) as $regex) {
+                               $hosts = preg_grep_invert($regex, $hosts);
                        }
+                       if (empty($hosts)) return $result;
                }
        }
 
        $remains = $hosts;
-
        return $result;
 }