Welcome to mirror list, hosted at ThFree Co, Russian Federation.

logout.php - github.com/erikdubbelboer/phpRedisAdmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 12cc80be5fd43f4dddb0fd389f776c34168408de (plain)
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');
}