JustinMs66@hotmail.com Posted September 17, 2006 Share Posted September 17, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/21102-aol-wandering-ip-checking-code/ Share on other sites More sharing options...
Mutley Posted September 17, 2006 Share Posted September 17, 2006 With AOL I'm sure the IP is fixed unless they reconnect their internet connection. It doesn't change on every page they load. Quote Link to comment https://forums.phpfreaks.com/topic/21102-aol-wandering-ip-checking-code/#findComment-93727 Share on other sites More sharing options...
HuggieBear Posted September 18, 2006 Share Posted September 18, 2006 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.456So to evaluate the whole pattern for you (a bit on each line to make it easier to read)...[code]^ \\ Match start of line123 \\ Match the first octet of IP address as 123\. \\ The backslash escapes the period as it has special meaning in a RegEx456 \\ 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.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/21102-aol-wandering-ip-checking-code/#findComment-93864 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.