function _get_org in GeoIP API 7
Same name and namespace in other branches
- 6 lib/geoip.inc \_get_org()
1 call to _get_org()
- geoip_org_by_addr in lib/
geoip.inc
File
- lib/
geoip.inc, line 464
Code
function _get_org($gi, $ipnum) {
$seek_org = _geoip_seek_country($gi, $ipnum);
if ($seek_org == $gi->databaseSegments) {
return NULL;
}
$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;
}