[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(); |
---|
[5233] | 48 | |
---|
[2] | 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(); |
---|
[5233] | 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 : |
---|
[2] | 66 | |
---|
[5233] | 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 | |
---|
[7655] | 81 | ++$total; |
---|
[5233] | 82 | } |
---|
| 83 | |
---|
| 84 | closedir($dir); |
---|
| 85 | |
---|
| 86 | return $total; |
---|
| 87 | |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | } |
---|