403Webshell
Server IP : 103.161.17.216  /  Your IP : 216.73.216.1
Web Server : nginx/1.18.0
System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/app.houseland.info/application/vendor/zbateson/stream-decorators/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/app.houseland.info/application/vendor/zbateson/stream-decorators/src/ChunkSplitStream.php
<?php
/**
 * This file is part of the ZBateson\StreamDecorators project.
 *
 * @license http://opensource.org/licenses/bsd-license.php BSD
 */

namespace ZBateson\StreamDecorators;

use GuzzleHttp\Psr7\StreamDecoratorTrait;
use Psr\Http\Message\StreamInterface;

/**
 * Inserts line ending characters after the set number of characters have been
 * written to the underlying stream.
 *
 * @author Zaahid Bateson
 */
class ChunkSplitStream implements StreamInterface
{
    use StreamDecoratorTrait;

    /**
     * @var int Number of bytes written, and importantly, if non-zero, writes a
     *      final $lineEnding on close (and so maintained instead of using
     *      tell() directly)
     */
    private $position;

    /**
     * @var int The number of characters in a line before inserting $lineEnding.
     */
    private $lineLength;

    /**
     * @var string The line ending characters to insert.
     */
    private $lineEnding;

    /**
     * @var int The strlen() of $lineEnding
     */
    private $lineEndingLength;

    /**
     * @var StreamInterface $stream
     */
    private $stream;

    public function __construct(StreamInterface $stream, int $lineLength = 76, string $lineEnding = "\r\n")
    {
        $this->stream = $stream;
        $this->lineLength = $lineLength;
        $this->lineEnding = $lineEnding;
        $this->lineEndingLength = \strlen($this->lineEnding);
    }

    /**
     * Inserts the line ending character after each line length characters in
     * the passed string, making sure previously written bytes are taken into
     * account.
     */
    private function getChunkedString(string $string) : string
    {
        $firstLine = '';
        if ($this->tell() !== 0) {
            $next = $this->lineLength - ($this->position % ($this->lineLength + $this->lineEndingLength));
            if (\strlen($string) > $next) {
                $firstLine = \substr($string, 0, $next) . $this->lineEnding;
                $string = \substr($string, $next);
            }
        }
        // chunk_split always ends with the passed line ending
        $chunked = $firstLine . \chunk_split($string, $this->lineLength, $this->lineEnding);
        return \substr($chunked, 0, \strlen($chunked) - $this->lineEndingLength);
    }

    /**
     * Writes the passed string to the underlying stream, ensuring line endings
     * are inserted every "line length" characters in the string.
     *
     * @param string $string
     * @return int number of bytes written
     */
    public function write($string) : int
    {
        $chunked = $this->getChunkedString($string);
        $this->position += \strlen($chunked);
        return $this->stream->write($chunked);
    }

    /**
     * Inserts a final line ending character.
     */
    private function beforeClose() : void
    {
        if ($this->position !== 0) {
            $this->stream->write($this->lineEnding);
        }
    }

    /**
     * @inheritDoc
     */
    public function close() : void
    {
        $this->beforeClose();
        $this->stream->close();
    }

    /**
     * @inheritDoc
     */
    public function detach()
    {
        $this->beforeClose();
        $this->stream->detach();

        return null;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit