GEOIP2
NAME
geoip2 - Finds geolocalisation information about an ip address.
SYNOPSIS
geoip2 ([error:variable,db:"string",lg:""],ip:"string");
DESCRIPTION
This function is used to retrieve geolocalisation information about an IP address.
This is using the new version of geoip from maxmind.
PARAMETERS
- ip
- IP address for which geolocalisation information is desired.
- error
- Parameter to use to return error information.
- lg
- Parameter to specify the language for the text return by geoip2
- db
- Database file used to get the geolocalisation information. Defaults to /GeoIP2-City-North-America.mmdb which is part of any Extenso installation.
RETURN
- Array
- Associative array of geolocalisation information
MODULES
To use this module, you must specify the following in /usr/local/website/site.conf:
Module geoip2 {
Library : "/usr/local/lib/libsngeoip2.so"
Init : "sngeoip2_init"
}
EXAMPLES
c = connection();
ip = c.client_ip;
geoip2(lg:"fr",error: t,db:"/GeoIP2-City.mmdb",ip);
return {"region":"QC","region_name":"Québec","country_code":"CA"}
geoip2(lg:"en",error: t,db:"/GeoIP2-City.mmdb",ip);
return {"continent":"North America",
"region":"QC","region_name":"Quebec",
"country_name":"Canada","city":"Saint-Lambert",
"ip":"70.25.40.105","timezone":"America/Toronto",
"longitude":-73.5082,"latitude":45.5073,
"postal_code":"J4P","country_code":"CA"}
geoip2(error: t,db:"/GeoIP2-City.mmdb",ip);
return {"continent":"North America","region":"QC",
"region_name":"Quebec","country_name":"Canada",
"city":"Saint-Lambert","ip":"70.25.40.105",
"timezone":"America/Toronto","longitude":-73.5082,
"latitude":45.5073,"postal_code":"J4P","country_code":"CA"}
SEE ALSO
AUTHOR
Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>
MODIFICATIONS
1.0 2014-09-09 21:24:14 laplante@sednove.com
Edit