Changeset 156

Show
Ignore:
Timestamp:
11/02/07 18:02:50 (14 months ago)
Author:
chris
Message:

Fixed a stupid typo in the README
Optimised the iprange function

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/README

    r155 r156  
    44*General Intall* 
    55 
    6 The installation is as simple as these 4 steps: 
     6The installation is as simple as these 5 steps: 
    77 
    881) Copy config-sample.php to config.php 
  • trunk/index.php

    r155 r156  
    3737$Id$ 
    3838 
    39  */ 
     39*/ 
    4040 
    4141        function ipInRange($range, $address) { 
    4242                $range = str_replace(array(' ', "\r", "\n"), '', $range); 
     43                list($a, $b, $c, $d) = explode('.', $address); 
     44                $check = ($a << 24) + ($b << 16) + ($c << 8) + $d; 
    4345                foreach(explode(',', $range) as $ip) { 
    4446                        list($base, $bits) = explode('/', $ip); 
     
    4749                        $i = ($a << 24) + ($b << 16) + ($c << 8) + $d; 
    4850                        $mask = $bits == 0 ? 0 : (~0 << (32 - $bits)); 
    49  
    5051                        $low = $i & $mask; 
    5152                        $high = $i | (~$mask & 0xFFFFFFFF); 
    5253 
    53                         list($a, $b, $c, $d) = explode('.', $address); 
    54                         $check = ($a << 24) + ($b << 16) + ($c << 8) + $d; 
    5554                        if ($check >= $low && $check <= $high) { 
    5655                                return true;