TR: [PHP] Restrict Access per IP Addresses
| From: | Nazoréen | Date: | Fri, 02 Mar 2001 02:22:56 +0000 |
| Subject: | TR: [PHP] Restrict Access per IP Addresses | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-42270@lists.php.net to get a copy of this message | ||
Hello again :-)
First, thanks for your help !
but it doesn't work, i think i don't make the right things !!! because i
don't understand very well what i must do :-)
For best explain, i must use PHP because my server disallow .htaccess files,
this is the .htaccess files i must transform in PHP files :
<limit GET>
HTTP_REFERER
require valid-user
Satisfy any
order deny,allow
deny from all
allow from 198.143.15.0/24
allow from 202.139.84.0/25
allow from 210.176.142.64/26
</Limit>
The script allow all users who are connect with an IP Address 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
All other users with other IP Address are disallow and redirect to
http://www.yahoo.com/ for example or 403 Page.
Information about network :
198.143.15.0/24 (255.255.255.0)
202.139.84.0/25 (255.255.255.128)
210.176.142.64/26 (255.255.255.192)
numbers "0/24" or 64/26 is the range from 0 to 255 for the IP Address
Could you help me once again, please.
Thank you !
Have a nice day.
Anthony.
----- Original Message -----
From: "Ernest E Vogelsinger" <ebird@1-at-web.at>
To: "Nazoréen" <nazoreen@netcourrier.com>
Cc: "PHP GENERAL LIST" <php-general@lists.php.net>
Sent: Thursday, March 01, 2001 4:27 PM
Subject: Re: [PHP] Restrict Access per IP Addresses
> 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
>