Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Using Geo-ip On My Site

  • 26-02-2007 02:18PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 3,484 ✭✭✭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, Registered Users 2 Posts: 7,742 ✭✭✭mneylon




  • Registered Users, Registered Users 2 Posts: 3,484 ✭✭✭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, Registered Users 2 Posts: 7,742 ✭✭✭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, Registered Users 2 Posts: 3,484 ✭✭✭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, Registered Users 2 Posts: 3,484 ✭✭✭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, Registered Users 2 Posts: 3,484 ✭✭✭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