Beispiel #1
0
 /**
  * @brief offer single file for download
  * 
  * @param string $path full path to file
  * @param int $id file id
  */
 public static function serveFile($path, $id)
 {
     \OCP\User::checkLoggedIn();
     \OC::$server->getSession()->close();
     Bookshelf::add($id);
     $dirName = dirname($path);
     $fileName = basename($path);
     \OC_Files::get($dirName, array($fileName), $_SERVER['REQUEST_METHOD'] == 'HEAD');
 }
* @author Robin Appelman
* @copyright 2010 Robin Appelman icewind1991@gmail.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/>.
*
*/
// only need filesystem apps
$RUNTIME_APPTYPES = array('filesystem');
// Init owncloud
// Check if we are a user
OCP\User::checkLoggedIn();
$files = $_GET["files"];
$dir = $_GET["dir"];
$files_list = json_decode($files);
// in case we get only a single file
if (!is_array($files_list)) {
    $files_list = array($files);
}
OC_Files::get($dir, $files_list, $_SERVER['REQUEST_METHOD'] == 'HEAD');
Beispiel #3
0
     if (isset($_GET['dir'])) {
         if (isset($_GET['files'])) {
             // download selected files
             OC_Files::get($path, $_GET['files'], $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
         } else {
             if (isset($_GET['path']) && $_GET['path'] != '') {
                 // download a file from a shared directory
                 OC_Files::get('', $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
             } else {
                 // download the whole shared directory
                 OC_Files::get($path, '', $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
             }
         }
     } else {
         // download a single shared file
         OC_Files::get("", $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
     }
 } else {
     OCP\Util::addStyle('files_sharing', 'public');
     OCP\Util::addScript('files_sharing', 'public');
     OCP\Util::addScript('files', 'fileactions');
     $tmpl = new OCP\Template('files_sharing', 'public', 'base');
     $tmpl->assign('owner', $uidOwner);
     // Show file list
     if (OC_Filesystem::is_dir($path)) {
         OCP\Util::addStyle('files', 'files');
         OCP\Util::addScript('files', 'files');
         OCP\Util::addScript('files', 'filelist');
         $files = array();
         $rootLength = strlen($baseDir) + 1;
         foreach (OC_Files::getDirectoryContent($path) as $i) {
Beispiel #4
0
<?php

/**
* ownCloud - ajax frontend
*
* @author Robin Appelman
* @copyright 2010 Robin Appelman icewind1991@gmail.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/>.
*
*/
// only need filesystem apps
$RUNTIME_APPTYPES = array('filesystem');
// Init owncloud
// Check if we are a user
OCP\User::checkLoggedIn();
$files = $_GET["files"];
$dir = $_GET["dir"];
OC_Files::get($dir, $files, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
<?php

/**
* ownCloud - ajax frontend
*
* @author Robin Appelman
* @copyright 2010 Robin Appelman icewind1991@gmail.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/>.
*
*/
// Init owncloud
require_once '../../lib/base.php';
// Check if we are a user
OC_Util::checkLoggedIn();
$files = $_GET["files"];
$dir = $_GET["dir"];
OC_Files::get($dir, $files);
Beispiel #6
0
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
// Check if we are a user
OCP\User::checkLoggedIn();
\OC::$server->getSession()->close();
$files = isset($_GET['files']) ? (string) $_GET['files'] : '';
$dir = isset($_GET['dir']) ? (string) $_GET['dir'] : '';
$files_list = json_decode($files);
// in case we get only a single file
if (!is_array($files_list)) {
    $files_list = array($files);
}
/**
 * this sets a cookie to be able to recognize the start of the download
 * the content must not be longer than 32 characters and must only contain
 * alphanumeric characters
 */
if (isset($_GET['downloadStartSecret']) && !isset($_GET['downloadStartSecret'][32]) && preg_match('!^[a-zA-Z0-9]+$!', $_GET['downloadStartSecret']) === 1) {
    setcookie('ocDownloadStarted', $_GET['downloadStartSecret'], time() + 20, '/');
}
$server_params = array('head' => \OC::$server->getRequest()->getMethod() == 'HEAD');
/**
 * Http range requests support
 */
if (isset($_SERVER['HTTP_RANGE'])) {
    $server_params['range'] = \OC::$server->getRequest()->getHeader('Range');
}
OC_Files::get($dir, $files_list, $server_params);
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  * @SSOCORS
  */
 public function download($dir = null, $file = null)
 {
     \OC::$server->getSession()->close();
     $exists = \OC\Files\Filesystem::file_exists($dir . "/" . $file);
     if (!$exists) {
         return new NotFoundResponse();
     }
     $files_list = json_decode($file);
     // in case we get only a single file
     if (!is_array($files_list)) {
         $files_list = array($file);
     }
     \OC_Files::get($dir, $files_list, $_SERVER['REQUEST_METHOD'] == 'HEAD');
 }