PHP Class Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Php

Inheritance: extends Piwik\Plugins\UserCountry\LocationProvider\GeoIp
Show file Open project: piwik/piwik Class Usage Examples

Public Methods

Method Description
__construct ( array | boolean $customDbNames = false ) Constructor.
__destruct ( ) Closes all open geoip instances.
getInfo ( ) : array Returns information about this location provider. Contains an id, title & description:
getLocation ( array $info ) : array Uses a GeoIP database to get a visitor's location based on their IP address.
getSupportedLocationInfo ( ) : array Returns an array describing the types of location information this provider will return.
isAvailable ( ) : boolean Returns true if this location provider is available. Piwik ships w/ the MaxMind PHP library, so this provider is available if a location GeoIP database can be found.
isWorking ( ) : boolean | string Returns true if this provider has been setup correctly, the error message if otherwise.

Private Methods

Method Description
getGeoIpInstance ( string $key ) : object | false Returns a GeoIP instance. Creates it if necessary.

Method Details

__construct() public method

Constructor.
public __construct ( array | boolean $customDbNames = false )
$customDbNames array | boolean The possible filenames for each type of GeoIP database. eg array( 'loc' => array('GeoLiteCity.dat'), 'isp' => array('GeoIP.dat', 'GeoIPISP.dat') 'org' => array('GeoIPOrg.dat') ) If a key is missing (or the parameter not supplied), then the default database names are used.

__destruct() public method

Closes all open geoip instances.
public __destruct ( )

getInfo() public method

array( 'id' => 'geoip_php', 'title' => '...', 'description' => '...' );
public getInfo ( ) : array
return array

getLocation() public method

This function will return different results based on the data used. If a city database is used, it may return the country code, region code, city name, area code, latitude, longitude and postal code of the visitor. Alternatively, if used with a country database, only the country code will be returned.
public getLocation ( array $info ) : array
$info array Must have an 'ip' field.
return array

getSupportedLocationInfo() public method

The location info this provider supports depends on what GeoIP databases it can find. This provider will always support country & continent information. If a region database is found, then region code & name information will be supported. If a city database is found, then region code, region name, city name, area code, latitude, longitude & postal code are all supported. If an organization database is found, organization information is supported. If an ISP database is found, ISP information is supported.
public getSupportedLocationInfo ( ) : array
return array

isAvailable() public method

Returns true if this location provider is available. Piwik ships w/ the MaxMind PHP library, so this provider is available if a location GeoIP database can be found.
public isAvailable ( ) : boolean
return boolean

isWorking() public method

Returns true if this provider has been setup correctly, the error message if otherwise.
public isWorking ( ) : boolean | string
return boolean | string