/** * Load into Location object all available data * * @param GeoIp_Location $location */ public function loadLocation(GeoIp_Location $location) { require_once "Net/GeoIP.php"; $flag = Net_GeoIP::STANDARD; //TODO: on some hostings it failed to work (e.g. mosso.com), so we will disable option of shared memory until it will be solved // if (Gpf_Php::isFunctionEnabled('shmop_open')) { // $flag = Net_GeoIP::SHARED_MEMORY; // } $geoip = Net_GeoIP::getInstance($this->file->getFileName(), $flag); if ($geoipLocation = @$geoip->lookupLocation($location->getIpString())) { $location->setCountryCode($geoipLocation->countryCode); $location->setCity($geoipLocation->city); $location->setAreaCode($geoipLocation->areaCode); $location->setCountryName($geoipLocation->countryName); $location->setDmaCode($geoipLocation->dmaCode); $location->setLatitude($geoipLocation->latitude); $location->setLongitude($geoipLocation->longitude); $location->setPostalCode($geoipLocation->postalCode); $location->setRegion($geoipLocation->region); } else { throw new Gpf_Exception($this->_('Ip address %s is not in geoip database.', $location->getIpString())); } }