Giter Club home page Giter Club logo

php-maxmind-geoip's Introduction

Requirements

None (only the 'GeoIP.dat' file is needed).  To download a free GeoIP Standard Country
database, go to
http://dev.maxmind.com/geoip/geolite

Install

Just place the 'geoip.inc' file somewhere according to the 'include_path' directive of
your 'php.ini' file, or just place it in the same directory as your PHP scripts.

Usage

Gets country name by hostname :

include("geoip.inc");

$gi = geoip_open("/usr/local/share/GeoIP/GeoIP.dat",GEOIP_STANDARD);

echo geoip_country_code_by_addr($gi, "24.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "24.24.24.24") . "\n";
echo geoip_country_code_by_addr($gi, "80.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "80.24.24.24") . "\n";

geoip_close($gi);

Memory Caching:
To enable memory caching, pass GEOIP_SHARED_MEMORY or
GEOIP_MEMORY_CACHE to the second argument of geoip_open

For GEOIP_SHARED_MEMORY, requires php >= 4.0.4,
and --enable-shmop passed at configure time, see
http://us2.php.net/manual/en/ref.shmop.php
In addition, you should call geoip_load_shared_mem
before calling geoip_open.  See sample_city.php for an
example of shared memory caching.

Working with PHP5.
geoip_country_code_by_addr should work
with PHP.  For help with the other
routines, please contact [email protected]

Thanks to Jim Winstead.

php-maxmind-geoip's People

Contributors

dirkaholic avatar maxromanovsky avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.