CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash))) { $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest'); $tmpl->assign('URL', OCP\Util::linkToPublic('files').'&file='.$_GET['file']); $tmpl->assign('error', true); $tmpl->printPage(); exit(); } else { // Save item id in session for future requests $_SESSION['public_link_authenticated'] = $linkItem['id']; } // 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']; // Download the file if (isset($_GET['download'])) { $mimetype = OC_Filesystem::getMimeType($path); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="'.basename($path).'"'); header('Content-Type: '.$mimetype); header('Content-Length: '.OC_Filesystem::filesize($path)); OCP\Response::disableCaching(); @ob_clean(); OC_Filesystem::readfile($path); } 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('details', $uidOwner.' shared the file '.basename($path).' with you'); $tmpl->assign('owner', $uidOwner); $tmpl->assign('name', basename($path)); // Show file list if (OC_Filesystem::is_dir($path)) { // TODO } else { // Show file preview if viewer is available $tmpl->assign('dir', dirname($path)); $tmpl->assign('filename', basename($path)); $tmpl->assign('mimetype', OC_Filesystem::getMimeType($path)); $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&file='.$_GET['file'].'&download'); } $tmpl->printPage(); } exit(); } } } header('HTTP/1.0 404 Not Found'); $tmpl = new OCP\Template('', '404', 'guest'); $tmpl->printPage();