forked from extern/egroupware
to work around the not terminated sessions (because php is configured by default only to check it on every 100th session-creation), we terminate now all timed out sessions when a list of sessions is requested
This commit is contained in:
parent
1a0f3ab29c
commit
332c9c41df
@ -181,16 +181,17 @@
|
||||
) * $sign;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function list_sessions
|
||||
@abstract get list of normal / non-anonymous sessions
|
||||
@note The data form the session-files get cached in the app_session phpgwapi/php4_session_cache
|
||||
@author ralfbecker
|
||||
*/
|
||||
/**
|
||||
* get list of normal / non-anonymous sessions (works only for session.handler = files!, but that's the default)
|
||||
*
|
||||
* The data from the session-files get cached in the app_session phpgwapi/php4_session_cache
|
||||
*
|
||||
* @author RalfBecker-AT-outdoor-training.de
|
||||
*/
|
||||
function list_sessions($start,$order,$sort,$all_no_sort = False)
|
||||
{
|
||||
//echo "<p>session_php4::list_sessions($start,'$order','$sort',$all)</p>\n";
|
||||
//$session_cache = $this->appsession('php4_session_cache','phpgwapi');
|
||||
$session_cache = $this->appsession('php4_session_cache','phpgwapi');
|
||||
|
||||
$values = array();
|
||||
$maxmatchs = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
|
||||
@ -199,19 +200,25 @@
|
||||
{
|
||||
return $values;
|
||||
}
|
||||
while ($file = readdir($dir))
|
||||
while (($file = readdir($dir)))
|
||||
{
|
||||
if (substr($file,0,5) != 'sess_' || $session_cache[$file] === false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (isset($session_cache[$file]) && !$session_cache[$file]) // session is marked as not to list (not ours or anonymous)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (isset($session_cache[$file])) // use copy from cache
|
||||
{
|
||||
if (!$all_no_sort) // we need the up-to-date data --> unset and reread it
|
||||
$session = $session_cache[$file];
|
||||
|
||||
if (!$all_no_sort || // we need the up-to-date data --> unset and reread it
|
||||
$session['session_dla'] <= (time() - $GLOBALS['egw_info']['server']['sessions_timeout'])) // cached dla is timeout
|
||||
{
|
||||
unset($session_cache[$file]);
|
||||
}
|
||||
$session = $session_cache[$file];
|
||||
}
|
||||
if (!isset($session_cache[$file])) // not in cache, read and cache it
|
||||
{
|
||||
@ -234,16 +241,25 @@
|
||||
$session = unserialize(substr($session,1+strlen(EGW_SESSION_VAR)));
|
||||
unset($session['app_sessions']); // not needed, saves memory
|
||||
$session_cache[$file] = $session;
|
||||
}
|
||||
if($session['session_flags'] == 'A' || !$session['session_id'] ||
|
||||
$session['session_install_id'] != $GLOBALS['egw_info']['server']['install_id'])
|
||||
{
|
||||
$session_cache[$file] = false; // dont try reading it again
|
||||
continue; // no anonymous sessions or other domains or installations
|
||||
|
||||
if($session['session_flags'] == 'A' || !$session['session_id'] ||
|
||||
$session['session_install_id'] != $GLOBALS['egw_info']['server']['install_id'])
|
||||
{
|
||||
$session_cache[$file] = false; // dont try reading it again
|
||||
continue; // no anonymous sessions or other domains or installations
|
||||
}
|
||||
// check for and terminate sessions which are timed out ==> destroy them
|
||||
// this should be not necessary if php is configured right, but I'm sick of the questions on the list
|
||||
if ($session['session_dla'] <= (time() - $GLOBALS['egw_info']['server']['sessions_timeout']))
|
||||
{
|
||||
//echo "session $session[session_id] is timed out !!!<br>\n";
|
||||
@unlink($path . '/' . $file);
|
||||
$session_cache[$file] = false;
|
||||
continue;
|
||||
}
|
||||
$session['php_session_file'] = $path . '/' . $file;
|
||||
}
|
||||
//echo "file='$file'=<pre>"; print_r($session); echo "</pre>";
|
||||
|
||||
$session['php_session_file'] = $path . '/' . $file;
|
||||
$values[$session['session_id']] = $session;
|
||||
}
|
||||
closedir($dir);
|
||||
@ -272,11 +288,11 @@
|
||||
return $values;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function total
|
||||
@abstract get number of normal / non-anonymous sessions
|
||||
@author ralfbecker
|
||||
*/
|
||||
/**
|
||||
* get number of normal / non-anonymous sessions
|
||||
*
|
||||
* @author RalfBecker-AT-outdoor-training.de
|
||||
*/
|
||||
function total()
|
||||
{
|
||||
return count($this->list_sessions(0,'','',True));
|
||||
|
Loading…
Reference in New Issue
Block a user