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'] = OCP\Util::formatDate($i['mtime'] ); if ($i['type'] == 'file') { $fileinfo = pathinfo($i['name']); $i['basename'] = $fileinfo['filename']; $i['extension'] = isset($fileinfo['extension']) ? ('.'.$fileinfo['extension']) : ''; } $i['directory'] = substr($i['directory'], $rootLength); if ($i['directory'] == "/") { $i['directory'] = ""; } $files[] = $i; } // Make breadcrumb $breadcrumb = array(); $pathtohere = ""; foreach (explode("/", $subPath) as $i) { if ($i != "") { $pathtohere .= "/$i"; $breadcrumb[] = array("dir" => $pathtohere, "name" => $i); } } // Load the files we need OCP\Util::addStyle("files", "files"); $breadcrumbNav = new OCP\Template("files", "part.breadcrumb", ""); $breadcrumbNav->assign("breadcrumb", $breadcrumb); $breadcrumbNav->assign("baseURL", OCP\Util::linkTo("", "public.php")."?service=files&token=".$token."&path="); $list = new OCP\Template("files", "part.list", ""); $list->assign("files", $files); $list->assign("baseURL", OCP\Util::linkTo("", "public.php")."?service=files&token=".$token."&path="); $list->assign("downloadURL", OCP\Util::linkTo("", "public.php")."?service=files&token=".$token."&path="); $list->assign("readonly", true); $tmpl = new OCP\Template("files", "index", "user"); $tmpl->assign("fileList", $list->fetchPage()); $tmpl->assign("breadcrumb", $breadcrumbNav->fetchPage()); $tmpl->assign("readonly", true); $tmpl->assign("allowZipDownload", false); $tmpl->assign("dir", 'shared dir'); $tmpl->printPage(); } else { //get time mimetype and set the headers $mimetype = OC_Filesystem::getMimeType($source); header("Content-Transfer-Encoding: binary"); OCP\Response::disableCaching(); header('Content-Disposition: attachment; filename="'.basename($source).'"'); header("Content-Type: " . $mimetype); header("Content-Length: " . OC_Filesystem::filesize($source)); //download the file @ob_clean(); OC_Filesystem::readfile($source); } } else { header("HTTP/1.0 404 Not Found"); $tmpl = new OCP\Template("", "404", "guest"); $tmpl->printPage(); die(); } ?>