* Infinity is used for some request supporting the HTTP Depth header and indicates that the operation should traverse the entire tree
*/
constDEPTH_INFINITY=-1;
/**
* XML namespace for all SabreDAV related elements
*/
constNS_SABREDAV='http://sabredav.org/ns';
/**
* The tree object
*
* @var Sabre\DAV\Tree
*/
public$tree;
/**
* The base uri
*
* @var string
*/
protected$baseUri=null;
/**
* httpResponse
*
* @var Sabre\HTTP\Response
*/
public$httpResponse;
/**
* httpRequest
*
* @var Sabre\HTTP\Request
*/
public$httpRequest;
/**
* PHP HTTP Sapi
*
* @var Sabre\HTTP\Sapi
*/
public$sapi;
/**
* The list of plugins
*
* @var array
*/
protected$plugins=[];
/**
* This property will be filled with a unique string that describes the
* transaction. This is useful for performance measuring and logging
* purposes.
*
* By default it will just fill it with a lowercased HTTP method name, but
* plugins override this. For example, the WebDAV-Sync sync-collection
* report will set this to 'report-sync-collection'.
*
* @var string
*/
public$transactionType;
/**
* This is a list of properties that are always server-controlled, and
* must not get modified with PROPPATCH.
*
* Plugins may add to this list.
*
* @var string[]
*/
public$protectedProperties=[
// RFC4918
'{DAV:}getcontentlength',
'{DAV:}getetag',
'{DAV:}getlastmodified',
'{DAV:}lockdiscovery',
'{DAV:}supportedlock',
// RFC4331
'{DAV:}quota-available-bytes',
'{DAV:}quota-used-bytes',
// RFC3744
'{DAV:}supported-privilege-set',
'{DAV:}current-user-privilege-set',
'{DAV:}acl',
'{DAV:}acl-restrictions',
'{DAV:}inherited-acl-set',
// RFC3253
'{DAV:}supported-method-set',
'{DAV:}supported-report-set',
// RFC6578
'{DAV:}sync-token',
// calendarserver.org extensions
'{http://calendarserver.org/ns/}ctag',
// sabredav extensions
'{http://sabredav.org/ns}sync-token',
];
/**
* This is a flag that allow or not showing file, line and code
* of the exception in the returned XML
*
* @var bool
*/
public$debugExceptions=false;
/**
* This property allows you to automatically add the 'resourcetype' value
* based on a node's classname or interface.
*
* The preset ensures that {DAV:}collection is automatically added for nodes
* implementing Sabre\DAV\ICollection.
*
* @var array
*/
public$resourceTypeMapping=[
'Sabre\\DAV\\ICollection'=>'{DAV:}collection',
];
/**
* This property allows the usage of Depth: infinity on PROPFIND requests.
*
* By default Depth: infinity is treated as Depth: 1. Allowing Depth:
* infinity is potentially risky, as it allows a single client to do a full
* index of the webdav server, which is an easy DoS attack vector.
*
* Only turn this on if you know what you're doing.
*
* @var bool
*/
public$enablePropfindDepthInfinity=false;
/**
* Reference to the XML utility object.
*
* @var Xml\Service
*/
public$xml;
/**
* If this setting is turned off, SabreDAV's version number will be hidden
* from various places.
*
* Some people feel this is a good security measure.
*
* @var bool
*/
static$exposeVersion=true;
/**
* Sets up the server
*
* If a Sabre\DAV\Tree object is passed as an argument, it will
* use it as the directory tree. If a Sabre\DAV\INode is passed, it
* will create a Sabre\DAV\Tree and use the node as the root.
*
* If nothing is passed, a Sabre\DAV\SimpleCollection is created in
* a Sabre\DAV\Tree.
*
* If an array is passed, we automatically create a root node, and use
* the nodes in the array as top-level children.
*
* @param Tree|INode|array|null $treeOrNode The tree object
*/
function__construct($treeOrNode=null){
if($treeOrNodeinstanceofTree){
$this->tree=$treeOrNode;
}elseif($treeOrNodeinstanceofINode){
$this->tree=newTree($treeOrNode);
}elseif(is_array($treeOrNode)){
// If it's an array, a list of nodes was passed, and we need to
// create the root node.
foreach($treeOrNodeas$node){
if(!($nodeinstanceofINode)){
thrownewException('Invalid argument passed to constructor. If you\'re passing an array, all the values must implement Sabre\\DAV\\INode');
}
}
$root=newSimpleCollection('root',$treeOrNode);
$this->tree=newTree($root);
}elseif(is_null($treeOrNode)){
$root=newSimpleCollection('root');
$this->tree=newTree($root);
}else{
thrownewException('Invalid argument passed to constructor. Argument must either be an instance of Sabre\\DAV\\Tree, Sabre\\DAV\\INode, an array or null');
}
$this->xml=newXml\Service();
$this->sapi=newHTTP\Sapi();
$this->httpResponse=newHTTP\Response();
$this->httpRequest=$this->sapi->getRequest();
$this->addPlugin(newCorePlugin());
}
/**
* Starts the DAV Server
*
* @return void
*/
functionexec(){
try{
// If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an
// origin, we must make sure we send back HTTP/1.0 if this was
// requested.
// This is mainly because nginx doesn't support Chunked Transfer
// Encoding, and this forces the webserver SabreDAV is running on,
// to buffer entire responses to calculate Content-Length.
// A special case, if the baseUri was accessed without a trailing
// slash, we'll accept it as well.
}elseif($uri.'/'===$baseUri){
return'';
}else{
thrownewException\Forbidden('Requested uri ('.$uri.') is out of base uri ('.$this->getBaseUri().')');
}
}
/**
* Returns the HTTP depth header
*
* This method returns the contents of the HTTP depth request header. If the depth header was 'infinity' it will return the Sabre\DAV\Server::DEPTH_INFINITY object
* It is possible to supply a default depth value, which is used when the depth header has invalid content, or is completely non-existent
thrownewException\PreconditionFailed('An If-Unmodified-Since header was specified, but the entity has been changed since the specified date.','If-Unmodified-Since');
}
}
}
}
// Now the hardest, the If: header. The If: header can contain multiple
// urls, ETags and so-called 'state tokens'.
//
// Examples of state tokens include lock-tokens (as defined in rfc4918)
// and sync-tokens (as defined in rfc6578).
//
// The only proper way to deal with these, is to emit events, that a