Serves javascript file from a per-version directory, to prevent cross-version caching...
[platal.git] / modules / search / classes.inc.php
index af3ee22..9def2db 100644 (file)
@@ -239,9 +239,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) {
@@ -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);
@@ -564,7 +571,7 @@ class StringSField extends SField
      * imposées par l'utilisateur) */
     function length()
     {
-        $cleaned = replace_accent(strtolower($this->value));
+        $cleaned = strtolower(replace_accent($this->value));
         $length  = strlen(ereg_replace('[a-z0-9]', '', $cleaned));
         return strlen($this->value) - $length;
     }