source: branches/2.2/expressoAdmin1_2/inc/class.totalsessions.inc.php @ 4586

Revision 4586, 2.7 KB checked in by niltonneto, 13 years ago (diff)

Ticket #1971 - Corrigido problema na rotina que contabiliza sessões válidas ativas.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
RevLine 
[2]1<?php
[414]2        /*************************************************************************************\
3        * Expresso Administração                                                                                                 *
[2]4        * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br)        *
[414]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        \*************************************************************************************/
[2]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                {
[309]38                        $GLOBALS['phpgw_info']['flags']['app_header'] = 'ExpressoAdmin - '.lang('Total Sessions');
[2]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');
[414]44                       
45                        $this->template->set_var($this->functions->make_dinamic_lang($this->template, 'list'));
[2]46
47                        $total = $this->get_total_sessions();
48                       
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');
[4586]77                                $session = @fread ($fd, 50);
[2]78                                fclose ($fd);
79
[4586]80                                if (strstr($session,'phpgw_session|') === FALSE)
[2]81                                {
82                                        continue;
83                                }
84                               
85                                $total++;
86                        }
87                        closedir($dir);
88                        return $total;
89                }
90        }
Note: See TracBrowser for help on using the repository browser.