Ejemplo n.º 1
0
 /**
  * Returns a GeoIP instance. Creates it if necessary.
  * 
  * @param string $key 'loc', 'isp' or 'org'. Determines the type of GeoIP database
  *                    to load.
  * @return object|false
  */
 private function getGeoIpInstance($key)
 {
     if (empty($this->geoIpCache[$key])) {
         // make sure region names are loaded & saved first
         parent::getRegionNames();
         require_once PIWIK_INCLUDE_PATH . '/libs/MaxMindGeoIP/geoipcity.inc';
         $pathToDb = self::getPathToGeoIpDatabase(parent::$dbNames[$key]);
         if ($pathToDb !== false) {
             $this->geoIpCache[$key] = geoip_open($pathToDb, GEOIP_STANDARD);
             // TODO support shared memory
         }
     }
     return empty($this->geoIpCache[$key]) ? false : $this->geoIpCache[$key];
 }