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');
136 $userAgent = strtolower($_SERVER[
'HTTP_USER_AGENT']);
137 $this->
writelog(
'userAgent='.$userAgent);
138 if (strpos($userAgent,
'windows') !==
false
139 || strpos($userAgent,
'microsoft') !==
false)
141 $this->clientOS =
'windows';
142 $this->clientOSFlavor =
'xp';
144 }
else if (strpos($userAgent,
'darwin') !==
false
145 || strpos($userAgent,
'macintosh') !==
false
146 || strpos($userAgent,
'linux') !==
false
147 || strpos($userAgent,
'solaris') !==
false
148 || strpos($userAgent,
'aix') !==
false
149 || strpos($userAgent,
'unix') !==
false
150 || strpos($userAgent,
'gvfs') !==
false
153 $this->clientOS =
'unix';
154 if (strpos($userAgent,
'linux') !==
false)
156 $this->clientOSFlavor =
'linux';
158 else if (strpos($userAgent,
'macintosh') !==
false)
160 $this->clientOSFlavor =
'osx';
163 if (strpos($userAgent,
'konqueror') !==
false)
165 $this->clientBrowser =
'konqueror';
175 if (!self::_isActive())
178 echo
'<html><body><h1>Sorry</h1>'.
179 '<p><b>Please enable the WebDAV plugin in the ILIAS Administration panel.</b></p>'.
180 '<p>You can only access this page, if WebDAV is enabled on this server.</p>'.
187 $this->
writelog(
'serveRequest():'.$_SERVER[
'REQUEST_METHOD'].
' '.$_SERVER[
'PATH_INFO'].
' ...');
190 $this->
writelog(
'serveRequest():'.$_SERVER[
'REQUEST_METHOD'].
' done status='.$this->_http_status.
' elapsed='.($end - $start));
193 $this->
writelog(
'serveRequest():'.$_SERVER[
'REQUEST_METHOD'].
' caught exception: '.$e->getMessage().
'\n'.$e->getTraceAsString());
238 $c = explode(
'/',
$path);
239 for ($i = 0; $i < count($c); $i++)
241 $c[$i] = str_replace(
'+',
'%20',urlencode($c[$i]));
243 return implode(
'/',$c);
259 $this->
writelog(
'PROPFIND(options:'.var_export($options,
true).
' files:'.var_export(
$files,
true).
'.)');
260 $this->
writelog(
'PROPFIND '.$options[
'path']);
267 $files[
'files'] = array();
270 if (is_null($objDAV)) {
273 if (! $objDAV->isPermitted(
'visible,read')) {
274 return '403 Forbidden';
280 $files[
'files'][] =& $this->
fileinfo($encodedPath, $encodedPath, $objDAV);
283 if (!empty($options[
'depth'])) {
288 $breadthFirst = array($objDAV);
289 $objDAV->encodedPath = $encodedPath;
291 while (count($breadthFirst) > 0) {
293 $collectionDAV = array_shift($breadthFirst);
294 $childrenDAV =& $collectionDAV->childrenWithPermission(
'visible');
295 foreach ($childrenDAV as $childDAV)
299 foreach ($childrenDAV as $duplChildDAV)
301 if ($duplChildDAV->getObjectId() < $childDAV->getObjectId() &&
302 $duplChildDAV->getResourceName() == $childDAV->getResourceName())
311 $this->
writelog(
'PROPFIND() child ref_id='.$childDAV->getRefId());
313 $collectionDAV->encodedPath.
'/'.$this->davUrlEncode($childDAV->getResourceName()),
314 $collectionDAV->encodedPath.
'/'.$this->davUrlEncode($childDAV->getDisplayName()),
318 if ($options[
'depth']==
'infinity' && $childDAV->isCollection()) {
320 $breadthFirst[] = $childDAV;
321 $childDAV->encodedPath = $collectionDAV->encodedPath.
'/'.$this->
davUrlEncode($childDAV->getResourceName());
337 $this->
writelog(
'PROPFIND():true options='.var_export($options,
true).
' files='.var_export(
$files,
true));
354 if ($objDAV->isNullResource()) {
355 if (count($this->locks->getLocksOnObjectDAV($objDAV)) == 0) {
360 $name = $objDAV->getResourceName();
361 $isFileHidden =
false;
362 switch ($this->clientOS)
368 || substr($name, 0, 2) ==
'~$';
370 $isFileHidden |= preg_match(
'/\\//', $name);
374 $isFileHidden = substr($name, 0, 1) ==
'.';
376 $isFileHidden |= preg_match(
'/\\\\|\\/|:|\\*|\\?|"|<|>|\\|/', $name);
380 $isFileHidden |= preg_match(
'/\\//', $name);
383 $this->
writelog($this->clientOS.
' '.$name.
' isHidden:'.$isFileHidden.
' clientOS:'.$this->clientOS);
384 return $isFileHidden;
394 private function fileinfo($resourcePath, $displayPath, &$objDAV)
398 $this->
writelog(
'fileinfo('.$resourcePath.
')');
405 if ($objDAV->isCollection() && $this->clientOSFlavor !=
'osx') {
406 $info[
'path'] = $resourcePath.
'/';
408 $info[
'path'] = $resourcePath;
411 $info[
'props'] = array();
414 $info[
"props"][] =& $this->
mkprop(
"displayname", $displayPath);
417 $info[
"props"][] =& $this->
mkprop(
"creationdate", $objDAV->getCreationTimestamp());
418 $info[
"props"][] =& $this->
mkprop(
"getlastmodified", $objDAV->getModificationTimestamp());
421 $info[
"props"][] =& $this->
mkprop(
"resourcetype", $objDAV->getResourceType());
422 $info[
"props"][] =& $this->
mkprop(
"getcontenttype", $objDAV->getContentType());
423 $info[
"props"][] =& $this->
mkprop(
"getcontentlength", $objDAV->getContentLength());
426 if ($objDAV->isPermitted(
'write'))
428 $info[
"props"][] =& $this->
mkprop(
"supportedlock",
430 .
'<D:lockscope><D:exclusive/></D:lockscope>'
431 .
'<D:locktype><D:write/></D:locktype>'
434 .
'<D:lockscope><D:shared/></D:lockscope>'
435 .
'<D:locktype><D:write/></D:locktype>'
443 $locks = $this->locks->getLocksOnObjectDAV($objDAV);
451 if ($lock[
'ilias_owner'] == $ilias->account->getId())
453 $owner = $lock[
'dav_owner'];
455 $owner =
'<D:href>'.$this->getLogin($lock[
'ilias_owner']).
'</D:href>';
457 $this->
writelog(
'lockowner='.$owner.
' ibi:'.$lock[
'ilias_owner'].
' davi:'.$lock[
'dav_owner']);
461 .
'<D:lockscope><D:'.$lock[
'scope'].
'/></D:lockscope>'
463 .
'<D:locktype><D:write/></D:locktype>'
464 .
'<D:depth>'.$lock[
'depth'].
'</D:depth>'
465 .
'<D:owner>'.$owner.
'</D:owner>'
469 .
'<D:timeout>Second-'.(($lock[
'expires'] > 1000000) ? $lock[
'expires']-time():$lock[
'expires']).
'</D:timeout>'
470 .
'<D:locktoken><D:href>'.$lock[
'token'].
'</D:href></D:locktoken>'
474 if (strlen($lockdiscovery) > 0)
476 $info[
"props"][] =& $this->
mkprop(
"lockdiscovery", $lockdiscovery);
483 $info[
"props"][] = $this->
mkprop($prop[
'namespace'], $prop[
'name'], $prop[
'value']);
502 public function GET(&$options)
506 $this->
writelog(
'GET('.var_export($options,
true).
')');
507 $this->
writelog(
'GET('.$options[
'path'].
')');
514 if (is_null($objDAV) || $objDAV->isNullResource())
519 if (! $objDAV->isPermitted(
'visible,read'))
521 return '403 Forbidden';
525 if ($objDAV->isCollection())
527 if (isset(
$_GET[
'mount']))
529 return $this->
mountDir($objDAV, $options);
530 }
else if (isset(
$_GET[
'mount-instructions']))
534 return $this->
getDir($objDAV, $options);
538 $options[
'mimetype'] =& $objDAV->getContentType();
543 $options[
'mtime'] =& $objDAV->getModificationTimestamp();
546 $options[
'size'] =& $objDAV->getContentLength();
549 $options[
'stream'] =& $objDAV->getContentStream();
550 if (is_null($options[
'stream']))
552 $options[
'data'] =& $objDAV->getContentData();
560 $this->
writelog(
'GET:'.var_export($options,
true));
579 header(
'Content-Type: application/davmount+xml');
581 echo
"<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n";
582 echo
" </dm:url>".$this->base_uri.
"</dm:url>\n";
584 $xmlPath = str_replace(
'&',
'&',
$path);
585 $xmlPath = str_replace(
'<',
'<',$xmlPath);
586 $xmlPath = str_replace(
'>',
'>',$xmlPath);
588 echo
" </dm:open>$xmlPath</dm:open>\n";
589 echo
"</dm:mount>\n";
613 foreach ($objectPath as $object)
615 if ($object->getRefId() == 1 && $this->
isFileHidden($object))
620 $fullPath .=
'/ref_1';
624 $fullPath .=
'/'.$this->davUrlEncode($object->getResourceName());
629 $shortenedPath =
'/ref_'.
630 $objectPath[count($objectPath) - 1]->getRefId();
633 if ($objDAV->isCollection())
635 $shortenedPath .=
'/';
640 $shortenedPath =
'/'.CLIENT_ID.$shortenedPath;
641 $fullPath =
'/'.CLIENT_ID.$fullPath;
646 $webfolderURI = $this->base_uri.$shortenedPath;
648 substr($this->base_uri, strrpos($this->base_uri,
':')).
652 substr($this->base_uri, strrpos($this->base_uri,
':')).
655 $webfolderURI_IE = $this->base_uri.$shortenedPath;
657 $webfolderTitle = $objectPath[count($objectPath) - 1]->getResourceName();
659 header(
'Content-Type: text/html; charset=UTF-8');
660 echo
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
661 echo
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
662 echo
" \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
663 echo
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
665 echo
" <title>".sprintf($lng->txt(
'webfolder_instructions_titletext'), $webfolderTitle).
"</title>\n";
670 $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
671 $this->clientOS,$this->clientOSFlavor);
686 private function getDir(&$objDAV, &$options)
700 if (
$path.
'/' != $options[
'path'])
702 header(
'Location: '.$this->base_uri.$path.
'/');
706 header(
'Content-Type: text/html; charset=UTF-8');
709 $format =
"%15s %-19s %-s\n";
711 echo
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
712 echo
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
713 echo
" \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
714 echo
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
716 echo
"<title>".sprintf($lng->txt(
'webfolder_index_of'),
$path).
"</title>\n";
720 echo
"<style type=\"text/css\">\n";
723 echo
" behavior:url(#default#AnchorClick);\n";
728 echo
"</head><body>\n";
731 $pathComponents = explode(
'/',
$path);
732 $uriComponents = array();
733 foreach ($pathComponents as $component)
737 for ($i = 0; $i < count($pathComponents); $i++)
739 $displayName = htmlspecialchars($pathComponents[$i]);
743 $uriPath = implode(
'/', array_slice($uriComponents,0,$i + 1));
749 $hrefPath .= $displayName;
753 $hrefPath .=
'<a href="'.$this->base_uri.$uriPath.
'/">'.$displayName.
'</a>';
756 echo
"<h3>".sprintf($lng->txt(
'webfolder_index_of'), $hrefPath).
"</h3>\n";
759 if ($ilias->account->getLogin() ==
'anonymous')
761 echo
"<p><font size=\"-1\">".$lng->txt(
'not_logged_in').
"</font><br>\n";
763 echo
"<p><font size=\"-1\">".$lng->txt(
'login_as').
" <i>"
764 .$ilias->account->getFirstname().
' '
765 .$ilias->account->getLastname().
' '
766 .
' '.$ilias->account->getLogin().
'</i> '
767 .
', '.$lng->txt(
'client').
' <i>'.$ilias->getClientId().
'</i>.'
772 $href = $this->base_uri.$uriPath;
775 if (count($pathComponents) > 2)
777 $hrefIE = $this->base_uri.
'/'.CLIENT_ID.
'/ref_'.$objDAV->getRefId();
781 echo
"<p><font size=\"-1\">".
782 sprintf($lng->txt(
'webfolder_dir_info'),
"$href?mount-instructions").
784 echo
"<p><font size=\"-1\">".
785 sprintf($lng->txt(
'webfolder_mount_dir_with'),
786 "$hrefIE\" folder=\"$hrefIE",
787 'webdav'.substr($href,4),
788 'dav'.substr($href,4),
794 printf($format, $lng->txt(
'size'), $lng->txt(
'last_change'), $lng->txt(
'filename'));
797 $collectionCount = 0;
799 $children =& $objDAV->childrenWithPermission(
'visible');
800 foreach ($children as $childDAV) {
801 if ($childDAV->isCollection() && !$this->
isFileHidden($childDAV))
804 $name = $this->
davUrlEncode($childDAV->getResourceName());
807 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
808 '<a href="'.$name.
'/'.
'">'.$childDAV->getDisplayName().
"</a>");
811 foreach ($children as $childDAV) {
812 if ($childDAV->isFile() && !$this->
isFileHidden($childDAV))
815 $name = $this->
davUrlEncode($childDAV->getResourceName());
817 number_format($childDAV->getContentLength()),
818 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
819 '<a href="'.$name.
'">'.$childDAV->getDisplayName().
"</a>");
822 foreach ($children as $childDAV) {
823 if ($childDAV->isNullResource() && !$this->
isFileHidden($childDAV))
825 $name = $this->
davUrlEncode($childDAV->getResourceName());
828 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
829 '<a href="'.$name.
'">'.$childDAV->getDisplayName().
"</a>");
833 echo $collectionCount.
' '.$lng->txt(($collectionCount == 1) ?
'folder' :
'folders').
', ';
834 echo $fileCount.
' '.$lng->txt(($fileCount == 1) ?
'file' :
'files').
'.';
836 echo
"</body></html>\n";
848 public function PUT(&$options)
852 $this->
writelog(
'PUT('.var_export($options,
true).
')');
855 $parent = dirname(
$path);
862 if (is_null($parentDAV) || ! $parentDAV->isCollection()) {
863 return '409 Conflict';
869 if ($options[
'content_length'] != null &&
872 $this->
writelog(
'PUT is forbidden, because content length='.
873 $options[
'content_length'].
' is larger than upload_max_filesize='.
876 return '403 Forbidden';
880 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
884 if (is_null($objDAV))
886 if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()))
888 $this->
writelog(
'PUT is forbidden, because user has no create permission');
889 return '403 Forbidden';
891 $options[
"new"] =
true;
892 $objDAV =& $parentDAV->createFile($name);
893 $this->
writelog(
'PUT obj='.$objDAV.
' name='.$name.
' content_type='.$options[
'content_type']);
895 $objDAV->setContentType($mime);
896 if ($options[
'content_length'] != null)
898 $objDAV->setContentLength($options[
'content_length']);
908 else if ($objDAV->isNullResource())
910 if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()))
912 $this->
writelog(
'PUT is forbidden, because user has no create permission');
913 return '403 Forbidden';
915 $options[
"new"] =
false;
916 $objDAV =& $parentDAV->createFileFromNull($name, $objDAV);
917 $this->
writelog(
'PUT obj='.$objDAV.
' name='.$name.
' content_type='.$options[
'content_type']);
919 $objDAV->setContentType($mime);
920 if ($options[
'content_length'] != null)
922 $objDAV->setContentLength($options[
'content_length']);
934 if (! $objDAV->isPermitted(
'write'))
936 $this->
writelog(
'PUT is forbidden, because user has no write permission');
937 return '403 Forbidden';
939 $options[
"new"] =
false;
940 $this->
writelog(
'PUT obj='.$objDAV.
' name='.$name.
' content_type='.$options[
'content_type'].
' content_length='.$options[
'content_length']);
943 if ($objDAV->getContentLength() != 0) {
944 $objDAV->createNewVersion();
948 $objDAV->setContentType($mime);
949 if ($options[
'content_length'] != null)
951 $objDAV->setContentLength($options[
'content_length']);
963 $this->putObjDAV = $objDAV;
965 $out =& $objDAV->getContentOutputStream();
978 $this->
writelog(
'PUTfinished('.var_export($options,
true).
')');
982 if ($options[
'content_length'] == null)
985 $objDAV->setContentLength($objDAV->getContentOutputStreamLength());
987 $this->putObjDAV = null;
1003 $this->
writelog(
'MKCOL('.var_export($options,
true).
')');
1004 $this->
writelog(
'MKCOL '.$options[
'path']);
1007 $parent =& dirname(
$path);
1011 if(!empty($_SERVER[
"CONTENT_LENGTH"])) {
1012 return "415 Unsupported media type";
1017 if (! is_null($objDAV))
1019 return '405 Method not allowed';
1023 $parentDAV =& $this->
getObject($parent);
1026 if (is_null($parentDAV) || ! $parentDAV->isCollection())
1028 return '409 Conflict';
1031 if (! $parentDAV->isPermitted(
'create',$parentDAV->getILIASCollectionType()))
1033 return '403 Forbidden';
1038 $objDAV = $parentDAV->createCollection($name);
1040 if ($objDAV != null)
1049 $result = ($objDAV != null) ?
"201 Created" :
"409 Conflict";
1064 $this->
writelog(
'DELETE('.var_export($options,
true).
')');
1065 $this->
writelog(
'DELETE '.$options[
'path']);
1073 if (is_null($objDAV) || $objDAV->isNullResource())
1075 return '404 Not Found';
1077 if (! $objDAV->isPermitted(
'delete'))
1079 return '403 Forbidden';
1082 $parentDAV->remove($objDAV);
1090 return '204 No Content';
1103 $this->
writelog(
'MOVE('.var_export($options,
true).
')');
1104 $this->
writelog(
'MOVE '.$options[
'path'].
' '.$options[
'dest']);
1108 $srcParent = dirname($src);
1112 $dstParent = dirname($dst);
1114 $this->
writelog(
'move '.$dst.
' dstname='.$dstName);
1118 return '409 Conflict (source and destination are the same)';
1122 if (substr($dst,strlen($src)+1) == $src.
'/')
1124 return '409 Conflict (destination is in subtree of source)';
1130 $srcParentDAV =& $this->
getObject($srcParent);
1131 $dstParentDAV =& $this->
getObject($dstParent);
1134 if ($srcDAV == null)
1136 return '409 Conflict (source does not exist)';
1140 $isOverwritten =
false;
1141 if ($dstDAV != null)
1143 if ($options[
'overwrite'] ==
'T')
1146 if ($dstDAV->isPermitted(
'delete'))
1148 $dstParentDAV->remove($dstDAV);
1150 $isOverwritten =
true;
1152 return '403 Not Permitted';
1155 return '412 Precondition Failed';
1160 if ($dstParentDAV == null)
1162 return '409 Conflict (parent of destination does not exist)';
1165 if ($srcParent == $dstParent)
1170 if (! $srcDAV->isPermitted(
'write'))
1172 return '403 Forbidden';
1174 $this->
writelog(
'rename dstName='.$dstName);
1175 $srcDAV->setResourceName($dstName);
1181 if (! $srcDAV->isPermitted(
'delete'))
1183 return '403 Forbidden';
1186 if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
1188 return '403 Forbidden';
1190 $dstParentDAV->addMove($srcDAV, $dstName);
1207 return ($isOverwritten) ?
'204 No Content' :
'201 Created';
1216 public function COPY($options, $del=
false)
1219 $this->
writelog(
'COPY('.var_export($options,
true).
' ,del='.$del.
')');
1220 $this->
writelog(
'COPY '.$options[
'path'].
' '.$options[
'dest']);
1223 if (isset($options[
"dest_url"])) {
1224 return "502 bad gateway";
1228 $srcParent = dirname($src);
1231 $dstParent = dirname($dst);
1237 return '409 Conflict';
1240 if (substr($dst,strlen($src)+1) == $src.
'/')
1242 return '409 Conflict';
1245 $this->
writelog(
'COPY src='.$src.
' dst='.$dst);
1249 $dstParentDAV =& $this->
getObject($dstParent);
1251 if (is_null($srcDAV) || $srcDAV->isNullResource())
1253 return '409 Conflict';
1255 if (is_null($dstParentDAV) || $dstParentDAV->isNullResource())
1257 return '409 Conflict';
1259 $isOverwritten =
false;
1262 if (! is_null($dstDAV))
1264 if ($options[
'overwrite'] ==
'T')
1266 if ($dstDAV->isPermitted(
'delete'))
1268 $dstParentDAV->remove($dstDAV);
1275 $isOverwritten =
true;
1277 return '403 Forbidden';
1280 return '412 Precondition Failed';
1284 if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
1286 return '403 Forbidden';
1288 $dstDAV = $dstParentDAV->addCopy($srcDAV, $dstName);
1297 return ($isOverwritten) ?
'204 No Content' :
'201 Created';
1308 $this->
writelog(
'PROPPATCH(options='.var_export($options,
true).
')');
1309 $this->
writelog(
'PROPPATCH '.$options[
'path']);
1316 if (is_null($objDAV) || $objDAV->isNullResource())
return false;
1318 $isPermitted = $objDAV->isPermitted(
'write');
1319 foreach($options[
'props'] as $key => $prop) {
1320 if (!$isPermitted || $prop[
'ns'] ==
'DAV:')
1322 $options[
'props'][$key][
'status'] =
'403 Forbidden';
1324 $this->properties->put($objDAV, $prop[
'ns'],$prop[
'name'],$prop[
'val']);
1341 $this->
writelog(
'LOCK('.var_export($options,
true).
')');
1342 $this->
writelog(
'LOCK '.$options[
'path']);
1349 if (is_null($objDAV))
1351 $this->
writelog(
'LOCK handling null-object locking...');
1354 if (isset($options[
"update"]))
1356 $this->
writelog(
'LOCK lock-update failed on non-existing null-object.');
1357 return '412 Precondition Failed';
1360 $parent = dirname(
$path);
1361 $parentDAV =& $this->
getObject($parent);
1362 if (is_null($parentDAV))
1364 $this->
writelog(
'LOCK lock failed on non-existing path to null-object.');
1365 return '404 Not Found';
1367 if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()) &&
1368 ! $parentDAV->isPermitted(
'create', $parentDAV->getILIASCollectionType()))
1370 $this->
writelog(
'LOCK lock failed - creation of null object not permitted.');
1371 return '403 Forbidden';
1379 if (! $objDAV->isNullResource() && ! $objDAV->isPermitted(
'write'))
1381 $this->
writelog(
'LOCK lock failed - user has no write permission.');
1382 return '403 Forbidden';
1386 if (!isset($options[
'timeout']) || is_array($options[
'timeout']))
1388 $options[
"timeout"] = time()+360;
1391 if(isset($options[
"update"])) {
1392 $this->
writelog(
'LOCK update token='.var_export($options,
true));
1393 $success = $this->locks->updateLockWithoutCheckingDAV(
1400 $data = $this->locks->getLockDAV($objDAV, $options[
'update']);
1401 if (
$data[
'ilias_owner'] == $ilias->account->getId())
1403 $owner =
$data[
'dav_owner'];
1405 $owner =
'<D:href>'.$this->getLogin(
$data[
'ilias_owner']).
'</D:href>';
1407 $options[
'owner'] = $owner;
1408 $options[
'locktoken'] =
$data[
'token'];
1409 $options[
'timeout'] =
$data[
'expires'];
1410 $options[
'depth'] =
$data[
'depth'];
1411 $options[
'scope'] =
$data[
'scope'];
1412 $options[
'type'] =
$data[
'scope'];
1416 $this->
writelog(
'LOCK create new lock');
1425 $this->
writelog(
'lock owner='.$owner);
1426 $success = $this->locks->lockWithoutCheckingDAV(
1428 $ilias->account->getId(),
1429 trim($options[
'owner']),
1430 $options[
'locktoken'],
1431 $options[
'timeout'],
1452 global
$log, $ilias;
1453 $this->
writelog(
'UNLOCK(options='.var_export($options,
true).
')');
1454 $this->
writelog(
'UNLOCK '.$options[
'path']);
1459 if (is_null($objDAV)) {
1460 return '404 Not Found';
1462 if (! $objDAV->isPermitted(
'write')) {
1463 return '403 Forbidden';
1466 $success = $this->locks->unlockWithoutCheckingDAV(
1473 if ($objDAV->isNullResource()
1474 && count($this->locks->getLocksOnObjectDAV($objDAV)) == 0)
1477 $parentDAV =& $this->
getObject($parent);
1478 $parentDAV->remove($objDAV);
1484 return (
$success) ?
'200 OK' :
'412 Precondition Failed';
1511 if (! is_null($objPath))
1513 $objDAV = $objPath[count($objPath) - 1];
1514 $locks = $this->locks->getLocksOnPathDAV($objPath);
1515 foreach (
$locks as $lock)
1517 $isLastPathComponent = $lock[
'obj_id'] == $objDAV->getObjectId()
1518 && $lock[
'node_id'] == $objDAV->getNodeId();
1522 if ($isLastPathComponent || $lock[
'depth'] ==
'infinity')
1528 if ($lock[
'ilias_owner'] == $ilias->account->getId())
1530 $owner = $lock[
'dav_owner'];
1532 $owner = $this->
getLogin($lock[
'ilias_owner']);
1539 "obj_id" => $lock[
'obj_id'],
1540 "node_id" => $lock[
'node_id'],
1541 "scope" => $lock[
'scope'],
1542 "depth" => $lock[
'depth'],
1544 "token" => $lock[
'token'],
1545 "expires" => $lock[
'expires']
1547 if ($lock[
'scope'] ==
'exclusive')
1570 $this->
writelog(
'getLogin('.$userId.
'):'.var_export($login,
true));
1589 $davPathComponents = split(
'/',substr($davPath,1));
1590 if (count($davPathComponents) > 1 &&
1591 substr($davPathComponents[1],0,5) ==
'file_')
1593 $ref_id = substr($davPathComponents[1],5);
1594 $nodePath = $tree->getNodePath(
$ref_id, $tree->root_id);
1598 header(
'Pragma: private');
1603 if ($nodePath == null && count($davPathComponents) == 1)
1608 if (is_null($nodePath))
1612 $top = $nodePath[count($nodePath) - 1];
1624 $this->
writelog(
'toObjectPath('.$davPath);
1628 if (is_null($nodePath))
1632 $objectPath = array();
1633 foreach ($nodePath as $node)
1636 if (is_null($pathElement))
1640 $objectPath[] = $pathElement;
1660 $this->
writelog(
'toNodePath('.$davPath.
')...');
1663 $titlePath = split(
'/',substr($davPath,1));
1666 if (count($titlePath) > 0)
1668 array_shift($titlePath);
1672 if (count($titlePath) > 0 && $titlePath[count($titlePath) - 1] ==
'')
1674 array_pop($titlePath);
1678 if (count($titlePath) == 0)
1680 $this->
writelog(
'toNodePath('.$davPath.
'):null, because path is empty.');
1688 if (count($titlePath) > 0 && substr($titlePath[0],0,4) ==
'ref_')
1690 $ref_id = substr($titlePath[0],4);
1691 array_shift($titlePath);
1694 $nodePath = $tree->getNodePathForTitlePath($titlePath,
$ref_id);
1696 $this->
writelog(
'toNodePath():'.var_export($nodePath,
true));
1725 $components = split(
'/',
$path);
1726 return count($components) == 0 ?
'' : $components[count($components) - 1];
1743 if ($message ==
'---')
1748 $ilias->account->getLogin()
1749 .
' '.$_SERVER[
'REMOTE_ADDR'].
':'.$_SERVER[
'REMOTE_PORT']
1750 .
' ilDAVServer.'.str_replace(
"\n",
";",$message)
1756 $fh = fopen(
'/opt/ilias/log/ilias.log',
'a');
1757 fwrite($fh, date(
'Y-m-d H:i:s '));
1758 fwrite($fh, str_replace(
"\n",
";",$message));
1759 fwrite($fh,
"\n\n");
1777 function getMountURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null, $genericURI =
false)
1782 }
else if ($this->clientOS ==
'windows') {
1784 $query =
'mount-instructions';
1785 }
else if ($this->clientBrowser ==
'konqueror') {
1788 }
else if ($this->clientBrowser ==
'nautilus') {
1793 $query =
'mount-instructions';
1795 $baseUri.=
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1796 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1798 $uri = $baseUri.
'/ref_'.$refId.
'/';
1820 function getFolderURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null)
1822 if ($this->clientOS ==
'windows') {
1825 }
else if ($this->clientBrowser ==
'konqueror') {
1828 }
else if ($this->clientBrowser ==
'nautilus') {
1835 $baseUri.=
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1836 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1838 $uri = $baseUri.
'/ref_'.$refId.
'/';
1857 public function getObjectURI($refId, $ressourceName = null, $parentRefId = null)
1861 "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1862 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1864 if (! is_null($ressourceName) && ! is_null($parentRefId))
1867 $uri = $baseUri.
'/ref_'.$parentRefId.
'/'.$this->
davUrlEncode($ressourceName);
1871 $nodePath = $tree->getNodePath($refId);
1873 if (is_null($nodePath) || count($nodePath) < 2)
1878 $uri = $baseUri.
'/ref_'.$nodePath[count($nodePath) - 2][
'child'].
'/'.
1879 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1902 public function getFileURI($refId, $ressourceName = null, $parentRefId = null)
1906 "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1907 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1909 if (! is_null($ressourceName) && ! is_null($parentRefId))
1916 $nodePath = $tree->getNodePath($refId);
1918 if (is_null($nodePath) || count($nodePath) < 2)
1923 $uri = $baseUri.
'/file_'.$nodePath[count($nodePath) - 1][
'child'].
'/'.
1924 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1936 if ($this->isHTTPS == null) {
1938 require_once
'classes/class.ilHTTPS.php';
1940 $this->isHTTPS = $https->isDetected() || $ilSetting->get(
'https');
1955 global $ilClientIniFile;
1956 return $ilClientIniFile->readVariable(
'file_access',
'webdav_enabled') ==
'1' &&
1957 @include_once(
"Auth/HTTP.php");
1966 global $ilClientIniFile;
1967 return $ilClientIniFile->readVariable(
'file_access',
'webdav_actions_visible') ==
'1';
1982 return $lng->txt(
'webfolder_instructions_text');
2012 $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
2013 $os =
'unknown', $osFlavor =
'unknown')
2017 $settings =
new ilSetting(
'file_access');
2018 $str = $settings->get(
'custom_webfolder_instructions',
'');
2019 if (strlen($str) == 0 || ! $settings->get(
'custom_webfolder_instructions_enabled'))
2024 $str = str_replace(
"[WEBFOLDER_TITLE]", $webfolderTitle, $str);
2025 $str = str_replace(
"[WEBFOLDER_URI]", $webfolderURI, $str);
2026 $str = str_replace(
"[WEBFOLDER_URI_IE]", $webfolderURI_IE, $str);
2027 $str = str_replace(
"[WEBFOLDER_URI_KONQUEROR]", $webfolderURI_Konqueror, $str);
2028 $str = str_replace(
"[WEBFOLDER_URI_NAUTILUS]", $webfolderURI_Nautilus, $str);
2029 $str = str_replace(
"[ADMIN_MAIL]", $ilSetting->get(
"admin_email"), $str);
2034 $operatingSystem =
'WINDOWS';
2040 $operatingSystem =
'MAC';
2043 $operatingSystem =
'LINUX';
2046 $operatingSystem =
'LINUX';
2051 $operatingSystem =
'UNKNOWN';
2055 if ($operatingSystem !=
'UNKNOWN')
2057 $str = preg_replace(
'/\[IF_'.$operatingSystem.
'\]((?:.|\n)*)\[\/IF_'.$operatingSystem.
'\]/',
'\1', $str);
2058 $str = preg_replace(
'/\[IF_([A-Z_]+)\](?:(?:.|\n)*)\[\/IF_\1\]/',
'', $str);
2062 $str = preg_replace(
'/\[IF_([A-Z_]+)\]((?:.|\n)*)\[\/IF_\1\]/',
'\2', $str);
2073 $val = ini_get(
'upload_max_filesize');
2076 $last = strtolower($val[strlen($val)-1]);