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 
'Services/Utilities/classes/class.ilFileUtils.php';
 
   32require_once 
'include/Unicode/UtfNormal.php';
 
   33require_once 
'Services/Tracking/classes/class.ilChangeEvent.php';
 
  146                $userAgent = strtolower(
$_SERVER[
'HTTP_USER_AGENT']);
 
  147                $this->
writelog(
'userAgent='.$userAgent);
 
  148                if (strpos($userAgent,
'windows') !== 
false 
  149                || strpos($userAgent,
'microsoft') !== 
false)
 
  151                        $this->clientOS = 
'windows';
 
  152                        if(strpos($userAgent,
'nt 5.1') !== 
false){
 
  153                            $this->clientOSFlavor = 
'xp';
 
  155                            $this->clientOSFlavor = 
'nichtxp';
 
  158                } 
else if (strpos($userAgent,
'darwin') !== 
false 
  159                || strpos($userAgent,
'macintosh') !== 
false 
  160                || strpos($userAgent,
'linux') !== 
false 
  161                || strpos($userAgent,
'solaris') !== 
false 
  162                || strpos($userAgent,
'aix') !== 
false 
  163                || strpos($userAgent,
'unix') !== 
false 
  164                || strpos($userAgent,
'gvfs') !== 
false  
  167                        $this->clientOS = 
'unix';
 
  168                        if (strpos($userAgent,
'linux') !== 
false)
 
  170                                $this->clientOSFlavor = 
'linux';
 
  172                        else if (strpos($userAgent,
'macintosh') !== 
false)
 
  174                                $this->clientOSFlavor = 
'osx';
 
  177                if (strpos($userAgent,
'konqueror') !== 
false)
 
  179                        $this->clientBrowser = 
'konqueror';
 
  189                if(self::$instance != NULL)
 
  202                if (!self::_isActive())
 
  204                        $this->
writelog(__METHOD__.
' WebDAV disabled. Aborting');
 
  206                        echo 
'<html><body><h1>Sorry</h1>'.
 
  207                                '<p><b>Please enable the WebDAV plugin in the ILIAS Administration panel.</b></p>'.
 
  208                                '<p>You can only access this page, if WebDAV is enabled on this server.</p>'.
 
  216                        parent::serveRequest();
 
  218                        $this->
writelog(
'serveRequest():'.$_SERVER[
'REQUEST_METHOD'].
' done status='.$this->_http_status.
' elapsed='.($end - $start));
 
  223            $this->
writelog(
'serveRequest():'.
$_SERVER[
'REQUEST_METHOD'].
' caught exception: '.$e->getMessage().
'\n'.$e->getTraceAsString());
 
  268                $c = explode(
'/',
$path);
 
  269                for ($i = 0; $i < count($c); $i++)
 
  271                        $c[$i] = str_replace(
'+',
'%20',urlencode($c[$i]));
 
  273                return implode(
'/',$c);
 
  289                $this->
writelog(
'PROPFIND(options:'.var_export(
$options, 
true).
' files:'.var_export($files, 
true).
'.)');
 
  297                $files[
'files'] = array();
 
  300                if (is_null($objDAV)) {
 
  303                if (! $objDAV->isPermitted(
'visible,read')) {
 
  304                        return '403 Forbidden';
 
  311                $GLOBALS[
'ilLog']->write(print_r($encodedPath,
true));
 
  313                $files[
'files'][] =& $this->
fileinfo($encodedPath, $encodedPath, $objDAV);
 
  321                        $breadthFirst = array($objDAV);
 
  322                        $objDAV->encodedPath = $encodedPath;
 
  324                        while (count($breadthFirst) > 0) {
 
  326                                $collectionDAV = array_shift($breadthFirst);
 
  327                                $childrenDAV =& $collectionDAV->childrenWithPermission(
'visible,read');
 
  328                                foreach ($childrenDAV as $childDAV)
 
  332                                        foreach ($childrenDAV as $duplChildDAV)
 
  334                                                if ($duplChildDAV->getObjectId() < $childDAV->getObjectId() &&
 
  335                                                                $duplChildDAV->getResourceName() == $childDAV->getResourceName())
 
  344                                                $this->
writelog(
'PROPFIND() child ref_id='.$childDAV->getRefId());
 
  345                                                $files[
'files'][] =& $this->
fileinfo(
 
  346                                                        $collectionDAV->encodedPath.
'/'.$this->davUrlEncode($childDAV->getResourceName()),
 
  347                                                        $collectionDAV->encodedPath.
'/'.$this->davUrlEncode($childDAV->getDisplayName()),
 
  350                                                if (
$options[
'depth']==
'infinity' && $childDAV->isCollection()) {
 
  352                                                        $breadthFirst[] = $childDAV;
 
  353                                                        $childDAV->encodedPath = $collectionDAV->encodedPath.
'/'.$this->
davUrlEncode($childDAV->getResourceName());
 
  364                        $objDAV->getObjectId(), 
$ilUser->getId(), 
false);
 
  367                $this->
writelog(
'PROPFIND():true options='.var_export(
$options, 
true).
' files='.var_export($files,
true));
 
  384                if ($objDAV->isNullResource()) {
 
  385                        if (count($this->locks->getLocksOnObjectDAV($objDAV)) == 0) {
 
  390                $name = $objDAV->getResourceName();
 
  391                $isFileHidden = 
false;
 
  392                switch ($this->clientOS)
 
  398                                || substr($name, 0, 2) == 
'~$';
 
  400                        $isFileHidden |= preg_match(
'/\\//', $name);
 
  404                        $isFileHidden = substr($name, 0, 1) == 
'.';
 
  406                        $isFileHidden |= preg_match(
'/\\\\|\\/|:|\\*|\\?|"|<|>|\\|/', $name);
 
  410                        $isFileHidden |= preg_match(
'/\\//', $name);
 
  413                $this->
writelog($this->clientOS.
' '.$name.
' isHidden:'.$isFileHidden.
' clientOS:'.$this->clientOS);
 
  414                return $isFileHidden;
 
  424        private function fileinfo($resourcePath, $displayPath, &$objDAV)
 
  428                $this->
writelog(
'fileinfo('.$resourcePath.
')');
 
  435                if ($objDAV->isCollection() && $this->clientOSFlavor != 
'osx') {
 
  436                        $info[
'path'] = $resourcePath.
'/';
 
  438                        $info[
'path'] = $resourcePath;
 
  441                $info[
'props'] = array();
 
  444                $info[
"props"][] =& $this->
mkprop(
"displayname", $displayPath);
 
  447                $info[
"props"][] =& $this->
mkprop(
"creationdate", $objDAV->getCreationTimestamp());
 
  448                $info[
"props"][] =& $this->
mkprop(
"getlastmodified", $objDAV->getModificationTimestamp());
 
  451                $info[
"props"][] =& $this->
mkprop(
"resourcetype", $objDAV->getResourceType());
 
  452                $info[
"props"][] =& $this->
mkprop(
"getcontenttype", $objDAV->getContentType());
 
  453                $info[
"props"][] =& $this->
mkprop(
"getcontentlength", $objDAV->getContentLength());
 
  456                if ($objDAV->isPermitted(
'write'))
 
  460                                        .
'<D:lockscope><D:exclusive/></D:lockscope>' 
  461                                        .
'<D:locktype><D:write/></D:locktype>' 
  464                                        .
'<D:lockscope><D:shared/></D:lockscope>' 
  465                                        .
'<D:locktype><D:write/></D:locktype>' 
  473                $locks = $this->locks->getLocksOnObjectDAV($objDAV);
 
  481                        if ($lock[
'ilias_owner'] == $ilias->account->getId())
 
  483                                $owner = $lock[
'dav_owner'];
 
  485                                $owner = 
'<D:href>'.$this->getLogin($lock[
'ilias_owner']).
'</D:href>';
 
  487                        $this->
writelog(
'lockowner='.$owner.
' ibi:'.$lock[
'ilias_owner'].
' davi:'.$lock[
'dav_owner']);
 
  491                                .
'<D:lockscope><D:'.$lock[
'scope'].
'/></D:lockscope>' 
  493                                .
'<D:locktype><D:write/></D:locktype>' 
  494                                .
'<D:depth>'.$lock[
'depth'].
'</D:depth>' 
  495                                .
'<D:owner>'.$owner.
'</D:owner>' 
  499                                .
'<D:timeout>Second-'.(($lock[
'expires'] > 1000000) ? $lock[
'expires']-time():$lock[
'expires']).
'</D:timeout>' 
  500                                .
'<D:locktoken><D:href>'.$lock[
'token'].
'</D:href></D:locktoken>' 
  504                if (strlen($lockdiscovery) > 0)
 
  506                        $info[
"props"][] =& $this->
mkprop(
"lockdiscovery", $lockdiscovery);
 
  513                        $info[
"props"][] = $this->
mkprop($prop[
'namespace'], $prop[
'name'], $prop[
'value']);
 
  543                if (is_null($objDAV) || $objDAV->isNullResource())
 
  548                if (! $objDAV->isPermitted(
'visible,read'))
 
  550                        return '403 Forbidden';
 
  554                if ($objDAV->isCollection())
 
  556                        if (isset(
$_GET[
'mount']))
 
  560                        else if (isset(
$_GET[
'mount-instructions']))
 
  570                $options[
'mimetype'] =& $objDAV->getContentType();
 
  575                $options[
'mtime'] =& $objDAV->getModificationTimestamp();
 
  578                $options[
'size'] =& $objDAV->getContentLength();
 
  581                $options[
'stream'] =& $objDAV->getContentStream();
 
  584                        $options[
'data'] =& $objDAV->getContentData();
 
  589                        $objDAV->getObjectId(), 
$ilUser->getId());
 
  610                header(
'Content-Type: application/davmount+xml');
 
  612                echo 
"<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n";
 
  613                echo 
"  </dm:url>".$this->base_uri.
"</dm:url>\n";
 
  615                $xmlPath = str_replace(
'&',
'&',
$path);
 
  616                $xmlPath = str_replace(
'<',
'<',$xmlPath);
 
  617                $xmlPath = str_replace(
'>',
'>',$xmlPath);
 
  619                echo 
"  </dm:open>$xmlPath</dm:open>\n";
 
  620                echo 
"</dm:mount>\n";
 
  644                foreach ($objectPath as $object)
 
  646                        if ($object->getRefId() == 1 && $this->isFileHidden($object))
 
  651                                $fullPath .= 
'/ref_1';
 
  655                                $fullPath .= 
'/'.$this->davUrlEncode($object->getResourceName());
 
  660                $shortenedPath = 
'/ref_'.
 
  661                                $objectPath[count($objectPath) - 1]->getRefId();
 
  663                if ($objDAV->isCollection())
 
  665                        $shortenedPath .= 
'/';
 
  670                $shortenedPath = 
'/'.CLIENT_ID.$shortenedPath;
 
  671                $fullPath = 
'/'.CLIENT_ID.$fullPath;
 
  676                $webfolderURI = $this->base_uri.$shortenedPath;
 
  678                                substr($this->base_uri, strrpos($this->base_uri,
':')).
 
  682                                substr($this->base_uri, strrpos($this->base_uri,
':')).
 
  685                $webfolderURI_IE = $this->base_uri.$shortenedPath;
 
  687                $webfolderTitle = $objectPath[count($objectPath) - 1]->getResourceName();
 
  689                header(
'Content-Type: text/html; charset=UTF-8');
 
  690                echo 
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 
  691                echo 
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
 
  692                echo 
"  \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
 
  693                echo 
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
 
  695                echo 
"  <title>".sprintf(
$lng->txt(
'webfolder_instructions_titletext'), $webfolderTitle).
"</title>\n";
 
  700                        $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
 
  701                        $this->clientOS,$this->clientOSFlavor);
 
  707                if(
$ilUser->getId() == ANONYMOUS_USER_ID)
 
  740                        header(
'Location: '.$this->base_uri.$path.
'/');
 
  744                header(
'Content-Type: text/html; charset=UTF-8');
 
  747                $format = 
"%15s  %-19s  %-s\n";
 
  749                echo 
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 
  750                echo 
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
 
  751                echo 
"  \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
 
  752                echo 
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
 
  754                echo 
"<title>".sprintf(
$lng->txt(
'webfolder_index_of'), 
$path).
"</title>\n";
 
  758                echo 
"<style type=\"text/css\">\n";
 
  761                echo 
"  behavior:url(#default#AnchorClick);\n";
 
  766                echo 
"</head><body>\n";
 
  769                $pathComponents = explode(
'/',
$path);
 
  770                $uriComponents = array();
 
  771                foreach ($pathComponents as $component)
 
  775                for ($i = 0; $i < count($pathComponents); $i++)
 
  777                        $displayName = htmlspecialchars($pathComponents[$i]);
 
  781                        $uriPath = implode(
'/', array_slice($uriComponents,0,$i + 1));
 
  787                                $hrefPath .= $displayName;
 
  791                                $hrefPath .= 
'<a href="'.$this->base_uri.$uriPath.
'/">'.$displayName.
'</a>';
 
  794                echo 
"<h3>".sprintf(
$lng->txt(
'webfolder_index_of'), $hrefPath).
"</h3>\n";
 
  797                if ($ilias->account->getLogin() == 
'anonymous')
 
  799                        echo 
"<p><font size=\"-1\">".$lng->txt(
'not_logged_in').
"</font><br>\n";
 
  801                        echo 
"<p><font size=\"-1\">".$lng->txt(
'login_as').
" <i>" 
  802                                .$ilias->account->getFirstname().
' ' 
  803                                .$ilias->account->getLastname().
' ' 
  804                                .
' '.$ilias->account->getLogin().
'</i> ' 
  805                                .
', '.
$lng->txt(
'client').
' <i>'.$ilias->getClientId().
'</i>.' 
  810                $href = $this->base_uri.$uriPath;
 
  813                if (count($pathComponents) > 2)
 
  815                        $hrefIE = $this->base_uri.
'/'.CLIENT_ID.
'/ref_'.$objDAV->getRefId();
 
  819                echo 
"<p><font size=\"-1\">".
 
  820                                sprintf(
$lng->txt(
'webfolder_dir_info'), 
"$href?mount-instructions").
 
  822                echo 
"<p><font size=\"-1\">".
 
  823                                sprintf(
$lng->txt(
'webfolder_mount_dir_with'),
 
  824                                        "$hrefIE\" folder=\"$hrefIE", 
 
  825                                        'webdav'.substr($href,4), 
 
  826                                        'dav'.substr($href,4), 
 
  832                printf($format, 
$lng->txt(
'size'), 
$lng->txt(
'last_change'), 
$lng->txt(
'filename'));
 
  835                $collectionCount = 0;
 
  837                $children =& $objDAV->childrenWithPermission(
'visible,read');
 
  838                foreach ($children as $childDAV) {
 
  839                        if ($childDAV->isCollection() && !$this->isFileHidden($childDAV))
 
  842                                $name = $this->
davUrlEncode($childDAV->getResourceName());
 
  845                                        strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
 
  846                                        '<a href="'.$name.
'/'.
'">'.$childDAV->getDisplayName().
"</a>");
 
  849                foreach ($children as $childDAV) {
 
  850                        if ($childDAV->isFile() && !$this->isFileHidden($childDAV))
 
  853                                $name = $this->
davUrlEncode($childDAV->getResourceName());
 
  855                                        number_format($childDAV->getContentLength()),
 
  856                                        strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
 
  857                                        '<a href="'.$name.
'">'.$childDAV->getDisplayName().
"</a>");
 
  860                foreach ($children as $childDAV) {
 
  861                        if ($childDAV->isNullResource() && !$this->isFileHidden($childDAV))
 
  863                                $name = $this->
davUrlEncode($childDAV->getResourceName());
 
  866                                        strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
 
  867                                        '<a href="'.$name.
'">'.$childDAV->getDisplayName().
"</a>");
 
  871                echo $collectionCount.
' '.
$lng->txt(($collectionCount == 1) ? 
'folder' : 
'folders').
', ';
 
  872                echo $fileCount.
' '.
$lng->txt(($fileCount == 1) ? 
'file' : 
'files').
'.';
 
  874                echo 
"</body></html>\n";
 
  893                $parent = dirname(
$path);
 
  905                if (is_null($parentDAV) || ! $parentDAV->isCollection()) {
 
  906                        return '409 Conflict';
 
  912                if (
$options[
'content_length'] != 
null &&
 
  915            $this->
writelog(
'PUT is forbidden, because content length='.
 
  916                        $options[
'content_length'].
' is larger than upload_max_filesize='.
 
  919            return '403 Forbidden';
 
  923                include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
 
  927                if (is_null($objDAV))
 
  929                        $ttype = $parentDAV->getILIASFileType();
 
  930                        $isperm = $parentDAV->isPermitted(
'create', $ttype);
 
  933                $this->
writelog(
'PUT is forbidden, because user has no create permission');
 
  935                                return '403 Forbidden';
 
  938                        $objDAV =& $parentDAV->createFile($name);
 
  939                        $this->
writelog(
'PUT obj='.$objDAV.
' name='.$name.
' content_type='.
$options[
'content_type']);
 
  941                        $objDAV->setContentType($mime);
 
  942                        if (
$options[
'content_length'] != 
null)
 
  944                                $objDAV->setContentLength(
$options[
'content_length']);
 
  950                else if ($objDAV->isNullResource())
 
  952                        if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()))
 
  954                $this->
writelog(
'PUT is forbidden, because user has no create permission');
 
  955                                return '403 Forbidden';
 
  958                        $objDAV =& $parentDAV->createFileFromNull($name, $objDAV);
 
  959                        $this->
writelog(
'PUT obj='.$objDAV.
' name='.$name.
' content_type='.
$options[
'content_type']);
 
  961                        $objDAV->setContentType($mime);
 
  962                        if (
$options[
'content_length'] != 
null)
 
  964                                $objDAV->setContentLength(
$options[
'content_length']);
 
  973                        if (! $objDAV->isPermitted(
'write'))
 
  975                $this->
writelog(
'PUT is forbidden, because user has no write permission');
 
  976                                return '403 Forbidden';
 
  979                        $this->
writelog(
'PUT obj='.$objDAV.
' name='.$name.
' content_type='.
$options[
'content_type'].
' content_length='.
$options[
'content_length']);
 
  982                        if ($objDAV->getContentLength() != 0) {
 
  983                                $objDAV->createNewVersion();
 
  987                        $objDAV->setContentType($mime);
 
  988                        if (
$options[
'content_length'] != 
null)
 
  990                        $objDAV->setContentLength(
$options[
'content_length']);
 
  999                $this->putObjDAV = $objDAV;
 
 1001                $out =& $objDAV->getContentOutputStream();
 
 1017                if($this->putObjDAV->getResourceType()==
""){
 
 1018                        $vir = 
ilUtil::virusHandling($this->putObjDAV->obj->getDirectory($this->putObjDAV->obj->version).
'/'.$this->putObjDAV->obj->filename, $this->putObjDAV->obj->filename);
 
 1019                        if ($vir[0] == 
false)
 
 1021                                $this->
writelog(
'PUTfinished Virus found: '.$vir[1]);
 
 1030                if (
$options[
'content_length'] == 
null || $this->putObjDAV->getContentLength() == 0)
 
 1033                        if ($objDAV->getContentOutputStreamLength() != 
null) {
 
 1034                                $objDAV->setContentLength($objDAV->getContentOutputStreamLength());
 
 1037                                $objDAV->setContentLength(filesize($objDAV->obj->getDirectory($objDAV->obj->version).
'/'.$objDAV->obj->filename));
 
 1040                        $this->putObjDAV = 
null;
 
 1060                $parent =& dirname(
$path);
 
 1064                if(!empty(
$_SERVER[
"CONTENT_LENGTH"])) {
 
 1065                        return "415 Unsupported media type";
 
 1070                if (! is_null($objDAV))
 
 1072                        return '405 Method not allowed';
 
 1076                $parentDAV =& $this->
getObject($parent);
 
 1079                if (is_null($parentDAV) || ! $parentDAV->isCollection())
 
 1081                        return '409 Conflict';
 
 1084                if (! $parentDAV->isPermitted(
'create',$parentDAV->getILIASCollectionType()))
 
 1086                        return '403 Forbidden';
 
 1091                $objDAV = $parentDAV->createCollection($name);
 
 1093                if ($objDAV != 
null)
 
 1099                $result = ($objDAV != 
null) ? 
"201 Created" : 
"409 Conflict";
 
 1123                if (is_null($objDAV) || $objDAV->isNullResource())
 
 1125                        return '404 Not Found';
 
 1127                if (! $objDAV->isPermitted(
'delete'))
 
 1129                        return '403 Forbidden';
 
 1132                $parentDAV->remove($objDAV);
 
 1137                return '204 No Content';
 
 1155                $srcParent = dirname($src);
 
 1159                $dstParent = dirname($dst);
 
 1161                $this->
writelog(
'move '.$dst.
'   dstname='.$dstName);
 
 1165                                return '409 Conflict (source and destination are the same)';
 
 1169                if (substr($dst,strlen($src)+1) == $src.
'/')
 
 1171                                return '409 Conflict (destination is in subtree of source)';
 
 1177                $srcParentDAV =& $this->
getObject($srcParent);
 
 1178                $dstParentDAV =& $this->
getObject($dstParent);
 
 1181                if ($srcDAV == 
null)
 
 1183                                return '409 Conflict (source does not exist)';
 
 1187                $isOverwritten = 
false;
 
 1188                if ($dstDAV != 
null)
 
 1193                                                if ($dstDAV->isPermitted(
'delete'))
 
 1195                                                                $dstParentDAV->remove($dstDAV);
 
 1197                                                                $isOverwritten = 
true;
 
 1199                                                                return '403 Not Permitted';
 
 1202                                                return '412 Precondition Failed';
 
 1207                if ($dstParentDAV == 
null)
 
 1209                                return '409 Conflict (parent of destination does not exist)';
 
 1212                if ($srcParent == $dstParent)
 
 1217                                if (! $srcDAV->isPermitted(
'write'))
 
 1219                                                return '403 Forbidden';
 
 1221        $this->
writelog(
'rename dstName='.$dstName);
 
 1222                                $srcDAV->setResourceName($dstName);
 
 1228                                if (! $srcDAV->isPermitted(
'delete'))
 
 1230                                                return '403 Forbidden';
 
 1233                                if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
 
 1235                                                return '403 Forbidden';
 
 1237                                $dstParentDAV->addMove($srcDAV, $dstName);
 
 1251                return ($isOverwritten) ? 
'204 No Content' : 
'201 Created';
 
 1268                        return "502 bad gateway";
 
 1272                $srcParent = dirname($src);
 
 1275                $dstParent = dirname($dst);
 
 1281                        return '409 Conflict'; 
 
 1284                if (substr($dst,strlen($src)+1) == $src.
'/')
 
 1286                        return '409 Conflict'; 
 
 1289                $this->
writelog(
'COPY src='.$src.
' dst='.$dst);
 
 1293                $dstParentDAV =& $this->
getObject($dstParent);
 
 1295                if (is_null($srcDAV) || $srcDAV->isNullResource())
 
 1297                        return '409 Conflict'; 
 
 1299                if (is_null($dstParentDAV) || $dstParentDAV->isNullResource())
 
 1301                        return '409 Conflict'; 
 
 1303                $isOverwritten = 
false;
 
 1306                if (! is_null($dstDAV))
 
 1310                                if ($dstDAV->isPermitted(
'delete'))
 
 1312                                        $dstParentDAV->remove($dstDAV);
 
 1316                                        $isOverwritten = 
true;
 
 1318                                        return '403 Forbidden';
 
 1321                                        return '412 Precondition Failed';
 
 1325                if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
 
 1327                        return '403 Forbidden';
 
 1329                $dstDAV = $dstParentDAV->addCopy($srcDAV, $dstName);
 
 1333                        $srcDAV->getObjectId(), 
$ilUser->getId());
 
 1336                return ($isOverwritten) ? 
'204 No Content' : 
'201 Created';
 
 1355                if (is_null($objDAV) || $objDAV->isNullResource()) 
return false;
 
 1357                $isPermitted = $objDAV->isPermitted(
'write');
 
 1358                foreach(
$options[
'props'] as $key => $prop) {
 
 1359                        if (!$isPermitted || $prop[
'ns'] == 
'DAV:')
 
 1361                                $options[
'props'][$key][
'status'] = 
'403 Forbidden';
 
 1363                                $this->properties->put($objDAV, $prop[
'ns'],$prop[
'name'],$prop[
'val']);
 
 1388                if (is_null($objDAV))
 
 1390                        $this->
writelog(
'LOCK handling null-object locking...');
 
 1395                                $this->
writelog(
'LOCK lock-update failed on non-existing null-object.');
 
 1396                                return '412 Precondition Failed';
 
 1399                        $parent = dirname(
$path);
 
 1400                        $parentDAV =& $this->
getObject($parent);
 
 1401                        if (is_null($parentDAV))
 
 1403                                $this->
writelog(
'LOCK lock failed on non-existing path to null-object.');
 
 1404                                return '404 Not Found';
 
 1406                        if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()) &&
 
 1407                                ! $parentDAV->isPermitted(
'create', $parentDAV->getILIASCollectionType()))
 
 1409                                $this->
writelog(
'LOCK lock failed - creation of null object not permitted.');
 
 1410                                return '403 Forbidden';
 
 1418                if (! $objDAV->isNullResource() && ! $objDAV->isPermitted(
'write'))
 
 1420                        $this->
writelog(
'LOCK lock failed - user has no write permission.');
 
 1421                        return '403 Forbidden';
 
 1432                        $success = $this->locks->updateLockWithoutCheckingDAV(
 
 1439                                $data = $this->locks->getLockDAV($objDAV, 
$options[
'update']);
 
 1440                                if (
$data[
'ilias_owner'] == $ilias->account->getId())
 
 1442                                        $owner = 
$data[
'dav_owner'];
 
 1444                                        $owner = 
'<D:href>'.$this->getLogin(
$data[
'ilias_owner']).
'</D:href>';
 
 1455                        $this->
writelog(
'LOCK create new lock');
 
 1464                        $this->
writelog(
'lock owner='.$owner);
 
 1465                        $success = $this->locks->lockWithoutCheckingDAV(
 
 1467                                $ilias->account->getId(),
 
 1491                global 
$log, $ilias;
 
 1498                if (is_null($objDAV)) {
 
 1499                        return '404 Not Found';
 
 1501                if (! $objDAV->isPermitted(
'write')) {
 
 1502                        return '403 Forbidden';
 
 1505                $success = $this->locks->unlockWithoutCheckingDAV(
 
 1512                if ($objDAV->isNullResource()
 
 1513                && count($this->locks->getLocksOnObjectDAV($objDAV)) == 0)
 
 1516                        $parentDAV =& $this->
getObject($parent);
 
 1517                        $parentDAV->remove($objDAV);
 
 1523                return (
$success) ? 
'200 OK' : 
'412 Precondition Failed';
 
 1550                if (! is_null($objPath))
 
 1552                        $objDAV = $objPath[count($objPath) - 1];
 
 1553                        $locks = $this->locks->getLocksOnPathDAV($objPath);
 
 1554                        foreach (
$locks as $lock)
 
 1556                                $isLastPathComponent = $lock[
'obj_id'] == $objDAV->getObjectId()
 
 1557                                && $lock[
'node_id'] == $objDAV->getNodeId();
 
 1561                                if ($isLastPathComponent || $lock[
'depth'] == 
'infinity')
 
 1567                                        if ($lock[
'ilias_owner'] == $ilias->account->getId())
 
 1569                                                $owner = $lock[
'dav_owner'];
 
 1571                                                $owner = $this->
getLogin($lock[
'ilias_owner']);
 
 1578                                                "obj_id"   => $lock[
'obj_id'],
 
 1579                                                "node_id"   => $lock[
'node_id'],
 
 1580                                                "scope"   => $lock[
'scope'],
 
 1581                                                "depth"   => $lock[
'depth'],
 
 1583                                                "token"   => $lock[
'token'],
 
 1584                                                "expires" => $lock[
'expires']
 
 1586                                        if ($lock[
'scope'] == 
'exclusive')
 
 1609                $this->
writelog(
'getLogin('.$userId.
'):'.var_export($login,
true));
 
 1628                $davPathComponents = split(
'/',substr($davPath,1));
 
 1629                if (count($davPathComponents) > 1 &&
 
 1630                        substr($davPathComponents[1],0,5) == 
'file_')
 
 1632                        $ref_id = substr($davPathComponents[1],5);
 
 1633                        $nodePath = $tree->getNodePath(
$ref_id, $tree->root_id);
 
 1637                        header(
'Pragma: private');
 
 1642                        if ($nodePath == 
null && count($davPathComponents) == 1)
 
 1647                if (is_null($nodePath))
 
 1651                        $top = $nodePath[count($nodePath)  - 1];
 
 1663                $this->
writelog(
'toObjectPath('.$davPath);
 
 1668                if (is_null($nodePath))
 
 1672                        $objectPath = array();
 
 1673                        foreach ($nodePath as $node)
 
 1676                                if (is_null($pathElement))
 
 1680                                $objectPath[] = $pathElement;
 
 1700                $this->
writelog(
'toNodePath('.$davPath.
')...');
 
 1703                $titlePath = split(
'/',substr($davPath,1));
 
 1706                if (count($titlePath) > 0)
 
 1708                        array_shift($titlePath);
 
 1712                if (count($titlePath) > 0 && $titlePath[count($titlePath) - 1] == 
'')
 
 1714                        array_pop($titlePath);
 
 1718                if (count($titlePath) == 0)
 
 1720                        $this->
writelog(
'toNodePath('.$davPath.
'):null, because path is empty.');
 
 1728                if (count($titlePath) > 0 && substr($titlePath[0],0,4) == 
'ref_')
 
 1730                        $ref_id = substr($titlePath[0],4);
 
 1731                        array_shift($titlePath);
 
 1734                $nodePath = $tree->getNodePathForTitlePath($titlePath, 
$ref_id);
 
 1736                $this->
writelog(
'toNodePath():'.var_export($nodePath,
true));
 
 1765                $components = split(
'/',
$path);
 
 1766                return count($components) == 0 ? 
'' : $components[count($components) - 1];
 
 1783                                if ($message == 
'---')
 
 1788                                                                $ilias->account->getLogin()
 
 1790                                                .
' ilDAVServer.'.str_replace(
"\n",
";",$message)
 
 1796                                $fh = fopen(
'/opt/ilias/log/ilias.log', 
'a');
 
 1797                                fwrite($fh, date(
'Y-m-d H:i:s '));
 
 1798                                fwrite($fh, str_replace(
"\n",
";",$message));
 
 1799                                fwrite($fh, 
"\n\n");
 
 1817        function getMountURI($refId, $nodeId = 0, $ressourceName = 
null, $parentRefId = 
null, $genericURI = 
false)
 
 1822                } 
else if ($this->clientOS == 
'windows') {
 
 1824                        $query = 
'mount-instructions';
 
 1825                } 
else if ($this->clientBrowser == 
'konqueror') {
 
 1828                } 
else if ($this->clientBrowser == 
'nautilus') {
 
 1833                        $query = 
'mount-instructions';
 
 1835                $baseUri.= 
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 1836                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 1838                $uri = $baseUri.
'/ref_'.$refId.
'/';
 
 1860        function getFolderURI($refId, $nodeId = 0, $ressourceName = 
null, $parentRefId = 
null)
 
 1862                if ($this->clientOS == 
'windows') {
 
 1865                } 
else if ($this->clientBrowser == 
'konqueror') {
 
 1868                } 
else if ($this->clientBrowser == 
'nautilus') {
 
 1875                $baseUri.= 
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 1876                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 1878                $uri = $baseUri.
'/ref_'.$refId.
'/';
 
 1897        public function getObjectURI($refId, $ressourceName = 
null, $parentRefId = 
null)
 
 1901                                "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 1902                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 1904                if (! is_null($ressourceName) && ! is_null($parentRefId))
 
 1907                        $uri = $baseUri.
'/ref_'.$parentRefId.
'/'.$this->
davUrlEncode($ressourceName);
 
 1911                        $nodePath = $tree->getNodePath($refId);
 
 1913                        if (is_null($nodePath) || count($nodePath) < 2)
 
 1918                                $uri = $baseUri.
'/ref_'.$nodePath[count($nodePath) - 2][
'child'].
'/'.
 
 1919                                                $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
 
 1942        public function getFileURI($refId, $ressourceName = 
null, $parentRefId = 
null)
 
 1946                                "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 1947                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 1949                if (! is_null($ressourceName) && ! is_null($parentRefId))
 
 1956                        $nodePath = $tree->getNodePath($refId);
 
 1958                        if (is_null($nodePath) || count($nodePath) < 2)
 
 1963                                $uri = $baseUri.
'/file_'.$nodePath[count($nodePath) - 1][
'child'].
'/'.
 
 1964                                                $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
 
 1976                if ($this->isHTTPS == 
null) {
 
 1978                        require_once 
'./Services/Http/classes/class.ilHTTPS.php';
 
 1995                global $ilClientIniFile;
 
 1996                return $ilClientIniFile->readVariable(
'file_access',
'webdav_enabled') == 
'1' &&
 
 1997                         @include_once(
"Auth/HTTP.php");
 
 2006                global $ilClientIniFile;
 
 2007                return $ilClientIniFile->readVariable(
'file_access',
'webdav_actions_visible') == 
'1';
 
 2022                return $lng->txt(
'webfolder_instructions_text');
 
 2052                        $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
 
 2053                        $os = 
'unknown', $osFlavor = 
'unknown')
 
 2057                $settings = 
new ilSetting(
'file_access');
 
 2058                $str = $settings->get(
'custom_webfolder_instructions', 
'');
 
 2059                if (strlen($str) == 0 || ! $settings->get(
'custom_webfolder_instructions_enabled'))
 
 2063                if(is_file(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm')){
 
 2064                        $str = fread(fopen(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm', 
"rb"),filesize(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm'));
 
 2066                $str=utf8_encode($str);
 
 2068                preg_match_all(
'/(\\d+)/', $webfolderURI, $matches);
 
 2069                $refID=$matches[0][0];
 
 2071                $str = str_replace(
"[WEBFOLDER_ID]", $refID, $str);
 
 2072                $str = str_replace(
"[WEBFOLDER_TITLE]", $webfolderTitle, $str);
 
 2073                $str = str_replace(
"[WEBFOLDER_URI]", $webfolderURI, $str);
 
 2074                $str = str_replace(
"[WEBFOLDER_URI_IE]", $webfolderURI_IE, $str);
 
 2075                $str = str_replace(
"[WEBFOLDER_URI_KONQUEROR]", $webfolderURI_Konqueror, $str);
 
 2076                $str = str_replace(
"[WEBFOLDER_URI_NAUTILUS]", $webfolderURI_Nautilus, $str);
 
 2077                $str = str_replace(
"[ADMIN_MAIL]", 
$ilSetting->get(
"admin_email"), $str);
 
 2079                if(strpos(
$_SERVER[
'HTTP_USER_AGENT'],
'MSIE')!==
false){
 
 2080                        $str = preg_replace(
'/\[IF_IEXPLORE\]((?:.|\n)*)\[\/IF_IEXPLORE\]/',
'\1', $str);
 
 2082                        $str = preg_replace(
'/\[IF_NOTIEXPLORE\]((?:.|\n)*)\[\/IF_NOTIEXPLORE\]/',
'\1', $str);
 
 2088                                $operatingSystem = 
'WINDOWS';
 
 2094                                                $operatingSystem = 
'MAC';
 
 2097                                                $operatingSystem = 
'LINUX';
 
 2100                                                $operatingSystem = 
'LINUX';
 
 2105                                $operatingSystem = 
'UNKNOWN';
 
 2109                if ($operatingSystem != 
'UNKNOWN')
 
 2111                        $str = preg_replace(
'/\[IF_'.$operatingSystem.
'\]((?:.|\n)*)\[\/IF_'.$operatingSystem.
'\]/',
'\1', $str);
 
 2112                        $str = preg_replace(
'/\[IF_([A-Z_]+)\](?:(?:.|\n)*)\[\/IF_\1\]/',
'', $str);
 
 2116                        $str = preg_replace(
'/\[IF_([A-Z_]+)\]((?:.|\n)*)\[\/IF_\1\]/',
'\2', $str);
 
 2127        $val = ini_get(
'upload_max_filesize');
 
 2130        $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.
static getValidFilename($a_filename)
Get valid filename.
static lookupMimeType($path_to_file, $fallback=self::APPLICATION__OCTET_STREAM, $a_external=false)
static _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
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Virtual base class for implementing WebDAV servers.
if(!is_array($argv)) $options
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']