/** * Implements a singleton design pattern * * when looking for an instance one can pass an IP address to have data populated * * @access public * @param string * @return reference to a GeoCityLocateIspOrg object */ function &getInstance($ip = "") { static $instance = null; if ($instance === null) { $instance = new GeoCityLocateIspOrg(); } if (!empty($ip)) { $instance->setIP($ip); } return $instance; }
function getLocationFromWebService($location_map) { $license_key = owa_coreAPI::getSetting('maxmind_geoip', 'ws_license_key'); if (!array_key_exists('ip_address', $location_map)) { return $location_map; } $geoloc = GeoCityLocateIspOrg::getInstance(); $geoloc->setLicenceKey($license_key); $geoloc->setIP(trim($location_map['ip_address'])); if ($geoloc->isError()) { owa_coreAPI::debug($geoloc->isError() . ": " . $geoloc->getError()); return $location_map; } $location_map['city'] = utf8_encode(strtolower(trim($geoloc->getCity()))); $location_map['state'] = utf8_encode(strtolower(trim($geoloc->getState()))); $location_map['country'] = utf8_encode(strtolower(trim($geoloc->lookupCountryCode($geoloc->getCountryCode())))); $location_map['country_code'] = strtoupper(trim($geoloc->getCountryCode())); $location_map['latitude'] = trim($geoloc->getLat()); $location_map['longitude'] = trim($geoloc->getLong()); $location_map['dma_code'] = trim($geoloc->getMetroCode()); $location_map['dma'] = trim($geoloc->lookupMetroCode($geoloc->getMetroCode())); $location_map['area_code'] = trim($geoloc->getAreaCode()); $location_map['postal_code'] = trim($geoloc->getZip()); $location_map['isp'] = utf8_encode(trim($geoloc->getIsp())); $location_map['organization'] = utf8_encode(trim($geoloc->getOrganization())); $location_map['subcountry_code'] = trim($geoloc->lookupSubCountryCode($geoloc->getState(), $geoloc->getCountryCode())); return $location_map; }