merge from 1.7.3.5(r13153:r13167)

git-svn-id: http://xe-core.googlecode.com/svn/trunk@13168 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ngleader 2013-09-29 23:32:39 +00:00
parent cc47d2b247
commit 2d3f149b5a
2042 changed files with 129266 additions and 126243 deletions

View file

@ -8,7 +8,7 @@
<title xml:lang="zh-TW">SESSION管理</title>
<title xml:lang="tr">Oturum</title>
<description xml:lang="ko">
접속자의 세션을 관리하는 모듈입니다.
접속자의 세션을 관리니다.
기본적인 세션 설정과 사용뿐 아니라 세션 정보를 이용하여 접속자등의 세션 기반의 정보를 제공하는 기능도 있습니다.
</description>
<description xml:lang="jp">

View file

@ -9,22 +9,14 @@
<value xml:lang="tr"><![CDATA[Oturum]]></value>
</item>
<item name="about_session">
<value xml:lang="ko"><![CDATA[세션 관리를 하는 모듈입니다.
틈틈이 세션 정리를 하시면 사이트 운영에 보다 좋은 효과를 낼 수 있습니다.]]></value>
<value xml:lang="en"><![CDATA[This module manages sessions.
Frequent session arrangement will provide a better environment for your site.]]></value>
<value xml:lang="jp"><![CDATA[セッションを管理するモジュールです。
定期的なセッションの整理はサイトのパフォーマンスに効果的です。]]></value>
<value xml:lang="zh-CN"><![CDATA[管理会话的模块。
有时间清理无用会话,可提高网站效率。]]></value>
<value xml:lang="zh-TW"><![CDATA[管理SESSION的模組。
請定時清理SESSION可提高網站效率。]]></value>
<value xml:lang="fr"><![CDATA[Ce module administre les sessions
L'arrangement fréquent des sessions pourvoira de meilleur environnement pour votre site Web.]]></value>
<value xml:lang="tr"><![CDATA[Bu modül oturumları yönetir
Alışılmış oturum düzenlemesi, sitenize daha iyi bir ortam sağlayacaktır.]]></value>
<value xml:lang="vi"><![CDATA[Module này quản lý những Session
Thường xuyên xắp xếp Session sẽ giúp Website của bạn hoạt động ổn định và nhanh hơn.]]></value>
<value xml:lang="ko"><![CDATA[세션을 관리합니다. 틈틈이 세션 정리를 하면 사이트 운영에 보다 좋은 효과를 낼 수 있습니다.]]></value>
<value xml:lang="en"><![CDATA[This module manages sessions. Frequent session arrangement will provide a better environment for your site.]]></value>
<value xml:lang="jp"><![CDATA[セッションを管理するモジュールです。定期的なセッションの整理はサイトのパフォーマンスに効果的です。]]></value>
<value xml:lang="zh-CN"><![CDATA[管理会话的模块。有时间清理无用会话,可提高网站效率。]]></value>
<value xml:lang="zh-TW"><![CDATA[管理SESSION的模組。請定時清理SESSION可提高網站效率。]]></value>
<value xml:lang="fr"><![CDATA[Ce module administre les sessions. L'arrangement fréquent des sessions pourvoira de meilleur environnement pour votre site Web.]]></value>
<value xml:lang="tr"><![CDATA[Bu modül oturumları yönetir. Alışılmış oturum düzenlemesi, sitenize daha iyi bir ortam sağlayacaktır.]]></value>
<value xml:lang="vi"><![CDATA[Module này quản lý những Session. Thường xuyên xắp xếp Session sẽ giúp Website của bạn hoạt động ổn định và nhanh hơn.]]></value>
</item>
<item name="cmd_clear_session">
<value xml:lang="ko"><![CDATA[세션 정리]]></value>

View file

@ -1,26 +1,28 @@
<?php
/**
* @class sessionAdminController
* @author NHN (developers@xpressengine.com)
* @brief The admin controller class of the session module
**/
/**
* @class sessionAdminController
* @author NHN (developers@xpressengine.com)
* @brief The admin controller class of the session module
*/
class sessionAdminController extends session
{
/**
* @brief Initialization
*/
function init()
{
}
class sessionAdminController extends session {
/**
* @brief The action to clean up the Derby session
*/
function procSessionAdminClear()
{
$oSessionController = &getController('session');
$oSessionController->gc(0);
/**
* @brief Initialization
**/
function init() {
}
/**
* @brief The action to clean up the Derby session
**/
function procSessionAdminClear() {
$oSessionController = &getController('session');
$oSessionController->gc(0);
$this->add('result',Context::getLang('session_cleared'));
}
}
?>
$this->add('result',Context::getLang('session_cleared'));
}
}
/* End of file session.admin.controller.php */
/* Location: ./modules/session/session.admin.controller.php */

View file

@ -1,26 +1,27 @@
<?php
/**
* @class sessionAdminView
* @author NHN (developers@xpressengine.com)
* @brief The admin view class of the session module
**/
/**
* @class sessionAdminView
* @author NHN (developers@xpressengine.com)
* @brief The admin view class of the session module
*/
class sessionAdminView extends session
{
/**
* @brief Initialization
*/
function init()
{
}
class sessionAdminView extends session {
/**
* @brief Initialization
**/
function init() {
}
/**
* @brief Configure
**/
function dispSessionAdminIndex() {
// Set the template file
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('index');
}
}
?>
/**
* @brief Configure
*/
function dispSessionAdminIndex()
{
// Set the template file
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('index');
}
}
/* End of file session.admin.view.php */
/* Location: ./modules/session/session.admin.view.php */

View file

@ -1,81 +1,88 @@
<?php
/**
* @class session
* @author NHN (developers@xpressengine.com)
* @brief session module's high class
* @version 0.1
*
* The session management class
**/
/**
* @class session
* @author NHN (developers@xpressengine.com)
* @brief session module's high class
* @version 0.1
*
* The session management class
*/
class session extends ModuleObject
{
var $lifetime = 18000;
var $session_started = false;
class session extends ModuleObject {
function session()
{
if(Context::isInstalled()) $this->session_started= true;
}
var $lifetime = 18000;
var $session_started = false;
/**
* @brief Additional tasks required to accomplish during the installation
*/
function moduleInstall()
{
$oDB = &DB::getInstance();
$oDB->addIndex("session","idx_session_update_mid", array("member_srl","last_update","cur_mid"));
function session() {
if(Context::isInstalled()) $this->session_started= true;
}
return new Object();
}
/**
* @brief Additional tasks required to accomplish during the installation
**/
function moduleInstall() {
$oDB = &DB::getInstance();
$oDB->addIndex("session","idx_session_update_mid", array("member_srl","last_update","cur_mid"));
/**
* @brief A method to check if the installation has been successful
*/
function checkUpdate()
{
$oDB = &DB::getInstance();
if(!$oDB->isTableExists('session')) return true;
if(!$oDB->isColumnExists("session","cur_mid")) return true;
if(!$oDB->isIndexExists("session","idx_session_update_mid")) return true;
return false;
}
return new Object();
}
/**
* @brief Execute update
*/
function moduleUpdate()
{
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
/**
* @brief A method to check if the installation has been successful
**/
function checkUpdate() {
$oDB = &DB::getInstance();
if(!$oDB->isTableExists('session')) return true;
if(!$oDB->isColumnExists("session","cur_mid")) return true;
if(!$oDB->isIndexExists("session","idx_session_update_mid")) return true;
return false;
}
if(!$oDB->isTableExists('session')) $oDB->createTableByXmlFile($this->module_path.'schemas/session.xml');
/**
* @brief Execute update
**/
function moduleUpdate() {
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
if(!$oDB->isTableExists('session')) $oDB->createTableByXmlFile($this->module_path.'schemas/session.xml');
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
if(!$oDB->isIndexExists("session","idx_session_update_mid")) $oDB->addIndex("session","idx_session_update_mid", array("member_srl","last_update","cur_mid"));
}
if(!$oDB->isIndexExists("session","idx_session_update_mid")) $oDB->addIndex("session","idx_session_update_mid", array("member_srl","last_update","cur_mid"));
}
/**
* @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 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;
/**
* @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).'}';
}
$str = '';
foreach($data as $key => $val) $str .= $key.'|'.serialize($val);
return substr($str, 0, strlen($str)-1).'}';
}
/**
* @brief Re-generate the cache file
**/
function recompileCache() {
}
}
?>
/**
* @brief Re-generate the cache file
*/
function recompileCache()
{
}
}
/* End of file session.class.php */
/* Location: ./modules/session/session.class.php */

View file

@ -1,128 +1,140 @@
<?php
/**
* @class sessionController
* @author NHN (developers@xpressengine.com)
* @brief The controller class of the session module
**/
/**
* @class sessionController
* @author NHN (developers@xpressengine.com)
* @brief The controller class of the session module
*/
class sessionController extends session
{
/**
* @brief Initialization
*/
function init()
{
}
class sessionController extends session {
function open()
{
return true;
}
/**
* @brief Initialization
**/
function init() {
}
function close()
{
return true;
}
function open() {
return true;
}
function write($session_key, $val)
{
if(!$session_key || !$this->session_started) return;
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$cache_vars = $oCacheHandler->get($cache_key);
}
function close() {
return true;
}
$args = new stdClass();
$args->session_key = $session_key;
if($cache_vars) $session_info = $cache_vars;
else
{
$output = executeQuery('session.getSession', $args);
$session_info = $output->data;
}
//if ip has changed delete the session from cache and db
if($session_info->session_key == $session_key && $session_info->ipaddress != $_SERVER['REMOTE_ADDR'])
{
if($oCacheHandler->isSupport()) $oCacheHandler->delete($cache_key);
executeQuery('session.deleteSession', $args);
return true;
}
function write($session_key, $val) {
if(!$session_key || !$this->session_started) return;
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport()) {
$cache_key = 'object:'.$session_key;
$cache_vars = $oCacheHandler->get($cache_key);
}
$args->session_key = $session_key;
if($cache_vars) $session_info = $cache_vars;
else {
$output = executeQuery('session.getSession', $args);
$session_info = $output->data;
}
//if ip has changed delete the session from cache and db
if($session_info->session_key == $session_key && $session_info->ipaddress != $_SERVER['REMOTE_ADDR']) {
if($oCacheHandler->isSupport()) $oCacheHandler->delete($cache_key);
executeQuery('session.deleteSession', $args);
return true;
}
$args->expired = date("YmdHis", time()+$this->lifetime);
$args->val = $val;
$args->cur_mid = Context::get('mid');
if(!$args->cur_mid)
{
$module_info = Context::get('current_module_info');
$args->cur_mid = $module_info->mid;
}
$args->expired = date("YmdHis", time()+$this->lifetime);
$args->val = $val;
$args->cur_mid = Context::get('mid');
if(!$args->cur_mid) {
$module_info = Context::get('current_module_info');
$args->cur_mid = $module_info->mid;
}
if(Context::get('is_logged'))
{
$logged_info = Context::get('logged_info');
$args->member_srl = $logged_info->member_srl;
}
else
{
$args->member_srl = 0;
}
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
$args->last_update = date("YmdHis", time());
$diff = $args->last_update - $cache_vars->last_update;
//verify if session values have changed
if($val == $cache_vars->val)
{
// if more than 5 minutes passed than modify the db session also
if($diff > 300)
{
//put session into cache
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$oCacheHandler->put($cache_key,$args,$this->lifetime);
}
//put session into db
if($session_info->session_key) $output = executeQuery('session.updateSession', $args);
}
else
{
//put session into cache
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$oCacheHandler->put($cache_key,$args,$this->lifetime);
}
}
}
else
{
//put session into cache
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$oCacheHandler->put($cache_key,$args,$this->lifetime);
}
//put session into db
if($session_info->session_key) $output = executeQuery('session.updateSession', $args);
else $output = executeQuery('session.insertSession', $args);
}
if(Context::get('is_logged')) {
$logged_info = Context::get('logged_info');
$args->member_srl = $logged_info->member_srl;
} else {
$args->member_srl = 0;
}
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
$args->last_update = date("YmdHis", time());
$diff = $args->last_update - $cache_vars->last_update;
//verify if session values have changed
if($val == $cache_vars->val){
// if more than 5 minutes passed than modify the db session also
if($diff > 300){
//put session into cache
if($oCacheHandler->isSupport()) {
$cache_key = 'object:'.$session_key;
$oCacheHandler->put($cache_key,$args);
}
//put session into db
if($session_info->session_key) $output = executeQuery('session.updateSession', $args);
}
else {
//put session into cache
if($oCacheHandler->isSupport()) {
$cache_key = 'object:'.$session_key;
$oCacheHandler->put($cache_key,$args);
}
}
}
else {
//put session into cache
if($oCacheHandler->isSupport()) {
$cache_key = 'object:'.$session_key;
$oCacheHandler->put($cache_key,$args);
}
//put session into db
if($session_info->session_key) $output = executeQuery('session.updateSession', $args);
else $output = executeQuery('session.insertSession', $args);
}
return true;
}
return true;
}
function destroy($session_key) {
if(!$session_key || !$this->session_started) return;
//remove session from cache
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport()) {
$cache_key = 'object:'.$session_key;
$oCacheHandler->delete($cache_key);
}
//remove session from db
$args->session_key = $session_key;
executeQuery('session.deleteSession', $args);
return true;
}
function destroy($session_key)
{
if(!$session_key || !$this->session_started) return;
//remove session from cache
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$oCacheHandler->delete($cache_key);
}
//remove session from db
$args = new stdClass();
$args->session_key = $session_key;
executeQuery('session.deleteSession', $args);
return true;
}
function gc($maxlifetime) {
if(!$this->session_started) return;
$expired_sessions = executeQueryArray('session.getExpiredSessions');
if($expired_session){
foreach ($expired_sessions as $session_key){
//remove session from cache
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport()) {
$cache_key = 'object:'.$session_key;
$oCacheHandler->delete($cache_key);
}
}
}
executeQuery('session.gcSession');
return true;
}
}
?>
function gc($maxlifetime)
{
if(!$this->session_started) return;
executeQuery('session.gcSession');
return true;
}
}
/* End of file session.controller.php */
/* Location: ./modules/session/session.controller.php */

View file

@ -1,100 +1,114 @@
<?php
/**
* @class sessionModel
* @author NHN (developers@xpressengine.com)
* @brief The Model class of the session module
**/
/**
* @class sessionModel
* @author NHN (developers@xpressengine.com)
* @brief The Model class of the session module
*/
class sessionModel extends session
{
/**
* @brief Initialization
*/
function init()
{
}
class sessionModel extends session {
function getLifeTime()
{
return $this->lifetime;
}
/**
* @brief Initialization
**/
function init() {
}
function read($session_key)
{
if(!$session_key || !$this->session_started) return;
function getLifeTime() {
return $this->lifetime;
}
function read($session_key) {
if(!$session_key || !$this->session_started) return;
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport()){
$cache_key = 'object:'.$session_key;
$output->data = $oCacheHandler->get($cache_key);
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$output->data = $oCacheHandler->get($cache_key);
}
if(!$output->data)
{
$args = new stdClass();
$args->session_key = $session_key;
$columnList = array('session_key', 'cur_mid', 'val');
$output = executeQuery('session.getSession', $args, $columnList);
// Confirm there is a table created if read error occurs
if(!$output->toBool())
{
$oDB = &DB::getInstance();
if(!$oDB->isTableExists('session')) $oDB->createTableByXmlFile($this->module_path.'schemas/session.xml');
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
$output = executeQuery('session.getSession', $args);
}
if(!$output->data) {
$args->session_key = $session_key;
$columnList = array('session_key', 'cur_mid', 'val');
$output = executeQuery('session.getSession', $args, $columnList);
// Confirm there is a table created if read error occurs
if(!$output->toBool()) {
$oDB = &DB::getInstance();
if(!$oDB->isTableExists('session')) $oDB->createTableByXmlFile($this->module_path.'schemas/session.xml');
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
$output = executeQuery('session.getSession', $args);
}
// Check if there is a table created in case there is no "cur_mid" value in the sessions information
if(!isset($output->data->cur_mid)) {
$oDB = &DB::getInstance();
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
}
// Check if there is a table created in case there is no "cur_mid" value in the sessions information
if(!isset($output->data->cur_mid))
{
$oDB = &DB::getInstance();
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
}
return $output->data->val;
}
}
return $output->data->val;
}
/**
* @brief Get a list of currently connected users
* Requires "object" argument because multiple arguments are expected
* limit_count : the number of objects
* page : the page number
* period_time: "n" specifies the time range in minutes since the last update
* mid: a user who belong to a specified mid
**/
function getLoggedMembers($args) {
if(!$args->site_srl) {
$site_module_info = Context::get('site_module_info');
$args->site_srl = (int)$site_module_info->site_srl;
}
if(!$args->list_count) $args->list_count = 20;
if(!$args->page) $args->page = 1;
if(!$args->period_time) $args->period_time = 3;
$args->last_update = date("YmdHis", time() - $args->period_time*60);
/**
* @brief Get a list of currently connected users
* Requires "object" argument because multiple arguments are expected
* limit_count : the number of objects
* page : the page number
* period_time: "n" specifies the time range in minutes since the last update
* mid: a user who belong to a specified mid
*/
function getLoggedMembers($args)
{
if(!$args->site_srl)
{
$site_module_info = Context::get('site_module_info');
$args->site_srl = (int)$site_module_info->site_srl;
}
if(!$args->list_count) $args->list_count = 20;
if(!$args->page) $args->page = 1;
if(!$args->period_time) $args->period_time = 3;
$args->last_update = date("YmdHis", time() - $args->period_time*60);
$output = executeQueryArray('session.getLoggedMembers', $args);
if(!$output->toBool()) return $output;
$output = executeQueryArray('session.getLoggedMembers', $args);
if(!$output->toBool()) return $output;
$member_srls = array();
if(count($output->data)) {
foreach($output->data as $key => $val) {
$member_srls[$key] = $val->member_srl;
$member_keys[$val->member_srl] = $key;
}
}
$member_srls = array();
if(count($output->data))
{
foreach($output->data as $key => $val)
{
$member_srls[$key] = $val->member_srl;
$member_keys[$val->member_srl] = $key;
}
}
if(Context::get('is_logged')) {
$logged_info = Context::get('logged_info');
if(!in_array($logged_info->member_srl, $member_srls)) {
$member_srls[0] = $logged_info->member_srl;
$member_keys[$logged_info->member_srl] = 0;
}
}
if(Context::get('is_logged'))
{
$logged_info = Context::get('logged_info');
if(!in_array($logged_info->member_srl, $member_srls))
{
$member_srls[0] = $logged_info->member_srl;
$member_keys[$logged_info->member_srl] = 0;
}
}
if(!count($member_srls)) return $output;
if(!count($member_srls)) return $output;
$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;
}
}
$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;
}
}
?>
return $output;
}
}
/* End of file session.model.php */
/* Location: ./modules/session/session.model.php */

View file

@ -1,8 +1,10 @@
<load target="js/session.js" usecdn="true" />
<h3 class="xeAdmin">{$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;">
<div class="fr"><span class="button black strong"><input type="button" value="{$lang->cmd_clear_session}" onclick="doClearSession(); return false; "/></span></div>
<div class="x_page-header">
<h1>{$lang->session} {$lang->cmd_management}</h1>
</div>
<section class="section">
<form action="./" method="post" onsubmit="return false">
<p>{nl2br($lang->about_session)}</p>
<button class="x_btn x_btn-warning" type="button" onclick="doClearSession(); return false;">{$lang->cmd_clear_session}</button>
</form>
</section>

View file

@ -3,7 +3,6 @@ function doClearSession() {
var response_tags = new Array('error','message','result');
var params = new Array();
exec_xml('session','procSessionAdminClear', params, completeClearSession, response_tags);
showWaitingFogLayer();
}
function completeClearSession(ret_obj, response_tags) {