Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 public function sendHeaders()
 {
     if (headers_sent()) {
         throw new \LogicException('Headers already send');
     }
     header("HTTP/1.1 {$this->getHttpCode()}");
     header("Content-Type:{$this->getContentType()}; charset={$this->getCharset()}");
     header("Content-Language: {$this->getLanguage()}");
     header("X-Response-Date: " . Header::toGmtDate());
     $modified = $this->getModified();
     Header::modified($modified);
     $cacheTime = $this->getTimeToCache();
     if ($cacheTime > 0) {
         Header::cache($cacheTime);
     } elseif ($cacheTime < 0) {
         Header::noCache();
     }
     header("ETag: {$this->getEtag()}");
 }