Merge commit 'origin/master' into fusionax
[platal.git] / modules / search / classes.inc.php
index 62a3ad7..f1c095c 100644 (file)
@@ -267,9 +267,9 @@ class QuickSearch extends SField
         $s = replace_accent(trim($this->value));
         $r = $s = str_replace('*','%',$s);
 
-        if (S::has_perms() && strpos($s, '@') !== false) {
+        if (S::admin() && strpos($s, '@') !== false) {
             $this->email = $s;
-        } else if (S::has_perms() && preg_match('/[0-9]+\.([0-9]+|%)\.([0-9]+|%)\.([0-9]+|%)/', $s)) {
+        } else if (S::admin() && preg_match('/[0-9]+\.([0-9]+|%)\.([0-9]+|%)\.([0-9]+|%)/', $s)) {
             $this->ip = $s;
         }
         if ($this->email || $this->ip) {
@@ -342,7 +342,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";
+            }
         }
         if (!empty($this->phone)){
             require_once("profil.func.inc.php");