17523819 : enable setting SSL and HTTP port

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5109 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
haneul 2008-12-17 09:42:07 +00:00
parent b92ae79baa
commit 3dc23c0223
11 changed files with 170 additions and 27 deletions

View file

@ -21,7 +21,6 @@
var $db_info = NULL; ///< @brief DB 정보 var $db_info = NULL; ///< @brief DB 정보
var $ftp_info = NULL; ///< @brief FTP 정보 var $ftp_info = NULL; ///< @brief FTP 정보
var $ssl_port = NULL; ///< @brief SSL Port number
var $ssl_actions = array(); ///< @brief ssl로 전송해야 할 action등록 (common/js/xml_handler.js에서 ajax통신시 활용) var $ssl_actions = array(); ///< @brief ssl로 전송해야 할 action등록 (common/js/xml_handler.js에서 ajax통신시 활용)
var $js_files = array(); ///< @brief display시에 사용하게 되는 js files의 목록 var $js_files = array(); ///< @brief display시에 사용하게 되는 js files의 목록
var $css_files = array(); ///< @brief display시에 사용하게 되는 css files의 목록 var $css_files = array(); ///< @brief display시에 사용하게 되는 css files의 목록
@ -204,11 +203,21 @@
else $db_info->use_optimizer = 'N'; else $db_info->use_optimizer = 'N';
if(!$db_info->qmail_compatibility || $db_info->qmail_compatibility != 'Y') $db_info->qmail_compatibility = 'N'; if(!$db_info->qmail_compatibility || $db_info->qmail_compatibility != 'Y') $db_info->qmail_compatibility = 'N';
else $db_info->qmail_compatibility = 'Y'; else $db_info->qmail_compatibility = 'Y';
if(!$db_info->use_ssl) $db_info->use_ssl = 'none';
$this->_setDBInfo($db_info); $this->_setDBInfo($db_info);
$GLOBALS['_time_zone'] = $db_info->time_zone; $GLOBALS['_time_zone'] = $db_info->time_zone;
$GLOBALS['_qmail_compatibility'] = $db_info->qmail_compatibility; $GLOBALS['_qmail_compatibility'] = $db_info->qmail_compatibility;
$GLOBALS['_use_ssl'] = $db_info->use_ssl;
if($db_info->http_port)
{
$GLOBALS['_http_port'] = $db_info->http_port;
}
if($db_info->https_port)
{
$GLOBALS['_https_port'] = $db_info->https_port;
}
} }
/** /**
@ -801,8 +810,17 @@
} }
$url_info = parse_url('http://'.$target_url); $url_info = parse_url('http://'.$target_url);
if($use_ssl && $this->ssl_port && $this->ssl_port != 443) { if($use_ssl)
$url_info['port'] = $this->ssl_port; {
if($GLOBALS["_https_port"] && $GLOBALS["_https_port"] != 443) {
$url_info['port'] = $GLOBALS["_https_port"];
}
}
else
{
if($GLOBALS["_http_port"] && $GLOBALS["_http_port"] != 80) {
$url_info['port'] = $GLOBALS["_http_port"];
}
} }
$url[$ssl_mode][$domain_key] = sprintf("%s://%s%s%s",$use_ssl?'https':$url_info['scheme'], $url_info['host'], $url_info['port']&&$url_info['port']!=80?':'.$url_info['port']:'',$url_info['path']); $url[$ssl_mode][$domain_key] = sprintf("%s://%s%s%s",$use_ssl?'https':$url_info['scheme'], $url_info['host'], $url_info['port']&&$url_info['port']!=80?':'.$url_info['port']:'',$url_info['path']);
@ -1261,13 +1279,5 @@
return dirname($_SERVER['PHP_SELF']) . "/" . $url; return dirname($_SERVER['PHP_SELF']) . "/" . $url;
} }
function setSSLPort($port) {
$oContext = &Context::getInstance();
$oContext->_setSSLPort($port);
}
function _setSSLPort($port) {
$this->ssl_port = (int) $port;
}
} }
?> ?>

View file

@ -317,12 +317,33 @@ String.prototype.setQuery = function(key, val) {
if(val.toString().trim()) uri = uri+"?"+key+"="+val; if(val.toString().trim()) uri = uri+"?"+key+"="+val;
} }
uri = uri.replace(/^https:\/\//i,'http://'); var re = /https:\/\/([^:\/]+)(:\d+|)/i;
var check = re.exec(uri);
if(check)
{
var toReplace = "http://"+check[1];
if(typeof(http_port)!='undefined' && http_port != 80)
{
toReplace += ":" + http_port;
}
uri = uri.replace(re,toReplace);
}
if(typeof(ssl_actions)!='undefined' && typeof(ssl_actions.length)!='undefined' && uri.getQuery('act')) { if(typeof(ssl_actions)!='undefined' && typeof(ssl_actions.length)!='undefined' && uri.getQuery('act')) {
var act = uri.getQuery('act'); var act = uri.getQuery('act');
for(i=0;i<ssl_actions.length;i++) { for(i=0;i<ssl_actions.length;i++) {
if(ssl_actions[i]==act) { if(ssl_actions[i]==act) {
uri = uri.replace(/^http:\/\//i,'https://'); var re = /http:\/\/([^:\/]+)(:\d+|)/i;
var check = re.exec(uri);
if(check)
{
var toReplace = "https://"+check[1];
if(typeof(https_port)!='undefined' && https_port != 443)
{
toReplace += ":" + https_port;
}
uri = uri.replace(re,toReplace);
}
break; break;
} }
} }

View file

@ -0,0 +1,60 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>JSSpec results</title>
<link rel="stylesheet" type="text/css" href="css/JSSpec.css" />
<script type="text/javascript" src="JSSpec/JSSpec.js"></script>
<script type="text/javascript" src="JSSpec/diff_match_patch.js"></script>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../common.js"></script>
<script type="text/javascript">// <![CDATA[
describe('SetQuery', {
'should satisfy basic uri condition' : function() {
target = "http://www.zeroboard.com/";
value_of(target.setQuery("q","r")).should_be("http://www.zeroboard.com/?q=r");
},
'should work when ssl is on' : function() {
target = "http://www.zeroboard.com/";
ssl_actions = new Array("dispLogin");
value_of(target.setQuery("act","dispLogin")).should_be("https://www.zeroboard.com/?act=dispLogin");
},
'should work when ssl is on and https_port is set (not 443)' : function() {
target = "http://www.zeroboard.com/";
https_port = 445;
ssl_actions = new Array("dispLogin");
value_of(target.setQuery("act","dispLogin")).should_be("https://www.zeroboard.com:445/?act=dispLogin");
},
'should work when ssl is on and https_port is set as 443' : function() {
target = "http://www.zeroboard.com/";
https_port = 443;
ssl_actions = new Array("dispLogin");
value_of(target.setQuery("act","dispLogin")).should_be("https://www.zeroboard.com/?act=dispLogin");
},
'should replace https to http if act is not a member of ssl_actions': function() {
targets = "https://www.zeroboard.com/";
ssl_actions = new Array("dispLogin");
value_of(targets.setQuery("act","dispLogin2")).should_be("http://www.zeroboard.com/?act=dispLogin2");
},
'should remove https port' : function() {
targetsp = "https://www.zeroboard.com:443/?q=r";
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://www.zeroboard.com/?q=r&act=dispLogin2");
},
'should remove https port and add http port if http port is defined' : function() {
targetsp = "https://www.zeroboard.com:443/?q=r";
http_port = 8000;
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://www.zeroboard.com:8000/?q=r&act=dispLogin2");
},
'should only remove https port and if http port is defined as 80' : function() {
targetsp = "https://www.zeroboard.com:443/?q=r";
http_port = 80;
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://www.zeroboard.com/?q=r&act=dispLogin2");
},
})
// ]]></script>
</head>
<body><div style="display:none;"><p>A</p><p>B</p></div></body>
</html>

View file

@ -51,6 +51,8 @@
var current_mid = "{$mid}"; var current_mid = "{$mid}";
var waiting_message = "{$lang->msg_call_server}"; var waiting_message = "{$lang->msg_call_server}";
var ssl_actions = new Array(<!--@if(count($ssl_actions))-->"{implode('","',$ssl_actions)}"<!--@end-->); var ssl_actions = new Array(<!--@if(count($ssl_actions))-->"{implode('","',$ssl_actions)}"<!--@end-->);
<!--@if($GLOBALS["_http_port"])-->var http_port = {$GLOBALS["_http_port"]};<!--@end-->
<!--@if($GLOBALS["_https_port"])-->var https_port = {$GLOBALS["_https_port"]};<!--@end-->
//]]></script> //]]></script>
{Context::getHtmlHeader()} {Context::getHtmlHeader()}

View file

@ -44,6 +44,15 @@
Context::set('use_rewrite', $db_info->use_rewrite=='Y'?'Y':'N'); Context::set('use_rewrite', $db_info->use_rewrite=='Y'?'Y':'N');
Context::set('use_optimizer', $db_info->use_optimizer!='N'?'Y':'N'); Context::set('use_optimizer', $db_info->use_optimizer!='N'?'Y':'N');
Context::set('qmail_compatibility', $db_info->qmail_compatibility=='Y'?'Y':'N'); Context::set('qmail_compatibility', $db_info->qmail_compatibility=='Y'?'Y':'N');
Context::set('use_ssl', $db_info->use_ssl?$db_info->use_ssl:"none");
if($db_info->http_port)
{
Context::set('http_port', $db_info->http_port);
}
if($db_info->https_port)
{
Context::set('https_port', $db_info->https_port);
}
Context::setBrowserTitle("XE Admin Page"); Context::setBrowserTitle("XE Admin Page");
} }
@ -205,6 +214,7 @@
**/ **/
function dispAdminConfig() { function dispAdminConfig() {
$db_info = Context::getDBInfo(); $db_info = Context::getDBInfo();
debugPrint($db_info);
Context::set('selected_lang', $db_info->lang_type); Context::set('selected_lang', $db_info->lang_type);
Context::set('lang_supported', Context::loadLangSupported()); Context::set('lang_supported', Context::loadLangSupported());

View file

@ -57,4 +57,13 @@
$lang->cmd_lang_select = "언어선택"; $lang->cmd_lang_select = "언어선택";
$lang->about_cmd_lang_select = "선택된 언어들만 서비스 됩니다"; $lang->about_cmd_lang_select = "선택된 언어들만 서비스 됩니다";
$lang->about_recompile_cache = "쓸모 없어졌거나 잘못된 캐시파일들을 정리할 수 있습니다"; $lang->about_recompile_cache = "쓸모 없어졌거나 잘못된 캐시파일들을 정리할 수 있습니다";
$lang->use_ssl = "SSL 사용";
$lang->ssl_options = array(
'none' => "사용안함",
'optional' => "선택적으로",
'always' => "항상사용"
);
$lang->about_use_ssl = "선택적으로에서는 회원가입/정보수정등의 지정된 action에서 SSL을 사용하고 항상 사용은 모든 서비스가 SSL을 이용하게 됩니다.";
$lang->server_ports = "서버포트지정";
$lang->about_server_ports = "HTTP는 80, HTTPS는 443이외의 다른 포트를 사용하는 경우에 포트를 지정해주어야합니다.";
?> ?>

View file

@ -53,6 +53,25 @@
<p>{$lang->about_qmail_compatibility}</p> <p>{$lang->about_qmail_compatibility}</p>
</td> </td>
</tr> </tr>
<tr class="row2">
<th><div>{$lang->use_ssl}</div></th>
<td>
<select name="use_ssl">
<!--@foreach($lang->ssl_options as $key => $val)-->
<option value="{$key}" <!--@if($key == $use_ssl)-->selected<!--@end--> >{$val}</option>
<!--@endforeach-->
</select>
<p>{$lang->about_use_ssl}</p>
</td>
</tr>
<tr>
<th><div>{$lang->server_ports}</div></th>
<td>
HTTP : <input type="text" name="http_port" class="inputTypeText" size="5" value="{$http_port}">,
HTTPS: <input type="text" name="https_port" class="inputTypeText" size="5" value="{$https_port}">
<p>{$lang->about_server_ports}</p>
</td>
</tr>
<tr class="row2"> <tr class="row2">
<td colspan="2" class="right"> <td colspan="2" class="right">
<span class="button"><input type="submit" value="{$lang->cmd_save}" /></span> <span class="button"><input type="submit" value="{$lang->cmd_save}" /></span>

View file

@ -56,12 +56,37 @@
$qmail_compatibility = Context::get('qmail_compatibility'); $qmail_compatibility = Context::get('qmail_compatibility');
if($qmail_compatibility!='Y') $qmail_compatibility = 'N'; if($qmail_compatibility!='Y') $qmail_compatibility = 'N';
$use_ssl = Context::get('use_ssl');
if(!$use_ssl) $use_ssl = 'none';
$http_port = Context::get('http_port');
$https_port = Context::get('https_port');
$db_info = Context::getDBInfo(); $db_info = Context::getDBInfo();
$db_info->time_zone = $time_zone; $db_info->time_zone = $time_zone;
$db_info->qmail_compatibility = $qmail_compatibility; $db_info->qmail_compatibility = $qmail_compatibility;
$db_info->use_rewrite = $use_rewrite; $db_info->use_rewrite = $use_rewrite;
$db_info->use_optimizer = $use_optimizer; $db_info->use_optimizer = $use_optimizer;
$db_info->lang_type = Context::get('lang_type'); $db_info->lang_type = Context::get('lang_type');
$db_info->use_ssl = $use_ssl;
if($http_port)
{
$db_info->http_port = (int) $http_port;
}
else if($db_info->http_port)
{
unset($db_info->http_port);
}
if($https_port)
{
$db_info->https_port = (int) $https_port;
}
else if($db_info->https_port)
{
unset($db_info->https_port);
}
Context::setDBInfo($db_info); Context::setDBInfo($db_info);
$oInstallController = &getController('install'); $oInstallController = &getController('install');

View file

@ -83,13 +83,12 @@
**/ **/
function procMemberAdminInsertConfig() { function procMemberAdminInsertConfig() {
// 기본 정보를 받음 // 기본 정보를 받음
$args = Context::gets('webmaster_name','webmaster_email','skin','colorset','enable_openid','enable_join','enable_confirm','enable_ssl','limit_day','after_login_url','after_logout_url','redirect_url','agreement','profile_image','profile_image_max_width','profile_image_max_height','image_name','image_mark', 'image_name_max_width', 'image_name_max_height','image_mark_max_width','image_mark_max_height','signature_max_height','editor_skin','editor_colorset', 'ssl_port'); $args = Context::gets('webmaster_name','webmaster_email','skin','colorset','enable_openid','enable_join','enable_confirm','limit_day','after_login_url','after_logout_url','redirect_url','agreement','profile_image','profile_image_max_width','profile_image_max_height','image_name','image_mark', 'image_name_max_width', 'image_name_max_height','image_mark_max_width','image_mark_max_height','signature_max_height','editor_skin','editor_colorset');
if(!$args->skin) $args->skin = "default"; if(!$args->skin) $args->skin = "default";
if(!$args->colorset) $args->colorset = "white"; if(!$args->colorset) $args->colorset = "white";
if(!$args->editor_skin) $args->editor_skin= "default"; if(!$args->editor_skin) $args->editor_skin= "default";
if(!$args->editor_colorset) $args->editor_colorset = "white"; if(!$args->editor_colorset) $args->editor_colorset = "white";
if($args->enable_join!='Y') $args->enable_join = 'N'; if($args->enable_join!='Y') $args->enable_join = 'N';
if($args->enable_ssl!='Y') $args->enable_ssl = 'N';
if($args->enable_openid!='Y') $args->enable_openid= 'N'; if($args->enable_openid!='Y') $args->enable_openid= 'N';
if($args->profile_image !='Y') $args->profile_image = 'N'; if($args->profile_image !='Y') $args->profile_image = 'N';
if($args->image_name!='Y') $args->image_name = 'N'; if($args->image_name!='Y') $args->image_name = 'N';

View file

@ -28,10 +28,6 @@
Context::addSSLAction('procMemberInsert'); Context::addSSLAction('procMemberInsert');
Context::addSSLAction('procMemberModifyInfo'); Context::addSSLAction('procMemberModifyInfo');
Context::addSSLAction('procMemberOpenIDLogin'); Context::addSSLAction('procMemberOpenIDLogin');
if($member_config->ssl_port)
{
Context::setSSLPort($member_config->ssl_port);
}
} }
} }

View file

@ -43,14 +43,6 @@
{$lang->about_enable_confirm} {$lang->about_enable_confirm}
</td> </td>
</tr> </tr>
<tr>
<th scope="row"><div>{$lang->enable_ssl}</div></th>
<td>
<input type="checkbox" name="enable_ssl" value="Y" <!--@if($config->enable_ssl=='Y')-->checked="checked"<!--@end--> class="checkbox" />
{$lang->about_enable_ssl} <BR />
<input type="text" name="ssl_port" value="{$config->ssl_port}" size="5" class="inputTypeText" /> {$lang->about_ssl_port}
</td>
</tr>
<tr class="row2"> <tr class="row2">
<th scope="row"><div>{$lang->limit_day}</div></th> <th scope="row"><div>{$lang->limit_day}</div></th>
<td> <td>