25require_once 
"Services/WebDAV/classes/Server.php";
 
   26require_once 
"Services/WebDAV/classes/class.ilDAVLocks.php";
 
   27require_once 
"Services/WebDAV/classes/class.ilDAVProperties.php";
 
   28require_once 
'Services/WebDAV/classes/class.ilObjectDAV.php';
 
   30require_once 
"Services/User/classes/class.ilObjUser.php";
 
   31require_once(
'include/Unicode/UtfNormal.php');
 
   32require_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'].
' ...');
 
  215                        parent::serveRequest();
 
  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");
 
  918                $mime = ilMimeTypeUtil::lookupMimeType($name);
 
  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 || $this->putObjDAV->getContentLength() == 0)
 
 1027                        if ($objDAV->getContentOutputStreamLength() != 
null) {
 
 1028                                $objDAV->setContentLength($objDAV->getContentOutputStreamLength());
 
 1031                                $objDAV->setContentLength(filesize($objDAV->obj->getDirectory($objDAV->obj->version).
'/'.$objDAV->obj->filename));
 
 1034                        $this->putObjDAV = 
null;
 
 1054                $parent =& dirname(
$path);
 
 1058                if(!empty($_SERVER[
"CONTENT_LENGTH"])) {
 
 1059                        return "415 Unsupported media type";
 
 1064                if (! is_null($objDAV))
 
 1066                        return '405 Method not allowed';
 
 1070                $parentDAV =& $this->
getObject($parent);
 
 1073                if (is_null($parentDAV) || ! $parentDAV->isCollection())
 
 1075                        return '409 Conflict';
 
 1078                if (! $parentDAV->isPermitted(
'create',$parentDAV->getILIASCollectionType()))
 
 1080                        return '403 Forbidden';
 
 1085                $objDAV = $parentDAV->createCollection($name);
 
 1087                if ($objDAV != 
null)
 
 1093                $result = ($objDAV != 
null) ? 
"201 Created" : 
"409 Conflict";
 
 1117                if (is_null($objDAV) || $objDAV->isNullResource())
 
 1119                        return '404 Not Found';
 
 1121                if (! $objDAV->isPermitted(
'delete'))
 
 1123                        return '403 Forbidden';
 
 1126                $parentDAV->remove($objDAV);
 
 1131                return '204 No Content';
 
 1149                $srcParent = dirname($src);
 
 1153                $dstParent = dirname($dst);
 
 1155                $this->
writelog(
'move '.$dst.
'   dstname='.$dstName);
 
 1159                                return '409 Conflict (source and destination are the same)';
 
 1163                if (substr($dst,strlen($src)+1) == $src.
'/')
 
 1165                                return '409 Conflict (destination is in subtree of source)';
 
 1171                $srcParentDAV =& $this->
getObject($srcParent);
 
 1172                $dstParentDAV =& $this->
getObject($dstParent);
 
 1175                if ($srcDAV == 
null)
 
 1177                                return '409 Conflict (source does not exist)';
 
 1181                $isOverwritten = 
false;
 
 1182                if ($dstDAV != 
null)
 
 1187                                                if ($dstDAV->isPermitted(
'delete'))
 
 1189                                                                $dstParentDAV->remove($dstDAV);
 
 1191                                                                $isOverwritten = 
true;
 
 1193                                                                return '403 Not Permitted';
 
 1196                                                return '412 Precondition Failed';
 
 1201                if ($dstParentDAV == 
null)
 
 1203                                return '409 Conflict (parent of destination does not exist)';
 
 1206                if ($srcParent == $dstParent)
 
 1211                                if (! $srcDAV->isPermitted(
'write'))
 
 1213                                                return '403 Forbidden';
 
 1215        $this->
writelog(
'rename dstName='.$dstName);
 
 1216                                $srcDAV->setResourceName($dstName);
 
 1222                                if (! $srcDAV->isPermitted(
'delete'))
 
 1224                                                return '403 Forbidden';
 
 1227                                if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
 
 1229                                                return '403 Forbidden';
 
 1231                                $dstParentDAV->addMove($srcDAV, $dstName);
 
 1245                return ($isOverwritten) ? 
'204 No Content' : 
'201 Created';
 
 1262                        return "502 bad gateway";
 
 1266                $srcParent = dirname($src);
 
 1269                $dstParent = dirname($dst);
 
 1275                        return '409 Conflict'; 
 
 1278                if (substr($dst,strlen($src)+1) == $src.
'/')
 
 1280                        return '409 Conflict'; 
 
 1283                $this->
writelog(
'COPY src='.$src.
' dst='.$dst);
 
 1287                $dstParentDAV =& $this->
getObject($dstParent);
 
 1289                if (is_null($srcDAV) || $srcDAV->isNullResource())
 
 1291                        return '409 Conflict'; 
 
 1293                if (is_null($dstParentDAV) || $dstParentDAV->isNullResource())
 
 1295                        return '409 Conflict'; 
 
 1297                $isOverwritten = 
false;
 
 1300                if (! is_null($dstDAV))
 
 1304                                if ($dstDAV->isPermitted(
'delete'))
 
 1306                                        $dstParentDAV->remove($dstDAV);
 
 1310                                        $isOverwritten = 
true;
 
 1312                                        return '403 Forbidden';
 
 1315                                        return '412 Precondition Failed';
 
 1319                if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
 
 1321                        return '403 Forbidden';
 
 1323                $dstDAV = $dstParentDAV->addCopy($srcDAV, $dstName);
 
 1327                        $srcDAV->getObjectId(), 
$ilUser->getId());
 
 1330                return ($isOverwritten) ? 
'204 No Content' : 
'201 Created';
 
 1349                if (is_null($objDAV) || $objDAV->isNullResource()) 
return false;
 
 1351                $isPermitted = $objDAV->isPermitted(
'write');
 
 1352                foreach(
$options[
'props'] as $key => $prop) {
 
 1353                        if (!$isPermitted || $prop[
'ns'] == 
'DAV:')
 
 1355                                $options[
'props'][$key][
'status'] = 
'403 Forbidden';
 
 1357                                $this->properties->put($objDAV, $prop[
'ns'],$prop[
'name'],$prop[
'val']);
 
 1382                if (is_null($objDAV))
 
 1384                        $this->
writelog(
'LOCK handling null-object locking...');
 
 1389                                $this->
writelog(
'LOCK lock-update failed on non-existing null-object.');
 
 1390                                return '412 Precondition Failed';
 
 1393                        $parent = dirname(
$path);
 
 1394                        $parentDAV =& $this->
getObject($parent);
 
 1395                        if (is_null($parentDAV))
 
 1397                                $this->
writelog(
'LOCK lock failed on non-existing path to null-object.');
 
 1398                                return '404 Not Found';
 
 1400                        if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()) &&
 
 1401                                ! $parentDAV->isPermitted(
'create', $parentDAV->getILIASCollectionType()))
 
 1403                                $this->
writelog(
'LOCK lock failed - creation of null object not permitted.');
 
 1404                                return '403 Forbidden';
 
 1412                if (! $objDAV->isNullResource() && ! $objDAV->isPermitted(
'write'))
 
 1414                        $this->
writelog(
'LOCK lock failed - user has no write permission.');
 
 1415                        return '403 Forbidden';
 
 1426                        $success = $this->locks->updateLockWithoutCheckingDAV(
 
 1433                                $data = $this->locks->getLockDAV($objDAV, 
$options[
'update']);
 
 1434                                if (
$data[
'ilias_owner'] == $ilias->account->getId())
 
 1436                                        $owner = 
$data[
'dav_owner'];
 
 1438                                        $owner = 
'<D:href>'.$this->getLogin(
$data[
'ilias_owner']).
'</D:href>';
 
 1449                        $this->
writelog(
'LOCK create new lock');
 
 1458                        $this->
writelog(
'lock owner='.$owner);
 
 1459                        $success = $this->locks->lockWithoutCheckingDAV(
 
 1461                                $ilias->account->getId(),
 
 1485                global 
$log, $ilias;
 
 1492                if (is_null($objDAV)) {
 
 1493                        return '404 Not Found';
 
 1495                if (! $objDAV->isPermitted(
'write')) {
 
 1496                        return '403 Forbidden';
 
 1499                $success = $this->locks->unlockWithoutCheckingDAV(
 
 1506                if ($objDAV->isNullResource()
 
 1507                && count($this->locks->getLocksOnObjectDAV($objDAV)) == 0)
 
 1510                        $parentDAV =& $this->
getObject($parent);
 
 1511                        $parentDAV->remove($objDAV);
 
 1517                return (
$success) ? 
'200 OK' : 
'412 Precondition Failed';
 
 1544                if (! is_null($objPath))
 
 1546                        $objDAV = $objPath[count($objPath) - 1];
 
 1547                        $locks = $this->locks->getLocksOnPathDAV($objPath);
 
 1548                        foreach (
$locks as $lock)
 
 1550                                $isLastPathComponent = $lock[
'obj_id'] == $objDAV->getObjectId()
 
 1551                                && $lock[
'node_id'] == $objDAV->getNodeId();
 
 1555                                if ($isLastPathComponent || $lock[
'depth'] == 
'infinity')
 
 1561                                        if ($lock[
'ilias_owner'] == $ilias->account->getId())
 
 1563                                                $owner = $lock[
'dav_owner'];
 
 1565                                                $owner = $this->
getLogin($lock[
'ilias_owner']);
 
 1572                                                "obj_id"   => $lock[
'obj_id'],
 
 1573                                                "node_id"   => $lock[
'node_id'],
 
 1574                                                "scope"   => $lock[
'scope'],
 
 1575                                                "depth"   => $lock[
'depth'],
 
 1577                                                "token"   => $lock[
'token'],
 
 1578                                                "expires" => $lock[
'expires']
 
 1580                                        if ($lock[
'scope'] == 
'exclusive')
 
 1603                $this->
writelog(
'getLogin('.$userId.
'):'.var_export($login,
true));
 
 1622                $davPathComponents = split(
'/',substr($davPath,1));
 
 1623                if (count($davPathComponents) > 1 &&
 
 1624                        substr($davPathComponents[1],0,5) == 
'file_')
 
 1626                        $ref_id = substr($davPathComponents[1],5);
 
 1627                        $nodePath = $tree->getNodePath(
$ref_id, $tree->root_id);
 
 1631                        header(
'Pragma: private');
 
 1636                        if ($nodePath == 
null && count($davPathComponents) == 1)
 
 1641                if (is_null($nodePath))
 
 1645                        $top = $nodePath[count($nodePath)  - 1];
 
 1657                $this->
writelog(
'toObjectPath('.$davPath);
 
 1662                if (is_null($nodePath))
 
 1666                        $objectPath = array();
 
 1667                        foreach ($nodePath as $node)
 
 1670                                if (is_null($pathElement))
 
 1674                                $objectPath[] = $pathElement;
 
 1694                $this->
writelog(
'toNodePath('.$davPath.
')...');
 
 1697                $titlePath = split(
'/',substr($davPath,1));
 
 1700                if (count($titlePath) > 0)
 
 1702                        array_shift($titlePath);
 
 1706                if (count($titlePath) > 0 && $titlePath[count($titlePath) - 1] == 
'')
 
 1708                        array_pop($titlePath);
 
 1712                if (count($titlePath) == 0)
 
 1714                        $this->
writelog(
'toNodePath('.$davPath.
'):null, because path is empty.');
 
 1722                if (count($titlePath) > 0 && substr($titlePath[0],0,4) == 
'ref_')
 
 1724                        $ref_id = substr($titlePath[0],4);
 
 1725                        array_shift($titlePath);
 
 1728                $nodePath = $tree->getNodePathForTitlePath($titlePath, 
$ref_id);
 
 1730                $this->
writelog(
'toNodePath():'.var_export($nodePath,
true));
 
 1759                $components = split(
'/',
$path);
 
 1760                return count($components) == 0 ? 
'' : $components[count($components) - 1];
 
 1777                                if ($message == 
'---')
 
 1782                                                                $ilias->account->getLogin()
 
 1783                                                .
' '.$_SERVER[
'REMOTE_ADDR'].
':'.$_SERVER[
'REMOTE_PORT']
 
 1784                                                .
' ilDAVServer.'.str_replace(
"\n",
";",$message)
 
 1790                                $fh = fopen(
'/opt/ilias/log/ilias.log', 
'a');
 
 1791                                fwrite($fh, date(
'Y-m-d H:i:s '));
 
 1792                                fwrite($fh, str_replace(
"\n",
";",$message));
 
 1793                                fwrite($fh, 
"\n\n");
 
 1811        function getMountURI($refId, $nodeId = 0, $ressourceName = 
null, $parentRefId = 
null, $genericURI = 
false)
 
 1816                } 
else if ($this->clientOS == 
'windows') {
 
 1818                        $query = 
'mount-instructions';
 
 1819                } 
else if ($this->clientBrowser == 
'konqueror') {
 
 1822                } 
else if ($this->clientBrowser == 
'nautilus') {
 
 1827                        $query = 
'mount-instructions';
 
 1829                $baseUri.= 
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 1830                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 1832                $uri = $baseUri.
'/ref_'.$refId.
'/';
 
 1854        function getFolderURI($refId, $nodeId = 0, $ressourceName = 
null, $parentRefId = 
null)
 
 1856                if ($this->clientOS == 
'windows') {
 
 1859                } 
else if ($this->clientBrowser == 
'konqueror') {
 
 1862                } 
else if ($this->clientBrowser == 
'nautilus') {
 
 1869                $baseUri.= 
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 1870                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 1872                $uri = $baseUri.
'/ref_'.$refId.
'/';
 
 1891        public function getObjectURI($refId, $ressourceName = 
null, $parentRefId = 
null)
 
 1895                                "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 1896                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 1898                if (! is_null($ressourceName) && ! is_null($parentRefId))
 
 1901                        $uri = $baseUri.
'/ref_'.$parentRefId.
'/'.$this->
davUrlEncode($ressourceName);
 
 1905                        $nodePath = $tree->getNodePath($refId);
 
 1907                        if (is_null($nodePath) || count($nodePath) < 2)
 
 1912                                $uri = $baseUri.
'/ref_'.$nodePath[count($nodePath) - 2][
'child'].
'/'.
 
 1913                                                $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
 
 1936        public function getFileURI($refId, $ressourceName = 
null, $parentRefId = 
null)
 
 1940                                "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 1941                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 1943                if (! is_null($ressourceName) && ! is_null($parentRefId))
 
 1950                        $nodePath = $tree->getNodePath($refId);
 
 1952                        if (is_null($nodePath) || count($nodePath) < 2)
 
 1957                                $uri = $baseUri.
'/file_'.$nodePath[count($nodePath) - 1][
'child'].
'/'.
 
 1958                                                $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
 
 1970                if ($this->isHTTPS == 
null) {
 
 1972                        require_once 
'./Services/Http/classes/class.ilHTTPS.php';
 
 1989                global $ilClientIniFile;
 
 1990                return $ilClientIniFile->readVariable(
'file_access',
'webdav_enabled') == 
'1' &&
 
 1991                         @include_once(
"Auth/HTTP.php");
 
 2000                global $ilClientIniFile;
 
 2001                return $ilClientIniFile->readVariable(
'file_access',
'webdav_actions_visible') == 
'1';
 
 2016                return $lng->txt(
'webfolder_instructions_text');
 
 2046                        $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
 
 2047                        $os = 
'unknown', $osFlavor = 
'unknown')
 
 2051                $settings = 
new ilSetting(
'file_access');
 
 2052                $str = $settings->get(
'custom_webfolder_instructions', 
'');
 
 2053                if (strlen($str) == 0 || ! $settings->get(
'custom_webfolder_instructions_enabled'))
 
 2057                if(is_file(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm')){
 
 2058                        $str = fread(fopen(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm', 
"rb"),filesize(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm'));
 
 2060                $str=utf8_encode($str);
 
 2062                preg_match_all(
'/(\\d+)/', $webfolderURI, $matches);
 
 2063                $refID=$matches[0][0];
 
 2065                $str = str_replace(
"[WEBFOLDER_ID]", $refID, $str);
 
 2066                $str = str_replace(
"[WEBFOLDER_TITLE]", $webfolderTitle, $str);
 
 2067                $str = str_replace(
"[WEBFOLDER_URI]", $webfolderURI, $str);
 
 2068                $str = str_replace(
"[WEBFOLDER_URI_IE]", $webfolderURI_IE, $str);
 
 2069                $str = str_replace(
"[WEBFOLDER_URI_KONQUEROR]", $webfolderURI_Konqueror, $str);
 
 2070                $str = str_replace(
"[WEBFOLDER_URI_NAUTILUS]", $webfolderURI_Nautilus, $str);
 
 2071                $str = str_replace(
"[ADMIN_MAIL]", 
$ilSetting->get(
"admin_email"), $str);
 
 2073                if(strpos($_SERVER[
'HTTP_USER_AGENT'],
'MSIE')!==
false){
 
 2074                        $str = preg_replace(
'/\[IF_IEXPLORE\]((?:.|\n)*)\[\/IF_IEXPLORE\]/',
'\1', $str);
 
 2076                        $str = preg_replace(
'/\[IF_NOTIEXPLORE\]((?:.|\n)*)\[\/IF_NOTIEXPLORE\]/',
'\1', $str);
 
 2082                                $operatingSystem = 
'WINDOWS';
 
 2088                                                $operatingSystem = 
'MAC';
 
 2091                                                $operatingSystem = 
'LINUX';
 
 2094                                                $operatingSystem = 
'LINUX';
 
 2099                                $operatingSystem = 
'UNKNOWN';
 
 2103                if ($operatingSystem != 
'UNKNOWN')
 
 2105                        $str = preg_replace(
'/\[IF_'.$operatingSystem.
'\]((?:.|\n)*)\[\/IF_'.$operatingSystem.
'\]/',
'\1', $str);
 
 2106                        $str = preg_replace(
'/\[IF_([A-Z_]+)\](?:(?:.|\n)*)\[\/IF_\1\]/',
'', $str);
 
 2110                        $str = preg_replace(
'/\[IF_([A-Z_]+)\]((?:.|\n)*)\[\/IF_\1\]/',
'\2', $str);
 
 2121        $val = ini_get(
'upload_max_filesize');
 
 2124        $last = strtolower($val[strlen($val)-1]);
 
HTTP_WebDAV_Server()
Constructor.
mkprop()
helper for property element creation
http_status($status)
set HTTP return status and mirror it in a private header
toNFC( $string)
Convert a UTF-8 string to normal form C, canonical composition.
_recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
_catchupWriteEvents($obj_id, $usr_id, $timestamp=null)
Catches up with all write events which occured before the specified timestamp.
_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.
getDir(&$objDAV, &$options)
GET method handler for directories.
$clientBrowser
The name of some well known browsers, that need special support.
LOCK(&$options)
LOCK method handler.
getMountURI($refId, $nodeId=0, $ressourceName=null, $parentRefId=null, $genericURI=false)
Returns an URI for mounting the repository object as a webfolder.
isWebDAVoverHTTPS()
Returns true, if the WebDAV server transfers data over HTTPS.
getFileURI($refId, $ressourceName=null, $parentRefId=null)
Returns an URI for getting a file object using WebDAV.
$isDebug
The WebDAVServer prints lots of log messages to the ilias log, if this variable is set to true.
davUrlEncode($path)
We do not implement this method, because authentication is done by ilias3/webdav.php.
GET(&$options)
GET method handler.
MKCOL($options)
MKCOL method handler.
davBasename($path)
Private implementation of PHP basename() function.
writelog($message)
Writes a message to the logfile.,.
static _isActionsVisible()
Static getter.
DELETE($options)
DELETE method handler.
getLogin($userId)
Returns the login for the specified user id, or null if the user does not exist.
static getInstance()
Get singelton iunstance.
PUTfinished(&$options)
PUTfinished handler.
ilDAVServer()
Constructor.
$cachedObjectDAV
Cached object handler.
davDeslashify($path)
davDeslashify - make sure path does not end in a slash
fileinfo($resourcePath, $displayPath, &$objDAV)
Creates file info properties for a single file/resource.
checkLock($path)
checkLock() helper
PUT(&$options)
PUT method handler.
$clientOS
The operating system of the WebDAV client.
showMountInstructions(&$objDAV, &$options)
Mount instructions method handler for directories.
static _isActive()
Static getter.
toObjectPath($davPath)
Converts a DAV path into an array of DAV objects.
getObjectURI($refId, $ressourceName=null, $parentRefId=null)
Returns an URI for getting a object using WebDAV by its name.
getUploadMaxFilesize()
Gets the maximum permitted upload filesize from php.ini in bytes.
PROPFIND(&$options, &$files)
PROPFIND method handler.
UNLOCK(&$options)
UNLOCK method handler.
static _getDefaultWebfolderInstructions()
Gets instructions for the usage of webfolders.
isFileHidden(&$objDAV)
Returns true, if the resource has a file name which is hidden from the user.
getObject($davPath)
Gets a DAV object for the specified path.
getFolderURI($refId, $nodeId=0, $ressourceName=null, $parentRefId=null)
Returns an URI for mounting the repository object as a webfolder using Internet Explorer and Firefox ...
static _getWebfolderInstructionsFor($webfolderTitle, $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus, $os='unknown', $osFlavor='unknown')
Gets Webfolder mount instructions for the specified webfolder.
mountDir(&$objDAV, &$options)
Mount method handler for directories.
PROPPATCH(&$options)
PROPPATCH method handler.
MOVE($options)
MOVE method handler.
serveRequest()
Serves a WebDAV request.
COPY($options, $del=false)
COPY method handler.
$clientOSFlavor
The flavor of the operating system of the WebDAV client.
$properties
Handler for properties.
_lookupLogin($a_user_id)
lookup login
createObject($refId, $type)
Static factory method to create a DAV object for a given refId and type.
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
Virtual base class for implementing WebDAV servers.
if(!is_array($argv)) $options