You are here

function _common_get_org in Smart IP 6.2

Same name and namespace in other branches
  1. 7.2 includes/geoip.inc \_common_get_org()
2 calls to _common_get_org()
_get_org in includes/geoip.inc
_get_org_v6 in includes/geoip.inc

File

includes/geoip.inc, line 681

Code

function _common_get_org($gi, $seek_org) {
  $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
  if ($gi->flags & GEOIP_SHARED_MEMORY) {
    $org_buf = @shmop_read($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
  }
  else {
    fseek($gi->filehandle, $record_pointer, SEEK_SET);
    $org_buf = fread($gi->filehandle, MAX_ORG_RECORD_LENGTH);
  }

  // workaround php's broken substr, strpos, etc handling with
  // mbstring.func_overload and mbstring.internal_encoding
  $enc = mb_internal_encoding();
  mb_internal_encoding('ISO-8859-1');
  $org_buf = substr($org_buf, 0, strpos($org_buf, "\0"));
  mb_internal_encoding($enc);
  return $org_buf;
}