]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorDevops <sys@15gifts.com>
Tue, 4 Apr 2017 12:54:45 +0000 (13:54 +0100)
committerDevops <sys@15gifts.com>
Tue, 4 Apr 2017 12:54:45 +0000 (13:54 +0100)
www/dbq/dbq.php

index 06c650f0fee834fe258c02bfe508bd9d7ad1f02f..30723237512ee15863fe8344835195d4b0b4cd43 100644 (file)
@@ -671,6 +671,7 @@ EOF;
         [ 'databases', 'List others databases' ],
         [ 'cryptkey', 'Generate a random encryption key' ],
         [ 'ssha_password', 'Encrypt a password' ],
+        [ 'logout', 'Clear Basic Auth' ],
         [ 'status', 'Status infos page' ],
       ],['command','description'],function(&$r) {
         $r['command'] = $this->page->tag('a',$r['command'],'href="'
@@ -688,6 +689,22 @@ EOF;
         $r['id'] = $this->page->tag('a',$r['id'],'href="'.$this->db->base.'/'.$r['id'].'.'.$this->ext.'"');
       });
 
+    } elseif ($action == 'logout') {
+      unset($_SERVER['PHP_AUTH_USER']);
+      unset($_SERVER['PHP_AUTH_PW']);
+      unset($_SERVER['REMOTE_USER']);
+      unset($_SERVER['REMOTE_PASSWORD']);
+      #header('HTTP/1.1 401 Access Denied');
+      if (empty($_REQUEST['realm'])) header('WWW-Authenticate: Basic');
+      else header('WWW-Authenticate: Basic realm="'.$_REQUEST['realm'].'"');
+      #echo '<html><head><title>401 Unauthorized</title><meta http-equiv="refresh" content="1"></head><body><h1>401 Unauthorized</h1><p>You are not allowed to see this page. Reload the page to try again.</p></body></html>';
+      header('HTTP/1.0 401 Unauthorized');
+      #header('Location: '.str_replace('//','//@',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/')));
+      header('Content-type: text/html');
+      echo '<meta http-equiv="refresh" content="0; url='.(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/').'">';
+      #if (!empty($_SERVER['PHP_AUTH_USER'])) header('Location: '.str_replace('//','//@',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/')));
+      exit;
+
     } elseif ($action == 'ssha_password') {
       $this->page($this,'ssha_password');