* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class StringStream implements StreamInterface { protected $data; protected $length; protected $pointer = 0; public function __construct($data = '') { $this->data = $data; $this->length = mb_strlen($data); } public function close() { $this->data = null; $this->length = 0; } public function detach() { if ($this->data !== null) { $handle = fopen('php://memory', 'r+'); fwrite($handle, $this->data); fseek($handle, 0); $this->close(); return $handle; } return null; } public function getSize() { return $this->length; } public function tell() { return $this->pointer; } public function eof() { if ($this->data !== null) { return $this->pointer >= $this->length; } return true; } public function rewind() { if ($this->data !== null) { $this->pointer = 0; } return true; } public function isSeekable() { return $this->data !== null; } public function seek($offset, $whence = SEEK_SET) { if ($this->isSeekable()) { if ($whence === SEEK_SET) { $this->pointer = $offset; } elseif ($whence === SEEK_CUR) { $this->pointer+= $offset; } elseif ($whence === SEEK_END) { $this->pointer = $this->length + $offset; } } return false; } public function isWritable() { return $this->data !== null; } public function write($string) { if ($this->isWritable()) { $length = mb_strlen($string); $pre = mb_substr($this->data, 0, $this->pointer); $post = mb_substr($this->data, $this->pointer + $length); $this->data = $pre . $string . $post; $this->pointer+= $length; $this->length = mb_strlen($this->data); return $length; } return false; } public function isReadable() { return $this->data !== null; } public function read($maxLength) { if ($this->isReadable()) { $data = mb_substr($this->data, $this->pointer, $maxLength); $this->pointer+= $maxLength; return $data; } return false; } public function getContents() { if ($this->data === null) { return null; } $data = mb_substr($this->data, $this->pointer); $this->pointer = $this->length; return $data; } public function getMetadata($key = null) { return $key === null ? array() : null; } public function __toString() { $this->pointer = $this->length; return $this->data === null ? '' : $this->data; } } __halt_compiler();----SIGNATURE:----aA9u4SDqYouS9PNpp1rGGBut0GiitPsk8XziWOQc9puSqTVCtD3PTDDfIahR42TLYH2nDe4Oc+vIhxiVVh3k0IsXapr9cY9BMPbieAJlMg+7r3UIDktHdWl87FWbXyf+Ififq4cg/cGzkdd+v4g8DOzbCOTy365XbmjXMaKGjohGXpZ1jUaTqsyjpwgZHxQ2XdGsTZGEPltcc6IvOn6Pg7YFcdJGrGRAPpHMetT9IAwK1C2IO2zRKnvuQ8i+416+TvgcRuycoBxVv75NnAB4pXH5vvv/kNAFQokoi9645F6JghyhrrSaRDvkUO6LhPYaxGT48VDuG9p6FZv2S/G4EPvU30BZAEF5HyMkYjuWVtT9WB9SpHAKmzvw6vzXTo+RyaQ+i3MoPgem+ROpxHQ/xUxjKEUhlN5IYPlptDw7kXdjtTl8Da6fKRjIHSAw3+J8T1OSqO0kvT23Bhx03YxPqnNNEIGC2N67wEcjR5nefQYcj5fQZLTMysNsfZ5TVBpupIriORFMzb/4oCd/g1WsRurQmd2pk6jKS6cXlEpOLF/9ljnuUPVc0EbH1GS0r6gfLywn/+6tmBSU/DKU9oEp6UNf3ERSBLmTlKJAkN3afg3xMWbBC/dqfA9p7Br8o5FqxhiPToRZaZ2n1Ju+MzsREu40hB3zh3eer0oXGJY15c0=----ATTACHMENT:----MTkzOTcxMTg2NDg5MzkxMSAxMDAwMDIwNjI4NDEzNzY2IDM4NjYzODM2OTg3ODI4NDQ=