mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
Rename Connection to Server and fix some other naming inconsistencies
This commit is contained in:
parent
71e917bbae
commit
89cb5a2104
10 changed files with 53 additions and 33 deletions
|
|
@ -10,12 +10,12 @@ namespace SMB\Command;
|
|||
|
||||
abstract class Command {
|
||||
/**
|
||||
* @var \SMB\Share $connection
|
||||
* @var \SMB\Share $share
|
||||
*/
|
||||
protected $share;
|
||||
|
||||
/**
|
||||
* @param \SMB\Share $connection
|
||||
* @param \SMB\Share $share
|
||||
*/
|
||||
public function __construct($share) {
|
||||
$this->share = $share;
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
namespace SMB\Command;
|
||||
|
||||
class Del extends Simple {
|
||||
public function __construct($connection) {
|
||||
parent::__construct($connection);
|
||||
public function __construct($share) {
|
||||
parent::__construct($share);
|
||||
$this->command = 'del';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
namespace SMB\Command;
|
||||
|
||||
class Dir extends Command {
|
||||
public function __construct($connection) {
|
||||
parent::__construct($connection);
|
||||
public function __construct($share) {
|
||||
parent::__construct($share);
|
||||
}
|
||||
|
||||
public function run($arguments) {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,23 @@
|
|||
|
||||
namespace SMB\Command;
|
||||
|
||||
class ListShares extends Command {
|
||||
public function run($arguments) {
|
||||
$auth = $this->escape($this->connection->getAuthString());
|
||||
$command = self::CLIENT . ' -N -U ' . $auth . ' ' . '-gL ' . $this->escape($this->connection->getHost()) . ' 2> /dev/null';
|
||||
class ListShares {
|
||||
|
||||
/**
|
||||
* @var \SMB\Server $server
|
||||
*/
|
||||
private $server;
|
||||
|
||||
/**
|
||||
* @param \SMB\Server $server
|
||||
*/
|
||||
public function __construct($server){
|
||||
$this->server=$server;
|
||||
}
|
||||
|
||||
public function run() {
|
||||
$auth = escapeshellarg($this->server->getAuthString());
|
||||
$command = \SMB\Server::CLIENT . ' -N -U ' . $auth . ' ' . '-gL ' . escapeshellarg($this->server->getHost()) . ' 2> /dev/null';
|
||||
exec($command, $output);
|
||||
return $this->parseOutput($output);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
namespace SMB\Command;
|
||||
|
||||
class Mkdir extends Simple {
|
||||
public function __construct($connection) {
|
||||
parent::__construct($connection);
|
||||
public function __construct($share) {
|
||||
parent::__construct($share);
|
||||
$this->command = 'mkdir';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
namespace SMB\Command;
|
||||
|
||||
class Rename extends Double {
|
||||
public function __construct($connection) {
|
||||
parent::__construct($connection);
|
||||
public function __construct($share) {
|
||||
parent::__construct($share);
|
||||
$this->command = 'rename';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
namespace SMB\Command;
|
||||
|
||||
class Rmdir extends Simple {
|
||||
public function __construct($connection) {
|
||||
parent::__construct($connection);
|
||||
public function __construct($share) {
|
||||
parent::__construct($share);
|
||||
$this->command = 'rmdir';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace SMB;
|
||||
|
||||
class Connection {
|
||||
class Server {
|
||||
const CLIENT = 'smbclient';
|
||||
const LOCALE = 'en_US.UTF-8';
|
||||
|
||||
|
|
@ -10,9 +10,9 @@ namespace SMB;
|
|||
|
||||
class Share {
|
||||
/**
|
||||
* @var Connection $connection
|
||||
* @var Server $server
|
||||
*/
|
||||
private $connection;
|
||||
private $server;
|
||||
|
||||
/**
|
||||
* @var resource $process
|
||||
|
|
@ -33,23 +33,23 @@ class Share {
|
|||
private $name;
|
||||
|
||||
/**
|
||||
* @param Connection $connection
|
||||
* @param Server $server
|
||||
* @param string $share
|
||||
*/
|
||||
public function __construct($connection, $name) {
|
||||
$this->connection = $connection;
|
||||
public function __construct($server, $name) {
|
||||
$this->server = $server;
|
||||
$this->name = $name;
|
||||
|
||||
$descriptorSpec = array(
|
||||
0 => array("pipe", "r"),
|
||||
1 => array("pipe", "w"),
|
||||
2 => array("file", "/tmp/smberror", "a")
|
||||
// 2 => array("file", "/tmp/smberror", "a")
|
||||
);
|
||||
|
||||
putenv('LC_ALL=' . Connection::LOCALE);
|
||||
setlocale(LC_ALL, Connection::LOCALE);
|
||||
$command = Connection::CLIENT . ' -N -U ' . $this->connection->getAuthString() .
|
||||
' //' . $this->connection->getHost() . '/' . $this->name;
|
||||
putenv('LC_ALL=' . Server::LOCALE);
|
||||
setlocale(LC_ALL, Server::LOCALE);
|
||||
$command = Server::CLIENT . ' -N -U ' . $this->server->getAuthString() .
|
||||
' //' . $this->server->getHost() . '/' . $this->name;
|
||||
$this->process = proc_open($command, $descriptorSpec, $this->pipes, null, array(
|
||||
'CLI_FORCE_INTERACTIVE' => 'y' // Needed or the prompt isn't displayed!!
|
||||
));
|
||||
|
|
@ -161,4 +161,11 @@ class Share {
|
|||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
*/
|
||||
public function getServer(){
|
||||
return $this->server;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue