FileDB = FileDB_Stream::getHandler()) { return false; } $this->_blockSize = $this->FileDB->blockSize; $url = parse_url($path); $this->id_file = $url['host']; $this->position = 0; $arr = $this->FileDB->getArr($this->id_file, 'id'); $this->size = $arr['size']; $this->mtime = $arr['changed_uts']; return true; } function stream_read($count) { $fileDataTable = 'tbl'.$this->FileDB->fileDataTable; $part = floor($this->position / $this->_blockSize ); $partRange = $this->position % $this->_blockSize ; $ret = ''; do { $sql = "SELECT data FROM {$this->FileDB->db->$fileDataTable} WHERE id_file = '{$this->id_file}' ORDER BY part ASC LIMIT $part, 1"; $data = $this->FileDB->db->queryOne($sql); if (PEAR::isError($data)) { $GLOBALS['_DEBUG']['level'] = D_ECHO; dump($data->getUserInfo(), 'stream_read error'); exit(); } if ($partRange || $this->_blockSize > ($partRange + $count - strlen($ret)) ){ $data = substr($data, $partRange, $count - strlen($ret) ); } $ret .= $data; $part++; $partRange = 0; }while (!empty($data) && $count > strlen($ret) && strlen($ret) + $this->position < $this->size ); $this->position += strlen($ret); return $ret; } function stream_seek($offset, $whence) { switch ($whence) { case SEEK_SET: if ($offset < $this->size && $offset >= 0) { $this->position = $offset; return true; } else { return false; } break; case SEEK_CUR: if ($offset >= 0) { $this->position += $offset; return true; } else { return false; } break; case SEEK_END: if ($this->size + $offset >= 0) { $this->position = $this->size + $offset; return true; } else { return false; } break; default: return false; } } function stream_tell() { return $this->position; } function stream_eof() { return $this->position >= $this->size; } function stream_flush() { return true; } function stream_stat() { return array('size' => $this->size, 'ino' => $this->id_file, 'mtime' => $this->mtime); } function stream_write($data) { return 0; } function stream_close() { return true; } }