[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] api class.admin.php,1.1.2.8,1.1.2.9
From: |
Joseph Engo <address@hidden> |
Subject: |
[Phpgroupware-cvs] api class.admin.php,1.1.2.8,1.1.2.9 |
Date: |
Sun, 09 Nov 2003 15:47:44 +0000 |
Update of /cvsroot/phpgroupware/api
In directory subversions:/tmp/cvs-serv30293/api
Modified Files:
Tag: proposal-branch
class.admin.php
Log Message:
- Started working on the current users screen
Some of the code needs to be moved to the sessions class, I will try to get
to that later on in the day
- Kill session isn't finished
Index: class.admin.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.admin.php,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** class.admin.php 3 Nov 2003 13:20:36 -0000 1.1.2.8
--- class.admin.php 9 Nov 2003 15:47:42 -0000 1.1.2.9
***************
*** 21,24 ****
--- 21,43 ----
'abstract' => 'Admin page main screen'
);
+ $functions['current_users'] = array(
+ 'type' => 'public',
+ 'title' => 'Current Users',
+ 'abstract' => 'List of current sessions'
+ );
+ $functions['kill_session'] = array(
+ 'type' => 'public',
+ 'title' => 'Kill session',
+ 'abstract' => 'Destroy another users session'
+ );
+ $functions['view_session_data'] = array(
+ 'type' => 'public',
+ 'title' => 'View session data',
+ 'abstract' => 'Debug function to show data stored in a
session',
+ 'params' => array(
+ 'vsid' => array('type' => 'string', 'default' =>
'##REQUIRD##', 'desc' => 'Session ID you want to view')
+ )
+
+ );
$GLOBALS['docs']['api']['classes']['api_admin'] = array(
***************
*** 31,42 ****
function api_admin()
{
-
- }
-
- function start()
- {
- $result['g'] = '';
$GLOBALS['phpgw']->add_xsl('api.admin');
-
$GLOBALS['phpgw_xml_apinode']->add_node('Admin','title');
$appmenu[] = array(
--- 50,54 ----
***************
*** 57,68 ****
--- 69,244 ----
);
$appmenu[] = array(
+ 'title' => 'Current Users',
+ 'op' => 'api.admin.current_users',
+ );
+ $appmenu[] = array(
'title' => 'Setup',
'op' => 'api.setup.start',
);
$GLOBALS['phpgw_xml_apinode']->add_node($appmenu,'appmenu');
+ }
+
+ function start()
+ {
+ $result['g'] = '';
+
$GLOBALS['phpgw_xml_apinode']->add_node('Admin','title');
return $result;
}
+ // This is ONLY intended as a debug tool
+ function view_session_data()
+ {
+ $args = new safe_args();
+ $args->set('vsid','##REQUIRED##','string');
+ $args = $args->get(func_get_args(),__LINE__,__FILE__);
+
+ $fh = fopen(get_cfg_var('session.save_path') . SEP .
'sess_' . $args['vsid'],'r');
+ if (! $fh)
+ {
+ $GLOBALS['msgbox']->add(lang('Could not open
session file (%s)',get_cfg_var('session.save_path') . SEP . 'sess_' .
$args['vsid']),__LINE__,__FILE__, 'error');
+ return;
+ }
+
+ while (! feof($fh))
+ {
+ $raw_data .= fgets($fh,4096);
+ }
+ fclose($fh);
+
+ $data =
unserialize(ereg_replace('phpgw_session\|','',$raw_data));
+ // If you want to see this data, comment out the
follow. I did this becuase at times this data was really way too big
+ // and looked like total shit in the browser. (jengo)
+ $data['serialized_classes'] = array('removed due to
size');
+
+ ob_start();
+ print_r($data);
+ $result_data = ob_get_contents();
+ ob_end_clean();
+
+ $result = array(
+ 'session_data' => $result_data,
+ 'action_type' => 'view_session_data'
+ );
+ return $result;
+ }
+
+ function kill_session()
+ {
+ $args = new safe_args();
+ $args->set('ksid','##REQUIRED##','string');
+ $args->set('answer', '##NOVAR##', 'any');
+ $args = $args->get(func_get_args(),__LINE__,__FILE__);
+
+ if ($args['answer'] == '##NOVAR##')
+ {
+ $GLOBALS['phpgw']->add_xsl('api.widgets');
+ $result['dialog'] = array(
+ // FIXME: Add session info so they know
which they are deleting
+ 'question' => lang('Are you sure you
want to delete this session ?'),
+ 'yes_op' => 'api.admin.kill_session',
+ 'no_op' => 'api.admin.current_users',
+ 'current_inputs' => array(
+ 0 => array(
+ 'name' => 'ksid',
+ 'value' => $args['ksid']
+ )
+ )
+ );
+ $result['action_type'] = 'kill_session';
+ }
+ else if ($args['answer'] == 'Yes')
+ {
+ $GLOBALS['msgbox']->add(lang('Session has NOT
been deleted',$account_lid),__LINE__,__FILE__, 'notice');
+ }
+
+ return $result;
+ }
+
+ function read_session_data($filename)
+ {
+ $sid = ereg_replace('sess_','',$filename);
+
+ $fh = fopen(get_cfg_var('session.save_path') . SEP .
$filename,'r');
+ if (! $fh)
+ {
+ $GLOBALS['msgbox']->add(lang('Could not open
session file (%s)',get_cfg_var('session.save_path') . SEP .
$filename),__LINE__,__FILE__, 'error');
+ return;
+ }
+
+ while (! feof($fh))
+ {
+ $raw_data .= fgets($fh,4096);
+ }
+ fclose($fh);
+
+ $data =
unserialize(ereg_replace('phpgw_session\|','',$raw_data));
+ list($app,$class,$method) =
explode('.',$data['prevop']);
+
+ if (! $app && ! $class && ! $method)
+ {
+ return False;
+ }
+
+ if (! file_exists(PHPGW_ROOT . SEP . $app . SEP .
'class.' . $class . '.php'))
+ {
+ // Not sure if errors should be spit out here,
its possiable a user was tring to access
+ // something that doesn't exist ... that would
prevent this method from working UNTIL
+ // the session is updating or deleted. So, for
now, just ignore times like this.
+ // Maybe in the future, add it to the debug log
(jengo)
+ return False;
+ }
+
+ require_once(PHPGW_ROOT . SEP . $app . SEP . 'class.' .
$class . '.php');
+
+ if (isset($GLOBALS['docs'][$app]['classes'][$app . '_'
. $class]['functions'][$method]['title']))
+ {
+ $title =
lang($GLOBALS['docs'][$app]['classes'][$app . '_' .
$class]['functions'][$method]['title']);
+ }
+ else
+ {
+ $title = $data['prevop'];
+ }
+
+ return array(
+ 'lid' => $data['session_lid'],
+ 'action' => $title,
+ 'ip' => $data['ip_address'],
+ 'login_time' =>
strftime('%x',$data['login_time']) . date(' h:i:s a',$data['login_time']),
+ 'idle' => gmdate('H:i:s',(time() -
$data['session_dla'])),
+ 'sid' => $sid
+ );
+ }
+
+ function current_users()
+ {
+ $GLOBALS['phpgw_xml_apinode']->add_node('Current
Users','title');
+
+ // FIXME: This NEEDS to be moved into the session class
(jengo)
+ $dh = opendir(get_cfg_var('session.save_path'));
+ while ($file = readdir($dh))
+ {
+ if (ereg('sess_',$file) && strlen($file) == 37)
+ {
+ $session_values =
$this->read_session_data($file);
+
+ if (is_array($session_values))
+ {
+ $result['current_users'][] =
array(
+ 'lid' =>
$session_values['lid'],
+ 'action' =>
$session_values['action'],
+ 'ip' =>
$session_values['ip'],
+ 'login_time' =>
$session_values['login_time'],
+ 'idle' =>
$session_values['idle'],
+ 'sid' =>
$session_values['sid']
+ );
+ }
+ }
+ }
+ closedir($dh);
+
+ $result['action_type'] = 'current_users';
+ return $result;
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] api class.admin.php,1.1.2.8,1.1.2.9,
Joseph Engo <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] api/sessions class.sessions_php.php, 1.1.1.1.2.3, 1.1.1.1.2.4
- Next by Date:
[Phpgroupware-cvs] api/skins/default admin.xsl, 1.1.2.1, 1.1.2.2 phpgw.xsl, 1.1.1.1.2.22, 1.1.1.1.2.23 widgets.xsl, 1.1.1.1.2.9, 1.1.1.1.2.10
- Previous by thread:
[Phpgroupware-cvs] api/sessions class.sessions_php.php, 1.1.1.1.2.3, 1.1.1.1.2.4
- Next by thread:
[Phpgroupware-cvs] api/skins/default admin.xsl, 1.1.2.1, 1.1.2.2 phpgw.xsl, 1.1.1.1.2.22, 1.1.1.1.2.23 widgets.xsl, 1.1.1.1.2.9, 1.1.1.1.2.10
- Index(es):