add previews for public files

This commit is contained in:
Georg Ehrke 2013-05-22 15:12:25 +02:00
parent 13c6ef1ba9
commit 00985068ca
3 changed files with 27 additions and 9 deletions

View File

@ -44,6 +44,8 @@ $this->create('core_ajax_routes', '/core/routes.json')
->action('OC_Router', 'JSRoutes'); ->action('OC_Router', 'JSRoutes');
$this->create('core_ajax_preview', '/core/preview.png') $this->create('core_ajax_preview', '/core/preview.png')
->action('OC_Preview', 'previewRouter'); ->action('OC_Preview', 'previewRouter');
$this->create('core_ajax_public_preview', '/core/publicpreview.png')
->action('OC_Preview', 'publicPreviewRouter');
OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php'; OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php';
$this->create('core_lostpassword_index', '/lostpassword/') $this->create('core_lostpassword_index', '/lostpassword/')
->get() ->get()

View File

@ -531,14 +531,28 @@ class OC_Preview {
if(array_key_exists('t', $_GET)) $token = (string) $_GET['t']; if(array_key_exists('t', $_GET)) $token = (string) $_GET['t'];
$linkItem = OCP\Share::getShareByToken($token); $linkItem = OCP\Share::getShareByToken($token);
if (is_array($linkItem) && isset($linkItem['uid_owner']) && isset($linkItem['file_source'])) { if (is_array($linkItem) && isset($linkItem['uid_owner']) && isset($linkItem['file_source'])) {
$userid = $linkItem['uid_owner']; $userid = $linkItem['uid_owner'];
OC_Util::setupFS($fileOwner); OC_Util::setupFS($userid);
$path = $linkItem['file_source']; $pathid = $linkItem['file_source'];
$path = \OC\Files\Filesystem::getPath($pathid);
} }
if($user !== null && $path !== null){ //clean up file parameter
$preview = new OC_Preview($userid, $path, $file, $maxX, $maxY, $scalingup); $file = \OC\Files\Filesystem::normalizePath($file);
if(!\OC\Files\Filesystem::isValidPath($file)){
OC_Response::setStatus(403);
exit;
}
$path = \OC\Files\Filesystem::normalizePath($path, false);
if(substr($path, 0, 1) == '/'){
$path = substr($path, 1);
}
if($userid !== null && $path !== null){
$preview = new OC_Preview($userid, 'files/' . $path, $file, $maxX, $maxY, $scalingup);
$preview->showPreview(); $preview->showPreview();
}else{ }else{
OC_Response::setStatus(404); OC_Response::setStatus(404);

View File

@ -13,9 +13,11 @@ class OC_Preview_Unknown extends OC_Preview_Provider{
} }
public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview) { public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview) {
/*$mimetype = $fileview->getMimeType($path);
$info = $fileview->getFileInfo($path);
$mimetype = $this->fileview->getMimeType($file); $name = array_key_exists('name', $info) ? $info['name'] : '';
$size = array_key_exists('size', $info) ? $info['size'] : 0;
$isencrypted = array_key_exists('encrypted', $info) ? $info['encrypted'] : false;*/ // show little lock
return new \OC_Image(); return new \OC_Image();
} }
} }