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 Whoops; use InvalidArgumentException; use Throwable; use Whoops\Exception..

Decoded Output download

<?php
 namespace Whoops; use InvalidArgumentException; use Throwable; use Whoops\Exception\ErrorException; use Whoops\Handler\CallbackHandler; use Whoops\Handler\Handler; use Whoops\Handler\HandlerInterface; use Whoops\Inspector\CallableInspectorFactory; use Whoops\Inspector\InspectorFactory; use Whoops\Inspector\InspectorFactoryInterface; use Whoops\Inspector\InspectorInterface; use Whoops\Util\Misc; use Whoops\Util\SystemFacade; final class Run implements RunInterface { private $isRegistered; private $allowQuit = true; private $sendOutput = true; private $sendHttpCode = 500; private $sendExitCode = 1; private $handlerStack = array(); private $silencedPatterns = array(); private $system; private $canThrowExceptions = true; private $inspectorFactory; private $frameFilters = array(); public function __construct(SystemFacade $system = null) { $this->system = $system ?: new SystemFacade(); $this->inspectorFactory = new InspectorFactory(); } public function appendHandler($handler) { array_unshift($this->handlerStack, $this->resolveHandler($handler)); return $this; } public function prependHandler($handler) { return $this->pushHandler($handler); } public function pushHandler($handler) { $this->handlerStack[] = $this->resolveHandler($handler); return $this; } public function popHandler() { return array_pop($this->handlerStack); } public function removeFirstHandler() { array_pop($this->handlerStack); } public function removeLastHandler() { array_shift($this->handlerStack); } public function getHandlers() { return $this->handlerStack; } public function clearHandlers() { $this->handlerStack = array(); return $this; } public function getFrameFilters() { return $this->frameFilters; } public function clearFrameFilters() { $this->frameFilters = array(); return $this; } public function register() { if (!$this->isRegistered) { class_exists("\Whoops\Exception\ErrorException"); class_exists("\Whoops\Exception\FrameCollection"); class_exists("\Whoops\Exception\Frame"); class_exists("\Whoops\Exception\Inspector"); class_exists("\Whoops\Inspector\InspectorFactory"); $this->system->setErrorHandler(array($this, self::ERROR_HANDLER)); $this->system->setExceptionHandler(array($this, self::EXCEPTION_HANDLER)); $this->system->registerShutdownFunction(array($this, self::SHUTDOWN_HANDLER)); $this->isRegistered = true; } return $this; } public function unregister() { if ($this->isRegistered) { $this->system->restoreExceptionHandler(); $this->system->restoreErrorHandler(); $this->isRegistered = false; } return $this; } public function allowQuit($exit = null) { if (func_num_args() == 0) { return $this->allowQuit; } return $this->allowQuit = (bool) $exit; } public function silenceErrorsInPaths($patterns, $levels = 10240) { $this->silencedPatterns = array_merge($this->silencedPatterns, array_map(function ($pattern) use($levels) { return array("pattern" => $pattern, "levels" => $levels); }, (array) $patterns)); return $this; } public function getSilenceErrorsInPaths() { return $this->silencedPatterns; } public function sendHttpCode($code = null) { if (func_num_args() == 0) { return $this->sendHttpCode; } if (!$code) { return $this->sendHttpCode = false; } if ($code === true) { $code = 500; } if ($code < 400 || 600 <= $code) { throw new InvalidArgumentException("Invalid status code '{$code}', must be 4xx or 5xx"); } return $this->sendHttpCode = $code; } public function sendExitCode($code = null) { if (func_num_args() == 0) { return $this->sendExitCode; } if ($code < 0 || 255 <= $code) { throw new InvalidArgumentException("Invalid status code '{$code}', must be between 0 and 254"); } return $this->sendExitCode = (int) $code; } public function writeToOutput($send = null) { if (func_num_args() == 0) { return $this->sendOutput; } return $this->sendOutput = (bool) $send; } public function handleException($exception) { $inspector = $this->getInspector($exception); $this->system->startOutputBuffering(); $handlerResponse = null; $handlerContentType = null; try { foreach (array_reverse($this->handlerStack) as $handler) { $handler->setRun($this); $handler->setInspector($inspector); $handler->setException($exception); $handlerResponse = $handler->handle($exception); $handlerContentType = method_exists($handler, "contentType") ? $handler->contentType() : null; if (in_array($handlerResponse, array(Handler::LAST_HANDLER, Handler::QUIT))) { break; } } $willQuit = $handlerResponse == Handler::QUIT && $this->allowQuit(); } finally { $output = $this->system->cleanOutputBuffer(); } if ($this->writeToOutput()) { if ($willQuit) { while ($this->system->getOutputBufferLevel() > 0) { $this->system->endOutputBuffering(); } if (Misc::canSendHeaders() && $handlerContentType) { header("Content-Type: {$handlerContentType}"); } } $this->writeToOutputNow($output); } if ($willQuit) { $this->system->flushOutputBuffer(); $this->system->stopExecution($this->sendExitCode()); } return $output; } public function handleError($level, $message, $file = null, $line = null) { if ($level & $this->system->getErrorReportingLevel()) { foreach ($this->silencedPatterns as $entry) { $pathMatches = (bool) preg_match($entry["pattern"], $file); $levelMatches = $level & $entry["levels"]; if ($pathMatches && $levelMatches) { return true; } } $exception = new ErrorException($message, $level, $level, $file, $line); if ($this->canThrowExceptions) { throw $exception; } else { $this->handleException($exception); } return true; } return false; } public function handleShutdown() { $this->canThrowExceptions = false; $error = $this->system->getLastError(); if ($error && Misc::isLevelFatal($error["type"])) { $this->allowQuit = false; $this->handleError($error["type"], $error["message"], $error["file"], $error["line"]); } } public function setInspectorFactory(InspectorFactoryInterface $factory) { $this->inspectorFactory = $factory; } public function addFrameFilter($filterCallback) { if (!is_callable($filterCallback)) { throw new \InvalidArgumentException(sprintf("A frame filter must be of type callable, %s type given.", gettype($filterCallback))); } $this->frameFilters[] = $filterCallback; return $this; } private function getInspector($exception) { return $this->inspectorFactory->create($exception); } private function resolveHandler($handler) { if (is_callable($handler)) { $handler = new CallbackHandler($handler); } if (!$handler instanceof HandlerInterface) { throw new InvalidArgumentException("Handler must be a callable, or instance of " . "Whoops\Handler\HandlerInterface"); } return $handler; } private function writeToOutputNow($output) { if ($this->sendHttpCode() && Misc::canSendHeaders()) { $this->system->setHttpResponseCode($this->sendHttpCode()); } echo $output; return $this; } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Whoops; use InvalidArgumentException; use Throwable; use Whoops\Exception\ErrorException; use Whoops\Handler\CallbackHandler; use Whoops\Handler\Handler; use Whoops\Handler\HandlerInterface; use Whoops\Inspector\CallableInspectorFactory; use Whoops\Inspector\InspectorFactory; use Whoops\Inspector\InspectorFactoryInterface; use Whoops\Inspector\InspectorInterface; use Whoops\Util\Misc; use Whoops\Util\SystemFacade; final class Run implements RunInterface { private $isRegistered; private $allowQuit = true; private $sendOutput = true; private $sendHttpCode = 500; private $sendExitCode = 1; private $handlerStack = array(); private $silencedPatterns = array(); private $system; private $canThrowExceptions = true; private $inspectorFactory; private $frameFilters = array(); public function __construct(SystemFacade $system = null) { $this->system = $system ?: new SystemFacade(); $this->inspectorFactory = new InspectorFactory(); } public function appendHandler($handler) { array_unshift($this->handlerStack, $this->resolveHandler($handler)); return $this; } public function prependHandler($handler) { return $this->pushHandler($handler); } public function pushHandler($handler) { $this->handlerStack[] = $this->resolveHandler($handler); return $this; } public function popHandler() { return array_pop($this->handlerStack); } public function removeFirstHandler() { array_pop($this->handlerStack); } public function removeLastHandler() { array_shift($this->handlerStack); } public function getHandlers() { return $this->handlerStack; } public function clearHandlers() { $this->handlerStack = array(); return $this; } public function getFrameFilters() { return $this->frameFilters; } public function clearFrameFilters() { $this->frameFilters = array(); return $this; } public function register() { if (!$this->isRegistered) { class_exists("\134\x57\150\x6f\157\160\163\x5c\105\170\x63\145\160\x74\x69\157\x6e\x5c\105\162\162\x6f\x72\x45\170\143\x65\160\x74\x69\157\156"); class_exists("\134\x57\150\x6f\157\160\163\134\105\x78\x63\x65\x70\164\151\157\x6e\134\x46\x72\x61\155\x65\x43\157\x6c\x6c\x65\x63\x74\151\157\156"); class_exists("\134\x57\x68\157\157\160\x73\134\105\170\143\145\x70\164\x69\157\156\134\106\x72\x61\x6d\145"); class_exists("\x5c\x57\x68\x6f\157\x70\x73\134\x45\170\x63\145\x70\164\151\157\156\x5c\111\156\x73\160\145\143\164\157\162"); class_exists("\134\127\x68\157\x6f\x70\163\x5c\111\x6e\x73\160\145\143\x74\157\x72\134\x49\x6e\163\x70\x65\143\x74\157\x72\x46\x61\x63\164\x6f\x72\x79"); $this->system->setErrorHandler(array($this, self::ERROR_HANDLER)); $this->system->setExceptionHandler(array($this, self::EXCEPTION_HANDLER)); $this->system->registerShutdownFunction(array($this, self::SHUTDOWN_HANDLER)); $this->isRegistered = true; } return $this; } public function unregister() { if ($this->isRegistered) { $this->system->restoreExceptionHandler(); $this->system->restoreErrorHandler(); $this->isRegistered = false; } return $this; } public function allowQuit($exit = null) { if (func_num_args() == 0) { return $this->allowQuit; } return $this->allowQuit = (bool) $exit; } public function silenceErrorsInPaths($patterns, $levels = 10240) { $this->silencedPatterns = array_merge($this->silencedPatterns, array_map(function ($pattern) use($levels) { return array("\x70\x61\x74\x74\x65\162\156" => $pattern, "\154\x65\166\145\x6c\x73" => $levels); }, (array) $patterns)); return $this; } public function getSilenceErrorsInPaths() { return $this->silencedPatterns; } public function sendHttpCode($code = null) { if (func_num_args() == 0) { return $this->sendHttpCode; } if (!$code) { return $this->sendHttpCode = false; } if ($code === true) { $code = 500; } if ($code < 400 || 600 <= $code) { throw new InvalidArgumentException("\x49\x6e\166\141\x6c\151\x64\x20\163\164\x61\x74\165\163\40\x63\157\x64\x65\x20\x27{$code}\x27\54\40\155\165\x73\x74\x20\x62\x65\x20\64\x78\170\40\157\x72\x20\65\x78\170"); } return $this->sendHttpCode = $code; } public function sendExitCode($code = null) { if (func_num_args() == 0) { return $this->sendExitCode; } if ($code < 0 || 255 <= $code) { throw new InvalidArgumentException("\x49\x6e\166\141\154\151\x64\x20\163\164\x61\164\x75\163\x20\143\157\x64\145\40\47{$code}\47\54\x20\x6d\165\x73\164\40\142\x65\40\142\145\164\167\x65\145\x6e\40\x30\x20\141\156\x64\40\x32\65\x34"); } return $this->sendExitCode = (int) $code; } public function writeToOutput($send = null) { if (func_num_args() == 0) { return $this->sendOutput; } return $this->sendOutput = (bool) $send; } public function handleException($exception) { $inspector = $this->getInspector($exception); $this->system->startOutputBuffering(); $handlerResponse = null; $handlerContentType = null; try { foreach (array_reverse($this->handlerStack) as $handler) { $handler->setRun($this); $handler->setInspector($inspector); $handler->setException($exception); $handlerResponse = $handler->handle($exception); $handlerContentType = method_exists($handler, "\x63\157\x6e\164\x65\x6e\x74\124\x79\x70\145") ? $handler->contentType() : null; if (in_array($handlerResponse, array(Handler::LAST_HANDLER, Handler::QUIT))) { break; } } $willQuit = $handlerResponse == Handler::QUIT && $this->allowQuit(); } finally { $output = $this->system->cleanOutputBuffer(); } if ($this->writeToOutput()) { if ($willQuit) { while ($this->system->getOutputBufferLevel() > 0) { $this->system->endOutputBuffering(); } if (Misc::canSendHeaders() && $handlerContentType) { header("\x43\x6f\x6e\164\x65\156\164\x2d\124\171\x70\x65\x3a\x20{$handlerContentType}"); } } $this->writeToOutputNow($output); } if ($willQuit) { $this->system->flushOutputBuffer(); $this->system->stopExecution($this->sendExitCode()); } return $output; } public function handleError($level, $message, $file = null, $line = null) { if ($level & $this->system->getErrorReportingLevel()) { foreach ($this->silencedPatterns as $entry) { $pathMatches = (bool) preg_match($entry["\x70\x61\164\164\x65\162\156"], $file); $levelMatches = $level & $entry["\154\x65\x76\145\154\163"]; if ($pathMatches && $levelMatches) { return true; } } $exception = new ErrorException($message, $level, $level, $file, $line); if ($this->canThrowExceptions) { throw $exception; } else { $this->handleException($exception); } return true; } return false; } public function handleShutdown() { $this->canThrowExceptions = false; $error = $this->system->getLastError(); if ($error && Misc::isLevelFatal($error["\x74\171\160\145"])) { $this->allowQuit = false; $this->handleError($error["\x74\171\x70\x65"], $error["\x6d\145\163\x73\141\x67\145"], $error["\x66\151\x6c\145"], $error["\154\151\156\x65"]); } } public function setInspectorFactory(InspectorFactoryInterface $factory) { $this->inspectorFactory = $factory; } public function addFrameFilter($filterCallback) { if (!is_callable($filterCallback)) { throw new \InvalidArgumentException(sprintf("\101\x20\x66\162\x61\155\145\40\x66\x69\x6c\164\x65\162\x20\x6d\165\x73\164\x20\142\x65\x20\x6f\x66\40\164\171\x70\x65\40\143\x61\154\154\x61\x62\x6c\x65\x2c\x20\45\x73\x20\164\171\160\x65\x20\x67\151\x76\145\156\56", gettype($filterCallback))); } $this->frameFilters[] = $filterCallback; return $this; } private function getInspector($exception) { return $this->inspectorFactory->create($exception); } private function resolveHandler($handler) { if (is_callable($handler)) { $handler = new CallbackHandler($handler); } if (!$handler instanceof HandlerInterface) { throw new InvalidArgumentException("\110\x61\x6e\x64\x6c\x65\x72\40\x6d\x75\163\x74\40\x62\x65\x20\x61\40\143\141\154\154\141\142\154\145\54\x20\x6f\162\x20\x69\x6e\x73\x74\x61\156\x63\x65\40\x6f\x66\40" . "\x57\x68\157\x6f\x70\163\x5c\110\141\156\x64\154\145\162\x5c\110\x61\x6e\x64\x6c\145\162\x49\x6e\x74\x65\162\146\x61\x63\x65"); } return $handler; } private function writeToOutputNow($output) { if ($this->sendHttpCode() && Misc::canSendHeaders()) { $this->system->setHttpResponseCode($this->sendHttpCode()); } echo $output; return $this; } }

Function Calls

None

Variables

None

Stats

MD5 0994afc125e31cc2035c72b86be8800f
Eval Count 0
Decode Time 85 ms