[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: phpgwapi/inc class.sessions_db.inc.php,1.2.2.9,
From: |
Ralf Becker <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: phpgwapi/inc class.sessions_db.inc.php,1.2.2.9,1.2.2.10 class.sessions_php4.inc.php,1.6.2.8,1.6.2.9 |
Date: |
Thu, 20 Mar 2003 18:53:29 -0500 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv11319
Modified Files:
Tag: Version-0_9_14-branch
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.sessions_db.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.sessions_db.inc.php,v
retrieving revision 1.2.2.9
retrieving revision 1.2.2.10
diff -C2 -r1.2.2.9 -r1.2.2.10
*** class.sessions_db.inc.php 14 Oct 2002 13:30:27 -0000 1.2.2.9
--- class.sessions_db.inc.php 20 Mar 2003 23:53:26 -0000 1.2.2.10
***************
*** 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
);
***************
*** 1033,1036 ****
--- 1035,1071 ----
//echo "$url\n";
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.6.2.8
retrieving revision 1.6.2.9
diff -C2 -r1.6.2.8 -r1.6.2.9
*** class.sessions_php4.inc.php 14 Oct 2002 13:30:27 -0000 1.6.2.8
--- class.sessions_php4.inc.php 20 Mar 2003 23:53:27 -0000 1.6.2.9
***************
*** 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();
}
***************
*** 284,298 ****
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
--- 287,301 ----
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
***************
*** 300,304 ****
$this->cookie_domain = '';
}
! print_debug('COOKIE_DOMAIN',$this->cookie_domain,'api');
session_set_cookie_params(0,'/',$this->cookie_domain);
}
--- 303,307 ----
$this->cookie_domain = '';
}
! print_debug('COOKIE_DOMAIN',$this->cookie_domain,'api');
session_set_cookie_params(0,'/',$this->cookie_domain);
}
***************
*** 435,440 ****
$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);
--- 438,443 ----
$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);
***************
*** 648,653 ****
$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);
--- 651,656 ----
$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);
***************
*** 686,694 ****
}
! session_unset();
! session_destroy();
! $this->phpgw_setcookie(session_name());
! //$GLOBALS['phpgw']->db->query("UPDATE phpgw_access_log
SET lo='" . $GLOBALS['phpgw']->datetime->gmtnow . "' WHERE sessionid='"
! // . $sessionid . "'",__LINE__,__FILE__);
// Only do the following, if where working with the
current user
--- 689,695 ----
}
! $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
***************
*** 696,701 ****
{
$this->clean_sessions();
}
- $GLOBALS['phpgw']->db->transaction_commit();
return True;
--- 697,714 ----
{
$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 ----
//echo "$url\n";
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)
+ {
+ 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.sessions_db.inc.php,1.2.2.9,1.2.2.10 class.sessions_php4.inc.php,1.6.2.8,1.6.2.9,
Ralf Becker <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: timetrack addjobdetail.php,1.20,1.21 admin3.php,1.10,1.11 editdetail.php,1.16,1.17
- Next by Date:
[Phpgroupware-cvs] CVS: phpgwapi/templates/default navbar.inc.php,1.28.2.1,1.28.2.2
- Previous by thread:
[Phpgroupware-cvs] CVS: timetrack addjobdetail.php,1.20,1.21 admin3.php,1.10,1.11 editdetail.php,1.16,1.17
- Next by thread:
[Phpgroupware-cvs] CVS: phpgwapi/templates/default navbar.inc.php,1.28.2.1,1.28.2.2
- Index(es):