1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * Expresso Administração * |
---|
4 | * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br) * |
---|
5 | * -----------------------------------------------------------------------------------------------------* |
---|
6 | * This program is free software; you can redistribute it and/or modify it * |
---|
7 | * under the terms of the GNU General Public License as published by the * |
---|
8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
9 | * option) any later version. * |
---|
10 | \**************************************************************************/ |
---|
11 | |
---|
12 | class totalsessions |
---|
13 | { |
---|
14 | var $functions; |
---|
15 | var $template; |
---|
16 | var $bo; |
---|
17 | var $public_functions = array( |
---|
18 | 'show_total_sessions' => True |
---|
19 | ); |
---|
20 | |
---|
21 | function totalsessions() |
---|
22 | { |
---|
23 | $this->functions = createobject('expressoAdmin1_2.functions'); |
---|
24 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
25 | $tmp = $this->functions->read_acl($account_lid); |
---|
26 | $manager_context = $tmp[0]['context']; |
---|
27 | // Verifica se o administrador tem acesso. |
---|
28 | if (!$this->functions->check_acl($account_lid,'view_global_sessions')) |
---|
29 | { |
---|
30 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
31 | } |
---|
32 | |
---|
33 | $this->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
34 | } |
---|
35 | |
---|
36 | function show_total_sessions() |
---|
37 | { |
---|
38 | $GLOBALS['phpgw_info']['flags']['app_header'] = 'ExpressoAdmin - '.lang('Total Sessions'); |
---|
39 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
40 | echo parse_navbar(); |
---|
41 | |
---|
42 | $this->template->set_file('template','totalsessions.tpl'); |
---|
43 | $this->template->set_block('template','list','list'); |
---|
44 | |
---|
45 | $total = $this->get_total_sessions(); |
---|
46 | |
---|
47 | $this->template->set_var('lang_total', lang('totalsessions')); |
---|
48 | $this->template->set_var('lang_back', lang('back')); |
---|
49 | $this->template->set_var('back_url', $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php')); |
---|
50 | $this->template->set_var('total', $total); |
---|
51 | |
---|
52 | $this->template->pfp('out','list'); |
---|
53 | } |
---|
54 | |
---|
55 | function get_total_sessions() |
---|
56 | { |
---|
57 | $values = array(); |
---|
58 | $dir = @opendir($path = ini_get('session.save_path')); |
---|
59 | $total = 0; |
---|
60 | |
---|
61 | if (!$dir) // eg. openbasedir restrictions |
---|
62 | { |
---|
63 | return $values; |
---|
64 | } |
---|
65 | while ($file = readdir($dir)) |
---|
66 | { |
---|
67 | if (substr($file,0,5) != 'sess_') |
---|
68 | { |
---|
69 | continue; |
---|
70 | } |
---|
71 | if (!is_readable($path. '/' . $file)) |
---|
72 | { |
---|
73 | continue; // happens if webserver runs multiple user-ids |
---|
74 | } |
---|
75 | |
---|
76 | $fd = fopen ($path . '/' . $file,'r'); |
---|
77 | $session = @fread ($fd, filesize ($path . '/' . $file)); |
---|
78 | fclose ($fd); |
---|
79 | |
---|
80 | if (substr($session,0,14) != 'phpgw_session|') |
---|
81 | { |
---|
82 | continue; |
---|
83 | } |
---|
84 | |
---|
85 | $total++; |
---|
86 | } |
---|
87 | closedir($dir); |
---|
88 | return $total; |
---|
89 | } |
---|
90 | } |
---|