path = $path; $this->mode = $writable ? 'w+b' : 'rb'; } /** * Get the complete path to the file. * * @return string */ public function getPath() { return $this->path; } /** * Reads $length bytes from the stream into a string and moves the pointer * through the stream by $length. * * If less bytes exist than are requested the * remaining bytes are given instead. If no bytes are remaining at all, boolean * false is returned. * * @param int $length * * @return string|bool * * @throws Swift_IoException */ public function read($length) { $fp = $this->getReadHandle(); if (!feof($fp)) { $bytes = fread($fp, $length); $this->offset = ftell($fp); // If we read one byte after reaching the end of the file // feof() will return false and an empty string is returned if ((false === $bytes || '' === $bytes) && feof($fp)) { $this->resetReadHandle(); return false; } return $bytes; } $this->resetReadHandle(); return false; } /** * Move the internal read pointer to $byteOffset in the stream. * * @param int $byteOffset * * @return bool */ public function setReadPointer($byteOffset) { if (isset($this->reader)) { $this->seekReadStreamToPosition($byteOffset); } $this->offset = $byteOffset; } /** * Just write the bytes to the file */ protected function doCommit($bytes) { fwrite($this->getWriteHandle(), $bytes); $this->resetReadHandle(); } /** * Not used */ protected function flush() { } /** * Get the resource for reading */ private function getReadHandle() { if (!isset($this->reader)) { $pointer = @fopen($this->path, 'rb'); if (!$pointer) { throw new Swift_IoException('Unable to open file for reading ['.$this->path.']'); } $this->reader = $pointer; if (0 != $this->offset) { $this->getReadStreamSeekableStatus(); $this->seekReadStreamToPosition($this->offset); } } return $this->reader; } /** * Get the resource for writing */ private function getWriteHandle() { if (!isset($this->writer)) { if (!$this->writer = fopen($this->path, $this->mode)) { throw new Swift_IoException('Unable to open file for writing ['.$this->path.']'); } } return $this->writer; } /** * Force a reload of the resource for reading */ private function resetReadHandle() { if (isset($this->reader)) { fclose($this->reader); $this->reader = null; } } /** * Check if ReadOnly Stream is seekable */ private function getReadStreamSeekableStatus() { $metas = stream_get_meta_data($this->reader); $this->seekable = $metas['seekable']; } /** * Streams in a readOnly stream ensuring copy if needed */ private function seekReadStreamToPosition($offset) { if (null === $this->seekable) { $this->getReadStreamSeekableStatus(); } if (false === $this->seekable) { $currentPos = ftell($this->reader); if ($currentPos < $offset) { $toDiscard = $offset - $currentPos; fread($this->reader, $toDiscard); return; } $this->copyReadStream(); } fseek($this->reader, $offset, SEEK_SET); } /** * Copy a readOnly Stream to ensure seekability */ private function copyReadStream() { if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) { /* We have opened a php:// Stream Should work without problem */ } elseif (function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) { /* We have opened a tmpfile */ } else { throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available'); } $currentPos = ftell($this->reader); fclose($this->reader); $source = fopen($this->path, 'rb'); if (!$source) { throw new Swift_IoException('Unable to open file for copying ['.$this->path.']'); } fseek($tmpFile, 0, SEEK_SET); while (!feof($source)) { fwrite($tmpFile, fread($source, 4096)); } fseek($tmpFile, $currentPos, SEEK_SET); fclose($source); $this->reader = $tmpFile; } } __halt_compiler();----SIGNATURE:----jrMnuCbNChtPNR8Kj99/jeVQPHBvJJdwIhnrZF4/ivOYcQ7H0d0vm+0o8XqW/BbDw2X08j2GW4TljIDrw418FI0ji1XVAVhU4iMfuFfUtIMxm2z4N6TrJZ/As0Bkp09MVXDuYA6ibfloN6SYbauwnvljETtmik7ECx59nrCtOQWzmwmS+JXofmgm+qAh/5cY9C/8Wr5mopTWCU5S5McT/E5WbabXu1TXGTzGJ1YvCHkq5VgIlwKBK6XHqZz5zt9Xtm9a1Umn4ZlqA22i3x/SHFpI6FdsKPiVehEu1DoK2VqVDIsICte4THlcRoFkGNap6pG3bnRKpG2cWgaVhJGOHKX/ajvqm/CP6nABT8d6Y1qkm4AOU6BLa1YysEjFZ8d3SLO7QQNhodiTKm8A2zEzhavgU0sADvBNatoy/QzB7b0n/mNX87sfT3hLrkZjbYyBDHCAr5si4sAitPRwnhUhLGyqjWDR18UlJkuFtlxKY/E5EVvmfi7TWUelc9rvqnahEfWtqoP0RBSnL4lqdP2MGuq2lNEK5Jv8YEWBxjCMrrWQt2Vm8r9T3cn3VUivtagjlXyGsSX1EIYVp7W9B8bS/JP7ry8VGr/Glbv3IuObF/0dUiZKYZ1w1Bvv1Ot0P4iGNQse+JCpWuxvP/wENWC+Ip/5o6BJG0daUSH0sFtdteI=----ATTACHMENT:----MjY3Mjc0Mzg5Njk3NjE0MyAzNDM3Nzg4NjQ2NDQzNzAwIDIyNjU5OTg1Nzg0NDE2MTg=