|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
|
3
|
|
|
/** |
|
4
|
|
|
* @class sessionModel |
|
5
|
|
|
* @author NAVER ([email protected]) |
|
6
|
|
|
* @brief The Model class of the session module |
|
7
|
|
|
*/ |
|
8
|
|
|
class sessionModel extends session |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @brief Initialization |
|
12
|
|
|
*/ |
|
13
|
|
|
function init() |
|
14
|
|
|
{ |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
function getLifeTime() |
|
18
|
|
|
{ |
|
19
|
|
|
return $this->lifetime; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
function read($session_key) |
|
23
|
|
|
{ |
|
24
|
|
|
if(!$session_key || !$this->session_started) return; |
|
25
|
|
|
|
|
26
|
|
|
$args = new stdClass(); |
|
27
|
|
|
$args->session_key = $session_key; |
|
28
|
|
|
$columnList = array('session_key', 'cur_mid', 'val'); |
|
29
|
|
|
$output = executeQuery('session.getSession', $args, $columnList); |
|
30
|
|
|
|
|
31
|
|
|
if(!$output->data) |
|
32
|
|
|
{ |
|
33
|
|
|
return ''; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
return $output->data->val; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @brief Get a list of currently connected users |
|
41
|
|
|
* Requires "object" argument because multiple arguments are expected |
|
42
|
|
|
* limit_count : the number of objects |
|
43
|
|
|
* page : the page number |
|
44
|
|
|
* period_time: "n" specifies the time range in minutes since the last update |
|
45
|
|
|
* mid: a user who belong to a specified mid |
|
46
|
|
|
*/ |
|
47
|
|
|
function getLoggedMembers($args) |
|
48
|
|
|
{ |
|
49
|
|
|
if(!$args->site_srl) |
|
50
|
|
|
{ |
|
51
|
|
|
$site_module_info = Context::get('site_module_info'); |
|
52
|
|
|
$args->site_srl = (int)$site_module_info->site_srl; |
|
53
|
|
|
} |
|
54
|
|
|
if(!$args->list_count) $args->list_count = 20; |
|
55
|
|
|
if(!$args->page) $args->page = 1; |
|
56
|
|
|
if(!$args->period_time) $args->period_time = 3; |
|
57
|
|
|
$args->last_update = date("YmdHis", $_SERVER['REQUEST_TIME'] - $args->period_time*60); |
|
58
|
|
|
|
|
59
|
|
|
$output = executeQueryArray('session.getLoggedMembers', $args); |
|
60
|
|
|
if(!$output->toBool()) return $output; |
|
61
|
|
|
|
|
62
|
|
|
$member_srls = array(); |
|
63
|
|
|
$member_keys = array(); |
|
64
|
|
|
if(count($output->data)) |
|
65
|
|
|
{ |
|
66
|
|
|
foreach($output->data as $key => $val) |
|
67
|
|
|
{ |
|
68
|
|
|
$member_srls[$key] = $val->member_srl; |
|
69
|
|
|
$member_keys[$val->member_srl] = $key; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
if(Context::get('is_logged')) |
|
74
|
|
|
{ |
|
75
|
|
|
$logged_info = Context::get('logged_info'); |
|
76
|
|
|
if(!in_array($logged_info->member_srl, $member_srls)) |
|
77
|
|
|
{ |
|
78
|
|
|
$member_srls[0] = $logged_info->member_srl; |
|
79
|
|
|
$member_keys[$logged_info->member_srl] = 0; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
if(!count($member_srls)) return $output; |
|
84
|
|
|
|
|
85
|
|
|
$member_args->member_srl = implode(',',$member_srls); |
|
|
|
|
|
|
86
|
|
|
$member_output = executeQueryArray('member.getMembers', $member_args); |
|
87
|
|
|
if($member_output->data) |
|
88
|
|
|
{ |
|
89
|
|
|
foreach($member_output->data as $key => $val) |
|
90
|
|
|
{ |
|
91
|
|
|
$output->data[$member_keys[$val->member_srl]] = $val; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
return $output; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
/* End of file session.model.php */ |
|
99
|
|
|
/* Location: ./modules/session/session.model.php */ |
|
100
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.