Store IP as uint instead of strings.
[platal.git] / modules / search / classes.inc.php
index 8a27101..f6922bd 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -307,7 +307,7 @@ class QuickSearch extends SField
             $where[] = 'ems.email = ' . XDB::escape($this->email);
         }
         if (!empty($this->ip)) {
-            $ip = XDB::escape($this->ip);
+            $ip = ip_to_uint($this->ip);
             $where[] = "( ls.ip = $ip OR ls.forward_ip = $ip )";
         }
 
@@ -755,6 +755,11 @@ class SFieldGroup
     {
         $this->fields = $_fields;
         $this->and    = $_and;
+        foreach ($this->fields as $key=>&$field) {
+            if (is_null($field)) {
+                unset($this->fields[$key]);
+            }
+        }
     }
 
     // }}}
@@ -764,7 +769,9 @@ class SFieldGroup
     {
         $b = true;
         for ($i=0 ; $b && $i<count($this->fields) ; $i++) {
-            $b = $b && $this->fields[$i]->too_large();
+            if (!is_null($this->fields[$i])) {
+                $b = $b && $this->fields[$i]->too_large();
+            }
         }
         return $b;
     }