#18532365 : remove storing ftp_password.

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7156 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
haneul 2010-01-15 15:49:34 +00:00
parent ddfa2f6df1
commit c43d52da74
27 changed files with 373 additions and 291 deletions

View file

@ -6,8 +6,12 @@
function getSFTPList()
{
$ftp_info = Context::getFTPInfo();
$connection = ssh2_connect('localhost', $ftp_info->ftp_port);
$ftp_info = Context::getRequestVars();
if(!$ftp_info->ftp_host)
{
$ftp_info->ftp_host = "127.0.0.1";
}
$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');
@ -36,8 +40,16 @@
{
set_time_limit(5);
require_once(_XE_PATH_.'libs/ftp.class.php');
$ftp_info = Context::getFTPInfo();
$this->pwd = Context::get('pwd');
$ftp_info = Context::getRequestVars();
if(!$ftp_info->ftp_user || !$ftp_info->ftp_password)
{
return new Object(-1, 'msg_ftp_invalid_auth_info');
}
$this->pwd = $ftp_info->ftp_root_path;
if(!$ftp_info->ftp_host)
{
$ftp_info->ftp_host = "127.0.0.1";
}
if($ftp_info->sftp == 'Y')
{
@ -45,7 +57,7 @@
}
$oFtp = new ftp();
if($oFtp->ftp_connect('localhost', $ftp_info->ftp_port)){
if($oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)){
if($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
$_list = $oFtp->ftp_rawlist($this->pwd);
$oFtp->ftp_quit();
@ -56,19 +68,6 @@
}
}
$list = array();
if(count($_list) == 0 || !$_list[0]) {
$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($this->pwd);
$oFtp->ftp_quit();
}
else
{
return new Object(-1,'msg_ftp_invalid_auth_info');
}
}
}
if($_list){
foreach($_list as $k => $v){

View file

@ -276,22 +276,6 @@
$output = executeQuery('module.getSiteInfo', $site_args);
Context::set('start_module', $output->data);
$pwd = Context::get('pwd');
if(!$pwd && $ftp_info->ftp_root_path)
{
$pwd = $ftp_info->ftp_root_path;
}
if(!$pwd) {
if($ftp_info->sftp == 'Y')
{
$pwd = _XE_PATH_;
}
else
{
$pwd = '/';
}
}
Context::set('pwd',$pwd);
Context::set('layout','none');
$this->setTemplateFile('config');

View file

@ -79,4 +79,6 @@
$lang->use_db_session = 'Use Session DB';
$lang->about_db_session = 'It will use php session with DB when authenticating.<br/>Websites with infrequent usage of web server may expect faster response when this function is disabled.<br/>However session DB will make it unable to get current users, so you cannot use related functions.';
$lang->sftp = "Use SFTP";
$lang->ftp_get_list = "Get List";
$lang->ftp_remove_info = 'Remove FTP Info.';
?>

View file

@ -81,4 +81,6 @@
$lang->use_db_session = '인증 세션 DB 사용';
$lang->about_db_session = '인증시 사용되는 PHP 세션을 DB로 사용하는 기능입니다.<br/>웹서버의 사용율이 낮은 사이트에서는 비활성화시 사이트 응답 속도가 향상될 수 있습니다<br/>단 현재 접속자를 구할 수 없어 관련된 기능을 사용할 수 없게 됩니다.';
$lang->sftp = "Use SFTP";
$lang->ftp_get_list = "Get List";
$lang->ftp_remove_info = 'Remove FTP Info.';
?>

View file

@ -80,4 +80,6 @@
$lang->use_db_session = '인증 세션 DB 사용';
$lang->about_db_session = '인증시 사용되는 PHP 세션을 DB로 사용하는 기능입니다.<br/>웹서버의 사용율이 낮은 사이트에서는 비활성화시 사이트 응답 속도가 향상될 수 있습니다<br/>단 현재 접속자를 구할 수 없어 관련된 기능을 사용할 수 없게 됩니다.';
$lang->sftp = "Use SFTP";
$lang->ftp_get_list = "Get List";
$lang->ftp_remove_info = 'Remove FTP Info.';
?>

View file

@ -79,4 +79,6 @@
$lang->use_db_session = 'DBで認証セッション管理';
$lang->about_db_session = '認証の時に使われるPHPセッションをDBで使う機能です。<br />ウェブサーバーの負荷が低いサイトではこの機能をオフにすることでむしろサイトのレスポンスが向上されることもあります。<br />また、この機能をオンにすると、「現在ログイン中の会員」の機能が不可になります。';
$lang->sftp = "Use SFTP";
$lang->ftp_get_list = "Get List";
$lang->ftp_remove_info = 'Remove FTP Info.';
?>

View file

@ -79,4 +79,6 @@
$lang->use_db_session = '인증 세션 DB 사용';
$lang->about_db_session = '인증 시 사용되는 PHP 세션을 DB로 사용하는 기능입니다.<br/>웹서버의 사용률이 낮은 사이트에서는 비활성화시 사이트 응답 속도가 향상될 수 있습니다.<br/>단 현재 접속자를 구할 수 없어 관련된 기능을 사용할 수 없게 됩니다.';
$lang->sftp = 'SFTP 사용';
$lang->ftp_get_list = '목록 가져오기';
$lang->ftp_remove_info = 'FTP 정보 삭제';
?>

View file

@ -80,4 +80,6 @@
$lang->use_db_session = '인증 세션 DB 사용';
$lang->about_db_session = '인증시 사용되는 PHP 세션을 DB로 사용하는 기능입니다.<br/>웹서버의 사용율이 낮은 사이트에서는 비활성화시 사이트 응답 속도가 향상될 수 있습니다<br/>단 현재 접속자를 구할 수 없어 관련된 기능을 사용할 수 없게 됩니다.';
$lang->sftp = "Use SFTP";
$lang->ftp_get_list = "Get List";
$lang->ftp_remove_info = 'Remove FTP Info.';
?>

View file

@ -81,4 +81,6 @@
$lang->use_db_session = 'Xác nhận Database';
$lang->about_db_session = 'PHP sẽ xác nhận với Database. Có thể cải thiện được tốc độ của Website.';
$lang->sftp = "Use SFTP";
$lang->ftp_get_list = "Get List";
$lang->ftp_remove_info = 'Remove FTP Info.';
?>

View file

@ -79,4 +79,6 @@
$lang->use_db_session = 'DB储存认证会话';
$lang->about_db_session = '用DB储存认证时的PHP会话。<br/>服务器使用率较少的网站建议不要勾选此项(可提高网站访问速度)。<br/>只是无法统计在线会员。';
$lang->sftp = "Use SFTP";
$lang->ftp_get_list = "Get List";
$lang->ftp_remove_info = 'Remove FTP Info.';
?>

View file

@ -79,4 +79,6 @@
$lang->use_db_session = 'DB session認證';
$lang->about_db_session = '인증 시 사용되는 PHP 세션을 DB로 사용하는 기능입니다.<br/>웹서버의 사용률이 낮은 사이트에서는 비활성화시 사이트 응답 속도가 향상될 수 있습니다.<br/>단 현재 접속자를 구할 수 없어 관련된 기능을 사용할 수 없게 됩니다.';
$lang->sftp = "使用 SFTP";
$lang->ftp_get_list = "Get List";
$lang->ftp_remove_info = 'Remove FTP Info.';
?>

View file

@ -15,12 +15,7 @@
sObj.value = module_srl;
obj.value = decodeURIComponent(browser_title.replace(/\+/g," "))+' ('+mid+')';
}
<!--@if($ftp_info && $ftp_info->ftp_password && $ftp_info->ftp_user)-->
var pwd = '{$pwd}';
params = new Array();
params['pwd'] = pwd;
exec_xml('admin','getAdminFTPList', params, completeGetFtpInfo, new Array('list','error','message'));
<!--@end-->
var xe_root = "{_XE_PATH_}";
</script>
<div class="content">
@ -127,67 +122,55 @@
</table>
</form>
<h4 class="xeAdmin" id="ftpSetup">{$lang->ftp_form_title}</h4>
<p class="summary">{$lang->about_ftp_info}</p>
<form action="./" method="post" onsubmit="return procFilter(this, install_ftp_info);" id="ftp_form">
{@ $nCols = 3; }
<table cellspacing="0" class="rowTable">
<tr>
<th><div><label for="textfield21">{$lang->user_id}</label></div></th>
<th><div><label for="textfield22">{$lang->password}</label></div></th>
<th><div><label for="textfield24">{$lang->ftp_port}</label></div></th>
<!--@if($sftp_support)-->
{@ $nCols += 1; }
<th><div><label for="checkbox25">{$lang->sftp}</label></div></th>
<!--@end-->
</tr>
<tr>
<td><input type="text" id="textfield21" name="ftp_user" value="{$ftp_info->ftp_user}" class="inputTypeText" /></td>
<td><input id="textfield22" type="password" name="ftp_password" value="" class="inputTypeText" /></td>
<td><input id="textfield24" type="text" name="ftp_port" value="{$ftp_info->ftp_port}" class="inputTypeText" /></td>
<!--@if($sftp_support)-->
<td><input type="checkbox" id="checkbox25" name="sftp" value="Y" <!--@if($ftp_info->sftp=="Y")-->checked="checked"<!--@end--> /></td>
<!--@end-->
</tr>
<tr>
<th colspan="{$nCols}" class="button">
<span class="button blue"><input type="button" value="{$lang->cmd_check_ftp_connect}" onclick="doCheckFTPInfo(); return false;"/></span>
<span class="button black strong"><input type="submit" value="{$lang->cmd_registration}" /></span>
</th>
</tr>
</table>
</form>
<!--@if($ftp_info && $ftp_info->ftp_password && $ftp_info->ftp_user)-->
<h4 class="xeAdmin" id="ftpSetup">{$lang->ftp_path_title}</h4>
<form action="./" method="POST" onsubmit="return procFilter(this, install_ftp_path)">
<table cellspacing="0" class="rowTable">
<tr>
<th scope="col"><div>{$lang->msg_ftp_installed_realpath}</div></th>
<td>{_XE_PATH_}
</td>
<th scope="col"><div><label for="textfield21">{$lang->user_id}</label></div></th>
<td><input type="text" id="textfield21" name="ftp_user" value="{$ftp_info->ftp_user}" class="inputTypeText" />
</tr>
<tr>
<th scope="col" rowspan="2"><div>{$lang->msg_ftp_installed_ftp_realpath}</div></th>
<th scope="col"><div><label for="textfield22">{$lang->password} ({$lang->about_ftp_password})</label></div></th>
<td><input id="textfield22" type="password" name="ftp_password" value="" class="inputTypeText" /></td>
</tr>
<tr>
<th scope="col"><div><label for="textfield23">{$lang->ftp_host} (default: 127.0.0.1)</label></div></th>
<td><input id="textfield23" type="text" name="ftp_host" value="{$ftp_info->ftp_host}" class="inputTypeText" /></td>
</tr>
<tr>
<th scope="col"><div><label for="textfield24">{$lang->ftp_port} (default: 21) </label></div></th>
<td><input id="textfield24" type="text" name="ftp_port" value="{$ftp_info->ftp_port}" class="inputTypeText" /></td>
</tr>
<!--@if($sftp_support)-->
<tr>
<th scope="col"><div><label for="checkbox25">{$lang->sftp}</label></div></th>
<td><input type="checkbox" id="checkbox25" name="sftp" value="Y" <!--@if($ftp_info->sftp=="Y")-->checked="checked"<!--@end--> /></td>
</tr>
<!--@end-->
<tr>
<th scope="col" rowspan="2"><div>{$lang->msg_ftp_installed_ftp_realpath}<br /><br/>{$lang->msg_ftp_installed_realpath}:<br/> {_XE_PATH_}</div></th>
<td>
<input type="text" name="ftp_root_path" value="<!--@if($pwd)-->{$pwd}<!--@else-->{$ftp_info->ftp_root_path}<!--@end-->" class="inputTypeText w400" />
<input type="text" name="ftp_root_path" value="{$ftp_info->ftp_root_path}" class="inputTypeText w400" />
</td>
</tr>
<tr id="ftplist">
<td>
<div class="serverresponse">
Waiting to load information
<div>
<span class="button blue strong"><input type="button" onclick="getFTPList(); return false;" value="{$lang->ftp_get_list}"></span>
</div>
</td>
</tr>
<tr class="row2">
<tr>
<th colspan="2" class="button">
<span class="button blue strong"><input type="button" onclick="removeFTPInfo(); return false;" value="{$lang->ftp_remove_info}"></span>
<span class="button black strong"><input type="submit" value="{$lang->cmd_registration}" /></span>
</th>
</tr>
</table>
</form>
<!--@end-->
</div>
<hr />

View file

@ -1,8 +1,8 @@
<filter name="install_ftp_info" module="install" act="procInstallAdminSaveFTPInfo" >
<form>
<node target="ftp_user" required="true" />
<node target="ftp_password" required="true" />
<node target="ftp_port" required="true" />
<node target="ftp_root_path" required="true" />
<node target="sftp" />
</form>
<response callback_func="completeMessage">

View file

@ -1,5 +1,42 @@
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)
{
if(typeof(form.sftp) != 'undefined' && form.sftp.checked) {
form.ftp_root_path.value = xe_root;
}
else
{
form.ftp_root_path.value = "/";
}
}
}
var params={}, data=jQuery("#ftp_form").serializeArray();
jQuery.each(data, function(i, field){ params[field.name] = field.value });
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("#ftplist").empty();
var list = "";
if(!jQuery.isArray(ret_obj['list']['item']))
@ -7,6 +44,7 @@ function completeGetFtpInfo(ret_obj)
ret_obj['list']['item'] = [ret_obj['list']['item']];
}
pwd = jQuery("#ftp_form").get(0).ftp_root_path.value;
if(pwd != "/")
{
arr = pwd.split("/");
@ -14,7 +52,7 @@ function completeGetFtpInfo(ret_obj)
arr.pop();
arr.push("");
target = arr.join("/");
list = list + "<li><a href='"+current_url.setQuery('pwd',target)+"#ftpSetup'>../</a></li>";
list = list + "<li><a href='#ftpSetup' onclick=\"getFTPList('"+target+"')\">../</a></li>";
}
for(var i=0;i<ret_obj['list']['item'].length;i++)
@ -30,10 +68,10 @@ function completeGetFtpInfo(ret_obj)
}
else
{
list = list + "<li><a href='"+current_url.setQuery('pwd',pwd+v)+"#ftpSetup'>"+v+"</a></li>";
list = list + "<li><a href='#ftpSetup' onclick=\"getFTPList('"+pwd+v+"')\">"+v+"</a></li>";
}
}
list = "<td><ul>"+list+"</ul></td>";
e.append(jQuery(list));
}
}