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

FIXME: For some reason, if the PECL module is loaded & an organization DB is available, the PHP module won't return organization info. If the PECL module is not loaded, organization info is returned.
Inheritance: extends Piwik\Plugins\UserCountry\LocationProvider\GeoIp
Show file Open project: piwik/piwik Class Usage Examples

Public Properties

Property Type Description
$forceDisable For tests.

Public Methods

Method Description
getInfo ( ) : array Returns information about this location provider. Contains an id, title & description:
getLocation ( array $info ) : array Uses the GeoIP PECL module 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 the PECL module is installed and loaded, false if otherwise.
isCityDatabaseAvailable ( ) : boolean Returns true if the PECL module can detect a city database.
isCountryDatabaseAvailable ( ) : boolean Returns true if the PECL module can detect a country database.
isISPDatabaseAvailable ( ) : boolean Returns true if the PECL module can detect an ISP database.
isLocationDatabaseAvailable ( ) : boolean Returns true if the PECL module can detect a location database (either a country, region or city will do).
isOrgDatabaseAvailable ( ) : boolean Returns true if the PECL module can detect an organization database.
isRegionDatabaseAvailable ( ) : boolean Returns true if the PECL module can detect a region database.
isWorking ( ) : boolean Returns true if the PECL module that is installed can be successfully used to get the location of an IP address.

Method Details

getInfo() public method

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

getLocation() public method

This function will return different results based on the data available. If a city database can be detected by the PECL module, it may return the country code, region code, city name, area code, latitude, longitude and postal code of the visitor. Alternatively, if only the country database can be detected, only the country code will be returned. The GeoIP PECL module will detect the following filenames: - GeoIP.dat - GeoIPCity.dat - GeoIPISP.dat - GeoIPOrg.dat Note how GeoLiteCity.dat, the name for the GeoLite city database, is not detected by the PECL module.
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 the PECL module is installed and loaded, false if otherwise.
public isAvailable ( ) : boolean
return boolean

isCityDatabaseAvailable() public static method

Returns true if the PECL module can detect a city database.
public static isCityDatabaseAvailable ( ) : boolean
return boolean

isCountryDatabaseAvailable() public static method

Returns true if the PECL module can detect a country database.
public static isCountryDatabaseAvailable ( ) : boolean
return boolean

isISPDatabaseAvailable() public static method

Returns true if the PECL module can detect an ISP database.
public static isISPDatabaseAvailable ( ) : boolean
return boolean

isLocationDatabaseAvailable() public static method

Returns true if the PECL module can detect a location database (either a country, region or city will do).
public static isLocationDatabaseAvailable ( ) : boolean
return boolean

isOrgDatabaseAvailable() public static method

Returns true if the PECL module can detect an organization database.
public static isOrgDatabaseAvailable ( ) : boolean
return boolean

isRegionDatabaseAvailable() public static method

Returns true if the PECL module can detect a region database.
public static isRegionDatabaseAvailable ( ) : boolean
return boolean

isWorking() public method

Returns true if the PECL module that is installed can be successfully used to get the location of an IP address.
public isWorking ( ) : boolean
return boolean

Property Details

$forceDisable public static property

For tests.
public static $forceDisable