Jump to content

AOL Wandering IP Checking Code


JustinMs66@hotmail.com

Recommended Posts

AOL uses a cluster of proxies. meaning that on every page they visit, they have a different IP address.

therefore i need to do a check to allow multiple IP's on a single account, otherwise the user will simply be logged out. something like this:
$ip_check = substr($userdata['session_ip'], 0, 4);

or SoMething like that, but i'm not exactly sure, because i'm not sure where i want the code to go because when i just use that code it won't work.

help?
Link to comment
https://forums.phpfreaks.com/topic/21102-aol-wandering-ip-checking-code/
Share on other sites

It's a tricky one.  Unless you know what the AOL range of addresses is for their proxy servers, you could have problems.

I think you're on the right lines though, maybe use a regular expression rather than substr().  Something like this:

[code]if (preg_match('/^123\.456\.\d{1,3}\.\d{1,3}$/', $userdata['session_ip'])){
  echo "IP Address OK";
}
else {
  echo "Your IP address is not in our acceptable range";
}[/code]

What this does is check that the IP address is formed of the correct pattern.  In this case 123.456.nnn.nnn (where 'n' is any other number).  This assumes that AOL's IP address range for their proxies starts 123.456

So to evaluate the whole pattern for you (a bit on each line to make it easier to read)...

[code]^        \\ Match start of line
123      \\ Match the first octet of IP address as 123
\.        \\ The backslash escapes the period as it has special meaning in a RegEx
456      \\ Match the second octet of the IP address as 456
\.        \\ Match the second escaped period
\d{1,3}  \\ Match a minimum of one and a maximum of three digits
\.        \\ Match the third escaped period
\d{1,3}  \\ Match a minimum of one and a maximum of three digits
$          \\ Match the end of line[/code]

This may seem quite confusing, check out [url=http://www.php.net/manual/en/ref.pcre.php]RegEx's[/url] in the manual for further information.

Regards
Huggie

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.