Re: stream wrappers
| From: | John Holmes | Date: | Wed, 01 Sep 2004 01:04:33 +0000 |
| Subject: | Re: stream wrappers | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195360@lists.php.net to get a copy of this message | ||
jarell wrote:
I'm trying to write a stream wrapper that will be used to let users download a file only once. I'm confused as to what function definined on the php definition page for stream_wrapper_register I need to use. I'm guessing that stream_eof will be important. What about stream_close?You'll need most of them, more than likely. stream_open, stream_read, stream_close, stream_eof at least. stream_wrapper_register('onetime','onetime'); class onetime { var $fp = FALSE; stream_open($path, $mode, $options, $opened_path) {
//Perform check for only one download
if($this->fp = fopen($path,$mode))
{ return TRUE; }
else
{ return FALSE; }
}
stream_read($bytes)
{ return fread($this->fp,$bytes); }
stream_eof()
{ return feof($this->fp); }
stream_close()
{ return fclose($this->fp); }
}
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com