You are here

function getrecordwithdnsservice in GeoIP API 7

Same name and namespace in other branches
  1. 6 lib/geoipcity.inc \getrecordwithdnsservice()

File

lib/geoipcity.inc, line 68

Code

function getrecordwithdnsservice($str) {
  $record = new geoipdnsrecord();
  $keyvalue = split(";", $str);
  foreach ($keyvalue as $keyvalue2) {
    list($key, $value) = split("=", $keyvalue2);
    if ($key == "co") {
      $record->country_code = $value;
    }
    if ($key == "ci") {
      $record->city = $value;
    }
    if ($key == "re") {
      $record->region = $value;
    }
    if ($key == "ac") {
      $record->areacode = $value;
    }
    if ($key == "dm" || $key == "me") {
      $record->dmacode = $value;
      $record->metrocode = $value;
    }
    if ($key == "is") {
      $record->isp = $value;
    }
    if ($key == "or") {
      $record->org = $value;
    }
    if ($key == "zi") {
      $record->postal_code = $value;
    }
    if ($key == "la") {
      $record->latitude = $value;
    }
    if ($key == "lo") {
      $record->longitude = $value;
    }
  }
  $number = $GLOBALS['GEOIP_COUNTRY_CODE_TO_NUMBER'][$record->country_code];
  $record->country_code3 = $GLOBALS['GEOIP_COUNTRY_CODES3'][$number];
  $record->country_name = $GLOBALS['GEOIP_COUNTRY_NAMES'][$number];
  if ($record->region != "") {
    if ($record->country_code == "US" || $record->country_code == "CA") {
      $record->regionname = $GLOBALS['ISO'][$record->country_code][$record->region];
    }
    else {
      $record->regionname = $GLOBALS['FIPS'][$record->country_code][$record->region];
    }
  }
  return $record;
}