Commit b9b661ef authored by webchick's avatar webchick

#1010506 by dww, chx, hgurol: Fixed FileTransfer doesn't properly handle any...

#1010506 by dww, chx, hgurol: Fixed FileTransfer doesn't properly handle any advanced settings nor the ssh username
parent 1b752819
......@@ -28,8 +28,15 @@ function __construct($jail) {
* Classes that extend this class must override the factory() static method.
*
* @param string $jail
* The full path where all file operations performed by this object will
* be restricted to. This prevents the FileTransfer classes from being
* able to touch other parts of the filesystem.
* @param array $settings
* @return object New instance of the appropriate FileTransfer subclass.
* An array of connection settings for the FileTransfer subclass. If the
* getSettingsForm() method uses any nested settings, the same structure
* will be assumed here.
* @return object
* New instance of the appropriate FileTransfer subclass.
*/
static function factory($jail, $settings) {
throw new FileTransferException('FileTransfer::factory() static method not overridden by FileTransfer subclass.');
......
......@@ -24,10 +24,10 @@ public function __construct($jail, $username, $password, $hostname, $port) {
* options. If the FTP PHP extension is available, use it.
*/
static function factory($jail, $settings) {
$settings['username'] = empty($settings['username']) ? '' : $settings['username'];
$settings['password'] = empty($settings['password']) ? '' : $settings['password'];
$settings['hostname'] = empty($settings['hostname']) ? 'localhost' : $settings['hostname'];
$settings['port'] = empty($settings['port']) ? 21 : $settings['port'];
$username = empty($settings['username']) ? '' : $settings['username'];
$password = empty($settings['password']) ? '' : $settings['password'];
$hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname'];
$port = empty($settings['advanced']['port']) ? 21 : $settings['advanced']['port'];
if (function_exists('ftp_connect')) {
$class = 'FileTransferFTPExtension';
......@@ -36,7 +36,7 @@ static function factory($jail, $settings) {
throw new FileTransferException('No FTP backend available.');
}
return new $class($jail, $settings['username'], $settings['password'], $settings['hostname'], $settings['port']);
return new $class($jail, $username, $password, $hostname, $port);
}
/**
......
......@@ -25,11 +25,11 @@ function connect() {
}
static function factory($jail, $settings) {
$settings['username'] = empty($settings['hostname']) ? '' : $settings['username'];
$settings['password'] = empty($settings['password']) ? '' : $settings['password'];
$settings['hostname'] = empty($settings['hostname']) ? 'localhost' : $settings['hostname'];
$settings['port'] = empty($settings['port']) ? 22 : $settings['port'];
return new FileTransferSSH($jail, $settings['username'], $settings['password'], $settings['hostname'], $settings['port']);
$username = empty($settings['username']) ? '' : $settings['username'];
$password = empty($settings['password']) ? '' : $settings['password'];
$hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname'];
$port = empty($settings['advanced']['port']) ? 22 : $settings['advanced']['port'];
return new FileTransferSSH($jail, $username, $password, $hostname, $port);
}
protected function copyFileJailed($source, $destination) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment