Properly handles the case where an admin search for a good looking IP-address that...
authorVincent Zanotti <vincent.zanotti@m4x.org>
Wed, 8 Apr 2009 12:14:05 +0000 (14:14 +0200)
committerVincent Zanotti <vincent.zanotti@m4x.org>
Fri, 10 Apr 2009 00:06:08 +0000 (02:06 +0200)
Signed-off-by: Vincent Zanotti <vincent.zanotti@m4x.org>
modules/search/classes.inc.php

index af3ee22..8289da5 100644 (file)
@@ -308,7 +308,14 @@ class QuickSearch extends SField
         }
         if (!empty($this->ip)) {
             $ip = ip_to_uint($this->ip);
-            $where[] = "( ls.ip = $ip OR ls.forward_ip = $ip ) AND ls.suid = 0";
+
+            // If the IP address requested for the search cannot be translated,
+            // the predicate should always be valued to false.
+            if ($ip != null) {
+                $where[] = "( ls.ip = $ip OR ls.forward_ip = $ip ) AND ls.suid = 0";
+            } else {
+                $where[] = "false";
+            }
         }
 
         return join(" AND ", $where);