serverFile = '/' . str_replace( $docRoot, '', $scriptFileName ); } /** * Parses the given URI to a locally understandable path. * * This method retrieves a URI (either full qualified or relative) and * translates it into a local path, which can be understood by the WebDAV * elements. * * @param string $uri * @return string */ public function parseUriToPath( $uri ) { $requestPath = parse_url( $uri, PHP_URL_PATH ); $serverBase = dirname( $this->serverFile ); // Check for request path including index.php if ( strpos( $requestPath, $this->serverFile ) === 0 ) { $path = substr( $requestPath, strlen( $this->serverFile ) ); } // Check for request path without index.php, but with some root to cut else if ( $serverBase !== '/' && strpos( $requestPath, $serverBase ) === 0 ) { $path = substr( $requestPath, strlen( $serverBase ) ); $this->serverFile = $serverBase; } // Already a good path, just use it else { $path = $requestPath; $this->serverFile = ''; } if ( substr( $path, -1, 1 ) === '/' ) { $path = substr( $path, 0, -1 ); $this->collectionPathes[$path] = true; } elseif ( isset( $this->collectionPathes[$path] ) ) { unset( $this->collectionPathes[$path] ); } return ( is_string( $path ) && $path !== '' ? $path : '/' ); } /** * Generates a URI from a local path. * * This method receives a local $path string, representing a node in the * local WebDAV store and translates it into a full qualified URI to be * used as external reference. * * @param string $path * @return string */ public function generateUriFromPath( $path ) { return 'http://' . $_SERVER['SERVER_NAME'] . ( $_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT'] ) . $this->serverFile . $path . ( isset( $this->collectionPathes[$path] ) ? '/' : '' ); } } ?>