Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Using Geo-ip On My Site

Options
  • 26-02-2007 2:18pm
    #1
    Registered Users Posts: 648 ✭✭✭


    hi

    i want to limit what info my visitors see depending on teh country they are in .

    anyone know a good db that will allow me to do a check?

    tnx
    chico


Comments

  • Registered Users Posts: 3,402 ✭✭✭randombar


    I would also be interested in getting co-ordinates from the ipaddress, maybe even the longitude and latitude? Please let me know how you get on!


  • Registered Users Posts: 7,739 ✭✭✭mneylon




  • Registered Users Posts: 3,402 ✭✭✭randombar


    I'm very lazy:


    <?
    function StripTags($string){
    while(strstr($string, '>')){
    $currentBeg = strpos($string, '<');
    $currentEnd = strpos($string, '>');
    $tmpStringBeg = @substr($string, 0, $currentBeg);
    $tmpStringEnd = @substr($string, $currentEnd + 1, strlen($string));
    $string = $tmpStringBeg.$tmpStringEnd;
    }
    return $string;
    }

    function GetCountry($IP){
    $lines = StripTags(file('http://api.hostip.info/get_html.php?ip='.$IP));
    return substr($lines[0], 9);
    }

    function GetCity($IP){
    $lines = StripTags(file('http://api.hostip.info/get_html.php?ip='.$IP));
    $pos = -(strlen($lines[1]) - strpos($lines[1], ','));
    return substr($lines[1], 6, $pos);
    }

    function GetState($IP){
    $lines = StripTags(file('http://api.hostip.info/get_html.php?ip='.$IP));
    $pos = strpos($lines[1], ',')+2;
    return substr($lines[1], $pos, 2);
    }

    echo GetCountry($REMOTE_ADDR).'<br>';
    echo GetCity($REMOTE_ADDR).'<br>';
    echo GetState($REMOTE_ADDR).'<br>';
    ?>

    Don't forget to check out http://www.ratemypub.ie and let me know what ye think!


  • Registered Users Posts: 7,739 ✭✭✭mneylon


    That database isn't very accurate. It doesn't recognise my netblock at all!


  • Closed Accounts Posts: 1,974 ✭✭✭mick.fr


    Myself I use http://www.ipligence.com
    They are pretty good and cheap.


  • Advertisement
  • Registered Users Posts: 3,402 ✭✭✭randombar


    I've been looking at maxmind all right and it seems the way to go, does anyone know how to use the Lite versions? I've downloaded the script and I keep getting errors from it?

    I don''t really like spending any money on something until I see it works well and stuff so I'm looking for free versions at the moment!


  • Closed Accounts Posts: 1,974 ✭✭✭mick.fr


    GaryCocs wrote:
    I've been looking at maxmind all right and it seems the way to go, does anyone know how to use the Lite versions? I've downloaded the script and I keep getting errors from it?

    I don''t really like spending any money on something until I see it works well and stuff so I'm looking for free versions at the moment!

    You mean IPLIENCE not MAXMIND right ?

    Search their website they provide code examples for PHP, ASP etc..


  • Registered Users Posts: 3,402 ✭✭✭randombar


    No I mean maxmind, I've been reading about the two and it seems more people favour maxmind. You can also get a free database off them. Free is my favorite word! Can you get anything from the other type?


  • Registered Users Posts: 3,402 ✭✭✭randombar


    Managed to sort this one out using maxmind, if anyone needs a hand with it just let me know! By the way if anyone has a better version i.e. the fuller version of the database please let me know

    Thanks
    Gary


Advertisement