From 05f616a8944a1362117166f60df0dc576f0dd061 Mon Sep 17 00:00:00 2001 From: henoheno Date: Thu, 1 Feb 2007 23:54:50 +0900 Subject: [PATCH] Simplify. Disable multiple items for glob, using array() --- spam.php | 22 +++++++++------------- spam/spam.php | 22 +++++++++------------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/spam.php b/spam.php index d05463a..039f083 100644 --- a/spam.php +++ b/spam.php @@ -1,5 +1,5 @@ '#^(?:.*\.)?example\.(?:com|net|org)$#', - // 'net-10.20' => '#^10\.20\.[0-9]+\.[0-9]+$#', // 10.20.12345.12 also matches - // ); if (file_exists(SPAM_INI_FILE)) { $blocklist = array(); require(SPAM_INI_FILE); + // $blocklist['badhost'] = array( + // '*.blogspot.com', // Blog services's subdomains (only) + // 'IANA-examples' => '#^(?:.*\.)?example\.(?:com|net|org)$#', + // ); foreach(array('goodhost', 'badhost') as $_list) { if (! isset($blocklist[$list])) continue; - foreach ($blocklist[$_list] as $key=>$value) { + foreach ($blocklist[$_list] as $key => $value) { if (is_string($key)) { - // Pre-defined regex $regexs[$_list][$key] = $value; } else { - // Glob to regex - $regexs[$_list][$value] = '/^' . generate_glob_regex($value) . '$/i'; + $regexs[$_list][$value] = + '/^' . generate_glob_regex($value, '/') . '$/i'; } } } @@ -695,7 +691,7 @@ function get_blocklist($list = '') } if ($list == '') { - return $regexs; + return $regexs; // ALL } else if (isset($regexs[$list])) { return $regexs[$list]; } else { diff --git a/spam/spam.php b/spam/spam.php index d05463a..039f083 100644 --- a/spam/spam.php +++ b/spam/spam.php @@ -1,5 +1,5 @@ '#^(?:.*\.)?example\.(?:com|net|org)$#', - // 'net-10.20' => '#^10\.20\.[0-9]+\.[0-9]+$#', // 10.20.12345.12 also matches - // ); if (file_exists(SPAM_INI_FILE)) { $blocklist = array(); require(SPAM_INI_FILE); + // $blocklist['badhost'] = array( + // '*.blogspot.com', // Blog services's subdomains (only) + // 'IANA-examples' => '#^(?:.*\.)?example\.(?:com|net|org)$#', + // ); foreach(array('goodhost', 'badhost') as $_list) { if (! isset($blocklist[$list])) continue; - foreach ($blocklist[$_list] as $key=>$value) { + foreach ($blocklist[$_list] as $key => $value) { if (is_string($key)) { - // Pre-defined regex $regexs[$_list][$key] = $value; } else { - // Glob to regex - $regexs[$_list][$value] = '/^' . generate_glob_regex($value) . '$/i'; + $regexs[$_list][$value] = + '/^' . generate_glob_regex($value, '/') . '$/i'; } } } @@ -695,7 +691,7 @@ function get_blocklist($list = '') } if ($list == '') { - return $regexs; + return $regexs; // ALL } else if (isset($regexs[$list])) { return $regexs[$list]; } else { -- 2.11.0