Refactor more URL related functions

This commit is contained in:
Kijin Sung 2016-01-20 15:53:42 +09:00
parent a8094fe766
commit 08560f84be
5 changed files with 9 additions and 15 deletions

View file

@ -1600,7 +1600,7 @@ class Context
static $url = null;
if(is_null($url))
{
$url = self::getRequestUri() . '?' . http_build_query($_GET);
$url = self::getRequestUri() . RX_REQUEST_URL;
}
return $url;
}
@ -1670,7 +1670,7 @@ class Context
$domain_info = parse_url($domain);
if(is_null($current_info))
{
$current_info = parse_url(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . getScriptPath());
$current_info = parse_url((RX_SSL ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . RX_BASEURL);
}
if($domain_info['host'] . $domain_info['path'] == $current_info['host'] . $current_info['path'])
{
@ -1678,11 +1678,7 @@ class Context
}
else
{
$domain = preg_replace('/^(http|https):\/\//i', '', trim($domain));
if(substr_compare($domain, '/', -1) !== 0)
{
$domain .= '/';
}
$domain = rtrim(preg_replace('/^(http|https):\/\//i', '', trim($domain)), '/') . '/';
}
}
@ -1808,7 +1804,7 @@ class Context
else
{
// currently on SSL but target is not based on SSL
if($_SERVER['HTTPS'] == 'on')
if(RX_SSL)
{
$query = self::getRequestUri(ENFORCE_SSL, $domain) . $query;
}

View file

@ -89,7 +89,7 @@ class ModuleHandler extends Handler
if(isset($this->act) && (strlen($this->act) >= 4 && substr_compare($this->act, 'disp', 0, 4) === 0))
{
if(Context::get('_use_ssl') == 'optional' && Context::isExistsSSLAction($this->act) && $_SERVER['HTTPS'] != 'on')
if(Context::get('_use_ssl') == 'optional' && Context::isExistsSSLAction($this->act) && RX_SSL)
{
if(Context::get('_https_port')!=null) {
header('location:https://' . $_SERVER['HTTP_HOST'] . ':' . Context::get('_https_port') . $_SERVER['REQUEST_URI']);

View file

@ -63,8 +63,7 @@ class image_link extends EditorHandler
if(substr($src, 0,2)=='./') $src = Context::getRequestUri().substr($src, 2);
else if(substr($src , 0, 1)=='/')
{
if($_SERVER['HTTPS']=='on') $http_src = 'https://';
else $http_src = 'http://';
$http_src = RX_SSL ? 'https://' : 'http://';
$src = $http_src.$_SERVER['HTTP_HOST'].$src;
}
else if(!strpos($temp_src[0],':') && $src) $src = Context::getRequestUri().$src;

View file

@ -153,7 +153,7 @@ class installView extends install
Context::set('progressMenu', '4');
$error_return_url = getNotEncodedUrl('', 'act', Context::get('act'), 'db_type', Context::get('db_type'));
if($_SERVER['HTTPS'] == 'on')
if(RX_SSL)
{
// Error occured when using https protocol at "ModuleHandler::init() '
$parsedUrl = parse_url($error_return_url);
@ -182,7 +182,7 @@ class installView extends install
include _XE_PATH_.'files/config/tmpDB.config.php';
Context::set('use_rewrite', $_SESSION['use_rewrite']);
Context::set('use_ssl', $_SERVER['HTTPS'] === 'on' ? 'always' : 'none');
Context::set('use_ssl', RX_SSL ? 'always' : 'none');
Context::set('time_zone', $GLOBALS['time_zone']);
Context::set('db_type', $db_info->db_type);
$this->setTemplateFile('admin_form');

View file

@ -157,8 +157,7 @@ class rssView extends rss
break;
}
if($_SERVER['HTTPS']=='on') $proctcl = 'https://';
else $proctcl = 'http://';
$proctcl = RX_SSL ? 'https://' : 'http://';
$temp_link = explode('/', $info->link);
if($temp_link[0]=='' && $info->link)