Posted by Kim Andrι Akerψ on 02/09/07 08:47
endlesstide@gmail.com wrote:
> Hi, could someone please show me in PHP how to express a low and high
> IP address, and do something based on result?
>
> Like
>
> <?
>
> $start_ip_range = "202.100.100.100"
> $end_ip_range = "220.255.255.255"
>
> if $actual_ip_address between $start_ip_range and $end_ip_range
> {
> do something
> }
>
> ?>
I believe you're looking for something like this:
<?php
$start_ip = ip2long($start_ip_range);
$end_ip = ip2long($end_ip_range);
$user_ip = ip2long($_SERVER["REMOTE_ADDR"]);
if (($user_ip >= $start_ip) and ($user_ip <= $end_ip)) {
// do something
}
?>
--
Kim AndrΓ© AkerΓΈ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
[Back to original message]
|