当前位置: 首页>>代码示例>>PHP>>正文


PHP Sabre_DAV_Server::createFile方法代码示例

本文整理汇总了PHP中Sabre_DAV_Server::createFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_DAV_Server::createFile方法的具体用法?PHP Sabre_DAV_Server::createFile怎么用?PHP Sabre_DAV_Server::createFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sabre_DAV_Server的用法示例。


在下文中一共展示了Sabre_DAV_Server::createFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: httpPOSTHandler

 /**
  * Handles POST requests for tree operations
  * 
  * This method is not yet used.
  * 
  * @param string $method 
  * @return bool
  */
 public function httpPOSTHandler($method, $uri)
 {
     if ($method != 'POST') {
         return true;
     }
     if (isset($_POST['sabreAction'])) {
         switch ($_POST['sabreAction']) {
             case 'mkcol':
                 if (isset($_POST['name']) && trim($_POST['name'])) {
                     // Using basename() because we won't allow slashes
                     list(, $folderName) = Sabre_DAV_URLUtil::splitPath(trim($_POST['name']));
                     $this->server->createDirectory($uri . '/' . $folderName);
                 }
                 break;
             case 'put':
                 if ($_FILES) {
                     $file = current($_FILES);
                 } else {
                     break;
                 }
                 $newName = trim($file['name']);
                 list(, $newName) = Sabre_DAV_URLUtil::splitPath(trim($file['name']));
                 if (isset($_POST['name']) && trim($_POST['name'])) {
                     $newName = trim($_POST['name']);
                 }
                 // Making sure we only have a 'basename' component
                 list(, $newName) = Sabre_DAV_URLUtil::splitPath($newName);
                 if (is_uploaded_file($file['tmp_name'])) {
                     $this->server->createFile($uri . '/' . $newName, fopen($file['tmp_name'], 'r'));
                 }
         }
     }
     $this->server->httpResponse->setHeader('Location', $this->server->httpRequest->getUri());
     return false;
 }
开发者ID:kumarsivarajan,项目名称:mollify,代码行数:43,代码来源:Plugin.php

示例2: httpLock

 /**
  * 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
  * of lock (shared or exclusive) and the owner of the lock
  *
  * If a lock is to be refreshed, no body should be supplied and there should be a valid If header containing the lock
  *
  * 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 string $uri
  * @return void
  */
 protected function httpLock($uri)
 {
     $lastLock = null;
     if (!$this->validateLock($uri, $lastLock)) {
         // If the existing lock was an exclusive lock, we need to fail
         if (!$lastLock || $lastLock->scope == Sabre_DAV_Locks_LockInfo::EXCLUSIVE) {
             //var_dump($lastLock);
             throw new Sabre_DAV_Exception_ConflictingLock($lastLock);
         }
     }
     if ($body = $this->server->httpRequest->getBody(true)) {
         // This is a new lock request
         $lockInfo = $this->parseLockRequest($body);
         $lockInfo->depth = $this->server->getHTTPDepth();
         $lockInfo->uri = $uri;
         if ($lastLock && $lockInfo->scope != Sabre_DAV_Locks_LockInfo::SHARED) {
             throw new Sabre_DAV_Exception_ConflictingLock($lastLock);
         }
     } elseif ($lastLock) {
         // This must have been a lock refresh
         $lockInfo = $lastLock;
         // The resource could have been locked through another uri.
         if ($uri != $lockInfo->uri) {
             $uri = $lockInfo->uri;
         }
     } else {
         // There was neither a lock refresh nor a new lock request
         throw new Sabre_DAV_Exception_BadRequest('An xml body is required for lock requests');
     }
     if ($timeout = $this->getTimeoutHeader()) {
         $lockInfo->timeout = $timeout;
     }
     $newFile = false;
     // If we got this far.. we should go check if this node actually exists. If this is not the case, we need to create it first
     try {
         $this->server->tree->getNodeForPath($uri);
         // We need to call the beforeWriteContent event for RFC3744
         // Edit: looks like this is not used, and causing problems now.
         //
         // See Issue 222
         // $this->server->broadcastEvent('beforeWriteContent',array($uri));
     } catch (Sabre_DAV_Exception_NotFound $e) {
         // It didn't, lets create it
         $this->server->createFile($uri, fopen('php://memory', 'r'));
         $newFile = true;
     }
     $this->lockNode($uri, $lockInfo);
     $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
     $this->server->httpResponse->setHeader('Lock-Token', '<opaquelocktoken:' . $lockInfo->token . '>');
     $this->server->httpResponse->sendStatus($newFile ? 201 : 200);
     $this->server->httpResponse->sendBody($this->generateLockResponse($lockInfo));
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:66,代码来源:Plugin.php

示例3: httpPOSTHandler

 /**
  * Handles POST requests for tree operations.
  *
  * @param string $method
  * @param string $uri
  * @return bool
  */
 public function httpPOSTHandler($method, $uri)
 {
     if ($method != 'POST') {
         return;
     }
     $contentType = $this->server->httpRequest->getHeader('Content-Type');
     list($contentType) = explode(';', $contentType);
     if ($contentType !== 'application/x-www-form-urlencoded' && $contentType !== 'multipart/form-data') {
         return;
     }
     $postVars = $this->server->httpRequest->getPostVars();
     if (!isset($postVars['sabreAction'])) {
         return;
     }
     if ($this->server->broadcastEvent('onBrowserPostAction', array($uri, $postVars['sabreAction'], $postVars))) {
         switch ($postVars['sabreAction']) {
             case 'mkcol':
                 if (isset($postVars['name']) && trim($postVars['name'])) {
                     // Using basename() because we won't allow slashes
                     list(, $folderName) = Sabre_DAV_URLUtil::splitPath(trim($postVars['name']));
                     $this->server->createDirectory($uri . '/' . $folderName);
                 }
                 break;
             case 'put':
                 if ($_FILES) {
                     $file = current($_FILES);
                 } else {
                     break;
                 }
                 list(, $newName) = Sabre_DAV_URLUtil::splitPath(trim($file['name']));
                 if (isset($postVars['name']) && trim($postVars['name'])) {
                     $newName = trim($postVars['name']);
                 }
                 // Making sure we only have a 'basename' component
                 list(, $newName) = Sabre_DAV_URLUtil::splitPath($newName);
                 if (is_uploaded_file($file['tmp_name'])) {
                     $this->server->createFile($uri . '/' . $newName, fopen($file['tmp_name'], 'r'));
                 }
                 break;
         }
     }
     $this->server->httpResponse->setHeader('Location', $this->server->httpRequest->getUri());
     $this->server->httpResponse->sendStatus(302);
     return false;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:52,代码来源:Plugin.php


注:本文中的Sabre_DAV_Server::createFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。