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 Dingo\Api; use Dingo\Api\Auth\Auth; use Illuminate\Support\Str; use Dingo..
Decoded Output download
<?php
namespace Dingo\Api; use Dingo\Api\Auth\Auth; use Illuminate\Support\Str; use Dingo\Api\Routing\Router; use Dingo\Api\Http\InternalRequest; use Illuminate\Container\Container; use Illuminate\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Cookie; use Dingo\Api\Exception\InternalHttpException; use Symfony\Component\HttpFoundation\File\UploadedFile; use Illuminate\Support\Facades\Request as RequestFacade; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; class Dispatcher { protected $container; protected $files; protected $router; protected $auth; protected $requestStack = array(); protected $routeStack = array(); protected $version; protected $headers = array(); protected $cookies = array(); protected $parameters = array(); protected $content; protected $uploads = array(); protected $domain; protected $raw = false; protected $persistAuthentication = true; protected $subtype; protected $standardsTree; protected $prefix; protected $defaultVersion; protected $defaultDomain; protected $defaultFormat; public function __construct(Container $container, Filesystem $files, Router $router, Auth $auth) { $this->container = $container; $this->files = $files; $this->router = $router; $this->auth = $auth; $this->setupRequestStack(); } protected function setupRequestStack() { $this->requestStack[] = $this->container["request"]; } public function attach(array $files) { foreach ($files as $key => $file) { if (is_array($file)) { $file = new UploadedFile($file["path"], basename($file["path"]), $file["mime"], $file["size"]); } elseif (is_string($file)) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $file = new UploadedFile($file, basename($file), finfo_file($finfo, $file), $this->files->size($file)); } elseif (!$file instanceof UploadedFile) { continue; } $this->uploads[$key] = $file; } return $this; } public function be($user) { $this->auth->setUser($user); return $this; } public function json($content) { if (is_array($content)) { $content = json_encode($content); } $this->content = $content; return $this->header("Content-Type", "application/json"); } public function on($domain) { $this->domain = $domain; return $this; } public function raw() { $this->raw = true; return $this; } public function once() { $this->persistAuthentication = false; return $this; } public function version($version) { $this->version = $version; return $this; } public function with($parameters) { $this->parameters = array_merge($this->parameters, is_array($parameters) ? $parameters : func_get_args()); return $this; } public function header($key, $value) { $this->headers[$key] = $value; return $this; } public function cookie(Cookie $cookie) { $this->cookies[] = $cookie; return $this; } public function get($uri, $parameters = array()) { return $this->queueRequest("get", $uri, $parameters); } public function post($uri, $parameters = array(), $content = '') { return $this->queueRequest("post", $uri, $parameters, $content); } public function put($uri, $parameters = array(), $content = '') { return $this->queueRequest("put", $uri, $parameters, $content); } public function patch($uri, $parameters = array(), $content = '') { return $this->queueRequest("patch", $uri, $parameters, $content); } public function delete($uri, $parameters = array(), $content = '') { return $this->queueRequest("delete", $uri, $parameters, $content); } protected function queueRequest($verb, $uri, $parameters, $content = '') { if (!empty($content)) { $this->content = $content; } if (end($this->requestStack) != $this->container["request"]) { $this->requestStack[] = $this->container["request"]; } $this->requestStack[] = $request = $this->createRequest($verb, $uri, $parameters); return $this->dispatch($request); } protected function createRequest($verb, $uri, $parameters) { $parameters = array_merge($this->parameters, (array) $parameters); $uri = $this->addPrefixToUri($uri); $rootUrl = $this->getRootRequest()->root(); if (!parse_url($uri, PHP_URL_SCHEME) && parse_url($rootUrl) !== false) { $uri = rtrim($rootUrl, "/") . "/" . ltrim($uri, "/"); } $request = InternalRequest::create($uri, $verb, $parameters, $this->cookies, $this->uploads, $this->container["request"]->server->all(), $this->content); $request->headers->set("host", $this->getDomain()); foreach ($this->headers as $header => $value) { $request->headers->set($header, $value); } $request->headers->set("accept", $this->getAcceptHeader()); return $request; } protected function addPrefixToUri($uri) { if (!isset($this->prefix)) { return $uri; } $uri = trim($uri, "/"); if (Str::startsWith($uri, $this->prefix)) { return $uri; } return rtrim("/" . trim($this->prefix, "/") . "/" . $uri, "/"); } protected function getAcceptHeader() { return sprintf("application/%s.%s.%s+%s", $this->getStandardsTree(), $this->getSubtype(), $this->getVersion(), $this->getFormat()); } protected function dispatch(InternalRequest $request) { $this->routeStack[] = $this->router->getCurrentRoute(); $this->clearCachedFacadeInstance(); try { $this->container->instance("request", $request); $response = $this->router->dispatch($request); if (!$response->isSuccessful() && !$response->isRedirection()) { throw new InternalHttpException($response); } if (!$this->raw) { $response = $response->getOriginalContent(); } } catch (HttpExceptionInterface $exception) { $this->refreshRequestStack(); throw $exception; } $this->refreshRequestStack(); return $response; } protected function refreshRequestStack() { if (!$this->persistAuthentication) { $this->auth->setUser(null); $this->persistAuthentication = true; } if ($route = array_pop($this->routeStack)) { $this->router->setCurrentRoute($route); } $this->replaceRequestInstance(); $this->clearCachedFacadeInstance(); $this->raw = false; $this->version = $this->domain = $this->content = null; $this->parameters = $this->uploads = array(); } protected function replaceRequestInstance() { array_pop($this->requestStack); $this->container->instance("request", end($this->requestStack)); } protected function clearCachedFacadeInstance() { RequestFacade::clearResolvedInstance("request"); } protected function getRootRequest() { return reset($this->requestStack); } public function getDomain() { return $this->domain ?: $this->defaultDomain; } public function getVersion() { return $this->version ?: $this->defaultVersion; } public function getFormat() { return $this->defaultFormat; } public function getSubtype() { return $this->subtype; } public function setSubtype($subtype) { $this->subtype = $subtype; } public function getStandardsTree() { return $this->standardsTree; } public function setStandardsTree($standardsTree) { $this->standardsTree = $standardsTree; } public function setPrefix($prefix) { $this->prefix = $prefix; } public function setDefaultVersion($version) { $this->defaultVersion = $version; } public function setDefaultDomain($domain) { $this->defaultDomain = $domain; } public function setDefaultFormat($format) { $this->defaultFormat = $format; } } ?>
Did this file decode correctly?
Original Code
<?php
namespace Dingo\Api; use Dingo\Api\Auth\Auth; use Illuminate\Support\Str; use Dingo\Api\Routing\Router; use Dingo\Api\Http\InternalRequest; use Illuminate\Container\Container; use Illuminate\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Cookie; use Dingo\Api\Exception\InternalHttpException; use Symfony\Component\HttpFoundation\File\UploadedFile; use Illuminate\Support\Facades\Request as RequestFacade; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; class Dispatcher { protected $container; protected $files; protected $router; protected $auth; protected $requestStack = array(); protected $routeStack = array(); protected $version; protected $headers = array(); protected $cookies = array(); protected $parameters = array(); protected $content; protected $uploads = array(); protected $domain; protected $raw = false; protected $persistAuthentication = true; protected $subtype; protected $standardsTree; protected $prefix; protected $defaultVersion; protected $defaultDomain; protected $defaultFormat; public function __construct(Container $container, Filesystem $files, Router $router, Auth $auth) { $this->container = $container; $this->files = $files; $this->router = $router; $this->auth = $auth; $this->setupRequestStack(); } protected function setupRequestStack() { $this->requestStack[] = $this->container["\162\145\161\165\145\163\164"]; } public function attach(array $files) { foreach ($files as $key => $file) { if (is_array($file)) { $file = new UploadedFile($file["\160\141\x74\150"], basename($file["\x70\x61\164\x68"]), $file["\x6d\151\x6d\x65"], $file["\x73\151\172\x65"]); } elseif (is_string($file)) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $file = new UploadedFile($file, basename($file), finfo_file($finfo, $file), $this->files->size($file)); } elseif (!$file instanceof UploadedFile) { continue; } $this->uploads[$key] = $file; } return $this; } public function be($user) { $this->auth->setUser($user); return $this; } public function json($content) { if (is_array($content)) { $content = json_encode($content); } $this->content = $content; return $this->header("\x43\157\156\164\145\x6e\164\x2d\124\x79\x70\145", "\x61\x70\160\x6c\x69\x63\141\x74\x69\157\x6e\x2f\x6a\x73\157\156"); } public function on($domain) { $this->domain = $domain; return $this; } public function raw() { $this->raw = true; return $this; } public function once() { $this->persistAuthentication = false; return $this; } public function version($version) { $this->version = $version; return $this; } public function with($parameters) { $this->parameters = array_merge($this->parameters, is_array($parameters) ? $parameters : func_get_args()); return $this; } public function header($key, $value) { $this->headers[$key] = $value; return $this; } public function cookie(Cookie $cookie) { $this->cookies[] = $cookie; return $this; } public function get($uri, $parameters = array()) { return $this->queueRequest("\147\145\x74", $uri, $parameters); } public function post($uri, $parameters = array(), $content = '') { return $this->queueRequest("\x70\x6f\163\164", $uri, $parameters, $content); } public function put($uri, $parameters = array(), $content = '') { return $this->queueRequest("\x70\x75\x74", $uri, $parameters, $content); } public function patch($uri, $parameters = array(), $content = '') { return $this->queueRequest("\x70\141\164\143\x68", $uri, $parameters, $content); } public function delete($uri, $parameters = array(), $content = '') { return $this->queueRequest("\144\145\154\145\x74\x65", $uri, $parameters, $content); } protected function queueRequest($verb, $uri, $parameters, $content = '') { if (!empty($content)) { $this->content = $content; } if (end($this->requestStack) != $this->container["\x72\x65\161\x75\x65\x73\164"]) { $this->requestStack[] = $this->container["\162\x65\161\165\145\x73\x74"]; } $this->requestStack[] = $request = $this->createRequest($verb, $uri, $parameters); return $this->dispatch($request); } protected function createRequest($verb, $uri, $parameters) { $parameters = array_merge($this->parameters, (array) $parameters); $uri = $this->addPrefixToUri($uri); $rootUrl = $this->getRootRequest()->root(); if (!parse_url($uri, PHP_URL_SCHEME) && parse_url($rootUrl) !== false) { $uri = rtrim($rootUrl, "\x2f") . "\57" . ltrim($uri, "\x2f"); } $request = InternalRequest::create($uri, $verb, $parameters, $this->cookies, $this->uploads, $this->container["\x72\145\x71\x75\x65\163\x74"]->server->all(), $this->content); $request->headers->set("\x68\x6f\x73\164", $this->getDomain()); foreach ($this->headers as $header => $value) { $request->headers->set($header, $value); } $request->headers->set("\x61\x63\143\x65\x70\x74", $this->getAcceptHeader()); return $request; } protected function addPrefixToUri($uri) { if (!isset($this->prefix)) { return $uri; } $uri = trim($uri, "\x2f"); if (Str::startsWith($uri, $this->prefix)) { return $uri; } return rtrim("\x2f" . trim($this->prefix, "\57") . "\x2f" . $uri, "\x2f"); } protected function getAcceptHeader() { return sprintf("\x61\x70\160\x6c\x69\x63\141\164\x69\157\156\57\x25\163\x2e\x25\163\x2e\x25\x73\53\45\163", $this->getStandardsTree(), $this->getSubtype(), $this->getVersion(), $this->getFormat()); } protected function dispatch(InternalRequest $request) { $this->routeStack[] = $this->router->getCurrentRoute(); $this->clearCachedFacadeInstance(); try { $this->container->instance("\162\145\161\x75\x65\163\164", $request); $response = $this->router->dispatch($request); if (!$response->isSuccessful() && !$response->isRedirection()) { throw new InternalHttpException($response); } if (!$this->raw) { $response = $response->getOriginalContent(); } } catch (HttpExceptionInterface $exception) { $this->refreshRequestStack(); throw $exception; } $this->refreshRequestStack(); return $response; } protected function refreshRequestStack() { if (!$this->persistAuthentication) { $this->auth->setUser(null); $this->persistAuthentication = true; } if ($route = array_pop($this->routeStack)) { $this->router->setCurrentRoute($route); } $this->replaceRequestInstance(); $this->clearCachedFacadeInstance(); $this->raw = false; $this->version = $this->domain = $this->content = null; $this->parameters = $this->uploads = array(); } protected function replaceRequestInstance() { array_pop($this->requestStack); $this->container->instance("\162\145\x71\165\x65\163\x74", end($this->requestStack)); } protected function clearCachedFacadeInstance() { RequestFacade::clearResolvedInstance("\162\x65\161\x75\x65\x73\x74"); } protected function getRootRequest() { return reset($this->requestStack); } public function getDomain() { return $this->domain ?: $this->defaultDomain; } public function getVersion() { return $this->version ?: $this->defaultVersion; } public function getFormat() { return $this->defaultFormat; } public function getSubtype() { return $this->subtype; } public function setSubtype($subtype) { $this->subtype = $subtype; } public function getStandardsTree() { return $this->standardsTree; } public function setStandardsTree($standardsTree) { $this->standardsTree = $standardsTree; } public function setPrefix($prefix) { $this->prefix = $prefix; } public function setDefaultVersion($version) { $this->defaultVersion = $version; } public function setDefaultDomain($domain) { $this->defaultDomain = $domain; } public function setDefaultFormat($format) { $this->defaultFormat = $format; } }
Function Calls
None |
Stats
MD5 | 9879214260cac72a7f81626e6f1cf701 |
Eval Count | 0 |
Decode Time | 90 ms |