Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Swoole\Memory; class Stream { protected $position; protected $var..

Decoded Output download

<?php
namespace Swoole\Memory;

class Stream
{
    protected $position;
    protected $varname;

    static $memory = array();

    function stream_open($path, $mode, $options, &$opened_path)
    {
        $url = parse_url($path);
        $this->varname = $url["host"];
        $this->position = 0;
        if (empty(self::$memory[$this->varname]))
        {
            self::$memory[$this->varname] = '';
        }
        return true;
    }

    function stream_read($count)
    {
        $ret = substr(self::$memory[$this->varname], $this->position, $count);
        $this->position += strlen($ret);
        return $ret;
    }

    function stream_write($data)
    {
        $left = substr(self::$memory[$this->varname], 0, $this->position);
        $right = substr(self::$memory[$this->varname], $this->position + strlen($data));
        self::$memory[$this->varname] = $left . $data . $right;
        $this->position += strlen($data);

        return strlen($data);
    }

    function stream_tell()
    {
        return $this->position;
    }

    function stream_eof()
    {
        return $this->position >= strlen(self::$memory[$this->varname]);
    }

    function stream_seek($offset, $whence)
    {
        switch ($whence)
        {
            case SEEK_SET:
                if ($offset < strlen(self::$memory[$this->varname]) && $offset >= 0)
                {
                    $this->position = $offset;

                    return true;
                }
                else
                {
                    return false;
                }
                break;

            case SEEK_CUR:
                if ($offset >= 0)
                {
                    $this->position += $offset;

                    return true;
                }
                else
                {
                    return false;
                }
                break;

            case SEEK_END:
                if (strlen(self::$memory[$this->varname]) + $offset >= 0)
                {
                    $this->position = strlen(self::$memory[$this->varname]) + $offset;

                    return true;
                }
                else
                {
                    return false;
                }
                break;

            default:
                return false;
        }
    }

    function stream_metadata($path, $option, $var)
    {
        if ($option == STREAM_META_TOUCH)
        {
            $url = parse_url($path);
            $varname = $url["host"];
            if (!isset(self::$memory[$varname]))
            {
                self::$memory[$varname] = '';
            }
            return true;
        }
        return false;
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php
namespace Swoole\Memory;

class Stream
{
    protected $position;
    protected $varname;

    static $memory = array();

    function stream_open($path, $mode, $options, &$opened_path)
    {
        $url = parse_url($path);
        $this->varname = $url["host"];
        $this->position = 0;
        if (empty(self::$memory[$this->varname]))
        {
            self::$memory[$this->varname] = '';
        }
        return true;
    }

    function stream_read($count)
    {
        $ret = substr(self::$memory[$this->varname], $this->position, $count);
        $this->position += strlen($ret);
        return $ret;
    }

    function stream_write($data)
    {
        $left = substr(self::$memory[$this->varname], 0, $this->position);
        $right = substr(self::$memory[$this->varname], $this->position + strlen($data));
        self::$memory[$this->varname] = $left . $data . $right;
        $this->position += strlen($data);

        return strlen($data);
    }

    function stream_tell()
    {
        return $this->position;
    }

    function stream_eof()
    {
        return $this->position >= strlen(self::$memory[$this->varname]);
    }

    function stream_seek($offset, $whence)
    {
        switch ($whence)
        {
            case SEEK_SET:
                if ($offset < strlen(self::$memory[$this->varname]) && $offset >= 0)
                {
                    $this->position = $offset;

                    return true;
                }
                else
                {
                    return false;
                }
                break;

            case SEEK_CUR:
                if ($offset >= 0)
                {
                    $this->position += $offset;

                    return true;
                }
                else
                {
                    return false;
                }
                break;

            case SEEK_END:
                if (strlen(self::$memory[$this->varname]) + $offset >= 0)
                {
                    $this->position = strlen(self::$memory[$this->varname]) + $offset;

                    return true;
                }
                else
                {
                    return false;
                }
                break;

            default:
                return false;
        }
    }

    function stream_metadata($path, $option, $var)
    {
        if ($option == STREAM_META_TOUCH)
        {
            $url = parse_url($path);
            $varname = $url["host"];
            if (!isset(self::$memory[$varname]))
            {
                self::$memory[$varname] = '';
            }
            return true;
        }
        return false;
    }
}

Function Calls

None

Variables

None

Stats

MD5 ab964f02bfa5531be5b37613369fc281
Eval Count 0
Decode Time 81 ms