コード例 #1
0
 /**
  * @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();
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
ファイル: ReaderTest.php プロジェクト: nicholasryan/CorePlus
 /**
  * @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();
 }
コード例 #4
0
ファイル: doit.php プロジェクト: jimleitch01/jimsjams
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();