From 8a7f2361d501683a88c5f687d15c4670da589a78 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 18 Apr 2011 10:19:50 +0200 Subject: [PATCH] public link sharing also works for folders now --- plugins/publiclink/get.php | 76 +++++++++++++++++++++ plugins/publiclink/getfile.php | 11 --- plugins/publiclink/lib_public.php | 23 ++----- plugins/publiclink/templates/breadcrumb.php | 4 ++ plugins/publiclink/templates/files.php | 9 +++ plugins/publiclink/templates/index.php | 17 +++++ 6 files changed, 110 insertions(+), 30 deletions(-) create mode 100644 plugins/publiclink/get.php delete mode 100644 plugins/publiclink/getfile.php create mode 100644 plugins/publiclink/templates/breadcrumb.php create mode 100644 plugins/publiclink/templates/files.php create mode 100644 plugins/publiclink/templates/index.php diff --git a/plugins/publiclink/get.php b/plugins/publiclink/get.php new file mode 100644 index 00000000000..cdfe42ef262 --- /dev/null +++ b/plugins/publiclink/get.php @@ -0,0 +1,76 @@ + $pathtohere, "name" => $i ); + } + } + + $breadcrumbNav = new OC_TEMPLATE( "plugins/publiclink", "breadcrumb", "" ); + $breadcrumbNav->assign( "breadcrumb", $breadcrumb ); + $breadcrumbNav->assign('token',$token); + + $list = new OC_TEMPLATE( 'plugins/publiclink', 'files', '' ); + $list->assign( 'files', $files ); + $list->assign('token',$token); + + $tmpl = new OC_TEMPLATE( 'plugins/publiclink', 'index', 'user' ); + $tmpl->assign('fileList', $list->fetchPage()); + $tmpl->assign( "breadcrumb", $breadcrumbNav->fetchPage() ); + $tmpl->printPage(); + }else{ + //get time mimetype and set the headers + $mimetype=OC_FILESYSTEM::getMimeType($path); + header('Content-Transfer-Encoding: binary'); + header('Content-Disposition: attachment; filename="'.basename($path).'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Type: ' . $mimetype); + header('Content-Length: ' . OC_FILESYSTEM::filesize($path)); + + //download the file + ob_clean(); + OC_FILESYSTEM::readfile($path); + } +}else{ + header("HTTP/1.0 404 Not Found"); + echo '404 Not Found'; + die(); +} +?> \ No newline at end of file diff --git a/plugins/publiclink/getfile.php b/plugins/publiclink/getfile.php deleted file mode 100644 index 15a568df3dc..00000000000 --- a/plugins/publiclink/getfile.php +++ /dev/null @@ -1,11 +0,0 @@ - \ No newline at end of file diff --git a/plugins/publiclink/lib_public.php b/plugins/publiclink/lib_public.php index 7c25c938fda..436dddeef22 100644 --- a/plugins/publiclink/lib_public.php +++ b/plugins/publiclink/lib_public.php @@ -22,10 +22,9 @@ class OC_PublicLink{ } /** - * download a file shared by a public link - * @param string token + * get the path of that shared file */ - public static function downloadFile($token){ + public static function getPath($token){ //remove expired links $query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE expire_time < NOW() AND expire_time!=0"); $query->execute(); @@ -41,23 +40,9 @@ class OC_PublicLink{ //prepare the filesystem OC_UTIL::setupFS($user); - //get time mimetype and set the headers - $mimetype=OC_FILESYSTEM::getMimeType($path); - // header('Content-Disposition: attachment; filename="'.basename($path).'"'); - header('Content-Transfer-Encoding: binary'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); - header('Content-Type: ' . $mimetype); - header('Content-Length: ' . OC_FILESYSTEM::filesize($path)); - - //download the file - ob_clean(); - OC_FILESYSTEM::readfile($path); + return $path; }else{ - header("HTTP/1.0 404 Not Found"); - echo '404 Not Found'; - die(); + return false; } } diff --git a/plugins/publiclink/templates/breadcrumb.php b/plugins/publiclink/templates/breadcrumb.php new file mode 100644 index 00000000000..3f4ae863ee0 --- /dev/null +++ b/plugins/publiclink/templates/breadcrumb.php @@ -0,0 +1,4 @@ + " alt="Root" /> + + "> + \ No newline at end of file diff --git a/plugins/publiclink/templates/files.php b/plugins/publiclink/templates/files.php new file mode 100644 index 00000000000..6473ad4c5c8 --- /dev/null +++ b/plugins/publiclink/templates/files.php @@ -0,0 +1,9 @@ + + + + )" href="" title=""> + + + + + + \ No newline at end of file diff --git a/plugins/publiclink/templates/index.php b/plugins/publiclink/templates/index.php new file mode 100644 index 00000000000..9e238452603 --- /dev/null +++ b/plugins/publiclink/templates/index.php @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
NameSizeModified
\ No newline at end of file -- 2.39.5