source: trunk/expressoAdmin1_2/inc/class.totalsessions.inc.php @ 5233

Revision 5233, 3.6 KB checked in by clairson, 12 years ago (diff)

Ticket #1971 - Pagina de exibir sessoes nao esta contando corretamente

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
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                        $this->template->set_var($this->functions->make_dinamic_lang($this->template, 'list'));
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                       
59                        //files memcache
60                        switch(ini_get('session.save_handler')){
61                            case "memcache" : $mem = new Memcache();
62                                $arrayretorno = $mem->getStats();
63                                break;
64                            case "files":
65                                default :
66
67                                    $dir = opendir($path = ini_get('session.save_path'));
68                                    $total = 0;
69                                               
70                                    while ($file = readdir($dir))
71                                    {
72                                            $session = file_get_contents( $path . '/' . $file, false, null, 0, 50 );
73                                           
74                                            if( substr($file,0,5) != 'sess_' ||
75                                                !$session || // happens if webserver runs multiple user-ids
76                                                strstr( $session, 'phpgw_sess' ) === FALSE )
77                                            {
78                                                    continue;
79                                            }
80
81                                            $total++;
82                                    }
83                                   
84                                    closedir($dir);
85
86                                    return $total;
87               
88                        }
89                }
90        }
Note: See TracBrowser for help on using the repository browser.