Beispiel #1
0
 /**
  * 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;
 }
 /**
  * Handles POST requests for tree operations
  * 
  * This method is not yet used.
  * 
  * @param string $method 
  * @return bool
  */
 public function httpPOSTHandler($method)
 {
     if ($method != 'POST') {
         return true;
     }
     if (isset($_POST['action'])) {
         switch ($_POST['action']) {
             case 'mkcol':
                 if (isset($_POST['name']) && trim($_POST['name'])) {
                     // Using basename() because we won't allow slashes
                     $folderName = trim(basename($_POST['name']));
                     $this->server->createDirectory($this->server->getRequestUri() . '/' . $folderName);
                 }
                 break;
             case 'put':
                 if ($_FILES) {
                     $file = current($_FILES);
                 } else {
                     break;
                 }
                 $newName = basename($file['name']);
                 if (isset($_POST['name']) && trim($_POST['name'])) {
                     $newName = trim(basename($_POST['name']));
                 }
                 if (is_uploaded_file($file['tmp_name'])) {
                     $parent = $this->server->tree->getNodeForPath(trim($this->server->getRequestUri(), '/'));
                     $parent->createFile($newName, fopen($file['tmp_name'], 'r'));
                 }
         }
     }
     $this->server->httpResponse->setHeader('Location', $this->server->httpRequest->getUri());
     return false;
 }
Beispiel #3
0
 /**
  * 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;
 }