1
|
|
|
<?php |
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
3
|
|
|
/** |
4
|
|
|
* @class session |
5
|
|
|
* @author NAVER ([email protected]) |
6
|
|
|
* @brief session module's high class |
7
|
|
|
* @version 0.1 |
8
|
|
|
* |
9
|
|
|
* The session management class |
10
|
|
|
*/ |
11
|
|
|
class session extends ModuleObject |
12
|
|
|
{ |
13
|
|
|
var $lifetime = 18000; |
14
|
|
|
var $session_started = false; |
15
|
|
|
|
16
|
|
|
function session() |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
if(Context::isInstalled()) $this->session_started= true; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @brief Additional tasks required to accomplish during the installation |
23
|
|
|
*/ |
24
|
|
|
function moduleInstall() |
25
|
|
|
{ |
26
|
|
|
$oDB = &DB::getInstance(); |
27
|
|
|
$oDB->addIndex("session","idx_session_update_mid", array("member_srl","last_update","cur_mid")); |
28
|
|
|
|
29
|
|
|
return new Object(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @brief A method to check if the installation has been successful |
34
|
|
|
*/ |
35
|
|
View Code Duplication |
function checkUpdate() |
|
|
|
|
36
|
|
|
{ |
37
|
|
|
$oDB = &DB::getInstance(); |
38
|
|
|
$oModuleModel = getModel('module'); |
39
|
|
|
$oModuleController = getController('module'); |
40
|
|
|
$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
41
|
|
|
if($oModuleModel->needUpdate($version_update_id)) |
42
|
|
|
{ |
43
|
|
|
if(!$oDB->isTableExists('session')) return true; |
44
|
|
|
if(!$oDB->isColumnExists("session","cur_mid")) return true; |
45
|
|
|
if(!$oDB->isIndexExists("session","idx_session_update_mid")) return true; |
46
|
|
|
|
47
|
|
|
$oModuleController->insertUpdatedLog($version_update_id); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return false; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @brief Execute update |
55
|
|
|
*/ |
56
|
|
|
function moduleUpdate() |
57
|
|
|
{ |
58
|
|
|
$oDB = &DB::getInstance(); |
59
|
|
|
$oModuleModel = getModel('module'); |
60
|
|
|
$oModuleController = getController('module'); |
61
|
|
|
$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
62
|
|
|
if($oModuleModel->needUpdate($version_update_id)) |
63
|
|
|
{ |
64
|
|
|
if(!$oDB->isTableExists('session')) |
65
|
|
|
{ |
66
|
|
|
$oDB->createTableByXmlFile($this->module_path.'schemas/session.xml'); |
|
|
|
|
67
|
|
|
} |
68
|
|
|
if(!$oDB->isColumnExists("session","cur_mid")) |
69
|
|
|
{ |
70
|
|
|
$oDB->addColumn('session',"cur_mid","varchar",128); |
71
|
|
|
} |
72
|
|
|
if(!$oDB->isIndexExists("session","idx_session_update_mid")) |
73
|
|
|
{ |
74
|
|
|
$oDB->addIndex("session","idx_session_update_mid", array("member_srl","last_update","cur_mid")); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
$oModuleController->insertUpdatedLog($version_update_id); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
return new Object(0, 'success_updated'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @brief session string decode |
85
|
|
|
*/ |
86
|
|
|
function unSerializeSession($val) |
87
|
|
|
{ |
88
|
|
|
$vars = preg_split('/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff^|]*)\|/', $val,-1,PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); |
89
|
|
|
for($i=0; $vars[$i]; $i++) $result[$vars[$i++]] = unserialize($vars[$i]); |
|
|
|
|
90
|
|
|
return $result; |
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @brief session string encode |
95
|
|
|
*/ |
96
|
|
|
function serializeSession($data) |
97
|
|
|
{ |
98
|
|
|
if(!count($data)) return; |
99
|
|
|
|
100
|
|
|
$str = ''; |
101
|
|
|
foreach($data as $key => $val) $str .= $key.'|'.serialize($val); |
102
|
|
|
return substr($str, 0, strlen($str)-1).'}'; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @brief Re-generate the cache file |
107
|
|
|
*/ |
108
|
|
|
function recompileCache() |
109
|
|
|
{ |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
/* End of file session.class.php */ |
113
|
|
|
/* Location: ./modules/session/session.class.php */ |
114
|
|
|
|