X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fsecurity.inc.php;h=64e3714a2415f28d24650151b346ecc544dacfbb;hb=2504be33ed7e7436c428f188bdafa9e72248131d;hp=e0b1d1485ccb4cca4ba9a6b23a8ff0ce3d759c72;hpb=1db75748d39cb4ee8314ff234a55bb732e871eeb;p=platal.git diff --git a/include/security.inc.php b/include/security.inc.php index e0b1d14..64e3714 100644 --- a/include/security.inc.php +++ b/include/security.inc.php @@ -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,7 @@ function check_redirect($red = null) { require_once 'emails.inc.php'; if (is_null($red)) { - $red = new Redirect(S::v('uid')); + $red = new Redirect(S::user()); } if ($red->get_uid() == S::v('uid')) { $_SESSION['no_redirect'] = !$red->other_active('');