mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 02:31:40 +09:00
added a feature that is find xe installed path automatic
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12107 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
25ebcf1e70
commit
c880cc2649
4 changed files with 242 additions and 30 deletions
|
|
@ -19,6 +19,173 @@
|
|||
*/
|
||||
var $gnbLangBuffer;
|
||||
|
||||
/**
|
||||
* Find XE installed path on sftp
|
||||
*/
|
||||
function getSFTPPath()
|
||||
{
|
||||
$ftp_info = Context::getRequestVars();
|
||||
debugPrint($ftp_info);
|
||||
|
||||
if(!$ftp_info->ftp_host)
|
||||
{
|
||||
$ftp_info->ftp_host = "127.0.0.1";
|
||||
}
|
||||
|
||||
if(!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port))
|
||||
{
|
||||
$ftp_info->ftp_port = '22';
|
||||
}
|
||||
|
||||
$connection = ssh2_connect($ftp_info->ftp_host, $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);
|
||||
|
||||
// create temp file
|
||||
$pin = time();
|
||||
FileHandler::writeFile('./files/cache/ftp_check', $pin);
|
||||
|
||||
// create path candidate
|
||||
$xe_path = _XE_PATH_;
|
||||
$path_info = array_reverse(explode('/', _XE_PATH_));
|
||||
array_pop($path_info); // remove last '/'
|
||||
$path_candidate = array();
|
||||
|
||||
$temp = '';
|
||||
foreach($path_info as $path)
|
||||
{
|
||||
$temp = '/' . $path . $temp;
|
||||
$path_candidate[] = $temp;
|
||||
}
|
||||
|
||||
// try
|
||||
foreach($path_candidate as $path)
|
||||
{
|
||||
// upload check file
|
||||
if(!@ssh2_scp_send($connection, FileHandler::getRealPath('./files/cache/ftp_check'), $path . 'ftp_check.html'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// get check file
|
||||
$result = FileHandler::getRemoteResource(getNotencodedFullUrl() . 'ftp_check.html');
|
||||
|
||||
// delete temp check file
|
||||
@ssh2_sftp_unlink($sftp, $path . 'ftp_check.html');
|
||||
|
||||
// found
|
||||
if($result == $pin)
|
||||
{
|
||||
$found_path = $path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FileHandler::removeFile('./files/cache/ftp_check', $pin);
|
||||
|
||||
if($found_path)
|
||||
{
|
||||
$this->add('found_path', $found_path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find XE installed path on ftp
|
||||
*/
|
||||
function getAdminFTPPath()
|
||||
{
|
||||
Context::loadLang('./modules/autoinstall/lang');
|
||||
set_time_limit(5);
|
||||
require_once(_XE_PATH_ . 'libs/ftp.class.php');
|
||||
|
||||
$ftp_info = Context::getRequestVars();
|
||||
|
||||
if(!$ftp_info->ftp_user || !$ftp_info->ftp_password)
|
||||
{
|
||||
return new Object(1, 'msg_ftp_invalid_auth_info');
|
||||
}
|
||||
|
||||
if(!$ftp_info->ftp_host)
|
||||
{
|
||||
$ftp_info->ftp_host = '127.0.0.1';
|
||||
}
|
||||
|
||||
if(!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port))
|
||||
{
|
||||
$ftp_info->ftp_port = '21';
|
||||
}
|
||||
|
||||
if($ftp_info->sftp == 'Y')
|
||||
{
|
||||
if(!function_exists(ssh2_sftp))
|
||||
{
|
||||
return new Object(-1,'disable_sftp_support');
|
||||
}
|
||||
return $this->getSFTPPath();
|
||||
}
|
||||
|
||||
$oFTP = new ftp();
|
||||
if(!$oFTP->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port))
|
||||
{
|
||||
return new Object(1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host));
|
||||
}
|
||||
|
||||
if(!$oFTP->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password))
|
||||
{
|
||||
return new Object(1, 'msg_ftp_invalid_auth_info');
|
||||
}
|
||||
|
||||
// create temp file
|
||||
$pin = time();
|
||||
FileHandler::writeFile('./files/cache/ftp_check', $pin);
|
||||
|
||||
// create path candidate
|
||||
$xe_path = _XE_PATH_;
|
||||
$path_info = array_reverse(explode('/', _XE_PATH_));
|
||||
array_pop($path_info); // remove last '/'
|
||||
$path_candidate = array();
|
||||
|
||||
$temp = '';
|
||||
foreach($path_info as $path)
|
||||
{
|
||||
$temp = '/' . $path . $temp;
|
||||
$path_candidate[] = $temp;
|
||||
}
|
||||
|
||||
// try
|
||||
foreach($path_candidate as $path)
|
||||
{
|
||||
// upload check file
|
||||
if(!$oFTP->ftp_put($path . 'ftp_check.html', FileHandler::getRealPath('./files/cache/ftp_check')))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// get check file
|
||||
$result = FileHandler::getRemoteResource(getNotencodedFullUrl() . 'ftp_check.html');
|
||||
|
||||
// delete temp check file
|
||||
$oFTP->ftp_delete($path . 'ftp_check.html');
|
||||
|
||||
// found
|
||||
if($result == $pin)
|
||||
{
|
||||
$found_path = $path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FileHandler::removeFile('./files/cache/ftp_check', $pin);
|
||||
|
||||
if($found_path)
|
||||
{
|
||||
$this->add('found_path', $found_path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add file list to Object after sftp connect
|
||||
* @return void|Object
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
<action name="procAdminMenuReset" type="controller" />
|
||||
|
||||
<action name="getAdminFTPList" type="model" standalone="true" />
|
||||
<action name="getAdminFTPPath" type="model" standalone="true" />
|
||||
<action name="getSiteAllList" type="model" standalone="true" />
|
||||
</actions>
|
||||
<menus>
|
||||
|
|
|
|||
|
|
@ -793,6 +793,10 @@
|
|||
<value xml:lang="tr"><![CDATA[FTP Bilgisini Sil.]]></value>
|
||||
<value xml:lang="vi"><![CDATA[Xóa thông tin FTP.]]></value>
|
||||
</item>
|
||||
<item name="msg_find_xe_path_fail">
|
||||
<value xml:lang="ko"><![CDATA[XE 설치 경로를 자동으로 찾지 못하였습니다. 수동 설정해주세요.]]></value>
|
||||
<value xml:lang="en"><![CDATA[Failed to search XE installed path. Please set manually.]]></value>
|
||||
</item>
|
||||
<item name="msg_ftp_invalid_path">
|
||||
<value xml:lang="ko"><![CDATA[FTP 경로(Path)를 읽을 수 없습니다.]]></value>
|
||||
<value xml:lang="en"><![CDATA[Failed to read the specified FTP Path.]]></value>
|
||||
|
|
@ -1480,4 +1484,4 @@
|
|||
<value xml:lang="ko"><![CDATA[모두 접기]]></value>
|
||||
<value xml:lang="en"><![CDATA[Close All]]></value>
|
||||
</item>
|
||||
</lang>
|
||||
</lang>
|
||||
|
|
|
|||
|
|
@ -7,17 +7,12 @@
|
|||
<div class="x_page-header">
|
||||
<h1>{$lang->menu_gnb_sub['adminConfigurationFtp']}</h1>
|
||||
</div>
|
||||
<section class="section">
|
||||
<form action="./" id="ftp_form" method="post" enctype="multipart/form-data" class="x_form-horizontal" ruleset="installFtpInfo">
|
||||
<input type="hidden" name="module" value="install" />
|
||||
<input type="hidden" name="act" value="procInstallAdminSaveFTPInfo" />
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="ftp_host">{$lang->ftp_host}</label>
|
||||
<div class="x_controls">
|
||||
<input type="text" name="ftp_host" id="ftp_host" value="{$ftp_info->ftp_host}" /> Default : 127.0.0.1
|
||||
<p class="x_help-block">{$lang->detail_about_ftp_info}</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="x_help-block">{$lang->detail_about_ftp_info}</p>
|
||||
<form action="./" id="ftp_form" method="post" enctype="multipart/form-data" class="x_form-horizontal" ruleset="installFtpInfo">
|
||||
<input type="hidden" name="module" value="install" />
|
||||
<input type="hidden" name="act" value="procInstallAdminSaveFTPInfo" />
|
||||
<section class="section">
|
||||
<h1>{$lang->subtitle_primary}</h1>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="ftp_user">{$lang->user_id}</label>
|
||||
<div class="x_controls">
|
||||
|
|
@ -31,12 +26,33 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="ftp_port">{$lang->ftp_port}</label>
|
||||
<label class="x_control-label" for="ftp_root_path">{$lang->msg_ftp_installed_ftp_realpath}</label>
|
||||
<div class="x_controls">
|
||||
<input type="text" name="ftp_port" id="ftp_port" value="{$ftp_info->ftp_port}" /> Default : 21
|
||||
<span class="x_input-append">
|
||||
<input type="text" name="ftp_root_path" id="ftp_root_path" value="{$ftp_info->ftp_root_path}" readonly />
|
||||
<a href="#ftpSuggestion" onclick="getFTPList(); return false;" class="x_btn tgAnchor" style="display:none">{$lang->ftp_get_list}</a>
|
||||
</span>
|
||||
<div id="ftpSuggestion" class="x_thumbnail">
|
||||
</div>
|
||||
<p class="x_help-block" style="margin-top:10px">{$lang->msg_ftp_installed_realpath} : {_XE_PATH_}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
</section>
|
||||
<section class="section collapse">
|
||||
<h1>{$lang->subtitle_advanced}</h1>
|
||||
<div class="x_control-group" style="display:none">
|
||||
<label class="x_control-label" for="ftp_host">{$lang->ftp_host}</label>
|
||||
<div class="x_controls">
|
||||
<input type="text" name="ftp_host" id="ftp_host" value="{$ftp_info->ftp_host ? $ftp_info->ftp_host : '127.0.0.1'}" /> Default : 127.0.0.1
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group" style="display:none">
|
||||
<label class="x_control-label" for="ftp_port">{$lang->ftp_port}</label>
|
||||
<div class="x_controls">
|
||||
<input type="text" name="ftp_port" id="ftp_port" value="{$ftp_info->ftp_port ? $ftp_info->ftp_port : '21'}" /> Default : 21
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group" style="display:none">
|
||||
<p class="x_control-label">{$lang->use_ftp_passive_mode}</p>
|
||||
<div class="x_controls">
|
||||
<label class="x_inline" for="ftp_passive_y">
|
||||
|
|
@ -49,7 +65,7 @@
|
|||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<div class="x_control-group" style="display:none">
|
||||
<label class="x_control-label" for="sftp_n">{$lang->use_sftp_support}</label>
|
||||
<div class="x_controls">
|
||||
<label class="x_inline" for="sftp_y"><input type="radio" name="sftp" id="sftp_y" value="Y" checked="checked"|cond="$ftp_info->sftp == 'Y'" disabled|cond="!$sftp_support" />{$lang->cmd_yes}</label>
|
||||
|
|
@ -57,27 +73,51 @@
|
|||
<p class="x_help-black" cond="!$sftp_support">{$lang->disable_sftp_support}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="ftp_root_path">{$lang->msg_ftp_installed_ftp_realpath}</label>
|
||||
<div class="x_controls">
|
||||
<span class="x_input-append">
|
||||
<input type="text" name="ftp_root_path" id="ftp_root_path" value="{$ftp_info->ftp_root_path}" />
|
||||
<a href="#ftpSuggestion" onclick="getFTPList(); return false;" class="x_btn tgAnchor">{$lang->ftp_get_list}</a>
|
||||
</span>
|
||||
<div id="ftpSuggestion" class="x_thumbnail">
|
||||
</div>
|
||||
<p class="x_help-block" style="margin-top:10px">{$lang->msg_ftp_installed_realpath} : {_XE_PATH_}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<div class="btnArea">
|
||||
<input type="submit" value="{$lang->cmd_save}" class="x_btn x_btn-large x_btn-primary x_pull-right" />
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
<style>
|
||||
#ftpSuggestion{padding:8px 15px;margin:2px 0;position:absolute;background:#fff;box-shadow:1px 1px 1px #eee;width:188px}
|
||||
#ftpSuggestion ul{margin:0;padding:0;list-style:none}
|
||||
#ftpSuggestion button{overflow:visible;padding:0;background:none;border:0;display:block;width:100%;text-align:left}
|
||||
#ftpSuggestion button:hover,
|
||||
#ftpSuggestion button:focus{font-weight:bold}
|
||||
</style>
|
||||
</style>
|
||||
<script>
|
||||
jQuery(function($){
|
||||
$('#ftp_form').submit(function(){
|
||||
if($(this).data('found')){
|
||||
return true;
|
||||
}
|
||||
|
||||
$('input[name="ftp_root_path"]').val('');
|
||||
|
||||
param = {
|
||||
'ftp_user': $('#ftp_user').val(),
|
||||
'ftp_password': $('#ftp_password').val(),
|
||||
'ftp_host': $('#ftp_host').val(),
|
||||
'ftp_port': $('#ftp_port').val(),
|
||||
'ftp_pasv': $('input:radio[name="ftp_pasv"]:checked').val(),
|
||||
'sftp': $('input:radio[name="sftp"]:checked').val()
|
||||
}
|
||||
|
||||
$.exec_json('admin.getAdminFTPPath', param, function(data){
|
||||
if(data.error) return;
|
||||
|
||||
if(!data.found_path){
|
||||
alert('{$lang->msg_find_xe_path_fail}');
|
||||
$('input[name="ftp_root_path"]').removeAttr('readonly').next().show();
|
||||
$('#ftp_form').data('found', true);
|
||||
return;
|
||||
}
|
||||
|
||||
$('input[name="ftp_root_path"]').val(data.found_path);
|
||||
$('#ftp_form').data('found', true).submit();
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue