getLocation() 추상적인 공개 메소드

The result of this function will be an array. The array can store some or all of the following information: - Continent Code: The code of the visitor's continent. (array key is self::CONTINENT_CODE_KEY) - Continent Name: The name of the visitor's continent. (array key is self::CONTINENT_NAME_KEY) - Country Code: The code of the visitor's country. (array key is self::COUNTRY_CODE_KEY) - Country Name: The name of the visitor's country. (array key is self::COUNTRY_NAME_KEY) - Region Code: The code of the visitor's region. (array key is self::REGION_CODE_KEY) - Region Name: The name of the visitor's region. (array key is self::REGION_NAME_KEY) - City Name: The name of the visitor's city. (array key is self::CITY_NAME_KEY) - Area Code: The visitor's area code. (array key is self::AREA_CODE_KEY) - Latitude: The visitor's latitude. (array key is self::LATITUDE_KEY) - Longitude: The visitor's longitude. (array key is self::LONGITUDE_KEY) - Postal Code: The visitor's postal code. (array key is self::POSTAL_CODE_KEY) - ISP: The visitor's ISP. (array key is self::ISP_KEY) - Org: The company/organization of the visitor's IP. (array key is self::ORG_KEY) All LocationProviders will attempt to return the country of the visitor.
abstract public getLocation ( array $info ) : array | false
$info array What this must contain depends on the specific provider implementation. All providers require an 'ip' key mapped to the visitor's IP address.
리턴 array | false
 /**
  * Tests a location provider using a test IP address and catches PHP errors
  * (ie, notices) if they occur. PHP error information is held in self::$unzipPhpError.
  *
  * @param LocationProvider $provider The provider to test.
  * @return array|false $location The result of geolocation. False if no location
  *                               can be found.
  */
 private static function getTestLocationCatchPhpErrors($provider)
 {
     // note: in most cases where this will fail, the error will usually be a PHP fatal error/notice.
     // in order to delete the files in such a case (which can be caused by a man-in-the-middle attack)
     // we need to catch them, so we set a new error handler.
     self::$unzipPhpError = null;
     set_error_handler(array('Piwik\\Plugins\\UserCountry\\GeoIPAutoUpdater', 'catchGeoIPError'));
     $location = $provider->getLocation(array('ip' => GeoIp::TEST_IP));
     restore_error_handler();
     return $location;
 }
예제 #2
0
 /**
  * @param LocationProvider $provider
  * @param array $userInfo
  * @return array|false
  */
 private function getLocationObject(LocationProvider $provider, $userInfo)
 {
     $location = $provider->getLocation($userInfo);
     $providerId = $provider->getId();
     $ipAddress = $userInfo['ip'];
     if ($location === false) {
         return false;
     }
     Common::printDebug("GEO: Found IP {$ipAddress} location (provider '" . $providerId . "'): " . var_export($location, true));
     return $location;
 }