summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-06-08 01:29:46 +0200
committerRobin Appelman <icewind@owncloud.com>2012-06-08 01:29:55 +0200
commit4768510923f6bfa3f3473874395a7a61872f1df0 (patch)
tree32655c82dda4dcd779f33b9b41073427c525fc2a /apps/files_external
parent4afcae8d56e880288124605a7b2a9890081601d5 (diff)
downloadnextcloud-server-4768510923f6bfa3f3473874395a7a61872f1df0.tar.gz
nextcloud-server-4768510923f6bfa3f3473874395a7a61872f1df0.zip
split share and root config for smb backend, also sanitize config a bit more
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/lib/smb.php20
-rw-r--r--apps/files_external/tests/config.php3
-rw-r--r--apps/files_external/tests/smb.php2
3 files changed, 21 insertions, 4 deletions
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php
index f5e6d78e776..f594fbb880d 100644
--- a/apps/files_external/lib/smb.php
+++ b/apps/files_external/lib/smb.php
@@ -13,6 +13,7 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
private $user;
private $host;
private $root;
+ private $share;
private static $tempFiles=array();
@@ -20,17 +21,32 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
$this->host=$params['host'];
$this->user=$params['user'];
$this->password=$params['password'];
+ $this->share=$params['share'];
$this->root=isset($params['root'])?$params['root']:'/';
+ if(substr($this->root,-1,1)!='/'){
+ $this->root.='/';
+ }
+ if(substr($this->root,0,1)!='/'){
+ $this->root='/'.$this->root;
+ }
+ if(substr($this->share,0,1)!='/'){
+ $this->share='/'.$this->share;
+ }
+ if(substr($this->share,-1,1)=='/'){
+ $this->share=substr($this->share,0,-1);
+ }
//create the root folder if necesary
- $this->mkdir('');
+ if(!$this->is_dir('')){
+ $this->mkdir('');
+ }
}
public function constructUrl($path){
if(substr($path,-1)=='/'){
$path=substr($path,0,-1);
}
- return 'smb://'.$this->user.':'.$this->password.'@'.$this->host.$this->root.$path;
+ return 'smb://'.$this->user.':'.$this->password.'@'.$this->host.$this->share.$this->root.$path;
}
}
diff --git a/apps/files_external/tests/config.php b/apps/files_external/tests/config.php
index 970008d642c..e58a87fabdf 100644
--- a/apps/files_external/tests/config.php
+++ b/apps/files_external/tests/config.php
@@ -34,7 +34,8 @@ return array(
'user'=>'test',
'password'=>'test',
'host'=>'localhost',
- 'root'=>'/test',
+ 'share'=>'/test',
+ 'root'=>'/test/',
),
'amazons3'=>array(
'run'=>false,
diff --git a/apps/files_external/tests/smb.php b/apps/files_external/tests/smb.php
index 52e1700b019..e1495b7480d 100644
--- a/apps/files_external/tests/smb.php
+++ b/apps/files_external/tests/smb.php
@@ -19,7 +19,7 @@ if(!is_array($config) or !isset($config['smb']) or !$config['smb']['run']){
public function setUp(){
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
- $this->config['smb']['root'].='/'.$id;//make sure we have an new empty folder to work in
+ $this->config['smb']['root'].=$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_SMB($this->config['smb']);
}