[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: phpgwapi/inc class.common.inc.php,1.191,1.192 cl
From: |
Ralf Becker <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: phpgwapi/inc class.common.inc.php,1.191,1.192 class.sessions_db.inc.php,1.15,1.16class.sessions_php4.inc.php,1.18,1.19 |
Date: |
Thu, 20 Mar 2003 19:46:57 -0500 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv30001
Modified Files:
class.common.inc.php class.sessions_db.inc.php
class.sessions_php4.inc.php
Log Message:
Moved list_sessions and total from admin.socurrentsessions into the
session-class and implemented them for php4 too.
So admin.socurrentsessions is no longer used and bocurrentsessions as well as
the phpgwapi/templates/xxx/navbar.inc.php use the session-class to get the
number of loged-in-users.
Aktivated the accesslog für php4-sessions too.
Index: class.common.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.common.inc.php,v
retrieving revision 1.191
retrieving revision 1.192
diff -C2 -r1.191 -r1.192
*** class.common.inc.php 4 Jan 2003 00:54:55 -0000 1.191
--- class.common.inc.php 21 Mar 2003 00:46:55 -0000 1.192
***************
*** 1234,1240 ****
if (isset($GLOBALS['phpgw_ifo']['navbar']['admin']) &&
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers']))
{
! $GLOBALS['phpgw']->db->query('select
count(session_id) from phpgw_sessions');
! $GLOBALS['phpgw']->db->next_record();
! $var['current_users'] = lang('Current
users') . ': ' . $GLOBALS['phpgw']->db->f(0);
$var['url_current_users'] =
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicurrentsessions.list_sessions');
}
--- 1234,1238 ----
if (isset($GLOBALS['phpgw_ifo']['navbar']['admin']) &&
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers']))
{
! $var['current_users'] = lang('Current
users') . ': ' . $GLOBALS['phpgw']->session->total();
$var['url_current_users'] =
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicurrentsessions.list_sessions');
}
Index: class.sessions_db.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.sessions_db.inc.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** class.sessions_db.inc.php 14 Oct 2002 14:29:06 -0000 1.15
--- class.sessions_db.inc.php 21 Mar 2003 00:46:55 -0000 1.16
***************
*** 48,52 ****
var $public_functions = array(
'list_methods' => True,
! 'update_dla' => True
);
--- 48,54 ----
var $public_functions = array(
'list_methods' => True,
! 'update_dla' => True,
! 'list' => True,
! 'total' => True
);
***************
*** 1039,1042 ****
--- 1041,1077 ----
/* if no extravars then we return the cleaned up
url/scriptname */
return $url;
+ }
+
+ function list_sessions($start,$order,$sort)
+ {
+ $values = array();
+
+ $ordermethod = 'order by session_dla asc';
+ $this->db->limit_query("select * from phpgw_sessions
where session_flags != 'A' order by $sort $order",$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $values[] = array(
+ 'session_id' =>
$this->db->f('session_id'),
+ 'session_lid' =>
$this->db->f('session_lid'),
+ 'session_ip' =>
$this->db->f('session_ip'),
+ 'session_logintime' =>
$this->db->f('session_logintime'),
+ 'session_action' =>
$this->db->f('session_action'),
+ 'session_dla' =>
$this->db->f('session_dla')
+ );
+ }
+ return $values;
+ }
+
+ /*!
+ @function total
+ @abstract get number of normal / non-anonymous sessions
+ */
+ function total()
+ {
+ $this->db->query("select count(*) from phpgw_sessions
where session_flags != 'A'",__LINE__,__FILE__);
+ $this->db->next_record();
+
+ return $this->db->f(0);
}
}
Index: class.sessions_php4.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.sessions_php4.inc.php,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** class.sessions_php4.inc.php 21 Mar 2003 00:17:15 -0000 1.18
--- class.sessions_php4.inc.php 21 Mar 2003 00:46:55 -0000 1.19
***************
*** 46,50 ****
var $public_functions = array(
'list_methods' => True,
! 'update_dla' => True
);
--- 46,52 ----
var $public_functions = array(
'list_methods' => True,
! 'update_dla' => True,
! 'list' => True,
! 'total' => True
);
***************
*** 60,63 ****
--- 62,66 ----
/* Create the crypto object */
$GLOBALS['phpgw']->crypto =
CreateObject('phpgwapi.crypto');
+ $GLOBALS['phpgw']->datetime =
CreateObject('phpgwapi.datetime');
$this->phpgw_set_cookiedomain();
}
***************
*** 292,306 ****
if (count($parts) > 2)
{
! if (!ereg('[0-9]+',$parts[1]))
! {
! for($i=1;$i<count($parts);$i++)
! {
! $this->cookie_domain .= '.'.$parts[$i];
! }
! }
! else
! {
! $this->cookie_domain = '';
! }
}
else
--- 295,309 ----
if (count($parts) > 2)
{
! if (!ereg('[0-9]+',$parts[1]))
! {
! for($i=1;$i<count($parts);$i++)
! {
! $this->cookie_domain .= '.'.$parts[$i];
! }
! }
! else
! {
! $this->cookie_domain = '';
! }
}
else
***************
*** 308,312 ****
$this->cookie_domain = '';
}
! print_debug('COOKIE_DOMAIN',$this->cookie_domain,'api');
session_set_cookie_params(0,'/',$this->cookie_domain);
}
--- 311,315 ----
$this->cookie_domain = '';
}
! print_debug('COOKIE_DOMAIN',$this->cookie_domain,'api');
session_set_cookie_params(0,'/',$this->cookie_domain);
}
***************
*** 443,448 ****
$GLOBALS['HTTP_SESSION_VARS']['phpgw_session'] =
$GLOBALS['phpgw_session'];
! //$GLOBALS['phpgw']->db->query('INSERT INTO
phpgw_access_log(sessionid,loginid,ip,li,lo,account_id) '
! // ." VALUES ('" . $this->sessionid . "','" .
"$login','" . $user_ip . "',".$now.",''," . $this->account_id .
")",__LINE__,__FILE__);
$this->appsession('account_previous_login','phpgwapi',$GLOBALS['phpgw']->auth->previous_login);
--- 446,451 ----
$GLOBALS['HTTP_SESSION_VARS']['phpgw_session'] =
$GLOBALS['phpgw_session'];
! $GLOBALS['phpgw']->db->query('INSERT INTO
phpgw_access_log(sessionid,loginid,ip,li,lo,account_id) '
! ." VALUES ('" . $this->sessionid . "','" .
"$login','" . $user_ip . "',".$now.",''," . $this->account_id .
")",__LINE__,__FILE__);
$this->appsession('account_previous_login','phpgwapi',$GLOBALS['phpgw']->auth->previous_login);
***************
*** 656,661 ****
$GLOBALS['HTTP_SESSION_VARS']['phpgw_session'] =
$GLOBALS['phpgw_session'];
! //$GLOBALS['phpgw']->db->query("INSERT INTO
phpgw_access_log VALUES ('" . $this->sessionid . "','"
! // . "$login','" . $user_ip . "','$now','','" .
$this->account_id . "')",__LINE__,__FILE__);
$this->appsession('account_previous_login','phpgwapi',$GLOBALS['phpgw']->auth->previous_login);
--- 659,664 ----
$GLOBALS['HTTP_SESSION_VARS']['phpgw_session'] =
$GLOBALS['phpgw_session'];
! $GLOBALS['phpgw']->db->query("INSERT INTO
phpgw_access_log VALUES ('" . $this->sessionid . "','"
! . "$login','" . $user_ip . "','$now','','" .
$this->account_id . "')",__LINE__,__FILE__);
$this->appsession('account_previous_login','phpgwapi',$GLOBALS['phpgw']->auth->previous_login);
***************
*** 694,702 ****
}
! session_unset();
! session_destroy();
! $this->phpgw_setcookie(session_name());
! //$GLOBALS['phpgw']->db->query("UPDATE phpgw_access_log
SET lo='" . time() . "' WHERE sessionid='"
! // . $sessionid . "'",__LINE__,__FILE__);
// Only do the following, if where working with the
current user
--- 697,703 ----
}
! $GLOBALS['phpgw']->db->query("UPDATE phpgw_access_log
SET lo='" . $GLOBALS['phpgw']->datetime->gmtnow . "' WHERE sessionid='"
! . $sessionid . "'",__LINE__,__FILE__);
! $GLOBALS['phpgw']->db->transaction_commit();
// Only do the following, if where working with the
current user
***************
*** 704,709 ****
{
$this->clean_sessions();
}
- $GLOBALS['phpgw']->db->transaction_commit();
return True;
--- 705,722 ----
{
$this->clean_sessions();
+ session_unset();
+ session_destroy();
+ $this->phpgw_setcookie(session_name());
+ }
+ else
+ {
+ $sessions = $this->list_sessions(0,'','',True);
+
+ if (isset($sessions[$sessionid]))
+ {
+ //echo
"<p>session_php4::destroy($session_id):
unlink('".$sessions[$sessionid]['php_session_file'].")</p>\n";
+
unlink($sessions[$sessionid]['php_session_file']);
+ }
}
return True;
***************
*** 996,999 ****
--- 1009,1093 ----
/* if no extravars then we return the cleaned up
url/scriptname */
return $url;
+ }
+
+ function session_sort($a,$b)
+ {
+ $sign =
strcasecmp($GLOBALS['phpgw']->session->sort_order,'ASC') ? 1 : -1;
+
+ return
strcasecmp($a[$GLOBALS['phpgw']->session->sort_by],
+
$b[$GLOBALS['phpgw']->session->sort_by]) * $sign;
+ }
+
+ /*!
+ @function list_sessions
+ @abstract get list of normal / non-anonymous sessions
+ @author ralfbecker
+ */
+ function list_sessions($start,$order,$sort,$all_no_sort = False)
+ {
+ //echo
"<p>session_php4::list_sessions($start,'$order','$sort',$all)</p>\n";
+ $values = array();
+ $maxmatchs =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ $dir = opendir($path = ini_get('session.save_path'));
+ while ($file = readdir($dir))
+ {
+ if (substr($file,0,5) != 'sess_')
+ {
+ continue;
+ }
+ list($session) = file($path . '/' . $file);
+
+ if (substr($session,0,14) != 'phpgw_session|')
+ {
+ continue;
+ }
+ $session = unserialize(substr($session,14));
+ list(,$domain) =
explode('@',$session['session_lid']);
+ if (empty($domain))
+ {
+ $domain =
$GLOBALS['phpgw_info']['server']['default_domain'];
+ }
+ if ($session['session_flags'] == 'A' || $domain
!= $this->account_domain || !$session['session_id'])
+ {
+ continue; // no anonymous
sessions or other domains
+ }
+ unset($session['phpgw_app_sessions']); // not
needed, saves memory
+ //echo "file='$file'=<pre>"; print_r($session);
echo "</pre>";
+
+ $session['php_session_file'] = $path . '/' .
$file;
+ $values[$session['session_id']] = $session;
+ }
+ closedir($dir);
+
+ if (!$all_no_sort)
+ {
+ $GLOBALS['phpgw']->session->sort_by = $sort;
+ $GLOBALS['phpgw']->session->sort_order = $order;
+
+
uasort($values,array('sessions','session_sort'));
+
+ $i = 0;
+ $start = intval($start);
+ foreach($values as $id => $data)
+ {
+ if ($i < $start || $i >
$start+$maxmatchs)
+ {
+ unset($values[$id]);
+ }
+ ++$i;
+ }
+ reset($values);
+ }
+ return $values;
+ }
+
+ /*!
+ @function total
+ @abstract get number of normal / non-anonymous sessions
+ @author ralfbecker
+ */
+ function total()
+ {
+ return count($this->list_sessions(0,'','',True));
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: phpgwapi/inc class.common.inc.php,1.191,1.192 class.sessions_db.inc.php,1.15,1.16class.sessions_php4.inc.php,1.18,1.19,
Ralf Becker <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: phpgwapi/inc class.sessions_php4.inc.php,1.17,1.18
- Next by Date:
[Phpgroupware-cvs] CVS: admin/inc class.bocurrentsessions.inc.php,1.7,1.8 class.socurrentsessions.inc.php,1.3,NONE
- Previous by thread:
[Phpgroupware-cvs] CVS: phpgwapi/inc class.sessions_php4.inc.php,1.17,1.18
- Next by thread:
[Phpgroupware-cvs] CVS: admin/inc class.bocurrentsessions.inc.php,1.7,1.8 class.socurrentsessions.inc.php,1.3,NONE
- Index(es):