[geeklog-cvs] geeklog: Make the CIDR check not trip over Mac OS X's use of ::1...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sat Apr 11 13:45:16 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/add909bdec43
changeset: 6920:add909bdec43
user:      Dirk Haun <dirk at haun-online.de>
date:      Sat Apr 11 17:03:12 2009 +0200
description:
Make the CIDR check not trip over Mac OS X's use of ::1 for localhost

diffstat:

1 file changed, 10 insertions(+), 8 deletions(-)
plugins/spamx/IP.Examine.class.php |   18 ++++++++++--------

diffs (30 lines):

diff -r 63d54d84c058 -r add909bdec43 plugins/spamx/IP.Examine.class.php
--- a/plugins/spamx/IP.Examine.class.php	Sat Apr 11 17:00:38 2009 +0200
+++ b/plugins/spamx/IP.Examine.class.php	Sat Apr 11 17:03:12 2009 +0200
@@ -99,16 +99,18 @@
         // here's our highest int
         $high = $i | (~$mask & 0xFFFFFFFF);
 
-        // now split the ip were checking against up into classes
-        list($a, $b, $c, $d) = explode('.', $iptocheck);
+        // now split the ip we're checking against up into classes
+        $ex = explode('.', $iptocheck);
 
-        // now convert the ip we're checking against to an int
-        $check = ($a << 24) + ($b << 16) + ($c << 8) + $d;
+        if (count($ex) == 4) {
+            // now convert the ip we're checking against to an int
+            $check = ($ex[0] << 24) + ($ex[1] << 16) + ($ex[2] << 8) + $ex[3];
 
-        // if the ip is within the range, including
-        // highest/lowest values, then it's witin the CIDR range
-        if (($check >= $low) && ($check <= $high)) {
-            return true;
+            // if the ip is within the range, including
+            // highest/lowest values, then it's witin the CIDR range
+            if (($check >= $low) && ($check <= $high)) {
+                return true;
+            }
         }
 
         return false;



More information about the geeklog-cvs mailing list