- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/sftp.php
- Класс: BitrixSaleTradingPlatformSftp
- Вызов: Sftp::connect
public function connect()
{
if(!extension_loaded("ssh2"))
throw new SystemException(Loc::getMessage("TRADING_PLATFORM_SFTP_ERROR_SSH2_EXT"));
$this->connection = @ssh2_connect($this->host, $this->port);
if(!$this->connection)
{
throw new SystemException(
Loc::getMessage(
"TRADING_PLATFORM_SFTP_ERROR_CONNECT",
array(
"#HOST#" => $this->host,
"#PORT#" => $this->port
)
)
);
}
if($this->fingerprint != "")
{
$fingerprint = ssh2_fingerprint($this->connection, SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX);
if ($fingerprint != $this->fingerprint)
{
throw new SystemException(Loc::getMessage(
"TRADING_PLATFORM_SFTP_ERROR_FINGERPRINT",
array(
"#HOST#" => $this->host,
"#FINGERPRINT1#" => $fingerprint,
"#FINGERPRINT2#" => $this->fingerprint,
)
));
}
}
if(!@ssh2_auth_password($this->connection, $this->login, $this->pass))
throw new SystemException(Loc::getMessage("TRADING_PLATFORM_SFTP_ERROR_PASS"));
$this->sftp = ssh2_sftp($this->connection);
if(!$this->sftp)
throw new SystemException(Loc::getMessage("TRADING_PLATFORM_SFTP_ERROR_INIT"));
return true;
}