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';
281 $files[
'files'][] =& $this->
fileinfo($encodedPath, $encodedPath, $objDAV);
284 if (!empty($options[
'depth'])) {
289 $breadthFirst = array($objDAV);
290 $objDAV->encodedPath = $encodedPath;
292 while (count($breadthFirst) > 0) {
294 $collectionDAV = array_shift($breadthFirst);
295 $childrenDAV =& $collectionDAV->childrenWithPermission(
'visible');
296 foreach ($childrenDAV as $childDAV)
300 foreach ($childrenDAV as $duplChildDAV)
302 if ($duplChildDAV->getObjectId() < $childDAV->getObjectId() &&
303 $duplChildDAV->getResourceName() == $childDAV->getResourceName())
312 $this->
writelog(
'PROPFIND() child ref_id='.$childDAV->getRefId());
314 $collectionDAV->encodedPath.
'/'.$this->davUrlEncode($childDAV->getResourceName()),
315 $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());
336 $this->
writelog(
'PROPFIND():true options='.var_export($options,
true).
' files='.var_export(
$files,
true));
353 if ($objDAV->isNullResource()) {
354 if (count($this->locks->getLocksOnObjectDAV($objDAV)) == 0) {
359 $name = $objDAV->getResourceName();
360 $isFileHidden =
false;
361 switch ($this->clientOS)
367 || substr(
$name, 0, 2) ==
'~$';
369 $isFileHidden |= preg_match(
'/\\//',
$name);
373 $isFileHidden = substr(
$name, 0, 1) ==
'.';
375 $isFileHidden |= preg_match(
'/\\\\|\\/|:|\\*|\\?|"|<|>|\\|/',
$name);
379 $isFileHidden |= preg_match(
'/\\//',
$name);
382 $this->
writelog($this->clientOS.
' '.
$name.
' isHidden:'.$isFileHidden.
' clientOS:'.$this->clientOS);
383 return $isFileHidden;
393 private function fileinfo($resourcePath, $displayPath, &$objDAV)
397 $this->
writelog(
'fileinfo('.$resourcePath.
')');
404 if ($objDAV->isCollection() && $this->clientOSFlavor !=
'osx') {
405 $info[
'path'] = $resourcePath.
'/';
407 $info[
'path'] = $resourcePath;
410 $info[
'props'] = array();
413 $info[
"props"][] =& $this->
mkprop(
"displayname", $displayPath);
416 $info[
"props"][] =& $this->
mkprop(
"creationdate", $objDAV->getCreationTimestamp());
417 $info[
"props"][] =& $this->
mkprop(
"getlastmodified", $objDAV->getModificationTimestamp());
420 $info[
"props"][] =& $this->
mkprop(
"resourcetype", $objDAV->getResourceType());
421 $info[
"props"][] =& $this->
mkprop(
"getcontenttype", $objDAV->getContentType());
422 $info[
"props"][] =& $this->
mkprop(
"getcontentlength", $objDAV->getContentLength());
425 if ($objDAV->isPermitted(
'write'))
427 $info[
"props"][] =& $this->
mkprop(
"supportedlock",
429 .
'<D:lockscope><D:exclusive/></D:lockscope>'
430 .
'<D:locktype><D:write/></D:locktype>'
433 .
'<D:lockscope><D:shared/></D:lockscope>'
434 .
'<D:locktype><D:write/></D:locktype>'
442 $locks = $this->locks->getLocksOnObjectDAV($objDAV);
450 if ($lock[
'ilias_owner'] == $ilias->account->getId())
452 $owner = $lock[
'dav_owner'];
454 $owner =
'<D:href>'.$this->getLogin($lock[
'ilias_owner']).
'</D:href>';
456 $this->
writelog(
'lockowner='.$owner.
' ibi:'.$lock[
'ilias_owner'].
' davi:'.$lock[
'dav_owner']);
460 .
'<D:lockscope><D:'.$lock[
'scope'].
'/></D:lockscope>'
462 .
'<D:locktype><D:write/></D:locktype>'
463 .
'<D:depth>'.$lock[
'depth'].
'</D:depth>'
464 .
'<D:owner>'.$owner.
'</D:owner>'
468 .
'<D:timeout>Second-'.(($lock[
'expires'] > 1000000) ? $lock[
'expires']-time():$lock[
'expires']).
'</D:timeout>'
469 .
'<D:locktoken><D:href>'.$lock[
'token'].
'</D:href></D:locktoken>'
473 if (strlen($lockdiscovery) > 0)
475 $info[
"props"][] =& $this->
mkprop(
"lockdiscovery", $lockdiscovery);
482 $info[
"props"][] = $this->
mkprop($prop[
'namespace'], $prop[
'name'], $prop[
'value']);
500 public function GET(&$options)
504 $this->
writelog(
'GET('.var_export($options,
true).
')');
505 $this->
writelog(
'GET('.$options[
'path'].
')');
512 if (is_null($objDAV) || $objDAV->isNullResource())
517 if (! $objDAV->isPermitted(
'visible,read'))
519 return '403 Forbidden';
523 if ($objDAV->isCollection())
525 if (isset(
$_GET[
'mount']))
527 return $this->
mountDir($objDAV, $options);
528 }
else if (isset(
$_GET[
'mount-instructions']))
532 return $this->
getDir($objDAV, $options);
536 $options[
'mimetype'] =& $objDAV->getContentType();
541 $options[
'mtime'] =& $objDAV->getModificationTimestamp();
544 $options[
'size'] =& $objDAV->getContentLength();
547 $options[
'stream'] =& $objDAV->getContentStream();
548 if (is_null($options[
'stream']))
550 $options[
'data'] =& $objDAV->getContentData();
558 $this->
writelog(
'GET:'.var_export($options,
true));
577 header(
'Content-Type: application/davmount+xml');
579 echo
"<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n";
580 echo
" </dm:url>".$this->base_uri.
"</dm:url>\n";
582 $xmlPath = str_replace(
'&',
'&',
$path);
583 $xmlPath = str_replace(
'<',
'<',$xmlPath);
584 $xmlPath = str_replace(
'>',
'>',$xmlPath);
586 echo
" </dm:open>$xmlPath</dm:open>\n";
587 echo
"</dm:mount>\n";
611 foreach ($objectPath as $object)
613 if ($object->getRefId() == 1 && $this->
isFileHidden($object))
618 $fullPath .=
'/ref_1';
622 $fullPath .=
'/'.$this->davUrlEncode($object->getResourceName());
627 $shortenedPath =
'/ref_'.
628 $objectPath[count($objectPath) - 1]->getRefId();
630 if ($objDAV->isCollection())
632 $shortenedPath .=
'/';
637 $shortenedPath =
'/'.CLIENT_ID.$shortenedPath;
638 $fullPath =
'/'.CLIENT_ID.$fullPath;
643 $webfolderURI = $this->base_uri.$shortenedPath;
645 substr($this->base_uri, strrpos($this->base_uri,
':')).
649 substr($this->base_uri, strrpos($this->base_uri,
':')).
652 $webfolderURI_IE = $this->base_uri.$shortenedPath;
654 $webfolderTitle = $objectPath[count($objectPath) - 1]->getResourceName();
656 header(
'Content-Type: text/html; charset=UTF-8');
657 echo
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
658 echo
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
659 echo
" \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
660 echo
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
662 echo
" <title>".sprintf($lng->txt(
'webfolder_instructions_titletext'), $webfolderTitle).
"</title>\n";
667 $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
668 $this->clientOS,$this->clientOSFlavor);
683 private function getDir(&$objDAV, &$options)
697 if (
$path.
'/' != $options[
'path'])
699 header(
'Location: '.$this->base_uri.$path.
'/');
703 header(
'Content-Type: text/html; charset=UTF-8');
706 $format =
"%15s %-19s %-s\n";
708 echo
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
709 echo
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
710 echo
" \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
711 echo
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
713 echo
"<title>".sprintf($lng->txt(
'webfolder_index_of'),
$path).
"</title>\n";
717 echo
"<style type=\"text/css\">\n";
720 echo
" behavior:url(#default#AnchorClick);\n";
725 echo
"</head><body>\n";
728 $pathComponents = explode(
'/',
$path);
729 $uriComponents = array();
730 foreach ($pathComponents as $component)
734 for ($i = 0; $i < count($pathComponents); $i++)
736 $displayName = htmlspecialchars($pathComponents[$i]);
740 $uriPath = implode(
'/', array_slice($uriComponents,0,$i + 1));
746 $hrefPath .= $displayName;
750 $hrefPath .=
'<a href="'.$this->base_uri.$uriPath.
'/">'.$displayName.
'</a>';
753 echo
"<h3>".sprintf($lng->txt(
'webfolder_index_of'), $hrefPath).
"</h3>\n";
756 if ($ilias->account->getLogin() ==
'anonymous')
758 echo
"<p><font size=\"-1\">".$lng->txt(
'not_logged_in').
"</font><br>\n";
760 echo
"<p><font size=\"-1\">".$lng->txt(
'login_as').
" <i>"
761 .$ilias->account->getFirstname().
' '
762 .$ilias->account->getLastname().
' '
763 .
' '.$ilias->account->getLogin().
'</i> '
764 .
', '.$lng->txt(
'client').
' <i>'.$ilias->getClientId().
'</i>.'
769 $href = $this->base_uri.$uriPath;
772 if (count($pathComponents) > 2)
774 $hrefIE = $this->base_uri.
'/'.CLIENT_ID.
'/ref_'.$objDAV->getRefId();
778 echo
"<p><font size=\"-1\">".
779 sprintf($lng->txt(
'webfolder_dir_info'),
"$href?mount-instructions").
781 echo
"<p><font size=\"-1\">".
782 sprintf($lng->txt(
'webfolder_mount_dir_with'),
783 "$hrefIE\" folder=\"$hrefIE",
784 'webdav'.substr($href,4),
785 'dav'.substr($href,4),
791 printf($format, $lng->txt(
'size'), $lng->txt(
'last_change'), $lng->txt(
'filename'));
794 $collectionCount = 0;
796 $children =& $objDAV->childrenWithPermission(
'visible');
797 foreach ($children as $childDAV) {
798 if ($childDAV->isCollection() && !$this->
isFileHidden($childDAV))
804 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
805 '<a href="'.
$name.
'/'.
'">'.$childDAV->getDisplayName().
"</a>");
808 foreach ($children as $childDAV) {
809 if ($childDAV->isFile() && !$this->
isFileHidden($childDAV))
814 number_format($childDAV->getContentLength()),
815 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
816 '<a href="'.
$name.
'">'.$childDAV->getDisplayName().
"</a>");
819 foreach ($children as $childDAV) {
820 if ($childDAV->isNullResource() && !$this->
isFileHidden($childDAV))
825 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
826 '<a href="'.
$name.
'">'.$childDAV->getDisplayName().
"</a>");
830 echo $collectionCount.
' '.$lng->txt(($collectionCount == 1) ?
'folder' :
'folders').
', ';
831 echo $fileCount.
' '.$lng->txt(($fileCount == 1) ?
'file' :
'files').
'.';
833 echo
"</body></html>\n";
845 public function PUT(&$options)
849 $this->
writelog(
'PUT('.var_export($options,
true).
')');
852 $parent = dirname(
$path);
859 if (is_null($parentDAV) || ! $parentDAV->isCollection()) {
860 return '409 Conflict';
866 if ($options[
'content_length'] != null &&
869 $this->
writelog(
'PUT is forbidden, because content length='.
870 $options[
'content_length'].
' is larger than upload_max_filesize='.
873 return '403 Forbidden';
877 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
881 if (is_null($objDAV))
883 $ttype = $parentDAV->getILIASFileType();
884 $isperm = $parentDAV->isPermitted(
'create', $ttype);
887 $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']);
907 else if ($objDAV->isNullResource())
909 if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()))
911 $this->
writelog(
'PUT is forbidden, because user has no create permission');
912 return '403 Forbidden';
914 $options[
"new"] =
false;
915 $objDAV =& $parentDAV->createFileFromNull(
$name, $objDAV);
916 $this->
writelog(
'PUT obj='.$objDAV.
' name='.
$name.
' content_type='.$options[
'content_type']);
918 $objDAV->setContentType($mime);
919 if ($options[
'content_length'] != null)
921 $objDAV->setContentLength($options[
'content_length']);
933 if (! $objDAV->isPermitted(
'write'))
935 $this->
writelog(
'PUT is forbidden, because user has no write permission');
936 return '403 Forbidden';
938 $options[
"new"] =
false;
939 $this->
writelog(
'PUT obj='.$objDAV.
' name='.
$name.
' content_type='.$options[
'content_type'].
' content_length='.$options[
'content_length']);
942 if ($objDAV->getContentLength() != 0) {
943 $objDAV->createNewVersion();
947 $objDAV->setContentType($mime);
948 if ($options[
'content_length'] != null)
950 $objDAV->setContentLength($options[
'content_length']);
962 $this->putObjDAV = $objDAV;
964 $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);
1629 if (is_null($nodePath))
1633 $objectPath = array();
1634 foreach ($nodePath as $node)
1637 if (is_null($pathElement))
1641 $objectPath[] = $pathElement;
1661 $this->
writelog(
'toNodePath('.$davPath.
')...');
1664 $titlePath = split(
'/',substr($davPath,1));
1667 if (count($titlePath) > 0)
1669 array_shift($titlePath);
1673 if (count($titlePath) > 0 && $titlePath[count($titlePath) - 1] ==
'')
1675 array_pop($titlePath);
1679 if (count($titlePath) == 0)
1681 $this->
writelog(
'toNodePath('.$davPath.
'):null, because path is empty.');
1689 if (count($titlePath) > 0 && substr($titlePath[0],0,4) ==
'ref_')
1691 $ref_id = substr($titlePath[0],4);
1692 array_shift($titlePath);
1695 $nodePath = $tree->getNodePathForTitlePath($titlePath,
$ref_id);
1697 $this->
writelog(
'toNodePath():'.var_export($nodePath,
true));
1726 $components = split(
'/',
$path);
1727 return count($components) == 0 ?
'' : $components[count($components) - 1];
1744 if ($message ==
'---')
1749 $ilias->account->getLogin()
1750 .
' '.$_SERVER[
'REMOTE_ADDR'].
':'.$_SERVER[
'REMOTE_PORT']
1751 .
' ilDAVServer.'.str_replace(
"\n",
";",$message)
1757 $fh = fopen(
'/opt/ilias/log/ilias.log',
'a');
1758 fwrite($fh, date(
'Y-m-d H:i:s '));
1759 fwrite($fh, str_replace(
"\n",
";",$message));
1760 fwrite($fh,
"\n\n");
1778 function getMountURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null, $genericURI =
false)
1783 }
else if ($this->clientOS ==
'windows') {
1785 $query =
'mount-instructions';
1786 }
else if ($this->clientBrowser ==
'konqueror') {
1789 }
else if ($this->clientBrowser ==
'nautilus') {
1794 $query =
'mount-instructions';
1796 $baseUri.=
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1797 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1799 $uri = $baseUri.
'/ref_'.$refId.
'/';
1821 function getFolderURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null)
1823 if ($this->clientOS ==
'windows') {
1826 }
else if ($this->clientBrowser ==
'konqueror') {
1829 }
else if ($this->clientBrowser ==
'nautilus') {
1836 $baseUri.=
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1837 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1839 $uri = $baseUri.
'/ref_'.$refId.
'/';
1858 public function getObjectURI($refId, $ressourceName = null, $parentRefId = null)
1862 "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1863 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1865 if (! is_null($ressourceName) && ! is_null($parentRefId))
1868 $uri = $baseUri.
'/ref_'.$parentRefId.
'/'.$this->
davUrlEncode($ressourceName);
1872 $nodePath = $tree->getNodePath($refId);
1874 if (is_null($nodePath) || count($nodePath) < 2)
1879 $uri = $baseUri.
'/ref_'.$nodePath[count($nodePath) - 2][
'child'].
'/'.
1880 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1903 public function getFileURI($refId, $ressourceName = null, $parentRefId = null)
1907 "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1908 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1910 if (! is_null($ressourceName) && ! is_null($parentRefId))
1917 $nodePath = $tree->getNodePath($refId);
1919 if (is_null($nodePath) || count($nodePath) < 2)
1924 $uri = $baseUri.
'/file_'.$nodePath[count($nodePath) - 1][
'child'].
'/'.
1925 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1937 if ($this->isHTTPS == null) {
1939 require_once
'classes/class.ilHTTPS.php';
1941 $this->isHTTPS = $https->isDetected() || $ilSetting->get(
'https');
1956 global $ilClientIniFile;
1957 return $ilClientIniFile->readVariable(
'file_access',
'webdav_enabled') ==
'1' &&
1958 @include_once(
"Auth/HTTP.php");
1967 global $ilClientIniFile;
1968 return $ilClientIniFile->readVariable(
'file_access',
'webdav_actions_visible') ==
'1';
1983 return $lng->txt(
'webfolder_instructions_text');
2013 $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
2014 $os =
'unknown', $osFlavor =
'unknown')
2018 $settings =
new ilSetting(
'file_access');
2019 $str = $settings->get(
'custom_webfolder_instructions',
'');
2020 if (strlen($str) == 0 || ! $settings->get(
'custom_webfolder_instructions_enabled'))
2025 $str = str_replace(
"[WEBFOLDER_TITLE]", $webfolderTitle, $str);
2026 $str = str_replace(
"[WEBFOLDER_URI]", $webfolderURI, $str);
2027 $str = str_replace(
"[WEBFOLDER_URI_IE]", $webfolderURI_IE, $str);
2028 $str = str_replace(
"[WEBFOLDER_URI_KONQUEROR]", $webfolderURI_Konqueror, $str);
2029 $str = str_replace(
"[WEBFOLDER_URI_NAUTILUS]", $webfolderURI_Nautilus, $str);
2030 $str = str_replace(
"[ADMIN_MAIL]", $ilSetting->get(
"admin_email"), $str);
2035 $operatingSystem =
'WINDOWS';
2041 $operatingSystem =
'MAC';
2044 $operatingSystem =
'LINUX';
2047 $operatingSystem =
'LINUX';
2052 $operatingSystem =
'UNKNOWN';
2056 if ($operatingSystem !=
'UNKNOWN')
2058 $str = preg_replace(
'/\[IF_'.$operatingSystem.
'\]((?:.|\n)*)\[\/IF_'.$operatingSystem.
'\]/',
'\1', $str);
2059 $str = preg_replace(
'/\[IF_([A-Z_]+)\](?:(?:.|\n)*)\[\/IF_\1\]/',
'', $str);
2063 $str = preg_replace(
'/\[IF_([A-Z_]+)\]((?:.|\n)*)\[\/IF_\1\]/',
'\2', $str);
2074 $val = ini_get(
'upload_max_filesize');
2077 $last = strtolower($val[strlen($val)-1]);