diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-10-30 22:59:55 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-10-30 22:59:55 +0100 |
commit | 6e9e2634978f08494a13bb3c5185032fc0ed7792 (patch) | |
tree | 8f0cf5eef65c29715c84b2c253834a2fa047bbd7 /apps/files_external/lib/webdav.php | |
parent | 890fbb82993db294489fb6ecf14d91d7652763d1 (diff) | |
parent | 6738275b01abf514d32171da604da8d63a2808e0 (diff) | |
download | nextcloud-server-6e9e2634978f08494a13bb3c5185032fc0ed7792.tar.gz nextcloud-server-6e9e2634978f08494a13bb3c5185032fc0ed7792.zip |
merge master into filesystem
Diffstat (limited to 'apps/files_external/lib/webdav.php')
-rw-r--r-- | apps/files_external/lib/webdav.php | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index aafecdab672..26d24ceff03 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -25,8 +25,8 @@ class DAV extends \OC\Files\Storage\Common{ public function __construct($params) { $host = $params['host']; //remove leading http[s], will be generated in createBaseUri() - if (substr($host,0,8) == "https://") $host = substr($host, 8); - else if (substr($host,0,7) == "http://") $host = substr($host, 7); + if (substr($host, 0, 8) == "https://") $host = substr($host, 8); + else if (substr($host, 0, 7) == "http://") $host = substr($host, 7); $this->host=$host; $this->user=$params['user']; $this->password=$params['password']; @@ -35,7 +35,7 @@ class DAV extends \OC\Files\Storage\Common{ if(!$this->root || $this->root[0]!='/') { $this->root='/'.$this->root; } - if(substr($this->root,-1,1)!='/') { + if(substr($this->root, -1, 1)!='/') { $this->root.='/'; } } @@ -80,20 +80,20 @@ class DAV extends \OC\Files\Storage\Common{ public function mkdir($path) { $this->init(); $path=$this->cleanPath($path); - return $this->simpleResponse('MKCOL',$path, null,201); + return $this->simpleResponse('MKCOL', $path, null, 201); } public function rmdir($path) { $this->init(); $path=$this->cleanPath($path); - return $this->simpleResponse('DELETE',$path, null,204); + return $this->simpleResponse('DELETE', $path, null, 204); } public function opendir($path) { $this->init(); $path=$this->cleanPath($path); try{ - $response=$this->client->propfind($path, array(),1); + $response=$this->client->propfind($path, array(), 1); $id=md5('webdav'.$this->root.$path); \OC_FakeDirStream::$dirs[$id]=array(); $files=array_keys($response); @@ -158,7 +158,7 @@ class DAV extends \OC\Files\Storage\Common{ //straight up curl instead of sabredav here, sabredav put's the entire get result in memory $curl = curl_init(); $fp = fopen('php://temp', 'r+'); - curl_setopt($curl,CURLOPT_USERPWD,$this->user.':'.$this->password); + curl_setopt($curl, CURLOPT_USERPWD, $this->user.':'.$this->password); curl_setopt($curl, CURLOPT_URL, $this->createBaseUri().$path); curl_setopt($curl, CURLOPT_FILE, $fp); @@ -179,18 +179,18 @@ class DAV extends \OC\Files\Storage\Common{ case 'c': case 'c+': //emulate these - if(strrpos($path,'.')!==false) { - $ext=substr($path, strrpos($path,'.')); + if(strrpos($path, '.')!==false) { + $ext=substr($path, strrpos($path, '.')); }else{ $ext=''; } - $tmpFile=\OCP\Files::tmpFile($ext); - \OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); + $tmpFile = \OCP\Files::tmpFile($ext); + \OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack'); if($this->file_exists($path)) { - $this->getFile($path,$tmpFile); + $this->getFile($path, $tmpFile); } self::$tempFiles[$tmpFile]=$path; - return fopen('close://'.$tmpFile,$mode); + return fopen('close://'.$tmpFile, $mode); } } @@ -233,10 +233,10 @@ class DAV extends \OC\Files\Storage\Common{ public function uploadFile($path,$target) { $this->init(); - $source=fopen($path,'r'); + $source=fopen($path, 'r'); $curl = curl_init(); - curl_setopt($curl,CURLOPT_USERPWD,$this->user.':'.$this->password); + curl_setopt($curl, CURLOPT_USERPWD, $this->user.':'.$this->password); curl_setopt($curl, CURLOPT_URL, $this->createBaseUri().$target); curl_setopt($curl, CURLOPT_BINARYTRANSFER, true); curl_setopt($curl, CURLOPT_INFILE, $source); // file pointer @@ -305,7 +305,7 @@ class DAV extends \OC\Files\Storage\Common{ private function cleanPath($path) { if(!$path || $path[0]=='/') { - return substr($path,1); + return substr($path, 1); }else{ return $path; } @@ -314,7 +314,7 @@ class DAV extends \OC\Files\Storage\Common{ private function simpleResponse($method,$path,$body,$expected) { $path=$this->cleanPath($path); try{ - $response=$this->client->request($method,$path,$body); + $response=$this->client->request($method, $path, $body); return $response['statusCode']==$expected; }catch(\Exception $e) { return false; |