Download????? TFTPHandler
*??????????? ????????? FTP/SFTP ?? ?????????? ??? ?????????? ?????????, ??????????? ?? ??????? ??????, ???????? ???????, ????????? CSRF ??? ?????????? ?? WebFTPClient.*
> #### ?????????? TSocketHandler
?????
use ASCOOS\OS\Kernel\Net\TFTPHandler;
// ???????????? ?? ??????????
$ftpConfig = [
'ftp' => [
'protocol' => 'sftp',
'host' => 'example.com',
'port' => 22,
'username' => 'user',
'password' => 'pass',
'useAsync' => true
],
'logs' => ['useLogger' => true],
'cache' => ['cacheType' => 'file']
];
$ftpHandler = new TFTPHandler($ftpConfig);
// ??????? ???? ??????????
$ftpHandler->connect('example.com', 22, 'user', 'pass', false);
????? ???????????? ??????.
?????????? ??????????
??? ??????? ???????????? (???????????, ??????, ????????????), ???????????? ?? ??????? Documentation Site (??? ?????????).
?????????
| ???????? | ????? | ????????? |
|----------|-------|-----------|
| ftpConnection | mixed | ? ????? ???????? FTP/SFTP (FTP\Connection ??? FTP, resource ??? SFTP). |
| protocol | string | ?? ?????????? ??? ??????????????? ('ftp' ? 'sftp'). |
| connectionConfig | array | ?????????? ??? ?? ??????? FTP/SFTP (host, port, username, password, ???.). |
| logger | ?TLoggerHandler | ??????????? ?????????? ??? ?????????????? FTP/SFTP (?????????????). |
| debugger | ?TDebugHandler | ??????????? ?????????????? ??? ????????? ????????????? (?????????????). |
| phpHandler | ?TPHPHandler | ???????????? ????????????? PHP (?????????????). |
| cache | ?TCacheHandler | ???????????? cache ??? ?????????? ????????????? ???????? ??? ??????? (?????????????). |
| files | ?TFilesHandler | ???????????? ??????? ??? ??????? ??????????? ???????. |
| transferStats | array | ?????????? ??? ????????? ??????? (bytes ??? ?????????/????????, ??????, ???.). |
| useAsync | bool | ?? ?? ??????????????? ?????????? ?????????. |
| publicKey | ?string | ???????? ???? ?? ??????? ?????? ??? ??????????? SFTP. |
| privateKey | ?string | ???????? ???? ?? ???????? ?????? ??? ??????????? SFTP. |
| sessionId | ?string | ????????????? ????????? ??? ????????? ?????????? ???????? ?? ????????? web. |
??????? ??? connectionConfig
| ?????? | ????? | ????????? |
|--------|-------|-----------|
| host | string | ?? ????? ????????? ?????????? ? ????????? IP (??????????: 'localhost'). |
| port | int | ? ???? ??? ?????????? (??????????: 21 ??? FTP, 22 ??? SFTP). |
| username | string | ?? ????? ?????? ??? ??????????? (??????????: ''). |
| password | string | ? ??????? ????????? ??? ??????????? (??????????: ''). |
| useSSL | bool | ?? ?? ?????????????? SSL/TLS ??? ?? ??????? (??????????: false). |
| passive | bool | ?? ?? ?????????????? ? ?????????? passive ??? FTP (??????????: true). |
| timeout | int | ?????? ????? ???????? ?? ???????????? (??????????: 30). |
| useAsync | bool | ?? ?? ??????????????? ?????????? ????????? (??????????: false). |
| publicKey | ?string | ???????? ???? ?? ??????? ?????? ??? ??????????? SFTP (??????????: null). |
| privateKey | ?string | ???????? ???? ?? ???????? ?????? ??? ??????????? SFTP (??????????: null). |
???????
| ??????? | ????????? | ????????? |
|---------|-----------|-----------|
| __construct(array $properties = []) | void | ??????????? ??? ???????? FTP/SFTP ?? ????????? ???????????. |
| asyncDownloadFile(string $remoteFile, string $localFile, int $mode = FTP_BINARY, ?callable $progressCallback = null) | bool | ????????? ????????? ??? ?????? ??? ??? ????????????? ??????????. |
| asyncUploadFile(string $localFile, string $remoteFile, int $mode = FTP_BINARY, ?callable $progressCallback = null) | bool | ???????? ????????? ??? ?????? ???? ????????????? ??????????. |
| authenticateWithKey(string $username, string $publicKey, string $privateKey, string $passphrase = '') | bool | ????????????? ???? ?????????? SFTP ?? ???????/???????? ??????. |
| bulkDownloadFiles(array $files, int $mode = FTP_BINARY, ?callable $progressCallback = null) | bool | ????????? ???????? ?????? ??? ??? ????????????? ??????????. |
| bulkUploadFiles(array $files, int $mode = FTP_BINARY, ?callable $progressCallback = null) | bool | ???????? ???????? ?????? ???? ????????????? ??????????. |
| cacheFileList(string $remoteDir, string $cacheKey) | bool | ?????????? ?? ????? ????????? ?? cache ??? ???????? ????????. |
| changeDirectory(string $remoteDir) | bool | ??????? ??? ???????? ???????? ???? ????????????? ??????????. |
| compressFile(string $source, string $destination, string $format = 'zip') | bool | ????????? ??? ?????? ???? ?? ????????. |
| connect(string $host, int $port = 21, string $username = '', string $password = '', bool $useSSL = false) | bool | ?????????? ??????? FTP ? SFTP. |
| createDirectory(string $remoteDir) | bool | ?????????? ???? ???????? ???? ????????????? ??????????. |
| decompressFile(string $source, string $destination, string $format = 'zip') | bool | ???????????? ??? ?????? ???? ?? ????????. |
| deleteDirectory(string $remoteDir) | bool | ????????? ???? ???????? ???? ????????????? ??????????. |
| deleteFile(string $remoteFile) | bool | ????????? ??? ?????? ???? ????????????? ??????????. |
| disconnect() | bool | ??????? ?? ??????? FTP/SFTP. |
| downloadFile(string $remoteFile, string $localFile, int $mode = FTP_BINARY) | bool | ????????? ??? ?????? ??? ??? ????????????? ??????????. |
| enablePassiveMode(bool $enable = true) | bool | ??????????? ? ????????????? ?? ?????????? passive ??? FTP. |
| generateCsrfToken(string $sessionId) | string | ?????????? ??? CSRF token ??? ???????? ????????? web. |
| getFilePermissions(string $remoteFile) | int | ?????? ?? ?????????? ??? ?????? ? ???????? ???? ????????????? ??????????. |
| getCurrentDirectory() | string | ?????? ??? ???????? ???????? ???? ????????????? ??????????. |
| getTransferStats() | array | ?????? ?????????? ????????? ???????. |
| listDirectory(string $remoteDir = '.') | array | ?????????? ?? ??????????? ???? ?????????????? ?????????. |
| logActivity(string $activity, string $level = 'info') | bool | ?????????? ?????????????? FTP/SFTP ??????????????? TLoggerHandler (?????????????). |
| login(string $username, string $password) | bool | ????????? ???? ?????????? FTP/SFTP. |
| monitorTransferProgress(callable $callback, int $interval = 1) | bool | ???????????? ??? ?????? ????????? ??????? ?? callback. |
| reconnect() | bool | ?????????????? ???? ?????????? ??????????????? ???????????? ??????????. |
| restoreFileListFromCache(string $cacheKey) | array | ?????????? ?? ????? ????????? ??? ?? cache. |
| restoreSession(string $sessionId) | bool | ?????????? ??? ????????? ???????? ??? ????????? web. |
| saveSession(string $sessionId) | bool | ?????????? ??? ????????? ???????? ??? ????????? web. |
| setFilePermissions(string $remoteFile, int $permissions) | bool | ?????? ?????????? ??? ?????? ? ???????? ???? ????????????? ??????????. |
| uploadFile(string $localFile, string $remoteFile, int $mode = FTP_BINARY) | bool | ???????? ??? ?????? ???? ????????????? ??????????. |
| validateCsrfToken(string $sessionId, string $token) | bool | ?????????? ??? CSRF token ??? ???????? ????????? web. |
<details>
<summary>? ???????????</summary>
?????????? ??? ??? TSocketHandler, ?????????? ??????????? ?????????? ?? sockets ??? ??????????? ??????????.
</details>
?????????
|