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
'Services/Utilities/classes/class.ilFileUtils.php';
32 require_once
'include/Unicode/UtfNormal.php';
33 require_once
'Services/Tracking/classes/class.ilChangeEvent.php';
143 $userAgent = strtolower(
$_SERVER[
'HTTP_USER_AGENT']);
144 $this->
writelog(
'userAgent=' . $userAgent);
145 if (strpos($userAgent,
'windows') !==
false 146 || strpos($userAgent,
'microsoft') !==
false) {
147 $this->clientOS =
'windows';
148 if (strpos($userAgent,
'nt 5.1') !==
false) {
149 $this->clientOSFlavor =
'xp';
151 $this->clientOSFlavor =
'nichtxp';
153 } elseif (strpos($userAgent,
'darwin') !==
false 154 || strpos($userAgent,
'macintosh') !==
false 155 || strpos($userAgent,
'linux') !==
false 156 || strpos($userAgent,
'solaris') !==
false 157 || strpos($userAgent,
'aix') !==
false 158 || strpos($userAgent,
'unix') !==
false 159 || strpos($userAgent,
'gvfs') !==
false 161 $this->clientOS =
'unix';
162 if (strpos($userAgent,
'linux') !==
false) {
163 $this->clientOSFlavor =
'linux';
164 } elseif (strpos($userAgent,
'macintosh') !==
false) {
165 $this->clientOSFlavor =
'osx';
168 if (strpos($userAgent,
'konqueror') !==
false) {
169 $this->clientBrowser =
'konqueror';
179 if (self::$instance != null) {
180 return self::$instance;
190 if (
$GLOBALS[
'DIC'][
'ilAuthSession']->isAuthenticated()) {
197 include_once
'./Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentialsHTTP.php';
199 $credentials->initFromRequest();
201 include_once
'./Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
203 $providers = $provider_factory->getProviders($credentials);
205 include_once
'./Services/Authentication/classes/class.ilAuthStatus.php';
208 include_once
'./Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
211 $frontend = $frontend_factory->getFrontend(
218 $frontend->authenticate();
220 switch ($status->getStatus()) {
226 ilInitialisation::initUserAccount();
252 if (!self::_isActive()) {
253 $this->
writelog(__METHOD__ .
' WebDAV disabled. Aborting');
255 echo
'<html><body><h1>Sorry</h1>' .
256 '<p><b>Please enable the WebDAV plugin in the ILIAS Administration panel.</b></p>' .
257 '<p>You can only access this page, if WebDAV is enabled on this server.</p>' .
265 parent::serveRequest();
267 $this->
writelog(
'serveRequest():' . $_SERVER[
'REQUEST_METHOD'] .
' done status=' . $this->_http_status .
' elapsed=' . (
$end - $start));
270 $this->
writelog(
'serveRequest():' .
$_SERVER[
'REQUEST_METHOD'] .
' caught exception: ' . $e->getMessage() .
'\n' . $e->getTraceAsString());
315 $c = explode(
'/',
$path);
316 for (
$i = 0;
$i < count($c);
$i++) {
317 $c[
$i] = str_replace(
'+',
'%20', urlencode($c[
$i]));
319 return implode(
'/', $c);
335 $this->
writelog(
'PROPFIND(options:' . var_export(
$options,
true) .
' files:' . var_export(
$files,
true) .
'.)');
346 if (is_null($objDAV)) {
349 if (!$objDAV->isPermitted(
'visible,read')) {
350 return '403 Forbidden';
357 $GLOBALS[
'ilLog']->write(print_r($encodedPath,
true));
359 $files[
'files'][] =&$this->
fileinfo($encodedPath, $encodedPath, $objDAV);
367 $breadthFirst =
array($objDAV);
368 $objDAV->encodedPath = $encodedPath;
370 while (count($breadthFirst) > 0) {
372 $collectionDAV = array_shift($breadthFirst);
373 $childrenDAV =&$collectionDAV->childrenWithPermission(
'visible,read');
374 foreach ($childrenDAV as $childDAV) {
377 foreach ($childrenDAV as $duplChildDAV) {
378 if ($duplChildDAV->getObjectId() < $childDAV->getObjectId() &&
379 $duplChildDAV->getResourceName() == $childDAV->getResourceName()) {
386 $this->
writelog(
'PROPFIND() child ref_id=' . $childDAV->getRefId());
388 $collectionDAV->encodedPath .
'/' . $this->davUrlEncode($childDAV->getResourceName()),
389 $collectionDAV->encodedPath .
'/' . $this->davUrlEncode($childDAV->getDisplayName()),
392 if (
$options[
'depth']==
'infinity' && $childDAV->isCollection()) {
394 $breadthFirst[] = $childDAV;
395 $childDAV->encodedPath = $collectionDAV->encodedPath .
'/' . $this->
davUrlEncode($childDAV->getResourceName());
406 $objDAV->getILIASType(),
408 $objDAV->getObjectId(),
414 $this->
writelog(
'PROPFIND():true options=' . var_export(
$options,
true) .
' files=' . var_export(
$files,
true));
431 if ($objDAV->isNullResource()) {
432 if (count($this->locks->getLocksOnObjectDAV($objDAV)) == 0) {
437 $name = $objDAV->getResourceName();
438 $isFileHidden =
false;
439 switch ($this->clientOS) {
444 || substr(
$name, 0, 2) ==
'~$';
446 $isFileHidden |= preg_match(
'/\\//',
$name);
450 $isFileHidden = substr(
$name, 0, 1) ==
'.';
452 $isFileHidden |= preg_match(
'/\\\\|\\/|:|\\*|\\?|"|<|>|\\|/',
$name);
456 $isFileHidden |= preg_match(
'/\\//',
$name);
459 $this->
writelog($this->clientOS .
' ' .
$name .
' isHidden:' . $isFileHidden .
' clientOS:' . $this->clientOS);
460 return $isFileHidden;
470 private function fileinfo($resourcePath, $displayPath, &$objDAV)
474 $this->
writelog(
'fileinfo(' . $resourcePath .
')');
481 if ($objDAV->isCollection() && $this->clientOSFlavor !=
'osx') {
482 $info[
'path'] = $resourcePath .
'/';
484 $info[
'path'] = $resourcePath;
490 $info[
"props"][] =&$this->
mkprop(
"displayname", $displayPath);
493 $info[
"props"][] =&$this->
mkprop(
"creationdate", $objDAV->getCreationTimestamp());
494 $info[
"props"][] =&$this->
mkprop(
"getlastmodified", $objDAV->getModificationTimestamp());
497 $info[
"props"][] =&$this->
mkprop(
"resourcetype", $objDAV->getResourceType());
498 $info[
"props"][] =&$this->
mkprop(
"getcontenttype", $objDAV->getContentType());
499 $info[
"props"][] =&$this->
mkprop(
"getcontentlength", $objDAV->getContentLength());
502 if ($objDAV->isPermitted(
'write')) {
503 $info[
"props"][] =&$this->
mkprop(
506 .
'<D:lockscope><D:exclusive/></D:lockscope>' 507 .
'<D:locktype><D:write/></D:locktype>' 510 .
'<D:lockscope><D:shared/></D:lockscope>' 511 .
'<D:locktype><D:write/></D:locktype>' 519 $locks = $this->locks->getLocksOnObjectDAV($objDAV);
521 foreach (
$locks as $lock) {
526 if ($lock[
'ilias_owner'] == $ilias->account->getId()) {
527 $owner = $lock[
'dav_owner'];
529 $owner =
'<D:href>' . $this->
getLogin($lock[
'ilias_owner']) .
'</D:href>';
531 $this->
writelog(
'lockowner=' . $owner .
' ibi:' . $lock[
'ilias_owner'] .
' davi:' . $lock[
'dav_owner']);
535 .
'<D:lockscope><D:' . $lock[
'scope'] .
'/></D:lockscope>' 537 .
'<D:locktype><D:write/></D:locktype>' 538 .
'<D:depth>' . $lock[
'depth'] .
'</D:depth>' 539 .
'<D:owner>' . $owner .
'</D:owner>' 543 .
'<D:timeout>Second-' . (($lock[
'expires'] > 1000000) ? $lock[
'expires']-
time():$lock[
'expires']) .
'</D:timeout>' 544 .
'<D:locktoken><D:href>' . $lock[
'token'] .
'</D:href></D:locktoken>' 548 if (strlen($lockdiscovery) > 0) {
549 $info[
"props"][] =&$this->
mkprop(
"lockdiscovery", $lockdiscovery);
555 $info[
"props"][] = $this->
mkprop($prop[
'namespace'], $prop[
'name'], $prop[
'value']);
585 if (is_null($objDAV) || $objDAV->isNullResource()) {
589 if (!$objDAV->isPermitted(
'visible,read')) {
590 return '403 Forbidden';
594 if ($objDAV->isCollection()) {
595 if (isset(
$_GET[
'mount'])) {
597 } elseif (isset(
$_GET[
'mount-instructions'])) {
604 $options[
'mimetype'] =&$objDAV->getContentType();
609 $options[
'mtime'] =&$objDAV->getModificationTimestamp();
612 $options[
'size'] =&$objDAV->getContentLength();
615 $options[
'stream'] =&$objDAV->getContentStream();
617 $options[
'data'] =&$objDAV->getContentData();
622 $objDAV->getILIASType(),
624 $objDAV->getObjectId(),
647 header(
'Content-Type: application/davmount+xml');
649 echo
"<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n";
650 echo
" </dm:url>" . $this->base_uri .
"</dm:url>\n";
652 $xmlPath = str_replace(
'&',
'&',
$path);
653 $xmlPath = str_replace(
'<',
'<', $xmlPath);
654 $xmlPath = str_replace(
'>',
'>', $xmlPath);
656 echo
" </dm:open>$xmlPath</dm:open>\n";
657 echo
"</dm:mount>\n";
680 foreach ($objectPath as $object) {
681 if ($object->getRefId() == 1 && $this->
isFileHidden($object)) {
685 $fullPath .=
'/ref_1';
687 $fullPath .=
'/' . $this->
davUrlEncode($object->getResourceName());
692 $shortenedPath =
'/ref_' .
693 $objectPath[count($objectPath) - 1]->getRefId();
695 if ($objDAV->isCollection()) {
696 $shortenedPath .=
'/';
701 $shortenedPath =
'/' . CLIENT_ID . $shortenedPath;
702 $fullPath =
'/' . CLIENT_ID . $fullPath;
707 $webfolderURI = $this->base_uri . $shortenedPath;
709 substr($this->base_uri, strrpos($this->base_uri,
':')) .
713 substr($this->base_uri, strrpos($this->base_uri,
':')) .
716 $webfolderURI_IE = $this->base_uri . $shortenedPath;
718 $webfolderTitle = $objectPath[count($objectPath) - 1]->getResourceName();
720 header(
'Content-Type: text/html; charset=UTF-8');
721 echo
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
722 echo
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
723 echo
" \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
724 echo
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
726 echo
" <title>" . sprintf($lng->txt(
'webfolder_instructions_titletext'), $webfolderTitle) .
"</title>\n";
734 $webfolderURI_Konqueror,
735 $webfolderURI_Nautilus,
737 $this->clientOSFlavor
744 if ($ilUser->getId() == ANONYMOUS_USER_ID) {
745 $GOBALS[
'DIC'][
'ilAuthSession']->logout();
774 header(
'Location: ' . $this->base_uri .
$path .
'/');
778 header(
'Content-Type: text/html; charset=UTF-8');
783 echo
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
784 echo
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
785 echo
" \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
786 echo
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
788 echo
"<title>" . sprintf($lng->txt(
'webfolder_index_of'),
$path) .
"</title>\n";
792 echo
"<style type=\"text/css\">\n";
795 echo
" behavior:url(#default#AnchorClick);\n";
800 echo
"</head><body>\n";
803 $pathComponents = explode(
'/',
$path);
804 $uriComponents =
array();
805 foreach ($pathComponents as $component) {
808 for (
$i = 0;
$i < count($pathComponents);
$i++) {
809 $displayName = htmlspecialchars($pathComponents[
$i]);
813 $uriPath = implode(
'/', array_slice($uriComponents, 0, $i + 1));
818 $hrefPath .= $displayName;
820 $hrefPath .=
'<a href="' . $this->base_uri . $uriPath .
'/">' . $displayName .
'</a>';
823 echo
"<h3>" . sprintf($lng->txt(
'webfolder_index_of'), $hrefPath) .
"</h3>\n";
826 if ($ilias->account->getLogin() ==
'anonymous') {
827 echo
"<p><font size=\"-1\">" . $lng->txt(
'not_logged_in') .
"</font><br>\n";
829 echo
"<p><font size=\"-1\">" . $lng->txt(
'login_as') .
" <i>" 830 . $ilias->account->getFirstname() .
' ' 831 . $ilias->account->getLastname() .
' ' 832 .
' ' . $ilias->account->getLogin() .
'</i> ' 833 .
', ' . $lng->txt(
'client') .
' <i>' . $ilias->getClientId() .
'</i>.' 838 $href = $this->base_uri . $uriPath;
841 if (count($pathComponents) > 2) {
842 $hrefIE = $this->base_uri .
'/' . CLIENT_ID .
'/ref_' . $objDAV->getRefId();
846 echo
"<p><font size=\"-1\">" .
847 sprintf($lng->txt(
'webfolder_dir_info'),
"$href?mount-instructions") .
849 echo
"<p><font size=\"-1\">" .
851 $lng->txt(
'webfolder_mount_dir_with'),
852 "$hrefIE\" folder=\"$hrefIE",
853 'webdav' . substr($href, 4),
854 'dav' . substr($href, 4),
860 printf(
$format, $lng->txt(
'size'), $lng->txt(
'last_change'), $lng->txt(
'filename'));
863 $collectionCount = 0;
865 $children =&$objDAV->childrenWithPermission(
'visible,read');
866 foreach ($children as $childDAV) {
867 if ($childDAV->isCollection() && !$this->
isFileHidden($childDAV)) {
873 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
874 '<a href="' .
$name .
'/' .
'">' . $childDAV->getDisplayName() .
"</a>" 878 foreach ($children as $childDAV) {
879 if ($childDAV->isFile() && !$this->
isFileHidden($childDAV)) {
884 number_format($childDAV->getContentLength()),
885 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
886 '<a href="' .
$name .
'">' . $childDAV->getDisplayName() .
"</a>" 890 foreach ($children as $childDAV) {
891 if ($childDAV->isNullResource() && !$this->
isFileHidden($childDAV)) {
896 strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
897 '<a href="' .
$name .
'">' . $childDAV->getDisplayName() .
"</a>" 902 echo $collectionCount .
' ' . $lng->txt(($collectionCount == 1) ?
'folder' :
'folders') .
', ';
903 echo $fileCount .
' ' . $lng->txt(($fileCount == 1) ?
'file' :
'files') .
'.';
905 echo
"</body></html>\n";
924 $parent = dirname(
$path);
936 if (is_null($parentDAV) || !$parentDAV->isCollection()) {
937 return '409 Conflict';
943 if (
$options[
'content_length'] != null &&
945 $this->
writelog(
'PUT is forbidden, because content length=' .
946 $options[
'content_length'] .
' is larger than upload_max_filesize=' .
949 return '403 Forbidden';
953 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
957 if (is_null($objDAV)) {
958 $ttype = $parentDAV->getILIASFileType();
959 $isperm = $parentDAV->isPermitted(
'create', $ttype);
961 $this->
writelog(
'PUT is forbidden, because user has no create permission');
963 return '403 Forbidden';
966 $objDAV =&$parentDAV->createFile(
$name);
967 $this->
writelog(
'PUT obj=' . $objDAV .
' name=' .
$name .
' content_type=' .
$options[
'content_type']);
969 $objDAV->setContentType($mime);
970 if ($options[
'content_length'] != null) {
971 $objDAV->setContentLength($options[
'content_length']);
976 } elseif ($objDAV->isNullResource()) {
977 if (!$parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType())) {
978 $this->
writelog(
'PUT is forbidden, because user has no create permission');
979 return '403 Forbidden';
982 $objDAV =&$parentDAV->createFileFromNull(
$name, $objDAV);
983 $this->
writelog(
'PUT obj=' . $objDAV .
' name=' .
$name .
' content_type=' .
$options[
'content_type']);
985 $objDAV->setContentType($mime);
986 if ($options[
'content_length'] != null) {
987 $objDAV->setContentLength($options[
'content_length']);
994 if (!$objDAV->isPermitted(
'write')) {
995 $this->
writelog(
'PUT is forbidden, because user has no write permission');
996 return '403 Forbidden';
999 $this->
writelog(
'PUT obj=' . $objDAV .
' name=' .
$name .
' content_type=' .
$options[
'content_type'] .
' content_length=' .
$options[
'content_length']);
1002 if ($objDAV->getContentLength() != 0) {
1003 $objDAV->createNewVersion();
1007 $objDAV->setContentType($mime);
1008 if ($options[
'content_length'] != null) {
1009 $objDAV->setContentLength($options[
'content_length']);
1018 $this->putObjDAV = $objDAV;
1020 $out =&$objDAV->getContentOutputStream();
1036 if ($this->putObjDAV->getResourceType()==
"") {
1037 $vir =
ilUtil::virusHandling($this->putObjDAV->obj->getDirectory($this->putObjDAV->obj->getVersion()) .
'/' . $this->putObjDAV->obj->getFileName(), $this->putObjDAV->obj->getFileName());
1038 if ($vir[0] ==
false) {
1039 $this->
writelog(
'PUTfinished Virus found: ' . $vir[1]);
1048 if (
$options[
'content_length'] == null || $this->putObjDAV->getContentLength() == 0) {
1050 if ($objDAV->getContentOutputStreamLength() != null) {
1051 $objDAV->setContentLength($objDAV->getContentOutputStreamLength());
1054 $objDAV->setContentLength(filesize($objDAV->obj->getDirectory($objDAV->obj->getVersion()) .
'/' . $objDAV->obj->getFileName()));
1057 $this->putObjDAV = null;
1077 $parent =&dirname(
$path);
1081 if (!empty(
$_SERVER[
"CONTENT_LENGTH"])) {
1082 return "415 Unsupported media type";
1087 if (!is_null($objDAV)) {
1088 return '405 Method not allowed';
1095 if (is_null($parentDAV) || !$parentDAV->isCollection()) {
1096 return '409 Conflict';
1099 if (!$parentDAV->isPermitted(
'create', $parentDAV->getILIASCollectionType())) {
1100 return '403 Forbidden';
1105 $objDAV = $parentDAV->createCollection(
$name);
1107 if ($objDAV != null) {
1112 $result = ($objDAV != null) ?
"201 Created" :
"409 Conflict";
1136 if (is_null($objDAV) || $objDAV->isNullResource()) {
1137 return '404 Not Found';
1139 if (!$objDAV->isPermitted(
'delete')) {
1140 return '403 Forbidden';
1143 $parentDAV->remove($objDAV);
1148 return '204 No Content';
1166 $srcParent = dirname($src);
1170 $dstParent = dirname(
$dst);
1175 return '409 Conflict (source and destination are the same)';
1179 if (substr(
$dst, strlen($src)+1) == $src .
'/') {
1180 return '409 Conflict (destination is in subtree of source)';
1186 $srcParentDAV =&$this->
getObject($srcParent);
1187 $dstParentDAV =&$this->
getObject($dstParent);
1190 if ($srcDAV == null) {
1191 return '409 Conflict (source does not exist)';
1195 $isOverwritten =
false;
1196 if ($dstDAV != null) {
1197 if ($options[
'overwrite'] ==
'T') {
1199 if ($dstDAV->isPermitted(
'delete')) {
1200 $dstParentDAV->remove($dstDAV);
1202 $isOverwritten =
true;
1204 return '403 Not Permitted';
1207 return '412 Precondition Failed';
1212 if ($dstParentDAV == null) {
1213 return '409 Conflict (parent of destination does not exist)';
1216 if ($srcParent == $dstParent) {
1220 if (!$srcDAV->isPermitted(
'write')) {
1221 return '403 Forbidden';
1223 $this->
writelog(
'rename dstName=' . $dstName);
1224 $srcDAV->setResourceName($dstName);
1230 if (!$srcDAV->isPermitted(
'delete')) {
1231 return '403 Forbidden';
1234 if (!$dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType())) {
1235 return '403 Forbidden';
1237 $dstParentDAV->addMove($srcDAV, $dstName);
1241 if ($isOverwritten) {
1248 return ($isOverwritten) ?
'204 No Content' :
'201 Created';
1260 $this->
writelog(
'COPY(' . var_export(
$options,
true) .
' ,del=' . $del .
')');
1264 if (isset($options[
"dest_url"])) {
1265 return "502 bad gateway";
1269 $srcParent = dirname($src);
1272 $dstParent = dirname(
$dst);
1277 return '409 Conflict';
1280 if (substr(
$dst, strlen($src)+1) == $src .
'/') {
1281 return '409 Conflict';
1288 $dstParentDAV =&$this->
getObject($dstParent);
1290 if (is_null($srcDAV) || $srcDAV->isNullResource()) {
1291 return '409 Conflict';
1293 if (is_null($dstParentDAV) || $dstParentDAV->isNullResource()) {
1294 return '409 Conflict';
1296 $isOverwritten =
false;
1299 if (!is_null($dstDAV)) {
1300 if ($options[
'overwrite'] ==
'T') {
1301 if ($dstDAV->isPermitted(
'delete')) {
1302 $dstParentDAV->remove($dstDAV);
1306 $isOverwritten =
true;
1308 return '403 Forbidden';
1311 return '412 Precondition Failed';
1315 if (!$dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType())) {
1316 return '403 Forbidden';
1318 $dstDAV = $dstParentDAV->addCopy($srcDAV,
$dstName);
1322 $srcDAV->getILIASType(),
1323 $srcDAV->getRefId(),
1324 $srcDAV->getObjectId(),
1329 return ($isOverwritten) ?
'204 No Content' :
'201 Created';
1348 if (is_null($objDAV) || $objDAV->isNullResource()) {
1352 $isPermitted = $objDAV->isPermitted(
'write');
1354 if (!$isPermitted || $prop[
'ns'] ==
'DAV:') {
1357 $this->
properties->put($objDAV, $prop[
'ns'], $prop[
'name'], $prop[
'val']);
1382 if (is_null($objDAV)) {
1383 $this->
writelog(
'LOCK handling null-object locking...');
1387 $this->
writelog(
'LOCK lock-update failed on non-existing null-object.');
1388 return '412 Precondition Failed';
1391 $parent = dirname(
$path);
1393 if (is_null($parentDAV)) {
1394 $this->
writelog(
'LOCK lock failed on non-existing path to null-object.');
1395 return '404 Not Found';
1397 if (!$parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()) &&
1398 !$parentDAV->isPermitted(
'create', $parentDAV->getILIASCollectionType())) {
1399 $this->
writelog(
'LOCK lock failed - creation of null object not permitted.');
1400 return '403 Forbidden';
1408 if (!$objDAV->isNullResource() && !$objDAV->isPermitted(
'write')) {
1409 $this->
writelog(
'LOCK lock failed - user has no write permission.');
1410 return '403 Forbidden';
1420 $success = $this->locks->updateLockWithoutCheckingDAV(
1426 $data = $this->locks->getLockDAV($objDAV,
$options[
'update']);
1427 if (
$data[
'ilias_owner'] == $ilias->account->getId()) {
1428 $owner =
$data[
'dav_owner'];
1430 $owner =
'<D:href>' . $this->
getLogin(
$data[
'ilias_owner']) .
'</D:href>';
1440 $this->
writelog(
'LOCK create new lock');
1449 $this->
writelog(
'lock owner=' . $owner);
1450 $success = $this->locks->lockWithoutCheckingDAV(
1452 $ilias->account->getId(),
1476 global
$log, $ilias;
1483 if (is_null($objDAV)) {
1484 return '404 Not Found';
1486 if (!$objDAV->isPermitted(
'write')) {
1487 return '403 Forbidden';
1490 $success = $this->locks->unlockWithoutCheckingDAV(
1497 if ($objDAV->isNullResource()
1498 && count($this->locks->getLocksOnObjectDAV($objDAV)) == 0) {
1501 $parentDAV->remove($objDAV);
1507 return (
$success) ?
'200 OK' :
'412 Precondition Failed';
1534 if (!is_null($objPath)) {
1535 $objDAV = $objPath[count($objPath) - 1];
1536 $locks = $this->locks->getLocksOnPathDAV($objPath);
1537 foreach (
$locks as $lock) {
1538 $isLastPathComponent = $lock[
'obj_id'] == $objDAV->getObjectId()
1539 && $lock[
'node_id'] == $objDAV->getNodeId();
1543 if ($isLastPathComponent || $lock[
'depth'] ==
'infinity') {
1548 if ($lock[
'ilias_owner'] == $ilias->account->getId()) {
1549 $owner = $lock[
'dav_owner'];
1551 $owner = $this->
getLogin($lock[
'ilias_owner']);
1558 "obj_id" => $lock[
'obj_id'],
1559 "node_id" => $lock[
'node_id'],
1560 "scope" => $lock[
'scope'],
1561 "depth" => $lock[
'depth'],
1563 "token" => $lock[
'token'],
1564 "expires" => $lock[
'expires']
1566 if ($lock[
'scope'] ==
'exclusive') {
1588 $this->
writelog(
'getLogin(' . $userId .
'):' . var_export($login,
true));
1606 $davPathComponents = explode(
'/', substr($davPath, 1));
1608 if (count($davPathComponents) > 1 &&
1609 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');
1618 if ($nodePath == null && count($davPathComponents) == 1) {
1622 if (is_null($nodePath)) {
1625 $top = $nodePath[count($nodePath) - 1];
1637 $this->
writelog(
'toObjectPath(' . $davPath);
1642 if (is_null($nodePath)) {
1645 $objectPath =
array();
1646 foreach ($nodePath as $node) {
1648 if (is_null($pathElement)) {
1651 $objectPath[] = $pathElement;
1671 $this->
writelog(
'toNodePath(' . $davPath .
')...');
1674 $titlePath = explode(
'/', substr($davPath, 1));
1677 if (count($titlePath) > 0) {
1678 array_shift($titlePath);
1682 if (count($titlePath) > 0 && $titlePath[count($titlePath) - 1] ==
'') {
1683 array_pop($titlePath);
1687 if (count($titlePath) == 0) {
1688 $this->
writelog(
'toNodePath(' . $davPath .
'):null, because path is empty.');
1696 if (count($titlePath) > 0 && substr($titlePath[0], 0, 4) ==
'ref_') {
1697 $ref_id = substr($titlePath[0], 4);
1698 array_shift($titlePath);
1701 $nodePath = $tree->getNodePathForTitlePath($titlePath, $ref_id);
1703 $this->
writelog(
'toNodePath():' . var_export($nodePath,
true));
1732 $components = explode(
'/',
$path);
1733 return count($components) == 0 ?
'' : $components[count($components) - 1];
1745 if ($this->isDebug) {
1752 $ilias->account->getLogin()
1754 .
' ilDAVServer.' . str_replace(
"\n",
";",
$message)
1758 $fh = fopen(
'/opt/ilias/log/ilias.log',
'a');
1759 fwrite(
$fh,
date(
'Y-m-d H:i:s '));
1761 fwrite(
$fh,
"\n\n");
1779 public function getMountURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null, $genericURI =
false)
1784 } elseif ($this->clientOS ==
'windows') {
1786 $query =
'mount-instructions';
1787 } elseif ($this->clientBrowser ==
'konqueror') {
1790 } elseif ($this->clientBrowser ==
'nautilus') {
1795 $query =
'mount-instructions';
1797 $baseUri.=
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1798 $baseUri = substr($baseUri, 0, strrpos($baseUri,
'/')) .
'/webdav.php/' . CLIENT_ID;
1800 $uri = $baseUri .
'/ref_' . $refId .
'/';
1821 public function getFolderURI($refId, $nodeId = 0, $ressourceName = null, $parentRefId = null)
1823 if ($this->clientOS ==
'windows') {
1826 } elseif ($this->clientBrowser ==
'konqueror') {
1829 } elseif ($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 .
'/';
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)) {
1866 $uri = $baseUri .
'/ref_' . $parentRefId .
'/' . $this->
davUrlEncode($ressourceName);
1870 $nodePath = $tree->getNodePath($refId);
1872 if (is_null($nodePath) || count($nodePath) < 2) {
1876 $uri = $baseUri .
'/ref_' . $nodePath[count($nodePath) - 2][
'child'] .
'/' .
1877 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1900 public function getFileURI($refId, $ressourceName = null, $parentRefId = null)
1904 "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
1905 $baseUri = substr($baseUri, 0, strrpos($baseUri,
'/')) .
'/webdav.php/' . CLIENT_ID;
1907 if (!is_null($ressourceName) && !is_null($parentRefId)) {
1909 $uri = $baseUri .
'/file_' . $refId .
'/' . $this->
davUrlEncode($ressourceName);
1913 $nodePath = $tree->getNodePath($refId);
1915 if (is_null($nodePath) || count($nodePath) < 2) {
1919 $uri = $baseUri .
'/file_' . $nodePath[count($nodePath) - 1][
'child'] .
'/' .
1920 $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
1933 if ($this->isHTTPS == null) {
1935 require_once
'./Services/Http/classes/class.ilHTTPS.php';
1937 $this->isHTTPS =
$https->isDetected() || $ilSetting->get(
'https');
1952 global $ilClientIniFile;
1953 return $ilClientIniFile->readVariable(
'file_access',
'webdav_enabled') ==
'1';
1962 global $ilClientIniFile;
1963 return $ilClientIniFile->readVariable(
'file_access',
'webdav_actions_visible') ==
'1';
1978 return $lng->txt(
'webfolder_instructions_text');
2011 $webfolderURI_Konqueror,
2012 $webfolderURI_Nautilus,
2014 $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')) {
2023 if (is_file(
'Customizing/clients/' . CLIENT_ID .
'/webdavtemplate.htm')) {
2024 $str = fread(fopen(
'Customizing/clients/' . CLIENT_ID .
'/webdavtemplate.htm',
"rb"), filesize(
'Customizing/clients/' . CLIENT_ID .
'/webdavtemplate.htm'));
2026 $str=utf8_encode($str);
2028 preg_match_all(
'/(\\d+)/', $webfolderURI, $matches);
2029 $refID=end($matches[0]);
2031 $str = str_replace(
"[WEBFOLDER_ID]", $refID, $str);
2032 $str = str_replace(
"[WEBFOLDER_TITLE]", $webfolderTitle, $str);
2033 $str = str_replace(
"[WEBFOLDER_URI]", $webfolderURI, $str);
2034 $str = str_replace(
"[WEBFOLDER_URI_IE]", $webfolderURI_IE, $str);
2035 $str = str_replace(
"[WEBFOLDER_URI_KONQUEROR]", $webfolderURI_Konqueror, $str);
2036 $str = str_replace(
"[WEBFOLDER_URI_NAUTILUS]", $webfolderURI_Nautilus, $str);
2037 $str = str_replace(
"[ADMIN_MAIL]", $ilSetting->get(
"admin_email"), $str);
2039 if (strpos(
$_SERVER[
'HTTP_USER_AGENT'],
'MSIE')!==
false) {
2040 $str = preg_replace(
'/\[IF_IEXPLORE\](?:(.*))\[\/IF_IEXPLORE\]/s',
'\1', $str);
2042 $str = preg_replace(
'/\[IF_NOTIEXPLORE\](?:(.*))\[\/IF_NOTIEXPLORE\]/s',
'\1', $str);
2047 $operatingSystem =
'WINDOWS';
2050 switch ($osFlavor) {
2052 $operatingSystem =
'MAC';
2055 $operatingSystem =
'LINUX';
2058 $operatingSystem =
'LINUX';
2063 $operatingSystem =
'UNKNOWN';
2067 if ($operatingSystem !=
'UNKNOWN') {
2068 $str = preg_replace(
'/\[IF_' . $operatingSystem .
'\](?:(.*))\[\/IF_' . $operatingSystem .
'\]/s',
'\1', $str);
2069 $str = preg_replace(
'/\[IF_([A-Z_]+)\](?:(.*))\[\/IF_\1\]/s',
'', $str);
2071 $str = preg_replace(
'/\[IF_([A-Z_]+)\](?:(.*))\[\/IF_\1\]/s',
'\2', $str);
2083 $val = ini_get(
'upload_max_filesize');
2086 $last = strtolower($val[strlen($val)-1]);
static _isActionsVisible()
Static getter.
static _lookupLogin($a_user_id)
lookup login
static createObject($refId, $type)
Static factory method to create a DAV object for a given refId and type.
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
$clientBrowser
The name of some well known browsers, that need special support.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
$isDebug
The WebDAVServer prints lots of log messages to the ilias log, if this variable is set to true...
const STATUS_AUTHENTICATION_FAILED
DELETE($options)
DELETE method handler.
MOVE($options)
MOVE method handler.
showMountInstructions(&$objDAV, &$options)
Mount instructions method handler for directories.
static _recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
mountDir(&$objDAV, &$options)
Mount method handler for directories.
getFileURI($refId, $ressourceName=null, $parentRefId=null)
Returns an URI for getting a file object using WebDAV.
Factory for auth frontend classes.
static _getDefaultWebfolderInstructions()
Gets instructions for the usage of webfolders.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _isActive()
Static getter.
Virtual base class for implementing WebDAV servers.
static lookupMimeType($path_to_file, $fallback=self::APPLICATION__OCTET_STREAM, $a_external=null)
COPY($options, $del=false)
COPY method handler.
LOCK(&$options)
LOCK method handler.
static _catchupWriteEvents($obj_id, $usr_id, $timestamp=null)
Catches up with all write events which occured before the specified timestamp.
http_status($status)
set HTTP return status and mirror it in a private header
checkLock($path)
checkLock() helper
GET(&$options)
GET method handler.
static toNFC($string)
Convert a UTF-8 string to normal form C, canonical composition.
PUTfinished(&$options)
PUTfinished handler.
$clientOSFlavor
The flavor of the operating system of the WebDAV client.
serveRequest()
Serves a WebDAV request.
$cachedObjectDAV
Cached object handler.
catch(Exception $e) $message
$clientOS
The operating system of the WebDAV client.
writelog($message)
Writes a message to the logfile.,.
getLogin($userId)
Returns the login for the specified user id, or null if the user does not exist.
__construct()
Constructor.
PROPFIND(&$options, &$files)
PROPFIND method handler.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
isFileHidden(&$objDAV)
Returns true, if the resource has a file name which is hidden from the user.
mkprop()
helper for property element creation
static _getWebfolderInstructionsFor( $webfolderTitle, $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus, $os='unknown', $osFlavor='unknown')
Gets Webfolder mount instructions for the specified webfolder.
getObjectURI($refId, $ressourceName=null, $parentRefId=null)
Returns an URI for getting a object using WebDAV by its name.
Add a drawing to the header
fileinfo($resourcePath, $displayPath, &$objDAV)
Creates file info properties for a single file/resource.
static getInstance()
Get singelton instance.
Create styles array
The data for the language used.
tryAuthentication()
Try authentication.
MKCOL($options)
MKCOL method handler.
davBasename($path)
Private implementation of PHP basename() function.
const STATUS_AUTHENTICATED
davUrlEncode($path)
We do not implement this method, because authentication is done by ilias3/webdav.php.
PUT(&$options)
PUT method handler.
getDir(&$objDAV, &$options)
GET method handler for directories.
PROPPATCH(&$options)
PROPPATCH method handler.
toNodePath($davPath)
Converts a DAV path into a node path.
static getInstance()
Get status instance.
$properties
Handler for properties.
static getLogger($a_component_id)
Get component logger.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
davDeslashify($path)
davDeslashify - make sure path does not end in a slash
isWebDAVoverHTTPS()
Returns true, if the WebDAV server transfers data over HTTPS.
toObjectPath($davPath)
Converts a DAV path into an array of DAV objects.
getFolderURI($refId, $nodeId=0, $ressourceName=null, $parentRefId=null)
Returns an URI for mounting the repository object as a webfolder using Internet Explorer and Firefox ...
const STATUS_ACCOUNT_MIGRATION_REQUIRED
static getValidFilename($a_filename)
Get valid filename.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
getMountURI($refId, $nodeId=0, $ressourceName=null, $parentRefId=null, $genericURI=false)
Returns an URI for mounting the repository object as a webfolder.
getUploadMaxFilesize()
Gets the maximum permitted upload filesize from php.ini in bytes.
UNLOCK(&$options)
UNLOCK method handler.
getObject($davPath)
Gets a DAV object for the specified path.