-
-
Notifications
You must be signed in to change notification settings - Fork 666
/
logout.php
52 lines (40 loc) · 1.15 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
<?php
require_once 'includes/common.inc.php';
global $redis, $config, $csrfToken, $server;
if (!empty($config['cookie_auth'])) {
// Cookie-based auth
setcookie('phpRedisAdminLogin', '', 1);
header("Location: login.php");
die();
} else {
// HTTP Digest auth
$needed_parts = array(
'nonce' => 1,
'nc' => 1,
'cnonce' => 1,
'qop' => 1,
'username' => 1,
'uri' => 1,
'response' => 1
);
$data = array();
$keys = implode('|', array_keys($needed_parts));
preg_match_all('/('.$keys.')=(?:([\'"])([^\2]+?)\2|([^\s,]+))/', $_SERVER['PHP_AUTH_DIGEST'], $matches, PREG_SET_ORDER);
foreach ($matches as $m) {
$data[$m[1]] = $m[3] ? $m[3] : $m[4];
unset($needed_parts[$m[1]]);
}
if (!isset($_GET['nonce'])) {
header('Location: logout.php?nonce='.$data['nonce']);
die;
}
if ($data['nonce'] == $_GET['nonce']) {
unset($_SERVER['PHP_AUTH_DIGEST']);
if (!empty($config['cookie_auth'])) {
$login = authCookie();
} else {
$login = authHttpDigest();
}
}
header('Location: logout.php');
}