mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
#904 autoinstall without ftp
This commit is contained in:
parent
49daa9d95d
commit
72dd48a596
8 changed files with 253 additions and 8 deletions
|
|
@ -1017,6 +1017,33 @@ class FileHandler
|
|||
$path = self::getRealPath($path);
|
||||
return is_dir($path) ? $path : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is writable dir
|
||||
*
|
||||
* @param string $path Target dir path
|
||||
* @return bool
|
||||
*/
|
||||
function isWritableDir($path)
|
||||
{
|
||||
$path = self::getRealPath($path);
|
||||
if(is_dir($path)==FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$checkFile = $path . '/_CheckWritableDir';
|
||||
|
||||
$fp = fopen($checkFile, 'w');
|
||||
if(!is_resource($fp))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
self::removeFile($checkFile);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file FileHandler.class.php */
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ class autoinstallAdminController extends autoinstall
|
|||
@set_time_limit(0);
|
||||
$package_srls = Context::get('package_srl');
|
||||
$oModel = getModel('autoinstall');
|
||||
$oAdminModel = getAdminModel('autoinstall');
|
||||
$packages = explode(',', $package_srls);
|
||||
$ftp_info = Context::getFTPInfo();
|
||||
if(!$_SESSION['ftp_password'])
|
||||
|
|
@ -196,7 +197,11 @@ class autoinstallAdminController extends autoinstall
|
|||
foreach($packages as $package_srl)
|
||||
{
|
||||
$package = $oModel->getPackage($package_srl);
|
||||
if($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
|
||||
if($oAdminModel->checkUseDirectModuleInstall($package)->toBool())
|
||||
{
|
||||
$oModuleInstaller = new DirectModuleInstaller($package);
|
||||
}
|
||||
else if($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
|
||||
{
|
||||
$oModuleInstaller = new SFTPModuleInstaller($package);
|
||||
}
|
||||
|
|
@ -308,7 +313,11 @@ class autoinstallAdminController extends autoinstall
|
|||
{
|
||||
$package_srl = Context::get('package_srl');
|
||||
|
||||
$this->uninstallPackageByPackageSrl($package_srl);
|
||||
$output = $this->uninstallPackageByPackageSrl($package_srl);
|
||||
if($output->toBool()==FALSE)
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
if(Context::get('return_url'))
|
||||
{
|
||||
|
|
@ -348,6 +357,8 @@ class autoinstallAdminController extends autoinstall
|
|||
{
|
||||
$path = $package->path;
|
||||
|
||||
$oAdminModel = getAdminModel('autoinstall');
|
||||
|
||||
if(!$_SESSION['ftp_password'])
|
||||
{
|
||||
$ftp_password = Context::get('ftp_password');
|
||||
|
|
@ -359,7 +370,11 @@ class autoinstallAdminController extends autoinstall
|
|||
$ftp_info = Context::getFTPInfo();
|
||||
|
||||
$isSftpSupported = function_exists(ssh2_sftp);
|
||||
if($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
|
||||
if($oAdminModel->checkUseDirectModuleInstall($package)->toBool())
|
||||
{
|
||||
$oModuleInstaller = new DirectModuleInstaller($package);
|
||||
}
|
||||
else if($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
|
||||
{
|
||||
$oModuleInstaller = new SFTPModuleInstaller($package);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -348,6 +348,61 @@ class autoinstallAdminModel extends autoinstall
|
|||
$this->add('package', $package);
|
||||
}
|
||||
|
||||
public function checkUseDirectModuleInstall($package)
|
||||
{
|
||||
$directModuleInstall = TRUE;
|
||||
$arrUnwritableDir = array();
|
||||
$output = $this->isWritableDir($package->path);
|
||||
if($output->toBool()==FALSE)
|
||||
{
|
||||
$directModuleInstall = FALSE;
|
||||
$arrUnwritableDir[] = $output->get('path');
|
||||
}
|
||||
|
||||
foreach($package->depends as $dep)
|
||||
{
|
||||
$output = $this->isWritableDir($dep->path);
|
||||
if($output->toBool()==FALSE)
|
||||
{
|
||||
$directModuleInstall = FALSE;
|
||||
$arrUnwritableDir[] = $output->get('path');
|
||||
}
|
||||
}
|
||||
|
||||
if($directModuleInstall==FALSE)
|
||||
{
|
||||
$output = new Object(-1, 'msg_direct_inall_invalid');
|
||||
$output->add('path', $arrUnwritableDir);
|
||||
return $output;
|
||||
}
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
public function isWritableDir($path)
|
||||
{
|
||||
$path_list = explode('/', dirname($path));
|
||||
$real_path = './';
|
||||
|
||||
while($path_list)
|
||||
{
|
||||
$check_path = $real_path . implode('/', $path_list);
|
||||
if(FileHandler::isDir($check_path))
|
||||
{
|
||||
break;
|
||||
}
|
||||
array_pop($path_list);
|
||||
}
|
||||
|
||||
if(FileHandler::isWritableDir($check_path)==FALSE)
|
||||
{
|
||||
$output = new Object(-1, 'msg_unwritable_directory');
|
||||
$output->add('path', FileHandler::getRealPath($check_path));
|
||||
return $output;
|
||||
}
|
||||
return new Object();
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file autoinstall.admin.model.php */
|
||||
/* Location: ./modules/autoinstall/autoinstall.admin.model.php */
|
||||
|
|
|
|||
|
|
@ -368,6 +368,9 @@ class autoinstallAdminView extends autoinstall
|
|||
Context::set('need_password', TRUE);
|
||||
}
|
||||
|
||||
$output = $oAdminModel->checkUseDirectModuleInstall($package);
|
||||
Context::set('directModuleInstall', $output);
|
||||
|
||||
$this->setTemplateFile('install');
|
||||
|
||||
$security = new Security();
|
||||
|
|
@ -503,6 +506,7 @@ class autoinstallAdminView extends autoinstall
|
|||
}
|
||||
|
||||
$oModel = getModel('autoinstall');
|
||||
$oAdminModel = getAdminModel('autoinstall');
|
||||
$installedPackage = $oModel->getInstalledPackage($package_srl);
|
||||
if(!$installedPackage)
|
||||
{
|
||||
|
|
@ -529,6 +533,9 @@ class autoinstallAdminView extends autoinstall
|
|||
return $this->stop("msg_invalid_request");
|
||||
}
|
||||
|
||||
$output = $oAdminModel->checkUseDirectModuleInstall($installedPackage);
|
||||
Context::set('directModuleInstall', $output);
|
||||
|
||||
$params["act"] = "getResourceapiPackages";
|
||||
$params["package_srls"] = $package_srl;
|
||||
$body = XmlGenerater::generate($params);
|
||||
|
|
|
|||
|
|
@ -867,6 +867,131 @@ class FTPModuleInstaller extends ModuleInstaller
|
|||
return new Object();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Module installer for Direct. Not use FTP
|
||||
* @author NAVER (developers@xpressengine.com)
|
||||
*/
|
||||
class DirectModuleInstaller extends ModuleInstaller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object $package Package information
|
||||
*/
|
||||
function DirectModuleInstaller(&$package)
|
||||
{
|
||||
$this->package = &$package;
|
||||
}
|
||||
|
||||
/**
|
||||
* empty
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function _connect()
|
||||
{
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove file
|
||||
*
|
||||
* @param string $path Path to remove
|
||||
* @return Object
|
||||
*/
|
||||
function _removeFile($path)
|
||||
{
|
||||
if(substr($path, 0, 2) == "./")
|
||||
{
|
||||
$path = substr($path, 2);
|
||||
}
|
||||
$target_path = FileHandler::getRealPath($path);
|
||||
|
||||
if(!FileHandler::removeFile($target_path))
|
||||
{
|
||||
return new Object(-1, sprintf(Context::getLang('msg_delete_file_failed'), $path));
|
||||
}
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove directory
|
||||
* @param string $path Path to remove
|
||||
* @return Object
|
||||
*/
|
||||
function _removeDir_real($path)
|
||||
{
|
||||
if(substr($path, 0, 2) == "./")
|
||||
{
|
||||
$path = substr($path, 2);
|
||||
}
|
||||
$target_path = FileHandler::getRealPath($path);
|
||||
|
||||
FileHandler::removeDir($target_path);
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _close()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy directory
|
||||
*
|
||||
* @param array $file_list File list to copy
|
||||
* @return Object
|
||||
*/
|
||||
function _copyDir(&$file_list)
|
||||
{
|
||||
$output = $this->_connect();
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
$target_dir = $this->target_path;
|
||||
|
||||
if(is_array($file_list))
|
||||
{
|
||||
foreach($file_list as $k => $file)
|
||||
{
|
||||
$org_file = $file;
|
||||
if($this->package->path == ".")
|
||||
{
|
||||
$file = substr($file, 3);
|
||||
}
|
||||
$path = FileHandler::getRealPath("./" . $this->target_path . "/" . $file);
|
||||
$path_list = explode('/', dirname($this->target_path . "/" . $file));
|
||||
$real_path = "./";
|
||||
|
||||
for($i = 0; $i < count($path_list); $i++)
|
||||
{
|
||||
if($path_list == "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$real_path .= $path_list[$i] . "/";
|
||||
if(!file_exists(FileHandler::getRealPath($real_path)))
|
||||
{
|
||||
FileHandler::makeDir($real_path);
|
||||
}
|
||||
}
|
||||
FileHandler::copyFile( FileHandler::getRealPath($this->download_path . "/" . $org_file), FileHandler::getRealPath("./" . $target_dir . '/' . $file));
|
||||
}
|
||||
}
|
||||
|
||||
$this->_close();
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file autoinstall.lib.php */
|
||||
/* Location: ./modules/autoinstall/autoinstall.lib.php */
|
||||
|
|
|
|||
|
|
@ -323,6 +323,11 @@
|
|||
<value xml:lang="en"><![CDATA[SFTP is not supported.]]></value>
|
||||
<value xml:lang="jp"><![CDATA[SFTPの非対応環境です。]]></value>
|
||||
</item>
|
||||
<item name="msg_direct_install_not_supported">
|
||||
<value xml:lang="ko"><![CDATA[아래 목록에 나열된 디렉터리에 쓰기 권한이 없기 때문에 FTP를 사용합니다.]]></value>
|
||||
<value xml:lang="en"><![CDATA[Use FTP because there is no write permission to the directories listed in the list below.]]></value>
|
||||
<value xml:lang="jp"><![CDATA[下記のリストにリストされているディレクトリへの書き込み権限がないため、FTPを使用してください。]]></value>
|
||||
</item>
|
||||
<item name="msg_does_not_support_delete">
|
||||
<value xml:lang="ko"><![CDATA[이 패키지가 삭제를 지원하지 않습니다(모듈 클래스에 moduleUninstall()이 없음).]]></value>
|
||||
<value xml:lang="en"><![CDATA[Cannot delete this package (no moduleUninstall() in the module class).]]></value>
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@
|
|||
<input type="hidden" name="act" value="procAutoinstallAdminPackageinstall" />
|
||||
<input type="hidden" name="package_srl" value="{$package->package_srl}" />
|
||||
<input type="hidden" name="return_url" value="{$return_url}" />
|
||||
<input cond="!$need_password" type="hidden" name="ftp_password" value="dummy" />
|
||||
<input cond="!$need_password || $directModuleInstall->toBool()" type="hidden" name="ftp_password" value="dummy" />
|
||||
<input type="hidden" name="xe_validator_id" value="modules/autoinstall/tpl/install/1" />
|
||||
|
||||
<block cond="$need_password">
|
||||
<block cond="$need_password && !$directModuleInstall->toBool()">
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="ftp_password">FTP {$lang->password}</label>
|
||||
<div class="x_controls">
|
||||
|
|
@ -52,6 +52,12 @@
|
|||
</div>
|
||||
</div>
|
||||
</block>
|
||||
<block cond="!$directModuleInstall->toBool()">
|
||||
<p>{$lang->msg_direct_install_not_supported}</p>
|
||||
<ul>
|
||||
<li loop="$directModuleInstall->get('path') => $path">{$path}</li>
|
||||
</ul>
|
||||
</block>
|
||||
<div class="x_clearfix btnArea">
|
||||
<div class="x_pull-right">
|
||||
<input class="x_btn x_btn-primary" type="submit" value="{$package->installed?$lang->update:$lang->install}" />
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@
|
|||
<input type="hidden" name="act" value="procAutoinstallAdminUninstallPackage" />
|
||||
<input type="hidden" name="package_srl" value="{$package_srl}" />
|
||||
<input type="hidden" name="return_url" value="{$return_url}" />
|
||||
<input cond="!$need_password" type="hidden" name="ftp_password" value="dummy" />
|
||||
<input cond="!$need_password || $directModuleInstall->toBool()" type="hidden" name="ftp_password" value="dummy" />
|
||||
<input type="hidden" name="xe_validator_id" value="modules/autoinstall/tpl/uninstall/1" />
|
||||
|
||||
<block cond="$need_password">
|
||||
<block cond="$need_password && !$directModuleInstall->toBool()">
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="ftp_password">FTP {$lang->password}</label>
|
||||
<div class="x_controls">
|
||||
|
|
@ -29,7 +29,12 @@
|
|||
</div>
|
||||
</div>
|
||||
</block>
|
||||
|
||||
<block cond="!$directModuleInstall->toBool()">
|
||||
<p>{$lang->msg_direct_install_not_supported}</p>
|
||||
<ul>
|
||||
<li loop="$directModuleInstall->get('path') => $path">{$path}</li>
|
||||
</ul>
|
||||
</block>
|
||||
<div class="x_clearfix btnArea">
|
||||
<div class="x_pull-right">
|
||||
<input class="x_btn x_btn-primary" type="submit" value="{$lang->cmd_delete}" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue