mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
#18430274 : support SFTP
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6948 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
c4fe618378
commit
51e758fd39
7 changed files with 131 additions and 26 deletions
|
|
@ -2,17 +2,52 @@
|
|||
|
||||
class adminAdminModel extends admin
|
||||
{
|
||||
var $pwd;
|
||||
|
||||
function getSFTPList()
|
||||
{
|
||||
$ftp_info = Context::getFTPInfo();
|
||||
$connection = ssh2_connect('localhost', $ftp_info->ftp_port);
|
||||
if(!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password))
|
||||
{
|
||||
return new Object(-1,'msg_ftp_invalid_auth_info');
|
||||
}
|
||||
|
||||
$sftp = ssh2_sftp($connection);
|
||||
$curpwd = "ssh2.sftp://$sftp".$this->pwd;
|
||||
$dh = opendir($curpwd);
|
||||
$list = array();
|
||||
while(($file = readdir($dh)) !== false) {
|
||||
if(is_dir($curpwd.$file))
|
||||
{
|
||||
$file .= "/";
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$list[] = $file;
|
||||
}
|
||||
closedir($dh);
|
||||
$this->add('list', $list);
|
||||
}
|
||||
|
||||
function getAdminFTPList()
|
||||
{
|
||||
set_time_limit(5);
|
||||
require_once(_XE_PATH_.'libs/ftp.class.php');
|
||||
$ftp_info = Context::getFTPInfo();
|
||||
$pwd = Context::get('pwd');
|
||||
$this->pwd = Context::get('pwd');
|
||||
|
||||
if($ftp_info->sftp == 'Y')
|
||||
{
|
||||
return $this->getSFTPList();
|
||||
}
|
||||
|
||||
$oFtp = new ftp();
|
||||
if($oFtp->ftp_connect('localhost', $ftp_info->ftp_port)){
|
||||
if($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
|
||||
$_list = $oFtp->ftp_rawlist($pwd);
|
||||
$_list = $oFtp->ftp_rawlist($this->pwd);
|
||||
$oFtp->ftp_quit();
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +56,7 @@
|
|||
$oFtp = new ftp();
|
||||
if($oFtp->ftp_connect($_SERVER['SERVER_NAME'], $ftp_info->ftp_port)){
|
||||
if($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
|
||||
$_list = $oFtp->ftp_rawlist($pwd);
|
||||
$_list = $oFtp->ftp_rawlist($this->pwd);
|
||||
$oFtp->ftp_quit();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue