/**
  * Stub - sends a generic avatar
  */
 public static function sendAvatar()
 {
     $uid = self::preDispatch(false);
     $image = new \OC_Image('iVBORw0KGgoAAAANSUhEUgAAADAAAAAwEAYAAAAHkiXEAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAwAAAAMADO7oxXAAAUWUlEQVR42u1beXBUVfb+3tZLOp21u0nSHbIRQkJYk5QwIhGNLMKAiDiCqGXpaKFSY2mpVTqOC9aUOo4zMjWihcoUboUysqqMDG6MJMAYooQtJJB962ydTi/v9Vt+f1zv73U3aQibOjOcKji5r1/fd9/3nXvuOefeBi7LZbksl+Wy/K8K81MP4GxiNptMDJOQkJ7ucDBMYaHdnprKsnl5RqPRCMTHGwyCAJjNoihJgM83MDA4qGnt7V1dbreq1tW53b29mnbypKZpGqCqP/X7RMvPhoC0NIeDZceNmznziisE4c47y8omTzaZFi9OS0tLS0kZPTo52WYrLJSklBSbLSuL4ywWszkxkec5ThAEgWWDwUBgcFCWvV6Px+1WlN5et7uhAejr6+k5cUJVGxoaGyWpsvKLL/buDQTWr6+pOXxYUbZulaRQCAgE/ucIyM/PyWHZq65atmzxYovlD38YP76oaMyYCRMmTy4t/dWvDAanMytr2jSeNxqNRosFAFS1vx/QNFUdGiLtYJD0JcuApgEsCzAMwxgMAMOwrNUKaJqmWa3A4GBfX309UFv73Xeffur319fX1X3+uap+8snnn3s8r7yyc+eXX4ZCL73k9wcCmjYw8F9HgNUaH88wdvvddy9bZrG8+eaVV/7iF+PHV1TMnFlR8fDDZnNycmpqbi6gabLc0kJ0aysB3OeL7EtVCbCKApA7w4nQtFCIXJckohWFkONwABwnCPn55F6bDTh2rLZ22zZJ2r9/37533/X716/fuNHjeeCBqqrqall+993/eALGjs3NZdmZMx966N57U1O3bJk1a968Rx+1WnNzx4y55hqe17RQqK4OUFVZ7ugg36GWzLKRfWkaAZh68nAChgNeksh1USS0iSLAMKGQJAEsqyhmM8BxZnNpKSCKmpaaC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cml2eS9kb2NzL2ljb25zL29wZW5faWNvbl9saWJyYXJ5LWRldmVsL2ljb25zL3RhbmdvL3N2ZzJwbmcvZW1vdGVzL2ZhY2Utc21pbGUtMi5zdmerBUU8AAAAAElFTkSuQmCC');
     \OC_Util::obEnd();
     echo $image->show();
 }
Esempio n. 2
0
 /**
  * Send the requested parts of the file
  */
 public function sendResponse()
 {
     if (!preg_match('/^bytes=\\d*-\\d*(,\\d*-\\d*)*$/', $_SERVER['HTTP_RANGE'])) {
         $this->sendNotSatisfiable();
     }
     $ranges = explode(',', substr($_SERVER['HTTP_RANGE'], 6));
     foreach ($ranges as $range) {
         $parts = explode('-', $range);
         $start = isset($parts[0]) ? $parts[0] : 0;
         $end = isset($parts[1]) ? $parts[1] : $this->getFilesize() - 1;
         if ($start > $end) {
             $this->sendNotSatisfiable();
         }
         $handle = $this->view->fopen($this->filepath, 'rb');
         \fseek($handle, $start);
         $buffer = \fread($handle, $end - $start);
         $md5Sum = md5($buffer);
         \fclose($handle);
         // send the headers and data
         header("Content-Length: " . $end - $start);
         header("Content-md5: " . $md5Sum);
         header("Accept-Ranges: bytes");
         header('Content-Range: bytes ' . $start . '-' . $end . '/' . $this->getFilesize());
         header("Connection: close");
         header("Content-type: " . $this->getMimeType());
         header('Content-Disposition: attachment; filename=' . $this->getFilename());
         \OC_Util::obEnd();
         echo $buffer;
         flush();
     }
 }
Esempio n. 3
0
 protected function init()
 {
     if ($this->started) {
         return;
     }
     $this->started = true;
     // prevent php output buffering, caching and nginx buffering
     OC_Util::obEnd();
     header('Cache-Control: no-cache');
     header('X-Accel-Buffering: no');
     $this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
     if ($this->fallback) {
         $this->fallBackId = (int) $_GET['fallback_id'];
         header("Content-Type: text/html");
         echo str_repeat('<span></span>' . PHP_EOL, 10);
         //dummy data to keep IE happy
     } else {
         header("Content-Type: text/event-stream");
     }
     if (!OC_Util::isCallRegistered()) {
         $this->send('error', 'Possible CSRF attack. Connection will be closed.');
         $this->close();
         exit;
     }
     flush();
 }
Esempio n. 4
0
 /**
  * Send the whole file content as a response
  */
 public function sendResponse()
 {
     header('Content-Type:' . $this->getMimeType());
     $encodedName = rawurlencode($this->getFilename());
     if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) {
         header('Content-Disposition: attachment; filepath="' . $encodedName . '"');
     } else {
         header('Content-Disposition: attachment; filepath*=UTF-8\'\'' . $encodedName . '; filepath="' . $encodedName . '"');
     }
     header('Content-Length: ' . $this->view->filesize($this->filepath));
     \OC_Util::obEnd();
     $this->view->readfile($this->filepath);
 }
Esempio n. 5
0
 /**
  * Send the whole file content as a response
  */
 public function sendResponse()
 {
     $mimetype = $this->getMimeType();
     $content = $this->view->file_get_contents($this->filepath);
     $data = Filter::read($content, $mimetype);
     header('Content-Type:' . $data['mimetype']);
     $encodedName = rawurlencode($this->getFilename());
     if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) {
         header('Content-Disposition: attachment; filepath="' . $encodedName . '"');
     } else {
         header('Content-Disposition: attachment; filepath*=UTF-8\'\'' . $encodedName . '; filepath="' . $encodedName . '"');
     }
     header('Content-Length: ' . strlen($data['content']));
     \OC_Util::obEnd();
     echo $data['content'];
 }
Esempio n. 6
0
 public function __construct()
 {
     OC_Util::obEnd();
     header('Cache-Control: no-cache');
     $this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
     if ($this->fallback) {
         $this->fallBackId = $_GET['fallback_id'];
         header("Content-Type: text/html");
         echo str_repeat('<span></span>' . PHP_EOL, 10);
         //dummy data to keep IE happy
     } else {
         header("Content-Type: text/event-stream");
     }
     if (!OC_Util::isCallRegistered()) {
         exit;
     }
     flush();
 }
Esempio n. 7
0
 /**
  * Send the requested parts of the file
  */
 public function sendResponse()
 {
     if (!preg_match('/^bytes=\\d*-\\d*(,\\d*-\\d*)*$/', $_SERVER['HTTP_RANGE'])) {
         $this->sendNotSatisfiable();
     }
     $mimetype = $this->getMimeType();
     $content = $this->view->file_get_contents($this->filepath);
     $data = Filter::read($content, $mimetype);
     $size = strlen($data['content']);
     $ranges = explode(',', substr($_SERVER['HTTP_RANGE'], 6));
     foreach ($ranges as $range) {
         $parts = explode('-', $range);
         if ($parts[0] === '' && $parts[1] == '') {
             $this->sendNotSatisfiable();
         }
         if ($parts[0] === '') {
             $start = $size - $parts[1];
             $end = $size - 1;
         } else {
             $start = $parts[0];
             $end = $parts[1] === '' ? $size - 1 : $parts[1];
         }
         if ($start > $end) {
             $this->sendNotSatisfiable();
         }
         $buffer = substr($data['content'], $start, $end - $start);
         $md5Sum = md5($buffer);
         // send the headers and data
         header("Content-Length: " . ($end - $start));
         header("Content-md5: " . $md5Sum);
         header("Accept-Ranges: bytes");
         header('Content-Range: bytes ' . $start . '-' . $end . '/' . $size);
         header("Connection: close");
         header("Content-type: " . $data['mimetype']);
         header('Content-Disposition: attachment; filename=' . $this->getFilename());
         \OC_Util::obEnd();
         echo $buffer;
         flush();
     }
 }
Esempio n. 8
0
 protected function init()
 {
     if ($this->started) {
         return;
     }
     $this->started = true;
     // prevent php output buffering, caching and nginx buffering
     OC_Util::obEnd();
     header('Cache-Control: no-cache');
     header('X-Accel-Buffering: no');
     $this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
     if ($this->fallback) {
         $this->fallBackId = (int) $_GET['fallback_id'];
         /**
          * FIXME: The default content-security-policy of ownCloud forbids inline
          * JavaScript for security reasons. IE starting on Windows 10 will
          * however also obey the CSP which will break the event source fallback.
          *
          * As a workaround thus we set a custom policy which allows the execution
          * of inline JavaScript.
          *
          * @link https://github.com/owncloud/core/issues/14286
          */
         header("Content-Security-Policy: default-src 'none'; script-src 'unsafe-inline'");
         header("Content-Type: text/html");
         echo str_repeat('<span></span>' . PHP_EOL, 10);
         //dummy data to keep IE happy
     } else {
         header("Content-Type: text/event-stream");
     }
     if (!OC_Util::isCallRegistered()) {
         $this->send('error', 'Possible CSRF attack. Connection will be closed.');
         $this->close();
         exit;
     }
     flush();
 }
Esempio n. 9
0
 /**
  * return the content of a file or return a zip file containing multiple files
  *
  * @param string $dir
  * @param string $files ; separated list of files to download
  * @param boolean $only_header ; boolean to only send header of the request
  */
 public static function get($dir, $files, $only_header = false)
 {
     $view = \OC\Files\Filesystem::getView();
     $xsendfile = false;
     if (\OC::$server->getLockingProvider() instanceof NoopLockingProvider) {
         if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || isset($_SERVER['MOD_X_SENDFILE2_ENABLED']) || isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
             $xsendfile = true;
         }
     }
     if (is_array($files) && count($files) === 1) {
         $files = $files[0];
     }
     if (is_array($files)) {
         $get_type = self::ZIP_FILES;
         $basename = basename($dir);
         if ($basename) {
             $name = $basename . '.zip';
         } else {
             $name = 'download.zip';
         }
         $filename = $dir . '/' . $name;
     } else {
         $filename = $dir . '/' . $files;
         if (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
             $get_type = self::ZIP_DIR;
             // downloading root ?
             if ($files === '') {
                 $name = 'download.zip';
             } else {
                 $name = $files . '.zip';
             }
         } else {
             $get_type = self::FILE;
             $name = $files;
         }
     }
     if ($get_type === self::FILE) {
         $zip = false;
         if ($xsendfile && \OC::$server->getEncryptionManager()->isEnabled()) {
             $xsendfile = false;
         }
     } else {
         $zip = new ZipStreamer(false);
     }
     OC_Util::obEnd();
     try {
         if ($get_type === self::FILE) {
             $view->lockFile($filename, ILockingProvider::LOCK_SHARED);
         }
         if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
             self::sendHeaders($filename, $name, $zip);
         } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
             header("HTTP/1.0 404 Not Found");
             $tmpl = new OC_Template('', '404', 'guest');
             $tmpl->printPage();
             exit;
         } else {
             header("HTTP/1.0 403 Forbidden");
             die('403 Forbidden');
         }
         if ($only_header) {
             return;
         }
         if ($zip) {
             $executionTime = intval(ini_get('max_execution_time'));
             set_time_limit(0);
             if ($get_type === self::ZIP_FILES) {
                 foreach ($files as $file) {
                     $file = $dir . '/' . $file;
                     if (\OC\Files\Filesystem::is_file($file)) {
                         $fh = \OC\Files\Filesystem::fopen($file, 'r');
                         $zip->addFileFromStream($fh, basename($file));
                         fclose($fh);
                     } elseif (\OC\Files\Filesystem::is_dir($file)) {
                         self::zipAddDir($file, $zip);
                     }
                 }
             } elseif ($get_type === self::ZIP_DIR) {
                 $file = $dir . '/' . $files;
                 self::zipAddDir($file, $zip);
             }
             $zip->finalize();
             set_time_limit($executionTime);
         } else {
             if ($xsendfile) {
                 /** @var $storage \OC\Files\Storage\Storage */
                 list($storage) = $view->resolvePath($filename);
                 if ($storage->isLocal()) {
                     self::addSendfileHeader($filename);
                 } else {
                     \OC\Files\Filesystem::readfile($filename);
                 }
             } else {
                 \OC\Files\Filesystem::readfile($filename);
             }
         }
         if ($get_type === self::FILE) {
             $view->unlockFile($filename, ILockingProvider::LOCK_SHARED);
         }
     } catch (\OCP\Lock\LockedException $ex) {
         $l = \OC::$server->getL10N('core');
         $hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
         \OC_Template::printErrorPage($l->t('File is currently busy, please try again later'), $hint);
     } catch (\Exception $ex) {
         $l = \OC::$server->getL10N('core');
         $hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
         \OC_Template::printErrorPage($l->t('Can\'t read file'), $hint);
     }
 }
Esempio n. 10
0
* @author Bjoern Schiessle
* @copyright 2013 Bjoern Schiessle schiessle@owncloud.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
OCP\JSON::checkAppEnabled('files_versions');
//OCP\JSON::callCheck();
$file = $_GET['file'];
$revision = (int) $_GET['revision'];
list($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($file);
$versionName = '/' . $uid . '/files_versions/' . $filename . '.v' . $revision;
$view = new OC\Files\View('/');
$ftype = $view->getMimeType('/' . $uid . '/files/' . $filename);
header('Content-Type:' . $ftype);
OCP\Response::setContentDispositionHeader(basename($filename), 'attachment');
OCP\Response::disableCaching();
OCP\Response::setContentLengthHeader($view->filesize($versionName));
OC_Util::obEnd();
$view->readfile($versionName);
Esempio n. 11
0
 /**
  * return the content of a file or return a zip file containing multiple files
  *
  * @param string $dir
  * @param string $files ; separated list of files to download
  * @param boolean $only_header ; boolean to only send header of the request
  */
 public static function get($dir, $files, $only_header = false)
 {
     $xsendfile = false;
     if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || isset($_SERVER['MOD_X_SENDFILE2_ENABLED']) || isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
         $xsendfile = true;
     }
     if (is_array($files) && count($files) === 1) {
         $files = $files[0];
     }
     if (is_array($files)) {
         $get_type = GET_TYPE::ZIP_FILES;
         $basename = basename($dir);
         if ($basename) {
             $name = $basename . '.zip';
         } else {
             $name = 'download.zip';
         }
         $filename = $dir . '/' . $name;
     } else {
         $filename = $dir . '/' . $files;
         if (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
             $get_type = GET_TYPE::ZIP_DIR;
             // downloading root ?
             if ($files === '') {
                 $name = 'download.zip';
             } else {
                 $name = $files . '.zip';
             }
         } else {
             $get_type = GET_TYPE::FILE;
             $name = $files;
         }
     }
     if ($get_type === GET_TYPE::FILE) {
         $zip = false;
         if ($xsendfile && OC_App::isEnabled('files_encryption')) {
             $xsendfile = false;
         }
     } else {
         $zip = new ZipStreamer(false);
     }
     OC_Util::obEnd();
     if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
         self::sendHeaders($filename, $name, $zip);
     } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->assign('file', $name);
         $tmpl->printPage();
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if ($only_header) {
         return;
     }
     if ($zip) {
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         if ($get_type === GET_TYPE::ZIP_FILES) {
             foreach ($files as $file) {
                 $file = $dir . '/' . $file;
                 if (\OC\Files\Filesystem::is_file($file)) {
                     $fh = \OC\Files\Filesystem::fopen($file, 'r');
                     $zip->addFileFromStream($fh, basename($file));
                     fclose($fh);
                 } elseif (\OC\Files\Filesystem::is_dir($file)) {
                     self::zipAddDir($file, $zip);
                 }
             }
         } elseif ($get_type === GET_TYPE::ZIP_DIR) {
             $file = $dir . '/' . $files;
             self::zipAddDir($file, $zip);
         }
         $zip->finalize();
         set_time_limit($executionTime);
     } else {
         if ($xsendfile) {
             $view = \OC\Files\Filesystem::getView();
             /** @var $storage \OC\Files\Storage\Storage */
             list($storage) = $view->resolvePath($filename);
             if ($storage->isLocal()) {
                 self::addSendfileHeader($filename);
             } else {
                 \OC\Files\Filesystem::readfile($filename);
             }
         } else {
             \OC\Files\Filesystem::readfile($filename);
         }
     }
 }
Esempio n. 12
0
 /**
  * @param View $view
  * @param string $name
  * @param string $dir
  * @param boolean $onlyHeader
  */
 private static function getSingleFile($view, $dir, $name, $onlyHeader)
 {
     $filename = $dir . '/' . $name;
     OC_Util::obEnd();
     $view->lockFile($filename, ILockingProvider::LOCK_SHARED);
     if (\OC\Files\Filesystem::isReadable($filename)) {
         self::sendHeaders($filename, $name);
     } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->printPage();
         exit;
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if ($onlyHeader) {
         return;
     }
     $view->readfile($filename);
 }
Esempio n. 13
0
 /**
  * return the content of a file or return a zip file containning multiply files
  *
  * @param dir  $dir
  * @param file $file ; seperated list of files to download
  * @param boolean $only_header ; boolean to only send header of the request
  */
 public static function get($dir, $files, $only_header = false)
 {
     $xsendfile = false;
     if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
         $xsendfile = true;
     }
     if (strpos($files, ';')) {
         $files = explode(';', $files);
     }
     if (is_array($files)) {
         self::validateZipDownload($dir, $files);
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         $zip = new ZipArchive();
         if ($xsendfile) {
             $filename = OC_Helper::tmpFileNoClean('.zip');
         } else {
             $filename = OC_Helper::tmpFile('.zip');
         }
         if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             exit("cannot open <{$filename}>\n");
         }
         foreach ($files as $file) {
             $file = $dir . '/' . $file;
             if (OC_Filesystem::is_file($file)) {
                 $tmpFile = OC_Filesystem::toTmpFile($file);
                 self::$tmpFiles[] = $tmpFile;
                 $zip->addFile($tmpFile, basename($file));
             } elseif (OC_Filesystem::is_dir($file)) {
                 self::zipAddDir($file, $zip);
             }
         }
         $zip->close();
         set_time_limit($executionTime);
     } elseif (OC_Filesystem::is_dir($dir . '/' . $files)) {
         self::validateZipDownload($dir, $files);
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         $zip = new ZipArchive();
         if ($xsendfile) {
             $filename = OC_Helper::tmpFileNoClean('.zip');
         } else {
             $filename = OC_Helper::tmpFile('.zip');
         }
         if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             exit("cannot open <{$filename}>\n");
         }
         $file = $dir . '/' . $files;
         self::zipAddDir($file, $zip);
         $zip->close();
         set_time_limit($executionTime);
     } else {
         $zip = false;
         $filename = $dir . '/' . $files;
     }
     OC_Util::obEnd();
     if ($zip or OC_Filesystem::is_readable($filename)) {
         header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
         header('Content-Transfer-Encoding: binary');
         OC_Response::disableCaching();
         if ($zip) {
             ini_set('zlib.output_compression', 'off');
             header('Content-Type: application/zip');
             header('Content-Length: ' . filesize($filename));
             self::addSendfileHeader($filename);
         } else {
             header('Content-Type: ' . OC_Filesystem::getMimeType($filename));
             $storage = OC_Filesystem::getStorage($filename);
             if ($storage instanceof OC_Filestorage_Local) {
                 self::addSendfileHeader(OC_Filesystem::getLocalFile($filename));
             }
         }
     } elseif ($zip or !OC_Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->assign('file', $filename);
         $tmpl->printPage();
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if ($only_header) {
         if (!$zip) {
             header("Content-Length: " . OC_Filesystem::filesize($filename));
         }
         return;
     }
     if ($zip) {
         $handle = fopen($filename, 'r');
         if ($handle) {
             $chunkSize = 8 * 1024;
             // 1 MB chunks
             while (!feof($handle)) {
                 echo fread($handle, $chunkSize);
                 flush();
             }
         }
         if (!$xsendfile) {
             unlink($filename);
         }
     } else {
         OC_Filesystem::readfile($filename);
     }
     foreach (self::$tmpFiles as $tmpFile) {
         if (file_exists($tmpFile) and is_file($tmpFile)) {
             unlink($tmpFile);
         }
     }
 }
Esempio n. 14
0
 /**
  * @param View $view
  * @param string $name
  */
 private static function getSingleFile($view, $dir, $name, $onlyHeader)
 {
     $filename = $dir . '/' . $name;
     OC_Util::obEnd();
     $view->lockFile($filename, ILockingProvider::LOCK_SHARED);
     if (\OC\Files\Filesystem::isReadable($filename)) {
         self::sendHeaders($filename, $name);
     } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->printPage();
         exit;
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if ($onlyHeader) {
         return;
     }
     $type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
     $pos = strpos(strtolower($type), "video");
     if ($pos != -1) {
         $view->streamVideoFile($filename);
     } else {
         $view->readfile($filename);
     }
 }
Esempio n. 15
0
 /**
  * return the content of a file or return a zip file containing multiple files
  *
  * @param string $dir
  * @param string $file ; separated list of files to download
  * @param boolean $only_header ; boolean to only send header of the request
  */
 public static function get($dir, $files, $only_header = false)
 {
     $xsendfile = false;
     if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || isset($_SERVER['MOD_X_SENDFILE2_ENABLED']) || isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
         $xsendfile = true;
     }
     if (is_array($files) && count($files) == 1) {
         $files = $files[0];
     }
     if (is_array($files)) {
         self::validateZipDownload($dir, $files);
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         $zip = new ZipArchive();
         $filename = OC_Helper::tmpFile('.zip');
         if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             $l = OC_L10N::get('lib');
             throw new Exception($l->t('cannot open "%s"', array($filename)));
         }
         foreach ($files as $file) {
             $file = $dir . '/' . $file;
             if (\OC\Files\Filesystem::is_file($file)) {
                 $tmpFile = \OC\Files\Filesystem::toTmpFile($file);
                 self::$tmpFiles[] = $tmpFile;
                 $zip->addFile($tmpFile, basename($file));
             } elseif (\OC\Files\Filesystem::is_dir($file)) {
                 self::zipAddDir($file, $zip);
             }
         }
         $zip->close();
         if ($xsendfile) {
             $filename = OC_Helper::moveToNoClean($filename);
         }
         $basename = basename($dir);
         if ($basename) {
             $name = $basename . '.zip';
         } else {
             $name = 'download.zip';
         }
         set_time_limit($executionTime);
     } elseif (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
         self::validateZipDownload($dir, $files);
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         $zip = new ZipArchive();
         $filename = OC_Helper::tmpFile('.zip');
         if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             $l = OC_L10N::get('lib');
             throw new Exception($l->t('cannot open "%s"', array($filename)));
         }
         $file = $dir . '/' . $files;
         self::zipAddDir($file, $zip);
         $zip->close();
         if ($xsendfile) {
             $filename = OC_Helper::moveToNoClean($filename);
         }
         $name = $files . '.zip';
         set_time_limit($executionTime);
     } else {
         $zip = false;
         $filename = $dir . '/' . $files;
         $name = $files;
         if ($xsendfile && OC_App::isEnabled('files_encryption')) {
             $xsendfile = false;
         }
     }
     OC_Util::obEnd();
     if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
         OC_Response::setContentDispositionHeader($name, 'attachment');
         header('Content-Transfer-Encoding: binary');
         OC_Response::disableCaching();
         if ($zip) {
             ini_set('zlib.output_compression', 'off');
             header('Content-Type: application/zip');
             header('Content-Length: ' . filesize($filename));
             self::addSendfileHeader($filename);
         } else {
             $filesize = \OC\Files\Filesystem::filesize($filename);
             header('Content-Type: ' . \OC\Files\Filesystem::getMimeType($filename));
             if ($filesize > -1) {
                 header("Content-Length: " . $filesize);
             }
             if ($xsendfile) {
                 list($storage) = \OC\Files\Filesystem::resolvePath(\OC\Files\Filesystem::getView()->getAbsolutePath($filename));
                 /**
                  * @var \OC\Files\Storage\Storage $storage
                  */
                 if ($storage->instanceOfStorage('\\OC\\Files\\Storage\\Local')) {
                     self::addSendfileHeader(\OC\Files\Filesystem::getLocalFile($filename));
                 }
             }
         }
     } elseif ($zip or !\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->assign('file', $name);
         $tmpl->printPage();
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if ($only_header) {
         return;
     }
     if ($zip) {
         $handle = fopen($filename, 'r');
         if ($handle) {
             $chunkSize = 8 * 1024;
             // 1 MB chunks
             while (!feof($handle)) {
                 echo fread($handle, $chunkSize);
                 flush();
             }
         }
         if (!$xsendfile) {
             unlink($filename);
         }
     } else {
         \OC\Files\Filesystem::readfile($filename);
     }
     foreach (self::$tmpFiles as $tmpFile) {
         if (file_exists($tmpFile) and is_file($tmpFile)) {
             unlink($tmpFile);
         }
     }
 }
Esempio n. 16
0
 public function readfile($path)
 {
     OC_Util::obEnd();
     $handle = $this->fopen($path, 'rb');
     if ($handle) {
         $chunkSize = 8192;
         // 8 MB chunks
         while (!feof($handle)) {
             echo fread($handle, $chunkSize);
             flush();
         }
         $size = $this->filesize($path);
         return $size;
     }
     return false;
 }
Esempio n. 17
0
 public function done()
 {
     OC_Util::obEnd();
     $this->eventSource->send('done', '');
     $this->eventSource->close();
 }
Esempio n. 18
0
 /**
  * @param View $view
  * @param string $name
  * @param string $dir
  * @param array $params ; 'head' boolean to only send header of the request ; 'range' http range header
  */
 private static function getSingleFile($view, $dir, $name, $params)
 {
     $filename = $dir . '/' . $name;
     OC_Util::obEnd();
     $view->lockFile($filename, ILockingProvider::LOCK_SHARED);
     $rangeArray = array();
     if (isset($params['range']) && substr($params['range'], 0, 6) === 'bytes=') {
         $rangeArray = self::parseHttpRangeHeader(substr($params['range'], 6), \OC\Files\Filesystem::filesize($filename));
     }
     if (\OC\Files\Filesystem::isReadable($filename)) {
         self::sendHeaders($filename, $name, $rangeArray);
     } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->printPage();
         exit;
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if (isset($params['head']) && $params['head']) {
         return;
     }
     if (!empty($rangeArray)) {
         try {
             if (count($rangeArray) == 1) {
                 $view->readfilePart($filename, $rangeArray[0]['from'], $rangeArray[0]['to']);
             } else {
                 // check if file is seekable (if not throw UnseekableException)
                 // we have to check it before body contents
                 $view->readfilePart($filename, $rangeArray[0]['size'], $rangeArray[0]['size']);
                 $type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
                 foreach ($rangeArray as $range) {
                     echo "\r\n--" . self::getBoundary() . "\r\n" . "Content-type: " . $type . "\r\n" . "Content-range: bytes " . $range['from'] . "-" . $range['to'] . "/" . $range['size'] . "\r\n\r\n";
                     $view->readfilePart($filename, $range['from'], $range['to']);
                 }
                 echo "\r\n--" . self::getBoundary() . "--\r\n";
             }
         } catch (\OCP\Files\UnseekableException $ex) {
             // file is unseekable
             header_remove('Accept-Ranges');
             header_remove('Content-Range');
             header("HTTP/1.1 200 OK");
             self::sendHeaders($filename, $name, array());
             $view->readfile($filename);
         }
     } else {
         $view->readfile($filename);
     }
 }
Esempio n. 19
0
 /**
  * return the content of a file or return a zip file containing multiple files
  *
  * @param string $dir
  * @param string $files ; separated list of files to download
  * @param boolean $onlyHeader ; boolean to only send header of the request
  */
 public static function get($dir, $files, $onlyHeader = false)
 {
     $view = \OC\Files\Filesystem::getView();
     if (is_array($files) && count($files) === 1) {
         $files = $files[0];
     }
     if (is_array($files)) {
         $getType = self::ZIP_FILES;
         $basename = basename($dir);
         if ($basename) {
             $name = $basename;
         } else {
             $name = 'download';
         }
         $filename = $dir . '/' . $name;
     } else {
         $filename = $dir . '/' . $files;
         if (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
             $getType = self::ZIP_DIR;
             // downloading root ?
             if ($files === '') {
                 $name = 'download';
             } else {
                 $name = $files;
             }
         } else {
             $getType = self::FILE;
             $name = $files;
         }
     }
     if ($getType === self::FILE) {
         $streamer = false;
     } else {
         $streamer = new Streamer();
     }
     OC_Util::obEnd();
     try {
         if ($getType === self::FILE) {
             $view->lockFile($filename, ILockingProvider::LOCK_SHARED);
         }
         if ($streamer) {
             $streamer->sendHeaders($name);
         } elseif (\OC\Files\Filesystem::isReadable($filename)) {
             self::sendHeaders($filename, $name);
         } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
             header("HTTP/1.0 404 Not Found");
             $tmpl = new OC_Template('', '404', 'guest');
             $tmpl->printPage();
             exit;
         } else {
             header("HTTP/1.0 403 Forbidden");
             die('403 Forbidden');
         }
         if ($onlyHeader) {
             return;
         }
         if ($streamer) {
             $executionTime = intval(ini_get('max_execution_time'));
             set_time_limit(0);
             if ($getType === self::ZIP_FILES) {
                 foreach ($files as $file) {
                     $file = $dir . '/' . $file;
                     if (\OC\Files\Filesystem::is_file($file)) {
                         $fileSize = \OC\Files\Filesystem::filesize($file);
                         $fh = \OC\Files\Filesystem::fopen($file, 'r');
                         $streamer->addFileFromStream($fh, basename($file), $fileSize);
                         fclose($fh);
                     } elseif (\OC\Files\Filesystem::is_dir($file)) {
                         $streamer->addDirRecursive($file);
                     }
                 }
             } elseif ($getType === self::ZIP_DIR) {
                 $file = $dir . '/' . $files;
                 $streamer->addDirRecursive($file);
             }
             $streamer->finalize();
             set_time_limit($executionTime);
         } else {
             \OC\Files\Filesystem::readfile($filename);
         }
         if ($getType === self::FILE) {
             $view->unlockFile($filename, ILockingProvider::LOCK_SHARED);
         }
     } catch (\OCP\Lock\LockedException $ex) {
         $l = \OC::$server->getL10N('core');
         $hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
         \OC_Template::printErrorPage($l->t('File is currently busy, please try again later'), $hint);
     } catch (\Exception $ex) {
         $l = \OC::$server->getL10N('core');
         $hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
         \OC_Template::printErrorPage($l->t('Can\'t read file'), $hint);
     }
 }