Re: Restricting access using IPs

From: Date: Sat, 13 Jul 2002 06:03:39 +0000
Subject: Re: Restricting access using IPs
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-107491@lists.php.net to get a copy of this message
On Saturday 13 July 2002 13:45, Liam MacKenzie wrote: > If I enter 192.168.0.13 (My IP) it works, I'm allowed in and any other IP > isn't. > However, I need to grant access to this whole network, not just me. So I > need 192.168.0.* to be able to access it, everyone else should get "Access > Denied" > > So I need to know how to write this bit: > $localip = "192.168.0.13"; > so that it's the network, not just me. > > I tried these but they didn't work: > $localip = "192.168.0.0"; > $localip = "192.168.0.*"; > $localip = "192.168.0.0/24"; In this particular case all you need to do is check that the ip address ($REMOTE_ADDR) begins with "192.168.0.". So look in the manual to see which of the string function(s) you need to perform this comparison (probably strstr()). -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Every improvement in communication makes the bore more terrible. -- Frank Moore Colby */

« previous php.general (#107491) next »