Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorverb
    • CommentTimeSep 20th 2007 edited
     permalink

    Hey,

    Just a quick question, this time: does anyone know what the exact limitations are when I collect someone's IP with $_SERVER['REMOTE_ADDR']?

    For example:

    • What is the maximum length?
    • What characters could be in it? (Only numers and periods, or other characters as well?)

    I was wondering about this while setting up a table for a database. The table will contain data of registered users: id, name, password, ip, etc.

    Any tips?

  1.  permalink

    According to Wikipedia, an IPv6 address looks like this (each line being the same address):

    2001:0db8:0000:0000:0000:0000:1428:57ab

    2001:0db8:0000:0000:0000::1428:57ab

    2001:0db8:0:0:0:0:1428:57ab

    2001:0db8:0:0::1428:57ab

    2001:0db8::1428:57ab

    2001:db8::1428:57ab

    Do you really need to set exact limitations?

    Here's a function that I use instead of just getting the REMOTE_ADDR:

    function GetRealIP() {

    $check = array('HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED','HTTP_VIA', 'HTTP_X_COMING_FROM', 'HTTP_COMING_FROM', 'HTTP_CLIENT_IP', 'REMOTE_ADDR');

    $length = count($check);

    for($i=0; $i<$length; $i++) {

    $item = $check[$i];

    if($found = $_SERVER[$item]) return $found;

    }

    }

    • CommentAuthorMatt
    • CommentTimeSep 21st 2007 edited
     permalink
    $_SERVER['REMOTE_ADDR'] always returns it in the format x.x.x.x, only numbers, always 3 periods.
    • CommentAuthorMatt
    • CommentTimeSep 21st 2007 edited
     permalink
    ­
  2.  permalink
    i would suggest using maybe char(15). That should have all the space needed for holding an IPv4 address at its full length 'xxx.xxx.xxx.xxx' I havent tested this though. i would love to hear any responses to this data type, and see if it works as it should.
Add your comments
    Username Password
  • Format comments as (Help)