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 if(strpos($userAgent,
'nt 5.1') !==
false){
152 $this->clientOSFlavor =
'xp';
154 $this->clientOSFlavor =
'nichtxp';
157 }
else if (strpos($userAgent,
'darwin') !==
false
158 || strpos($userAgent,
'macintosh') !==
false
159 || strpos($userAgent,
'linux') !==
false
160 || strpos($userAgent,
'solaris') !==
false
161 || strpos($userAgent,
'aix') !==
false
162 || strpos($userAgent,
'unix') !==
false
163 || strpos($userAgent,
'gvfs') !==
false
166 $this->clientOS =
'unix';
167 if (strpos($userAgent,
'linux') !==
false)
169 $this->clientOSFlavor =
'linux';
171 else if (strpos($userAgent,
'macintosh') !==
false)
173 $this->clientOSFlavor =
'osx';
176 if (strpos($userAgent,
'konqueror') !==
false)
178 $this->clientBrowser =
'konqueror';
188 if(self::$instance != NULL)
201 if (!self::_isActive())
203 $this->
writelog(__METHOD__.
' WebDAV disabled. Aborting');
205 echo
'<html><body><h1>Sorry</h1>'.
206 '<p><b>Please enable the WebDAV plugin in the ILIAS Administration panel.</b></p>'.
207 '<p>You can only access this page, if WebDAV is enabled on this server.</p>'.
214 $this->
writelog(
'serveRequest():'.$_SERVER[
'REQUEST_METHOD'].
' '.$_SERVER[
'PATH_INFO'].
' ...');
217 $this->
writelog(
'serveRequest():'.$_SERVER[
'REQUEST_METHOD'].
' done status='.$this->_http_status.
' elapsed='.($end - $start));
222 $this->
writelog(
'serveRequest():'.$_SERVER[
'REQUEST_METHOD'].
' caught exception: '.$e->getMessage().
'\n'.$e->getTraceAsString());
267 $c = explode(
'/',
$path);
268 for ($i = 0; $i < count($c); $i++)
270 $c[$i] = str_replace(
'+',
'%20',urlencode($c[$i]));
272 return implode(
'/',$c);
288 $this->
writelog(
'PROPFIND(options:'.var_export(
$options,
true).
' files:'.var_export($files,
true).
'.)');
296 $files[
'files'] = array();
299 if (is_null($objDAV)) {
302 if (! $objDAV->isPermitted(
'visible,read')) {
303 return '403 Forbidden';
310 $GLOBALS[
'ilLog']->write(print_r($encodedPath,
true));
312 $files[
'files'][] =& $this->
fileinfo($encodedPath, $encodedPath, $objDAV);
320 $breadthFirst = array($objDAV);
321 $objDAV->encodedPath = $encodedPath;
323 while (count($breadthFirst) > 0) {
325 $collectionDAV = array_shift($breadthFirst);
326 $childrenDAV =& $collectionDAV->childrenWithPermission(
'visible,read');
327 foreach ($childrenDAV as $childDAV)
331 foreach ($childrenDAV as $duplChildDAV)
333 if ($duplChildDAV->getObjectId() < $childDAV->getObjectId() &&
334 $duplChildDAV->getResourceName() == $childDAV->getResourceName())
343 $this->
writelog(
'PROPFIND() child ref_id='.$childDAV->getRefId());
344 $files[
'files'][] =& $this->
fileinfo(
345 $collectionDAV->encodedPath.
'/'.$this->davUrlEncode($childDAV->getResourceName()),
346 $collectionDAV->encodedPath.
'/'.$this->davUrlEncode($childDAV->getDisplayName()),
349 if (
$options[
'depth']==
'infinity' && $childDAV->isCollection()) {
351 $breadthFirst[] = $childDAV;
352 $childDAV->encodedPath = $collectionDAV->encodedPath.
'/'.$this->
davUrlEncode($childDAV->getResourceName());
363 $objDAV->getObjectId(), $ilUser->getId(),
false);
366 $this->
writelog(
'PROPFIND():true options='.var_export(
$options,
true).
' files='.var_export($files,
true));
383 if ($objDAV->isNullResource()) {
384 if (count($this->locks->getLocksOnObjectDAV($objDAV)) == 0) {
389 $name = $objDAV->getResourceName();
390 $isFileHidden =
false;
391 switch ($this->clientOS)
397 || substr($name, 0, 2) ==
'~$';
399 $isFileHidden |= preg_match(
'/\\//', $name);
403 $isFileHidden = substr($name, 0, 1) ==
'.';
405 $isFileHidden |= preg_match(
'/\\\\|\\/|:|\\*|\\?|"|<|>|\\|/', $name);
409 $isFileHidden |= preg_match(
'/\\//', $name);
412 $this->
writelog($this->clientOS.
' '.$name.
' isHidden:'.$isFileHidden.
' clientOS:'.$this->clientOS);
413 return $isFileHidden;
423 private function fileinfo($resourcePath, $displayPath, &$objDAV)
427 $this->
writelog(
'fileinfo('.$resourcePath.
')');
434 if ($objDAV->isCollection() && $this->clientOSFlavor !=
'osx') {
435 $info[
'path'] = $resourcePath.
'/';
437 $info[
'path'] = $resourcePath;
440 $info[
'props'] = array();
443 $info[
"props"][] =& $this->
mkprop(
"displayname", $displayPath);
446 $info[
"props"][] =& $this->
mkprop(
"creationdate", $objDAV->getCreationTimestamp());
447 $info[
"props"][] =& $this->
mkprop(
"getlastmodified", $objDAV->getModificationTimestamp());
450 $info[
"props"][] =& $this->
mkprop(
"resourcetype", $objDAV->getResourceType());
451 $info[
"props"][] =& $this->
mkprop(
"getcontenttype", $objDAV->getContentType());
452 $info[
"props"][] =& $this->
mkprop(
"getcontentlength", $objDAV->getContentLength());
455 if ($objDAV->isPermitted(
'write'))
457 $info[
"props"][] =& $this->
mkprop(
"supportedlock",
459 .
'<D:lockscope><D:exclusive/></D:lockscope>'
460 .
'<D:locktype><D:write/></D:locktype>'
463 .
'<D:lockscope><D:shared/></D:lockscope>'
464 .
'<D:locktype><D:write/></D:locktype>'
472 $locks = $this->locks->getLocksOnObjectDAV($objDAV);
480 if ($lock[
'ilias_owner'] == $ilias->account->getId())
482 $owner = $lock[
'dav_owner'];
484 $owner =
'<D:href>'.$this->getLogin($lock[
'ilias_owner']).
'</D:href>';
486 $this->
writelog(
'lockowner='.$owner.
' ibi:'.$lock[
'ilias_owner'].
' davi:'.$lock[
'dav_owner']);
490 .
'<D:lockscope><D:'.$lock[
'scope'].
'/></D:lockscope>'
492 .
'<D:locktype><D:write/></D:locktype>'
493 .
'<D:depth>'.$lock[
'depth'].
'</D:depth>'
494 .
'<D:owner>'.$owner.
'</D:owner>'
498 .
'<D:timeout>Second-'.(($lock[
'expires'] > 1000000) ? $lock[
'expires']-time():$lock[
'expires']).
'</D:timeout>'
499 .
'<D:locktoken><D:href>'.$lock[
'token'].
'</D:href></D:locktoken>'
503 if (strlen($lockdiscovery) > 0)
505 $info[
"props"][] =& $this->
mkprop(
"lockdiscovery", $lockdiscovery);
512 $info[
"props"][] = $this->
mkprop($prop[
'namespace'], $prop[
'name'], $prop[
'value']);
542 if (is_null($objDAV) || $objDAV->isNullResource())
547 if (! $objDAV->isPermitted(
'visible,read'))
549 return '403 Forbidden';
553 if ($objDAV->isCollection())
555 if (isset(
$_GET[
'mount']))
559 else if (isset(
$_GET[
'mount-instructions']))
569 $options[
'mimetype'] =& $objDAV->getContentType();
574 $options[
'mtime'] =& $objDAV->getModificationTimestamp();
577 $options[
'size'] =& $objDAV->getContentLength();
580 $options[
'stream'] =& $objDAV->getContentStream();
583 $options[
'data'] =& $objDAV->getContentData();
588 $objDAV->getObjectId(), $ilUser->getId());
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)
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,read');
837 foreach ($children as $childDAV) {
838 if ($childDAV->isCollection() && !$this->
isFileHidden($childDAV))
841 $name = $this->
davUrlEncode($childDAV->getResourceName());
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))
852 $name = $this->
davUrlEncode($childDAV->getResourceName());
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))
862 $name = $this->
davUrlEncode($childDAV->getResourceName());
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";
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';
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']);
944 else if ($objDAV->isNullResource())
946 if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()))
948 $this->
writelog(
'PUT is forbidden, because user has no create permission');
949 return '403 Forbidden';
952 $objDAV =& $parentDAV->createFileFromNull($name, $objDAV);
953 $this->
writelog(
'PUT obj='.$objDAV.
' name='.$name.
' content_type='.
$options[
'content_type']);
955 $objDAV->setContentType($mime);
956 if (
$options[
'content_length'] != null)
958 $objDAV->setContentLength(
$options[
'content_length']);
967 if (! $objDAV->isPermitted(
'write'))
969 $this->
writelog(
'PUT is forbidden, because user has no write permission');
970 return '403 Forbidden';
973 $this->
writelog(
'PUT obj='.$objDAV.
' name='.$name.
' content_type='.
$options[
'content_type'].
' content_length='.
$options[
'content_length']);
976 if ($objDAV->getContentLength() != 0) {
977 $objDAV->createNewVersion();
981 $objDAV->setContentType($mime);
982 if ($options[
'content_length'] != null)
984 $objDAV->setContentLength($options[
'content_length']);
993 $this->putObjDAV = $objDAV;
995 $out =& $objDAV->getContentOutputStream();
1011 if($this->putObjDAV->getResourceType()==
""){
1012 $vir =
ilUtil::virusHandling($this->putObjDAV->obj->getDirectory($this->putObjDAV->obj->version).
'/'.$this->putObjDAV->obj->filename, $this->putObjDAV->obj->filename);
1013 if ($vir[0] ==
false)
1015 $this->
writelog(
'PUTfinished Virus found: '.$vir[1]);
1024 if (
$options[
'content_length'] == null)
1027 $objDAV->setContentLength($objDAV->getContentOutputStreamLength());
1029 $this->putObjDAV = null;
1049 $parent =& dirname(
$path);
1053 if(!empty($_SERVER[
"CONTENT_LENGTH"])) {
1054 return "415 Unsupported media type";
1059 if (! is_null($objDAV))
1061 return '405 Method not allowed';
1065 $parentDAV =& $this->
getObject($parent);
1068 if (is_null($parentDAV) || ! $parentDAV->isCollection())
1070 return '409 Conflict';
1073 if (! $parentDAV->isPermitted(
'create',$parentDAV->getILIASCollectionType()))
1075 return '403 Forbidden';
1080 $objDAV = $parentDAV->createCollection($name);
1082 if ($objDAV != null)
1088 $result = ($objDAV != null) ?
"201 Created" :
"409 Conflict";
1112 if (is_null($objDAV) || $objDAV->isNullResource())
1114 return '404 Not Found';
1116 if (! $objDAV->isPermitted(
'delete'))
1118 return '403 Forbidden';
1121 $parentDAV->remove($objDAV);
1126 return '204 No Content';
1144 $srcParent = dirname($src);
1148 $dstParent = dirname($dst);
1150 $this->
writelog(
'move '.$dst.
' dstname='.$dstName);
1154 return '409 Conflict (source and destination are the same)';
1158 if (substr($dst,strlen($src)+1) == $src.
'/')
1160 return '409 Conflict (destination is in subtree of source)';
1166 $srcParentDAV =& $this->
getObject($srcParent);
1167 $dstParentDAV =& $this->
getObject($dstParent);
1170 if ($srcDAV == null)
1172 return '409 Conflict (source does not exist)';
1176 $isOverwritten =
false;
1177 if ($dstDAV != null)
1179 if ($options[
'overwrite'] ==
'T')
1182 if ($dstDAV->isPermitted(
'delete'))
1184 $dstParentDAV->remove($dstDAV);
1186 $isOverwritten =
true;
1188 return '403 Not Permitted';
1191 return '412 Precondition Failed';
1196 if ($dstParentDAV == null)
1198 return '409 Conflict (parent of destination does not exist)';
1201 if ($srcParent == $dstParent)
1206 if (! $srcDAV->isPermitted(
'write'))
1208 return '403 Forbidden';
1210 $this->
writelog(
'rename dstName='.$dstName);
1211 $srcDAV->setResourceName($dstName);
1217 if (! $srcDAV->isPermitted(
'delete'))
1219 return '403 Forbidden';
1222 if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
1224 return '403 Forbidden';
1226 $dstParentDAV->addMove($srcDAV, $dstName);
1240 return ($isOverwritten) ?
'204 No Content' :
'201 Created';
1256 if (isset($options[
"dest_url"])) {
1257 return "502 bad gateway";
1261 $srcParent = dirname($src);
1264 $dstParent = dirname($dst);
1270 return '409 Conflict';
1273 if (substr($dst,strlen($src)+1) == $src.
'/')
1275 return '409 Conflict';
1278 $this->
writelog(
'COPY src='.$src.
' dst='.$dst);
1282 $dstParentDAV =& $this->
getObject($dstParent);
1284 if (is_null($srcDAV) || $srcDAV->isNullResource())
1286 return '409 Conflict';
1288 if (is_null($dstParentDAV) || $dstParentDAV->isNullResource())
1290 return '409 Conflict';
1292 $isOverwritten =
false;
1295 if (! is_null($dstDAV))
1297 if ($options[
'overwrite'] ==
'T')
1299 if ($dstDAV->isPermitted(
'delete'))
1301 $dstParentDAV->remove($dstDAV);
1305 $isOverwritten =
true;
1307 return '403 Forbidden';
1310 return '412 Precondition Failed';
1314 if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
1316 return '403 Forbidden';
1318 $dstDAV = $dstParentDAV->addCopy($srcDAV, $dstName);
1322 $srcDAV->getObjectId(), $ilUser->getId());
1325 return ($isOverwritten) ?
'204 No Content' :
'201 Created';
1344 if (is_null($objDAV) || $objDAV->isNullResource())
return false;
1346 $isPermitted = $objDAV->isPermitted(
'write');
1347 foreach(
$options[
'props'] as $key => $prop) {
1348 if (!$isPermitted || $prop[
'ns'] ==
'DAV:')
1350 $options[
'props'][$key][
'status'] =
'403 Forbidden';
1352 $this->properties->put($objDAV, $prop[
'ns'],$prop[
'name'],$prop[
'val']);
1377 if (is_null($objDAV))
1379 $this->
writelog(
'LOCK handling null-object locking...');
1384 $this->
writelog(
'LOCK lock-update failed on non-existing null-object.');
1385 return '412 Precondition Failed';
1388 $parent = dirname(
$path);
1389 $parentDAV =& $this->
getObject($parent);
1390 if (is_null($parentDAV))
1392 $this->
writelog(
'LOCK lock failed on non-existing path to null-object.');
1393 return '404 Not Found';
1395 if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()) &&
1396 ! $parentDAV->isPermitted(
'create', $parentDAV->getILIASCollectionType()))
1398 $this->
writelog(
'LOCK lock failed - creation of null object not permitted.');
1399 return '403 Forbidden';
1407 if (! $objDAV->isNullResource() && ! $objDAV->isPermitted(
'write'))
1409 $this->
writelog(
'LOCK lock failed - user has no write permission.');
1410 return '403 Forbidden';
1421 $success = $this->locks->updateLockWithoutCheckingDAV(
1428 $data = $this->locks->getLockDAV($objDAV,
$options[
'update']);
1429 if ($data[
'ilias_owner'] == $ilias->account->getId())
1431 $owner = $data[
'dav_owner'];
1433 $owner =
'<D:href>'.$this->getLogin($data[
'ilias_owner']).
'</D:href>';
1436 $options[
'locktoken'] = $data[
'token'];
1437 $options[
'timeout'] = $data[
'expires'];
1438 $options[
'depth'] = $data[
'depth'];
1439 $options[
'scope'] = $data[
'scope'];
1444 $this->
writelog(
'LOCK create new lock');
1453 $this->
writelog(
'lock owner='.$owner);
1454 $success = $this->locks->lockWithoutCheckingDAV(
1456 $ilias->account->getId(),
1480 global
$log, $ilias;
1487 if (is_null($objDAV)) {
1488 return '404 Not Found';
1490 if (! $objDAV->isPermitted(
'write')) {
1491 return '403 Forbidden';
1494 $success = $this->locks->unlockWithoutCheckingDAV(
1501 if ($objDAV->isNullResource()
1502 && count($this->locks->getLocksOnObjectDAV($objDAV)) == 0)
1505 $parentDAV =& $this->
getObject($parent);
1506 $parentDAV->remove($objDAV);
1512 return (
$success) ?
'200 OK' :
'412 Precondition Failed';
1539 if (! is_null($objPath))
1541 $objDAV = $objPath[count($objPath) - 1];
1542 $locks = $this->locks->getLocksOnPathDAV($objPath);
1543 foreach (
$locks as $lock)
1545 $isLastPathComponent = $lock[
'obj_id'] == $objDAV->getObjectId()
1546 && $lock[
'node_id'] == $objDAV->getNodeId();
1550 if ($isLastPathComponent || $lock[
'depth'] ==
'infinity')
1556 if ($lock[
'ilias_owner'] == $ilias->account->getId())
1558 $owner = $lock[
'dav_owner'];
1560 $owner = $this->
getLogin($lock[
'ilias_owner']);
1567 "obj_id" => $lock[
'obj_id'],
1568 "node_id" => $lock[
'node_id'],
1569 "scope" => $lock[
'scope'],
1570 "depth" => $lock[
'depth'],
1572 "token" => $lock[
'token'],
1573 "expires" => $lock[
'expires']
1575 if ($lock[
'scope'] ==
'exclusive')
1598 $this->
writelog(
'getLogin('.$userId.
'):'.var_export($login,
true));
1617 $davPathComponents = split(
'/',substr($davPath,1));
1618 if (count($davPathComponents) > 1 &&
1619 substr($davPathComponents[1],0,5) ==
'file_')
1621 $ref_id = substr($davPathComponents[1],5);
1622 $nodePath = $tree->getNodePath(
$ref_id, $tree->root_id);
1626 header(
'Pragma: private');
1631 if ($nodePath == null && count($davPathComponents) == 1)
1636 if (is_null($nodePath))
1640 $top = $nodePath[count($nodePath) - 1];
1652 $this->
writelog(
'toObjectPath('.$davPath);
1657 if (is_null($nodePath))
1661 $objectPath = array();
1662 foreach ($nodePath as $node)
1665 if (is_null($pathElement))
1669 $objectPath[] = $pathElement;
1689 $this->
writelog(
'toNodePath('.$davPath.
')...');
1692 $titlePath = split(
'/',substr($davPath,1));
1695 if (count($titlePath) > 0)
1697 array_shift($titlePath);
1701 if (count($titlePath) > 0 && $titlePath[count($titlePath) - 1] ==
'')
1703 array_pop($titlePath);
1707 if (count($titlePath) == 0)
1709 $this->
writelog(
'toNodePath('.$davPath.
'):null, because path is empty.');
1717 if (count($titlePath) > 0 && substr($titlePath[0],0,4) ==
'ref_')
1719 $ref_id = substr($titlePath[0],4);
1720 array_shift($titlePath);
1723 $nodePath = $tree->getNodePathForTitlePath($titlePath,
$ref_id);
1725 $this->
writelog(
'toNodePath():'.var_export($nodePath,
true));
1754 $components = split(
'/',
$path);
1755 return count($components) == 0 ?
'' : $components[count($components) - 1];
1772 if ($message ==
'---')
1777 $ilias->account->getLogin()
1778 .
' '.$_SERVER[
'REMOTE_ADDR'].
':'.$_SERVER[
'REMOTE_PORT']
1779 .
' ilDAVServer.'.str_replace(
"\n",
";",$message)
1785 $fh = fopen(
'/opt/ilias/log/ilias.log',
'a');
1786 fwrite($fh, date(
'Y-m-d H:i:s '));
1787 fwrite($fh, str_replace(
"\n",
";",$message));
1788 fwrite($fh,
"\n\n");
1806 function getMountURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null, $genericURI =
false)
1811 }
else if ($this->clientOS ==
'windows') {
1813 $query =
'mount-instructions';
1814 }
else if ($this->clientBrowser ==
'konqueror') {
1817 }
else if ($this->clientBrowser ==
'nautilus') {
1822 $query =
'mount-instructions';
1824 $baseUri.=
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1825 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1827 $uri = $baseUri.
'/ref_'.$refId.
'/';
1849 function getFolderURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null)
1851 if ($this->clientOS ==
'windows') {
1854 }
else if ($this->clientBrowser ==
'konqueror') {
1857 }
else if ($this->clientBrowser ==
'nautilus') {
1864 $baseUri.=
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1865 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1867 $uri = $baseUri.
'/ref_'.$refId.
'/';
1886 public function getObjectURI($refId, $ressourceName = null, $parentRefId = null)
1890 "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1891 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1893 if (! is_null($ressourceName) && ! is_null($parentRefId))
1896 $uri = $baseUri.
'/ref_'.$parentRefId.
'/'.$this->
davUrlEncode($ressourceName);
1900 $nodePath = $tree->getNodePath($refId);
1902 if (is_null($nodePath) || count($nodePath) < 2)
1907 $uri = $baseUri.
'/ref_'.$nodePath[count($nodePath) - 2][
'child'].
'/'.
1908 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1931 public function getFileURI($refId, $ressourceName = null, $parentRefId = null)
1935 "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1936 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1938 if (! is_null($ressourceName) && ! is_null($parentRefId))
1945 $nodePath = $tree->getNodePath($refId);
1947 if (is_null($nodePath) || count($nodePath) < 2)
1952 $uri = $baseUri.
'/file_'.$nodePath[count($nodePath) - 1][
'child'].
'/'.
1953 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1965 if ($this->isHTTPS == null) {
1967 require_once
'./Services/Http/classes/class.ilHTTPS.php';
1969 $this->isHTTPS =
$https->isDetected() || $ilSetting->get(
'https');
1984 global $ilClientIniFile;
1985 return $ilClientIniFile->readVariable(
'file_access',
'webdav_enabled') ==
'1' &&
1986 @include_once(
"Auth/HTTP.php");
1995 global $ilClientIniFile;
1996 return $ilClientIniFile->readVariable(
'file_access',
'webdav_actions_visible') ==
'1';
2011 return $lng->txt(
'webfolder_instructions_text');
2041 $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
2042 $os =
'unknown', $osFlavor =
'unknown')
2046 $settings =
new ilSetting(
'file_access');
2047 $str = $settings->get(
'custom_webfolder_instructions',
'');
2048 if (strlen($str) == 0 || ! $settings->get(
'custom_webfolder_instructions_enabled'))
2052 if(is_file(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm')){
2053 $str = fread(fopen(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm',
"rb"),filesize(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm'));
2055 $str=utf8_encode($str);
2057 preg_match_all(
'/(\\d+)/', $webfolderURI, $matches);
2058 $refID=$matches[0][0];
2060 $str = str_replace(
"[WEBFOLDER_ID]", $refID, $str);
2061 $str = str_replace(
"[WEBFOLDER_TITLE]", $webfolderTitle, $str);
2062 $str = str_replace(
"[WEBFOLDER_URI]", $webfolderURI, $str);
2063 $str = str_replace(
"[WEBFOLDER_URI_IE]", $webfolderURI_IE, $str);
2064 $str = str_replace(
"[WEBFOLDER_URI_KONQUEROR]", $webfolderURI_Konqueror, $str);
2065 $str = str_replace(
"[WEBFOLDER_URI_NAUTILUS]", $webfolderURI_Nautilus, $str);
2066 $str = str_replace(
"[ADMIN_MAIL]", $ilSetting->get(
"admin_email"), $str);
2068 if(strpos($_SERVER[
'HTTP_USER_AGENT'],
'MSIE')!==
false){
2069 $str = preg_replace(
'/\[IF_IEXPLORE\]((?:.|\n)*)\[\/IF_IEXPLORE\]/',
'\1', $str);
2071 $str = preg_replace(
'/\[IF_NOTIEXPLORE\]((?:.|\n)*)\[\/IF_NOTIEXPLORE\]/',
'\1', $str);
2077 $operatingSystem =
'WINDOWS';
2083 $operatingSystem =
'MAC';
2086 $operatingSystem =
'LINUX';
2089 $operatingSystem =
'LINUX';
2094 $operatingSystem =
'UNKNOWN';
2098 if ($operatingSystem !=
'UNKNOWN')
2100 $str = preg_replace(
'/\[IF_'.$operatingSystem.
'\]((?:.|\n)*)\[\/IF_'.$operatingSystem.
'\]/',
'\1', $str);
2101 $str = preg_replace(
'/\[IF_([A-Z_]+)\](?:(?:.|\n)*)\[\/IF_\1\]/',
'', $str);
2105 $str = preg_replace(
'/\[IF_([A-Z_]+)\]((?:.|\n)*)\[\/IF_\1\]/',
'\2', $str);
2116 $val = ini_get(
'upload_max_filesize');
2119 $last = strtolower($val[strlen($val)-1]);