当前位置: 首页>>代码示例>>PHP>>正文


PHP Net_SFTP::getLastError方法代码示例

本文整理汇总了PHP中Net_SFTP::getLastError方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_SFTP::getLastError方法的具体用法?PHP Net_SFTP::getLastError怎么用?PHP Net_SFTP::getLastError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Net_SFTP的用法示例。


在下文中一共展示了Net_SFTP::getLastError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 public function connect()
 {
     // we have to mangle the include path a little to find our plugins
     $oldIncludePath = get_include_path();
     set_include_path($oldIncludePath . ':' . TL_ROOT . '/plugins/phpseclib/:' . TL_ROOT . '/plugins/phpseclib/Net:' . TL_ROOT . '/plugins/phpseclib/Crypt');
     include 'SFTP.php';
     if ($GLOBALS['TL_CONFIG']['sftpKeyFile']) {
         include 'RSA.php';
     }
     set_include_path($oldIncludePath);
     $this->ftpHost = $GLOBALS['TL_CONFIG']['ftpHost'];
     $this->ftpPort = $GLOBALS['TL_CONFIG']['ftpPort'];
     $this->ftpUser = $GLOBALS['TL_CONFIG']['ftpUser'];
     if ($GLOBALS['TL_CONFIG']['sftpKeyFile']) {
         $key = new Crypt_RSA();
         if ($GLOBALS['TL_CONFIG']['sftpKeyPass']) {
             $key->setPassword($GLOBALS['TL_CONFIG']['sftpKeyPass']);
         }
         $key->loadKey(file_get_contents($GLOBALS['TL_CONFIG']['sftpKeyFile']));
         $this->ftpPass = $key;
     } else {
         $this->ftpPass = $GLOBALS['TL_CONFIG']['ftpPass'];
     }
     $this->ftpPath = $GLOBALS['TL_CONFIG']['ftpPath'];
     // Connect to FTP server
     if (!is_numeric($this->ftpPort) || $this->ftpPort == 0) {
         $this->ftpPort = 22;
     }
     if ($GLOBALS['TL_CONFIG']['debugSmhExtended']) {
         define('NET_SSH2_LOGGING', true);
         define('NET_SFTP_LOGGING', true);
     }
     if (($resConnection = new Net_SFTP($this->ftpHost, $this->ftpPort, 5)) != false) {
         // Login
         if (!$resConnection->login($this->ftpUser, $this->ftpPass)) {
             throw new Exception('Could not login to sftp: ' . $resConnection->getLastError() . (defined('NET_SSH2_LOGGING') ? implode("\n", $resConnection->message_number_log) : ''));
         }
         // security, clean user id and password as we won't need them anymore.
         $this->ftpUser = NULL;
         $this->ftpPass = NULL;
         // change to root directory to ensure we can really work.
         $resConnection->chdir($this->ftpPath);
         $this->resConnection = $resConnection;
         return $resConnection;
     } else {
         throw new Exception('Could not connect to sftp: ' . $resConnection->getLastError());
     }
 }
开发者ID:unmaintained-stuff,项目名称:tl_smhextended,代码行数:48,代码来源:SMHSFTP.php

示例2: getError

 public function getError()
 {
     $err = $this->ftp->getLastError();
     if (!$err) {
         $err = $this->ftp->getLastSFTPError();
     }
     if ($err) {
         return $err['msg'];
     }
 }
开发者ID:grlf,项目名称:eyedock,代码行数:10,代码来源:AdminUpgradeController.php


注:本文中的Net_SFTP::getLastError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。