/** * {@inheritdoc} */ public function __construct($params) { // Register sftp:// Stream::register(); $parsedHost = $this->splitHost($params['host']); $this->host = $parsedHost[0]; $this->port = $parsedHost[1]; if (!isset($params['user'])) { throw new \UnexpectedValueException('no authentication parameters specified'); } $this->user = $params['user']; if (isset($params['public_key_auth'])) { $this->auth = $params['public_key_auth']; } elseif (isset($params['password'])) { $this->auth = $params['password']; } else { throw new \UnexpectedValueException('no authentication parameters specified'); } $this->root = isset($params['root']) ? $this->cleanPath($params['root']) : '/'; if ($this->root[0] != '/') { $this->root = '/' . $this->root; } if (substr($this->root, -1, 1) != '/') { $this->root .= '/'; } }
/** * {@inheritdoc} */ public function __construct($params) { // Register sftp:// Stream::register(); $this->host = $params['host']; //deals with sftp://server example $proto = strpos($this->host, '://'); if ($proto != false) { $this->host = substr($this->host, $proto + 3); } //deals with server:port $hasPort = strpos($this->host, ':'); if ($hasPort != false) { $pieces = explode(":", $this->host); $this->host = $pieces[0]; $this->port = $pieces[1]; } $this->user = $params['user']; if (isset($params['public_key_auth'])) { $this->auth = $params['public_key_auth']; } elseif (isset($params['password'])) { $this->auth = $params['password']; } else { throw new \UnexpectedValueException('no authentication parameters specified'); } $this->root = isset($params['root']) ? $this->cleanPath($params['root']) : '/'; if ($this->root[0] != '/') { $this->root = '/' . $this->root; } if (substr($this->root, -1, 1) != '/') { $this->root .= '/'; } }
public function testRegisterWithArgument() { $protocol = 'sftptest'; $this->assertTrue(Stream::register($protocol)); $this->assertContains($protocol, stream_get_wrappers()); $this->assertTrue(stream_wrapper_unregister($protocol)); }
/** * {@inheritdoc} */ public function __construct($params) { // Register sftp:// Stream::register(); $this->host = $params['host']; //deals with sftp://server example $proto = strpos($this->host, '://'); if ($proto != false) { $this->host = substr($this->host, $proto + 3); } //deals with server:port $hasPort = strpos($this->host, ':'); if ($hasPort != false) { $pieces = explode(":", $this->host); $this->host = $pieces[0]; $this->port = $pieces[1]; } $this->user = $params['user']; $this->password = isset($params['password']) ? $params['password'] : ''; $this->root = isset($params['root']) ? $this->cleanPath($params['root']) : '/'; if ($this->root[0] != '/') { $this->root = '/' . $this->root; } if (substr($this->root, -1, 1) != '/') { $this->root .= '/'; } }
public static function setUpBeforeClass() { Stream::register(); parent::setUpBeforeClass(); }