Re: Restrict Access per IP Addresses
| From: | Ernest E Vogelsinger | Date: | Thu, 01 Mar 2001 15:27:17 +0000 |
| Subject: | Re: Restrict Access per IP Addresses | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-42180@lists.php.net to get a copy of this message | ||
At 16:09 01.03.2001, Nazoréen said:
--------------------[snip]--------------------
>there are 3 networks, each of them have a mask : (it is not necessary to
>know these parameters i think !)
>198.143.15.255 (255.255.255.0)
>202.139.84.255 (255.255.255.128)
>210.176.142.255 (255.255.255.192)
>
>When a user will connect, his IP will be between 198.143.15.0 and
>198.143.15.255 or between 202.139.84.0 and 202.139.84.255 or between
>210.176.142.0 and 210.176.142.255
>
>So if someone else connect without using my network, the system disallow him
>and redirect in 403 Page.
--------------------[snip]--------------------
Anthony,
given the function contains_ip from my earlier post, you would code:
<?php
if (!contains_ip("198.143.15.255", "255.255.255.0", $REMOTE_ADDRESS) &&
!contains_ip("202.139.84.255", "255.255.255.128", $REMOTE_ADDRESS)
&&
!contains_ip("210.176.142.255", "255.255.255.192", $REMOTE_ADDRESS))
{
header("403 Forbidden");
echo "<h1>Access Forbidden</h1>You may not come here from outside our
domain";
exit();
}
process_domain_app();
?>
...ebird
>O Ernest E. Vogelsinger
(\) http://www.1-at-web.at/
^ ICQ# 13394035