OSDN Git Service

is_badhost() testing
authorhenoheno <henoheno>
Thu, 23 Nov 2006 02:05:03 +0000 (11:05 +0900)
committerhenoheno <henoheno>
Thu, 23 Nov 2006 02:05:03 +0000 (11:05 +0900)
spam.php
spam/spam.php

index a601b4b..bf220d0 100644 (file)
--- a/spam.php
+++ b/spam.php
@@ -1,5 +1,5 @@
 <?php
-// $Id: spam.php,v 1.27 2006/11/23 01:27:56 henoheno Exp $
+// $Id: spam.php,v 1.28 2006/11/23 02:05:03 henoheno Exp $
 // Copyright (C) 2006 PukiWiki Developers Team
 // License: GPL v2 or (at your option) any later version
 
@@ -413,10 +413,26 @@ function is_badhost($host = '')
 
        if (! isset($blocklist_regex)) {
                $blocklist = array(
+                       // Well-known
                        '.blogspot.com',
+
+                       // 2006-11 dev
+                       'wwwtahoo.com',
+
+                       // 2006/11/19 17:50 dev
+                       '.google0site.org',
+                       '.bigpricesearch.org',
+                       '.osfind.org',
+                       '.bablomira.biz',
                );
+
+               $blocklist_regex = array();
                foreach ($blocklist as $part) {
-                       $blocklist_regex[] = '#\b' . preg_quote($part, '#') . '$#';
+                       if ($part[0] === '.') {
+                               $blocklist_regex[] = '#' . preg_quote($part, '#') . '$#';
+                       } else {
+                               $blocklist_regex[] = '#^(.*\.)?' . preg_quote($part, '#') . '$#';
+                       }
                }
        }
 
@@ -433,17 +449,6 @@ function is_badhost($host = '')
 // Simple/fast spam check
 function is_uri_spam($target = '')
 {
-       static $blocklist = array(
-               '.blogspot.com',
-       );
-       static $blocklist_regex;
-
-       if (! isset($blocklist_regex)) {
-               foreach ($blocklist as $part) {
-                       $blocklist_regex[] = '#\b' . preg_quote($part, '#') . '$#';
-               }
-       }
-
        $is_spam = FALSE;
        $urinum = 0;
 
index a601b4b..bf220d0 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// $Id: spam.php,v 1.27 2006/11/23 01:27:56 henoheno Exp $
+// $Id: spam.php,v 1.28 2006/11/23 02:05:03 henoheno Exp $
 // Copyright (C) 2006 PukiWiki Developers Team
 // License: GPL v2 or (at your option) any later version
 
@@ -413,10 +413,26 @@ function is_badhost($host = '')
 
        if (! isset($blocklist_regex)) {
                $blocklist = array(
+                       // Well-known
                        '.blogspot.com',
+
+                       // 2006-11 dev
+                       'wwwtahoo.com',
+
+                       // 2006/11/19 17:50 dev
+                       '.google0site.org',
+                       '.bigpricesearch.org',
+                       '.osfind.org',
+                       '.bablomira.biz',
                );
+
+               $blocklist_regex = array();
                foreach ($blocklist as $part) {
-                       $blocklist_regex[] = '#\b' . preg_quote($part, '#') . '$#';
+                       if ($part[0] === '.') {
+                               $blocklist_regex[] = '#' . preg_quote($part, '#') . '$#';
+                       } else {
+                               $blocklist_regex[] = '#^(.*\.)?' . preg_quote($part, '#') . '$#';
+                       }
                }
        }
 
@@ -433,17 +449,6 @@ function is_badhost($host = '')
 // Simple/fast spam check
 function is_uri_spam($target = '')
 {
-       static $blocklist = array(
-               '.blogspot.com',
-       );
-       static $blocklist_regex;
-
-       if (! isset($blocklist_regex)) {
-               foreach ($blocklist as $part) {
-                       $blocklist_regex[] = '#\b' . preg_quote($part, '#') . '$#';
-               }
-       }
-
        $is_spam = FALSE;
        $urinum = 0;