25 require_once
"Services/WebDAV/classes/Server.php";
26 require_once
"Services/WebDAV/classes/class.ilDAVLocks.php";
27 require_once
"Services/WebDAV/classes/class.ilDAVProperties.php";
28 require_once
'Services/WebDAV/classes/class.ilObjectDAV.php';
30 require_once
"Services/User/classes/class.ilObjUser.php";
31 require_once(
'include/Unicode/UtfNormal.php');
32 require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
145 $userAgent = strtolower($_SERVER[
'HTTP_USER_AGENT']);
146 $this->
writelog(
'userAgent='.$userAgent);
147 if (strpos($userAgent,
'windows') !==
false
148 || strpos($userAgent,
'microsoft') !==
false)
150 $this->clientOS =
'windows';
151 $this->clientOSFlavor =
'xp';
153 }
else if (strpos($userAgent,
'darwin') !==
false
154 || strpos($userAgent,
'macintosh') !==
false
155 || strpos($userAgent,
'linux') !==
false
156 || strpos($userAgent,
'solaris') !==
false
157 || strpos($userAgent,
'aix') !==
false
158 || strpos($userAgent,
'unix') !==
false
159 || strpos($userAgent,
'gvfs') !==
false
162 $this->clientOS =
'unix';
163 if (strpos($userAgent,
'linux') !==
false)
165 $this->clientOSFlavor =
'linux';
167 else if (strpos($userAgent,
'macintosh') !==
false)
169 $this->clientOSFlavor =
'osx';
172 if (strpos($userAgent,
'konqueror') !==
false)
174 $this->clientBrowser =
'konqueror';
184 if(self::$instance != NULL)
197 if (!self::_isActive())
199 $this->
writelog(__METHOD__.
' WebDAV disabled. Aborting');
201 echo
'<html><body><h1>Sorry</h1>'.
202 '<p><b>Please enable the WebDAV plugin in the ILIAS Administration panel.</b></p>'.
203 '<p>You can only access this page, if WebDAV is enabled on this server.</p>'.
210 $this->
writelog(
'serveRequest():'.$_SERVER[
'REQUEST_METHOD'].
' '.$_SERVER[
'PATH_INFO'].
' ...');
213 $this->
writelog(
'serveRequest():'.$_SERVER[
'REQUEST_METHOD'].
' done status='.$this->_http_status.
' elapsed='.($end - $start));
218 $this->
writelog(
'serveRequest():'.$_SERVER[
'REQUEST_METHOD'].
' caught exception: '.$e->getMessage().
'\n'.$e->getTraceAsString());
263 $c = explode(
'/',
$path);
264 for ($i = 0; $i < count($c); $i++)
266 $c[$i] = str_replace(
'+',
'%20',urlencode($c[$i]));
268 return implode(
'/',$c);
284 $this->
writelog(
'PROPFIND(options:'.var_export($options,
true).
' files:'.var_export(
$files,
true).
'.)');
285 $this->
writelog(
'PROPFIND '.$options[
'path']);
292 $files[
'files'] = array();
295 if (is_null($objDAV)) {
298 if (! $objDAV->isPermitted(
'visible,read')) {
299 return '403 Forbidden';
306 $GLOBALS[
'ilLog']->write(print_r($encodedPath,
true));
308 $files[
'files'][] =& $this->
fileinfo($encodedPath, $encodedPath, $objDAV);
311 if (!empty($options[
'depth'])) {
316 $breadthFirst = array($objDAV);
317 $objDAV->encodedPath = $encodedPath;
319 while (count($breadthFirst) > 0) {
321 $collectionDAV = array_shift($breadthFirst);
322 $childrenDAV =& $collectionDAV->childrenWithPermission(
'visible');
323 foreach ($childrenDAV as $childDAV)
327 foreach ($childrenDAV as $duplChildDAV)
329 if ($duplChildDAV->getObjectId() < $childDAV->getObjectId() &&
330 $duplChildDAV->getResourceName() == $childDAV->getResourceName())
339 $this->
writelog(
'PROPFIND() child ref_id='.$childDAV->getRefId());
341 $collectionDAV->encodedPath.
'/'.$this->davUrlEncode($childDAV->getResourceName()),
342 $collectionDAV->encodedPath.
'/'.$this->davUrlEncode($childDAV->getDisplayName()),
345 if ($options[
'depth']==
'infinity' && $childDAV->isCollection()) {
347 $breadthFirst[] = $childDAV;
348 $childDAV->encodedPath = $collectionDAV->encodedPath.
'/'.$this->
davUrlEncode($childDAV->getResourceName());
361 $objDAV->getObjectId(), $ilUser->getId(),
false);
364 $this->
writelog(
'PROPFIND():true options='.var_export($options,
true).
' files='.var_export(
$files,
true));
381 if ($objDAV->isNullResource()) {
382 if (count($this->locks->getLocksOnObjectDAV($objDAV)) == 0) {
387 $name = $objDAV->getResourceName();
388 $isFileHidden =
false;
389 switch ($this->clientOS)
395 || substr(
$name, 0, 2) ==
'~$';
397 $isFileHidden |= preg_match(
'/\\//',
$name);
401 $isFileHidden = substr(
$name, 0, 1) ==
'.';
403 $isFileHidden |= preg_match(
'/\\\\|\\/|:|\\*|\\?|"|<|>|\\|/',
$name);
407 $isFileHidden |= preg_match(
'/\\//',
$name);
410 $this->
writelog($this->clientOS.
' '.
$name.
' isHidden:'.$isFileHidden.
' clientOS:'.$this->clientOS);
411 return $isFileHidden;
421 private function fileinfo($resourcePath, $displayPath, &$objDAV)
425 $this->
writelog(
'fileinfo('.$resourcePath.
')');
432 if ($objDAV->isCollection() && $this->clientOSFlavor !=
'osx') {
433 $info[
'path'] = $resourcePath.
'/';
435 $info[
'path'] = $resourcePath;
438 $info[
'props'] = array();
441 $info[
"props"][] =& $this->
mkprop(
"displayname", $displayPath);
444 $info[
"props"][] =& $this->
mkprop(
"creationdate", $objDAV->getCreationTimestamp());
445 $info[
"props"][] =& $this->
mkprop(
"getlastmodified", $objDAV->getModificationTimestamp());
448 $info[
"props"][] =& $this->
mkprop(
"resourcetype", $objDAV->getResourceType());
449 $info[
"props"][] =& $this->
mkprop(
"getcontenttype", $objDAV->getContentType());
450 $info[
"props"][] =& $this->
mkprop(
"getcontentlength", $objDAV->getContentLength());
453 if ($objDAV->isPermitted(
'write'))
455 $info[
"props"][] =& $this->
mkprop(
"supportedlock",
457 .
'<D:lockscope><D:exclusive/></D:lockscope>'
458 .
'<D:locktype><D:write/></D:locktype>'
461 .
'<D:lockscope><D:shared/></D:lockscope>'
462 .
'<D:locktype><D:write/></D:locktype>'
470 $locks = $this->locks->getLocksOnObjectDAV($objDAV);
478 if ($lock[
'ilias_owner'] == $ilias->account->getId())
480 $owner = $lock[
'dav_owner'];
482 $owner =
'<D:href>'.$this->getLogin($lock[
'ilias_owner']).
'</D:href>';
484 $this->
writelog(
'lockowner='.$owner.
' ibi:'.$lock[
'ilias_owner'].
' davi:'.$lock[
'dav_owner']);
488 .
'<D:lockscope><D:'.$lock[
'scope'].
'/></D:lockscope>'
490 .
'<D:locktype><D:write/></D:locktype>'
491 .
'<D:depth>'.$lock[
'depth'].
'</D:depth>'
492 .
'<D:owner>'.$owner.
'</D:owner>'
496 .
'<D:timeout>Second-'.(($lock[
'expires'] > 1000000) ? $lock[
'expires']-time():$lock[
'expires']).
'</D:timeout>'
497 .
'<D:locktoken><D:href>'.$lock[
'token'].
'</D:href></D:locktoken>'
501 if (strlen($lockdiscovery) > 0)
503 $info[
"props"][] =& $this->
mkprop(
"lockdiscovery", $lockdiscovery);
510 $info[
"props"][] = $this->
mkprop($prop[
'namespace'], $prop[
'name'], $prop[
'value']);
528 public function GET(&$options)
532 $this->
writelog(
'GET('.var_export($options,
true).
')');
533 $this->
writelog(
'GET('.$options[
'path'].
')');
540 if (is_null($objDAV) || $objDAV->isNullResource())
545 if (! $objDAV->isPermitted(
'visible,read'))
547 return '403 Forbidden';
551 if ($objDAV->isCollection())
553 if (isset(
$_GET[
'mount']))
555 return $this->
mountDir($objDAV, $options);
557 else if (isset(
$_GET[
'mount-instructions']))
563 return $this->
getDir($objDAV, $options);
567 $options[
'mimetype'] =& $objDAV->getContentType();
572 $options[
'mtime'] =& $objDAV->getModificationTimestamp();
575 $options[
'size'] =& $objDAV->getContentLength();
578 $options[
'stream'] =& $objDAV->getContentStream();
579 if (is_null($options[
'stream']))
581 $options[
'data'] =& $objDAV->getContentData();
588 $objDAV->getObjectId(), $ilUser->getId());
590 $this->
writelog(
'GET:'.var_export($options,
true));
609 header(
'Content-Type: application/davmount+xml');
611 echo
"<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n";
612 echo
" </dm:url>".$this->base_uri.
"</dm:url>\n";
614 $xmlPath = str_replace(
'&',
'&',
$path);
615 $xmlPath = str_replace(
'<',
'<',$xmlPath);
616 $xmlPath = str_replace(
'>',
'>',$xmlPath);
618 echo
" </dm:open>$xmlPath</dm:open>\n";
619 echo
"</dm:mount>\n";
643 foreach ($objectPath as $object)
645 if ($object->getRefId() == 1 && $this->
isFileHidden($object))
650 $fullPath .=
'/ref_1';
654 $fullPath .=
'/'.$this->davUrlEncode($object->getResourceName());
659 $shortenedPath =
'/ref_'.
660 $objectPath[count($objectPath) - 1]->getRefId();
662 if ($objDAV->isCollection())
664 $shortenedPath .=
'/';
669 $shortenedPath =
'/'.CLIENT_ID.$shortenedPath;
670 $fullPath =
'/'.CLIENT_ID.$fullPath;
675 $webfolderURI = $this->base_uri.$shortenedPath;
677 substr($this->base_uri, strrpos($this->base_uri,
':')).
681 substr($this->base_uri, strrpos($this->base_uri,
':')).
684 $webfolderURI_IE = $this->base_uri.$shortenedPath;
686 $webfolderTitle = $objectPath[count($objectPath) - 1]->getResourceName();
688 header(
'Content-Type: text/html; charset=UTF-8');
689 echo
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
690 echo
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
691 echo
" \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
692 echo
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
694 echo
" <title>".sprintf($lng->txt(
'webfolder_instructions_titletext'), $webfolderTitle).
"</title>\n";
699 $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
700 $this->clientOS,$this->clientOSFlavor);
706 if($ilUser->getId() == ANONYMOUS_USER_ID)
723 private function getDir(&$objDAV, &$options)
737 if (
$path.
'/' != $options[
'path'])
739 header(
'Location: '.$this->base_uri.$path.
'/');
743 header(
'Content-Type: text/html; charset=UTF-8');
746 $format =
"%15s %-19s %-s\n";
748 echo
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
749 echo
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
750 echo
" \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
751 echo
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
753 echo
"<title>".sprintf($lng->txt(
'webfolder_index_of'),
$path).
"</title>\n";
757 echo
"<style type=\"text/css\">\n";
760 echo
" behavior:url(#default#AnchorClick);\n";
765 echo
"</head><body>\n";
768 $pathComponents = explode(
'/',
$path);
769 $uriComponents = array();
770 foreach ($pathComponents as $component)
774 for ($i = 0; $i < count($pathComponents); $i++)
776 $displayName = htmlspecialchars($pathComponents[$i]);
780 $uriPath = implode(
'/', array_slice($uriComponents,0,$i + 1));
786 $hrefPath .= $displayName;
790 $hrefPath .=
'<a href="'.$this->base_uri.$uriPath.
'/">'.$displayName.
'</a>';
793 echo
"<h3>".sprintf($lng->txt(
'webfolder_index_of'), $hrefPath).
"</h3>\n";
796 if ($ilias->account->getLogin() ==
'anonymous')
798 echo
"<p><font size=\"-1\">".$lng->txt(
'not_logged_in').
"</font><br>\n";
800 echo
"<p><font size=\"-1\">".$lng->txt(
'login_as').
" <i>"
801 .$ilias->account->getFirstname().
' '
802 .$ilias->account->getLastname().
' '
803 .
' '.$ilias->account->getLogin().
'</i> '
804 .
', '.$lng->txt(
'client').
' <i>'.$ilias->getClientId().
'</i>.'
809 $href = $this->base_uri.$uriPath;
812 if (count($pathComponents) > 2)
814 $hrefIE = $this->base_uri.
'/'.CLIENT_ID.
'/ref_'.$objDAV->getRefId();
818 echo
"<p><font size=\"-1\">".
819 sprintf($lng->txt(
'webfolder_dir_info'),
"$href?mount-instructions").
821 echo
"<p><font size=\"-1\">".
822 sprintf($lng->txt(
'webfolder_mount_dir_with'),
823 "$hrefIE\" folder=\"$hrefIE",
824 'webdav'.substr($href,4),
825 'dav'.substr($href,4),
831 printf($format, $lng->txt(
'size'), $lng->txt(
'last_change'), $lng->txt(
'filename'));
834 $collectionCount = 0;
836 $children =& $objDAV->childrenWithPermission(
'visible');
837 foreach ($children as $childDAV) {
838 if ($childDAV->isCollection() && !$this->
isFileHidden($childDAV))
844 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
845 '<a href="'.
$name.
'/'.
'">'.$childDAV->getDisplayName().
"</a>");
848 foreach ($children as $childDAV) {
849 if ($childDAV->isFile() && !$this->
isFileHidden($childDAV))
854 number_format($childDAV->getContentLength()),
855 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
856 '<a href="'.
$name.
'">'.$childDAV->getDisplayName().
"</a>");
859 foreach ($children as $childDAV) {
860 if ($childDAV->isNullResource() && !$this->
isFileHidden($childDAV))
865 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
866 '<a href="'.
$name.
'">'.$childDAV->getDisplayName().
"</a>");
870 echo $collectionCount.
' '.$lng->txt(($collectionCount == 1) ?
'folder' :
'folders').
', ';
871 echo $fileCount.
' '.$lng->txt(($fileCount == 1) ?
'file' :
'files').
'.';
873 echo
"</body></html>\n";
885 public function PUT(&$options)
889 $this->
writelog(
'PUT('.var_export($options,
true).
')');
892 $parent = dirname(
$path);
899 if (is_null($parentDAV) || ! $parentDAV->isCollection()) {
900 return '409 Conflict';
906 if ($options[
'content_length'] != null &&
909 $this->
writelog(
'PUT is forbidden, because content length='.
910 $options[
'content_length'].
' is larger than upload_max_filesize='.
913 return '403 Forbidden';
917 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
921 if (is_null($objDAV))
923 $ttype = $parentDAV->getILIASFileType();
924 $isperm = $parentDAV->isPermitted(
'create', $ttype);
927 $this->
writelog(
'PUT is forbidden, because user has no create permission');
929 return '403 Forbidden';
931 $options[
"new"] =
true;
932 $objDAV =& $parentDAV->createFile(
$name);
933 $this->
writelog(
'PUT obj='.$objDAV.
' name='.
$name.
' content_type='.$options[
'content_type']);
935 $objDAV->setContentType($mime);
936 if ($options[
'content_length'] != null)
938 $objDAV->setContentLength($options[
'content_length']);
947 else if ($objDAV->isNullResource())
949 if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()))
951 $this->
writelog(
'PUT is forbidden, because user has no create permission');
952 return '403 Forbidden';
954 $options[
"new"] =
false;
955 $objDAV =& $parentDAV->createFileFromNull(
$name, $objDAV);
956 $this->
writelog(
'PUT obj='.$objDAV.
' name='.
$name.
' content_type='.$options[
'content_type']);
958 $objDAV->setContentType($mime);
959 if ($options[
'content_length'] != null)
961 $objDAV->setContentLength($options[
'content_length']);
973 if (! $objDAV->isPermitted(
'write'))
975 $this->
writelog(
'PUT is forbidden, because user has no write permission');
976 return '403 Forbidden';
978 $options[
"new"] =
false;
979 $this->
writelog(
'PUT obj='.$objDAV.
' name='.
$name.
' content_type='.$options[
'content_type'].
' content_length='.$options[
'content_length']);
982 if ($objDAV->getContentLength() != 0) {
983 $objDAV->createNewVersion();
987 $objDAV->setContentType($mime);
988 if ($options[
'content_length'] != null)
990 $objDAV->setContentLength($options[
'content_length']);
1002 $this->putObjDAV = $objDAV;
1004 $out =& $objDAV->getContentOutputStream();
1018 $this->
writelog(
'PUTfinished('.var_export($options,
true).
')');
1022 if ($options[
'content_length'] == null)
1025 $objDAV->setContentLength($objDAV->getContentOutputStreamLength());
1027 $this->putObjDAV = null;
1043 $this->
writelog(
'MKCOL('.var_export($options,
true).
')');
1044 $this->
writelog(
'MKCOL '.$options[
'path']);
1047 $parent =& dirname(
$path);
1051 if(!empty($_SERVER[
"CONTENT_LENGTH"])) {
1052 return "415 Unsupported media type";
1057 if (! is_null($objDAV))
1059 return '405 Method not allowed';
1063 $parentDAV =& $this->
getObject($parent);
1066 if (is_null($parentDAV) || ! $parentDAV->isCollection())
1068 return '409 Conflict';
1071 if (! $parentDAV->isPermitted(
'create',$parentDAV->getILIASCollectionType()))
1073 return '403 Forbidden';
1078 $objDAV = $parentDAV->createCollection(
$name);
1080 if ($objDAV != null)
1089 $result = ($objDAV != null) ?
"201 Created" :
"409 Conflict";
1104 $this->
writelog(
'DELETE('.var_export($options,
true).
')');
1105 $this->
writelog(
'DELETE '.$options[
'path']);
1113 if (is_null($objDAV) || $objDAV->isNullResource())
1115 return '404 Not Found';
1117 if (! $objDAV->isPermitted(
'delete'))
1119 return '403 Forbidden';
1122 $parentDAV->remove($objDAV);
1130 return '204 No Content';
1143 $this->
writelog(
'MOVE('.var_export($options,
true).
')');
1144 $this->
writelog(
'MOVE '.$options[
'path'].
' '.$options[
'dest']);
1148 $srcParent = dirname($src);
1152 $dstParent = dirname($dst);
1154 $this->
writelog(
'move '.$dst.
' dstname='.$dstName);
1158 return '409 Conflict (source and destination are the same)';
1162 if (substr($dst,strlen($src)+1) == $src.
'/')
1164 return '409 Conflict (destination is in subtree of source)';
1170 $srcParentDAV =& $this->
getObject($srcParent);
1171 $dstParentDAV =& $this->
getObject($dstParent);
1174 if ($srcDAV == null)
1176 return '409 Conflict (source does not exist)';
1180 $isOverwritten =
false;
1181 if ($dstDAV != null)
1183 if ($options[
'overwrite'] ==
'T')
1186 if ($dstDAV->isPermitted(
'delete'))
1188 $dstParentDAV->remove($dstDAV);
1190 $isOverwritten =
true;
1192 return '403 Not Permitted';
1195 return '412 Precondition Failed';
1200 if ($dstParentDAV == null)
1202 return '409 Conflict (parent of destination does not exist)';
1205 if ($srcParent == $dstParent)
1210 if (! $srcDAV->isPermitted(
'write'))
1212 return '403 Forbidden';
1214 $this->
writelog(
'rename dstName='.$dstName);
1215 $srcDAV->setResourceName($dstName);
1221 if (! $srcDAV->isPermitted(
'delete'))
1223 return '403 Forbidden';
1226 if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
1228 return '403 Forbidden';
1230 $dstParentDAV->addMove($srcDAV, $dstName);
1247 return ($isOverwritten) ?
'204 No Content' :
'201 Created';
1256 public function COPY($options, $del=
false)
1259 $this->
writelog(
'COPY('.var_export($options,
true).
' ,del='.$del.
')');
1260 $this->
writelog(
'COPY '.$options[
'path'].
' '.$options[
'dest']);
1263 if (isset($options[
"dest_url"])) {
1264 return "502 bad gateway";
1268 $srcParent = dirname($src);
1271 $dstParent = dirname($dst);
1277 return '409 Conflict';
1280 if (substr($dst,strlen($src)+1) == $src.
'/')
1282 return '409 Conflict';
1285 $this->
writelog(
'COPY src='.$src.
' dst='.$dst);
1289 $dstParentDAV =& $this->
getObject($dstParent);
1291 if (is_null($srcDAV) || $srcDAV->isNullResource())
1293 return '409 Conflict';
1295 if (is_null($dstParentDAV) || $dstParentDAV->isNullResource())
1297 return '409 Conflict';
1299 $isOverwritten =
false;
1302 if (! is_null($dstDAV))
1304 if ($options[
'overwrite'] ==
'T')
1306 if ($dstDAV->isPermitted(
'delete'))
1308 $dstParentDAV->remove($dstDAV);
1315 $isOverwritten =
true;
1317 return '403 Forbidden';
1320 return '412 Precondition Failed';
1324 if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
1326 return '403 Forbidden';
1328 $dstDAV = $dstParentDAV->addCopy($srcDAV, $dstName);
1334 $srcDAV->getObjectId(), $ilUser->getId());
1338 return ($isOverwritten) ?
'204 No Content' :
'201 Created';
1349 $this->
writelog(
'PROPPATCH(options='.var_export($options,
true).
')');
1350 $this->
writelog(
'PROPPATCH '.$options[
'path']);
1357 if (is_null($objDAV) || $objDAV->isNullResource())
return false;
1359 $isPermitted = $objDAV->isPermitted(
'write');
1360 foreach($options[
'props'] as $key => $prop) {
1361 if (!$isPermitted || $prop[
'ns'] ==
'DAV:')
1363 $options[
'props'][$key][
'status'] =
'403 Forbidden';
1365 $this->properties->put($objDAV, $prop[
'ns'],$prop[
'name'],$prop[
'val']);
1382 $this->
writelog(
'LOCK('.var_export($options,
true).
')');
1383 $this->
writelog(
'LOCK '.$options[
'path']);
1390 if (is_null($objDAV))
1392 $this->
writelog(
'LOCK handling null-object locking...');
1395 if (isset($options[
"update"]))
1397 $this->
writelog(
'LOCK lock-update failed on non-existing null-object.');
1398 return '412 Precondition Failed';
1401 $parent = dirname(
$path);
1402 $parentDAV =& $this->
getObject($parent);
1403 if (is_null($parentDAV))
1405 $this->
writelog(
'LOCK lock failed on non-existing path to null-object.');
1406 return '404 Not Found';
1408 if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()) &&
1409 ! $parentDAV->isPermitted(
'create', $parentDAV->getILIASCollectionType()))
1411 $this->
writelog(
'LOCK lock failed - creation of null object not permitted.');
1412 return '403 Forbidden';
1420 if (! $objDAV->isNullResource() && ! $objDAV->isPermitted(
'write'))
1422 $this->
writelog(
'LOCK lock failed - user has no write permission.');
1423 return '403 Forbidden';
1427 if (!isset($options[
'timeout']) || is_array($options[
'timeout']))
1429 $options[
"timeout"] = time()+360;
1432 if(isset($options[
"update"])) {
1433 $this->
writelog(
'LOCK update token='.var_export($options,
true));
1434 $success = $this->locks->updateLockWithoutCheckingDAV(
1441 $data = $this->locks->getLockDAV($objDAV, $options[
'update']);
1442 if (
$data[
'ilias_owner'] == $ilias->account->getId())
1444 $owner =
$data[
'dav_owner'];
1446 $owner =
'<D:href>'.$this->getLogin(
$data[
'ilias_owner']).
'</D:href>';
1448 $options[
'owner'] = $owner;
1449 $options[
'locktoken'] =
$data[
'token'];
1450 $options[
'timeout'] =
$data[
'expires'];
1451 $options[
'depth'] =
$data[
'depth'];
1452 $options[
'scope'] =
$data[
'scope'];
1453 $options[
'type'] =
$data[
'scope'];
1457 $this->
writelog(
'LOCK create new lock');
1466 $this->
writelog(
'lock owner='.$owner);
1467 $success = $this->locks->lockWithoutCheckingDAV(
1469 $ilias->account->getId(),
1470 trim($options[
'owner']),
1471 $options[
'locktoken'],
1472 $options[
'timeout'],
1493 global
$log, $ilias;
1494 $this->
writelog(
'UNLOCK(options='.var_export($options,
true).
')');
1495 $this->
writelog(
'UNLOCK '.$options[
'path']);
1500 if (is_null($objDAV)) {
1501 return '404 Not Found';
1503 if (! $objDAV->isPermitted(
'write')) {
1504 return '403 Forbidden';
1507 $success = $this->locks->unlockWithoutCheckingDAV(
1514 if ($objDAV->isNullResource()
1515 && count($this->locks->getLocksOnObjectDAV($objDAV)) == 0)
1518 $parentDAV =& $this->
getObject($parent);
1519 $parentDAV->remove($objDAV);
1525 return ($success) ?
'200 OK' :
'412 Precondition Failed';
1552 if (! is_null($objPath))
1554 $objDAV = $objPath[count($objPath) - 1];
1555 $locks = $this->locks->getLocksOnPathDAV($objPath);
1556 foreach (
$locks as $lock)
1558 $isLastPathComponent = $lock[
'obj_id'] == $objDAV->getObjectId()
1559 && $lock[
'node_id'] == $objDAV->getNodeId();
1563 if ($isLastPathComponent || $lock[
'depth'] ==
'infinity')
1569 if ($lock[
'ilias_owner'] == $ilias->account->getId())
1571 $owner = $lock[
'dav_owner'];
1573 $owner = $this->
getLogin($lock[
'ilias_owner']);
1580 "obj_id" => $lock[
'obj_id'],
1581 "node_id" => $lock[
'node_id'],
1582 "scope" => $lock[
'scope'],
1583 "depth" => $lock[
'depth'],
1585 "token" => $lock[
'token'],
1586 "expires" => $lock[
'expires']
1588 if ($lock[
'scope'] ==
'exclusive')
1599 $this->
writelog(
'checkLock('.
$path.
'):'.var_export($result,
true));
1611 $this->
writelog(
'getLogin('.$userId.
'):'.var_export($login,
true));
1630 $davPathComponents = split(
'/',substr($davPath,1));
1631 if (count($davPathComponents) > 1 &&
1632 substr($davPathComponents[1],0,5) ==
'file_')
1634 $ref_id = substr($davPathComponents[1],5);
1635 $nodePath = $tree->getNodePath(
$ref_id, $tree->root_id);
1639 header(
'Pragma: private');
1644 if ($nodePath == null && count($davPathComponents) == 1)
1649 if (is_null($nodePath))
1653 $top = $nodePath[count($nodePath) - 1];
1665 $this->
writelog(
'toObjectPath('.$davPath);
1670 if (is_null($nodePath))
1674 $objectPath = array();
1675 foreach ($nodePath as $node)
1678 if (is_null($pathElement))
1682 $objectPath[] = $pathElement;
1702 $this->
writelog(
'toNodePath('.$davPath.
')...');
1705 $titlePath = split(
'/',substr($davPath,1));
1708 if (count($titlePath) > 0)
1710 array_shift($titlePath);
1714 if (count($titlePath) > 0 && $titlePath[count($titlePath) - 1] ==
'')
1716 array_pop($titlePath);
1720 if (count($titlePath) == 0)
1722 $this->
writelog(
'toNodePath('.$davPath.
'):null, because path is empty.');
1730 if (count($titlePath) > 0 && substr($titlePath[0],0,4) ==
'ref_')
1732 $ref_id = substr($titlePath[0],4);
1733 array_shift($titlePath);
1736 $nodePath = $tree->getNodePathForTitlePath($titlePath,
$ref_id);
1738 $this->
writelog(
'toNodePath():'.var_export($nodePath,
true));
1767 $components = split(
'/',
$path);
1768 return count($components) == 0 ?
'' : $components[count($components) - 1];
1785 if ($message ==
'---')
1790 $ilias->account->getLogin()
1791 .
' '.$_SERVER[
'REMOTE_ADDR'].
':'.$_SERVER[
'REMOTE_PORT']
1792 .
' ilDAVServer.'.str_replace(
"\n",
";",$message)
1798 $fh = fopen(
'/opt/ilias/log/ilias.log',
'a');
1799 fwrite($fh, date(
'Y-m-d H:i:s '));
1800 fwrite($fh, str_replace(
"\n",
";",$message));
1801 fwrite($fh,
"\n\n");
1819 function getMountURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null, $genericURI =
false)
1824 }
else if ($this->clientOS ==
'windows') {
1826 $query =
'mount-instructions';
1827 }
else if ($this->clientBrowser ==
'konqueror') {
1830 }
else if ($this->clientBrowser ==
'nautilus') {
1835 $query =
'mount-instructions';
1837 $baseUri.=
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1838 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1840 $uri = $baseUri.
'/ref_'.$refId.
'/';
1862 function getFolderURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null)
1864 if ($this->clientOS ==
'windows') {
1867 }
else if ($this->clientBrowser ==
'konqueror') {
1870 }
else if ($this->clientBrowser ==
'nautilus') {
1877 $baseUri.=
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1878 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1880 $uri = $baseUri.
'/ref_'.$refId.
'/';
1899 public function getObjectURI($refId, $ressourceName = null, $parentRefId = null)
1903 "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1904 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1906 if (! is_null($ressourceName) && ! is_null($parentRefId))
1909 $uri = $baseUri.
'/ref_'.$parentRefId.
'/'.$this->
davUrlEncode($ressourceName);
1913 $nodePath = $tree->getNodePath($refId);
1915 if (is_null($nodePath) || count($nodePath) < 2)
1920 $uri = $baseUri.
'/ref_'.$nodePath[count($nodePath) - 2][
'child'].
'/'.
1921 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1944 public function getFileURI($refId, $ressourceName = null, $parentRefId = null)
1948 "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1949 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1951 if (! is_null($ressourceName) && ! is_null($parentRefId))
1958 $nodePath = $tree->getNodePath($refId);
1960 if (is_null($nodePath) || count($nodePath) < 2)
1965 $uri = $baseUri.
'/file_'.$nodePath[count($nodePath) - 1][
'child'].
'/'.
1966 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1978 if ($this->isHTTPS == null) {
1980 require_once
'classes/class.ilHTTPS.php';
1982 $this->isHTTPS = $https->isDetected() || $ilSetting->get(
'https');
1997 global $ilClientIniFile;
1998 return $ilClientIniFile->readVariable(
'file_access',
'webdav_enabled') ==
'1' &&
1999 @include_once(
"Auth/HTTP.php");
2008 global $ilClientIniFile;
2009 return $ilClientIniFile->readVariable(
'file_access',
'webdav_actions_visible') ==
'1';
2024 return $lng->txt(
'webfolder_instructions_text');
2054 $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
2055 $os =
'unknown', $osFlavor =
'unknown')
2059 $settings =
new ilSetting(
'file_access');
2060 $str = $settings->get(
'custom_webfolder_instructions',
'');
2061 if (strlen($str) == 0 || ! $settings->get(
'custom_webfolder_instructions_enabled'))
2066 $str = str_replace(
"[WEBFOLDER_TITLE]", $webfolderTitle, $str);
2067 $str = str_replace(
"[WEBFOLDER_URI]", $webfolderURI, $str);
2068 $str = str_replace(
"[WEBFOLDER_URI_IE]", $webfolderURI_IE, $str);
2069 $str = str_replace(
"[WEBFOLDER_URI_KONQUEROR]", $webfolderURI_Konqueror, $str);
2070 $str = str_replace(
"[WEBFOLDER_URI_NAUTILUS]", $webfolderURI_Nautilus, $str);
2071 $str = str_replace(
"[ADMIN_MAIL]", $ilSetting->get(
"admin_email"), $str);
2076 $operatingSystem =
'WINDOWS';
2082 $operatingSystem =
'MAC';
2085 $operatingSystem =
'LINUX';
2088 $operatingSystem =
'LINUX';
2093 $operatingSystem =
'UNKNOWN';
2097 if ($operatingSystem !=
'UNKNOWN')
2099 $str = preg_replace(
'/\[IF_'.$operatingSystem.
'\]((?:.|\n)*)\[\/IF_'.$operatingSystem.
'\]/',
'\1', $str);
2100 $str = preg_replace(
'/\[IF_([A-Z_]+)\](?:(?:.|\n)*)\[\/IF_\1\]/',
'', $str);
2104 $str = preg_replace(
'/\[IF_([A-Z_]+)\]((?:.|\n)*)\[\/IF_\1\]/',
'\2', $str);
2115 $val = ini_get(
'upload_max_filesize');
2118 $last = strtolower($val[strlen($val)-1]);