Jump to content

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.