Jump to content


AOL Wandering IP Checking Code

  • Please log in to reply
2 replies to this topic

#1 JustinMs66@hotmail.com

  • Members
  • PipPipPip
  • Advanced Member
  • 138 posts

Posted 17 September 2006 - 10:47 PM

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.


#2 Mutley

  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 17 September 2006 - 11:58 PM

With AOL I'm sure the IP is fixed unless they reconnect their internet connection. It doesn't change on every page they load.
~ Mutley.

#3 HuggieBear

  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 18 September 2006 - 09:33 AM

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:

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";

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)...

^         \\ 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

This may seem quite confusing, check out RegEx's in the manual for further information.

Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users