<?PHP

include_once('init.php');

$lastactivitytime = time() - ($config['session_timeout'] * 60);

$temp =& $osDB->getAll( 'SELECT * FROM ! where lastactivitytime < ?', array( ONLINE_USERS_TABLE, $lastactivitytime ) );

session_destroy();

if ( sizeof( $temp ) > 0 ) {

	foreach( $temp as $index => $row ) {

		if ( ( time() - $row['lastactivitytime'] ) > (int)( $config['session_timeout'] * 60 ) && $row['session_id'] != '' ) {

			/* First destroy session */
			session_id($row['session_id']);
			session_start();
			session_destroy();

			$osDB->query( 'DELETE FROM ! WHERE userid = ?', array( ONLINE_USERS_TABLE, $row['userid'] ) );
		}
	}

}

unset($temp);

?>