示例#1
0
 /**
  * Wrapper to the real, fast resizing
  * @return void
  */
 private function resizeImage()
 {
     //Load the image-dimensions
     if (is_file(_realpath_ . $this->strFilename) && (uniStrpos($this->strFilename, "/files") !== false || uniStrpos($this->strFilename, "/templates") !== false)) {
         //check headers, maybe execution could be terminated right here
         if (checkConditionalGetHeaders(md5(md5_file(_realpath_ . $this->strFilename) . $this->intMaxWidth . $this->intMaxHeight . $this->intFixedWidth . $this->intFixedHeight))) {
             class_response_object::getInstance()->sendHeaders();
             return;
         }
         $objImage = new class_image2();
         $objImage->load($this->strFilename);
         $objImage->addOperation(new class_image_scale_and_crop($this->intFixedWidth, $this->intFixedHeight));
         $objImage->addOperation(new class_image_scale($this->intMaxWidth, $this->intMaxHeight));
         //send the headers for conditional gets
         setConditionalGetHeaders(md5(md5_file(_realpath_ . $this->strFilename) . $this->intMaxWidth . $this->intMaxHeight . $this->intFixedWidth . $this->intFixedHeight));
         //TODO: add expires header for browser caching (optional)
         /*
         $intCacheSeconds = 604800; //default: 1 week (60*60*24*7)
         header("Expires: ".gmdate("D, d M Y H:i:s", time() + $intCacheSeconds)." GMT", true);
         header("Cache-Control: public, max-age=".$intCacheSeconds, true);
         header("Pragma: ", true);
         */
         //and send it to the browser
         $objImage->setJpegQuality((int) $this->intQuality);
         $objImage->sendToBrowser();
         return;
     }
     class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND);
     class_response_object::getInstance()->sendHeaders();
 }
 /**
  * Sends conditional get headers and tries to match sent ones.
  *
  * @param string $strContent
  * @return void
  */
 private function sendConditionalGetHeaders($strContent)
 {
     //check headers, maybe execution could be terminated right here
     //yes, this doesn't save us from generating the page, but the traffic towards the client can be reduced
     if (checkConditionalGetHeaders(md5($_SERVER["REQUEST_URI"] . $this->objSession->getSessionId() . $strContent))) {
         class_response_object::getInstance()->sendHeaders();
         flush();
         die;
     }
     //send headers if not an ie
     if (strpos(getServer("HTTP_USER_AGENT"), "IE") === false) {
         setConditionalGetHeaders(md5($_SERVER["REQUEST_URI"] . $this->objSession->getSessionId() . $strContent));
     }
 }