function geoip_load_shared_mem in GeoIP API 7
Same name and namespace in other branches
- 6 lib/geoip.inc \geoip_load_shared_mem()
File
- lib/
geoip.inc, line 236
Code
function geoip_load_shared_mem($file) {
$fp = fopen($file, "rb");
if (!$fp) {
print "error opening {$file}: {$php_errormsg}\n";
exit;
}
$s_array = fstat($fp);
$size = $s_array['size'];
if ($shmid = @shmop_open(GEOIP_SHM_KEY, "w", 0, 0)) {
shmop_delete($shmid);
shmop_close($shmid);
}
$shmid = shmop_open(GEOIP_SHM_KEY, "c", 0644, $size);
shmop_write($shmid, fread($fp, $size), 0);
shmop_close($shmid);
}