本文整理汇总了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());
}
}
示例2: getError
public function getError()
{
$err = $this->ftp->getLastError();
if (!$err) {
$err = $this->ftp->getLastSFTPError();
}
if ($err) {
return $err['msg'];
}
}