diff --git a/lib/webdavlib.php b/lib/webdavlib.php index 6b6dbd43e71..4eddc7d3340 100644 --- a/lib/webdavlib.php +++ b/lib/webdavlib.php @@ -154,7 +154,7 @@ class webdav_client { function open() { // let's try to open a socket $this->_error_log('open a socket connection'); - $this->sock = @fsockopen ($this->_server, $this->_port, $this->_errno, $this->_errstr, $this->_socket_timeout); + $this->sock = fsockopen($this->_server, $this->_port, $this->_errno, $this->_errstr, $this->_socket_timeout); set_time_limit(30); if (is_resource($this->sock)) { socket_set_blocking($this->sock, true); @@ -787,7 +787,6 @@ EOD; fputs($this->sock, $xml); $this->get_respond(); $response = $this->process_respond(); - echo_fb($response); // validate the response ... (only basic validation) // check http-version if ($response['status']['http-version'] == 'HTTP/1.1' || diff --git a/repository/webdav/lib.php b/repository/webdav/lib.php index fd42ea1082c..6c460276ce0 100644 --- a/repository/webdav/lib.php +++ b/repository/webdav/lib.php @@ -61,14 +61,15 @@ class repository_webdav extends repository { public function check_login() { return true; } - public function get_file($url, $title) { + public function get_file($path, $title) { global $CFG; + $path = urldecode($path); $path = $this->prepare_file($title); $buffer = ''; if (!$this->dav->open()) { return false; } - $this->dav->get($url, $buffer); + $this->dav->get($path, $buffer); $fp = fopen($path, 'wb'); fwrite($fp, $buffer); return array('path'=>$path); @@ -96,6 +97,7 @@ class repository_webdav extends repository { } $dir = $this->dav->ls($path); } else { + $path = urldecode($path); if (empty($this->options['webdav_type'])) { $partern = '#http://'.$this->webdav_host.'/#'; } else { @@ -125,8 +127,8 @@ class repository_webdav extends repository { $title = urldecode($v['href']); } $ret['list'][] = array( - 'title'=>$title, - 'thumbnail'=>$OUTPUT->pix_url('f/folder-32').out(false), + 'title'=>urldecode(basename($title)), + 'thumbnail'=>$OUTPUT->pix_url('f/folder-32')->out(false), 'children'=>array(), 'date'=>$filedate, 'size'=>0, @@ -136,6 +138,7 @@ class repository_webdav extends repository { }else{ // a file $title = urldecode(substr($v['href'], strpos($v['href'], $path)+strlen($path))); + $title = basename($title); $size = !empty($v['getcontentlength'])? $v['getcontentlength']:''; $ret['list'][] = array( 'title'=>$title,