示例#1
0
 /**
  * Establish SFTP connection
  * @return bool true when connection success
  * @throws CException if connection fails
  */
 public function connect()
 {
     $this->objSftp = new Net_SFTP($this->host);
     if ($this->objSftp->login($this->username, $this->password)) {
         $this->objSsh = new Net_SSH2($this->host);
         $this->objSsh->login($this->username, $this->password);
         return true;
     } else {
         $this->errorCode = self::ERROR_CONNECTION_FAILED;
         $this->errorMessage = Yii::t('XSFtp.sftp', 'SFtp connection failed!');
         return false;
     }
 }