server->createDirectory($uri . '/' . $folderName); } break; case 'put' : if ($_FILES) $file = $_FILES['file']; 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; } public function generateDirectoryIndex($path) { $html = " Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . Sabre_DAV_Version::VERSION . "

Index for " . $this->escapeHTML($path) . "/

"; $files = $this->server->getPropertiesForPath($path,array( '{DAV:}displayname', '{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified', ),1); $parent = $this->server->tree->getNodeForPath($path); if ($path) { list($parentUri) = Sabre_DAV_URLUtil::splitPath($path); $fullPath = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $parentUri); $html.= ""; } foreach($files as $k=>$file) { // This is the current directory, we can skip it if (rtrim($file['href'],'/')==$path) continue; list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']); $type = null; if (isset($file[200]['{DAV:}resourcetype'])) { $type = $file[200]['{DAV:}resourcetype']->getValue(); // resourcetype can have multiple values if (!is_array($type)) $type = array($type); foreach($type as $k=>$v) { // Some name mapping is preferred switch($v) { case '{DAV:}collection' : $type[$k] = 'Collection'; break; case '{DAV:}principal' : $type[$k] = 'Principal'; break; case '{urn:ietf:params:xml:ns:carddav}addressbook' : $type[$k] = 'Addressbook'; break; case '{urn:ietf:params:xml:ns:caldav}calendar' : $type[$k] = 'Calendar'; break; } } $type = implode(', ', $type); } // If no resourcetype was found, we attempt to use // the contenttype property if (!$type && isset($file[200]['{DAV:}getcontenttype'])) { $type = $file[200]['{DAV:}getcontenttype']; } if (!$type) $type = 'Unknown'; $size = isset($file[200]['{DAV:}getcontentlength'])?(int)$file[200]['{DAV:}getcontentlength']:''; $lastmodified = isset($file[200]['{DAV:}getlastmodified'])?$file[200]['{DAV:}getlastmodified']->getTime()->format(DateTime::ATOM):''; $fullPath = Sabre_DAV_URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path?$path . '/':'') . $name,'/')); $displayName = isset($file[200]['{DAV:}displayname'])?$file[200]['{DAV:}displayname']:$name; $name = $this->escapeHTML($name); $displayName = $this->escapeHTML($displayName); $type = $this->escapeHTML($type); $html.= ""; } $html.= ""; if ($this->enablePost && $parent instanceof Sabre_DAV_ICollection) { $html.= ''; } $html.= "
NameTypeSizeLast modified

.. [parent]
{$displayName} {$type} {$size} {$lastmodified}

Upload file

Name (optional):
File:
Generated by SabreDAV " . Sabre_DAV_Version::VERSION ."-". Sabre_DAV_Version::STABILITY . " (c)2007-2012 http://code.google.com/p/sabredav/
"; return $html; } }