issue 160, code arrange on genaral config

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9373 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
chschy 2011-09-27 10:12:00 +00:00
parent a4ab618883
commit e6c4a3bd2a
7 changed files with 26 additions and 47 deletions

View file

@ -378,9 +378,7 @@
$config = $oDocumentModel->getDocumentConfig();
Context::set('thumbnail_type',$config->thumbnail_type);
$oModuleAdminModel = &getAdminModel('module');
$IP = $oModuleAdminModel->getModuleAdminCurrentIP();
Context::set('IP',$IP);
Context::set('IP',$_SERVER['REMOTE_ADDR']);
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('module');

View file

@ -186,11 +186,7 @@
* @brief Supported languages (was procInstallAdminSaveLangSelected)
**/
function saveLangSelected($selected_lang){
/*$selected_lang = trim($selected_lang);
if(!$selected_lang) return new Object(-1,'msg_invalid_request');
$langs = explode('|@|', $selected_lang);*/
$langs = $selected_lang;
//fileter로 넘어오지 않으므로 위에 처럼 변경
$lang_supported = Context::loadLangSupported();
$buff = null;

View file

@ -35,6 +35,7 @@
<action name="getMemberMenu" type="model" standalone="true" />
<action name="getMemberAdminColorset" type="model" standalone="true" />
<action name="getMemberAdminInsertJoinForm" type="model" />
<action name="getMemberAdminIPCheck" type="model" standalone="true" />
<action name="procMemberLogin" type="controller" standalone="true" ruleset="@login" />
<action name="procMemberOpenIDLogin" type="controller" standalone="true" ruleset="openidLogin" />

View file

@ -206,5 +206,27 @@
$this->add('tpl', str_replace("\n"," ",$tpl));
}
function getMemberAdminIPCheck() {
$db_info = Context::getDBInfo();
$admin_ip_list = $db_info->admin_ip_list;
$admin_ip_list = explode(",",$admin_ip_list);
$oMemberModel = &getModel('member');
$ip = $_SERVER['REMOTE_ADDR'];
$falg = false;
foreach($admin_ip_list as $admin_ip_list_key => $admin_ip_value) {
if(preg_match('/^\d{1,3}(?:.(\d{1,3}|\*)){3}\s*$/', $admin_ip_value, $matches) && $ip) {
$admin_ip = $matches[0];
$admin_ip = str_replace('*','',$admin_ip);
$admin_ip_patterns[] = preg_quote($admin_ip);
$admin_ip_pattern = '/^('.implode($admin_ip_patterns,'|').')/';
if(preg_match($admin_ip_pattern, $ip, $matches)) return true;
$flag = true;
}
}
if(!$flag) return true;
return false;
}
}
?>

View file

@ -1478,8 +1478,8 @@
if($autologin_output->toBool()) setCookie('xeak',$autologin_args->autologin_key, time()+60*60*24*365, '/');
}
if($this->memberInfo->is_admin == 'Y') {
$oModuleAdminModel = &getAdminModel('module');
if(!$oModuleAdminModel->getModuleAdminIPCheck()) {
$oMemberAdminModel = &getAdminModel('member');
if(!$oMemberAdminModel->getMemberAdminIPCheck()) {
$_SESSION['denied_admin'] = 'Y';
}
}

View file

@ -26,12 +26,10 @@
<action name="procModuleFileBoxAdd" type="controller" standalone="true" />
<action name="procModuleFileBoxDelete" type="controller" standalone="true" />
<action name="getModuleAdminCurrentIP" type="model" standalone="true" />
<action name="getModuleAdminModuleList" type="model" standalone="true" />
<action name="getModuleAdminLangCode" type="model" standalone="true" />
<action name="getModuleAdminLangListByName" type="model" standalone="true" />
<action name="getModuleAdminLangListByValue" type="model" standalone="true" />
<action name="getModuleAdminIPCheck" type="model" standalone="true" />
<action name="getLangListByLangcodeForAutoComplete" type="model" standalone="true" />
<action name="getFileBoxListHtml" type="model" />
<action name="getLangByLangcode" type="model" />

View file

@ -257,41 +257,5 @@
return $output;
}
function getModuleAdminIPCheck() {
$db_info = Context::getDBInfo();
$admin_ip_list = $db_info->admin_ip_list;
$admin_ip_list = explode(",",$admin_ip_list);
$ip = $this->getModuleAdminCurrentIP();
$falg = false;
foreach($admin_ip_list as $admin_ip_list_key => $admin_ip_value) {
if(preg_match('/^\d{1,3}(?:.(\d{1,3}|\*)){3}\s*$/', $admin_ip_value, $matches) && $ip) {
$admin_ip = $matches[0];
$admin_ip = str_replace('*','',$admin_ip);
$admin_ip_patterns[] = preg_quote($admin_ip);
$admin_ip_pattern = '/^('.implode($admin_ip_patterns,'|').')/';
if(preg_match($admin_ip_pattern, $ip, $matches)) return true;
$flag = true;
}
}
if(!$flag) return true;
return false;
}
function getModuleAdminCurrentIP(){
if(!empty($_SERVER['HTTP_CLIENT_IP']) && getenv('HTTP_CLIENT_IP')){
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR']) && getenv('HTTP_X_FORWARDED_FOR')){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else if(!empty($_SERVER['REMOTE_HOST']) && getenv('REMOTE_HOST')){
$ip = $_SERVER['REMOTE_HOST'];
}
else if(!empty($_SERVER['REMOTE_ADDR']) && getenv('REMOTE_ADDR')){
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
}
?>