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 yii\web; use Yii; use yii\base\Component; use yii\base\InvalidConfigExcep..

Decoded Output download

<?php
 namespace yii\web; use Yii; use yii\base\Component; use yii\base\InvalidConfigException; use yii\caching\CacheInterface; use yii\di\Instance; use yii\helpers\Url; class UrlManager extends Component { public $enablePrettyUrl = false; public $enableStrictParsing = false; public $rules = array(); public $suffix; public $showScriptName = true; public $routeParam = "r"; public $cache = "cache"; public $ruleConfig = array("class" => "yii\web\UrlRule"); public $normalizer = false; protected $cacheKey = __CLASS__; private $_baseUrl; private $_scriptUrl; private $_hostInfo; private $_ruleCache; public function init() { parent::init(); if ($this->normalizer !== false) { $this->normalizer = Yii::createObject($this->normalizer); if (!$this->normalizer instanceof UrlNormalizer) { throw new InvalidConfigException("`" . get_class($this) . "::normalizer` should be an instance of `" . UrlNormalizer::className() . "` or its DI compatible configuration."); } } if (!$this->enablePrettyUrl) { return; } if (!empty($this->rules)) { $this->rules = $this->buildRules($this->rules); } } public function addRules($rules, $append = true) { if (!$this->enablePrettyUrl) { return; } $rules = $this->buildRules($rules); if ($append) { $this->rules = array_merge($this->rules, $rules); } else { $this->rules = array_merge($rules, $this->rules); } } protected function buildRules($ruleDeclarations) { $builtRules = $this->getBuiltRulesFromCache($ruleDeclarations); if ($builtRules !== false) { return $builtRules; } $builtRules = array(); $verbs = "GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS"; foreach ($ruleDeclarations as $key => $rule) { if (is_string($rule)) { $rule = array("route" => $rule); if (preg_match("/^((?:({$verbs}),)*({$verbs}))\s+(.*)$/", $key, $matches)) { $rule["verb"] = explode(",", $matches[1]); $key = $matches[4]; } $rule["pattern"] = $key; } if (is_array($rule)) { $rule = Yii::createObject(array_merge($this->ruleConfig, $rule)); } if (!$rule instanceof UrlRuleInterface) { throw new InvalidConfigException("URL rule class must implement UrlRuleInterface."); } $builtRules[] = $rule; } $this->setBuiltRulesCache($ruleDeclarations, $builtRules); return $builtRules; } private function ensureCache() { if (!$this->cache instanceof CacheInterface && $this->cache !== false && $this->cache !== null) { try { $this->cache = Instance::ensure($this->cache, "yii\caching\CacheInterface"); } catch (InvalidConfigException $e) { Yii::warning("Unable to use cache for URL manager: " . $e->getMessage()); $this->cache = null; } } return $this->cache; } protected function setBuiltRulesCache($ruleDeclarations, $builtRules) { $cache = $this->ensureCache(); if (!$cache) { return false; } return $cache->set(array($this->cacheKey, $this->ruleConfig, $ruleDeclarations), $builtRules); } protected function getBuiltRulesFromCache($ruleDeclarations) { $cache = $this->ensureCache(); if (!$cache) { return false; } return $cache->get(array($this->cacheKey, $this->ruleConfig, $ruleDeclarations)); } public function parseRequest($request) { if ($this->enablePrettyUrl) { foreach ($this->rules as $rule) { $result = $rule->parseRequest($this, $request); if (YII_DEBUG) { Yii::debug(array("rule" => method_exists($rule, "__toString") ? $rule->__toString() : get_class($rule), "match" => $result !== false, "parent" => null), __METHOD__); } if ($result !== false) { return $result; } } if ($this->enableStrictParsing) { return false; } Yii::debug("No matching URL rules. Using default URL parsing logic.", __METHOD__); $suffix = (string) $this->suffix; $pathInfo = $request->getPathInfo(); $normalized = false; if ($this->normalizer !== false) { $pathInfo = $this->normalizer->normalizePathInfo($pathInfo, $suffix, $normalized); } if ($suffix !== '' && $pathInfo !== '') { $n = strlen($this->suffix); if (substr_compare($pathInfo, $this->suffix, -$n, $n) === 0) { $pathInfo = substr($pathInfo, 0, -$n); if ($pathInfo === '') { return false; } } else { return false; } } if ($normalized) { return $this->normalizer->normalizeRoute(array($pathInfo, array())); } return array($pathInfo, array()); } Yii::debug("Pretty URL not enabled. Using default URL parsing logic.", __METHOD__); $route = $request->getQueryParam($this->routeParam, ''); if (is_array($route)) { $route = ''; } return array((string) $route, array()); } public function createUrl($params) { $params = (array) $params; $anchor = isset($params["#"]) ? "#" . $params["#"] : ''; unset($params["#"], $params[$this->routeParam]); $route = trim(isset($params[0]) ? $params[0] : '', "/"); unset($params[0]); $baseUrl = $this->showScriptName || !$this->enablePrettyUrl ? $this->getScriptUrl() : $this->getBaseUrl(); if ($this->enablePrettyUrl) { $cacheKey = $route . "?"; foreach ($params as $key => $value) { if ($value !== null) { $cacheKey .= $key . "&"; } } $url = $this->getUrlFromCache($cacheKey, $route, $params); if ($url === false) { foreach ($this->rules as $rule) { if (in_array($rule, $this->_ruleCache[$cacheKey], true)) { continue; } $url = $rule->createUrl($this, $route, $params); if ($this->canBeCached($rule)) { $this->setRuleToCache($cacheKey, $rule); } if ($url !== false) { break; } } } if ($url !== false) { if (strpos($url, "://") !== false) { if ($baseUrl !== '' && ($pos = strpos($url, "/", 8)) !== false) { return substr($url, 0, $pos) . $baseUrl . substr($url, $pos) . $anchor; } return $url . $baseUrl . $anchor; } elseif (strncmp($url, "//", 2) === 0) { if ($baseUrl !== '' && ($pos = strpos($url, "/", 2)) !== false) { return substr($url, 0, $pos) . $baseUrl . substr($url, $pos) . $anchor; } return $url . $baseUrl . $anchor; } $url = ltrim($url, "/"); return "{$baseUrl}/{$url}{$anchor}"; } if ($this->suffix !== null) { $route .= $this->suffix; } if (!empty($params) && ($query = http_build_query($params)) !== '') { $route .= "?" . $query; } $route = ltrim($route, "/"); return "{$baseUrl}/{$route}{$anchor}"; } $url = "{$baseUrl}?{$this->routeParam}=" . urlencode($route); if (!empty($params) && ($query = http_build_query($params)) !== '') { $url .= "&" . $query; } return $url . $anchor; } protected function canBeCached(UrlRuleInterface $rule) { return !method_exists($rule, "getCreateUrlStatus") || ($status = $rule->getCreateUrlStatus()) === null || $status === UrlRule::CREATE_STATUS_SUCCESS || $status & UrlRule::CREATE_STATUS_PARAMS_MISMATCH; } protected function getUrlFromCache($cacheKey, $route, $params) { if (!empty($this->_ruleCache[$cacheKey])) { foreach ($this->_ruleCache[$cacheKey] as $rule) { if (($url = $rule->createUrl($this, $route, $params)) !== false) { return $url; } } } else { $this->_ruleCache[$cacheKey] = array(); } return false; } protected function setRuleToCache($cacheKey, UrlRuleInterface $rule) { $this->_ruleCache[$cacheKey][] = $rule; } public function createAbsoluteUrl($params, $scheme = null) { $params = (array) $params; $url = $this->createUrl($params); if (strpos($url, "://") === false) { $hostInfo = $this->getHostInfo(); if (strncmp($url, "//", 2) === 0) { $url = substr($hostInfo, 0, strpos($hostInfo, "://")) . ":" . $url; } else { $url = $hostInfo . $url; } } return Url::ensureScheme($url, $scheme); } public function getBaseUrl() { if ($this->_baseUrl === null) { $request = Yii::$app->getRequest(); if ($request instanceof Request) { $this->_baseUrl = $request->getBaseUrl(); } else { throw new InvalidConfigException("Please configure UrlManager::baseUrl correctly as you are running a console application."); } } return $this->_baseUrl; } public function setBaseUrl($value) { $this->_baseUrl = $value === null ? null : rtrim(Yii::getAlias($value), "/"); } public function getScriptUrl() { if ($this->_scriptUrl === null) { $request = Yii::$app->getRequest(); if ($request instanceof Request) { $this->_scriptUrl = $request->getScriptUrl(); } else { throw new InvalidConfigException("Please configure UrlManager::scriptUrl correctly as you are running a console application."); } } return $this->_scriptUrl; } public function setScriptUrl($value) { $this->_scriptUrl = $value; } public function getHostInfo() { if ($this->_hostInfo === null) { $request = Yii::$app->getRequest(); if ($request instanceof \yii\web\Request) { $this->_hostInfo = $request->getHostInfo(); } else { throw new InvalidConfigException("Please configure UrlManager::hostInfo correctly as you are running a console application."); } } return $this->_hostInfo; } public function setHostInfo($value) { $this->_hostInfo = $value === null ? null : rtrim($value, "/"); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace yii\web; use Yii; use yii\base\Component; use yii\base\InvalidConfigException; use yii\caching\CacheInterface; use yii\di\Instance; use yii\helpers\Url; class UrlManager extends Component { public $enablePrettyUrl = false; public $enableStrictParsing = false; public $rules = array(); public $suffix; public $showScriptName = true; public $routeParam = "\x72"; public $cache = "\x63\x61\143\x68\145"; public $ruleConfig = array("\x63\154\x61\x73\163" => "\171\x69\x69\134\x77\x65\142\134\125\x72\x6c\122\x75\x6c\x65"); public $normalizer = false; protected $cacheKey = __CLASS__; private $_baseUrl; private $_scriptUrl; private $_hostInfo; private $_ruleCache; public function init() { parent::init(); if ($this->normalizer !== false) { $this->normalizer = Yii::createObject($this->normalizer); if (!$this->normalizer instanceof UrlNormalizer) { throw new InvalidConfigException("\x60" . get_class($this) . "\x3a\72\x6e\x6f\162\x6d\x61\154\x69\172\x65\162\x60\x20\x73\150\157\x75\x6c\x64\40\x62\x65\x20\141\x6e\40\151\x6e\x73\164\141\156\143\145\x20\x6f\146\x20\x60" . UrlNormalizer::className() . "\140\x20\157\x72\x20\x69\164\163\x20\x44\x49\x20\x63\157\x6d\x70\x61\164\151\x62\x6c\x65\x20\143\x6f\x6e\146\x69\147\165\x72\141\x74\x69\157\156\56"); } } if (!$this->enablePrettyUrl) { return; } if (!empty($this->rules)) { $this->rules = $this->buildRules($this->rules); } } public function addRules($rules, $append = true) { if (!$this->enablePrettyUrl) { return; } $rules = $this->buildRules($rules); if ($append) { $this->rules = array_merge($this->rules, $rules); } else { $this->rules = array_merge($rules, $this->rules); } } protected function buildRules($ruleDeclarations) { $builtRules = $this->getBuiltRulesFromCache($ruleDeclarations); if ($builtRules !== false) { return $builtRules; } $builtRules = array(); $verbs = "\x47\105\124\174\x48\x45\x41\x44\x7c\120\x4f\x53\124\174\120\x55\124\x7c\120\x41\x54\103\x48\x7c\x44\x45\x4c\x45\124\x45\174\117\120\x54\x49\117\x4e\x53"; foreach ($ruleDeclarations as $key => $rule) { if (is_string($rule)) { $rule = array("\162\x6f\x75\x74\145" => $rule); if (preg_match("\x2f\136\50\50\x3f\x3a\x28{$verbs}\x29\54\x29\x2a\50{$verbs}\51\51\134\x73\53\50\x2e\x2a\51\44\57", $key, $matches)) { $rule["\x76\x65\162\142"] = explode("\x2c", $matches[1]); $key = $matches[4]; } $rule["\160\x61\x74\164\145\162\x6e"] = $key; } if (is_array($rule)) { $rule = Yii::createObject(array_merge($this->ruleConfig, $rule)); } if (!$rule instanceof UrlRuleInterface) { throw new InvalidConfigException("\125\122\x4c\40\162\x75\x6c\x65\x20\x63\154\141\x73\x73\40\x6d\165\163\164\x20\x69\x6d\160\154\x65\x6d\x65\156\164\x20\125\x72\154\x52\165\154\x65\x49\x6e\164\x65\162\146\141\x63\x65\56"); } $builtRules[] = $rule; } $this->setBuiltRulesCache($ruleDeclarations, $builtRules); return $builtRules; } private function ensureCache() { if (!$this->cache instanceof CacheInterface && $this->cache !== false && $this->cache !== null) { try { $this->cache = Instance::ensure($this->cache, "\x79\x69\151\134\143\x61\x63\x68\151\x6e\x67\x5c\x43\141\143\x68\145\x49\156\x74\x65\162\x66\x61\143\x65"); } catch (InvalidConfigException $e) { Yii::warning("\x55\156\x61\x62\154\145\x20\164\157\x20\165\163\145\x20\x63\x61\143\x68\145\40\146\x6f\162\x20\125\122\114\40\155\141\x6e\x61\147\x65\x72\72\40" . $e->getMessage()); $this->cache = null; } } return $this->cache; } protected function setBuiltRulesCache($ruleDeclarations, $builtRules) { $cache = $this->ensureCache(); if (!$cache) { return false; } return $cache->set(array($this->cacheKey, $this->ruleConfig, $ruleDeclarations), $builtRules); } protected function getBuiltRulesFromCache($ruleDeclarations) { $cache = $this->ensureCache(); if (!$cache) { return false; } return $cache->get(array($this->cacheKey, $this->ruleConfig, $ruleDeclarations)); } public function parseRequest($request) { if ($this->enablePrettyUrl) { foreach ($this->rules as $rule) { $result = $rule->parseRequest($this, $request); if (YII_DEBUG) { Yii::debug(array("\x72\165\x6c\145" => method_exists($rule, "\137\x5f\x74\157\123\x74\162\x69\x6e\x67") ? $rule->__toString() : get_class($rule), "\x6d\x61\164\x63\x68" => $result !== false, "\x70\141\162\x65\x6e\x74" => null), __METHOD__); } if ($result !== false) { return $result; } } if ($this->enableStrictParsing) { return false; } Yii::debug("\x4e\157\x20\x6d\141\164\x63\150\x69\156\x67\x20\125\122\114\40\162\x75\x6c\145\163\56\x20\125\163\x69\x6e\x67\x20\144\x65\146\x61\165\x6c\x74\40\125\122\114\x20\x70\x61\162\163\151\156\x67\40\x6c\x6f\147\x69\x63\56", __METHOD__); $suffix = (string) $this->suffix; $pathInfo = $request->getPathInfo(); $normalized = false; if ($this->normalizer !== false) { $pathInfo = $this->normalizer->normalizePathInfo($pathInfo, $suffix, $normalized); } if ($suffix !== '' && $pathInfo !== '') { $n = strlen($this->suffix); if (substr_compare($pathInfo, $this->suffix, -$n, $n) === 0) { $pathInfo = substr($pathInfo, 0, -$n); if ($pathInfo === '') { return false; } } else { return false; } } if ($normalized) { return $this->normalizer->normalizeRoute(array($pathInfo, array())); } return array($pathInfo, array()); } Yii::debug("\120\x72\145\x74\x74\171\x20\x55\122\114\40\x6e\x6f\x74\40\x65\156\141\x62\x6c\x65\x64\56\x20\x55\163\151\x6e\147\40\144\145\146\x61\165\154\164\40\x55\x52\114\x20\x70\x61\x72\163\x69\156\x67\40\x6c\157\x67\151\143\56", __METHOD__); $route = $request->getQueryParam($this->routeParam, ''); if (is_array($route)) { $route = ''; } return array((string) $route, array()); } public function createUrl($params) { $params = (array) $params; $anchor = isset($params["\x23"]) ? "\x23" . $params["\x23"] : ''; unset($params["\x23"], $params[$this->routeParam]); $route = trim(isset($params[0]) ? $params[0] : '', "\57"); unset($params[0]); $baseUrl = $this->showScriptName || !$this->enablePrettyUrl ? $this->getScriptUrl() : $this->getBaseUrl(); if ($this->enablePrettyUrl) { $cacheKey = $route . "\x3f"; foreach ($params as $key => $value) { if ($value !== null) { $cacheKey .= $key . "\x26"; } } $url = $this->getUrlFromCache($cacheKey, $route, $params); if ($url === false) { foreach ($this->rules as $rule) { if (in_array($rule, $this->_ruleCache[$cacheKey], true)) { continue; } $url = $rule->createUrl($this, $route, $params); if ($this->canBeCached($rule)) { $this->setRuleToCache($cacheKey, $rule); } if ($url !== false) { break; } } } if ($url !== false) { if (strpos($url, "\72\57\x2f") !== false) { if ($baseUrl !== '' && ($pos = strpos($url, "\57", 8)) !== false) { return substr($url, 0, $pos) . $baseUrl . substr($url, $pos) . $anchor; } return $url . $baseUrl . $anchor; } elseif (strncmp($url, "\x2f\x2f", 2) === 0) { if ($baseUrl !== '' && ($pos = strpos($url, "\57", 2)) !== false) { return substr($url, 0, $pos) . $baseUrl . substr($url, $pos) . $anchor; } return $url . $baseUrl . $anchor; } $url = ltrim($url, "\57"); return "{$baseUrl}\x2f{$url}{$anchor}"; } if ($this->suffix !== null) { $route .= $this->suffix; } if (!empty($params) && ($query = http_build_query($params)) !== '') { $route .= "\77" . $query; } $route = ltrim($route, "\57"); return "{$baseUrl}\57{$route}{$anchor}"; } $url = "{$baseUrl}\x3f{$this->routeParam}\x3d" . urlencode($route); if (!empty($params) && ($query = http_build_query($params)) !== '') { $url .= "\46" . $query; } return $url . $anchor; } protected function canBeCached(UrlRuleInterface $rule) { return !method_exists($rule, "\x67\145\164\x43\x72\x65\x61\164\x65\x55\x72\x6c\x53\164\x61\x74\165\x73") || ($status = $rule->getCreateUrlStatus()) === null || $status === UrlRule::CREATE_STATUS_SUCCESS || $status & UrlRule::CREATE_STATUS_PARAMS_MISMATCH; } protected function getUrlFromCache($cacheKey, $route, $params) { if (!empty($this->_ruleCache[$cacheKey])) { foreach ($this->_ruleCache[$cacheKey] as $rule) { if (($url = $rule->createUrl($this, $route, $params)) !== false) { return $url; } } } else { $this->_ruleCache[$cacheKey] = array(); } return false; } protected function setRuleToCache($cacheKey, UrlRuleInterface $rule) { $this->_ruleCache[$cacheKey][] = $rule; } public function createAbsoluteUrl($params, $scheme = null) { $params = (array) $params; $url = $this->createUrl($params); if (strpos($url, "\72\57\57") === false) { $hostInfo = $this->getHostInfo(); if (strncmp($url, "\x2f\57", 2) === 0) { $url = substr($hostInfo, 0, strpos($hostInfo, "\x3a\57\x2f")) . "\x3a" . $url; } else { $url = $hostInfo . $url; } } return Url::ensureScheme($url, $scheme); } public function getBaseUrl() { if ($this->_baseUrl === null) { $request = Yii::$app->getRequest(); if ($request instanceof Request) { $this->_baseUrl = $request->getBaseUrl(); } else { throw new InvalidConfigException("\x50\x6c\x65\x61\x73\x65\x20\143\x6f\x6e\146\x69\147\165\162\145\x20\x55\x72\x6c\x4d\x61\156\141\147\145\x72\72\72\142\x61\163\145\125\x72\x6c\40\x63\157\x72\162\145\143\164\154\171\x20\141\x73\x20\171\157\x75\x20\x61\162\x65\x20\162\x75\x6e\x6e\x69\x6e\x67\40\x61\40\x63\157\x6e\163\x6f\x6c\x65\x20\x61\x70\x70\154\151\143\141\164\x69\157\156\56"); } } return $this->_baseUrl; } public function setBaseUrl($value) { $this->_baseUrl = $value === null ? null : rtrim(Yii::getAlias($value), "\57"); } public function getScriptUrl() { if ($this->_scriptUrl === null) { $request = Yii::$app->getRequest(); if ($request instanceof Request) { $this->_scriptUrl = $request->getScriptUrl(); } else { throw new InvalidConfigException("\x50\154\x65\141\x73\145\x20\143\x6f\156\146\x69\147\165\162\x65\x20\125\162\x6c\115\141\156\141\147\145\162\x3a\x3a\x73\x63\162\151\160\x74\125\x72\x6c\40\143\157\x72\x72\x65\143\164\154\x79\40\141\x73\x20\171\x6f\165\x20\x61\x72\x65\40\162\x75\156\156\x69\x6e\147\40\141\x20\143\157\156\163\157\154\x65\40\x61\x70\160\154\x69\143\141\164\x69\157\156\x2e"); } } return $this->_scriptUrl; } public function setScriptUrl($value) { $this->_scriptUrl = $value; } public function getHostInfo() { if ($this->_hostInfo === null) { $request = Yii::$app->getRequest(); if ($request instanceof \yii\web\Request) { $this->_hostInfo = $request->getHostInfo(); } else { throw new InvalidConfigException("\120\154\x65\x61\x73\x65\40\143\157\156\146\151\x67\x75\x72\145\x20\x55\x72\154\x4d\x61\156\141\147\145\162\x3a\x3a\x68\157\x73\x74\111\156\x66\157\x20\x63\157\x72\162\145\x63\x74\154\171\x20\141\x73\40\171\x6f\x75\x20\141\162\145\x20\162\x75\x6e\x6e\x69\156\147\40\141\40\143\157\x6e\x73\x6f\x6c\145\40\x61\160\160\x6c\x69\x63\141\x74\x69\x6f\x6e\x2e"); } } return $this->_hostInfo; } public function setHostInfo($value) { $this->_hostInfo = $value === null ? null : rtrim($value, "\57"); } }

Function Calls

None

Variables

None

Stats

MD5 b94b8c5cfee044239ba11496c7b58c8c
Eval Count 0
Decode Time 122 ms