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

To make this provider available, make sure the GEOIP_ADDR server variable is set.
Inheritance: extends Piwik\Plugins\UserCountry\LocationProvider\GeoIp
Show file Open project: piwik/piwik

Public Methods

Method Description
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 | string Checks if an HTTP server module has been installed. It checks by looking for the GEOIP_ADDR server variable.
isSameOrAnonymizedIp ( string $ip, string $currentIp ) : boolean Checks if two IP addresses are the same or if the first is the anonymized version of the other.
isWorking ( ) : boolean Returns true if the GEOIP_ADDR server variable is defined.

Method Details

getInfo() public method

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

getLocation() public method

This function will return different results based on the data used and based on how the GeoIP module is configured. If a region database is used, it may return the country code, region code, city name, area code, latitude, longitude and postal code of the visitor. Alternatively, only the country code may be returned for another database. If your HTTP server is not configured to include all GeoIP information, some information will not be available to Piwik.
public getLocation ( array $info ) : array
$info array Must have an 'ip' field.
return array

getSupportedLocationInfo() public method

There's no way to tell exactly what database the HTTP server is using, so we just assume country and continent information is available. This can make diagnostics a bit more difficult, unfortunately.
public getSupportedLocationInfo ( ) : array
return array

isAvailable() public method

There's a special check for the Apache module, but we can't check specifically for anything else.
public isAvailable ( ) : boolean | string
return boolean | string

isSameOrAnonymizedIp() public static method

Checks if two IP addresses are the same or if the first is the anonymized version of the other.
public static isSameOrAnonymizedIp ( string $ip, string $currentIp ) : boolean
$ip string
$currentIp string This IP should not be anonymized.
return boolean

isWorking() public method

Returns true if the GEOIP_ADDR server variable is defined.
public isWorking ( ) : boolean
return boolean