Пример #1
0
 /**
  * Checks and set Last-Modified header, when the request matches sends a
  * 'not modified' response
  * @param string $lastModified time when the reponse was last modified
  */
 public static function setLastModifiedHeader($lastModified)
 {
     \OC_Response::setLastModifiedHeader($lastModified);
 }
Пример #2
0
 public static function getTmpAvatar($args)
 {
     \OC_JSON::checkLoggedIn();
     \OC_JSON::callCheck();
     $tmpavatar = \OC_Cache::get('tmpavatar');
     if (is_null($tmpavatar)) {
         $l = new \OC_L10n('core');
         \OC_JSON::error(array("data" => array("message" => $l->t("No temporary profile picture available, try again"))));
         return;
     }
     $image = new \OC_Image($tmpavatar);
     \OC_Response::disableCaching();
     \OC_Response::setLastModifiedHeader(time());
     \OC_Response::setETagHeader(crc32($image->data()));
     $image->show();
 }
Пример #3
0
 public function show()
 {
     if ($this->useOriginal) {
         $fp = @$this->view->fopen($this->path, 'rb');
         $mtime = $this->view->filemtime($this->path);
         $size = $this->view->filesize($this->path);
         $mime = $this->view->getMimetype($this->path);
     } else {
         $fp = @fopen($this->path, 'rb');
         $mtime = filemtime($this->path);
         $size = filesize($this->path);
         $mime = \OC_Helper::getMimetype($this->path);
     }
     if ($fp) {
         \OC_Response::enableCaching();
         \OC_Response::setLastModifiedHeader($mtime);
         header('Content-Length: ' . $size);
         header('Content-Type: ' . $mime);
         fpassthru($fp);
     } else {
         \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
     }
 }
Пример #4
0
 public static function loadfile()
 {
     if (file_exists(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE)) {
         if (substr(OC::$REQUESTEDFILE, -3) == 'css') {
             $appswebroot = (string) OC::$APPSWEBROOT;
             $webroot = (string) OC::$WEBROOT;
             $filepath = OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE;
             header('Content-Type: text/css');
             OC_Response::enableCaching();
             OC_Response::setLastModifiedHeader(filemtime($filepath));
             $cssfile = file_get_contents($filepath);
             $cssfile = str_replace('%appswebroot%', $appswebroot, $cssfile);
             $cssfile = str_replace('%webroot%', $webroot, $cssfile);
             OC_Response::setETagHeader(md5($cssfile));
             header('Content-Length: ' . strlen($cssfile));
             echo $cssfile;
             exit;
         } elseif (substr(OC::$REQUESTEDFILE, -3) == 'php') {
             require_once OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE;
         }
     } else {
         header('HTTP/1.0 404 Not Found');
         exit;
     }
 }