Simplify FTP configuration using new format

This commit is contained in:
Kijin Sung 2016-02-04 16:10:52 +09:00
parent 673cd48db0
commit a36bc03970
9 changed files with 155 additions and 201 deletions

View file

@ -284,7 +284,7 @@ class Lang
public function __get($key) public function __get($key)
{ {
// Separate the plugin name from the key. // Separate the plugin name from the key.
if (($keys = explode('.', $key, 2)) && count($keys) === 2) if (preg_match('/^[a-z0-9_.-]+$/i', $key) && ($keys = explode('.', $key, 2)) && count($keys) === 2)
{ {
list($plugin_name, $key) = $keys; list($plugin_name, $key) = $keys;
if (!isset($this->_loaded_plugins[$plugin_name])) if (!isset($this->_loaded_plugins[$plugin_name]))

View file

@ -543,6 +543,7 @@ class adminAdminController extends admin
// Save // Save
Rhymix\Framework\Config::save(); Rhymix\Framework\Config::save();
$this->setMessage('success_updated');
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral')); $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral'));
} }
@ -575,6 +576,7 @@ class adminAdminController extends admin
Rhymix\Framework\Config::set('embedfilter.object', array_values($embed_object)); Rhymix\Framework\Config::set('embedfilter.object', array_values($embed_object));
Rhymix\Framework\Config::save(); Rhymix\Framework\Config::save();
$this->setMessage('success_updated');
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'act', 'dispAdminConfigSecurity')); $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'act', 'dispAdminConfigSecurity'));
} }
@ -586,7 +588,7 @@ class adminAdminController extends admin
$vars = Context::getRequestVars(); $vars = Context::getRequestVars();
// Default URL // Default URL
$default_url = rtrim(trim($vars->default_url), '/') . '/'; $default_url = rtrim(trim($vars->default_url), '/\\') . '/';
if (!filter_var($default_url, FILTER_VALIDATE_URL) || !preg_match('@^https?://@', $default_url)) if (!filter_var($default_url, FILTER_VALIDATE_URL) || !preg_match('@^https?://@', $default_url))
{ {
return new Object(-1, 'msg_invalid_default_url'); return new Object(-1, 'msg_invalid_default_url');
@ -624,6 +626,7 @@ class adminAdminController extends admin
Rhymix\Framework\Config::set('admin.allow', array_values($allowed_ip)); Rhymix\Framework\Config::set('admin.allow', array_values($allowed_ip));
Rhymix\Framework\Config::save(); Rhymix\Framework\Config::save();
$this->setMessage('success_updated');
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'act', 'dispAdminConfigAdvanced')); $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'act', 'dispAdminConfigAdvanced'));
} }
@ -650,9 +653,98 @@ class adminAdminController extends admin
Rhymix\Framework\Config::set('lock.allow', array_values($allowed_ip)); Rhymix\Framework\Config::set('lock.allow', array_values($allowed_ip));
Rhymix\Framework\Config::save(); Rhymix\Framework\Config::save();
$this->setMessage('success_updated');
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'act', 'dispAdminConfigSitelock')); $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'act', 'dispAdminConfigSitelock'));
} }
/**
* Update FTP configuration.
*/
function procAdminUpdateFTPInfo()
{
$vars = Context::getRequestVars();
$vars->ftp_path = str_replace('\\', '/', rtrim(trim($vars->ftp_path), '/\\')) . '/';
if (strlen($vars->ftp_pass) === 0)
{
$vars->ftp_pass = Rhymix\Framework\Config::get('ftp.pass');
}
// Test FTP connection.
if ($vars->ftp_sftp !== 'Y')
{
if (!($conn = @ftp_connect($vars->ftp_host, $vars->ftp_port, 3)))
{
return new Object(-1, 'msg_ftp_not_connected');
}
if (!@ftp_login($conn, $vars->ftp_user, $vars->ftp_pass))
{
return new Object(-1, 'msg_ftp_invalid_auth_info');
}
if (!@ftp_pasv($conn, $vars->ftp_pasv === 'Y'))
{
return new Object(-1, 'msg_ftp_cannot_set_passive_mode');
}
if (!@ftp_chdir($conn, $vars->ftp_path))
{
return new Object(-1, 'msg_ftp_invalid_path');
}
ftp_close($conn);
}
else
{
if (!function_exists('ssh2_connect'))
{
return new Object(-1, 'disable_sftp_support');
}
if (!($conn = ssh2_connect($vars->ftp_host, $vars->ftp_port)))
{
return new Object(-1, 'msg_ftp_not_connected');
}
if (!@ssh2_auth_password($conn, $vars->ftp_user, $vars->ftp_pass))
{
return new Object(-1, 'msg_ftp_invalid_auth_info');
}
if (!@($sftp = ssh2_sftp($conn)))
{
return new Object(-1, 'msg_ftp_sftp_error');
}
if (!@ssh2_sftp_stat($sftp, $vars->ftp_path . 'common/defaults/config.php'))
{
return new Object(-1, 'msg_ftp_invalid_path');
}
unset($sftp, $conn);
}
// Save settings.
Rhymix\Framework\Config::set('ftp.host', $vars->ftp_host);
Rhymix\Framework\Config::set('ftp.port', $vars->ftp_port);
Rhymix\Framework\Config::set('ftp.user', $vars->ftp_user);
Rhymix\Framework\Config::set('ftp.pass', $vars->ftp_pass);
Rhymix\Framework\Config::set('ftp.path', $vars->ftp_path);
Rhymix\Framework\Config::set('ftp.pasv', $vars->ftp_pasv === 'Y');
Rhymix\Framework\Config::set('ftp.sftp', $vars->ftp_sftp === 'Y');
Rhymix\Framework\Config::save();
$this->setMessage('success_updated');
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'act', 'dispAdminConfigFtp'));
}
/**
* Remove FTP configuration.
*/
function procAdminRemoveFTPInfo()
{
Rhymix\Framework\Config::set('ftp.host', null);
Rhymix\Framework\Config::set('ftp.port', null);
Rhymix\Framework\Config::set('ftp.user', null);
Rhymix\Framework\Config::set('ftp.pass', null);
Rhymix\Framework\Config::set('ftp.path', null);
Rhymix\Framework\Config::set('ftp.pasv', true);
Rhymix\Framework\Config::set('ftp.sftp', false);
Rhymix\Framework\Config::save();
$this->setMessage('success_deleted');
}
/** /**
* Upload favicon and mobicon. * Upload favicon and mobicon.
*/ */

View file

@ -499,16 +499,10 @@ class adminAdminView extends admin
*/ */
function dispAdminConfigFtp() function dispAdminConfigFtp()
{ {
Context::loadLang('modules/install/lang'); Context::set('ftp_info', Rhymix\Framework\Config::get('ftp'));
Context::set('sftp_support', function_exists('ssh2_sftp'));
$ftp_info = Context::getFTPInfo();
Context::set('ftp_info', $ftp_info);
Context::set('sftp_support', function_exists(ssh2_sftp));
$this->setTemplateFile('config_ftp'); $this->setTemplateFile('config_ftp');
//$security = new Security();
//$security->encodeHTML('ftp_info..');
} }
/** /**

View file

@ -25,10 +25,10 @@
<action name="procAdminUpdateSecurity" type="controller" /> <action name="procAdminUpdateSecurity" type="controller" />
<action name="procAdminUpdateAdvanced" type="controller" /> <action name="procAdminUpdateAdvanced" type="controller" />
<action name="procAdminUpdateSitelock" type="controller" /> <action name="procAdminUpdateSitelock" type="controller" />
<action name="procAdminUpdateFTPInfo" type="controller" />
<action name="procAdminRemoveFTPInfo" type="controller" />
<action name="procAdminFaviconUpload" type="controller" /> <action name="procAdminFaviconUpload" type="controller" />
<action name="getAdminFTPList" type="model" />
<action name="getAdminFTPPath" type="model" />
<action name="getSiteAllList" type="model" /> <action name="getSiteAllList" type="model" />
</actions> </actions>
<menus> <menus>

View file

@ -90,7 +90,11 @@ $lang->sftp = 'Use SFTP';
$lang->ftp_get_list = 'Get List'; $lang->ftp_get_list = 'Get List';
$lang->ftp_remove_info = 'Remove FTP Info.'; $lang->ftp_remove_info = 'Remove FTP Info.';
$lang->msg_find_xe_path_fail = 'Failed to search Rhymix installed path automatically. Please set manually.'; $lang->msg_find_xe_path_fail = 'Failed to search Rhymix installed path automatically. Please set manually.';
$lang->msg_ftp_not_connected = 'Failed to connect to FTP server. Please check the hostname and port.';
$lang->msg_ftp_invalid_auth_info = 'Failed to log in to FTP server. Please check your username and password.';
$lang->msg_ftp_cannot_set_passive_mode = 'Failed to set passive mode. Please change your settings and try again.';
$lang->msg_ftp_invalid_path = 'Failed to read the specified FTP Path.'; $lang->msg_ftp_invalid_path = 'Failed to read the specified FTP Path.';
$lang->msg_ftp_sftp_error = 'Failed to initialize SFTP mode after connecting to SSH server.';
$lang->use_ftp_passive_mode = 'Use FTP Passive Mode'; $lang->use_ftp_passive_mode = 'Use FTP Passive Mode';
$lang->use_sftp_support = 'Use SFTP'; $lang->use_sftp_support = 'Use SFTP';
$lang->disable_sftp_support = 'You should install ssh2 PHP module to use SFTP.'; $lang->disable_sftp_support = 'You should install ssh2 PHP module to use SFTP.';
@ -113,8 +117,8 @@ $lang->corp = 'Crop(Cut)';
$lang->ratio = 'Ratio(Keep Aspect)'; $lang->ratio = 'Ratio(Keep Aspect)';
$lang->admin_ip_limit = 'Sepcify IP address band that can access the admin page.'; $lang->admin_ip_limit = 'Sepcify IP address band that can access the admin page.';
$lang->local_ip_address = 'Local IP address'; $lang->local_ip_address = 'Local IP address';
$lang->about_admin_ip_limit = 'Specify IP address which can access to admin page. Please note that only the specified IP addresses can access the admin page. The information on IP address band is stored in /files/config/db.config.php. Change the line to multiple IP.'; $lang->about_admin_ip_limit = 'Specify IP address which can access to admin page. Please note that only the specified IP addresses can access the admin page.';
$lang->detail_about_ftp_info = 'Enable easy installation if you enter FTP information. The information of FTP is stored in files/config/ftp.config.php. If you are unable to easy install, PHP\'s \'safe_mode\' must be changed \'On\''; $lang->detail_about_ftp_info = 'FTP information is needed for easyinstall when save_mode = on.';
$lang->allow_use_favicon = 'Do you want to use favicon?'; $lang->allow_use_favicon = 'Do you want to use favicon?';
$lang->about_use_favicon = 'You can upload 16x16 size<em>*.ico</em> file only.'; $lang->about_use_favicon = 'You can upload 16x16 size<em>*.ico</em> file only.';
$lang->allow_use_mobile_icon = 'Do you want to use the mobile home screen icon?'; $lang->allow_use_mobile_icon = 'Do you want to use the mobile home screen icon?';
@ -172,6 +176,7 @@ $lang->msg_ftp_connect_success = 'Successfully connected to FTP server and authe
$lang->ftp_path_title = 'FTP Path Information'; $lang->ftp_path_title = 'FTP Path Information';
$lang->ftp_installed_realpath = 'Absolute Path of Rhymix'; $lang->ftp_installed_realpath = 'Absolute Path of Rhymix';
$lang->msg_ftp_installed_ftp_realpath = 'Absolute FTP Path of Rhymix installed'; $lang->msg_ftp_installed_ftp_realpath = 'Absolute FTP Path of Rhymix installed';
$lang->msg_ftp_autodetected_ftp_realpath = 'Auto-detected path';
$lang->msg_php_warning_title = 'Warning unsafe PHP version'; $lang->msg_php_warning_title = 'Warning unsafe PHP version';
$lang->msg_php_warning_notice = 'The server is using a unsafe version of PHP, it is recommended to upgrade to the latest stable version.'; $lang->msg_php_warning_notice = 'The server is using a unsafe version of PHP, it is recommended to upgrade to the latest stable version.';
$lang->msg_php_warning_notice_explain = '<li>PHP version of this server can be exposed to serious security problems and attacks.</li><li>Latest version of Rhymix is not available.</li><li>You can not use extensions that are supported by the latest version of Rhymix.</li><li>Some extensions may not work properly. It can cause problems.</li>'; $lang->msg_php_warning_notice_explain = '<li>PHP version of this server can be exposed to serious security problems and attacks.</li><li>Latest version of Rhymix is not available.</li><li>You can not use extensions that are supported by the latest version of Rhymix.</li><li>Some extensions may not work properly. It can cause problems.</li>';

View file

@ -87,14 +87,15 @@ $lang->delay_session = '세션 시작 지연';
$lang->about_delay_session = 'Varnish 등의 프록시 캐싱 서버 사용시 성능 개선을 위해, 로그인하지 않은 사용자에게는 인증 세션을 부여하지 않습니다.<br>이 옵션을 선택할 경우 방문자 수 및 조회수 집계가 정확하게 이루어지지 않을 수 있습니다.'; $lang->about_delay_session = 'Varnish 등의 프록시 캐싱 서버 사용시 성능 개선을 위해, 로그인하지 않은 사용자에게는 인증 세션을 부여하지 않습니다.<br>이 옵션을 선택할 경우 방문자 수 및 조회수 집계가 정확하게 이루어지지 않을 수 있습니다.';
$lang->msg_invalid_default_url = '기본 URL이 올바르지 않습니다.'; $lang->msg_invalid_default_url = '기본 URL이 올바르지 않습니다.';
$lang->sftp = 'SFTP 사용'; $lang->sftp = 'SFTP 사용';
$lang->ftp_get_list = '목록 가져오기'; $lang->msg_ftp_not_connected = 'FTP 서버에 접속할 수 없습니다. 주소와 포트를 확인해 주십시오.';
$lang->ftp_remove_info = 'FTP 정보 삭제'; $lang->msg_ftp_invalid_auth_info = 'FTP 서버에 로그인할 수 없습니다. 아이디와 비밀번호를 확인해 주십시오.';
$lang->msg_find_xe_path_fail = 'Rhymix 설치 경로를 자동으로 찾지 못하였습니다. 수동 설정해주세요.'; $lang->msg_ftp_cannot_set_passive_mode = 'Passive 모드 설정에 실패하였습니다. 설정을 변경하여 다시 시도해 주십시오.';
$lang->msg_ftp_invalid_path = 'FTP 경로(Path)를 읽을 수 없습니다.'; $lang->msg_ftp_invalid_path = 'FTP 서버에서 입력하신 설치 경로를 찾을 수 없습니다.';
$lang->msg_ftp_sftp_error = 'SSH 서버에 접속한 후 SFTP 모드로 전환하는 데 실패했습니다.';
$lang->use_ftp_passive_mode = 'Passive 모드 사용'; $lang->use_ftp_passive_mode = 'Passive 모드 사용';
$lang->use_sftp_support = 'SFTP 사용'; $lang->use_sftp_support = 'SFTP 사용';
$lang->disable_sftp_support = 'SFTP를 사용하시려면 ssh2 PHP 모듈을 설치하셔야 합니다.'; $lang->disable_sftp_support = 'SFTP를 사용하려면 PHP에 ssh2 모듈이 설치되어 있어야 합니다.';
$lang->msg_self_restart_cache_engine = 'Memcached 또는 캐쉬데몬을 재시작 해주세요.'; $lang->msg_self_restart_cache_engine = 'Memcached 또는 캐시 서비스를 재시작해 주세요.';
$lang->autoinstall = '쉬운 설치'; $lang->autoinstall = '쉬운 설치';
$lang->last_week = '지난주'; $lang->last_week = '지난주';
$lang->this_week = '이번주'; $lang->this_week = '이번주';
@ -113,8 +114,8 @@ $lang->corp = 'Crop(잘라내기)';
$lang->ratio = 'Ratio(비율 맞추기)'; $lang->ratio = 'Ratio(비율 맞추기)';
$lang->admin_ip_limit = '관리자 IP대역'; $lang->admin_ip_limit = '관리자 IP대역';
$lang->local_ip_address = '로컬 IP 주소'; $lang->local_ip_address = '로컬 IP 주소';
$lang->about_admin_ip_limit = '관리자 페이지로 접근가능한 IP대역을 지정합니다. 해당 IP에 대해서만 관리자 페이지로 접근이 가능하므로 주의 바랍니다. IP대역 정보는 /files/config/db.config.php 파일에 저장됩니다. 여러개의 항목은 줄을 바꾸어 입력하세요.'; $lang->about_admin_ip_limit = '관리자 페이지로 접근가능한 IP대역을 지정합니다. 해당 IP에 대해서만 관리자 페이지로 접근이 가능하므로 주의 바랍니다.';
$lang->detail_about_ftp_info = 'FTP 정보를 입력하면 쉬운 설치를 가능하도록 합니다. FTP 정보는 files/config/ftp.config.php 파일에 저장됩니다. 쉬운 설치가 불가능한 경우 PHP의 safe_mode를 On으로 변경해야 합니다.'; $lang->detail_about_ftp_info = 'safe_mode = on 상태에서 쉬운설치를 사용하려면 FTP 정보를 입력해야 합니다.';
$lang->allow_use_favicon = '파비콘 지정'; $lang->allow_use_favicon = '파비콘 지정';
$lang->about_use_favicon = '16 x 16 크기의<em>*.ico</em> 파일 업로드 권장.'; $lang->about_use_favicon = '16 x 16 크기의<em>*.ico</em> 파일 업로드 권장.';
$lang->allow_use_mobile_icon = '모바일 홈 화면 아이콘'; $lang->allow_use_mobile_icon = '모바일 홈 화면 아이콘';
@ -159,7 +160,7 @@ $lang->server_env = '서버 정보';
$lang->ftp_form_title = 'FTP 계정 정보 입력'; $lang->ftp_form_title = 'FTP 계정 정보 입력';
$lang->ftp = 'FTP'; $lang->ftp = 'FTP';
$lang->ftp_host = 'FTP 서버 주소'; $lang->ftp_host = 'FTP 서버 주소';
$lang->ftp_port = 'FTP port'; $lang->ftp_port = 'FTP 포트';
$lang->about_ftp_password = '비밀번호는 FTP 경로 확인을 위한 FTP 접속 시 필요하며 사용 후 저장하지 않습니다.'; $lang->about_ftp_password = '비밀번호는 FTP 경로 확인을 위한 FTP 접속 시 필요하며 사용 후 저장하지 않습니다.';
$lang->cmd_check_ftp_connect = 'FTP 접속 확인'; $lang->cmd_check_ftp_connect = 'FTP 접속 확인';
$lang->msg_safe_mode_ftp_needed = 'PHP의<strong>safe_mode=On</strong>일 경우 Rhymix의 정상적인 동작을 돕습니다.'; $lang->msg_safe_mode_ftp_needed = 'PHP의<strong>safe_mode=On</strong>일 경우 Rhymix의 정상적인 동작을 돕습니다.';
@ -170,8 +171,9 @@ $lang->msg_ftp_mkdir_fail = 'FTP를 이용한 디렉토리 생성 명령에 실
$lang->msg_ftp_chmod_fail = 'FTP를 이용한 디렉토리의 속성 변경에 실패했습니다. FTP 서버의 설정을 확인해주세요.'; $lang->msg_ftp_chmod_fail = 'FTP를 이용한 디렉토리의 속성 변경에 실패했습니다. FTP 서버의 설정을 확인해주세요.';
$lang->msg_ftp_connect_success = 'FTP 접속 및 인증에 성공했습니다.'; $lang->msg_ftp_connect_success = 'FTP 접속 및 인증에 성공했습니다.';
$lang->ftp_path_title = 'FTP 경로 정보 입력'; $lang->ftp_path_title = 'FTP 경로 정보 입력';
$lang->ftp_installed_realpath = '설치된 Rhymix의 절대경로'; $lang->ftp_installed_realpath = 'Rhymix 설치 경로';
$lang->msg_ftp_installed_ftp_realpath = '설치된 Rhymix의 FTP 경로'; $lang->msg_ftp_installed_ftp_realpath = 'Rhymix 설치 경로';
$lang->msg_ftp_autodetected_ftp_realpath = '자동 감지된 경로';
$lang->msg_php_warning_title = '안전하지 않은 PHP 버전 경고'; $lang->msg_php_warning_title = '안전하지 않은 PHP 버전 경고';
$lang->msg_php_warning_notice = '이 서버는 안전하지 않은 PHP 버전을 사용하고 있으며, PHP를 최신 안정 버전으로 업그레이드를 권장합니다.'; $lang->msg_php_warning_notice = '이 서버는 안전하지 않은 PHP 버전을 사용하고 있으며, PHP를 최신 안정 버전으로 업그레이드를 권장합니다.';
$lang->msg_php_warning_notice_explain = '<li>매우 심각한 PHP 보안 문제 및 공격에 노출될 수 있습니다.</li><li>Rhymix 최신 버전을 사용할 수 없습니다.</li><li>Rhymix 최신 버전 이상에서 지원하는 확장 기능을 사용할 수 없습니다.</li><li>일부 확장 기능이 동작하지 않거나, 이로 인해 장애가 발생할 수 있습니다.</li>'; $lang->msg_php_warning_notice_explain = '<li>매우 심각한 PHP 보안 문제 및 공격에 노출될 수 있습니다.</li><li>Rhymix 최신 버전을 사용할 수 없습니다.</li><li>Rhymix 최신 버전 이상에서 지원하는 확장 기능을 사용할 수 없습니다.</li><li>일부 확장 기능이 동작하지 않거나, 이로 인해 장애가 발생할 수 있습니다.</li>';

View file

@ -1,78 +1,68 @@
<load target="./js/config.js" usecdn="true" /> <load target="./js/config.js" />
<load target="../install/lang/lang.xml" usecdn="true" /> <load target="../../session/tpl/js/session.js" />
<load target="../../session/tpl/js/session.js" usecdn="true" />
<div class="x_page-header"> <div class="x_page-header">
<h1>{$lang->menu_gnb_sub['adminConfigurationFtp']} <a class="x_icon-question-sign" href="./common/manual/admin/#UMAN_config_ftp" target="_blank">{$lang->help}</a></h1> <h1>{$lang->menu_gnb_sub['adminConfigurationFtp']} <a class="x_icon-question-sign" href="./common/manual/admin/#UMAN_config_ftp" target="_blank">{$lang->help}</a></h1>
</div> </div>
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/admin/tpl/config_ftp/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}"> <div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/admin/tpl/config_ftp/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
<p>{$XE_VALIDATOR_MESSAGE}</p> <p>{$XE_VALIDATOR_MESSAGE}</p>
</div> </div>
<p class="x_help-block">{$lang->detail_about_ftp_info}</p> <p>{$lang->detail_about_ftp_info}</p>
<form action="./" id="ftp_form" method="post" enctype="multipart/form-data" class="x_form-horizontal" ruleset="installFtpInfo"> <form action="./" id="ftp_form" method="post" class="x_form-horizontal" ruleset="installFtpInfo">
<input type="hidden" name="module" value="install" /> <input type="hidden" name="module" value="admin" />
<input type="hidden" name="act" value="procInstallAdminSaveFTPInfo" /> <input type="hidden" name="act" value="procAdminUpdateFTPInfo" />
<input type="hidden" name="success_return_url" value="{base64_decode($success_return_url)}" /> <input type="hidden" name="success_return_url" value="{$success_return_url}" />
<input type="hidden" name="xe_validator_id" value="modules/admin/tpl/config_ftp/1" /> <input type="hidden" name="xe_validator_id" value="modules/admin/tpl/config_ftp/1" />
<section class="section"> <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">
<input type="text" name="ftp_user" id="ftp_user" value="{$ftp_info->ftp_user}" />
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="ftp_password">{$lang->password}</label>
<div class="x_controls">
<input type="password" name="ftp_password" id="ftp_password" value="" />
<p class="x_help-block">{$lang->about_ftp_password}</p>
</div>
</div>
<div id="__xe_path" class="x_control-group" hidden>
<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>
<section class="section" style="margin-bottom:0">
<h1>{$lang->subtitle_advanced}</h1>
<div class="x_control-group"> <div class="x_control-group">
<label class="x_control-label" for="ftp_host">{$lang->ftp_host}</label> <label class="x_control-label" for="ftp_host">{$lang->ftp_host}</label>
<div class="x_controls"> <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 <input type="text" name="ftp_host" id="ftp_host" value="{$ftp_info['host'] ?: 'localhost'}" />
</div> </div>
</div> </div>
<div class="x_control-group"> <div class="x_control-group">
<label class="x_control-label" for="ftp_port">{$lang->ftp_port}</label> <label class="x_control-label" for="ftp_port">{$lang->ftp_port}</label>
<div class="x_controls"> <div class="x_controls">
<input type="number" name="ftp_port" id="ftp_port" value="{$ftp_info->ftp_port ? $ftp_info->ftp_port : '21'}" /> Default : 21 <input type="number" name="ftp_port" id="ftp_port" value="{$ftp_info['port'] ?: '21'}" />
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="ftp_user">{$lang->user_id}</label>
<div class="x_controls">
<input type="text" name="ftp_user" id="ftp_user" value="{$ftp_info['user']}" />
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="ftp_pass">{$lang->password}</label>
<div class="x_controls">
<input type="password" name="ftp_pass" id="ftp_pass" value="" />
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="ftp_path">{$lang->msg_ftp_installed_ftp_realpath}</label>
<div class="x_controls">
<input type="text" name="ftp_path" id="ftp_path" style="min-width:90%" value="{$ftp_info['path'] ?: _XE_PATH_}" />
<br />
<p class="x_help-block">{$lang->msg_ftp_autodetected_ftp_realpath} : {_XE_PATH_}</p>
</div> </div>
</div> </div>
<div class="x_control-group"> <div class="x_control-group">
<div class="x_control-label">{$lang->use_ftp_passive_mode}</div> <div class="x_control-label">{$lang->use_ftp_passive_mode}</div>
<div class="x_controls"> <div class="x_controls">
<label class="x_inline" for="ftp_passive_y"> <label class="x_inline" for="ftp_pasv_y">
<input type="radio" name="ftp_pasv" id="ftp_passive_y" value="Y" checked="checked"|cond="$ftp_info->ftp_pasv == 'Y'" /> <input type="radio" name="ftp_pasv" id="ftp_pasv_y" value="Y" checked="checked"|cond="$ftp_info['pasv']" />
{$lang->cmd_yes} {$lang->cmd_yes}
</label> </label>
<label class="x_inline" for="ftp_passive_n"> <label class="x_inline" for="ftp_pasv_n">
<input type="radio" name="ftp_pasv" id="ftp_passive_n" value="N" checked="checked"|cond="$ftp_info->ftp_pasv != 'Y'" /> <input type="radio" name="ftp_pasv" id="ftp_pasv_n" value="N" checked="checked"|cond="!$ftp_info['pasv']" />
{$lang->cmd_no} {$lang->cmd_no}
</label> </label>
</div> </div>
</div> </div>
<div class="x_control-group"> <div class="x_control-group">
<label class="x_control-label" for="sftp_n">{$lang->use_sftp_support}</label> <label class="x_control-label">{$lang->use_sftp_support}</label>
<div class="x_controls"> <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> <label class="x_inline" for="ftp_sftp_y"><input type="radio" name="ftp_sftp" id="ftp_sftp_y" value="Y" checked="checked"|cond="$ftp_info['sftp']" disabled|cond="!$sftp_support" /> {$lang->cmd_yes}</label>
<label class="x_inline" for="sftp_n"><input type="radio" name="sftp" id="sftp_n" value="N" checked="checked"|cond="$ftp_info->sftp != 'Y'" /> {$lang->cmd_no}</label> <label class="x_inline" for="ftp_sftp_n"><input type="radio" name="ftp_sftp" id="ftp_sftp_n" value="N" checked="checked"|cond="!$ftp_info['sftp']" /> {$lang->cmd_no}</label>
<p class="x_help-black" cond="!$sftp_support">{$lang->disable_sftp_support}</p> <p class="x_help-black" cond="!$sftp_support">{$lang->disable_sftp_support}</p>
</div> </div>
</div> </div>
@ -80,47 +70,4 @@
<div class="btnArea" style="margin-top:0"> <div class="btnArea" style="margin-top:0">
<input type="submit" value="{$lang->cmd_save}" class="x_btn x_btn-primary x_pull-right" /> <input type="submit" value="{$lang->cmd_save}" class="x_btn x_btn-primary x_pull-right" />
</div> </div>
</form> </form>
<style>
#ftpSuggestion{padding:8px 15px;margin:2px 0;position:absolute;background:#fff;box-shadow:1px 1px 1px #eee;width:188px;z-index:99}
#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>
<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}');
$('#__xe_path').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>

View file

@ -16,90 +16,6 @@ function viewSiteSearch(){
jQuery(".site_keyword_search").css("display",""); jQuery(".site_keyword_search").css("display","");
} }
function getFTPList(pwd)
{
var form = jQuery("#ftp_form").get(0);
if(typeof(pwd) != 'undefined')
{
form.ftp_root_path.value = pwd;
}
else
{
if(!form.ftp_root_path.value && typeof(form.sftp) != 'undefined' && form.sftp.checked)
{
form.ftp_root_path.value = xe_root;
}
else
{
form.ftp_root_path.value = "/";
}
}
var params = [];
//ftp_pasv not used
params.ftp_user = jQuery("#ftp_user").val();
params.ftp_password =jQuery("#ftp_password").val();
params.ftp_host = jQuery("#ftp_host").val();
params.ftp_port = jQuery("#ftp_port").val();
params.ftp_root_path = jQuery("#ftp_root_path").val();
params.sftp = jQuery("input[name=sftp]:checked").val();
exec_xml('admin', 'getAdminFTPList', params, completeGetFtpInfo, ['list', 'error', 'message'], params, form);
}
function removeFTPInfo()
{
var params = {};
exec_xml('install', 'procInstallAdminRemoveFTPInfo', params, filterAlertMessage, ['error', 'message'], params);
}
function completeGetFtpInfo(ret_obj)
{
if(ret_obj.error !== 0)
{
alert(ret_obj.error);
alert(ret_obj.message);
return;
}
var e = jQuery("#ftpSuggestion").empty();
var list = "";
if(!jQuery.isArray(ret_obj.list.item))
{
ret_obj.list.item = [ret_obj.list.item];
}
pwd = jQuery("#ftp_form").get(0).ftp_root_path.value;
if(pwd != "/")
{
arr = pwd.split("/");
arr.pop();
arr.pop();
arr.push("");
target = arr.join("/");
list = list + "<li><button type='button' onclick=\"getFTPList('"+target+"')\">../</button></li>";
}
for(var i=0;i<ret_obj.list.item.length;i++)
{
var v = ret_obj.list.item[i];
if(v == "../")
{
continue;
}
else if( v == "./")
{
continue;
}
else
{
list = list + "<li><button type='button' onclick=\"getFTPList('"+pwd+v+"')\">"+v+"</button></li>";
}
}
list = "<ul>"+list+"</ul>";
e.append(jQuery(list));
}
var icon = null; var icon = null;
function deleteIcon(iconname){ function deleteIcon(iconname){
var params = []; var params = [];

View file

@ -15,8 +15,6 @@
<action name="procInstallAdminInstall" type="controller" /> <action name="procInstallAdminInstall" type="controller" />
<action name="procInstallAdminUpdate" type="controller" /> <action name="procInstallAdminUpdate" type="controller" />
<action name="procInstallAdminUpdateIndexModule" type="controller" /> <action name="procInstallAdminUpdateIndexModule" type="controller" />
<action name="procInstallAdminSaveFTPInfo" type="controller" ruleset="installFtpInfo" />
<action name="procInstallAdminRemoveFTPInfo" type="controller" />
<action name="getInstallFTPList" type="model" /> <action name="getInstallFTPList" type="model" />
</actions> </actions>
</module> </module>