3namespace Bitrix\Sale\TradingPlatform;
5use Bitrix\Main\Localization\Loc;
6use \Bitrix\Main\SystemException;
8Loc::loadMessages(__FILE__);
50 if(!extension_loaded(
"ssh2"))
51 throw new SystemException(Loc::getMessage(
"TRADING_PLATFORM_SFTP_ERROR_SSH2_EXT"));
53 $this->connection = @ssh2_connect($this->host, $this->port);
55 if(!$this->connection)
59 "TRADING_PLATFORM_SFTP_ERROR_CONNECT",
61 "#HOST#" => $this->host,
62 "#PORT#" => $this->port
68 if($this->fingerprint !=
"")
70 $fingerprint = ssh2_fingerprint($this->connection, SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX);
75 "TRADING_PLATFORM_SFTP_ERROR_FINGERPRINT",
77 "#HOST#" => $this->host,
79 "#FINGERPRINT2#" => $this->fingerprint,
85 if(!@ssh2_auth_password($this->connection, $this->login, $this->pass))
86 throw new SystemException(Loc::getMessage(
"TRADING_PLATFORM_SFTP_ERROR_PASS"));
88 $this->sftp = ssh2_sftp($this->connection);
91 throw new SystemException(Loc::getMessage(
"TRADING_PLATFORM_SFTP_ERROR_INIT"));
104 $remotePath =
"sftp://".intval($this->sftp).$remoteFile;
105 $stream = @fopen(
"ssh2.".$remotePath,
'w');
108 throw new SystemException(Loc::getMessage(
"TRADING_PLATFORM_SFTP_ERROR_OPEN_FILE",
array(
"#FILE#" => $remotePath)));
110 $data = file_get_contents($localFile);
113 throw new SystemException(Loc::getMessage(
"TRADING_PLATFORM_SFTP_ERROR_READ_FILE",
array(
"#FILE#" => $localFile)));
115 if (fwrite($stream,
$data) ===
false)
116 throw new SystemException(Loc::getMessage(
"TRADING_PLATFORM_SFTP_ERROR_WRITE_FILE",
array(
"#FILE#" => $remotePath)));
131 $remotePath =
"sftp://".intval($this->sftp).$remoteFile;
132 $stream = @fopen(
"ssh2.".$remotePath,
'r');
135 throw new SystemException(Loc::getMessage(
"TRADING_PLATFORM_SFTP_ERROR_OPEN_FILE",
array(
"#FILE#" => $remotePath)));
137 $contents = stream_get_contents($stream);
139 if(file_put_contents($localFile,
$contents) ===
false)
140 throw new SystemException(Loc::getMessage(
"TRADING_PLATFORM_SFTP_ERROR_WRITE_FILE",
array(
"#FILE#" => $localFile)));
154 $fullPath =
"sftp://".intval($this->sftp).$remotePath;
155 $dirHandle = @opendir(
"ssh2.".$fullPath);
157 if($dirHandle ===
false)
158 throw new SystemException(Loc::getMessage(
"TRADING_PLATFORM_SFTP_ERROR_OPEN_PATH",
array(
"#PATH#" => $fullPath)));
160 while (
false !== ($file = readdir($dirHandle)))
161 if(is_file(
"ssh2.".$fullPath.
"/".$file))
173 return filesize(
"ssh2.sftp://".intval($this->sftp).$remoteFile);
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)