RELEASE 0.9.8
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/timeout_functions.php,v 1.6.2.5 2005/12/31 03:06:15 wurley Exp $
|
||||
|
||||
/**
|
||||
* A collection of functions used throughout phpLDAPadmin for the timeout and automatic logout feature
|
||||
@@ -16,9 +17,9 @@
|
||||
* @param object $ldapserver The LDAPServer object of the server which the user has logged in.
|
||||
* @return bool
|
||||
*/
|
||||
function set_lastactivity( $ldapserver ) {
|
||||
function set_lastactivity($ldapserver) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('set_lastactivity(): Entered with (%s)',2,$ldapserver->server_id);
|
||||
debug_log('set_lastactivity(): Entered with (%s)',1,$ldapserver->server_id);
|
||||
|
||||
$_SESSION['activity']['server'][$ldapserver->server_id] = time();
|
||||
$_SESSION['activity']['rightframe_server_id'] = $ldapserver->server_id;
|
||||
@@ -31,63 +32,49 @@ function set_lastactivity( $ldapserver ) {
|
||||
*
|
||||
* @param object $ldapserver The LDAPServer object of the server which the user has logged in.
|
||||
*/
|
||||
function unset_lastactivity( $ldapserver ) {
|
||||
function unset_lastactivity($ldapserver) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('unset_lastactivity(): Entered with (%s)',2,$ldapserver->server_id);
|
||||
debug_log('unset_lastactivity(): Entered with (%s)',1,$ldapserver->server_id);
|
||||
|
||||
if (isset($_SESSION['activity']['server'][$ldapserver->server_id])) {
|
||||
if (isset($_SESSION['activity']['server'][$ldapserver->server_id]))
|
||||
unset($_SESSION['activity']['server'][$ldapserver->server_id]);
|
||||
session_write_close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if custom session timeout has been reached for server $ldapserver.
|
||||
* If it has:
|
||||
* - automatically log out user by calling unset_login_dn( $server_id )
|
||||
* - automatically log out user by calling $ldapserver->unsetLoginDN()
|
||||
* - if $server_id is equal to right frame $server_id, load timeout.php page in the right frame
|
||||
* - return true
|
||||
*
|
||||
* @param object $ldapserver The LDAPServer object of the server which the user has logged in.
|
||||
* @return bool true on success, false on failure.
|
||||
*/
|
||||
function session_timed_out( $ldapserver ) {
|
||||
function session_timed_out($ldapserver) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('session_timed_out(): Entered with (%s)',2,$ldapserver->server_id);
|
||||
|
||||
global $lang;
|
||||
debug_log('session_timed_out(): Entered with (%s)',1,$ldapserver->server_id);
|
||||
|
||||
# If session hasn't expired yet
|
||||
if( isset( $_SESSION[ 'activity' ]['server'][$ldapserver->server_id] ) ) {
|
||||
if (isset($_SESSION['activity']['server'][$ldapserver->server_id])) {
|
||||
|
||||
// If $session_timeout not defined, use ( session_cache_expire() - 1 )
|
||||
# If $session_timeout not defined, use (session_cache_expire() - 1)
|
||||
if (! isset($ldapserver->session_timeout))
|
||||
$session_timeout = session_cache_expire()-1;
|
||||
else
|
||||
$session_timeout = $ldapserver->session_timeout;
|
||||
|
||||
// Get the $last_activity and $rightframe_server_id value
|
||||
# Get the $last_activity and $rightframe_server_id value
|
||||
$last_activity = $_SESSION['activity']['server'][$ldapserver->server_id];
|
||||
$rightframe_server_id = $_SESSION['activity']['rightframe_server_id'];
|
||||
|
||||
// If diff between current time and last activity greater than $session_timeout, log out user
|
||||
if ( ( time()-$last_activity ) > ( $session_timeout*60 ) ) {
|
||||
# If diff between current time and last activity greater than $session_timeout, log out user
|
||||
if ((time()-$last_activity) > ($session_timeout*60)) {
|
||||
|
||||
if( in_array($ldapserver->auth_type, array('cookie','session')) ) {
|
||||
syslog_notice ( "Logout for " . get_logged_in_dn( $ldapserver ) );
|
||||
unset_login_dn( $ldapserver ) or pla_error( $lang['could_not_logout'] );
|
||||
if (in_array($ldapserver->auth_type, array('cookie','session'))) {
|
||||
syslog_notice('Logout for '.$ldapserver->getLoggedInDN());
|
||||
$ldapserver->unsetLoginDN() or pla_error(_('Could not logout.'));
|
||||
}
|
||||
|
||||
// If $ldapserver->server_id equal $rightframe_server_id load timeout page on right frame
|
||||
if ( $ldapserver->server_id == $rightframe_server_id ) { ?>
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
<!--
|
||||
parent.right_frame.location.href = 'timeout.php?server_id=<?php echo $ldapserver->server_id; ?>';
|
||||
//--></SCRIPT>
|
||||
|
||||
<?php }
|
||||
return true;
|
||||
return true;
|
||||
|
||||
} else
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user