不知道我做错了什么,但这个错误让我发疯了。我不断从以下这些代码中收到“fseek():提供的参数不是有效的流资源”错误:
public function _geoip_seek_country($ipnum) {
$offset = 0;
for ($depth = 31; $depth >= 0; $depth--) {
if ($this->flags & $this->GEOIP_MEMORY_CACHE) {
$enc = mb_internal_encoding();
mb_internal_encoding('ISO-8859-1');
$buf = substr($this->memory_buffer,
2 * $this->record_length * $offset,
2 * $this->record_length);
mb_internal_encoding($enc);
} elseif ($this->flags & $this->GEOIP_SHARED_MEMORY) {
$buf = @shmop_read ($this->shmid,
2 * $this->record_length * $offset,
2 * $this->record_length );
} else {
fseek($this->filehandle, 2 * $this->record_length * $offset, SEEK_SET) == 0
or die("fseek failed");
$buf = fread($this->filehandle, 2 * $this->record_length);
}
$x = array(0,0);
for ($i = 0; $i < 2; ++$i) {
for ($j = 0; $j < $this->record_length; ++$j) {
$x[$i] += ord($buf[$this->record_length * $i + $j]) << ($j * 8);
}
}
if ($ipnum & (1 << $depth)) {
if ($x[1] >= $this->databaseSegments) {
return $x[1];
}
$offset = $x[1];
} else {
if ($x[0] >= $this->databaseSegments) {
return $x[0];
}
$offset = $x[0];
}
}
trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
return false;
}
该文件确实存在并将权限设置为 777。
$this->filehandle = fopen($filename,"rb"))
已经是真的了。不知道为什么一直说
提供的参数不是有效的流资源