You are here: Re: Script assistance, IP address related « All PHP « IT news, forums, messages
Re: Script assistance, IP address related

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)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация