-
Notifications
You must be signed in to change notification settings - Fork 98
/
logout.php
executable file
·115 lines (102 loc) · 2.82 KB
/
logout.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* EGroupware - Logout
*
* @link http://www.egroupware.org
* @author Joseph Engo <[email protected]>
* @license http://opensource.org/licenses/lgpl-license.php LGPL - GNU Lesser General Public License
* @package api
* @subpackage authentication
* @version $Id$
*/
use EGroupware\Api;
$GLOBALS['egw_info'] = array(
'flags' => array(
'disable_Template_class' => True,
'currentapp' => 'logout',
'noheader' => True,
'nofooter' => True,
'nonavbar' => True
)
);
include('./header.inc.php');
$GLOBALS['sessionid'] = Api\Session::get_sessionid();
$GLOBALS['kp3'] = Api\Session::get_request('kp3');
$verified = $GLOBALS['egw']->session->verify();
if(!($redirectTarget = Api\Cache::getSession('login', 'referer')))
{
$redirectTarget = $GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=1&domain='.$GLOBALS['egw_info']['user']['domain'];
}
elseif(strpos($redirectTarget, '[?&]cd=') !== false)
{
$redirectTarget = preg_replace('/([?&])cd=[^&]+/', '$1cd=1', $redirectTarget);
}
if ($verified)
{
$auth = new Api\Auth();
// remove remember me cookie on explicit logout, unless it is a second factor
if ($GLOBALS['egw']->session->removeRememberMeTokenOnLogout())
{
Api\Session::egw_setcookie('eGW_remember','',0,'/');
}
Api\Hooks::process('logout');
$GLOBALS['egw']->session->destroy($GLOBALS['sessionid'],$GLOBALS['kp3']);
}
Api\Session::egw_setcookie('sessionid');
Api\Session::egw_setcookie('kp3');
Api\Session::egw_setcookie('domain');
// SSO Logout (does not return for SSO systems)
if (isset($auth)) $auth->logout();
// $GLOBALS['egw']->redirect($redirectTarget);
?>
<head>
<script language="javascript">
function clearAuthenticationCache(page)
{
// Default to a non-existing page (give error 500).
// An empty page is better, here.
if (!page) page = '.force_logout';
try
{
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("msie") != -1)
{
// IE clear HTTP Authentication
document.execCommand("ClearAuthenticationCache");
}
else
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
return;
}
// 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();
}
}
catch(e)
{
alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message);
// There was an error
return;
}
}
</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>