Ejemplo n.º 1
0
 public function getThumbnail($path)
 {
     $gallery_path = \OCP\Config::getSystemValue('datadirectory') . '/' . \OC_User::getUser() . '/gallery';
     if (file_exists($gallery_path . $path)) {
         return new \OC_Image($gallery_path . $path);
     }
     if (!\OC_Filesystem::file_exists($path)) {
         \OC_Log::write(self::TAG, 'File ' . $path . ' don\'t exists', \OC_Log::WARN);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromFile(\OC_Filesystem::getLocalFile($path));
     if (!$image->valid()) {
         return false;
     }
     $image->fixOrientation();
     $ret = $image->preciseResize(floor(150 * $image->width() / $image->height()), 150);
     if (!$ret) {
         \OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR);
         unset($image);
         return false;
     }
     $image->save($gallery_path . '/' . $path);
     return $image;
 }
Ejemplo n.º 2
0
function thumb($path)
{
    $thumb_path = \OCP\Config::getSystemValue('datadirectory') . '/' . \OC_User::getUser() . '/reader';
    if (file_exists($thumb_path . $path)) {
        return new \OC_Image($thumb_path . $path);
    }
    if (!\OC_Filesystem::file_exists($path)) {
        return false;
    }
}
 public static function createDataScope($appUrl, $userAddress, $dataScope)
 {
     $token = uniqid();
     self::addToken($token, $appUrl, $userAddress, $dataScope);
     //TODO: input checking on $userAddress and $dataScope
     list($userName, $userHost) = explode('@', $userAddress);
     OC_Util::setupFS(OC_User::getUser());
     $scopePathParts = array('remoteStorage', 'webdav', $userHost, $userName, $dataScope);
     for ($i = 0; $i <= count($scopePathParts); $i++) {
         $thisPath = '/' . implode('/', array_slice($scopePathParts, 0, $i));
         if (!OC_Filesystem::file_exists($thisPath)) {
             OC_Filesystem::mkdir($thisPath);
         }
     }
     return $token;
 }
Ejemplo n.º 4
0
 public static function createCategories($appUrl, $categories)
 {
     $token = uniqid();
     OC_Util::setupFS(OC_User::getUser());
     self::addToken($token, $appUrl, $categories);
     foreach (explode(',', $categories) as $category) {
         //TODO: input checking on $category
         $scopePathParts = array('remoteStorage', $category);
         for ($i = 0; $i <= count($scopePathParts); $i++) {
             $thisPath = '/' . implode('/', array_slice($scopePathParts, 0, $i));
             if (!OC_Filesystem::file_exists($thisPath)) {
                 OC_Filesystem::mkdir($thisPath);
             }
         }
     }
     return base64_encode('remoteStorage:' . $token);
 }
Ejemplo n.º 5
0
function handleStoreSettings($root, $order)
{
    if (!OC_Filesystem::file_exists($root)) {
        OCP\JSON::error(array('cause' => 'No such file or directory'));
        return;
    }
    if (!OC_Filesystem::is_dir($root)) {
        OCP\JSON::error(array('cause' => $root . ' is not a directory'));
        return;
    }
    $current_root = OCP\Config::getUserValue(OCP\USER::getUser(), 'gallery', 'root', '/');
    $root = trim($root);
    $root = rtrim($root, '/') . '/';
    $rescan = $current_root == $root ? 'no' : 'yes';
    OCP\Config::setUserValue(OCP\USER::getUser(), 'gallery', 'root', $root);
    OCP\Config::setUserValue(OCP\USER::getUser(), 'gallery', 'order', $order);
    OCP\JSON::success(array('rescan' => $rescan));
}
Ejemplo n.º 6
0
         // Check if item id is set in session
     } else {
         if (!isset($_SESSION['public_link_authenticated']) || $_SESSION['public_link_authenticated'] !== $linkItem['id']) {
             // Prompt for password
             $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
             $tmpl->assign('URL', OCP\Util::linkToPublic('files') . '&file=' . $_GET['file']);
             $tmpl->printPage();
             exit;
         }
     }
 }
 $path = $linkItem['path'];
 if (isset($_GET['path'])) {
     $path .= $_GET['path'];
     $dir .= $_GET['path'];
     if (!OC_Filesystem::file_exists($path)) {
         header('HTTP/1.0 404 Not Found');
         $tmpl = new OCP\Template('', '404', 'guest');
         $tmpl->printPage();
         exit;
     }
 }
 // Download the file
 if (isset($_GET['download'])) {
     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
 /**
  * Get the file by an URL
  * @param URL of the file
  */
 public static function getHttpFile($file, $pr_transfer = NULL)
 {
     try {
         if (!self::remoteFileExists($file)) {
             return 'The file does not exists ...';
         }
         if (!isset($pr_transfer)) {
             $fileinfo = pathinfo($file);
         } else {
             $fileinfo = pathinfo($pr_transfer);
         }
         $filename = strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? preg_replace('/\\./', '%2e', $fileinfo['basename'], substr_count($fileinfo['basename'], '.') - 1) : $fileinfo['basename'];
         if (strpos($filename, 'rsapi.cgi')) {
             $filename = substr($filename, 0, strpos($filename, '&'));
         }
         if (OC_Filesystem::file_exists('/Downloads/' . $filename)) {
             $filename = md5(rand()) . '_' . $filename;
         }
         $fs = OC_Filesystem::fopen('/Downloads/' . $filename, 'w');
         $size = self::getRemoteFileSize($file);
         if ($size == 0) {
             return 'Error ! Null file size.';
         }
         switch (strtolower($fileinfo['extension'])) {
             case 'exe':
                 $ctype = 'application/octet-stream';
                 break;
             case 'zip':
                 $ctype = 'application/zip';
                 break;
             case 'mp3':
                 $ctype = 'audio/mpeg';
                 break;
             case 'mpg':
                 $ctype = 'video/mpeg';
                 break;
             case 'avi':
                 $ctype = 'video/x-msvideo';
                 break;
             case 'png':
                 $ctype = 'image/png';
                 break;
             default:
                 $ctype = 'application/force-download';
         }
         $seek_end = empty($seek_end) ? $size - 1 : min(abs(intval($seek_end)), $size - 1);
         $seek_start = empty($seek_start) || $seek_end < abs(intval($seek_start)) ? 0 : max(abs(intval($seek_start)), 0);
         /*header("Cache-Control: cache, must-revalidate");  
           header("Pragma: public");
           header('Content-Type: ' . $ctype);
           header('Content-Disposition: attachment; filename="' . $filename . '"');
           header('Content-Length: ' . ($seek_end - $seek_start + 1));*/
         $fp = fopen($file, 'rb');
         set_time_limit(0);
         while (!feof($fp)) {
             $data = fread($fp, 1024 * 8);
             if ($data == '') {
                 break;
             }
             fwrite($fs, $data);
         }
         fclose($fp);
         fclose($fs);
         return array('ok' => 'Transfer completed successfully. The file has been moved in your Downloads folder.');
     } catch (exception $e) {
         return array('error' => $e->getMessage());
     }
 }
Ejemplo n.º 8
0
 /**
  * Checks if a child exists.
  *
  * @param string $name
  * @return bool
  */
 public function childExists($name)
 {
     $path = $this->path . '/' . $name;
     return OC_Filesystem::file_exists($path);
 }
Ejemplo n.º 9
0
 /**
  * Adds a suffix to the name in case the file exists
  *
  * @param $path
  * @param $filename
  * @return string
  */
 public static function buildNotExistingFileName($path, $filename)
 {
     if ($path === '/') {
         $path = '';
     }
     if ($pos = strrpos($filename, '.')) {
         $name = substr($filename, 0, $pos);
         $ext = substr($filename, $pos);
     } else {
         $name = $filename;
     }
     $newpath = $path . '/' . $filename;
     $newname = $filename;
     $counter = 2;
     while (OC_Filesystem::file_exists($newpath)) {
         $newname = $name . ' (' . $counter . ')' . $ext;
         $newpath = $path . '/' . $newname;
         $counter++;
     }
     return $newpath;
 }
 /**
  * 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
  */
 public static function get($dir, $files)
 {
     if (strpos($files, ';')) {
         $files = explode(';', $files);
     }
     if (is_array($files)) {
         $zip = new ZipArchive();
         $filename = sys_get_temp_dir() . "/ownCloud.zip";
         if ($zip->open($filename, ZIPARCHIVE::CREATE) !== 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();
     } elseif (OC_Filesystem::is_dir($dir . '/' . $files)) {
         $zip = new ZipArchive();
         $filename = sys_get_temp_dir() . "/ownCloud.zip";
         if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
             exit("cannot open <{$filename}>\n");
         }
         $file = $dir . '/' . $files;
         self::zipAddDir($file, $zip);
         $zip->close();
     } else {
         $zip = false;
         $filename = $dir . '/' . $files;
     }
     if ($zip or OC_Filesystem::is_readable($filename)) {
         header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
         header('Content-Transfer-Encoding: binary');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         if ($zip) {
             header('Content-Type: application/zip');
             header('Content-Length: ' . filesize($filename));
         } else {
             header('Content-Type: ' . OC_Filesystem::getMimeType($filename));
             header('Content-Length: ' . OC_Filesystem::filesize($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();
         // 			die('404 Not Found');
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     @ob_end_clean();
     if ($zip) {
         readfile($filename);
         unlink($filename);
     } else {
         OC_Filesystem::readfile($filename);
     }
     foreach (self::$tmpFiles as $tmpFile) {
         if (file_exists($tmpFile) and is_file($tmpFile)) {
             unlink($tmpFile);
         }
     }
 }
Ejemplo n.º 11
0
 public function postFopen($path, &$result)
 {
     if (!$result) {
         return $result;
     }
     $meta = stream_get_meta_data($result);
     if (self::isEncrypted($path)) {
         fclose($result);
         $result = fopen('crypt://' . $path, $meta['mode']);
     } elseif (self::shouldEncrypt($path) and $meta['mode'] != 'r' and $meta['mode'] != 'rb') {
         if (OC_Filesystem::file_exists($path) and OC_Filesystem::filesize($path) > 0) {
             //first encrypt the target file so we don't end up with a half encrypted file
             OCP\Util::writeLog('files_encryption', 'Decrypting ' . $path . ' before writing', OCP\Util::DEBUG);
             $tmp = fopen('php://temp');
             OCP\Files::streamCopy($result, $tmp);
             fclose($result);
             OC_Filesystem::file_put_contents($path, $tmp);
             fclose($tmp);
         }
         $result = fopen('crypt://' . $path, $meta['mode']);
     }
     return $result;
 }
Ejemplo n.º 12
0
 public function getThumbnailInfo($path)
 {
     $arr = DatabaseManager::getInstance()->getFileData($path);
     if (!$arr) {
         if (!\OC_Filesystem::file_exists($path)) {
             \OC_Log::write(self::TAG, 'File ' . $path . ' don\'t exists', \OC_Log::WARN);
             return false;
         }
         $image = new \OC_Image();
         $image->loadFromFile(\OC_Filesystem::getLocalFile($path));
         if (!$image->valid()) {
             return false;
         }
         $arr = DatabaseManager::getInstance()->setFileData($path, $this->getThumbnailWidth($image), self::THUMBNAIL_HEIGHT);
     }
     $ret = array('filepath' => $arr['path'], 'width' => $arr['width'], 'height' => $arr['height']);
     return $ret;
 }
     flush();
     break;
 case 'scanFile':
     echo OC_MEDIA_SCANNER::scanFile($arguments['path']) ? 'true' : 'false';
     break;
 case 'get_artists':
     OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getArtists($arguments['search']));
     break;
 case 'get_albums':
     OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getAlbums($arguments['artist'], $arguments['search']));
     break;
 case 'get_songs':
     OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getSongs($arguments['artist'], $arguments['album'], $arguments['search']));
     break;
 case 'get_path_info':
     if (OC_Filesystem::file_exists($arguments['path'])) {
         $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']);
         if ($songId == 0) {
             unset($_SESSION['collection']);
             $songId = OC_MEDIA_SCANNER::scanFile($arguments['path']);
         }
         if ($songId > 0) {
             $song = OC_MEDIA_COLLECTION::getSong($songId);
             $song['artist'] = OC_MEDIA_COLLECTION::getArtistName($song['song_artist']);
             $song['album'] = OC_MEDIA_COLLECTION::getAlbumName($song['song_album']);
             OC_JSON::encodedPrint($song);
         }
     }
     break;
 case 'play':
     ob_end_clean();
Ejemplo n.º 14
0
<?php

// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
// Get data
$dir = stripslashes($_GET["dir"]);
$file = stripslashes($_GET["file"]);
$target = stripslashes(rawurldecode($_GET["target"]));
if (OC_Filesystem::file_exists($target . '/' . $file)) {
    OCP\JSON::error(array("data" => array("message" => "Could not move {$file} - File with this name already exists")));
    exit;
}
if (OC_Files::move($dir, $file, $target, $file)) {
    OCP\JSON::success(array("data" => array("dir" => $dir, "files" => $file)));
} else {
    OCP\JSON::error(array("data" => array("message" => "Could not move {$file}")));
}
Ejemplo n.º 15
0
* 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
// Check if we are a user
OCP\User::checkLoggedIn();
$filename = $_GET["file"];
if (!OC_Filesystem::file_exists($filename)) {
    header("HTTP/1.0 404 Not Found");
    $tmpl = new OCP\Template('', '404', 'guest');
    $tmpl->assign('file', $filename);
    $tmpl->printPage();
    exit;
}
$ftype = OC_Filesystem::getMimeType($filename);
header('Content-Type:' . $ftype);
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
OCP\Response::disableCaching();
header('Content-Length: ' . OC_Filesystem::filesize($filename));
@ob_end_clean();
OC_Filesystem::readfile($filename);
//don't setup the fs yet
require_once '../../lib/base.php';
OC_JSON::checkAppEnabled('files_sharing');
require_once 'lib_share.php';
//get the path of the shared file
$token = $_GET['token'];
$source = OC_Share::getSource($token);
if ($source !== false) {
    // TODO Manipulating the string may not be the best choice. Is there an alternative?
    $user = substr($source, 1, strpos($source, "/", 1) - 1);
    OC_Util::setupFS($user);
    $source = substr($source, strlen("/" . $user . "/files"));
    $subPath = isset($_GET['path']) ? $_GET['path'] : '';
    $root = $source;
    $source .= $subPath;
    if (!OC_Filesystem::file_exists($source)) {
        header("HTTP/1.0 404 Not Found");
        $tmpl = new OC_Template("", "404", "guest");
        $tmpl->assign("file", $subPath);
        $tmpl->printPage();
        exit;
    }
    if (OC_Filesystem::is_dir($source)) {
        $files = array();
        $rootLength = strlen($root);
        foreach (OC_Files::getdirectorycontent($source) as $i) {
            $i['date'] = OC_Util::formatDate($i['mtime']);
            if ($i['type'] == 'file') {
                $fileinfo = pathinfo($i['name']);
                $i['basename'] = $fileinfo['filename'];
                $i['extention'] = isset($fileinfo['extension']) ? '.' . $fileinfo['extension'] : '';
Ejemplo n.º 17
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)
 {
     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();
         $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();
         $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;
     }
     @ob_end_clean();
     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));
         } else {
             $fileData = OC_FileCache::get($filename);
             header('Content-Type: ' . $fileData['mimetype']);
         }
     } 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();
             }
         }
         unlink($filename);
     } else {
         OC_Filesystem::readfile($filename);
     }
     foreach (self::$tmpFiles as $tmpFile) {
         if (file_exists($tmpFile) and is_file($tmpFile)) {
             unlink($tmpFile);
         }
     }
 }
    $query = '/' . $query;
}
if (substr($query, -1, 1) == '/') {
    $base = $query;
} else {
    $base = dirname($query);
}
$query = substr($query, strlen($base));
if ($base != '/') {
    $query = substr($query, 1);
}
$queryLen = strlen($query);
$query = strtolower($query);
// echo "$base - $query";
$files = array();
if (OC_Filesystem::file_exists($base) and OC_Filesystem::is_dir($base)) {
    $dh = OC_Filesystem::opendir($base);
    if ($dh) {
        if (substr($base, -1, 1) != '/') {
            $base = $base . '/';
        }
        while (($file = readdir($dh)) !== false) {
            if ($file != "." && $file != "..") {
                if (substr(strtolower($file), 0, $queryLen) == $query) {
                    $item = $base . $file;
                    if (!$dirOnly or OC_Filesystem::is_dir($item)) {
                        $files[] = (object) array('id' => $item, 'label' => $item, 'name' => $item);
                    }
                }
            }
        }
Ejemplo n.º 19
0
 public function file_assemble($path)
 {
     $absolutePath = OC_Filesystem::normalizePath(OC_Filesystem::getView()->getAbsolutePath($path));
     $data = '';
     // use file_put_contents as method because that best matches what this function does
     if (OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) && OC_Filesystem::isValidPath($path)) {
         $path = OC_Filesystem::getView()->getRelativePath($absolutePath);
         $exists = OC_Filesystem::file_exists($path);
         $run = true;
         if (!$exists) {
             OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, array(OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run));
         }
         OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, array(OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run));
         if (!$run) {
             return false;
         }
         $target = OC_Filesystem::fopen($path, 'w');
         if ($target) {
             $count = $this->assemble($target);
             fclose($target);
             if (!$exists) {
                 OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_create, array(OC_Filesystem::signal_param_path => $path));
             }
             OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, array(OC_Filesystem::signal_param_path => $path));
             OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
             return $count > 0;
         } else {
             return false;
         }
     }
 }
Ejemplo n.º 20
0
     } else {
         if (!isset($_SESSION['public_link_authenticated']) || $_SESSION['public_link_authenticated'] !== $linkItem['id']) {
             // Prompt for password
             $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
             $tmpl->assign('URL', $url);
             $tmpl->printPage();
             exit;
         }
     }
 }
 $basePath = substr($pathAndUser['path'], strlen('/' . $fileOwner . '/files'));
 $path = $basePath;
 if (isset($_GET['path'])) {
     $path .= $_GET['path'];
 }
 if (!$path || !OC_Filesystem::isValidPath($path) || !OC_Filesystem::file_exists($path)) {
     OCP\Util::writeLog('share', 'Invalid path ' . $path . ' for share id ' . $linkItem['id'], \OCP\Util::ERROR);
     header('HTTP/1.0 404 Not Found');
     $tmpl = new OCP\Template('', '404', 'guest');
     $tmpl->printPage();
     exit;
 }
 $dir = dirname($path);
 $file = basename($path);
 // Download the file
 if (isset($_GET['download'])) {
     if (isset($_GET['path']) && $_GET['path'] !== '') {
         if (isset($_GET['files'])) {
             // download selected files
             OC_Files::get($path, $_GET['files'], $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
         } else {