#18430274 : support SFTP

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6948 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
haneul 2009-11-16 04:35:29 +00:00
parent c4fe618378
commit 51e758fd39
7 changed files with 131 additions and 26 deletions

View file

@ -14,11 +14,6 @@
var $url;
var $download_path;
function ModuleInstaller(&$package)
{
$this->package =& $package;
}
function _download()
{
if($this->package->path == ".")
@ -70,6 +65,53 @@
return $file_list;
}
}
class SFTPModuleInstaller extends ModuleInstaller {
function SFTPModuleInstaller(&$package)
{
$this->package =& $package;
}
function _copyDir(&$file_list){
$ftp_info = Context::getFTPInfo();
if(!$ftp_info->ftp_user || !$ftp_info->ftp_password || !$ftp_info->sftp || $ftp_info->sftp != 'Y') return new Object(-1,'msg_ftp_invalid_auth_info');
$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);
$target_dir = $ftp_info->ftp_root_path.$this->target_path;
foreach($file_list as $k => $file){
$org_file = $file;
if($this->package->path == ".")
{
$file = substr($file,3);
}
$path = FileHandler::getRealPath("./".$this->target_path."/".$file);
$pathname = dirname($target_dir."/".$file);
if(!file_exists(FileHandler::getRealPath($real_path)))
{
ssh2_sftp_mkdir($sftp, $pathname, 0755, true);
}
ssh2_scp_send($connection, FileHandler::getRealPath($this->download_path."/".$org_file), $target_dir."/".$file);
}
}
}
class FTPModuleInstaller extends ModuleInstaller {
function FTPModuleInstaller(&$package)
{
$this->package =& $package;
}
function _copyDir(&$file_list){
$ftp_info = Context::getFTPInfo();
if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_ftp_invalid_auth_info');
@ -125,7 +167,6 @@
return new Object();
}
}
class autoinstallAdminController extends autoinstall {
@ -235,10 +276,18 @@
$package_srls = Context::get('package_srl');
$oModel =& getModel('autoinstall');
$packages = explode(',', $package_srls);
$ftp_info = Context::getFTPInfo();
foreach($packages as $package_srl)
{
$package = $oModel->getPackage($package_srl);
$oModuleInstaller = new ModuleInstaller($package);
if($ftp_info->sftp && $ftp_info->sftp == 'Y')
{
$oModuleInstaller = new SFTPModuleInstaller($package);
}
else
{
$oModuleInstaller = new FTPModuleInstaller($package);
}
$oModuleInstaller->install();
}
$this->setMessage('success_installed');

View file

@ -109,7 +109,6 @@
}
}
}
debugPrint($package);
}
$installedPackage = $oModel->getInstalledPackage($package_srl);
if($installedPackage) {