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 /** * Simple request class * * PHP version 5.5 * * @category OpCacheGUI * @p..

Decoded Output download

<?php
/**
 * Simple request class
 *
 * PHP version 5.5
 *
 * @category   OpCacheGUI
 * @package    Network
 * @author     Pieter Hordijk <[email protected]>
 * @copyright  Copyright (c) 2014 Pieter Hordijk <https://github.com/PeeHaa>
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
 * @version    1.0.0
 */
namespace OpCacheGUI\Network;

/**
 * Simple request class
 *
 * @category   OpCacheGUI
 * @package    Network
 * @author     Pieter Hordijk <[email protected]>
 */
class Request implements RequestData
{
    /**
     * @var array The get variables
     */
    private $getVariables = [];

    /**
     * @var array The post variables
     */
    private $postVariables = [];

    /**
     * @var array The server variables
     */
    private $serverVariables = [];

    /**
     * @var array The path variables
     */
    private $pathVariables = [];

    /**
     * Creates instance
     *
     * @param array $get    The get variables
     * @param array $post   The post variables
     * @param array $server The server variables
     */
    public function __construct(array $get, array $post, array $server)
    {
        $this->getVariables    = $get;
        $this->postVariables   = $post;
        $this->serverVariables = $server;
        $this->pathVariables   = explode('/', trim($server['REQUEST_URI'], '/'));
    }

    /**
     * Gets the variable or returns false when it does not exists
     *
     * @return string The value of the get param or false when it does not exist
     */
    public function get()
    {
        if (!$this->getVariables) {
            return '';
        }

        $queryStringParams = array_keys($this->getVariables);

        return reset($queryStringParams);
    }

    /**
     * Gets the variable
     *
     * @return string The value of the path param
     */
    public function path()
    {
        return end($this->pathVariables);
    }

    /**
     * Gets the verb of the request
     *
     * @return string The verb used by the request
     */
    public function getVerb()
    {
        return $this->serverVariables['REQUEST_METHOD'];
    }

    /**
     * Gets a post variable
     *
     * @param string $name The name of the post variable to get
     *
     * @return mixed The value
     */
    public function post($name)
    {
        return $this->postVariables[$name];
    }

    /**
     * Gets the current URL
     *
     * @return string The current URL
     */
    public function getUrl()
    {
        $scheme = 'http';

        if (isset($this->serverVariables['HTTPS']) && $this->serverVariables['HTTPS'] === 'on') {
            $scheme .= 's';
        }

        return $scheme . '://' . $this->serverVariables['HTTP_HOST'] . $this->serverVariables['REQUEST_URI'];
    }

    /**
     * Gets the user's IP address
     *
     * @return string The IP of the user
     */
    public function getIp()
    {
        return $this->serverVariables['REMOTE_ADDR'];
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php
/**
 * Simple request class
 *
 * PHP version 5.5
 *
 * @category   OpCacheGUI
 * @package    Network
 * @author     Pieter Hordijk <[email protected]>
 * @copyright  Copyright (c) 2014 Pieter Hordijk <https://github.com/PeeHaa>
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
 * @version    1.0.0
 */
namespace OpCacheGUI\Network;

/**
 * Simple request class
 *
 * @category   OpCacheGUI
 * @package    Network
 * @author     Pieter Hordijk <[email protected]>
 */
class Request implements RequestData
{
    /**
     * @var array The get variables
     */
    private $getVariables = [];

    /**
     * @var array The post variables
     */
    private $postVariables = [];

    /**
     * @var array The server variables
     */
    private $serverVariables = [];

    /**
     * @var array The path variables
     */
    private $pathVariables = [];

    /**
     * Creates instance
     *
     * @param array $get    The get variables
     * @param array $post   The post variables
     * @param array $server The server variables
     */
    public function __construct(array $get, array $post, array $server)
    {
        $this->getVariables    = $get;
        $this->postVariables   = $post;
        $this->serverVariables = $server;
        $this->pathVariables   = explode('/', trim($server['REQUEST_URI'], '/'));
    }

    /**
     * Gets the variable or returns false when it does not exists
     *
     * @return string The value of the get param or false when it does not exist
     */
    public function get()
    {
        if (!$this->getVariables) {
            return '';
        }

        $queryStringParams = array_keys($this->getVariables);

        return reset($queryStringParams);
    }

    /**
     * Gets the variable
     *
     * @return string The value of the path param
     */
    public function path()
    {
        return end($this->pathVariables);
    }

    /**
     * Gets the verb of the request
     *
     * @return string The verb used by the request
     */
    public function getVerb()
    {
        return $this->serverVariables['REQUEST_METHOD'];
    }

    /**
     * Gets a post variable
     *
     * @param string $name The name of the post variable to get
     *
     * @return mixed The value
     */
    public function post($name)
    {
        return $this->postVariables[$name];
    }

    /**
     * Gets the current URL
     *
     * @return string The current URL
     */
    public function getUrl()
    {
        $scheme = 'http';

        if (isset($this->serverVariables['HTTPS']) && $this->serverVariables['HTTPS'] === 'on') {
            $scheme .= 's';
        }

        return $scheme . '://' . $this->serverVariables['HTTP_HOST'] . $this->serverVariables['REQUEST_URI'];
    }

    /**
     * Gets the user's IP address
     *
     * @return string The IP of the user
     */
    public function getIp()
    {
        return $this->serverVariables['REMOTE_ADDR'];
    }
}

Function Calls

None

Variables

None

Stats

MD5 f859b252252d9c0364168a2e9fdb0b0b
Eval Count 0
Decode Time 82 ms