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).
'.)');
289 $this->
writelog(
'PROPFIND '.$options[
'path']);
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);
315 if (!empty($options[
'depth'])) {
320 $breadthFirst = array($objDAV);
321 $objDAV->encodedPath = $encodedPath;
323 while (count($breadthFirst) > 0) {
325 $collectionDAV = array_shift($breadthFirst);
326 $childrenDAV =& $collectionDAV->childrenWithPermission(
'visible');
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());
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']);
530 public function GET(&$options)
534 $this->
writelog(
'GET('.var_export($options,
true).
')');
535 $this->
writelog(
'GET('.$options[
'path'].
')');
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']))
557 return $this->
mountDir($objDAV, $options);
559 else if (isset(
$_GET[
'mount-instructions']))
565 return $this->
getDir($objDAV, $options);
569 $options[
'mimetype'] =& $objDAV->getContentType();
574 $options[
'mtime'] =& $objDAV->getModificationTimestamp();
577 $options[
'size'] =& $objDAV->getContentLength();
580 $options[
'stream'] =& $objDAV->getContentStream();
581 if (is_null($options[
'stream']))
583 $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))
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";
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']);
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';
951 $options[
"new"] =
false;
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';
972 $options[
"new"] =
false;
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();
1009 $this->
writelog(
'PUTfinished('.var_export($options,
true).
')');
1013 if ($options[
'content_length'] == null)
1016 $objDAV->setContentLength($objDAV->getContentOutputStreamLength());
1018 $this->putObjDAV = null;
1034 $this->
writelog(
'MKCOL('.var_export($options,
true).
')');
1035 $this->
writelog(
'MKCOL '.$options[
'path']);
1038 $parent =& dirname(
$path);
1042 if(!empty($_SERVER[
"CONTENT_LENGTH"])) {
1043 return "415 Unsupported media type";
1048 if (! is_null($objDAV))
1050 return '405 Method not allowed';
1054 $parentDAV =& $this->
getObject($parent);
1057 if (is_null($parentDAV) || ! $parentDAV->isCollection())
1059 return '409 Conflict';
1062 if (! $parentDAV->isPermitted(
'create',$parentDAV->getILIASCollectionType()))
1064 return '403 Forbidden';
1069 $objDAV = $parentDAV->createCollection($name);
1071 if ($objDAV != null)
1077 $result = ($objDAV != null) ?
"201 Created" :
"409 Conflict";
1092 $this->
writelog(
'DELETE('.var_export($options,
true).
')');
1093 $this->
writelog(
'DELETE '.$options[
'path']);
1101 if (is_null($objDAV) || $objDAV->isNullResource())
1103 return '404 Not Found';
1105 if (! $objDAV->isPermitted(
'delete'))
1107 return '403 Forbidden';
1110 $parentDAV->remove($objDAV);
1115 return '204 No Content';
1128 $this->
writelog(
'MOVE('.var_export($options,
true).
')');
1129 $this->
writelog(
'MOVE '.$options[
'path'].
' '.$options[
'dest']);
1133 $srcParent = dirname($src);
1137 $dstParent = dirname($dst);
1139 $this->
writelog(
'move '.$dst.
' dstname='.$dstName);
1143 return '409 Conflict (source and destination are the same)';
1147 if (substr($dst,strlen($src)+1) == $src.
'/')
1149 return '409 Conflict (destination is in subtree of source)';
1155 $srcParentDAV =& $this->
getObject($srcParent);
1156 $dstParentDAV =& $this->
getObject($dstParent);
1159 if ($srcDAV == null)
1161 return '409 Conflict (source does not exist)';
1165 $isOverwritten =
false;
1166 if ($dstDAV != null)
1168 if ($options[
'overwrite'] ==
'T')
1171 if ($dstDAV->isPermitted(
'delete'))
1173 $dstParentDAV->remove($dstDAV);
1175 $isOverwritten =
true;
1177 return '403 Not Permitted';
1180 return '412 Precondition Failed';
1185 if ($dstParentDAV == null)
1187 return '409 Conflict (parent of destination does not exist)';
1190 if ($srcParent == $dstParent)
1195 if (! $srcDAV->isPermitted(
'write'))
1197 return '403 Forbidden';
1199 $this->
writelog(
'rename dstName='.$dstName);
1200 $srcDAV->setResourceName($dstName);
1206 if (! $srcDAV->isPermitted(
'delete'))
1208 return '403 Forbidden';
1211 if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
1213 return '403 Forbidden';
1215 $dstParentDAV->addMove($srcDAV, $dstName);
1229 return ($isOverwritten) ?
'204 No Content' :
'201 Created';
1238 public function COPY($options, $del=
false)
1241 $this->
writelog(
'COPY('.var_export($options,
true).
' ,del='.$del.
')');
1242 $this->
writelog(
'COPY '.$options[
'path'].
' '.$options[
'dest']);
1245 if (isset($options[
"dest_url"])) {
1246 return "502 bad gateway";
1250 $srcParent = dirname($src);
1253 $dstParent = dirname($dst);
1259 return '409 Conflict';
1262 if (substr($dst,strlen($src)+1) == $src.
'/')
1264 return '409 Conflict';
1267 $this->
writelog(
'COPY src='.$src.
' dst='.$dst);
1271 $dstParentDAV =& $this->
getObject($dstParent);
1273 if (is_null($srcDAV) || $srcDAV->isNullResource())
1275 return '409 Conflict';
1277 if (is_null($dstParentDAV) || $dstParentDAV->isNullResource())
1279 return '409 Conflict';
1281 $isOverwritten =
false;
1284 if (! is_null($dstDAV))
1286 if ($options[
'overwrite'] ==
'T')
1288 if ($dstDAV->isPermitted(
'delete'))
1290 $dstParentDAV->remove($dstDAV);
1294 $isOverwritten =
true;
1296 return '403 Forbidden';
1299 return '412 Precondition Failed';
1303 if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
1305 return '403 Forbidden';
1307 $dstDAV = $dstParentDAV->addCopy($srcDAV, $dstName);
1311 $srcDAV->getObjectId(), $ilUser->getId());
1314 return ($isOverwritten) ?
'204 No Content' :
'201 Created';
1325 $this->
writelog(
'PROPPATCH(options='.var_export($options,
true).
')');
1326 $this->
writelog(
'PROPPATCH '.$options[
'path']);
1333 if (is_null($objDAV) || $objDAV->isNullResource())
return false;
1335 $isPermitted = $objDAV->isPermitted(
'write');
1336 foreach($options[
'props'] as $key => $prop) {
1337 if (!$isPermitted || $prop[
'ns'] ==
'DAV:')
1339 $options[
'props'][$key][
'status'] =
'403 Forbidden';
1341 $this->properties->put($objDAV, $prop[
'ns'],$prop[
'name'],$prop[
'val']);
1358 $this->
writelog(
'LOCK('.var_export($options,
true).
')');
1359 $this->
writelog(
'LOCK '.$options[
'path']);
1366 if (is_null($objDAV))
1368 $this->
writelog(
'LOCK handling null-object locking...');
1371 if (isset($options[
"update"]))
1373 $this->
writelog(
'LOCK lock-update failed on non-existing null-object.');
1374 return '412 Precondition Failed';
1377 $parent = dirname(
$path);
1378 $parentDAV =& $this->
getObject($parent);
1379 if (is_null($parentDAV))
1381 $this->
writelog(
'LOCK lock failed on non-existing path to null-object.');
1382 return '404 Not Found';
1384 if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()) &&
1385 ! $parentDAV->isPermitted(
'create', $parentDAV->getILIASCollectionType()))
1387 $this->
writelog(
'LOCK lock failed - creation of null object not permitted.');
1388 return '403 Forbidden';
1396 if (! $objDAV->isNullResource() && ! $objDAV->isPermitted(
'write'))
1398 $this->
writelog(
'LOCK lock failed - user has no write permission.');
1399 return '403 Forbidden';
1403 if (!isset($options[
'timeout']) || is_array($options[
'timeout']))
1405 $options[
"timeout"] = time()+360;
1408 if(isset($options[
"update"])) {
1409 $this->
writelog(
'LOCK update token='.var_export($options,
true));
1410 $success = $this->locks->updateLockWithoutCheckingDAV(
1417 $data = $this->locks->getLockDAV($objDAV, $options[
'update']);
1418 if (
$data[
'ilias_owner'] == $ilias->account->getId())
1420 $owner =
$data[
'dav_owner'];
1422 $owner =
'<D:href>'.$this->getLogin(
$data[
'ilias_owner']).
'</D:href>';
1424 $options[
'owner'] = $owner;
1425 $options[
'locktoken'] =
$data[
'token'];
1426 $options[
'timeout'] =
$data[
'expires'];
1427 $options[
'depth'] =
$data[
'depth'];
1428 $options[
'scope'] =
$data[
'scope'];
1429 $options[
'type'] =
$data[
'scope'];
1433 $this->
writelog(
'LOCK create new lock');
1442 $this->
writelog(
'lock owner='.$owner);
1443 $success = $this->locks->lockWithoutCheckingDAV(
1445 $ilias->account->getId(),
1446 trim($options[
'owner']),
1447 $options[
'locktoken'],
1448 $options[
'timeout'],
1469 global
$log, $ilias;
1470 $this->
writelog(
'UNLOCK(options='.var_export($options,
true).
')');
1471 $this->
writelog(
'UNLOCK '.$options[
'path']);
1476 if (is_null($objDAV)) {
1477 return '404 Not Found';
1479 if (! $objDAV->isPermitted(
'write')) {
1480 return '403 Forbidden';
1483 $success = $this->locks->unlockWithoutCheckingDAV(
1490 if ($objDAV->isNullResource()
1491 && count($this->locks->getLocksOnObjectDAV($objDAV)) == 0)
1494 $parentDAV =& $this->
getObject($parent);
1495 $parentDAV->remove($objDAV);
1501 return (
$success) ?
'200 OK' :
'412 Precondition Failed';
1528 if (! is_null($objPath))
1530 $objDAV = $objPath[count($objPath) - 1];
1531 $locks = $this->locks->getLocksOnPathDAV($objPath);
1532 foreach (
$locks as $lock)
1534 $isLastPathComponent = $lock[
'obj_id'] == $objDAV->getObjectId()
1535 && $lock[
'node_id'] == $objDAV->getNodeId();
1539 if ($isLastPathComponent || $lock[
'depth'] ==
'infinity')
1545 if ($lock[
'ilias_owner'] == $ilias->account->getId())
1547 $owner = $lock[
'dav_owner'];
1549 $owner = $this->
getLogin($lock[
'ilias_owner']);
1556 "obj_id" => $lock[
'obj_id'],
1557 "node_id" => $lock[
'node_id'],
1558 "scope" => $lock[
'scope'],
1559 "depth" => $lock[
'depth'],
1561 "token" => $lock[
'token'],
1562 "expires" => $lock[
'expires']
1564 if ($lock[
'scope'] ==
'exclusive')
1587 $this->
writelog(
'getLogin('.$userId.
'):'.var_export($login,
true));
1606 $davPathComponents = split(
'/',substr($davPath,1));
1607 if (count($davPathComponents) > 1 &&
1608 substr($davPathComponents[1],0,5) ==
'file_')
1610 $ref_id = substr($davPathComponents[1],5);
1611 $nodePath = $tree->getNodePath(
$ref_id, $tree->root_id);
1615 header(
'Pragma: private');
1620 if ($nodePath == null && count($davPathComponents) == 1)
1625 if (is_null($nodePath))
1629 $top = $nodePath[count($nodePath) - 1];
1641 $this->
writelog(
'toObjectPath('.$davPath);
1646 if (is_null($nodePath))
1650 $objectPath = array();
1651 foreach ($nodePath as $node)
1654 if (is_null($pathElement))
1658 $objectPath[] = $pathElement;
1678 $this->
writelog(
'toNodePath('.$davPath.
')...');
1681 $titlePath = split(
'/',substr($davPath,1));
1684 if (count($titlePath) > 0)
1686 array_shift($titlePath);
1690 if (count($titlePath) > 0 && $titlePath[count($titlePath) - 1] ==
'')
1692 array_pop($titlePath);
1696 if (count($titlePath) == 0)
1698 $this->
writelog(
'toNodePath('.$davPath.
'):null, because path is empty.');
1706 if (count($titlePath) > 0 && substr($titlePath[0],0,4) ==
'ref_')
1708 $ref_id = substr($titlePath[0],4);
1709 array_shift($titlePath);
1712 $nodePath = $tree->getNodePathForTitlePath($titlePath,
$ref_id);
1714 $this->
writelog(
'toNodePath():'.var_export($nodePath,
true));
1743 $components = split(
'/',
$path);
1744 return count($components) == 0 ?
'' : $components[count($components) - 1];
1761 if ($message ==
'---')
1766 $ilias->account->getLogin()
1767 .
' '.$_SERVER[
'REMOTE_ADDR'].
':'.$_SERVER[
'REMOTE_PORT']
1768 .
' ilDAVServer.'.str_replace(
"\n",
";",$message)
1774 $fh = fopen(
'/opt/ilias/log/ilias.log',
'a');
1775 fwrite($fh, date(
'Y-m-d H:i:s '));
1776 fwrite($fh, str_replace(
"\n",
";",$message));
1777 fwrite($fh,
"\n\n");
1795 function getMountURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null, $genericURI =
false)
1800 }
else if ($this->clientOS ==
'windows') {
1802 $query =
'mount-instructions';
1803 }
else if ($this->clientBrowser ==
'konqueror') {
1806 }
else if ($this->clientBrowser ==
'nautilus') {
1811 $query =
'mount-instructions';
1813 $baseUri.=
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1814 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1816 $uri = $baseUri.
'/ref_'.$refId.
'/';
1838 function getFolderURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null)
1840 if ($this->clientOS ==
'windows') {
1843 }
else if ($this->clientBrowser ==
'konqueror') {
1846 }
else if ($this->clientBrowser ==
'nautilus') {
1853 $baseUri.=
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1854 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1856 $uri = $baseUri.
'/ref_'.$refId.
'/';
1875 public function getObjectURI($refId, $ressourceName = null, $parentRefId = null)
1879 "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1880 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1882 if (! is_null($ressourceName) && ! is_null($parentRefId))
1885 $uri = $baseUri.
'/ref_'.$parentRefId.
'/'.$this->
davUrlEncode($ressourceName);
1889 $nodePath = $tree->getNodePath($refId);
1891 if (is_null($nodePath) || count($nodePath) < 2)
1896 $uri = $baseUri.
'/ref_'.$nodePath[count($nodePath) - 2][
'child'].
'/'.
1897 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1920 public function getFileURI($refId, $ressourceName = null, $parentRefId = null)
1924 "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1925 $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
1927 if (! is_null($ressourceName) && ! is_null($parentRefId))
1934 $nodePath = $tree->getNodePath($refId);
1936 if (is_null($nodePath) || count($nodePath) < 2)
1941 $uri = $baseUri.
'/file_'.$nodePath[count($nodePath) - 1][
'child'].
'/'.
1942 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1954 if ($this->isHTTPS == null) {
1956 require_once
'classes/class.ilHTTPS.php';
1958 $this->isHTTPS = $https->isDetected() || $ilSetting->get(
'https');
1973 global $ilClientIniFile;
1974 return $ilClientIniFile->readVariable(
'file_access',
'webdav_enabled') ==
'1' &&
1975 @include_once(
"Auth/HTTP.php");
1984 global $ilClientIniFile;
1985 return $ilClientIniFile->readVariable(
'file_access',
'webdav_actions_visible') ==
'1';
2000 return $lng->txt(
'webfolder_instructions_text');
2030 $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
2031 $os =
'unknown', $osFlavor =
'unknown')
2035 $settings =
new ilSetting(
'file_access');
2036 $str = $settings->get(
'custom_webfolder_instructions',
'');
2037 if (strlen($str) == 0 || ! $settings->get(
'custom_webfolder_instructions_enabled'))
2042 $str = str_replace(
"[WEBFOLDER_TITLE]", $webfolderTitle, $str);
2043 $str = str_replace(
"[WEBFOLDER_URI]", $webfolderURI, $str);
2044 $str = str_replace(
"[WEBFOLDER_URI_IE]", $webfolderURI_IE, $str);
2045 $str = str_replace(
"[WEBFOLDER_URI_KONQUEROR]", $webfolderURI_Konqueror, $str);
2046 $str = str_replace(
"[WEBFOLDER_URI_NAUTILUS]", $webfolderURI_Nautilus, $str);
2047 $str = str_replace(
"[ADMIN_MAIL]", $ilSetting->get(
"admin_email"), $str);
2052 $operatingSystem =
'WINDOWS';
2058 $operatingSystem =
'MAC';
2061 $operatingSystem =
'LINUX';
2064 $operatingSystem =
'LINUX';
2069 $operatingSystem =
'UNKNOWN';
2073 if ($operatingSystem !=
'UNKNOWN')
2075 $str = preg_replace(
'/\[IF_'.$operatingSystem.
'\]((?:.|\n)*)\[\/IF_'.$operatingSystem.
'\]/',
'\1', $str);
2076 $str = preg_replace(
'/\[IF_([A-Z_]+)\](?:(?:.|\n)*)\[\/IF_\1\]/',
'', $str);
2080 $str = preg_replace(
'/\[IF_([A-Z_]+)\]((?:.|\n)*)\[\/IF_\1\]/',
'\2', $str);
2091 $val = ini_get(
'upload_max_filesize');
2094 $last = strtolower($val[strlen($val)-1]);