1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Icluding viewer's city with GeoIP data from Maxmind GeoLite into a page?

Discussion in 'Black Hat SEO' started by dirtbag, Feb 27, 2014.

  1. dirtbag

    dirtbag Senior Member

    Joined:
    Jul 24, 2008
    Messages:
    990
    Likes Received:
    525
    Is there a resource or code snippet somewhere that can help someone php/js-illiterate manage this with the free GeoLite City database? I've ried breaking down other people's code without luck, and the Maxminf site doesn't appear to have any documentation for using the database.
     
    Last edited: Feb 28, 2014
  2. dirtbag

    dirtbag Senior Member

    Joined:
    Jul 24, 2008
    Messages:
    990
    Likes Received:
    525
    bumping it up...............
     
  3. 45415

    45415 Junior Member

    Joined:
    Feb 5, 2009
    Messages:
    194
    Likes Received:
    92
    Code:
    <?php
    
    include("geoipcity.inc");
    
    $gi = geoip_open("GeoLiteCity.dat", GEOIP_STANDARD);
    $record = geoip_record_by_addr($gi, $_SERVER['REMOTE_ADDR']);
    echo $record->city;
    geoip_close($gi);
    
    ?>
    This works. Make sure geoipcity.inc, GeoLiteCity.dat and GeoIP.inc are in the same folder.