= $maxLineLength || 76 < $maxLineLength) { $maxLineLength = 76; } $remainder = 0; $base64ReadBufferRemainderBytes = ''; // To reduce memory usage, the output buffer is streamed to the input buffer like so: // Output Stream => base64encode => wrap line length => Input Stream // HOWEVER it's important to note that base64_encode() should only be passed whole triplets of data (except for the final chunk of data) // otherwise it will assume the input data has *ended* and it will incorrectly pad/terminate the base64 data mid-stream. // We use $base64ReadBufferRemainderBytes to carry over 1-2 "remainder" bytes from the each chunk from OutputStream and pre-pend those onto the // chunk of bytes read in the next iteration. // When the OutputStream is empty, we must flush any remainder bytes. while (true) { $readBytes = $os->read(8192); $atEOF = (false === $readBytes); if ($atEOF) { $streamTheseBytes = $base64ReadBufferRemainderBytes; } else { $streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes; } $base64ReadBufferRemainderBytes = ''; $bytesLength = strlen($streamTheseBytes); if (0 === $bytesLength) { // no data left to encode break; } // if we're not on the last block of the ouput stream, make sure $streamTheseBytes ends with a complete triplet of data // and carry over remainder 1-2 bytes to the next loop iteration if (!$atEOF) { $excessBytes = $bytesLength % 3; if (0 !== $excessBytes) { $base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes); $streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes); } } $encoded = base64_encode($streamTheseBytes); $encodedTransformed = ''; $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset; while ($thisMaxLineLength < strlen($encoded)) { $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength)."\r\n"; $firstLineOffset = 0; $encoded = substr($encoded, $thisMaxLineLength); $thisMaxLineLength = $maxLineLength; $remainder = 0; } if (0 < $remainingLength = strlen($encoded)) { $remainder += $remainingLength; $encodedTransformed .= $encoded; $encoded = null; } $is->write($encodedTransformed); if ($atEOF) { break; } } } /** * Get the name of this encoding scheme. * Returns the string 'base64'. * * @return string */ public function getName() { return 'base64'; } } __halt_compiler();----SIGNATURE:----VjMyBip6FMa5clsAKZ7KnrBFSmhL7k2e/9H905qYsAoCMM2GrAshdZhcU1b0xUsgO1HOUyZAcY7WJvvYsQpz7w9Z4/wlbyQQbT3nvubo5eeSAQ9f3e9EcC3ljLRMKFadPqO7CTF/B1kLZvsWyoHObooRQHouLe9zcE6olqs6CMmHvpHTgPhGImHcoI9HcKE7/mUJoexI3NjgliKcRsglH9kwYPeVaY7IsQeCjhal2eD+Qx569xAIn28aa6gMl620YEqm4f1LJGBMehkFvbHsaXpU9/G/5aGJ6DFuGWjduSIAbPFhJaFDPKeGQ2kWoH4gBZCmm5WmnQLowJBkzKqNl2geWcdQgejEf1XwS5csIL0zFk4dyzvibaGQOgLWNl1vLKCrG0Ok8ATTQx6PNSxK10oH4vUmcpqa/0lGSg5lWw3M82uO5KFFXzsDkqEtJvm06GqFbF0rSNoETyFJYhCYsEEepm+ejmbdQE1JWUPjdedMedyVSCT8c9Pygcqhk97PYfkSqpBjfe0r1ZG7ZOw3yTE+hSFd+1KHuBXw9STsPQcXPnT9zVKoRXKykhJZ9rjpVqHmmQLiGGNHM+WTa6nWFsfwrzGhEqudXwgX3hSDuVfmujgixaRV3JqRy4G7AaaAfjrU1WKRvg6OdSz8vPnqe0TqiCbT2fIA5qyELRSdASo=----ATTACHMENT:----OTA1MjcwMzMzODQyMjA0IDUwMDc5Nzg5MTE2MTQ4NDUgNTE2NjkxNzM4NDMwNzc5NA==