Re: [PHP] How to ask if private IP?

2007-11-27 Thread Philip Thompson
On Nov 26, 2007 6:08 AM, Jochem Maas [EMAIL PROTECTED] wrote: Ronald, I really dont care if my email doesn't reach you, making normal people jump through hoops because you want to avoid spam is not the right way to do things, next time I'll remember not to answer your questions as your not

Re: [PHP] How to ask if private IP?

2007-11-26 Thread Jochem Maas
Ronald Wiplinger wrote: I use $aa=$_SERVER[REMOTE_ADDR]; and if(($aa==192.168.2.108) || ($aa==192.168.2.34)) { $aa=61.64.101.101;// for testing put in a public IP } However, I would like to cover all private IPs (192.168.x.x and 10.x.x.x and 172.??.x.x). How can I do that

Re: [PHP] How to ask if private IP?

2007-11-26 Thread Jochem Maas
Ronald, I really dont care if my email doesn't reach you, making normal people jump through hoops because you want to avoid spam is not the right way to do things, next time I'll remember not to answer your questions as your not going to ['be able to'] read my answers: BLA BLA BLA This message

Re: [PHP] How to ask if private IP?

2007-11-26 Thread William Betts
Below is a quick example. This isn't the best way to do it, just another way. I personally would convert them to integers then compare instead of doing it the way I'm doing it below. ?php function privateIP($ip) { if ( (($ip = 10.0.0.0) ($ip = 10.255.255.255)) || (($ip =

RE: [PHP] How to ask if private IP?

2007-11-25 Thread Andrés Robinet
$remoteIP = $_SERVER['REMOTE_ADDR']; $parts = explode('.', $remoteIP); // Get IP bytes in an array $isPrivateIP = false; /* single class A */ $classA = $parts[0] == 10; /* 16 contiguous class Bs */ $classB = $parts[0] == 172 $parts[1] = 16 $parts[1] = 31; /* 256 contiguous class Cs */ $classC =

Re: [PHP] How to ask if private IP?

2007-11-25 Thread mike
i did this once $ip = sprintf(%u,intval(ip2long($_SERVER['REMOTE_ADDR']))); and then did checks to see if it was between the ranges for 10.0.0.0, 192.168 etc... apparently i lost that code. but it was pretty simple. http://www.faqs.org/rfcs/rfc1918.html 10.0.0.0- 10.255.255.255