donglian1523 2019-08-06 16:07
浏览 72

为什么我不能在mvc中使用phpseclib登录? [关闭]

i was testing my code only in my controler and it worked, when i went to put all in the model and call the functions in the controller it wont connect to the sftp server.

    require "vendor/autoload.php";
    use phpseclib\Net\SFTP;

class sftpInno extends SFTP{

        private $Host;
        private $Port;
        private $Username;
        private $Password;


    public function __construct()
    {

        $this->Host = '192.168.61.192';
        $this->Port = '99';
        $this->Username = 'tester';
        $this->Password = 'password';

    }

    public function SFTPLogin()
    {
        $return = true;

        if (!$this->login($this->Username, $this->Password)) {
            $return = false;
        }

        return $return;
    }

Controller

    $InnoSFT = new sftpInno();

$return = $InnoSFT->SFTPLogin();

Any toughts? Thanks

  • 写回答

1条回答 默认 最新

  • duanlvji4780 2019-08-06 16:57
    关注

    You should do parent::__construct($this->Host, $this->Port) in your constructor. The constructor for phpsecib's SFTP class (and SSH2 class) do do stuff after all:

    https://github.com/phpseclib/phpseclib/blob/2.0.21/phpseclib/Net/SFTP.php#L273 https://github.com/phpseclib/phpseclib/blob/2.0.21/phpseclib/Net/SSH2.php#L953

    If you have further issues then update your post to include the SSH logs. You can get them by doing define('NET_SSH2_LOGGING', 2); at the top and then echo $this->getLog(); after the login attempt.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据