rhymix/modules/session/session.class.php
Kijin Sung 84e5542d77 Remove unnecessary use of BaseObject
- 트리거 등 반환값이 필요하지 않은 곳에서 new BaseObject()를 반환하는 것 삭제
- 모듈 설치, 업데이트 후 무의미한 new BaseObject()를 반환하는 것 삭제
- 사용자에게 에러 메시지를 돌려주는 용도로 new BaseObject(-1, '에러메시지')를
  사용하는 경우는 대부분 $this->setError()로 변경함. 언어 변환과 sprintf()
  처리까지 한 번에 이루어지므로 이쪽이 더 편리함.
2017-12-01 00:54:51 +09:00

87 lines
2.2 KiB
PHP

<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* @class session
* @author NAVER (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;
function __construct()
{
if(Context::isInstalled()) $this->session_started= true;
}
/**
* @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;
}
/**
* @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->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 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 Re-generate the cache file
*/
function recompileCache()
{
}
}
/* End of file session.class.php */
/* Location: ./modules/session/session.class.php */