From: henoheno Date: Sun, 22 Apr 2007 08:04:19 +0000 (+0900) Subject: List => Multiple lists X-Git-Url: http://git.osdn.net/view?p=pukiwiki%2Fpukiwiki_sandbox.git;a=commitdiff_plain;h=0804eeeb75480d620b89e325f6daaa1b99bd0173;hp=85e9b5a6cceb7a2226ca2a2b22c574ef90f793ff List => Multiple lists --- diff --git a/spam/spam.ini.php b/spam/spam.ini.php index cb95155..7729484 100644 --- a/spam/spam.ini.php +++ b/spam/spam.ini.php @@ -1,15 +1,31 @@ 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 // diff --git a/spam/spam.php b/spam/spam.php index 547a481..0850859 100644 --- a/spam/spam.php +++ b/spam/spam.php @@ -1,5 +1,5 @@ '#^(?:.*\.)?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; }