1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - Administration * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * This file written by Joseph Engo <jengo@phpgroupware.org> * |
---|
6 | * -------------------------------------------- * |
---|
7 | * This program is free software; you can redistribute it and/or modify it * |
---|
8 | * under the terms of the GNU General Public License as published by the * |
---|
9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
10 | * option) any later version. * |
---|
11 | \**************************************************************************/ |
---|
12 | |
---|
13 | |
---|
14 | class uicurrentsessions |
---|
15 | { |
---|
16 | var $template; |
---|
17 | var $bo; |
---|
18 | var $public_functions = array( |
---|
19 | 'list_sessions' => True, |
---|
20 | 'kill' => True |
---|
21 | ); |
---|
22 | |
---|
23 | function uicurrentsessions() |
---|
24 | { |
---|
25 | if ($GLOBALS['phpgw']->acl->check('current_sessions_access',1,'admin')) |
---|
26 | { |
---|
27 | $GLOBALS['phpgw']->redirect_link('/index.php'); |
---|
28 | } |
---|
29 | $this->template = createobject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
30 | $this->bo = createobject('admin.bocurrentsessions'); |
---|
31 | $this->nextmatchs = createobject('phpgwapi.nextmatchs'); |
---|
32 | } |
---|
33 | |
---|
34 | function header() |
---|
35 | { |
---|
36 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
37 | { |
---|
38 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
39 | } |
---|
40 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
41 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
42 | echo parse_navbar(); |
---|
43 | } |
---|
44 | |
---|
45 | function store_location($info) |
---|
46 | { |
---|
47 | $GLOBALS['phpgw']->session->appsession('currentsessions_session_data','admin',$info); |
---|
48 | } |
---|
49 | |
---|
50 | function list_sessions() |
---|
51 | { |
---|
52 | $info = $GLOBALS['phpgw']->session->appsession('currentsessions_session_data','admin'); |
---|
53 | if (! is_array($info)) |
---|
54 | { |
---|
55 | $info = array( |
---|
56 | 'start' => 0, |
---|
57 | 'sort' => 'asc', |
---|
58 | 'order' => 'session_dla' |
---|
59 | ); |
---|
60 | $this->store_location($info); |
---|
61 | } |
---|
62 | |
---|
63 | if ($GLOBALS['start'] || $GLOBALS['sort'] || $GLOBALS['order']) |
---|
64 | { |
---|
65 | if ($GLOBALS['start'] == 0 || $GLOBALS['start'] && $GLOBALS['start'] != $info['start']) |
---|
66 | { |
---|
67 | $info['start'] = $GLOBALS['start']; |
---|
68 | } |
---|
69 | |
---|
70 | if ($GLOBALS['sort'] && $GLOBALS['sort'] != $info['sort']) |
---|
71 | { |
---|
72 | $info['sort'] = $GLOBALS['sort']; |
---|
73 | } |
---|
74 | |
---|
75 | if ($GLOBALS['order'] && $GLOBALS['order'] != $info['order']) |
---|
76 | { |
---|
77 | $info['order'] = $GLOBALS['order']; |
---|
78 | } |
---|
79 | |
---|
80 | $this->store_location($info); |
---|
81 | } |
---|
82 | |
---|
83 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('List of current users'); |
---|
84 | $this->header(); |
---|
85 | |
---|
86 | $this->template->set_file('current','currentusers.tpl'); |
---|
87 | $this->template->set_block('current','list','list'); |
---|
88 | $this->template->set_block('current','row','row'); |
---|
89 | |
---|
90 | $can_view_action = !$GLOBALS['phpgw']->acl->check('current_sessions_access',2,'admin'); |
---|
91 | $can_view_ip = !$GLOBALS['phpgw']->acl->check('current_sessions_access',4,'admin'); |
---|
92 | $can_kill = !$GLOBALS['phpgw']->acl->check('current_sessions_access',8,'admin'); |
---|
93 | |
---|
94 | $total = $this->bo->total(); |
---|
95 | |
---|
96 | $this->template->set_var('bg_color',$GLOBALS['phpgw_info']['theme']['bg_color']); |
---|
97 | $this->template->set_var('left_next_matchs',$this->nextmatchs->left('/admin/currentusers.php',$info['start'],$total)); |
---|
98 | $this->template->set_var('right_next_matchs',$this->nextmatchs->right('/admin/currentusers.php',$info['start'],$total)); |
---|
99 | $this->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']); |
---|
100 | |
---|
101 | $this->template->set_var('sort_loginid',$this->nextmatchs->show_sort_order($info['sort'],'session_lid',$info['order'], |
---|
102 | '/admin/currentusers.php',lang('LoginID'))); |
---|
103 | $this->template->set_var('sort_ip',$this->nextmatchs->show_sort_order($info['sort'],'session_ip',$info['order'], |
---|
104 | '/admin/currentusers.php',lang('IP'))); |
---|
105 | $this->template->set_var('sort_login_time',$this->nextmatchs->show_sort_order($info['sort'],'session_logintime',$info['order'], |
---|
106 | '/admin/currentusers.php',lang('Login Time'))); |
---|
107 | $this->template->set_var('sort_action',$this->nextmatchs->show_sort_order($info['sort'],'session_action',$info['order'], |
---|
108 | '/admin/currentusers.php',lang('Action'))); |
---|
109 | $this->template->set_var('sort_idle',$this->nextmatchs->show_sort_order($info['sort'],'session_dla',$info['order'], |
---|
110 | '/admin/currentusers.php',lang('idle'))); |
---|
111 | $this->template->set_var('lang_kill',lang('Kill')); |
---|
112 | |
---|
113 | $values = $this->bo->list_sessions($info['start'],$info['order'],$info['sort']); |
---|
114 | |
---|
115 | while (list(,$value) = @each($values)) |
---|
116 | { |
---|
117 | $this->nextmatchs->template_alternate_row_color($this->template); |
---|
118 | |
---|
119 | $this->template->set_var('row_loginid',$value['session_lid']); |
---|
120 | |
---|
121 | $this->template->set_var('row_ip',$can_view_ip?$value['session_ip']:' '); |
---|
122 | |
---|
123 | $this->template->set_var('row_logintime',$value['session_logintime']); |
---|
124 | $this->template->set_var('row_idle',$value['session_idle']); |
---|
125 | |
---|
126 | if ($value['session_action'] && $can_view_action) |
---|
127 | { |
---|
128 | $this->template->set_var('row_action',$GLOBALS['phpgw']->strip_html($value['session_action'])); |
---|
129 | } |
---|
130 | else |
---|
131 | { |
---|
132 | $this->template->set_var('row_action',' '); |
---|
133 | } |
---|
134 | |
---|
135 | if ($value['session_id'] != $GLOBALS['phpgw_info']['user']['sessionid'] && $can_kill) |
---|
136 | { |
---|
137 | $this->template->set_var('row_kill','<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicurrentsessions.kill&ksession=' |
---|
138 | . $value['session_id'] . '&kill=true') . '">' . lang('Kill').'</a>'); |
---|
139 | } |
---|
140 | else |
---|
141 | { |
---|
142 | $this->template->set_var('row_kill',' '); |
---|
143 | } |
---|
144 | |
---|
145 | $this->template->parse('rows','row',True); |
---|
146 | } |
---|
147 | |
---|
148 | $this->template->pfp('out','list'); |
---|
149 | } |
---|
150 | |
---|
151 | function kill() |
---|
152 | { |
---|
153 | if ($GLOBALS['phpgw']->acl->check('current_sessions_access',8,'admin')) |
---|
154 | { |
---|
155 | $GLOBALS['phpgw']->redirect_link('/index.php'); |
---|
156 | } |
---|
157 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Kill session'); |
---|
158 | $this->header(); |
---|
159 | $this->template->set_file('form','kill_session.tpl'); |
---|
160 | |
---|
161 | $this->template->set_var('lang_message',lang('Are you sure you want to kill this session ?')); |
---|
162 | $this->template->set_var('link_no','<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicurrentsessions.list_sessions') . '">' . lang('No') . '</a>'); |
---|
163 | $this->template->set_var('link_yes','<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.bocurrentsessions.kill&ksession=' . $_GET['ksession']) . '">' . lang('Yes') . '</a>'); |
---|
164 | |
---|
165 | $this->template->pfp('out','form'); |
---|
166 | } |
---|
167 | } |
---|