Adds address edition in entreprise validation.
[platal.git] / include / security.inc.php
index e0b1d14..9e9aa45 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -34,8 +34,13 @@ function check_ip($level)
             $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
         }
         $ips[] = $_SERVER['REMOTE_ADDR'];
-        foreach ($ips as &$ip) {
-            $ip = '(ip & mask) = (' . ip_to_uint($ip) . '& mask)';
+        foreach ($ips as $key=>$ip) {
+            $v = ip_to_uint($ip);
+            if (is_null($v)) {
+                unset($ips[$key]);
+            } else {
+                $ips[$key] = '(ip & mask) = (' . $v . '& mask)';
+            }
         }
         $res = XDB::query('SELECT  state, description
                              FROM  ip_watch
@@ -80,7 +85,8 @@ function check_redirect($red = null)
 {
     require_once 'emails.inc.php';
     if (is_null($red)) {
-        $red = new Redirect(S::v('uid'));
+        $user = S::user();
+        $red = new Redirect($user);
     }
     if ($red->get_uid() == S::v('uid')) {
         $_SESSION['no_redirect'] = !$red->other_active('');