OSDN Git Service

testFunc_uri_pickup(): Added two more tests
[pukiwiki/pukiwiki_sandbox.git] / spam / spam.php
index fa33a02..3ce18cb 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// $Id: spam.php,v 1.211 2008/12/28 15:43:07 henoheno Exp $
+// $Id: spam.php,v 1.213 2008/12/30 11:41:38 henoheno Exp $
 // Copyright (C) 2006-2007 PukiWiki Developers Team
 // License: GPL v2 or (at your option) any later version
 //
@@ -672,14 +672,16 @@ function check_uri_spam($target = '', $method = array())
 
                if ($_result) {
                        foreach(array_keys($_method) as $key) {
-                               $sum[$key] = $_result[$key];
-                               if (isset($method[$key]) && $sum[$key] > $method[$key]) {
-                                       $is_spam[$key] = TRUE;
+                               if (isset($_result[$key])) {
+                                       $sum[$key] = $_result[$key];
+                                       if (isset($method[$key]) && $sum[$key] > $method[$key]) {
+                                               $is_spam[$key] = TRUE;
+                                       }
                                }
                        }
                }
 
-               $_method = $_result = NULL;
+               unset($_asap, $_method, $_result);
        }
 
        // Return if ...
@@ -688,22 +690,30 @@ function check_uri_spam($target = '', $method = array())
        // ----------------------------------------
        // URI: Pickup
 
-       $pickups = uri_pickup_normalize(spam_uri_pickup($target, $method));
+       $pickups = spam_uri_pickup($target, $method);
+
+
+       // Return if ...
+       if (empty($pickups)) return $progress;
+
+       // Normalize all
+       $pickups = uri_pickup_normalize($pickups);
+
+       // ----------------------------------------
+       // Pickup some part of URI
+
        $hosts = array();
        foreach ($pickups as $key => $pickup) {
                $hosts[$key] = & $pickup['host'];
        }
 
-       // Return if ...
-       if (empty($pickups)) return $progress;
-
        // ----------------------------------------
        // URI: Bad host <pre-filter> (Separate good/bad hosts from $hosts)
 
        if ((! $asap || ! $is_spam) && isset($method['badhost'])) {
                $list    = get_blocklist('pre');
                $blocked = blocklist_distiller($hosts, array_keys($list), $asap);
-               foreach($list as $key=>$type){
+               foreach($list as $key => $type){
                        if (! $type) unset($blocked[$key]); // Ignore goodhost etc
                }
                unset($list);