public function setPath($path_) { $this->m_pathParams = []; if (0 == String::indexOf($path_, ':')) { $pathParams = explode(':', String::substring($path_, 1)); } else { $pathParams = explode(':', $path_); } foreach ($pathParams as $pathParam) { $this->pushPathParam(\str\decodeUrl($pathParam)); } return $this; }
/** * @param \Components\Http_Scriptlet_Context $context_ * @param \Components\Uri $uri_ */ public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_) { $uri = $context_->getRequest()->getUri(); $extension = $uri->getFileExtension(); $name = $uri->getFilename(true); $uri_->popPathParam(); $pathTarget = Environment::pathWeb() . $uri_->getPath() . '/' . \str\decodeUrl($name, true) . ".{$extension}"; if (false === is_file($pathTarget)) { $fileTarget = Io::file($pathTarget); $directoryTarget = $fileTarget->getDirectory(); if (false === $directoryTarget->exists()) { $directoryTarget->create(); } $info = @json_decode(\str\decodeBase64Url($name)); if (false === isset($info[0])) { throw new Http_Exception('media/scriptlet/engine', sprintf('Not found [%s].', $uri), Http_Exception::NOT_FOUND); } $pathSource = Environment::pathWeb($info[0]); if (false === is_file($pathSource)) { throw new Http_Exception('media/scriptlet/engine', sprintf('Not found [%s].', $uri), Http_Exception::NOT_FOUND); } if (isset($info[1]) || isset($info[2])) { if (!isset($info[1])) { $info[1] = 0; } if (!isset($info[2])) { $info[2] = 0; } Io::image($pathSource)->scale(Point::of($info[1], $info[2]))->saveAs($fileTarget); } else { Io::file($pathSource)->copy($fileTarget); } } header('Content-Length: ' . Io::fileSize($pathTarget)->bytes()); readfile($pathTarget); }
/** * @see \str\decodeUrl() decodeUrl */ public static function decodeUrl($string_, $avoidDoubleDecoding_ = false) { return \str\decodeUrl($string_, $avoidDoubleDecoding_); }
protected function parseImpl(array $uri_) { $this->m_scheme = isset($uri_['scheme']) && 'null' !== $uri_['scheme'] ? $uri_['scheme'] : null; $this->m_host = isset($uri_['host']) ? $uri_['host'] : null; $this->m_port = isset($uri_['port']) ? (int) $uri_['port'] : null; $this->m_username = isset($uri_['user']) ? \str\decodeUrl($uri_['user']) : null; $this->m_password = isset($uri_['pass']) ? \str\decodeUrl($uri_['pass']) : null; $this->setPath(isset($uri_['path']) ? $uri_['path'] : null); $this->m_queryParams = isset($uri_['query']) ? self::parseQueryString($uri_['query']) : []; $this->m_fragment = isset($uri_['fragment']) ? \str\decodeUrl($uri_['fragment']) : null; }