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';
 
  143                $userAgent = strtolower(
$_SERVER[
'HTTP_USER_AGENT']);
 
  144                $this->
writelog(
'userAgent='.$userAgent);
 
  145                if (strpos($userAgent,
'windows') !== 
false 
  146                || strpos($userAgent,
'microsoft') !== 
false)
 
  148                        $this->clientOS = 
'windows';
 
  149                        if(strpos($userAgent,
'nt 5.1') !== 
false){
 
  150                            $this->clientOSFlavor = 
'xp';
 
  152                            $this->clientOSFlavor = 
'nichtxp';
 
  155                } 
else if (strpos($userAgent,
'darwin') !== 
false 
  156                || strpos($userAgent,
'macintosh') !== 
false 
  157                || strpos($userAgent,
'linux') !== 
false 
  158                || strpos($userAgent,
'solaris') !== 
false 
  159                || strpos($userAgent,
'aix') !== 
false 
  160                || strpos($userAgent,
'unix') !== 
false 
  161                || strpos($userAgent,
'gvfs') !== 
false  
  164                        $this->clientOS = 
'unix';
 
  165                        if (strpos($userAgent,
'linux') !== 
false)
 
  167                                $this->clientOSFlavor = 
'linux';
 
  169                        else if (strpos($userAgent,
'macintosh') !== 
false)
 
  171                                $this->clientOSFlavor = 
'osx';
 
  174                if (strpos($userAgent,
'konqueror') !== 
false)
 
  176                        $this->clientBrowser = 
'konqueror';
 
  186                if(self::$instance != NULL)
 
  198                if(
$GLOBALS[
'DIC'][
'ilAuthSession']->isAuthenticated())
 
  206                include_once 
'./Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentialsHTTP.php';
 
  208                $credentials->initFromRequest();
 
  210                include_once 
'./Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
 
  212                $providers = $provider_factory->getProviders($credentials);
 
  214                include_once 
'./Services/Authentication/classes/class.ilAuthStatus.php';
 
  217                include_once 
'./Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
 
  220                $frontend = $frontend_factory->getFrontend(
 
  227                $frontend->authenticate();
 
  229                switch($status->getStatus())
 
  236                                ilInitialisation::initUserAccount();
 
  263                if (!self::_isActive())
 
  265                        $this->
writelog(__METHOD__.
' WebDAV disabled. Aborting');
 
  267                        echo 
'<html><body><h1>Sorry</h1>'.
 
  268                                '<p><b>Please enable the WebDAV plugin in the ILIAS Administration panel.</b></p>'.
 
  269                                '<p>You can only access this page, if WebDAV is enabled on this server.</p>'.
 
  277                        parent::serveRequest();
 
  279                        $this->
writelog(
'serveRequest():'.$_SERVER[
'REQUEST_METHOD'].
' done status='.$this->_http_status.
' elapsed='.($end - 
$start));
 
  284            $this->
writelog(
'serveRequest():'.
$_SERVER[
'REQUEST_METHOD'].
' caught exception: '.$e->getMessage().
'\n'.$e->getTraceAsString());
 
  329                $c = explode(
'/',
$path);
 
  330                for ($i = 0; $i < count($c); $i++)
 
  332                        $c[$i] = str_replace(
'+',
'%20',urlencode($c[$i]));
 
  334                return implode(
'/',$c);
 
  358                $files[
'files'] = array();
 
  361                if (is_null($objDAV)) {
 
  364                if (! $objDAV->isPermitted(
'visible,read')) {
 
  365                        return '403 Forbidden';
 
  372                $GLOBALS[
'ilLog']->write(print_r($encodedPath,
true));
 
  374                $files[
'files'][] =& $this->
fileinfo($encodedPath, $encodedPath, $objDAV);
 
  382                        $breadthFirst = array($objDAV);
 
  383                        $objDAV->encodedPath = $encodedPath;
 
  385                        while (count($breadthFirst) > 0) {
 
  387                                $collectionDAV = array_shift($breadthFirst);
 
  388                                $childrenDAV =& $collectionDAV->childrenWithPermission(
'visible,read');
 
  389                                foreach ($childrenDAV as $childDAV)
 
  393                                        foreach ($childrenDAV as $duplChildDAV)
 
  395                                                if ($duplChildDAV->getObjectId() < $childDAV->getObjectId() &&
 
  396                                                                $duplChildDAV->getResourceName() == $childDAV->getResourceName())
 
  405                                                $this->
writelog(
'PROPFIND() child ref_id='.$childDAV->getRefId());
 
  407                                                        $collectionDAV->encodedPath.
'/'.$this->davUrlEncode($childDAV->getResourceName()),
 
  408                                                        $collectionDAV->encodedPath.
'/'.$this->davUrlEncode($childDAV->getDisplayName()),
 
  411                                                if (
$options[
'depth']==
'infinity' && $childDAV->isCollection()) {
 
  413                                                        $breadthFirst[] = $childDAV;
 
  414                                                        $childDAV->encodedPath = $collectionDAV->encodedPath.
'/'.$this->
davUrlEncode($childDAV->getResourceName());
 
  425                        $objDAV->getObjectId(), 
$ilUser->getId(), 
false);
 
  445                if ($objDAV->isNullResource()) {
 
  446                        if (count($this->locks->getLocksOnObjectDAV($objDAV)) == 0) {
 
  451                $name = $objDAV->getResourceName();
 
  452                $isFileHidden = 
false;
 
  453                switch ($this->clientOS)
 
  459                                || substr($name, 0, 2) == 
'~$';
 
  461                        $isFileHidden |= preg_match(
'/\\//', $name);
 
  465                        $isFileHidden = substr($name, 0, 1) == 
'.';
 
  467                        $isFileHidden |= preg_match(
'/\\\\|\\/|:|\\*|\\?|"|<|>|\\|/', $name);
 
  471                        $isFileHidden |= preg_match(
'/\\//', $name);
 
  474                $this->
writelog($this->clientOS.
' '.$name.
' isHidden:'.$isFileHidden.
' clientOS:'.$this->clientOS);
 
  475                return $isFileHidden;
 
  485        private function fileinfo($resourcePath, $displayPath, &$objDAV)
 
  489                $this->
writelog(
'fileinfo('.$resourcePath.
')');
 
  496                if ($objDAV->isCollection() && $this->clientOSFlavor != 
'osx') {
 
  497                        $info[
'path'] = $resourcePath.
'/';
 
  499                        $info[
'path'] = $resourcePath;
 
  502                $info[
'props'] = array();
 
  505                $info[
"props"][] =& $this->
mkprop(
"displayname", $displayPath);
 
  508                $info[
"props"][] =& $this->
mkprop(
"creationdate", $objDAV->getCreationTimestamp());
 
  509                $info[
"props"][] =& $this->
mkprop(
"getlastmodified", $objDAV->getModificationTimestamp());
 
  512                $info[
"props"][] =& $this->
mkprop(
"resourcetype", $objDAV->getResourceType());
 
  513                $info[
"props"][] =& $this->
mkprop(
"getcontenttype", $objDAV->getContentType());
 
  514                $info[
"props"][] =& $this->
mkprop(
"getcontentlength", $objDAV->getContentLength());
 
  517                if ($objDAV->isPermitted(
'write'))
 
  521                                        .
'<D:lockscope><D:exclusive/></D:lockscope>' 
  522                                        .
'<D:locktype><D:write/></D:locktype>' 
  525                                        .
'<D:lockscope><D:shared/></D:lockscope>' 
  526                                        .
'<D:locktype><D:write/></D:locktype>' 
  534                $locks = $this->locks->getLocksOnObjectDAV($objDAV);
 
  542                        if ($lock[
'ilias_owner'] == $ilias->account->getId())
 
  544                                $owner = $lock[
'dav_owner'];
 
  546                                $owner = 
'<D:href>'.$this->getLogin($lock[
'ilias_owner']).
'</D:href>';
 
  548                        $this->
writelog(
'lockowner='.$owner.
' ibi:'.$lock[
'ilias_owner'].
' davi:'.$lock[
'dav_owner']);
 
  552                                .
'<D:lockscope><D:'.$lock[
'scope'].
'/></D:lockscope>' 
  554                                .
'<D:locktype><D:write/></D:locktype>' 
  555                                .
'<D:depth>'.$lock[
'depth'].
'</D:depth>' 
  556                                .
'<D:owner>'.$owner.
'</D:owner>' 
  560                                .
'<D:timeout>Second-'.(($lock[
'expires'] > 1000000) ? $lock[
'expires']-time():$lock[
'expires']).
'</D:timeout>' 
  561                                .
'<D:locktoken><D:href>'.$lock[
'token'].
'</D:href></D:locktoken>' 
  565                if (strlen($lockdiscovery) > 0)
 
  567                        $info[
"props"][] =& $this->
mkprop(
"lockdiscovery", $lockdiscovery);
 
  574                        $info[
"props"][] = $this->
mkprop($prop[
'namespace'], $prop[
'name'], $prop[
'value']);
 
  604                if (is_null($objDAV) || $objDAV->isNullResource())
 
  609                if (! $objDAV->isPermitted(
'visible,read'))
 
  611                        return '403 Forbidden';
 
  615                if ($objDAV->isCollection())
 
  617                        if (isset(
$_GET[
'mount']))
 
  621                        else if (isset(
$_GET[
'mount-instructions']))
 
  631                $options[
'mimetype'] =& $objDAV->getContentType();
 
  636                $options[
'mtime'] =& $objDAV->getModificationTimestamp();
 
  639                $options[
'size'] =& $objDAV->getContentLength();
 
  642                $options[
'stream'] =& $objDAV->getContentStream();
 
  645                        $options[
'data'] =& $objDAV->getContentData();
 
  650                        $objDAV->getObjectId(), 
$ilUser->getId());
 
  671                header(
'Content-Type: application/davmount+xml');
 
  673                echo 
"<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n";
 
  674                echo 
"  </dm:url>".$this->base_uri.
"</dm:url>\n";
 
  676                $xmlPath = str_replace(
'&',
'&',
$path);
 
  677                $xmlPath = str_replace(
'<',
'<',$xmlPath);
 
  678                $xmlPath = str_replace(
'>',
'>',$xmlPath);
 
  680                echo 
"  </dm:open>$xmlPath</dm:open>\n";
 
  681                echo 
"</dm:mount>\n";
 
  705                foreach ($objectPath as $object)
 
  707                        if ($object->getRefId() == 1 && $this->isFileHidden($object))
 
  712                                $fullPath .= 
'/ref_1';
 
  716                                $fullPath .= 
'/'.$this->davUrlEncode($object->getResourceName());
 
  721                $shortenedPath = 
'/ref_'.
 
  722                                $objectPath[count($objectPath) - 1]->getRefId();
 
  724                if ($objDAV->isCollection())
 
  726                        $shortenedPath .= 
'/';
 
  731                $shortenedPath = 
'/'.CLIENT_ID.$shortenedPath;
 
  732                $fullPath = 
'/'.CLIENT_ID.$fullPath;
 
  737                $webfolderURI = $this->base_uri.$shortenedPath;
 
  739                                substr($this->base_uri, strrpos($this->base_uri,
':')).
 
  743                                substr($this->base_uri, strrpos($this->base_uri,
':')).
 
  746                $webfolderURI_IE = $this->base_uri.$shortenedPath;
 
  748                $webfolderTitle = $objectPath[count($objectPath) - 1]->getResourceName();
 
  750                header(
'Content-Type: text/html; charset=UTF-8');
 
  751                echo 
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 
  752                echo 
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
 
  753                echo 
"  \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
 
  754                echo 
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
 
  756                echo 
"  <title>".sprintf(
$lng->txt(
'webfolder_instructions_titletext'), $webfolderTitle).
"</title>\n";
 
  761                        $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
 
  762                        $this->clientOS,$this->clientOSFlavor);
 
  768                if(
$ilUser->getId() == ANONYMOUS_USER_ID)
 
  770                        $GOBALS[
'DIC'][
'ilAuthSession']->logout();
 
  800                        header(
'Location: '.$this->base_uri.$path.
'/');
 
  804                header(
'Content-Type: text/html; charset=UTF-8');
 
  807                $format = 
"%15s  %-19s  %-s\n";
 
  809                echo 
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 
  810                echo 
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\"\n";
 
  811                echo 
"  \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\">\n";
 
  812                echo 
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
 
  814                echo 
"<title>".sprintf(
$lng->txt(
'webfolder_index_of'), 
$path).
"</title>\n";
 
  818                echo 
"<style type=\"text/css\">\n";
 
  821                echo 
"  behavior:url(#default#AnchorClick);\n";
 
  826                echo 
"</head><body>\n";
 
  829                $pathComponents = explode(
'/',
$path);
 
  830                $uriComponents = array();
 
  831                foreach ($pathComponents as $component)
 
  835                for ($i = 0; $i < count($pathComponents); $i++)
 
  837                        $displayName = htmlspecialchars($pathComponents[$i]);
 
  841                        $uriPath = implode(
'/', array_slice($uriComponents,0,$i + 1));
 
  847                                $hrefPath .= $displayName;
 
  851                                $hrefPath .= 
'<a href="'.$this->base_uri.$uriPath.
'/">'.$displayName.
'</a>';
 
  854                echo 
"<h3>".sprintf(
$lng->txt(
'webfolder_index_of'), $hrefPath).
"</h3>\n";
 
  857                if ($ilias->account->getLogin() == 
'anonymous')
 
  859                        echo 
"<p><font size=\"-1\">".$lng->txt(
'not_logged_in').
"</font><br>\n";
 
  861                        echo 
"<p><font size=\"-1\">".$lng->txt(
'login_as').
" <i>" 
  862                                .$ilias->account->getFirstname().
' ' 
  863                                .$ilias->account->getLastname().
' ' 
  864                                .
' '.$ilias->account->getLogin().
'</i> ' 
  865                                .
', '.
$lng->txt(
'client').
' <i>'.$ilias->getClientId().
'</i>.' 
  870                $href = $this->base_uri.$uriPath;
 
  873                if (count($pathComponents) > 2)
 
  875                        $hrefIE = $this->base_uri.
'/'.CLIENT_ID.
'/ref_'.$objDAV->getRefId();
 
  879                echo 
"<p><font size=\"-1\">".
 
  880                                sprintf(
$lng->txt(
'webfolder_dir_info'), 
"$href?mount-instructions").
 
  882                echo 
"<p><font size=\"-1\">".
 
  884                                        "$hrefIE\" folder=\"$hrefIE", 
 
  885                                        'webdav'.substr($href,4), 
 
  886                                        'dav'.substr($href,4), 
 
  892                printf($format, 
$lng->txt(
'size'), 
$lng->txt(
'last_change'), 
$lng->txt(
'filename'));
 
  895                $collectionCount = 0;
 
  897                $children =& $objDAV->childrenWithPermission(
'visible,read');
 
  898                foreach ($children as $childDAV) {
 
  899                        if ($childDAV->isCollection() && !$this->isFileHidden($childDAV))
 
  902                                $name = $this->
davUrlEncode($childDAV->getResourceName());
 
  905                                        strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
 
  906                                        '<a href="'.$name.
'/'.
'">'.$childDAV->getDisplayName().
"</a>");
 
  909                foreach ($children as $childDAV) {
 
  910                        if ($childDAV->isFile() && !$this->isFileHidden($childDAV))
 
  913                                $name = $this->
davUrlEncode($childDAV->getResourceName());
 
  915                                        number_format($childDAV->getContentLength()),
 
  916                                        strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
 
  917                                        '<a href="'.$name.
'">'.$childDAV->getDisplayName().
"</a>");
 
  920                foreach ($children as $childDAV) {
 
  921                        if ($childDAV->isNullResource() && !$this->isFileHidden($childDAV))
 
  923                                $name = $this->
davUrlEncode($childDAV->getResourceName());
 
  926                                        strftime(
"%Y-%m-%d %H:%M:%S", $childDAV->getModificationTimestamp()),
 
  927                                        '<a href="'.$name.
'">'.$childDAV->getDisplayName().
"</a>");
 
  931                echo $collectionCount.
' '.
$lng->txt(($collectionCount == 1) ? 
'folder' : 
'folders').
', ';
 
  932                echo $fileCount.
' '.
$lng->txt(($fileCount == 1) ? 
'file' : 
'files').
'.';
 
  934                echo 
"</body></html>\n";
 
  953                $parent = dirname(
$path);
 
  965                if (is_null($parentDAV) || ! $parentDAV->isCollection()) {
 
  966                        return '409 Conflict';
 
  972                if (
$options[
'content_length'] != 
null &&
 
  975            $this->
writelog(
'PUT is forbidden, because content length='.
 
  976                        $options[
'content_length'].
' is larger than upload_max_filesize='.
 
  979            return '403 Forbidden';
 
  983                include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
 
  987                if (is_null($objDAV))
 
  989                        $ttype = $parentDAV->getILIASFileType();
 
  990                        $isperm = $parentDAV->isPermitted(
'create', $ttype);
 
  993                $this->
writelog(
'PUT is forbidden, because user has no create permission');
 
  995                                return '403 Forbidden';
 
  998                        $objDAV =& $parentDAV->createFile($name);
 
  999                        $this->
writelog(
'PUT obj='.$objDAV.
' name='.$name.
' content_type='.
$options[
'content_type']);
 
 1001                        $objDAV->setContentType($mime);
 
 1002                        if (
$options[
'content_length'] != 
null)
 
 1004                                $objDAV->setContentLength(
$options[
'content_length']);
 
 1010                else if ($objDAV->isNullResource())
 
 1012                        if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()))
 
 1014                $this->
writelog(
'PUT is forbidden, because user has no create permission');
 
 1015                                return '403 Forbidden';
 
 1018                        $objDAV =& $parentDAV->createFileFromNull($name, $objDAV);
 
 1019                        $this->
writelog(
'PUT obj='.$objDAV.
' name='.$name.
' content_type='.
$options[
'content_type']);
 
 1021                        $objDAV->setContentType($mime);
 
 1022                        if (
$options[
'content_length'] != 
null)
 
 1024                                $objDAV->setContentLength(
$options[
'content_length']);
 
 1033                        if (! $objDAV->isPermitted(
'write'))
 
 1035                $this->
writelog(
'PUT is forbidden, because user has no write permission');
 
 1036                                return '403 Forbidden';
 
 1039                        $this->
writelog(
'PUT obj='.$objDAV.
' name='.$name.
' content_type='.
$options[
'content_type'].
' content_length='.
$options[
'content_length']);
 
 1042                        if ($objDAV->getContentLength() != 0) {
 
 1043                                $objDAV->createNewVersion();
 
 1047                        $objDAV->setContentType($mime);
 
 1048                        if (
$options[
'content_length'] != 
null)
 
 1050                        $objDAV->setContentLength(
$options[
'content_length']);
 
 1059                $this->putObjDAV = $objDAV;
 
 1061                $out =& $objDAV->getContentOutputStream();
 
 1077                if($this->putObjDAV->getResourceType()==
""){
 
 1078                        $vir = 
ilUtil::virusHandling($this->putObjDAV->obj->getDirectory($this->putObjDAV->obj->version).
'/'.$this->putObjDAV->obj->filename, $this->putObjDAV->obj->filename);
 
 1079                        if ($vir[0] == 
false)
 
 1081                                $this->
writelog(
'PUTfinished Virus found: '.$vir[1]);
 
 1090                if (
$options[
'content_length'] == 
null || $this->putObjDAV->getContentLength() == 0)
 
 1093                        if ($objDAV->getContentOutputStreamLength() != 
null) {
 
 1094                                $objDAV->setContentLength($objDAV->getContentOutputStreamLength());
 
 1097                                $objDAV->setContentLength(filesize($objDAV->obj->getDirectory($objDAV->obj->version).
'/'.$objDAV->obj->filename));
 
 1100                        $this->putObjDAV = 
null;
 
 1120                $parent =& dirname(
$path);
 
 1124                if(!empty(
$_SERVER[
"CONTENT_LENGTH"])) {
 
 1125                        return "415 Unsupported media type";
 
 1130                if (! is_null($objDAV))
 
 1132                        return '405 Method not allowed';
 
 1136                $parentDAV =& $this->
getObject($parent);
 
 1139                if (is_null($parentDAV) || ! $parentDAV->isCollection())
 
 1141                        return '409 Conflict';
 
 1144                if (! $parentDAV->isPermitted(
'create',$parentDAV->getILIASCollectionType()))
 
 1146                        return '403 Forbidden';
 
 1151                $objDAV = $parentDAV->createCollection($name);
 
 1153                if ($objDAV != 
null)
 
 1159                $result = ($objDAV != 
null) ? 
"201 Created" : 
"409 Conflict";
 
 1183                if (is_null($objDAV) || $objDAV->isNullResource())
 
 1185                        return '404 Not Found';
 
 1187                if (! $objDAV->isPermitted(
'delete'))
 
 1189                        return '403 Forbidden';
 
 1192                $parentDAV->remove($objDAV);
 
 1197                return '204 No Content';
 
 1215                $srcParent = dirname($src);
 
 1219                $dstParent = dirname($dst);
 
 1221                $this->
writelog(
'move '.$dst.
'   dstname='.$dstName);
 
 1225                                return '409 Conflict (source and destination are the same)';
 
 1229                if (substr($dst,strlen($src)+1) == $src.
'/')
 
 1231                                return '409 Conflict (destination is in subtree of source)';
 
 1237                $srcParentDAV =& $this->
getObject($srcParent);
 
 1238                $dstParentDAV =& $this->
getObject($dstParent);
 
 1241                if ($srcDAV == 
null)
 
 1243                                return '409 Conflict (source does not exist)';
 
 1247                $isOverwritten = 
false;
 
 1248                if ($dstDAV != 
null)
 
 1253                                                if ($dstDAV->isPermitted(
'delete'))
 
 1255                                                                $dstParentDAV->remove($dstDAV);
 
 1257                                                                $isOverwritten = 
true;
 
 1259                                                                return '403 Not Permitted';
 
 1262                                                return '412 Precondition Failed';
 
 1267                if ($dstParentDAV == 
null)
 
 1269                                return '409 Conflict (parent of destination does not exist)';
 
 1272                if ($srcParent == $dstParent)
 
 1277                                if (! $srcDAV->isPermitted(
'write'))
 
 1279                                                return '403 Forbidden';
 
 1281        $this->
writelog(
'rename dstName='.$dstName);
 
 1282                                $srcDAV->setResourceName($dstName);
 
 1288                                if (! $srcDAV->isPermitted(
'delete'))
 
 1290                                                return '403 Forbidden';
 
 1293                                if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
 
 1295                                                return '403 Forbidden';
 
 1297                                $dstParentDAV->addMove($srcDAV, $dstName);
 
 1311                return ($isOverwritten) ? 
'204 No Content' : 
'201 Created';
 
 1328                        return "502 bad gateway";
 
 1332                $srcParent = dirname($src);
 
 1335                $dstParent = dirname($dst);
 
 1341                        return '409 Conflict'; 
 
 1344                if (substr($dst,strlen($src)+1) == $src.
'/')
 
 1346                        return '409 Conflict'; 
 
 1349                $this->
writelog(
'COPY src='.$src.
' dst='.$dst);
 
 1353                $dstParentDAV =& $this->
getObject($dstParent);
 
 1355                if (is_null($srcDAV) || $srcDAV->isNullResource())
 
 1357                        return '409 Conflict'; 
 
 1359                if (is_null($dstParentDAV) || $dstParentDAV->isNullResource())
 
 1361                        return '409 Conflict'; 
 
 1363                $isOverwritten = 
false;
 
 1366                if (! is_null($dstDAV))
 
 1370                                if ($dstDAV->isPermitted(
'delete'))
 
 1372                                        $dstParentDAV->remove($dstDAV);
 
 1376                                        $isOverwritten = 
true;
 
 1378                                        return '403 Forbidden';
 
 1381                                        return '412 Precondition Failed';
 
 1385                if (! $dstParentDAV->isPermitted(
'create', $srcDAV->getILIASType()))
 
 1387                        return '403 Forbidden';
 
 1389                $dstDAV = $dstParentDAV->addCopy($srcDAV, $dstName);
 
 1393                        $srcDAV->getObjectId(), 
$ilUser->getId());
 
 1396                return ($isOverwritten) ? 
'204 No Content' : 
'201 Created';
 
 1415                if (is_null($objDAV) || $objDAV->isNullResource()) 
return false;
 
 1417                $isPermitted = $objDAV->isPermitted(
'write');
 
 1418                foreach(
$options[
'props'] as $key => $prop) {
 
 1419                        if (!$isPermitted || $prop[
'ns'] == 
'DAV:')
 
 1421                                $options[
'props'][$key][
'status'] = 
'403 Forbidden';
 
 1423                                $this->properties->put($objDAV, $prop[
'ns'],$prop[
'name'],$prop[
'val']);
 
 1448                if (is_null($objDAV))
 
 1450                        $this->
writelog(
'LOCK handling null-object locking...');
 
 1455                                $this->
writelog(
'LOCK lock-update failed on non-existing null-object.');
 
 1456                                return '412 Precondition Failed';
 
 1459                        $parent = dirname(
$path);
 
 1460                        $parentDAV =& $this->
getObject($parent);
 
 1461                        if (is_null($parentDAV))
 
 1463                                $this->
writelog(
'LOCK lock failed on non-existing path to null-object.');
 
 1464                                return '404 Not Found';
 
 1466                        if (! $parentDAV->isPermitted(
'create', $parentDAV->getILIASFileType()) &&
 
 1467                                ! $parentDAV->isPermitted(
'create', $parentDAV->getILIASCollectionType()))
 
 1469                                $this->
writelog(
'LOCK lock failed - creation of null object not permitted.');
 
 1470                                return '403 Forbidden';
 
 1478                if (! $objDAV->isNullResource() && ! $objDAV->isPermitted(
'write'))
 
 1480                        $this->
writelog(
'LOCK lock failed - user has no write permission.');
 
 1481                        return '403 Forbidden';
 
 1492                        $success = $this->locks->updateLockWithoutCheckingDAV(
 
 1499                                $data = $this->locks->getLockDAV($objDAV, 
$options[
'update']);
 
 1500                                if (
$data[
'ilias_owner'] == $ilias->account->getId())
 
 1502                                        $owner = 
$data[
'dav_owner'];
 
 1504                                        $owner = 
'<D:href>'.$this->getLogin(
$data[
'ilias_owner']).
'</D:href>';
 
 1515                        $this->
writelog(
'LOCK create new lock');
 
 1524                        $this->
writelog(
'lock owner='.$owner);
 
 1525                        $success = $this->locks->lockWithoutCheckingDAV(
 
 1527                                $ilias->account->getId(),
 
 1551                global 
$log, $ilias;
 
 1558                if (is_null($objDAV)) {
 
 1559                        return '404 Not Found';
 
 1561                if (! $objDAV->isPermitted(
'write')) {
 
 1562                        return '403 Forbidden';
 
 1565                $success = $this->locks->unlockWithoutCheckingDAV(
 
 1572                if ($objDAV->isNullResource()
 
 1573                && count($this->locks->getLocksOnObjectDAV($objDAV)) == 0)
 
 1576                        $parentDAV =& $this->
getObject($parent);
 
 1577                        $parentDAV->remove($objDAV);
 
 1583                return (
$success) ? 
'200 OK' : 
'412 Precondition Failed';
 
 1610                if (! is_null($objPath))
 
 1612                        $objDAV = $objPath[count($objPath) - 1];
 
 1613                        $locks = $this->locks->getLocksOnPathDAV($objPath);
 
 1614                        foreach (
$locks as $lock)
 
 1616                                $isLastPathComponent = $lock[
'obj_id'] == $objDAV->getObjectId()
 
 1617                                && $lock[
'node_id'] == $objDAV->getNodeId();
 
 1621                                if ($isLastPathComponent || $lock[
'depth'] == 
'infinity')
 
 1627                                        if ($lock[
'ilias_owner'] == $ilias->account->getId())
 
 1629                                                $owner = $lock[
'dav_owner'];
 
 1631                                                $owner = $this->
getLogin($lock[
'ilias_owner']);
 
 1638                                                "obj_id"   => $lock[
'obj_id'],
 
 1639                                                "node_id"   => $lock[
'node_id'],
 
 1640                                                "scope"   => $lock[
'scope'],
 
 1641                                                "depth"   => $lock[
'depth'],
 
 1643                                                "token"   => $lock[
'token'],
 
 1644                                                "expires" => $lock[
'expires']
 
 1646                                        if ($lock[
'scope'] == 
'exclusive')
 
 1669                $this->
writelog(
'getLogin('.$userId.
'):'.var_export($login,
true));
 
 1687                $davPathComponents = explode(
'/',substr($davPath,1));
 
 1689                if (count($davPathComponents) > 1 &&
 
 1690                        substr($davPathComponents[1],0,5) == 
'file_')
 
 1692                        $ref_id = substr($davPathComponents[1],5);
 
 1693                        $nodePath = $tree->getNodePath(
$ref_id, $tree->root_id);
 
 1697                        header(
'Pragma: private');
 
 1702                        if ($nodePath == 
null && count($davPathComponents) == 1)
 
 1707                if (is_null($nodePath))
 
 1711                        $top = $nodePath[count($nodePath)  - 1];
 
 1723                $this->
writelog(
'toObjectPath('.$davPath);
 
 1728                if (is_null($nodePath))
 
 1732                        $objectPath = array();
 
 1733                        foreach ($nodePath as $node)
 
 1736                                if (is_null($pathElement))
 
 1740                                $objectPath[] = $pathElement;
 
 1760                $this->
writelog(
'toNodePath('.$davPath.
')...');
 
 1763                $titlePath = explode(
'/',substr($davPath,1));
 
 1766                if (count($titlePath) > 0)
 
 1768                        array_shift($titlePath);
 
 1772                if (count($titlePath) > 0 && $titlePath[count($titlePath) - 1] == 
'')
 
 1774                        array_pop($titlePath);
 
 1778                if (count($titlePath) == 0)
 
 1780                        $this->
writelog(
'toNodePath('.$davPath.
'):null, because path is empty.');
 
 1788                if (count($titlePath) > 0 && substr($titlePath[0],0,4) == 
'ref_')
 
 1790                        $ref_id = substr($titlePath[0],4);
 
 1791                        array_shift($titlePath);
 
 1794                $nodePath = $tree->getNodePathForTitlePath($titlePath, 
$ref_id);
 
 1796                $this->
writelog(
'toNodePath():'.var_export($nodePath,
true));
 
 1825                $components = explode(
'/',
$path);
 
 1826                return count($components) == 0 ? 
'' : $components[count($components) - 1];
 
 1843                                if ($message == 
'---')
 
 1848                                                                $ilias->account->getLogin()
 
 1850                                                .
' ilDAVServer.'.str_replace(
"\n",
";",$message)
 
 1856                                $fh = fopen(
'/opt/ilias/log/ilias.log', 
'a');
 
 1857                                fwrite(
$fh, 
date(
'Y-m-d H:i:s '));
 
 1858                                fwrite(
$fh, str_replace(
"\n",
";",$message));
 
 1859                                fwrite(
$fh, 
"\n\n");
 
 1877        function getMountURI($refId, $nodeId = 0, $ressourceName = 
null, $parentRefId = 
null, $genericURI = 
false)
 
 1882                } 
else if ($this->clientOS == 
'windows') {
 
 1884                        $query = 
'mount-instructions';
 
 1885                } 
else if ($this->clientBrowser == 
'konqueror') {
 
 1888                } 
else if ($this->clientBrowser == 
'nautilus') {
 
 1893                        $query = 
'mount-instructions';
 
 1895                $baseUri.= 
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 1896                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 1898                $uri = $baseUri.
'/ref_'.$refId.
'/';
 
 1920        function getFolderURI($refId, $nodeId = 0, $ressourceName = 
null, $parentRefId = 
null)
 
 1922                if ($this->clientOS == 
'windows') {
 
 1925                } 
else if ($this->clientBrowser == 
'konqueror') {
 
 1928                } 
else if ($this->clientBrowser == 
'nautilus') {
 
 1935                $baseUri.= 
"//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 1936                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 1938                $uri = $baseUri.
'/ref_'.$refId.
'/';
 
 1957        public function getObjectURI($refId, $ressourceName = 
null, $parentRefId = 
null)
 
 1961                                "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 1962                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 1964                if (! is_null($ressourceName) && ! is_null($parentRefId))
 
 1967                        $uri = $baseUri.
'/ref_'.$parentRefId.
'/'.$this->
davUrlEncode($ressourceName);
 
 1971                        $nodePath = $tree->getNodePath($refId);
 
 1973                        if (is_null($nodePath) || count($nodePath) < 2)
 
 1978                                $uri = $baseUri.
'/ref_'.$nodePath[count($nodePath) - 2][
'child'].
'/'.
 
 1979                                                $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
 
 2002        public function getFileURI($refId, $ressourceName = 
null, $parentRefId = 
null)
 
 2006                                "//$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]";
 
 2007                $baseUri = substr($baseUri,0,strrpos($baseUri,
'/')).
'/webdav.php/'.CLIENT_ID;
 
 2009                if (! is_null($ressourceName) && ! is_null($parentRefId))
 
 2016                        $nodePath = $tree->getNodePath($refId);
 
 2018                        if (is_null($nodePath) || count($nodePath) < 2)
 
 2023                                $uri = $baseUri.
'/file_'.$nodePath[count($nodePath) - 1][
'child'].
'/'.
 
 2024                                                $this->
davUrlEncode($nodePath[count($nodePath) - 1][
'title']);
 
 2036                if ($this->isHTTPS == 
null) {
 
 2038                        require_once 
'./Services/Http/classes/class.ilHTTPS.php';
 
 2055                global $ilClientIniFile;
 
 2056                return $ilClientIniFile->readVariable(
'file_access',
'webdav_enabled') == 
'1';
 
 2065                global $ilClientIniFile;
 
 2066                return $ilClientIniFile->readVariable(
'file_access',
'webdav_actions_visible') == 
'1';
 
 2081                return $lng->txt(
'webfolder_instructions_text');
 
 2111                        $webfolderURI, $webfolderURI_IE, $webfolderURI_Konqueror, $webfolderURI_Nautilus,
 
 2112                        $os = 
'unknown', $osFlavor = 
'unknown')
 
 2116                $settings = 
new ilSetting(
'file_access');
 
 2117                $str = $settings->get(
'custom_webfolder_instructions', 
'');
 
 2118                if (strlen($str) == 0 || ! $settings->get(
'custom_webfolder_instructions_enabled'))
 
 2122                if(is_file(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm')){
 
 2123                        $str = fread(fopen(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm', 
"rb"),filesize(
'Customizing/clients/'.CLIENT_ID.
'/webdavtemplate.htm'));
 
 2125                $str=utf8_encode($str);
 
 2127                preg_match_all(
'/(\\d+)/', $webfolderURI, $matches);
 
 2128                $refID=end($matches[0]);
 
 2130                $str = str_replace(
"[WEBFOLDER_ID]", $refID, $str);
 
 2131                $str = str_replace(
"[WEBFOLDER_TITLE]", $webfolderTitle, $str);
 
 2132                $str = str_replace(
"[WEBFOLDER_URI]", $webfolderURI, $str);
 
 2133                $str = str_replace(
"[WEBFOLDER_URI_IE]", $webfolderURI_IE, $str);
 
 2134                $str = str_replace(
"[WEBFOLDER_URI_KONQUEROR]", $webfolderURI_Konqueror, $str);
 
 2135                $str = str_replace(
"[WEBFOLDER_URI_NAUTILUS]", $webfolderURI_Nautilus, $str);
 
 2136                $str = str_replace(
"[ADMIN_MAIL]", 
$ilSetting->get(
"admin_email"), $str);
 
 2138                if(strpos(
$_SERVER[
'HTTP_USER_AGENT'],
'MSIE')!==
false){
 
 2139                        $str = preg_replace(
'/\[IF_IEXPLORE\](?:(.*))\[\/IF_IEXPLORE\]/s',
'\1', $str);
 
 2141                        $str = preg_replace(
'/\[IF_NOTIEXPLORE\](?:(.*))\[\/IF_NOTIEXPLORE\]/s',
'\1', $str);
 
 2147                                $operatingSystem = 
'WINDOWS';
 
 2153                                                $operatingSystem = 
'MAC';
 
 2156                                                $operatingSystem = 
'LINUX';
 
 2159                                                $operatingSystem = 
'LINUX';
 
 2164                                $operatingSystem = 
'UNKNOWN';
 
 2168                if ($operatingSystem != 
'UNKNOWN')
 
 2170                        $str = preg_replace(
'/\[IF_'.$operatingSystem.
'\](?:(.*))\[\/IF_'.$operatingSystem.
'\]/s',
'\1', $str);
 
 2171                        $str = preg_replace(
'/\[IF_([A-Z_]+)\](?:(.*))\[\/IF_\1\]/s',
'', $str);
 
 2175                        $str = preg_replace(
'/\[IF_([A-Z_]+)\](?:(.*))\[\/IF_\1\]/s',
'\2', $str);
 
 2186        $val = ini_get(
'upload_max_filesize');
 
 2189        $last = strtolower($val[strlen($val)-1]);
 
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
mkprop()
helper for property element creation
http_status($status)
set HTTP return status and mirror it in a private header
static toNFC( $string)
Convert a UTF-8 string to normal form C, canonical composition.
Factory for auth frontend classes.
const STATUS_AUTHENTICATED
static getInstance()
Get status instance.
const STATUS_AUTHENTICATION_FAILED
const STATUS_ACCOUNT_MIGRATION_REQUIRED
static _catchupWriteEvents($obj_id, $usr_id, $timestamp=null)
Catches up with all write events which occured before the specified timestamp.
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.
static _recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
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.
tryAuthentication()
Try authentication.
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 instance.
PUTfinished(&$options)
PUTfinished handler.
$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 ...
__construct()
Constructor.
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 getLogger($a_component_id)
Get component logger.
static lookupMimeType($path_to_file, $fallback=self::APPLICATION__OCTET_STREAM, $a_external=false)
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 virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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']