mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-26 22:02:13 +09:00
#472 세션을 파일기반이 아닌 DB기반으로 사용하도록 변경하고 접속자 출력 위젯 추가
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4290 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
474ca4df06
commit
ea2fede30e
42 changed files with 702 additions and 111 deletions
|
|
@ -793,23 +793,52 @@
|
|||
$tree[$parent_srl][$category_srl] = $node;
|
||||
}
|
||||
|
||||
// 세션 디렉토리 변경 구문
|
||||
$php_script = "";
|
||||
if(!ini_get('session.auto_start')) {
|
||||
if(!is_dir("./files/sessions")) {
|
||||
FileHandler::makeDir("./files/sessions");
|
||||
@chmod("./files/sessions", 0777);
|
||||
}
|
||||
// 캐시 파일의 권한과 그룹 설정을 위한 공통 헤더
|
||||
$header_script =
|
||||
'$lang_type = Context::getLangType(); '.
|
||||
'$is_logged = Context::get(\'is_logged\'); '.
|
||||
'$logged_info = Context::get(\'logged_info\'); '.
|
||||
'if($is_logged && $logged_info->is_admin=="Y") { '.
|
||||
'$is_admin = true; '.
|
||||
'$group_srls = array_keys($logged_info->group_list); '.
|
||||
'} else { '.
|
||||
'$is_admin = false; '.
|
||||
'$group_srsl = array(); '.
|
||||
'} ';
|
||||
|
||||
$php_script = 'session_cache_limiter("no-cache, must-revalidate"); ini_set("session.gc_maxlifetime", "18000"); if(is_dir("../../sessions")) session_save_path("../../sessions/"); session_start();';
|
||||
}
|
||||
|
||||
// xml 캐시 파일 생성
|
||||
$xml_buff = sprintf('<?php %s header("Content-Type: text/xml; charset=UTF-8"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); @session_start(); ?><root>%s</root>', $php_script, $this->getXmlTree($tree[0], $tree));
|
||||
// xml 캐시 파일 생성 (xml캐시는 따로 동작하기에 session 지정을 해주어야 함)
|
||||
$xml_buff = sprintf(
|
||||
'<?php '.
|
||||
'define(\'__ZBXE__\', true); '.
|
||||
'require_once(\'../../../config/config.inc.php\'); '.
|
||||
'$oContext = &Context::getInstance(); '.
|
||||
'$oContext->init(); '.
|
||||
'header("Content-Type: text/xml; charset=UTF-8"); '.
|
||||
'header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); '.
|
||||
'header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); '.
|
||||
'header("Cache-Control: no-store, no-cache, must-revalidate"); '.
|
||||
'header("Cache-Control: post-check=0, pre-check=0", false); '.
|
||||
'header("Pragma: no-cache"); '.
|
||||
'%s'.
|
||||
'?>'.
|
||||
'<root>%s</root>',
|
||||
$header_script,
|
||||
$this->getXmlTree($tree[0], $tree)
|
||||
);
|
||||
|
||||
// php 캐시 파일 생성
|
||||
$php_output = $this->getPhpCacheCode($tree[0], $tree, 0);
|
||||
$php_buff = sprintf('<?php if(!defined("__ZBXE__")) exit(); %s; $menu->list = array(%s); ?>', $php_output['category_title_str'], $php_output['buff']);
|
||||
$php_buff = sprintf(
|
||||
'<?php '.
|
||||
'if(!defined("__ZBXE__")) exit(); '.
|
||||
'%s; '.
|
||||
'%s; '.
|
||||
'$menu->list = array(%s); '.
|
||||
'?>',
|
||||
$header_script,
|
||||
$php_output['category_title_str'],
|
||||
$php_output['buff']
|
||||
);
|
||||
|
||||
// 파일 저장
|
||||
FileHandler::writeFile($xml_file, $xml_buff);
|
||||
|
|
@ -839,7 +868,7 @@
|
|||
$module_srl = $node->module_srl;
|
||||
|
||||
// node->group_srls값이 있으면
|
||||
if($group_srls) $group_check_code = sprintf('($_SESSION["is_admin"]==true||(is_array($_SESSION["group_srls"])&&count(array_intersect($_SESSION["group_srls"], array(%s)))))',$group_srls);
|
||||
if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
|
||||
else $group_check_code = "true";
|
||||
|
||||
$attribute = sprintf(
|
||||
|
|
@ -886,7 +915,7 @@
|
|||
$output['category_srl_list'] = array_merge($output['category_srl_list'], $child_output['category_srl_list']);
|
||||
|
||||
// node->group_srls값이 있으면
|
||||
if($node->group_srls) $group_check_code = sprintf('($_SESSION["is_admin"]==true||(is_array($_SESSION["group_srls"])&&count(array_intersect($_SESSION["group_srls"], array(%s)))))',$node->group_srls);
|
||||
if($node->group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls);
|
||||
else $group_check_code = "true";
|
||||
|
||||
// 변수 정리
|
||||
|
|
|
|||
|
|
@ -349,23 +349,52 @@
|
|||
$tree[$parent_srl][$menu_item_srl] = $node;
|
||||
}
|
||||
|
||||
// 세션 디렉토리 변경 구문
|
||||
$php_script = "";
|
||||
if(!ini_get('session.auto_start')) {
|
||||
if(!is_dir("./files/sessions")) {
|
||||
FileHandler::makeDir("./files/sessions");
|
||||
@chmod("./files/sessions", 0777);
|
||||
}
|
||||
// 캐시 파일의 권한과 그룹 설정을 위한 공통 헤더
|
||||
$header_script =
|
||||
'$lang_type = Context::getLangType(); '.
|
||||
'$is_logged = Context::get(\'is_logged\'); '.
|
||||
'$logged_info = Context::get(\'logged_info\'); '.
|
||||
'if($is_logged && $logged_info->is_admin=="Y") { '.
|
||||
'$is_admin = true; '.
|
||||
'$group_srls = array_keys($logged_info->group_list); '.
|
||||
'} else { '.
|
||||
'$is_admin = false; '.
|
||||
'$group_srsl = array(); '.
|
||||
'} ';
|
||||
|
||||
$php_script = 'session_cache_limiter("no-cache, must-revalidate"); ini_set("session.gc_maxlifetime", "18000"); if(is_dir("../../sessions")) session_save_path("../../sessions/"); session_start();';
|
||||
}
|
||||
|
||||
// xml 캐시 파일 생성
|
||||
$xml_buff = sprintf('<?php %s header("Content-Type: text/xml; charset=UTF-8"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); @session_start(); if($_SESSION["logged_info"]&&$_SESSION["logged_info"]->is_admin=="Y") $_is_admin = true; ?><root>%s</root>', $php_script, $this->getXmlTree($tree[0], $tree));
|
||||
// xml 캐시 파일 생성 (xml캐시는 따로 동작하기에 session 지정을 해주어야 함)
|
||||
$xml_buff = sprintf(
|
||||
'<?php '.
|
||||
'define(\'__ZBXE__\', true); '.
|
||||
'require_once(\'../../../config/config.inc.php\'); '.
|
||||
'$oContext = &Context::getInstance(); '.
|
||||
'$oContext->init(); '.
|
||||
'header("Content-Type: text/xml; charset=UTF-8"); '.
|
||||
'header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); '.
|
||||
'header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); '.
|
||||
'header("Cache-Control: no-store, no-cache, must-revalidate"); '.
|
||||
'header("Cache-Control: post-check=0, pre-check=0", false); '.
|
||||
'header("Pragma: no-cache"); '.
|
||||
'%s'.
|
||||
'?>'.
|
||||
'<root>%s</root>',
|
||||
$header_script,
|
||||
$this->getXmlTree($tree[0], $tree)
|
||||
);
|
||||
|
||||
// php 캐시 파일 생성
|
||||
$php_output = $this->getPhpCacheCode($tree[0], $tree);
|
||||
$php_buff = sprintf('<?php if(!defined("__ZBXE__")) exit(); if($_SESSION["logged_info"]&&$_SESSION["logged_info"]->is_admin=="Y") $_is_admin = true; $lang_type = Context::getLangType(); %s; $menu->list = array(%s); ?>', $php_output['name'], $php_output['buff']);
|
||||
$php_buff = sprintf(
|
||||
'<?php '.
|
||||
'if(!defined("__ZBXE__")) exit(); '.
|
||||
'%s; '.
|
||||
'%s; '.
|
||||
'$menu->list = array(%s); '.
|
||||
'?>',
|
||||
$header_script,
|
||||
$php_output['name'],
|
||||
$php_output['buff']
|
||||
);
|
||||
|
||||
// 파일 저장
|
||||
FileHandler::writeFile($xml_file, $xml_buff);
|
||||
|
|
@ -394,7 +423,7 @@
|
|||
foreach($names as $key => $val) {
|
||||
$name_arr_str .= sprintf('"%s"=>"%s",',$key, htmlspecialchars($val));
|
||||
}
|
||||
$name_str = sprintf('$_names = array(%s); print $_names[$_SESSION["lang_type"]];', $name_arr_str);
|
||||
$name_str = sprintf('$_names = array(%s); print $_names[$lang_type];', $name_arr_str);
|
||||
|
||||
$url = str_replace(array('&','"','<','>'),array('&','"','<','>'),$node->url);
|
||||
if(preg_match('/^([0-9a-zA-Z\_\-]+)$/', $node->url)) {
|
||||
|
|
@ -422,13 +451,13 @@
|
|||
else $classname = '';
|
||||
if($hover_btn) $hover_str = sprintf('onmouseover="this.src=\'%s\'"', $hover_btn); else $hover_str = '';
|
||||
if($active_btn) $active_str = sprintf('onmousedown="this.src=\'%s\'"', $active_btn); else $active_str = '';
|
||||
$link = sprintf('<img src="%s" onmouseout="this.src=\'%s\'" alt="<?php print htmlspecialchars($_names[$_SESSION["lang_type"]]) ?>" %s %s %s />', $normal_btn, $normal_btn, $hover_str, $active_str, $classname);
|
||||
$link = sprintf('<img src="%s" onmouseout="this.src=\'%s\'" alt="<?php print htmlspecialchars($_names[$lang_type]) ?>" %s %s %s />', $normal_btn, $normal_btn, $hover_str, $active_str, $classname);
|
||||
} else {
|
||||
$link = '<?php print $_names[$_SESSION["lang_type"]]; ?>';
|
||||
$link = '<?php print $_names[$lang_type]; ?>';
|
||||
}
|
||||
|
||||
// node->group_srls값이 있으면
|
||||
if($group_srls) $group_check_code = sprintf('($_is_admin==true||(is_array($_SESSION["group_srls"])&&count(array_intersect($_SESSION["group_srls"], array(%s)))))',$group_srls);
|
||||
if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
|
||||
else $group_check_code = "true";
|
||||
$attribute = sprintf(
|
||||
'node_srl="%s" parent_srl="%s" text="<?php if(%s) { %s }?>" url="<?php print(%s?"%s":"")?>" href="<?php print(%s?"%s":"")?>" open_window="%s" expand="%s" normal_btn="%s" hover_btn="%s" active_btn="%s" link="<?php if(%s) {?>%s<?php }?>"',
|
||||
|
|
@ -484,7 +513,7 @@
|
|||
$output['url_list'] = array_merge($output['url_list'], $child_output['url_list']);
|
||||
|
||||
// node->group_srls값이 있으면
|
||||
if($node->group_srls) $group_check_code = sprintf('($_is_admin==true||(is_array($_SESSION["group_srls"])&&count(array_intersect($_SESSION["group_srls"], array(%s)))))',$node->group_srls);
|
||||
if($node->group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls);
|
||||
else $group_check_code = "true";
|
||||
|
||||
// 변수 정리
|
||||
|
|
|
|||
11
modules/session/conf/info.xml
Normal file
11
modules/session/conf/info.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<module version="0.1" category="base">
|
||||
<title xml:lang="ko">Session관리자</title>
|
||||
<author email_address="zero@zeroboard.com" link="http://www.zeroboard.com" date="2008. 6. 18">
|
||||
<name xml:lang="ko">zero</name>
|
||||
<description xml:lang="ko">
|
||||
접속자의 session을 관리하는 모듈입니다.
|
||||
기본적인 세션 설정과 사용뿐 아니라 세션 정보를 이용하여 접속자등의 세션 기반의 정보를 제공하는 기능도 있습니다.
|
||||
</description>
|
||||
</author>
|
||||
</module>
|
||||
9
modules/session/conf/module.xml
Normal file
9
modules/session/conf/module.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<module>
|
||||
<grants />
|
||||
<permissions />
|
||||
<actions>
|
||||
<action name="dispSessionAdminIndex" type="view" standalone="true" admin_index="true" />
|
||||
<action name="procSessionAdminClear" type="controller" standalone="true" />
|
||||
</actions>
|
||||
</module>
|
||||
13
modules/session/lang/ko.lang.php
Normal file
13
modules/session/lang/ko.lang.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @file modules/session/lang/ko.lang.php
|
||||
* @author zero <zero@nzeo.com>
|
||||
* @brief 한국어 언어팩 (기본적인 내용만 수록)
|
||||
**/
|
||||
|
||||
$lang->session = '세션';
|
||||
$lang->about_session = "세션 관리를 하는 모듈입니다\n틈틈히 세션 정리를 하시면 사이트 운영시 보다 좋은 효과를 낼 수 있습니다.";
|
||||
|
||||
$lang->cmd_clear_session = '세션 정리';
|
||||
$lang->session_cleared = '쓸모 없는 세션 정보가 정리되었습니다';
|
||||
?>
|
||||
8
modules/session/queries/deleteSession.xml
Normal file
8
modules/session/queries/deleteSession.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<query id="deleteSession" action="delete">
|
||||
<tables>
|
||||
<table name="session" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="session_key" var="session_key" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
8
modules/session/queries/gcSession.xml
Normal file
8
modules/session/queries/gcSession.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<query id="gcSession" action="delete">
|
||||
<tables>
|
||||
<table name="session" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="less" column="expired" default="curdate()" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
19
modules/session/queries/getLoggedMembers.xml
Normal file
19
modules/session/queries/getLoggedMembers.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<query id="getLoggedMembers" action="select">
|
||||
<tables>
|
||||
<table name="session" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="member_srl" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="more" column="last_update" var="last_update" notnull="notnull" />
|
||||
</conditions>
|
||||
<navigation>
|
||||
<list_count var="list_count" default="20" />
|
||||
<page_count var="page_count" default="10" />
|
||||
<page var="page" default="1" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="member_srl" />
|
||||
</groups>
|
||||
</query>
|
||||
14
modules/session/queries/getLoogedMemberList.xml
Normal file
14
modules/session/queries/getLoogedMemberList.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<query id="getLoggedMembers" action="select">
|
||||
<tables>
|
||||
<table name="session" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="member_srl" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="more" column="last_update" var="last_update" notnull="notnull" />
|
||||
</conditions>
|
||||
<groups>
|
||||
<group column="member_srl" />
|
||||
</groups>
|
||||
</query>
|
||||
11
modules/session/queries/getSession.xml
Normal file
11
modules/session/queries/getSession.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<query id="getSession" action="select">
|
||||
<tables>
|
||||
<table name="session" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="session_key" var="session_key" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
13
modules/session/queries/insertSession.xml
Normal file
13
modules/session/queries/insertSession.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<query id="insertSession" action="insert">
|
||||
<tables>
|
||||
<table name="session" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="session_key" var="session_key" notnull="notnull" />
|
||||
<column name="member_srl" var="member_srl" filter="number" default="0" />
|
||||
<column name="expired" var="expired" />
|
||||
<column name="val" var="val" />
|
||||
<column name="ipaddress" default="ipaddress()" />
|
||||
<column name="last_update" default="curdate()" />
|
||||
</columns>
|
||||
</query>
|
||||
15
modules/session/queries/updateSession.xml
Normal file
15
modules/session/queries/updateSession.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<query id="updateSession" action="update">
|
||||
<tables>
|
||||
<table name="session" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="member_srl" var="member_srl" filter="number" default="0" />
|
||||
<column name="expired" var="expired" />
|
||||
<column name="val" var="val" notnull="notnull" />
|
||||
<column name="ipaddress" default="ipaddress()" />
|
||||
<column name="last_update" default="curdate()" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="session_key" var="session_key" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
8
modules/session/schemas/session.xml
Normal file
8
modules/session/schemas/session.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<table name="session">
|
||||
<column name="session_key" type="varchar" size="255" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="member_srl" type="number" size="11" notnull="notnull" index="idx_session_member_srl" />
|
||||
<column name="expired" type="date" index="idx_session_expired" />
|
||||
<column name="val" type="bigtext" />
|
||||
<column name="ipaddress" type="varchar" size="128" notnull="notnull" />
|
||||
<column name="last_update" type="date" index="idx_session_update" />
|
||||
</table>
|
||||
26
modules/session/session.admin.controller.php
Normal file
26
modules/session/session.admin.controller.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @class sessionAdminController
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief session 모듈의 admin controller class
|
||||
**/
|
||||
|
||||
class sessionAdminController extends session {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 더비 세션 정리하는 action
|
||||
**/
|
||||
function procSessionAdminClear() {
|
||||
$oSessionController = &getController('session');
|
||||
$oSessionController->gc(0);
|
||||
|
||||
$this->add('result',Context::getLang('session_cleared'));
|
||||
}
|
||||
}
|
||||
?>
|
||||
26
modules/session/session.admin.view.php
Normal file
26
modules/session/session.admin.view.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @class sessionAdminView
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief session모듈의 admin view class
|
||||
**/
|
||||
|
||||
class sessionAdminView extends session {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 설정
|
||||
**/
|
||||
function dispSessionAdminIndex() {
|
||||
// 템플릿 파일 지정
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
$this->setTemplateFile('index');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
87
modules/session/session.class.php
Normal file
87
modules/session/session.class.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/**
|
||||
* @class session
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief session 모듈의 high class
|
||||
* @version 0.1
|
||||
*
|
||||
* session 관리를 하는 class
|
||||
**/
|
||||
|
||||
class session extends ModuleObject {
|
||||
|
||||
var $lifetime = 18000;
|
||||
var $session_started = false;
|
||||
|
||||
function session() {
|
||||
if(Context::isInstalled()) $this->session_started= true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 설치시 추가 작업이 필요할시 구현
|
||||
**/
|
||||
function moduleInstall() {
|
||||
// action forward에 등록 (관리자 모드에서 사용하기 위함)
|
||||
$oModuleController = &getController('module');
|
||||
$oModuleController->insertActionForward('session', 'view', 'dispSessionAdminIndex');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 설치가 이상이 없는지 체크하는 method
|
||||
**/
|
||||
function checkUpdate() {
|
||||
$oDB = &DB::getInstance();
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
if(!$oModuleModel->getActionForward('dispSessionAdminIndex')) return true;
|
||||
|
||||
if(!$oDB->isTableExists('session')) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 업데이트 실행
|
||||
**/
|
||||
function moduleUpdate() {
|
||||
$oDB = &DB::getInstance();
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleController = &getController('module');
|
||||
|
||||
if(!$oDB->isTableExists('session')) $oDB->createTableByXmlFile($this->module_path.'schemas/session.xml');
|
||||
|
||||
if(!$oModuleModel->getActionForward('dispSessionAdminIndex'))
|
||||
$oModuleController->insertActionForward('document', 'view', 'dispSessionAdminIndex');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief session string decode
|
||||
**/
|
||||
function unSerializeSession($val) {
|
||||
$vars = preg_split('/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff^|]*)\|/', $val,-1,PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
||||
for($i=0; $vars[$i]; $i++) $result[$vars[$i++]] = unserialize($vars[$i]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief session string encode
|
||||
**/
|
||||
function serializeSession($data) {
|
||||
if(!count($data)) return;
|
||||
|
||||
$str = '';
|
||||
foreach($data as $key => $val) $str .= $key.'|'.serialize($val);
|
||||
return substr($str, 0, strlen($str)-1).'}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 캐시 파일 재생성
|
||||
**/
|
||||
function recompileCache() {
|
||||
// 기존 파일 기반의 세션 삭제
|
||||
FileHandler::removeDir(_XE_PATH_."files/sessions");
|
||||
}
|
||||
}
|
||||
?>
|
||||
65
modules/session/session.controller.php
Normal file
65
modules/session/session.controller.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* @class sessionController
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief session 모듈의 controller class
|
||||
**/
|
||||
|
||||
class sessionController extends session {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
function open() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function close() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function write($session_key, $val) {
|
||||
if(!$session_key || !$this->session_started) return;
|
||||
|
||||
$args->session_key = $session_key;
|
||||
$output = executeQuery('session.getSession', $args);
|
||||
$session_info = $output->data;
|
||||
if($session_info->session_key == $session_key && $session_info->ipaddress != $_SERVER['REMOTE_ADDR']) {
|
||||
executeQuery('session.deleteSession', $args);
|
||||
return true;
|
||||
}
|
||||
|
||||
$args->expired = date("YmdHis", time()+$this->lifetime);
|
||||
$args->val = $val;
|
||||
|
||||
if(Context::get('is_logged')) {
|
||||
$logged_info = Context::get('logged_info');
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
} else {
|
||||
$args->member_srl = 0;
|
||||
}
|
||||
|
||||
if($session_info->session_key) $output = executeQuery('session.updateSession', $args);
|
||||
else $output = executeQuery('session.insertSession', $args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function destroy($session_key) {
|
||||
if(!$session_key || !$this->session_started) return;
|
||||
|
||||
$args->session_key = $session_key;
|
||||
executeQuery('session.deleteSession', $args);
|
||||
return true;
|
||||
}
|
||||
|
||||
function gc($maxlifetime) {
|
||||
if(!$this->session_started) return;
|
||||
executeQuery('session.gcSession');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
63
modules/session/session.model.php
Normal file
63
modules/session/session.model.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* @class sessionModel
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief session 모듈의 Model class
|
||||
**/
|
||||
|
||||
class sessionModel extends session {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
function getLifeTime() {
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
function read($session_key) {
|
||||
if(!$session_key || !$this->session_started) return;
|
||||
|
||||
$args->session_key = $session_key;
|
||||
$output = executeQuery('session.getSession', $args);
|
||||
|
||||
// 읽기 오류 발생시 테이블 생성 유무 확인
|
||||
if(!$output->toBool()) {
|
||||
$oDB = &DB::getInstance();
|
||||
if(!$oDB->isTableExists('session')) $oDB->createTableByXmlFile($this->module_path.'schemas/session.xml');
|
||||
}
|
||||
|
||||
return $output->data->val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 현재 접속중인 사용자의 목록을 구함
|
||||
* period_time 인자의 값을 n으로 하여 최근 n분 이내에 세션을 갱신한 대상을 추출함
|
||||
**/
|
||||
function getLoggedMembers($limit_count = 20, $page = 1, $period_time = 3) {
|
||||
$args->last_update = date("YmdHis", time() - $period_time*60);
|
||||
$args->page = $page;
|
||||
|
||||
$output = executeQueryArray('session.getLoggedMembers', $args);
|
||||
if(!$output->toBool() || !$output->data) return $output;
|
||||
|
||||
$member_srls = array();
|
||||
foreach($output->data as $key => $val) {
|
||||
$member_srls[$key] = $val->member_srl;
|
||||
$member_keys[$val->member_srl] = $key;
|
||||
}
|
||||
|
||||
$member_args->member_srl = implode(',',$member_srls);
|
||||
$member_output = executeQueryArray('member.getMembers', $member_args);
|
||||
if($member_output->data) {
|
||||
foreach($member_output->data as $key => $val) {
|
||||
$output->data[$member_keys[$val->member_srl]] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
?>
|
||||
8
modules/session/tpl/index.html
Normal file
8
modules/session/tpl/index.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<!--%import("js/session.js",optimized=false)-->
|
||||
|
||||
<h3>{$lang->session} <span class="gray">{$lang->cmd_management}</span></h3>
|
||||
<div class="infoText">{nl2br($lang->about_session)}</div>
|
||||
|
||||
<form action="./" method="post" onsubmit="return false;">
|
||||
<span class="button"><input type="button" value="{$lang->cmd_clear_session}" onclick="doClearSession(); return false; "/></span>
|
||||
</form>
|
||||
9
modules/session/tpl/js/session.js
Normal file
9
modules/session/tpl/js/session.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
function doClearSession() {
|
||||
var response_tags = new Array('error','message','result');
|
||||
var params = new Array();
|
||||
exec_xml('session','procSessionAdminClear', params, completeClearSession, response_tags);
|
||||
}
|
||||
|
||||
function completeClearSession(ret_obj, response_tags) {
|
||||
alert(ret_obj['result']);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue