You are here

function geoip_open in Smart IP 7.2

Same name and namespace in other branches
  1. 6.2 includes/geoip.inc \geoip_open()
1 call to geoip_open()
smart_ip_get_location in ./smart_ip.module
Get the geo location from the IP address

File

includes/geoip.inc, line 380

Code

function geoip_open($filename, $flags) {
  $gi = new GeoIP();
  $gi->flags = $flags;
  if ($gi->flags & GEOIP_SHARED_MEMORY) {
    $gi->shmid = @shmop_open(GEOIP_SHM_KEY, "a", 0, 0);
  }
  else {
    $gi->filehandle = fopen($filename, "rb") or die("Can not open {$filename}\n");
    if ($gi->flags & GEOIP_MEMORY_CACHE) {
      $s_array = fstat($gi->filehandle);
      $gi->memory_buffer = fread($gi->filehandle, $s_array['size']);
    }
  }
  $gi = _setup_segments($gi);
  return $gi;
}