public function IndexAction() { $uri = $this->getRequest()->getUriNormal(); $template = $this->getRequest()->getUriPartByNum(-2); $fileDir = FileSystem::getDirName($uri, 2); $fileName = basename($uri); $filePath = $fileDir . "/" . $fileName; $imagesDir = $this->getConfig(["ImageProcessor", "directory"], "data/images"); $imagesDir = ROOT_DIR . "/" . $imagesDir; $realPath = ROOT_DIR . $filePath; $path = FileSystem::inDir($imagesDir, $realPath); if (!$path) { throw new \Exception("file not in images dir"); } $pubDir = ROOT_DIR . "/public"; $pubPath = ROOT_DIR . "/public/" . $fileDir; $realPubPath = FileSystem::inDir($pubDir, $pubPath, false); if (!$realPubPath) { throw new \Exception("Path not allow {$pubPath} in {$pubDir}"); } $pubPath = $realPubPath . "/" . $template . "/" . $fileName; $imp = $this->getImageProcessor(); $imp->process($realPath, $pubPath, $template); //TODO use accel Header::mime($pubPath); echo file_get_contents($pubPath); }
public function IndexAction(array $params = []) { $template = $params["template"]; $fileDir = $params["directory"]; $fileName = $params["file"]; $filePath = $fileDir . "/" . $fileName; $imagesDir = $this->getConfig(["ImageProcessor", "directory"], "data/images"); $imagesDir = ROOT_DIR . "/" . $imagesDir; $realPath = ROOT_DIR . $filePath; $path = FileSystem::inDir($imagesDir, $realPath); if (!$path) { throw new \Exception("file not in images dir"); } $pubDir = ROOT_DIR . "/public"; $pubPath = ROOT_DIR . "/public" . $fileDir; $realPubPath = FileSystem::getSubDir($pubDir, $pubPath, false); if (!$realPubPath) { throw new \Exception("Path not allow {$pubPath} in {$pubDir}"); } $pubPath = "/" . $realPubPath . "/" . $template . "/" . $fileName; $outFullPath = ROOT_DIR . "/public/" . $pubPath; $imp = $this->getImageProcessor(); $outFile = $imp->process($realPath, $outFullPath, $template); //TODO use accel Header::accel($pubPath, $outFile); // echo file_get_contents($pubPath); }