2012-05-24 20:22:33 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('smb4php/smb.php');
|
|
|
|
|
2012-05-24 21:39:14 +04:00
|
|
|
class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
|
2012-05-24 20:22:33 +04:00
|
|
|
private $password;
|
|
|
|
private $user;
|
|
|
|
private $host;
|
|
|
|
private $root;
|
2012-06-08 03:29:46 +04:00
|
|
|
private $share;
|
2012-05-24 20:22:33 +04:00
|
|
|
|
|
|
|
private static $tempFiles=array();
|
|
|
|
|
|
|
|
public function __construct($params){
|
|
|
|
$this->host=$params['host'];
|
|
|
|
$this->user=$params['user'];
|
|
|
|
$this->password=$params['password'];
|
2012-06-08 03:29:46 +04:00
|
|
|
$this->share=$params['share'];
|
2012-05-24 20:22:33 +04:00
|
|
|
$this->root=isset($params['root'])?$params['root']:'/';
|
2012-06-08 23:23:25 +04:00
|
|
|
if(!$this->root || $this->root[0]!='/'){
|
|
|
|
$this->root='/'.$this->root;
|
|
|
|
}
|
2012-06-08 03:29:46 +04:00
|
|
|
if(substr($this->root,-1,1)!='/'){
|
|
|
|
$this->root.='/';
|
|
|
|
}
|
2012-06-08 23:23:25 +04:00
|
|
|
if(!$this->share || $this->share[0]!='/'){
|
2012-06-08 03:29:46 +04:00
|
|
|
$this->share='/'.$this->share;
|
|
|
|
}
|
|
|
|
if(substr($this->share,-1,1)=='/'){
|
|
|
|
$this->share=substr($this->share,0,-1);
|
|
|
|
}
|
2012-05-24 20:22:33 +04:00
|
|
|
|
|
|
|
//create the root folder if necesary
|
2012-06-08 03:29:46 +04:00
|
|
|
if(!$this->is_dir('')){
|
|
|
|
$this->mkdir('');
|
|
|
|
}
|
2012-05-24 20:22:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function constructUrl($path){
|
|
|
|
if(substr($path,-1)=='/'){
|
|
|
|
$path=substr($path,0,-1);
|
|
|
|
}
|
2012-06-08 03:29:46 +04:00
|
|
|
return 'smb://'.$this->user.':'.$this->password.'@'.$this->host.$this->share.$this->root.$path;
|
2012-05-24 20:22:33 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|