This topic is locked

Security: Restrict Access by IP Address

10/27/2009 11:27:03 AM
PHPRunner General questions
P
phpwalker author

Is there a way to restrict access by IP address?

D
danaci 10/27/2009

your user table contains
user_name

user_passwd

user_ip
BeforeLogin event
$rstmp = CustomQuery("select * from user_Table where user_name='".$_SESSION["UserID"]."'");

$datatmp = db_fetch_numarray($rstmp);

$ip = $datatmp[2];
if ($ip<>$_server['REMOTE_ADDR']) {
restrict command ...
}

T
thesofa 10/28/2009

you can restrict access to any folder on a web server by IP address.

If you are running your website from an Apache server, you can restict or allow access to any given folder using the <Directory>

syntax, for example I only allow access to "E:/wwwroot/Intranet/staff/netinfo" from the range 10.0.11.0 to 10.0.11.255thus:_

<Directory "E:/wwwroot/Intranet/staff/netinfo">

Order deny,allow

deny from all

allow from 10.0.11

</Directory>



anyone coming to the folder from a machine outside of the range gets access denied.

Of course, you need access to httpd.conf, but you may be able to add this command to the .htaccess file

the documentation for this is here Apache HowTo

Good luck and tell us how it worked or not?

T
thesofa 11/2/2009

did this work for you?