| ' . $this->escapeHTML($subProps['displayPath']) . ' | '; - $html .= '' . $this->escapeHTML($type['string']) . ' | '; + $html .= ''.$this->escapeHTML($subProps['displayPath']).' | '; + $html .= ''.$this->escapeHTML($type['string']).' | '; $html .= ''; if (isset($subProps['{DAV:}getcontentlength'])) { - $html .= $this->escapeHTML($subProps['{DAV:}getcontentlength'] . ' bytes'); + $html .= $this->escapeHTML($subProps['{DAV:}getcontentlength'].' bytes'); } $html .= ' | '; if (isset($subProps['{DAV:}getlastmodified'])) { $lastMod = $subProps['{DAV:}getlastmodified']->getTime(); $html .= $this->escapeHTML($lastMod->format('F j, Y, g:i a')); } + $html .= ' | '; + if (isset($subProps['{DAV:}displayname'])) { + $html .= $this->escapeHTML($subProps['{DAV:}displayname']); + } $html .= ' | '; $buttonActions = ''; if ($subProps['subNode'] instanceof DAV\IFile) { - $buttonActions = ''; + $buttonActions = ''; } $this->server->emit('browserButtonActions', [$subProps['fullPath'], $subProps['subNode'], &$buttonActions]); - $html .= '' . $buttonActions . ' | '; + $html .= ''.$buttonActions.' | '; $html .= '
" . $html->h(implode("\n", $xml)) . "";
+ return ''.$html->h(implode("\n", $xml)).'';
} else {
- return "unknown";
+ return 'unknown';
}
-
}
/**
@@ -772,10 +775,9 @@ HTML;
*
* @return string
*/
- function getPluginName() {
-
+ public function getPluginName()
+ {
return 'browser';
-
}
/**
@@ -789,14 +791,12 @@ HTML;
*
* @return array
*/
- function getPluginInfo() {
-
+ public function getPluginInfo()
+ {
return [
- 'name' => $this->getPluginName(),
+ 'name' => $this->getPluginName(),
'description' => 'Generates HTML indexes and debug information for your sabre/dav server',
- 'link' => 'http://sabre.io/dav/browser-plugin/',
+ 'link' => 'http://sabre.io/dav/browser-plugin/',
];
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Browser/PropFindAll.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Browser/PropFindAll.php
index c14b7f2f96d..34702bdd8aa 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Browser/PropFindAll.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Browser/PropFindAll.php
@@ -1,5 +1,7 @@
result[$propertyName] = [200, $value];
}
-
}
/**
- * Sets the value of the property
+ * Sets the value of the property.
*
* If status is not supplied, the status will default to 200 for non-null
* properties, and 404 for null properties.
*
* @param string $propertyName
- * @param mixed $value
- * @param int $status
- * @return void
+ * @param mixed $value
+ * @param int $status
*/
- function set($propertyName, $value, $status = null) {
-
+ public function set($propertyName, $value, $status = null)
+ {
if (is_null($status)) {
$status = is_null($value) ? 404 : 200;
}
$this->result[$propertyName] = [$status, $value];
-
}
/**
* Returns the current value for a property.
*
* @param string $propertyName
+ *
* @return mixed
*/
- function get($propertyName) {
-
+ public function get($propertyName)
+ {
return isset($this->result[$propertyName]) ? $this->result[$propertyName][1] : null;
-
}
/**
@@ -99,12 +96,12 @@ class PropFindAll extends PropFind {
* null will be returned.
*
* @param string $propertyName
+ *
* @return int|null
*/
- function getStatus($propertyName) {
-
+ public function getStatus($propertyName)
+ {
return isset($this->result[$propertyName]) ? $this->result[$propertyName][0] : 404;
-
}
/**
@@ -113,11 +110,11 @@ class PropFindAll extends PropFind {
*
* @return array
*/
- function get404Properties() {
-
+ public function get404Properties()
+ {
$result = [];
foreach ($this->result as $propertyName => $stuff) {
- if ($stuff[0] === 404) {
+ if (404 === $stuff[0]) {
$result[] = $propertyName;
}
}
@@ -125,8 +122,7 @@ class PropFindAll extends PropFind {
if (!$result) {
$result[] = '{http://sabredav.org/ns}idk';
}
+
return $result;
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Client.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Client.php
index 175ad1bc459..cfa24cd2992 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Client.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Client.php
@@ -1,12 +1,14 @@
xml->elementMap.
* It's deprecated as of version 3.0.0, and should no longer be used.
*
* @deprecated
+ *
* @var array
*/
public $propertyMap = [];
/**
- * Base URI
+ * Base URI.
*
* This URI will be used to resolve relative urls.
*
@@ -49,17 +52,17 @@ class Client extends HTTP\Client {
protected $baseUri;
/**
- * Basic authentication
+ * Basic authentication.
*/
const AUTH_BASIC = 1;
/**
- * Digest authentication
+ * Digest authentication.
*/
const AUTH_DIGEST = 2;
/**
- * NTLM authentication
+ * NTLM authentication.
*/
const AUTH_NTLM = 4;
@@ -69,12 +72,12 @@ class Client extends HTTP\Client {
const ENCODING_IDENTITY = 1;
/**
- * Deflate encoding
+ * Deflate encoding.
*/
const ENCODING_DEFLATE = 2;
/**
- * Gzip encoding
+ * Gzip encoding.
*/
const ENCODING_GZIP = 4;
@@ -84,14 +87,14 @@ class Client extends HTTP\Client {
const ENCODING_ALL = 7;
/**
- * Content-encoding
+ * Content-encoding.
*
* @var int
*/
protected $encoding = self::ENCODING_IDENTITY;
/**
- * Constructor
+ * Constructor.
*
* Settings are provided through the 'settings' argument. The following
* settings are supported:
@@ -112,8 +115,8 @@ class Client extends HTTP\Client {
*
* @param array $settings
*/
- function __construct(array $settings) {
-
+ public function __construct(array $settings)
+ {
if (!isset($settings['baseUri'])) {
throw new \InvalidArgumentException('A baseUri must be provided');
}
@@ -146,8 +149,7 @@ class Client extends HTTP\Client {
}
$this->addCurlSetting(CURLOPT_HTTPAUTH, $curlType);
- $this->addCurlSetting(CURLOPT_USERPWD, $userName . ':' . $password);
-
+ $this->addCurlSetting(CURLOPT_USERPWD, $userName.':'.$password);
}
if (isset($settings['encoding'])) {
@@ -166,16 +168,15 @@ class Client extends HTTP\Client {
$this->addCurlSetting(CURLOPT_ENCODING, implode(',', $encodings));
}
- $this->addCurlSetting(CURLOPT_USERAGENT, 'sabre-dav/' . Version::VERSION . ' (http://sabre.io/)');
+ $this->addCurlSetting(CURLOPT_USERAGENT, 'sabre-dav/'.Version::VERSION.' (http://sabre.io/)');
$this->xml = new Xml\Service();
// BC
- $this->propertyMap = & $this->xml->elementMap;
-
+ $this->propertyMap = &$this->xml->elementMap;
}
/**
- * Does a PROPFIND request
+ * Does a PROPFIND request.
*
* The list of requested properties must be specified as an array, in clark
* notation.
@@ -191,28 +192,28 @@ class Client extends HTTP\Client {
* made to the server to also return all child resources.
*
* @param string $url
- * @param array $properties
- * @param int $depth
+ * @param array $properties
+ * @param int $depth
+ *
* @return array
*/
- function propFind($url, array $properties, $depth = 0) {
-
+ public function propFind($url, array $properties, $depth = 0)
+ {
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
$root = $dom->createElementNS('DAV:', 'd:propfind');
$prop = $dom->createElement('d:prop');
foreach ($properties as $property) {
-
list(
$namespace,
$elementName
) = \Sabre\Xml\Service::parseClarkNotation($property);
- if ($namespace === 'DAV:') {
- $element = $dom->createElement('d:' . $elementName);
+ if ('DAV:' === $namespace) {
+ $element = $dom->createElement('d:'.$elementName);
} else {
- $element = $dom->createElementNS($namespace, 'x:' . $elementName);
+ $element = $dom->createElementNS($namespace, 'x:'.$elementName);
}
$prop->appendChild($element);
@@ -224,49 +225,48 @@ class Client extends HTTP\Client {
$url = $this->getAbsoluteUrl($url);
$request = new HTTP\Request('PROPFIND', $url, [
- 'Depth' => $depth,
- 'Content-Type' => 'application/xml'
+ 'Depth' => $depth,
+ 'Content-Type' => 'application/xml',
], $body);
$response = $this->send($request);
- if ((int)$response->getStatus() >= 400) {
+ if ((int) $response->getStatus() >= 400) {
throw new HTTP\ClientHttpException($response);
}
$result = $this->parseMultiStatus($response->getBodyAsString());
// If depth was 0, we only return the top item
- if ($depth === 0) {
+ if (0 === $depth) {
reset($result);
$result = current($result);
+
return isset($result[200]) ? $result[200] : [];
}
$newResult = [];
foreach ($result as $href => $statusList) {
-
$newResult[$href] = isset($statusList[200]) ? $statusList[200] : [];
-
}
return $newResult;
-
}
/**
- * Updates a list of properties on the server
+ * Updates a list of properties on the server.
*
* The list of properties must have clark-notation properties for the keys,
* and the actual (string) value for the value. If the value is null, an
* attempt is made to delete the property.
*
* @param string $url
- * @param array $properties
+ * @param array $properties
+ *
* @return bool
*/
- function propPatch($url, array $properties) {
-
+ public function propPatch($url, array $properties)
+ {
$propPatch = new Xml\Request\PropPatch();
$propPatch->properties = $properties;
$xml = $this->xml->write(
@@ -284,7 +284,7 @@ class Client extends HTTP\Client {
throw new HTTP\ClientHttpException($response);
}
- if ($response->getStatus() === 207) {
+ if (207 === $response->getStatus()) {
// If it's a 207, the request could still have failed, but the
// information is hidden in the response body.
$result = $this->parseMultiStatus($response->getBodyAsString());
@@ -292,26 +292,23 @@ class Client extends HTTP\Client {
$errorProperties = [];
foreach ($result as $href => $statusList) {
foreach ($statusList as $status => $properties) {
-
if ($status >= 400) {
foreach ($properties as $propName => $propValue) {
- $errorProperties[] = $propName . ' (' . $status . ')';
+ $errorProperties[] = $propName.' ('.$status.')';
}
}
-
}
}
if ($errorProperties) {
-
- throw new HTTP\ClientException('PROPPATCH failed. The following properties errored: ' . implode(', ', $errorProperties));
+ throw new HTTP\ClientException('PROPPATCH failed. The following properties errored: '.implode(', ', $errorProperties));
}
}
- return true;
+ return true;
}
/**
- * Performs an HTTP options request
+ * Performs an HTTP options request.
*
* This method returns all the features from the 'DAV:' header as an array.
* If there was no DAV header, or no contents this method will return an
@@ -319,8 +316,8 @@ class Client extends HTTP\Client {
*
* @return array
*/
- function options() {
-
+ public function options()
+ {
$request = new HTTP\Request('OPTIONS', $this->getAbsoluteUrl(''));
$response = $this->send($request);
@@ -333,8 +330,8 @@ class Client extends HTTP\Client {
foreach ($features as &$v) {
$v = trim($v);
}
- return $features;
+ return $features;
}
/**
@@ -359,24 +356,26 @@ class Client extends HTTP\Client {
* Note that it is no longer recommended to use this method, use the send()
* method instead.
*
- * @param string $method
- * @param string $url
+ * @param string $method
+ * @param string $url
* @param string|resource|null $body
- * @param array $headers
- * @throws ClientException, in case a curl error occurred.
+ * @param array $headers
+ *
+ * @throws clientException, in case a curl error occurred
+ *
* @return array
*/
- function request($method, $url = '', $body = null, array $headers = []) {
-
+ public function request($method, $url = '', $body = null, array $headers = [])
+ {
$url = $this->getAbsoluteUrl($url);
$response = $this->send(new HTTP\Request($method, $url, $headers, $body));
- return [
- 'body' => $response->getBodyAsString(),
- 'statusCode' => (int)$response->getStatus(),
- 'headers' => array_change_key_case($response->getHeaders()),
- ];
+ return [
+ 'body' => $response->getBodyAsString(),
+ 'statusCode' => (int) $response->getStatus(),
+ 'headers' => array_change_key_case($response->getHeaders()),
+ ];
}
/**
@@ -384,19 +383,19 @@ class Client extends HTTP\Client {
* urls are expanded based on the base url as given by the server.
*
* @param string $url
+ *
* @return string
*/
- function getAbsoluteUrl($url) {
-
+ public function getAbsoluteUrl($url)
+ {
return Uri\resolve(
$this->baseUri,
$url
);
-
}
/**
- * Parses a WebDAV multistatus response body
+ * Parses a WebDAV multistatus response body.
*
* This method returns an array with the following structure
*
@@ -418,22 +417,19 @@ class Client extends HTTP\Client {
*
*
* @param string $body xml body
+ *
* @return array
*/
- function parseMultiStatus($body) {
-
+ public function parseMultiStatus($body)
+ {
$multistatus = $this->xml->expect('{DAV:}multistatus', $body);
$result = [];
foreach ($multistatus->getResponses() as $response) {
-
$result[$response->getHref()] = $response->getResponseProperties();
-
}
return $result;
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Collection.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Collection.php
index 35c90b5afae..2728bb27ed9 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Collection.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Collection.php
@@ -1,9 +1,11 @@
getChildren() as $child) {
-
- if ($child->getName() === $name) return $child;
-
+ if ($child->getName() === $name) {
+ return $child;
+ }
}
- throw new Exception\NotFound('File not found: ' . $name);
-
+ throw new Exception\NotFound('File not found: '.$name);
}
/**
@@ -45,25 +48,22 @@ abstract class Collection extends Node implements ICollection {
* It is generally a good idea to try and override this. Usually it can be optimized.
*
* @param string $name
+ *
* @return bool
*/
- function childExists($name) {
-
+ public function childExists($name)
+ {
try {
-
$this->getChild($name);
+
return true;
-
} catch (Exception\NotFound $e) {
-
return false;
-
}
-
}
/**
- * Creates a new file in the directory
+ * Creates a new file in the directory.
*
* Data will either be supplied as a stream resource, or in certain cases
* as a string. Keep in mind that you may have to support either.
@@ -82,28 +82,25 @@ abstract class Collection extends Node implements ICollection {
* return the same contents of what was submitted here, you are strongly
* recommended to omit the ETag.
*
- * @param string $name Name of the file
+ * @param string $name Name of the file
* @param resource|string $data Initial payload
- * @return null|string
+ *
+ * @return string|null
*/
- function createFile($name, $data = null) {
-
- throw new Exception\Forbidden('Permission denied to create file (filename ' . $name . ')');
-
+ public function createFile($name, $data = null)
+ {
+ throw new Exception\Forbidden('Permission denied to create file (filename '.$name.')');
}
/**
- * Creates a new subdirectory
+ * Creates a new subdirectory.
*
* @param string $name
+ *
* @throws Exception\Forbidden
- * @return void
*/
- function createDirectory($name) {
-
+ public function createDirectory($name)
+ {
throw new Exception\Forbidden('Permission denied to create directory');
-
}
-
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/CorePlugin.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/CorePlugin.php
index 676cdd04a29..ef1dfceb65b 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/CorePlugin.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/CorePlugin.php
@@ -1,5 +1,7 @@
server = $server;
- $server->on('method:GET', [$this, 'httpGet']);
- $server->on('method:OPTIONS', [$this, 'httpOptions']);
- $server->on('method:HEAD', [$this, 'httpHead']);
- $server->on('method:DELETE', [$this, 'httpDelete']);
- $server->on('method:PROPFIND', [$this, 'httpPropFind']);
+ $server->on('method:GET', [$this, 'httpGet']);
+ $server->on('method:OPTIONS', [$this, 'httpOptions']);
+ $server->on('method:HEAD', [$this, 'httpHead']);
+ $server->on('method:DELETE', [$this, 'httpDelete']);
+ $server->on('method:PROPFIND', [$this, 'httpPropFind']);
$server->on('method:PROPPATCH', [$this, 'httpPropPatch']);
- $server->on('method:PUT', [$this, 'httpPut']);
- $server->on('method:MKCOL', [$this, 'httpMkcol']);
- $server->on('method:MOVE', [$this, 'httpMove']);
- $server->on('method:COPY', [$this, 'httpCopy']);
- $server->on('method:REPORT', [$this, 'httpReport']);
+ $server->on('method:PUT', [$this, 'httpPut']);
+ $server->on('method:MKCOL', [$this, 'httpMkcol']);
+ $server->on('method:MOVE', [$this, 'httpMove']);
+ $server->on('method:COPY', [$this, 'httpCopy']);
+ $server->on('method:REPORT', [$this, 'httpReport']);
- $server->on('propPatch', [$this, 'propPatchProtectedPropertyCheck'], 90);
- $server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200);
- $server->on('propFind', [$this, 'propFind']);
- $server->on('propFind', [$this, 'propFindNode'], 120);
- $server->on('propFind', [$this, 'propFindLate'], 200);
-
- $server->on('exception', [$this, 'exception']);
+ $server->on('propPatch', [$this, 'propPatchProtectedPropertyCheck'], 90);
+ $server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200);
+ $server->on('propFind', [$this, 'propFind']);
+ $server->on('propFind', [$this, 'propFindNode'], 120);
+ $server->on('propFind', [$this, 'propFindLate'], 200);
+ $server->on('exception', [$this, 'exception']);
}
/**
@@ -62,34 +62,40 @@ class CorePlugin extends ServerPlugin {
*
* @return string
*/
- function getPluginName() {
-
+ public function getPluginName()
+ {
return 'core';
-
}
/**
* This is the default implementation for the GET method.
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpGet(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpGet(RequestInterface $request, ResponseInterface $response)
+ {
$path = $request->getPath();
$node = $this->server->tree->getNodeForPath($path);
- if (!$node instanceof IFile) return;
+ if (!$node instanceof IFile) {
+ return;
+ }
- $body = $node->get();
+ if ('HEAD' === $request->getHeader('X-Sabre-Original-Method')) {
+ $body = '';
+ } else {
+ $body = $node->get();
- // Converting string into stream, if needed.
- if (is_string($body)) {
- $stream = fopen('php://temp', 'r+');
- fwrite($stream, $body);
- rewind($stream);
- $body = $stream;
+ // Converting string into stream, if needed.
+ if (is_string($body)) {
+ $stream = fopen('php://temp', 'r+');
+ fwrite($stream, $body);
+ rewind($stream);
+ $body = $stream;
+ }
}
/*
@@ -105,14 +111,11 @@ class CorePlugin extends ServerPlugin {
$httpHeaders['Content-Type'] = 'application/octet-stream';
}
-
if (isset($httpHeaders['Content-Length'])) {
-
$nodeSize = $httpHeaders['Content-Length'];
// Need to unset Content-Length, because we'll handle that during figuring out the range
unset($httpHeaders['Content-Length']);
-
} else {
$nodeSize = null;
}
@@ -126,7 +129,6 @@ class CorePlugin extends ServerPlugin {
// If ifRange is set, and range is specified, we first need to check
// the precondition.
if ($nodeSize && $range && $ifRange) {
-
// if IfRange is parsable as a date we'll treat it as a DateTime
// otherwise, we must treat it as an etag.
try {
@@ -134,81 +136,87 @@ class CorePlugin extends ServerPlugin {
// It's a date. We must check if the entity is modified since
// the specified date.
- if (!isset($httpHeaders['Last-Modified'])) $ignoreRangeHeader = true;
- else {
+ if (!isset($httpHeaders['Last-Modified'])) {
+ $ignoreRangeHeader = true;
+ } else {
$modified = new \DateTime($httpHeaders['Last-Modified']);
- if ($modified > $ifRangeDate) $ignoreRangeHeader = true;
+ if ($modified > $ifRangeDate) {
+ $ignoreRangeHeader = true;
+ }
}
-
} catch (\Exception $e) {
-
// It's an entity. We can do a simple comparison.
- if (!isset($httpHeaders['ETag'])) $ignoreRangeHeader = true;
- elseif ($httpHeaders['ETag'] !== $ifRange) $ignoreRangeHeader = true;
+ if (!isset($httpHeaders['ETag'])) {
+ $ignoreRangeHeader = true;
+ } elseif ($httpHeaders['ETag'] !== $ifRange) {
+ $ignoreRangeHeader = true;
+ }
}
}
// We're only going to support HTTP ranges if the backend provided a filesize
if (!$ignoreRangeHeader && $nodeSize && $range) {
-
// Determining the exact byte offsets
if (!is_null($range[0])) {
-
$start = $range[0];
$end = $range[1] ? $range[1] : $nodeSize - 1;
- if ($start >= $nodeSize)
- throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $range[0] . ') exceeded the size of the entity (' . $nodeSize . ')');
-
- if ($end < $start) throw new Exception\RequestedRangeNotSatisfiable('The end offset (' . $range[1] . ') is lower than the start offset (' . $range[0] . ')');
- if ($end >= $nodeSize) $end = $nodeSize - 1;
-
+ if ($start >= $nodeSize) {
+ throw new Exception\RequestedRangeNotSatisfiable('The start offset ('.$range[0].') exceeded the size of the entity ('.$nodeSize.')');
+ }
+ if ($end < $start) {
+ throw new Exception\RequestedRangeNotSatisfiable('The end offset ('.$range[1].') is lower than the start offset ('.$range[0].')');
+ }
+ if ($end >= $nodeSize) {
+ $end = $nodeSize - 1;
+ }
} else {
-
$start = $nodeSize - $range[1];
$end = $nodeSize - 1;
- if ($start < 0) $start = 0;
-
+ if ($start < 0) {
+ $start = 0;
+ }
}
// Streams may advertise themselves as seekable, but still not
// actually allow fseek. We'll manually go forward in the stream
// if fseek failed.
- if (!stream_get_meta_data($body)['seekable'] || fseek($body, $start, SEEK_SET) === -1) {
+ if (!stream_get_meta_data($body)['seekable'] || -1 === fseek($body, $start, SEEK_SET)) {
$consumeBlock = 8192;
- for ($consumed = 0; $start - $consumed > 0;){
- if (feof($body)) throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $start . ') exceeded the size of the entity (' . $consumed . ')');
+ for ($consumed = 0; $start - $consumed > 0;) {
+ if (feof($body)) {
+ throw new Exception\RequestedRangeNotSatisfiable('The start offset ('.$start.') exceeded the size of the entity ('.$consumed.')');
+ }
$consumed += strlen(fread($body, min($start - $consumed, $consumeBlock)));
}
}
$response->setHeader('Content-Length', $end - $start + 1);
- $response->setHeader('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $nodeSize);
+ $response->setHeader('Content-Range', 'bytes '.$start.'-'.$end.'/'.$nodeSize);
$response->setStatus(206);
$response->setBody($body);
-
} else {
-
- if ($nodeSize) $response->setHeader('Content-Length', $nodeSize);
+ if ($nodeSize) {
+ $response->setHeader('Content-Length', $nodeSize);
+ }
$response->setStatus(200);
$response->setBody($body);
-
}
// Sending back false will interrupt the event chain and tell the server
// we've handled this method.
return false;
-
}
/**
- * HTTP OPTIONS
+ * HTTP OPTIONS.
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpOptions(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpOptions(RequestInterface $request, ResponseInterface $response)
+ {
$methods = $this->server->getAllowedMethods($request->getPath());
$response->setHeader('Allow', strtoupper(implode(', ', $methods)));
@@ -227,31 +235,31 @@ class CorePlugin extends ServerPlugin {
// Sending back false will interrupt the event chain and tell the server
// we've handled this method.
return false;
-
}
/**
- * HTTP HEAD
+ * HTTP HEAD.
*
* This method is normally used to take a peak at a url, and only get the
* HTTP response headers, without the body. This is used by clients to
* determine if a remote file was changed, so they can use a local cached
* version, instead of downloading it again
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpHead(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpHead(RequestInterface $request, ResponseInterface $response)
+ {
// This is implemented by changing the HEAD request to a GET request,
- // and dropping the response body.
+ // and telling the request handler that is doesn't need to create the body.
$subRequest = clone $request;
$subRequest->setMethod('GET');
+ $subRequest->setHeader('X-Sabre-Original-Method', 'HEAD');
try {
$this->server->invokeMethod($subRequest, $response, false);
- $response->setBody('');
} catch (Exception\NotImplemented $e) {
// Some clients may do HEAD requests on collections, however, GET
// requests and HEAD requests _may_ not be defined on a collection,
@@ -267,23 +275,23 @@ class CorePlugin extends ServerPlugin {
// Sending back false will interrupt the event chain and tell the server
// we've handled this method.
return false;
-
}
/**
- * HTTP Delete
+ * HTTP Delete.
*
* The HTTP delete method, deletes a given uri
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
- * @return void
*/
- function httpDelete(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpDelete(RequestInterface $request, ResponseInterface $response)
+ {
$path = $request->getPath();
- if (!$this->server->emit('beforeUnbind', [$path])) return false;
+ if (!$this->server->emit('beforeUnbind', [$path])) {
+ return false;
+ }
$this->server->tree->delete($path);
$this->server->emit('afterUnbind', [$path]);
@@ -293,11 +301,10 @@ class CorePlugin extends ServerPlugin {
// Sending back false will interrupt the event chain and tell the server
// we've handled this method.
return false;
-
}
/**
- * WebDAV PROPFIND
+ * WebDAV PROPFIND.
*
* This WebDAV method requests information about an uri resource, or a list of resources
* If a client wants to receive the properties for a single resource it will add an HTTP Depth: header with a 0 value
@@ -308,12 +315,11 @@ class CorePlugin extends ServerPlugin {
*
* It has to return a HTTP 207 Multi-status status code
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
- * @return void
*/
- function httpPropFind(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpPropFind(RequestInterface $request, ResponseInterface $response)
+ {
$path = $request->getPath();
$requestBody = $request->getBodyAsString();
@@ -321,7 +327,7 @@ class CorePlugin extends ServerPlugin {
try {
$propFindXml = $this->server->xml->expect('{DAV:}propfind', $requestBody);
} catch (ParseException $e) {
- throw new BadRequest($e->getMessage(), null, $e);
+ throw new BadRequest($e->getMessage(), 0, $e);
}
} else {
$propFindXml = new Xml\Request\PropFind();
@@ -331,7 +337,9 @@ class CorePlugin extends ServerPlugin {
$depth = $this->server->getHTTPDepth(1);
// The only two options for the depth of a propfind is 0 or 1 - as long as depth infinity is not enabled
- if (!$this->server->enablePropfindDepthInfinity && $depth != 0) $depth = 1;
+ if (!$this->server->enablePropfindDepthInfinity && 0 != $depth) {
+ $depth = 1;
+ }
$newProperties = $this->server->getPropertiesIteratorForPath($path, $propFindXml->properties, $depth);
@@ -350,7 +358,7 @@ class CorePlugin extends ServerPlugin {
$response->setHeader('DAV', implode(', ', $features));
$prefer = $this->server->getHTTPPrefer();
- $minimal = $prefer['return'] === 'minimal';
+ $minimal = 'minimal' === $prefer['return'];
$data = $this->server->generateMultiStatus($newProperties, $minimal);
$response->setBody($data);
@@ -358,27 +366,27 @@ class CorePlugin extends ServerPlugin {
// Sending back false will interrupt the event chain and tell the server
// we've handled this method.
return false;
-
}
/**
- * WebDAV PROPPATCH
+ * WebDAV PROPPATCH.
*
* This method is called to update properties on a Node. The request is an XML body with all the mutations.
* In this XML body it is specified which properties should be set/updated and/or deleted
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpPropPatch(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpPropPatch(RequestInterface $request, ResponseInterface $response)
+ {
$path = $request->getPath();
try {
$propPatch = $this->server->xml->expect('{DAV:}propertyupdate', $request->getBody());
} catch (ParseException $e) {
- throw new BadRequest($e->getMessage(), null, $e);
+ throw new BadRequest($e->getMessage(), 0, $e);
}
$newProperties = $propPatch->properties;
@@ -387,31 +395,27 @@ class CorePlugin extends ServerPlugin {
$prefer = $this->server->getHTTPPrefer();
$response->setHeader('Vary', 'Brief,Prefer');
- if ($prefer['return'] === 'minimal') {
-
+ if ('minimal' === $prefer['return']) {
// If return-minimal is specified, we only have to check if the
// request was successful, and don't need to return the
// multi-status.
$ok = true;
foreach ($result as $prop => $code) {
- if ((int)$code > 299) {
+ if ((int) $code > 299) {
$ok = false;
}
}
if ($ok) {
-
$response->setStatus(204);
+
return false;
-
}
-
}
$response->setStatus(207);
$response->setHeader('Content-Type', 'application/xml; charset=utf-8');
-
// Reorganizing the result for generateMultiStatus
$multiStatus = [];
foreach ($result as $propertyName => $code) {
@@ -430,22 +434,22 @@ class CorePlugin extends ServerPlugin {
// Sending back false will interrupt the event chain and tell the server
// we've handled this method.
return false;
-
}
/**
- * HTTP PUT method
+ * HTTP PUT method.
*
* This HTTP method updates a file, or creates a new one.
*
* If a new resource was created, a 201 Created status code should be returned. If an existing resource is updated, it's a 204 No Content
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpPut(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpPut(RequestInterface $request, ResponseInterface $response)
+ {
$body = $request->getBodyAsStream();
$path = $request->getPath();
@@ -463,7 +467,6 @@ class CorePlugin extends ServerPlugin {
// Intercepting the Finder problem
if (($expected = $request->getHeader('X-Expected-Entity-Length')) && $expected > 0) {
-
/*
Many webservers will not cooperate well with Finder PUT requests,
because it uses 'Chunked' transfer encoding for the request body.
@@ -487,7 +490,7 @@ class CorePlugin extends ServerPlugin {
// Only reading first byte
$firstByte = fread($body, 1);
- if (strlen($firstByte) !== 1) {
+ if (1 !== strlen($firstByte)) {
throw new Exception\Forbidden('This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.');
}
@@ -500,26 +503,25 @@ class CorePlugin extends ServerPlugin {
rewind($newBody);
$body = $newBody;
-
}
if ($this->server->tree->nodeExists($path)) {
-
$node = $this->server->tree->getNodeForPath($path);
// If the node is a collection, we'll deny it
- if (!($node instanceof IFile)) throw new Exception\Conflict('PUT is not allowed on non-files.');
-
+ if (!($node instanceof IFile)) {
+ throw new Exception\Conflict('PUT is not allowed on non-files.');
+ }
if (!$this->server->updateFile($path, $body, $etag)) {
return false;
}
$response->setHeader('Content-Length', '0');
- if ($etag) $response->setHeader('ETag', $etag);
+ if ($etag) {
+ $response->setHeader('ETag', $etag);
+ }
$response->setStatus(204);
-
} else {
-
$etag = null;
// If we got here, the resource didn't exist yet.
if (!$this->server->createFile($path, $body, $etag)) {
@@ -528,61 +530,55 @@ class CorePlugin extends ServerPlugin {
}
$response->setHeader('Content-Length', '0');
- if ($etag) $response->setHeader('ETag', $etag);
+ if ($etag) {
+ $response->setHeader('ETag', $etag);
+ }
$response->setStatus(201);
-
}
// Sending back false will interrupt the event chain and tell the server
// we've handled this method.
return false;
-
}
-
/**
- * WebDAV MKCOL
+ * WebDAV MKCOL.
*
* The MKCOL method is used to create a new collection (directory) on the server
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpMkcol(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpMkcol(RequestInterface $request, ResponseInterface $response)
+ {
$requestBody = $request->getBodyAsString();
$path = $request->getPath();
if ($requestBody) {
-
$contentType = $request->getHeader('Content-Type');
- if (strpos($contentType, 'application/xml') !== 0 && strpos($contentType, 'text/xml') !== 0) {
-
+ if (null === $contentType || (0 !== strpos($contentType, 'application/xml') && 0 !== strpos($contentType, 'text/xml'))) {
// We must throw 415 for unsupported mkcol bodies
throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must have an xml Content-Type');
-
}
try {
$mkcol = $this->server->xml->expect('{DAV:}mkcol', $requestBody);
} catch (\Sabre\Xml\ParseException $e) {
- throw new Exception\BadRequest($e->getMessage(), null, $e);
+ throw new Exception\BadRequest($e->getMessage(), 0, $e);
}
$properties = $mkcol->getProperties();
- if (!isset($properties['{DAV:}resourcetype']))
+ if (!isset($properties['{DAV:}resourcetype'])) {
throw new Exception\BadRequest('The mkcol request must include a {DAV:}resourcetype property');
-
+ }
$resourceType = $properties['{DAV:}resourcetype']->getValue();
unset($properties['{DAV:}resourcetype']);
-
} else {
-
$properties = [];
$resourceType = ['{DAV:}collection'];
-
}
$mkcol = new MkCol($resourceType, $properties);
@@ -596,7 +592,6 @@ class CorePlugin extends ServerPlugin {
$response->setBody(
$this->server->generateMultiStatus([$result])
);
-
} else {
$response->setHeader('Content-Length', '0');
$response->setStatus(201);
@@ -605,38 +600,42 @@ class CorePlugin extends ServerPlugin {
// Sending back false will interrupt the event chain and tell the server
// we've handled this method.
return false;
-
}
/**
- * WebDAV HTTP MOVE method
+ * WebDAV HTTP MOVE method.
*
* This method moves one uri to a different uri. A lot of the actual request processing is done in getCopyMoveInfo
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpMove(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpMove(RequestInterface $request, ResponseInterface $response)
+ {
$path = $request->getPath();
$moveInfo = $this->server->getCopyAndMoveInfo($request);
if ($moveInfo['destinationExists']) {
-
- if (!$this->server->emit('beforeUnbind', [$moveInfo['destination']])) return false;
-
+ if (!$this->server->emit('beforeUnbind', [$moveInfo['destination']])) {
+ return false;
+ }
+ }
+ if (!$this->server->emit('beforeUnbind', [$path])) {
+ return false;
+ }
+ if (!$this->server->emit('beforeBind', [$moveInfo['destination']])) {
+ return false;
+ }
+ if (!$this->server->emit('beforeMove', [$path, $moveInfo['destination']])) {
+ return false;
}
- if (!$this->server->emit('beforeUnbind', [$path])) return false;
- if (!$this->server->emit('beforeBind', [$moveInfo['destination']])) return false;
- if (!$this->server->emit('beforeMove', [$path, $moveInfo['destination']])) return false;
if ($moveInfo['destinationExists']) {
-
$this->server->tree->delete($moveInfo['destination']);
$this->server->emit('afterUnbind', [$moveInfo['destination']]);
-
}
$this->server->tree->move($path, $moveInfo['destination']);
@@ -656,28 +655,32 @@ class CorePlugin extends ServerPlugin {
// Sending back false will interrupt the event chain and tell the server
// we've handled this method.
return false;
-
}
/**
- * WebDAV HTTP COPY method
+ * WebDAV HTTP COPY method.
*
* This method copies one uri to a different uri, and works much like the MOVE request
* A lot of the actual request processing is done in getCopyMoveInfo
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpCopy(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpCopy(RequestInterface $request, ResponseInterface $response)
+ {
$path = $request->getPath();
$copyInfo = $this->server->getCopyAndMoveInfo($request);
- if (!$this->server->emit('beforeBind', [$copyInfo['destination']])) return false;
+ if (!$this->server->emit('beforeBind', [$copyInfo['destination']])) {
+ return false;
+ }
if ($copyInfo['destinationExists']) {
- if (!$this->server->emit('beforeUnbind', [$copyInfo['destination']])) return false;
+ if (!$this->server->emit('beforeUnbind', [$copyInfo['destination']])) {
+ return false;
+ }
$this->server->tree->delete($copyInfo['destination']);
}
@@ -691,22 +694,21 @@ class CorePlugin extends ServerPlugin {
// Sending back false will interrupt the event chain and tell the server
// we've handled this method.
return false;
-
-
}
/**
- * HTTP REPORT method implementation
+ * HTTP REPORT method implementation.
*
* Although the REPORT method is not part of the standard WebDAV spec (it's from rfc3253)
* It's used in a lot of extensions, so it made sense to implement it into the core.
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpReport(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpReport(RequestInterface $request, ResponseInterface $response)
+ {
$path = $request->getPath();
$result = $this->server->xml->parse(
@@ -716,16 +718,13 @@ class CorePlugin extends ServerPlugin {
);
if ($this->server->emit('report', [$rootElementName, $result, $path])) {
-
// If emit returned true, it means the report was not supported
throw new Exception\ReportNotSupported();
-
}
// Sending back false will interrupt the event chain and tell the server
// we've handled this method.
return false;
-
}
/**
@@ -734,12 +733,11 @@ class CorePlugin extends ServerPlugin {
* Here we check if a user attempted to update a protected property and
* ensure that the process fails if this is the case.
*
- * @param string $path
+ * @param string $path
* @param PropPatch $propPatch
- * @return void
*/
- function propPatchProtectedPropertyCheck($path, PropPatch $propPatch) {
-
+ public function propPatchProtectedPropertyCheck($path, PropPatch $propPatch)
+ {
// Comparing the mutation list to the list of protected properties.
$mutations = $propPatch->getMutations();
@@ -751,7 +749,6 @@ class CorePlugin extends ServerPlugin {
if ($protected) {
$propPatch->setResultCode($protected, 403);
}
-
}
/**
@@ -760,19 +757,17 @@ class CorePlugin extends ServerPlugin {
* Here we check if a node implements IProperties and let the node handle
* updating of (some) properties.
*
- * @param string $path
+ * @param string $path
* @param PropPatch $propPatch
- * @return void
*/
- function propPatchNodeUpdate($path, PropPatch $propPatch) {
-
+ public function propPatchNodeUpdate($path, PropPatch $propPatch)
+ {
// This should trigger a 404 if the node doesn't exist.
$node = $this->server->tree->getNodeForPath($path);
if ($node instanceof IProperties) {
$node->propPatch($propPatch);
}
-
}
/**
@@ -781,12 +776,11 @@ class CorePlugin extends ServerPlugin {
* Here we add all the default properties.
*
* @param PropFind $propFind
- * @param INode $node
- * @return void
+ * @param INode $node
*/
- function propFind(PropFind $propFind, INode $node) {
-
- $propFind->handle('{DAV:}getlastmodified', function() use ($node) {
+ public function propFind(PropFind $propFind, INode $node)
+ {
+ $propFind->handle('{DAV:}getlastmodified', function () use ($node) {
$lm = $node->getLastModified();
if ($lm) {
return new Xml\Property\GetLastModified($lm);
@@ -801,34 +795,36 @@ class CorePlugin extends ServerPlugin {
if ($node instanceof IQuota) {
$quotaInfo = null;
- $propFind->handle('{DAV:}quota-used-bytes', function() use (&$quotaInfo, $node) {
+ $propFind->handle('{DAV:}quota-used-bytes', function () use (&$quotaInfo, $node) {
$quotaInfo = $node->getQuotaInfo();
+
return $quotaInfo[0];
});
- $propFind->handle('{DAV:}quota-available-bytes', function() use (&$quotaInfo, $node) {
+ $propFind->handle('{DAV:}quota-available-bytes', function () use (&$quotaInfo, $node) {
if (!$quotaInfo) {
$quotaInfo = $node->getQuotaInfo();
}
+
return $quotaInfo[1];
});
}
- $propFind->handle('{DAV:}supported-report-set', function() use ($propFind) {
+ $propFind->handle('{DAV:}supported-report-set', function () use ($propFind) {
$reports = [];
foreach ($this->server->getPlugins() as $plugin) {
$reports = array_merge($reports, $plugin->getSupportedReportSet($propFind->getPath()));
}
+
return new Xml\Property\SupportedReportSet($reports);
});
- $propFind->handle('{DAV:}resourcetype', function() use ($node) {
+ $propFind->handle('{DAV:}resourcetype', function () use ($node) {
return new Xml\Property\ResourceType($this->server->getResourceTypeForNode($node));
});
- $propFind->handle('{DAV:}supported-method-set', function() use ($propFind) {
+ $propFind->handle('{DAV:}supported-method-set', function () use ($propFind) {
return new Xml\Property\SupportedMethodSet(
$this->server->getAllowedMethods($propFind->getPath())
);
});
-
}
/**
@@ -838,20 +834,16 @@ class CorePlugin extends ServerPlugin {
* populate the result.
*
* @param PropFind $propFind
- * @param INode $node
- * @return void
+ * @param INode $node
*/
- function propFindNode(PropFind $propFind, INode $node) {
-
+ public function propFindNode(PropFind $propFind, INode $node)
+ {
if ($node instanceof IProperties && $propertyNames = $propFind->get404Properties()) {
-
$nodeProperties = $node->getProperties($propertyNames);
foreach ($nodeProperties as $propertyName => $propertyValue) {
$propFind->set($propertyName, $propertyValue, 200);
}
-
}
-
}
/**
@@ -861,17 +853,17 @@ class CorePlugin extends ServerPlugin {
* want other systems to first have a chance to handle the properties.
*
* @param PropFind $propFind
- * @param INode $node
- * @return void
+ * @param INode $node
*/
- function propFindLate(PropFind $propFind, INode $node) {
-
- $propFind->handle('{http://calendarserver.org/ns/}getctag', function() use ($propFind) {
-
+ public function propFindLate(PropFind $propFind, INode $node)
+ {
+ $propFind->handle('{http://calendarserver.org/ns/}getctag', function () use ($propFind) {
// If we already have a sync-token from the current propFind
// request, we can re-use that.
$val = $propFind->get('{http://sabredav.org/ns}sync-token');
- if ($val) return $val;
+ if ($val) {
+ return $val;
+ }
$val = $propFind->get('{DAV:}sync-token');
if ($val && is_scalar($val)) {
@@ -899,9 +891,7 @@ class CorePlugin extends ServerPlugin {
return substr($val->getHref(), strlen(Sync\Plugin::SYNCTOKEN_PREFIX));
}
}
-
});
-
}
/**
@@ -909,8 +899,8 @@ class CorePlugin extends ServerPlugin {
*
* @param Exception $e
*/
- function exception($e) {
-
+ public function exception($e)
+ {
$logLevel = \Psr\Log\LogLevel::CRITICAL;
if ($e instanceof \Sabre\DAV\Exception) {
// If it's a standard sabre/dav exception, it means we have a http
@@ -947,13 +937,12 @@ class CorePlugin extends ServerPlugin {
*
* @return array
*/
- function getPluginInfo() {
-
+ public function getPluginInfo()
+ {
return [
- 'name' => $this->getPluginName(),
+ 'name' => $this->getPluginName(),
'description' => 'The Core plugin provides a lot of the basic functionality required by WebDAV, such as a default implementation for all HTTP and WebDAV methods.',
- 'link' => null,
+ 'link' => null,
];
-
}
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception.php
index 14f5bab2a53..e1d9906234b 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception.php
@@ -1,5 +1,7 @@
lock) {
$error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:no-conflicting-lock');
$errorNode->appendChild($error);
$error->appendChild($errorNode->ownerDocument->createElementNS('DAV:', 'd:href', $this->lock->uri));
}
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/Forbidden.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/Forbidden.php
index 77df7ca9ecc..2f882c39650 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/Forbidden.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/Forbidden.php
@@ -1,11 +1,13 @@
ownerDocument->createElementNS('DAV:', 'd:valid-resourcetype');
$errorNode->appendChild($error);
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php
index 51a253b296b..6c5f1c4358e 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/InvalidSyncToken.php
@@ -1,11 +1,13 @@
ownerDocument->createElementNS('DAV:', 'd:valid-sync-token');
$errorNode->appendChild($error);
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/LengthRequired.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/LengthRequired.php
index 98971855834..9d26fcb105a 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/LengthRequired.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/LengthRequired.php
@@ -1,11 +1,13 @@
message = 'The locktoken supplied does not match any locks on this entity';
-
+ public function __construct()
+ {
+ parent::__construct('The locktoken supplied does not match any locks on this entity');
}
/**
- * This method allows the exception to include additional information into the WebDAV error response
+ * This method allows the exception to include additional information into the WebDAV error response.
*
- * @param DAV\Server $server
+ * @param DAV\Server $server
* @param \DOMElement $errorNode
- * @return void
*/
- function serialize(DAV\Server $server, \DOMElement $errorNode) {
-
+ public function serialize(DAV\Server $server, \DOMElement $errorNode)
+ {
$error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:lock-token-matches-request-uri');
$errorNode->appendChild($error);
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/Locked.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/Locked.php
index 8176db46e87..632bafc6081 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/Locked.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/Locked.php
@@ -1,11 +1,13 @@
lock = $lock;
-
}
/**
- * Returns the HTTP statuscode for this exception
+ * Returns the HTTP statuscode for this exception.
*
* @return int
*/
- function getHTTPCode() {
-
+ public function getHTTPCode()
+ {
return 423;
-
}
/**
- * This method allows the exception to include additional information into the WebDAV error response
+ * This method allows the exception to include additional information into the WebDAV error response.
*
- * @param DAV\Server $server
+ * @param DAV\Server $server
* @param \DOMElement $errorNode
- * @return void
*/
- function serialize(DAV\Server $server, \DOMElement $errorNode) {
-
+ public function serialize(DAV\Server $server, \DOMElement $errorNode)
+ {
if ($this->lock) {
$error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:lock-token-submitted');
$errorNode->appendChild($error);
@@ -66,7 +67,5 @@ class Locked extends DAV\Exception {
$href
);
}
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php
index 30c1c255345..a3d9c56f2d4 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/MethodNotAllowed.php
@@ -1,11 +1,13 @@
getAllowedMethods($server->getRequestUri());
return [
'Allow' => strtoupper(implode(', ', $methods)),
];
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/NotAuthenticated.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/NotAuthenticated.php
index e69a60c7549..0a5ba9b5abd 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/NotAuthenticated.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/NotAuthenticated.php
@@ -1,11 +1,13 @@
header = $header;
-
}
/**
- * Returns the HTTP statuscode for this exception
+ * Returns the HTTP statuscode for this exception.
*
* @return int
*/
- function getHTTPCode() {
-
+ public function getHTTPCode()
+ {
return 412;
-
}
/**
- * This method allows the exception to include additional information into the WebDAV error response
+ * This method allows the exception to include additional information into the WebDAV error response.
*
- * @param DAV\Server $server
+ * @param DAV\Server $server
* @param \DOMElement $errorNode
- * @return void
*/
- function serialize(DAV\Server $server, \DOMElement $errorNode) {
-
+ public function serialize(DAV\Server $server, \DOMElement $errorNode)
+ {
if ($this->header) {
$prop = $errorNode->ownerDocument->createElement('s:header');
$prop->nodeValue = $this->header;
$errorNode->appendChild($prop);
}
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/ReportNotSupported.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/ReportNotSupported.php
index a8369562702..cecfec12d9b 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/ReportNotSupported.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/ReportNotSupported.php
@@ -1,11 +1,13 @@
ownerDocument->createElementNS('DAV:', 'd:supported-report');
$errorNode->appendChild($error);
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php
index c8ccfc062a9..6ccb5b8c88b 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/RequestedRangeNotSatisfiable.php
@@ -1,11 +1,13 @@
ownerDocument->createElementNS('DAV:', 'd:number-of-matches-within-limits');
$errorNode->appendChild($error);
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php
index f3d92842da5..bc9da30dae5 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Exception/UnsupportedMediaType.php
@@ -1,11 +1,13 @@
path . '/' . $name;
+ public function createFile($name, $data = null)
+ {
+ $newPath = $this->path.'/'.$name;
file_put_contents($newPath, $data);
clearstatcache(true, $newPath);
-
}
/**
- * Creates a new subdirectory
+ * Creates a new subdirectory.
*
* @param string $name
- * @return void
*/
- function createDirectory($name) {
-
- $newPath = $this->path . '/' . $name;
+ public function createDirectory($name)
+ {
+ $newPath = $this->path.'/'.$name;
mkdir($newPath);
clearstatcache(true, $newPath);
-
}
/**
- * Returns a specific child node, referenced by its name
+ * Returns a specific child node, referenced by its name.
*
* This method must throw DAV\Exception\NotFound if the node does not
* exist.
*
* @param string $name
+ *
* @throws DAV\Exception\NotFound
+ *
* @return DAV\INode
*/
- function getChild($name) {
-
- $path = $this->path . '/' . $name;
-
- if (!file_exists($path)) throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located');
-
- if (is_dir($path)) {
-
- return new self($path);
-
- } else {
-
- return new File($path);
+ public function getChild($name)
+ {
+ $path = $this->path.'/'.$name;
+ if (!file_exists($path)) {
+ throw new DAV\Exception\NotFound('File with name '.$path.' could not be located');
+ }
+ if (is_dir($path)) {
+ return new self($path);
+ } else {
+ return new File($path);
}
-
}
/**
- * Returns an array with all the child nodes
+ * Returns an array with all the child nodes.
*
* @return DAV\INode[]
*/
- function getChildren() {
-
+ public function getChildren()
+ {
$nodes = [];
$iterator = new \FilesystemIterator(
$this->path,
@@ -101,51 +99,49 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota {
| \FilesystemIterator::SKIP_DOTS
);
foreach ($iterator as $entry) {
-
$nodes[] = $this->getChild($entry->getFilename());
-
}
- return $nodes;
+ return $nodes;
}
/**
* Checks if a child exists.
*
* @param string $name
+ *
* @return bool
*/
- function childExists($name) {
+ public function childExists($name)
+ {
+ $path = $this->path.'/'.$name;
- $path = $this->path . '/' . $name;
return file_exists($path);
-
}
/**
- * Deletes all files in this directory, and then itself
- *
- * @return void
+ * Deletes all files in this directory, and then itself.
*/
- function delete() {
-
- foreach ($this->getChildren() as $child) $child->delete();
+ public function delete()
+ {
+ foreach ($this->getChildren() as $child) {
+ $child->delete();
+ }
rmdir($this->path);
-
}
/**
- * Returns available diskspace information
+ * Returns available diskspace information.
*
* @return array
*/
- function getQuotaInfo() {
+ public function getQuotaInfo()
+ {
$absolute = realpath($this->path);
+
return [
disk_total_space($absolute) - disk_free_space($absolute),
- disk_free_space($absolute)
+ disk_free_space($absolute),
];
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/FS/File.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/FS/File.php
index 4fc5af0574b..b78a801389c 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/FS/File.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/FS/File.php
@@ -1,66 +1,61 @@
path, $data);
clearstatcache(true, $this->path);
-
}
/**
- * Returns the data
+ * Returns the data.
*
* @return resource
*/
- function get() {
-
+ public function get()
+ {
return fopen($this->path, 'r');
-
}
/**
- * Delete the current file
- *
- * @return void
+ * Delete the current file.
*/
- function delete() {
-
+ public function delete()
+ {
unlink($this->path);
-
}
/**
- * Returns the size of the node, in bytes
+ * Returns the size of the node, in bytes.
*
* @return int
*/
- function getSize() {
-
+ public function getSize()
+ {
return filesize($this->path);
-
}
/**
- * Returns the ETag for a file
+ * Returns the ETag for a file.
*
* An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
* The ETag is an arbitrary string, but MUST be surrounded by double-quotes.
@@ -69,27 +64,24 @@ class File extends Node implements DAV\IFile {
*
* @return mixed
*/
- function getETag() {
-
- return '"' . sha1(
- fileinode($this->path) .
- filesize($this->path) .
+ public function getETag()
+ {
+ return '"'.sha1(
+ fileinode($this->path).
+ filesize($this->path).
filemtime($this->path)
- ) . '"';
-
+ ).'"';
}
/**
- * Returns the mime-type for a file
+ * Returns the mime-type for a file.
*
* If null is returned, we'll assume application/octet-stream
*
* @return mixed
*/
- function getContentType() {
-
+ public function getContentType()
+ {
return null;
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/FS/Node.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/FS/Node.php
index 424718f966e..32aa74755c3 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/FS/Node.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/FS/Node.php
@@ -1,12 +1,15 @@
path = $path;
-
- }
-
-
+ protected $overrideName;
/**
- * Returns the name of the node
+ * Sets up the node, expects a full path name.
+ *
+ * If $overrideName is set, this node shows up in the tree under a
+ * different name. In this case setName() will be disabled.
+ *
+ * @param string $path
+ * @param string $overrideName
+ */
+ public function __construct($path, $overrideName = null)
+ {
+ $this->path = $path;
+ $this->overrideName = $overrideName;
+ }
+
+ /**
+ * Returns the name of the node.
*
* @return string
*/
- function getName() {
+ public function getName()
+ {
+ if ($this->overrideName) {
+ return $this->overrideName;
+ }
+
+ list(, $name) = Uri\split($this->path);
- list(, $name) = URLUtil::splitPath($this->path);
return $name;
-
}
/**
- * Renames the node
+ * Renames the node.
*
* @param string $name The new name
- * @return void
*/
- function setName($name) {
+ public function setName($name)
+ {
+ if ($this->overrideName) {
+ throw new Forbidden('This node cannot be renamed');
+ }
- list($parentPath, ) = URLUtil::splitPath($this->path);
- list(, $newName) = URLUtil::splitPath($name);
+ list($parentPath) = Uri\split($this->path);
+ list(, $newName) = Uri\split($name);
- $newPath = $parentPath . '/' . $newName;
+ $newPath = $parentPath.'/'.$newName;
rename($this->path, $newPath);
$this->path = $newPath;
-
}
/**
- * Returns the last modification time, as a unix timestamp
+ * Returns the last modification time, as a unix timestamp.
*
* @return int
*/
- function getLastModified() {
-
+ public function getLastModified()
+ {
return filemtime($this->path);
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/FSExt/Directory.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/FSExt/Directory.php
index dd5f992dbce..d6aea009492 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/FSExt/Directory.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/FSExt/Directory.php
@@ -1,21 +1,23 @@
path . '/' . $name;
+ if ('.' == $name || '..' == $name) {
+ throw new DAV\Exception\Forbidden('Permission denied to . and ..');
+ }
+ $newPath = $this->path.'/'.$name;
file_put_contents($newPath, $data);
clearstatcache(true, $newPath);
- return '"' . sha1(
- fileinode($newPath) .
- filesize($newPath) .
+ return '"'.sha1(
+ fileinode($newPath).
+ filesize($newPath).
filemtime($newPath)
- ) . '"';
-
+ ).'"';
}
/**
- * Creates a new subdirectory
+ * Creates a new subdirectory.
*
* @param string $name
- * @return void
*/
- function createDirectory($name) {
-
+ public function createDirectory($name)
+ {
// We're not allowing dots
- if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..');
- $newPath = $this->path . '/' . $name;
+ if ('.' == $name || '..' == $name) {
+ throw new DAV\Exception\Forbidden('Permission denied to . and ..');
+ }
+ $newPath = $this->path.'/'.$name;
mkdir($newPath);
clearstatcache(true, $newPath);
-
}
/**
- * Returns a specific child node, referenced by its name
+ * Returns a specific child node, referenced by its name.
*
* This method must throw Sabre\DAV\Exception\NotFound if the node does not
* exist.
*
* @param string $name
+ *
* @throws DAV\Exception\NotFound
+ *
* @return DAV\INode
*/
- function getChild($name) {
-
- $path = $this->path . '/' . $name;
-
- if (!file_exists($path)) throw new DAV\Exception\NotFound('File could not be located');
- if ($name == '.' || $name == '..') throw new DAV\Exception\Forbidden('Permission denied to . and ..');
-
- if (is_dir($path)) {
-
- return new self($path);
-
- } else {
-
- return new File($path);
+ public function getChild($name)
+ {
+ $path = $this->path.'/'.$name;
+ if (!file_exists($path)) {
+ throw new DAV\Exception\NotFound('File could not be located');
+ }
+ if ('.' == $name || '..' == $name) {
+ throw new DAV\Exception\Forbidden('Permission denied to . and ..');
+ }
+ if (is_dir($path)) {
+ return new self($path);
+ } else {
+ return new File($path);
}
-
}
/**
* Checks if a child exists.
*
* @param string $name
+ *
* @return bool
*/
- function childExists($name) {
-
- if ($name == '.' || $name == '..')
+ public function childExists($name)
+ {
+ if ('.' == $name || '..' == $name) {
throw new DAV\Exception\Forbidden('Permission denied to . and ..');
+ }
+ $path = $this->path.'/'.$name;
- $path = $this->path . '/' . $name;
return file_exists($path);
-
}
/**
- * Returns an array with all the child nodes
+ * Returns an array with all the child nodes.
*
* @return DAV\INode[]
*/
- function getChildren() {
-
+ public function getChildren()
+ {
$nodes = [];
$iterator = new \FilesystemIterator(
$this->path,
@@ -130,44 +135,43 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa
);
foreach ($iterator as $entry) {
-
$nodes[] = $this->getChild($entry->getFilename());
-
}
- return $nodes;
+ return $nodes;
}
/**
- * Deletes all files in this directory, and then itself
+ * Deletes all files in this directory, and then itself.
*
* @return bool
*/
- function delete() {
-
+ public function delete()
+ {
// Deleting all children
- foreach ($this->getChildren() as $child) $child->delete();
+ foreach ($this->getChildren() as $child) {
+ $child->delete();
+ }
// Removing the directory itself
rmdir($this->path);
return true;
-
}
/**
- * Returns available diskspace information
+ * Returns available diskspace information.
*
* @return array
*/
- function getQuotaInfo() {
-
+ public function getQuotaInfo()
+ {
$total = disk_total_space(realpath($this->path));
$free = disk_free_space(realpath($this->path));
return [
$total - $free,
- $free
+ $free,
];
}
@@ -186,13 +190,14 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa
* the move itself. If you return true from this function, the assumption
* is that the move was successful.
*
- * @param string $targetName New local file/collection name.
- * @param string $sourcePath Full path to source node
+ * @param string $targetName new local file/collection name
+ * @param string $sourcePath Full path to source node
* @param DAV\INode $sourceNode Source node itself
+ *
* @return bool
*/
- function moveInto($targetName, $sourcePath, DAV\INode $sourceNode) {
-
+ public function moveInto($targetName, $sourcePath, DAV\INode $sourceNode)
+ {
// We only support FSExt\Directory or FSExt\File objects, so
// anything else we want to quickly reject.
if (!$sourceNode instanceof self && !$sourceNode instanceof File) {
@@ -200,12 +205,8 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa
}
// PHP allows us to access protected properties from other objects, as
- // long as they are defined in a class that has a shared inheritence
+ // long as they are defined in a class that has a shared inheritance
// with the current class.
- rename($sourceNode->path, $this->path . '/' . $targetName);
-
- return true;
-
+ return rename($sourceNode->path, $this->path.'/'.$targetName);
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/FSExt/File.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/FSExt/File.php
index eb5ae19fec5..060ef5a4857 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/FSExt/File.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/FSExt/File.php
@@ -1,33 +1,36 @@
path, $data);
clearstatcache(true, $this->path);
- return $this->getETag();
+ return $this->getETag();
}
/**
@@ -53,21 +56,22 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport {
* time.
*
* @param resource|string $data
- * @param int $rangeType
- * @param int $offset
+ * @param int $rangeType
+ * @param int $offset
+ *
* @return string|null
*/
- function patch($data, $rangeType, $offset = null) {
-
+ public function patch($data, $rangeType, $offset = null)
+ {
switch ($rangeType) {
- case 1 :
+ case 1:
$f = fopen($this->path, 'a');
break;
- case 2 :
+ case 2:
$f = fopen($this->path, 'c');
fseek($f, $offset);
break;
- case 3 :
+ case 3:
$f = fopen($this->path, 'c');
fseek($f, $offset, SEEK_END);
break;
@@ -79,34 +83,32 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport {
}
fclose($f);
clearstatcache(true, $this->path);
- return $this->getETag();
+ return $this->getETag();
}
/**
- * Returns the data
+ * Returns the data.
*
* @return resource
*/
- function get() {
-
+ public function get()
+ {
return fopen($this->path, 'r');
-
}
/**
- * Delete the current file
+ * Delete the current file.
*
* @return bool
*/
- function delete() {
-
+ public function delete()
+ {
return unlink($this->path);
-
}
/**
- * Returns the ETag for a file
+ * Returns the ETag for a file.
*
* An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
* The ETag is an arbitrary string, but MUST be surrounded by double-quotes.
@@ -115,38 +117,34 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport {
*
* @return string|null
*/
- function getETag() {
-
- return '"' . sha1(
- fileinode($this->path) .
- filesize($this->path) .
+ public function getETag()
+ {
+ return '"'.sha1(
+ fileinode($this->path).
+ filesize($this->path).
filemtime($this->path)
- ) . '"';
-
+ ).'"';
}
/**
- * Returns the mime-type for a file
+ * Returns the mime-type for a file.
*
* If null is returned, we'll assume application/octet-stream
*
* @return string|null
*/
- function getContentType() {
-
+ public function getContentType()
+ {
return null;
-
}
/**
- * Returns the size of the file, in bytes
+ * Returns the size of the file, in bytes.
*
* @return int
*/
- function getSize() {
-
+ public function getSize()
+ {
return filesize($this->path);
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/File.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/File.php
index 5161fbd5153..daf83aa4d87 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/File.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/File.php
@@ -1,9 +1,11 @@
locksFile = $locksFile;
-
}
/**
- * Returns a list of Sabre\DAV\Locks\LockInfo objects
+ * Returns a list of Sabre\DAV\Locks\LockInfo objects.
*
* This method should return all the locks for a particular uri, including
* locks that might be set on a parent uri.
@@ -47,47 +48,47 @@ class File extends AbstractBackend {
* any locks in the subtree of the uri for locks.
*
* @param string $uri
- * @param bool $returnChildLocks
+ * @param bool $returnChildLocks
+ *
* @return array
*/
- function getLocks($uri, $returnChildLocks) {
-
+ public function getLocks($uri, $returnChildLocks)
+ {
$newLocks = [];
$locks = $this->getData();
foreach ($locks as $lock) {
-
if ($lock->uri === $uri ||
//deep locks on parents
- ($lock->depth != 0 && strpos($uri, $lock->uri . '/') === 0) ||
+ (0 != $lock->depth && 0 === strpos($uri, $lock->uri.'/')) ||
// locks on children
- ($returnChildLocks && (strpos($lock->uri, $uri . '/') === 0))) {
-
+ ($returnChildLocks && (0 === strpos($lock->uri, $uri.'/')))) {
$newLocks[] = $lock;
-
}
-
}
// Checking if we can remove any of these locks
foreach ($newLocks as $k => $lock) {
- if (time() > $lock->timeout + $lock->created) unset($newLocks[$k]);
+ if (time() > $lock->timeout + $lock->created) {
+ unset($newLocks[$k]);
+ }
}
- return $newLocks;
+ return $newLocks;
}
/**
- * Locks a uri
+ * Locks a uri.
*
- * @param string $uri
+ * @param string $uri
* @param LockInfo $lockInfo
+ *
* @return bool
*/
- function lock($uri, LockInfo $lockInfo) {
-
+ public function lock($uri, LockInfo $lockInfo)
+ {
// We're making the lock timeout 30 minutes
$lockInfo->timeout = 1800;
$lockInfo->created = time();
@@ -105,32 +106,31 @@ class File extends AbstractBackend {
}
$locks[] = $lockInfo;
$this->putData($locks);
- return true;
+ return true;
}
/**
- * Removes a lock from a uri
+ * Removes a lock from a uri.
*
- * @param string $uri
+ * @param string $uri
* @param LockInfo $lockInfo
+ *
* @return bool
*/
- function unlock($uri, LockInfo $lockInfo) {
-
+ public function unlock($uri, LockInfo $lockInfo)
+ {
$locks = $this->getData();
foreach ($locks as $k => $lock) {
-
if ($lock->token == $lockInfo->token) {
-
unset($locks[$k]);
$this->putData($locks);
- return true;
+ return true;
}
}
- return false;
+ return false;
}
/**
@@ -138,9 +138,11 @@ class File extends AbstractBackend {
*
* @return array
*/
- protected function getData() {
-
- if (!file_exists($this->locksFile)) return [];
+ protected function getData()
+ {
+ if (!file_exists($this->locksFile)) {
+ return [];
+ }
// opening up the file, and creating a shared lock
$handle = fopen($this->locksFile, 'r');
@@ -155,19 +157,20 @@ class File extends AbstractBackend {
// Unserializing and checking if the resource file contains data for this file
$data = unserialize($data);
- if (!$data) return [];
- return $data;
+ if (!$data) {
+ return [];
+ }
+ return $data;
}
/**
- * Saves the lockdata
+ * Saves the lockdata.
*
* @param array $newData
- * @return void
*/
- protected function putData(array $newData) {
-
+ protected function putData(array $newData)
+ {
// opening up the file, and creating an exclusive lock
$handle = fopen($this->locksFile, 'a+');
flock($handle, LOCK_EX);
@@ -179,7 +182,5 @@ class File extends AbstractBackend {
fwrite($handle, serialize($newData));
flock($handle, LOCK_UN);
fclose($handle);
-
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Locks/Backend/PDO.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Locks/Backend/PDO.php
index 510f266f7e6..36a12d1abb6 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Locks/Backend/PDO.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Locks/Backend/PDO.php
@@ -1,5 +1,7 @@
pdo = $pdo;
-
}
/**
- * Returns a list of Sabre\DAV\Locks\LockInfo objects
+ * Returns a list of Sabre\DAV\Locks\LockInfo objects.
*
* This method should return all the locks for a particular uri, including
* locks that might be set on a parent uri.
@@ -51,16 +52,17 @@ class PDO extends AbstractBackend {
* any locks in the subtree of the uri for locks.
*
* @param string $uri
- * @param bool $returnChildLocks
+ * @param bool $returnChildLocks
+ *
* @return array
*/
- function getLocks($uri, $returnChildLocks) {
-
+ public function getLocks($uri, $returnChildLocks)
+ {
// NOTE: the following 10 lines or so could be easily replaced by
// pure sql. MySQL's non-standard string concatenation prevents us
// from doing this though.
- $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM ' . $this->tableName . ' WHERE (created > (? - timeout)) AND ((uri = ?)';
- $params = [time(),$uri];
+ $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM '.$this->tableName.' WHERE (created > (? - timeout)) AND ((uri = ?)';
+ $params = [time(), $uri];
// We need to check locks for every part in the uri.
$uriParts = explode('/', $uri);
@@ -71,20 +73,18 @@ class PDO extends AbstractBackend {
$currentPath = '';
foreach ($uriParts as $part) {
-
- if ($currentPath) $currentPath .= '/';
+ if ($currentPath) {
+ $currentPath .= '/';
+ }
$currentPath .= $part;
$query .= ' OR (depth!=0 AND uri = ?)';
$params[] = $currentPath;
-
}
if ($returnChildLocks) {
-
$query .= ' OR (uri LIKE ?)';
- $params[] = $uri . '/%';
-
+ $params[] = $uri.'/%';
}
$query .= ')';
@@ -94,7 +94,6 @@ class PDO extends AbstractBackend {
$lockList = [];
foreach ($result as $row) {
-
$lockInfo = new LockInfo();
$lockInfo->owner = $row['owner'];
$lockInfo->token = $row['token'];
@@ -104,22 +103,21 @@ class PDO extends AbstractBackend {
$lockInfo->depth = $row['depth'];
$lockInfo->uri = $row['uri'];
$lockList[] = $lockInfo;
-
}
return $lockList;
-
}
/**
- * Locks a uri
+ * Locks a uri.
*
- * @param string $uri
+ * @param string $uri
* @param LockInfo $lockInfo
+ *
* @return bool
*/
- function lock($uri, LockInfo $lockInfo) {
-
+ public function lock($uri, LockInfo $lockInfo)
+ {
// We're making the lock timeout 30 minutes
$lockInfo->timeout = 30 * 60;
$lockInfo->created = time();
@@ -128,11 +126,13 @@ class PDO extends AbstractBackend {
$locks = $this->getLocks($uri, false);
$exists = false;
foreach ($locks as $lock) {
- if ($lock->token == $lockInfo->token) $exists = true;
+ if ($lock->token == $lockInfo->token) {
+ $exists = true;
+ }
}
if ($exists) {
- $stmt = $this->pdo->prepare('UPDATE ' . $this->tableName . ' SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?');
+ $stmt = $this->pdo->prepare('UPDATE '.$this->tableName.' SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?');
$stmt->execute([
$lockInfo->owner,
$lockInfo->timeout,
@@ -140,10 +140,10 @@ class PDO extends AbstractBackend {
$lockInfo->depth,
$uri,
$lockInfo->created,
- $lockInfo->token
+ $lockInfo->token,
]);
} else {
- $stmt = $this->pdo->prepare('INSERT INTO ' . $this->tableName . ' (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)');
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->tableName.' (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)');
$stmt->execute([
$lockInfo->owner,
$lockInfo->timeout,
@@ -151,30 +151,26 @@ class PDO extends AbstractBackend {
$lockInfo->depth,
$uri,
$lockInfo->created,
- $lockInfo->token
+ $lockInfo->token,
]);
}
return true;
-
}
-
-
/**
- * Removes a lock from a uri
+ * Removes a lock from a uri.
*
- * @param string $uri
+ * @param string $uri
* @param LockInfo $lockInfo
+ *
* @return bool
*/
- function unlock($uri, LockInfo $lockInfo) {
-
- $stmt = $this->pdo->prepare('DELETE FROM ' . $this->tableName . ' WHERE uri = ? AND token = ?');
+ public function unlock($uri, LockInfo $lockInfo)
+ {
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->tableName.' WHERE uri = ? AND token = ?');
$stmt->execute([$uri, $lockInfo->token]);
- return $stmt->rowCount() === 1;
-
+ return 1 === $stmt->rowCount();
}
-
}
diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Locks/LockInfo.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Locks/LockInfo.php
index 2c8cca0fee4..df82275665d 100644
--- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Locks/LockInfo.php
+++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Locks/LockInfo.php
@@ -1,9 +1,11 @@
locksBackend = $locksBackend;
-
}
/**
- * Initializes the plugin
+ * Initializes the plugin.
*
* This method is automatically called by the Server class after addPlugin.
*
* @param DAV\Server $server
- * @return void
*/
- function initialize(DAV\Server $server) {
-
+ public function initialize(DAV\Server $server)
+ {
$this->server = $server;
$this->server->xml->elementMap['{DAV:}lockinfo'] = 'Sabre\\DAV\\Xml\\Request\\Lock';
- $server->on('method:LOCK', [$this, 'httpLock']);
- $server->on('method:UNLOCK', [$this, 'httpUnlock']);
+ $server->on('method:LOCK', [$this, 'httpLock']);
+ $server->on('method:UNLOCK', [$this, 'httpUnlock']);
$server->on('validateTokens', [$this, 'validateTokens']);
- $server->on('propFind', [$this, 'propFind']);
- $server->on('afterUnbind', [$this, 'afterUnbind']);
-
+ $server->on('propFind', [$this, 'propFind']);
+ $server->on('afterUnbind', [$this, 'afterUnbind']);
}
/**
@@ -77,31 +76,28 @@ class Plugin extends DAV\ServerPlugin {
*
* @return string
*/
- function getPluginName() {
-
+ public function getPluginName()
+ {
return 'locks';
-
}
/**
* This method is called after most properties have been found
- * it allows us to add in any Lock-related properties
+ * it allows us to add in any Lock-related properties.
*
* @param DAV\PropFind $propFind
- * @param DAV\INode $node
- * @return void
+ * @param DAV\INode $node
*/
- function propFind(DAV\PropFind $propFind, DAV\INode $node) {
-
- $propFind->handle('{DAV:}supportedlock', function() {
+ public function propFind(DAV\PropFind $propFind, DAV\INode $node)
+ {
+ $propFind->handle('{DAV:}supportedlock', function () {
return new DAV\Xml\Property\SupportedLock();
});
- $propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) {
+ $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) {
return new DAV\Xml\Property\LockDiscovery(
$this->getLocks($propFind->getPath())
);
});
-
}
/**
@@ -112,12 +108,12 @@ class Plugin extends DAV\ServerPlugin {
* available for the specified uri.
*
* @param string $uri
+ *
* @return array
*/
- function getHTTPMethods($uri) {
-
- return ['LOCK','UNLOCK'];
-
+ public function getHTTPMethods($uri)
+ {
+ return ['LOCK', 'UNLOCK'];
}
/**
@@ -128,14 +124,13 @@ class Plugin extends DAV\ServerPlugin {
*
* @return array
*/
- function getFeatures() {
-
+ public function getFeatures()
+ {
return [2];
-
}
/**
- * Returns all lock information on a particular uri
+ * Returns all lock information on a particular uri.
*
* This function should return an array with Sabre\DAV\Locks\LockInfo objects. If there are no locks on a file, return an empty array.
*
@@ -144,17 +139,17 @@ class Plugin extends DAV\ServerPlugin {
* for any possible locks and return those as well.
*
* @param string $uri
- * @param bool $returnChildLocks
+ * @param bool $returnChildLocks
+ *
* @return array
*/
- function getLocks($uri, $returnChildLocks = false) {
-
+ public function getLocks($uri, $returnChildLocks = false)
+ {
return $this->locksBackend->getLocks($uri, $returnChildLocks);
-
}
/**
- * Locks an uri
+ * Locks an uri.
*
* The WebDAV lock request can be operated to either create a new lock on a file, or to refresh an existing lock
* If a new lock is created, a full XML body should be supplied, containing information about the lock such as the type
@@ -164,12 +159,13 @@ class Plugin extends DAV\ServerPlugin {
*
* Additionally, a lock can be requested for a non-existent file. In these case we're obligated to create an empty file as per RFC4918:S7.3
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpLock(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpLock(RequestInterface $request, ResponseInterface $response)
+ {
$uri = $request->getPath();
$existingLocks = $this->getLocks($uri);
@@ -180,7 +176,7 @@ class Plugin extends DAV\ServerPlugin {
$existingLock = null;
// Checking if there's already non-shared locks on the uri.
foreach ($existingLocks as $existingLock) {
- if ($existingLock->scope === LockInfo::EXCLUSIVE) {
+ if (LockInfo::EXCLUSIVE === $existingLock->scope) {
throw new DAV\Exception\ConflictingLock($existingLock);
}
}
@@ -188,11 +184,10 @@ class Plugin extends DAV\ServerPlugin {
$lockInfo = $this->parseLockRequest($body);
$lockInfo->depth = $this->server->getHTTPDepth();
$lockInfo->uri = $uri;
- if ($existingLock && $lockInfo->scope != LockInfo::SHARED)
+ if ($existingLock && LockInfo::SHARED != $lockInfo->scope) {
throw new DAV\Exception\ConflictingLock($existingLock);
-
+ }
} else {
-
// Gonna check if this was a lock refresh.
$existingLocks = $this->getLocks($uri);
$conditions = $this->server->getIfConditions($request);
@@ -201,7 +196,7 @@ class Plugin extends DAV\ServerPlugin {
foreach ($existingLocks as $existingLock) {
foreach ($conditions as $condition) {
foreach ($condition['tokens'] as $token) {
- if ($token['token'] === 'opaquelocktoken:' . $existingLock->token) {
+ if ($token['token'] === 'opaquelocktoken:'.$existingLock->token) {
$found = $existingLock;
break 3;
}
@@ -216,18 +211,20 @@ class Plugin extends DAV\ServerPlugin {
} else {
throw new DAV\Exception\BadRequest('An xml body is required for lock requests');
}
-
}
// This must have been a lock refresh
$lockInfo = $found;
// The resource could have been locked through another uri.
- if ($uri != $lockInfo->uri) $uri = $lockInfo->uri;
-
+ if ($uri != $lockInfo->uri) {
+ $uri = $lockInfo->uri;
+ }
}
- if ($timeout = $this->getTimeoutHeader()) $lockInfo->timeout = $timeout;
+ if ($timeout = $this->getTimeoutHeader()) {
+ $lockInfo->timeout = $timeout;
+ }
$newFile = false;
@@ -240,56 +237,52 @@ class Plugin extends DAV\ServerPlugin {
//
// See Issue 222
// $this->server->emit('beforeWriteContent',array($uri));
-
} catch (DAV\Exception\NotFound $e) {
-
// It didn't, lets create it
$this->server->createFile($uri, fopen('php://memory', 'r'));
$newFile = true;
-
}
$this->lockNode($uri, $lockInfo);
$response->setHeader('Content-Type', 'application/xml; charset=utf-8');
- $response->setHeader('Lock-Token', '| Principal | Privilege |
|---|
| Principal | Privilege | ||
|---|---|---|---|
| ', $html->xmlName($privilege['principal']), ' | '; } else { echo '', $html->link($privilege['principal']), ' | '; } echo '', $html->xmlName($privilege['privilege']), ' | '; echo ''; - if (!empty($privilege['protected'])) echo '(protected)'; + if (!empty($privilege['protected'])) { + echo '(protected)'; + } echo ' | '; echo '
some text