/** * @expectedException BadMethodCallException * @expectedExceptionMessage Attempt to read from a closed MaxMind DB. */ public function testClosedMetadata() { $reader = new Reader('tests/data/test-data/MaxMind-DB-test-decoder.mmdb'); $reader->close(); $reader->metadata(); }
/** * Fetches the location from the Maxmind local db * * @param string $ip */ function getLocation($location_map) { if (!$this->isDbReady()) { return $location_map; } if (!array_key_exists('ip_address', $location_map)) { return $location_map; } $reader = new Reader($this->db_file_path); $record = $reader->get(trim($location_map['ip_address'])); $reader->close(); if ($record) { $location_map = $this->mapCityRecord($record, $location_map); } return $location_map; }
/** * @expectedException BadMethodCallException * @expectedExceptionMessage Attempt to read from a closed MaxMind DB. */ public function testClosedMetadata() { $reader = new Reader(ROOT_PDIR . 'components/geographic-codes/libs/MaxMind-DB-Reader-php/tests/data/test-data/MaxMind-DB-test-decoder.mmdb'); $reader->close(); $reader->metadata(); }
print "IP: {$ipAddress}\n"; print "CITY:" . $geoinfo[city][names][en] . "\n"; print "COUNTRY:" . $geoinfo[registered_country][names][en] . "\n"; print "LATITUDE:" . $geoinfo[location][latitude] . "\n"; print "LONGITUDE:" . $geoinfo[location][longitude] . "\n"; $handle = fopen("ips.txt", "r"); if ($handle) { while (($line = fgets($handle)) !== false) { //print "$line"; $ipAddress = trim($line); $geoinfo = $reader->get($ipAddress); print "IP: {$ipAddress},"; print "CITY:" . $geoinfo[city][names][en] . ","; print "COUNTRY:" . $geoinfo[registered_country][names][en] . ","; print "LATITUDE:" . $geoinfo[location][latitude] . ","; print "LONGITUDE:" . $geoinfo[location][longitude] . "\n"; } fclose($handle); } else { // error opening the file. } // foreach($reader->get($ipAddress) as $x=>$x_value) // { // print "Key=" . $x . ", Value=" . $x_value . "\n"; // // // print "Key=" . $x . ", Value=" . $x_value . "\n"; // // } $reader->close();