Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions apps/dav/lib/connector/sabre/filesplugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function initialize(\Sabre\DAV\Server $server) {
$this->server->on('afterBind', array($this, 'sendFileIdHeader'));
$this->server->on('afterWriteContent', array($this, 'sendFileIdHeader'));
$this->server->on('afterMethod:GET', [$this,'httpGet']);
$this->server->on('afterMethod:GET', array($this, 'handleDownloadToken'));
$this->server->on('afterResponse', function($request, ResponseInterface $response) {
$body = $response->getBody();
if (is_resource($body)) {
Expand Down Expand Up @@ -148,6 +149,32 @@ function checkMove($source, $destination) {
}
}

/**
* This sets a cookie to be able to recognize the start of the download
* the content must not be longer than 32 characters and must only contain
* alphanumeric characters
*
* @param RequestInterface $request
* @param ResponseInterface $response
*/
function handleDownloadToken(RequestInterface $request, ResponseInterface $response) {
$queryParams = $request->getQueryParameters();

/**
* this sets a cookie to be able to recognize the start of the download
* the content must not be longer than 32 characters and must only contain
* alphanumeric characters
*/
if (isset($queryParams['downloadStartSecret'])) {
$token = $queryParams['downloadStartSecret'];
if (!isset($token[32])
&& preg_match('!^[a-zA-Z0-9]+$!', $token) === 1) {
// FIXME: use $response->setHeader() instead
setcookie('ocDownloadStarted', $token, time() + 20, '/');
}
}
}

/**
* Plugin that adds a 'Content-Disposition: attachment' header to all files
* delivered by SabreDAV.
Expand Down
81 changes: 0 additions & 81 deletions apps/files/ajax/delete.php

This file was deleted.

59 changes: 0 additions & 59 deletions apps/files/ajax/move.php

This file was deleted.

103 changes: 0 additions & 103 deletions apps/files/ajax/newfile.php

This file was deleted.

99 changes: 0 additions & 99 deletions apps/files/ajax/newfolder.php

This file was deleted.

Loading