本文整理汇总了PHP中Sabre\DAV\Server类的典型用法代码示例。如果您正苦于以下问题:PHP Server类的具体用法?PHP Server怎么用?PHP Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* This initializes the plugin.
*
* This function is called by Sabre\DAV\Server, after
* addPlugin is called.
*
* This method should set up the required event subscriptions.
*
* @param Server $server
* @return void
*/
function initialize(Server $server)
{
$server->on('propFind', [$this, 'propFind'], 130);
$server->on('propPatch', [$this, 'propPatch'], 300);
$server->on('afterMove', [$this, 'afterMove']);
$server->on('afterUnbind', [$this, 'afterUnbind']);
}
示例2: testBrief
function testBrief()
{
$httpRequest = HTTP\Sapi::createFromServerArray(array('HTTP_BRIEF' => 't'));
$server = new Server();
$server->httpRequest = $httpRequest;
$this->assertEquals(array('strict' => false, 'lenient' => false, 'wait' => null, 'return-asynch' => false, 'return-minimal' => true, 'return-representation' => false), $server->getHTTPPrefer());
}
示例3: __construct
/**
* Constructor.
*
* @param Server $dav
* @param EventDispatcherInterface $dispatcher
* @param RouterInterface $router
*/
public function __construct(Server $dav, EventDispatcherInterface $dispatcher, RouterInterface $router)
{
$this->dav = $dav;
$this->dav->setBaseUri($router->generate('secotrust_sabre_dav', array()));
$this->dispatcher = $dispatcher;
// TODO needed?
}
示例4: initialize
/**
* Initializes the plugin
*
* @param \Sabre\DAV\Server $server
* @return void
*/
public function initialize(\Sabre\DAV\Server $server)
{
$this->server = $server;
$this->server->subscribeEvent('beforeMethod', array($this, 'beforeMethod'));
$this->server->subscribeEvent('beforeBind', array($this, 'beforeBind'), 30);
$this->server->subscribeEvent('afterUnbind', array($this, 'afterUnbind'), 30);
}
示例5: serialize
/**
* serialize
*
* @param DAV\Server $server
* @param \DOMElement $prop
* @return void
*/
public function serialize(DAV\Server $server, \DOMElement $prop)
{
$doc = $prop->ownerDocument;
foreach ($this->locks as $lock) {
$activeLock = $doc->createElementNS('DAV:', 'd:activelock');
$prop->appendChild($activeLock);
$lockScope = $doc->createElementNS('DAV:', 'd:lockscope');
$activeLock->appendChild($lockScope);
$lockScope->appendChild($doc->createElementNS('DAV:', 'd:' . ($lock->scope == DAV\Locks\LockInfo::EXCLUSIVE ? 'exclusive' : 'shared')));
$lockType = $doc->createElementNS('DAV:', 'd:locktype');
$activeLock->appendChild($lockType);
$lockType->appendChild($doc->createElementNS('DAV:', 'd:write'));
/* {DAV:}lockroot */
if (!self::$hideLockRoot) {
$lockRoot = $doc->createElementNS('DAV:', 'd:lockroot');
$activeLock->appendChild($lockRoot);
$href = $doc->createElementNS('DAV:', 'd:href');
$href->appendChild($doc->createTextNode($server->getBaseUri() . $lock->uri));
$lockRoot->appendChild($href);
}
$activeLock->appendChild($doc->createElementNS('DAV:', 'd:depth', $lock->depth == DAV\Server::DEPTH_INFINITY ? 'infinity' : $lock->depth));
$activeLock->appendChild($doc->createElementNS('DAV:', 'd:timeout', 'Second-' . $lock->timeout));
if ($this->revealLockToken) {
$lockToken = $doc->createElementNS('DAV:', 'd:locktoken');
$activeLock->appendChild($lockToken);
$lockToken->appendChild($doc->createElementNS('DAV:', 'd:href', 'opaquelocktoken:' . $lock->token));
}
$activeLock->appendChild($doc->createElementNS('DAV:', 'd:owner', $lock->owner));
}
}
示例6: initialize
/**
* Initializes the plugin
*
* @param DAV\Server $server
* @return void
*/
function initialize(DAV\Server $server)
{
/* Events */
$server->on('propFind', [$this, 'propFindEarly']);
$server->on('propFind', [$this, 'propFindLate'], 150);
$server->on('propPatch', [$this, 'propPatch']);
$server->on('report', [$this, 'report']);
$server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']);
$server->on('onBrowserPostAction', [$this, 'browserPostAction']);
$server->on('beforeWriteContent', [$this, 'beforeWriteContent']);
$server->on('beforeCreateFile', [$this, 'beforeCreateFile']);
$server->on('afterMethod:GET', [$this, 'httpAfterGet']);
/* Namespaces */
$server->xmlNamespaces[self::NS_CARDDAV] = 'card';
/* Mapping Interfaces to {DAV:}resourcetype values */
$server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook'] = '{' . self::NS_CARDDAV . '}addressbook';
$server->resourceTypeMapping['Sabre\\CardDAV\\IDirectory'] = '{' . self::NS_CARDDAV . '}directory';
/* Adding properties that may never be changed */
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}supported-address-data';
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}max-resource-size';
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}addressbook-home-set';
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}supported-collation-set';
$server->propertyMap['{http://calendarserver.org/ns/}me-card'] = 'Sabre\\DAV\\Property\\Href';
$this->server = $server;
}
示例7: initialize
public function initialize(\Sabre\DAV\Server $server)
{
$this->server = $server;
$server->subscribeEvent('beforeMethod', array($this, 'httpGetInterceptor'));
$server->subscribeEvent('beforeMethod', array($this, 'beforeMethod'));
$server->subscribeEvent('beforeCreateFile', array($this, 'beforeCreateFile'));
}
示例8: testBrief
function testBrief()
{
$httpRequest = HTTP\Sapi::createFromServerArray(['HTTP_BRIEF' => 't']);
$server = new Server();
$server->httpRequest = $httpRequest;
$this->assertEquals(['respond-async' => false, 'return' => 'minimal', 'handling' => null, 'wait' => null], $server->getHTTPPrefer());
}
示例9: serialize
/**
* serialize
*
* @param DAV\Server $server
* @param \DOMElement $dom
* @return void
*/
public function serialize(DAV\Server $server, \DOMElement $dom)
{
$document = $dom->ownerDocument;
$properties = $this->responseProperties;
$xresponse = $document->createElement('d:response');
$dom->appendChild($xresponse);
$uri = DAV\URLUtil::encodePath($this->href);
// Adding the baseurl to the beginning of the url
$uri = $server->getBaseUri() . $uri;
$xresponse->appendChild($document->createElement('d:href', $uri));
// The properties variable is an array containing properties, grouped by
// HTTP status
foreach ($properties as $httpStatus => $propertyGroup) {
// The 'href' is also in this array, and it's special cased.
// We will ignore it
if ($httpStatus == 'href') {
continue;
}
// If there are no properties in this group, we can also just carry on
if (!count($propertyGroup)) {
continue;
}
$xpropstat = $document->createElement('d:propstat');
$xresponse->appendChild($xpropstat);
$xprop = $document->createElement('d:prop');
$xpropstat->appendChild($xprop);
$nsList = $server->xmlNamespaces;
foreach ($propertyGroup as $propertyName => $propertyValue) {
$propName = null;
preg_match('/^{([^}]*)}(.*)$/', $propertyName, $propName);
// special case for empty namespaces
if ($propName[1] == '') {
$currentProperty = $document->createElement($propName[2]);
$xprop->appendChild($currentProperty);
$currentProperty->setAttribute('xmlns', '');
} else {
if (!isset($nsList[$propName[1]])) {
$nsList[$propName[1]] = 'x' . count($nsList);
}
// If the namespace was defined in the top-level xml namespaces, it means
// there was already a namespace declaration, and we don't have to worry about it.
if (isset($server->xmlNamespaces[$propName[1]])) {
$currentProperty = $document->createElement($nsList[$propName[1]] . ':' . $propName[2]);
} else {
$currentProperty = $document->createElementNS($propName[1], $nsList[$propName[1]] . ':' . $propName[2]);
}
$xprop->appendChild($currentProperty);
}
if (is_scalar($propertyValue)) {
$text = $document->createTextNode($propertyValue);
$currentProperty->appendChild($text);
} elseif ($propertyValue instanceof DAV\PropertyInterface) {
$propertyValue->serialize($server, $currentProperty);
} elseif (!is_null($propertyValue)) {
throw new DAV\Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName);
}
}
$xpropstat->appendChild($document->createElement('d:status', $server->httpResponse->getStatusMessage($httpStatus)));
}
}
示例10: testLockEtc
function testLockEtc()
{
mkdir(SABRE_TEMPDIR . '/mstest');
$tree = new DAV\FS\Directory(SABRE_TEMPDIR . '/mstest');
$server = new DAV\Server($tree);
$server->debugExceptions = true;
$locksBackend = new Backend\File(SABRE_TEMPDIR . '/locksdb');
$locksPlugin = new Plugin($locksBackend);
$server->addPlugin($locksPlugin);
$response1 = new HTTP\ResponseMock();
$server->httpRequest = $this->getLockRequest();
$server->httpResponse = $response1;
$server->sapi = new HTTP\SapiMock();
$server->exec();
$this->assertEquals(201, $server->httpResponse->getStatus(), 'Full response body:' . $response1->getBodyAsString());
$this->assertTrue(!!$server->httpResponse->getHeaders('Lock-Token'));
$lockToken = $server->httpResponse->getHeader('Lock-Token');
//sleep(10);
$response2 = new HTTP\ResponseMock();
$server->httpRequest = $this->getLockRequest2();
$server->httpResponse = $response2;
$server->exec();
$this->assertEquals(201, $server->httpResponse->status);
$this->assertTrue(!!$server->httpResponse->getHeaders('Lock-Token'));
//sleep(10);
$response3 = new HTTP\ResponseMock();
$server->httpRequest = $this->getPutRequest($lockToken);
$server->httpResponse = $response3;
$server->exec();
$this->assertEquals(204, $server->httpResponse->status);
}
示例11: serialize
/**
* Serializes this property.
*
* It will additionally prepend the href property with the server's base uri.
*
* @param DAV\Server $server
* @param \DOMElement $dom
* @return void
*/
public function serialize(DAV\Server $server, \DOMElement $dom)
{
$prefix = $server->xmlNamespaces['DAV:'];
$elem = $dom->ownerDocument->createElement($prefix . ':href');
$elem->nodeValue = ($this->autoPrefix ? $server->getBaseUri() : '') . $this->href;
$dom->appendChild($elem);
}
示例12: testLockEtc
function testLockEtc()
{
mkdir(SABRE_TEMPDIR . '/mstest');
$tree = new DAV\FS\Directory(SABRE_TEMPDIR . '/mstest');
$server = new DAV\Server($tree);
$server->debugExceptions = true;
$locksBackend = new Backend\File(SABRE_TEMPDIR . '/locksdb');
$locksPlugin = new Plugin($locksBackend);
$server->addPlugin($locksPlugin);
$response1 = new HTTP\ResponseMock();
$server->httpRequest = $this->getLockRequest();
$server->httpResponse = $response1;
$server->exec();
$this->assertEquals('HTTP/1.1 201 Created', $server->httpResponse->status);
$this->assertTrue(isset($server->httpResponse->headers['Lock-Token']));
$lockToken = $server->httpResponse->headers['Lock-Token'];
//sleep(10);
$response2 = new HTTP\ResponseMock();
$server->httpRequest = $this->getLockRequest2();
$server->httpResponse = $response2;
$server->exec();
$this->assertEquals('HTTP/1.1 201 Created', $server->httpResponse->status);
$this->assertTrue(isset($server->httpResponse->headers['Lock-Token']));
//sleep(10);
$response3 = new HTTP\ResponseMock();
$server->httpRequest = $this->getPutRequest($lockToken);
$server->httpResponse = $response3;
$server->exec();
$this->assertEquals('HTTP/1.1 204 No Content', $server->httpResponse->status);
}
示例13: initialize
/**
* Initializes the plugin
*
* This method is automatically called by the Server class after addPlugin.
*
* @param DAV\Server $server
* @return void
*/
public function initialize(DAV\Server $server)
{
$this->server = $server;
$server->subscribeEvent('unknownMethod', array($this, 'unknownMethod'));
$server->subscribeEvent('beforeMethod', array($this, 'beforeMethod'), 50);
$server->subscribeEvent('afterGetProperties', array($this, 'afterGetProperties'));
}
示例14: init
function init()
{
if (!is_dir('store')) {
os_mkdir('store', STORAGE_DEFAULT_PERMISSIONS, false);
}
$which = null;
if (argc() > 1) {
$which = argv(1);
}
$profile = 0;
\App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . z_root() . '/feed/' . $which . '" />' . "\r\n";
if ($which) {
profile_load($which, $profile);
}
$auth = new \Zotlabs\Storage\BasicAuth();
$ob_hash = get_observer_hash();
if ($ob_hash) {
if (local_channel()) {
$channel = \App::get_channel();
$auth->setCurrentUser($channel['channel_address']);
$auth->channel_id = $channel['channel_id'];
$auth->channel_hash = $channel['channel_hash'];
$auth->channel_account_id = $channel['channel_account_id'];
if ($channel['channel_timezone']) {
$auth->setTimezone($channel['channel_timezone']);
}
}
$auth->observer = $ob_hash;
}
if ($_GET['davguest']) {
$_SESSION['davguest'] = true;
}
$_SERVER['QUERY_STRING'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['QUERY_STRING']);
$_SERVER['QUERY_STRING'] = strip_zids($_SERVER['QUERY_STRING']);
$_SERVER['QUERY_STRING'] = preg_replace('/[\\?&]davguest=(.*?)([\\?&]|$)/ism', '', $_SERVER['QUERY_STRING']);
$_SERVER['REQUEST_URI'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = strip_zids($_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = preg_replace('/[\\?&]davguest=(.*?)([\\?&]|$)/ism', '', $_SERVER['REQUEST_URI']);
$rootDirectory = new \Zotlabs\Storage\Directory('/', $auth);
// A SabreDAV server-object
$server = new SDAV\Server($rootDirectory);
// prevent overwriting changes each other with a lock backend
$lockBackend = new SDAV\Locks\Backend\File('store/[data]/locks');
$lockPlugin = new SDAV\Locks\Plugin($lockBackend);
$server->addPlugin($lockPlugin);
$is_readable = false;
// provide a directory view for the cloud in Hubzilla
$browser = new \Zotlabs\Storage\Browser($auth);
$auth->setBrowserPlugin($browser);
$server->addPlugin($browser);
// Experimental QuotaPlugin
// require_once('\Zotlabs\Storage/QuotaPlugin.php');
// $server->addPlugin(new \Zotlabs\Storage\\QuotaPlugin($auth));
ob_start();
// All we need to do now, is to fire up the server
$server->exec();
ob_end_flush();
killme();
}
示例15: idAction
public function idAction($id)
{
$server = new Server(new RootId($id));
$server->setBaseUri(WEBDAV_BASE_URI . "id/" . $id . "/");
$this->initDavPlugins($server);
$server->exec();
exit;
}