/** * {@inheritdoc} */ public function __construct($params) { // Register sftp:// \Net_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 function __construct($params) { // Register sftp:// \Net_SFTP_Stream::register(); $this->host = $params['host']; $proto = strpos($this->host, '://'); if ($proto != false) { $this->host = substr($this->host, $proto + 3); } $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 .= '/'; } }
* * If NET_SFTP_STREAM_LOGGING is defined all calls will be output on the screen and then (regardless of whether or not * NET_SFTP_STREAM_LOGGING is enabled) the parameters will be passed through to the appropriate method. * * @param String * @param Array * @return Mixed * @access public */ function __call($name, $arguments) { if (defined('NET_SFTP_STREAM_LOGGING')) { echo $name . '('; $last = count($arguments) - 1; foreach ($arguments as $i => $argument) { var_export($argument); if ($i != $last) { echo ','; } } echo ")\r\n"; } $name = '_' . $name; if (!method_exists($this, $name)) { return false; } return call_user_func_array(array($this, $name), $arguments); } } Net_SFTP_Stream::register();
public function testRegisterWithArgument() { Net_SFTP_Stream::register($this->protocol); $this->assertContains($this->protocol, stream_get_wrappers()); }
/** * Initializes the component. */ public function init() { parent::init(); // autoload phpseclib library set_include_path(dirname(__FILE__) . '/phpseclib/' . get_include_path()); Yii::registerAutoloader(array("XSFtp", "autoload")); // register stream for sftp:// Net_SFTP_Stream::register(); }