[Phplib-users] preauth using cidr
Brought to you by:
nhruby,
richardarcher
From: Paul W. <pa...@zz...> - 2001-11-08 19:47:59
|
Hi, I am trying to do a preauth using cidr to allow some institutional subscribers to access info that is normally password protected. I found some Perl code that does this but it does not work in php. Does anyone know how one could accomplish this? $cidr = $valid_client; /* eg 192.55.192.0/24 */ list ($quad, $nbits) = split ("/", $cidr, 2); $byte = explode (".", $quad); $address = ($byte[0] << 24) | ($byte[1] << 16) | ($byte[2] << 8) | $byte[3]; $bitmask = 0xffffffff << (32 - $nbits); if ($ip & $bitmask == $address & $bitmask) { $this->auth['uname'] = $this->dbAuth->f('ID'); $this->auth['perm'][$this->dbAuth->f('Service')] = 1; } -- ________________________________________________________________ Paul Wolstenholme SMA Webware http://www.zzube.com/ What do you know? http://make.zzube.com/ Vancouver, BC Canada |