2000-08-18 05:24:22 +02:00
|
|
|
<?php
|
2008-11-15 11:54:39 +01:00
|
|
|
/**
|
|
|
|
* eGroupWare - Logout
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Joseph Engo <jengo@phpgroupware.org>
|
|
|
|
* @license http://opensource.org/licenses/lgpl-license.php LGPL - GNU Lesser General Public License
|
|
|
|
* @package api
|
|
|
|
* @subpackage authentication
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
2001-03-31 13:43:14 +02:00
|
|
|
|
2008-11-15 11:54:39 +01:00
|
|
|
$GLOBALS['egw_info'] = array(
|
|
|
|
'flags' => array(
|
|
|
|
'disable_Template_class' => True,
|
|
|
|
'currentapp' => 'logout',
|
|
|
|
'noheader' => True,
|
|
|
|
'nofooter' => True,
|
|
|
|
'nonavbar' => True
|
|
|
|
)
|
|
|
|
);
|
|
|
|
include('./header.inc.php');
|
2001-03-31 13:43:14 +02:00
|
|
|
|
2009-10-02 10:33:13 +02:00
|
|
|
$GLOBALS['sessionid'] = egw_session::get_sessionid();
|
2009-08-22 21:32:28 +02:00
|
|
|
$GLOBALS['kp3'] = egw_session::get_request('kp3');
|
2001-03-31 13:43:14 +02:00
|
|
|
|
2008-11-15 11:54:39 +01:00
|
|
|
$verified = $GLOBALS['egw']->session->verify();
|
2001-08-21 20:34:56 +02:00
|
|
|
|
2015-07-17 08:29:22 +02:00
|
|
|
if(!($redirectTarget = $GLOBALS['egw']->session->appsession('referer', 'login')))
|
2008-11-15 11:54:39 +01:00
|
|
|
{
|
|
|
|
$redirectTarget = $GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=1&domain='.$GLOBALS['egw_info']['user']['domain'];
|
|
|
|
}
|
2015-07-17 08:29:22 +02:00
|
|
|
elseif(strpos($redirectTarget, '[?&]cd=') !== false)
|
|
|
|
{
|
|
|
|
$redirectTarget = preg_replace('/([?&])cd=[^&]+/', '$1cd=1', $redirectTarget);
|
|
|
|
}
|
2006-08-23 15:50:02 +02:00
|
|
|
|
2008-11-15 11:54:39 +01:00
|
|
|
if($verified)
|
|
|
|
{
|
|
|
|
$GLOBALS['egw']->hooks->process('logout');
|
|
|
|
$GLOBALS['egw']->session->destroy($GLOBALS['sessionid'],$GLOBALS['kp3']);
|
|
|
|
}
|
2014-07-12 12:11:53 +02:00
|
|
|
|
2008-11-15 11:54:39 +01:00
|
|
|
$GLOBALS['egw']->session->egw_setcookie('eGW_remember','',0,'/');
|
|
|
|
$GLOBALS['egw']->session->egw_setcookie('sessionid');
|
|
|
|
$GLOBALS['egw']->session->egw_setcookie('kp3');
|
|
|
|
$GLOBALS['egw']->session->egw_setcookie('domain');
|
2006-08-23 15:50:02 +02:00
|
|
|
|
2008-11-15 11:54:39 +01:00
|
|
|
if($GLOBALS['egw_info']['server']['auth_type'] == 'cas')
|
|
|
|
{
|
|
|
|
require_once('CAS/CAS.php');
|
2006-09-27 09:10:43 +02:00
|
|
|
|
2008-11-15 11:54:39 +01:00
|
|
|
phpCAS::client(CAS_VERSION_2_0,
|
|
|
|
$GLOBALS['egw_info']['server']['cas_server_host_name'],
|
|
|
|
(int) $GLOBALS['egw_info']['server']['cas_server_port'],
|
|
|
|
$GLOBALS['egw_info']['server']['cas_server_uri'] );
|
2011-12-09 11:55:40 +01:00
|
|
|
phpCAS::logout(array('url'=>$GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=1&domain='.$GLOBALS['egw_info']['user']['domain']));
|
2008-11-15 11:54:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// $GLOBALS['egw']->redirect($redirectTarget);
|
2008-03-09 15:37:57 +01:00
|
|
|
?>
|
|
|
|
<head>
|
|
|
|
<script language="javascript">
|
|
|
|
function clearAuthenticationCache(page)
|
2008-11-15 11:54:39 +01:00
|
|
|
{
|
|
|
|
// Default to a non-existing page (give error 500).
|
|
|
|
// An empty page is better, here.
|
|
|
|
if (!page) page = '.force_logout';
|
2008-03-09 15:37:57 +01:00
|
|
|
|
|
|
|
try
|
2008-11-15 11:54:39 +01:00
|
|
|
{
|
|
|
|
var agt=navigator.userAgent.toLowerCase();
|
2008-03-09 15:37:57 +01:00
|
|
|
if (agt.indexOf("msie") != -1)
|
2008-11-15 11:54:39 +01:00
|
|
|
{
|
|
|
|
// IE clear HTTP Authentication
|
|
|
|
document.execCommand("ClearAuthenticationCache");
|
|
|
|
}
|
2008-03-09 15:37:57 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
var xmlhttp;
|
|
|
|
if (window.XMLHttpRequest)
|
|
|
|
{
|
|
|
|
xmlhttp = new XMLHttpRequest();
|
|
|
|
}
|
|
|
|
else if (window.ActiveXObject)
|
2008-11-15 11:54:39 +01:00
|
|
|
{
|
|
|
|
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
2008-03-09 15:37:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-15 11:54:39 +01:00
|
|
|
// Let's prepare invalid credentials
|
|
|
|
xmlhttp.open("GET", page, true, "logout", "logout");
|
|
|
|
// Let's send the request to the server
|
|
|
|
xmlhttp.send("");
|
|
|
|
// Let's abort the request
|
|
|
|
xmlhttp.abort();
|
|
|
|
}
|
2008-03-09 15:37:57 +01:00
|
|
|
}
|
|
|
|
catch(e)
|
2008-11-15 11:54:39 +01:00
|
|
|
{
|
2008-03-09 15:37:57 +01:00
|
|
|
alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message);
|
2008-11-15 11:54:39 +01:00
|
|
|
// There was an error
|
|
|
|
return;
|
|
|
|
}
|
2008-03-09 15:37:57 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<meta http-equiv="refresh" content="1;url=<?php echo $redirectTarget ?>">
|
|
|
|
</head>
|
|
|
|
<body onload="clearAuthenticationCache()">
|
|
|
|
<a href="<?php echo $redirectTarget ?>">Logout in progress...</a>
|
|
|
|
</body>
|
|
|
|
|