| @@ 280-315 (lines=36) @@ | ||
| 277 | * Add file list to BaseObject after sftp connect |
|
| 278 | * @return void|BaseObject |
|
| 279 | */ |
|
| 280 | function getSFTPList() |
|
| 281 | { |
|
| 282 | $ftp_info = Context::getRequestVars(); |
|
| 283 | if(!$ftp_info->ftp_host) |
|
| 284 | { |
|
| 285 | $ftp_info->ftp_host = "127.0.0.1"; |
|
| 286 | } |
|
| 287 | $connection = ssh2_connect($ftp_info->ftp_host, $ftp_info->ftp_port); |
|
| 288 | if(!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 289 | { |
|
| 290 | return new BaseObject(-1, 'msg_ftp_invalid_auth_info'); |
|
| 291 | } |
|
| 292 | ||
| 293 | $sftp = ssh2_sftp($connection); |
|
| 294 | $curpwd = "ssh2.sftp://$sftp" . $this->pwd; |
|
| 295 | $dh = @opendir($curpwd); |
|
| 296 | if(!$dh) |
|
| 297 | { |
|
| 298 | return new BaseObject(-1, 'msg_ftp_invalid_path'); |
|
| 299 | } |
|
| 300 | $list = array(); |
|
| 301 | while(($file = readdir($dh)) !== FALSE) |
|
| 302 | { |
|
| 303 | if(is_dir($curpwd . $file)) |
|
| 304 | { |
|
| 305 | $file .= "/"; |
|
| 306 | } |
|
| 307 | else |
|
| 308 | { |
|
| 309 | continue; |
|
| 310 | } |
|
| 311 | $list[] = $file; |
|
| 312 | } |
|
| 313 | closedir($dh); |
|
| 314 | $this->add('list', $list); |
|
| 315 | } |
|
| 316 | ||
| 317 | /** |
|
| 318 | * Add file list to BaseObject after ftp connect |
|
| @@ 7-34 (lines=28) @@ | ||
| 4 | { |
|
| 5 | var $pwd; |
|
| 6 | ||
| 7 | function getSFTPList() |
|
| 8 | { |
|
| 9 | $ftp_info = Context::getRequestVars(); |
|
| 10 | if(!$ftp_info->ftp_host) |
|
| 11 | { |
|
| 12 | $ftp_info->ftp_host = "127.0.0.1"; |
|
| 13 | } |
|
| 14 | ||
| 15 | $connection = ssh2_connect($ftp_info->ftp_host, $ftp_info->ftp_port); |
|
| 16 | if(!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 17 | { |
|
| 18 | return new BaseObject(-1,'msg_ftp_invalid_auth_info'); |
|
| 19 | } |
|
| 20 | ||
| 21 | $sftp = ssh2_sftp($connection); |
|
| 22 | $curpwd = "ssh2.sftp://$sftp".$this->pwd; |
|
| 23 | $dh = @opendir($curpwd); |
|
| 24 | if(!$dh) return new BaseObject(-1, 'msg_ftp_invalid_path'); |
|
| 25 | ||
| 26 | $list = array(); |
|
| 27 | while(($file = readdir($dh)) !== false) |
|
| 28 | { |
|
| 29 | if(!is_dir($curpwd.$file)) continue; |
|
| 30 | $list[] = $file . "/"; |
|
| 31 | } |
|
| 32 | closedir($dh); |
|
| 33 | $this->add('list', $list); |
|
| 34 | } |
|
| 35 | ||
| 36 | function getInstallFTPList() |
|
| 37 | { |
|