]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 24 Nov 2017 03:51:25 +0000 (03:51 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 24 Nov 2017 03:51:25 +0000 (03:51 +0000)
www/dbq/dbq.php

index b332cc00d961af98abcb81359ba3c18bc1d50c92..5a4cd3e0af71368cb7a19892f077ff39f0f9ae53 100644 (file)
@@ -133,9 +133,9 @@ class DbQ extends nb {
     if ($run) $this->run();
   }
 
-  public function json() {
+  public function conf() {
     $rows = [];
-    foreach ($this->json as $k=>$v) $rows[] = ['name'=>$k,'value'=>$v];
+    foreach ($this->conf as $k=>$v) $rows[] = ['name'=>$k,'value'=>$v];
     return $rows;
   }
 
@@ -161,7 +161,7 @@ class DbQ extends nb {
 
       $this->page->headers_no_cache();
       $this->page->js = $this->js;
-      $this->json = [
+      $this->conf = [
         'db.base' => ( empty($this->db) ? '' : $this->db->base ),
         'table.base' => ( empty($this->table) ? '' : $this->table->base ),
         'default.format' => $this->format_html,
@@ -177,7 +177,7 @@ class DbQ extends nb {
         'perm' => $this->perm,
         'perms' => $this->perms,
       ];
-      $this->page->js_code = 'window._dbq = '.json_encode($this->json);
+      $this->page->js_code = 'window._dbq = '.json_encode($this->conf);
 
 # NB 22.05.17       if (is_scalar($obj) and $obj != 'logout') {
       if ($obj != 'logout') {
@@ -242,7 +242,7 @@ class DbQ extends nb {
         and $connect === true
       ) {
         if (empty($this->db->conf[$this->params['db']]))
-          $this->not_found('Unknown database: '.$this->params['db']);
+          $this->not_found('Unknown db: '.$this->params['db']);
         $connect = $this->db->conf[$this->params['db']];
       }
 
@@ -310,8 +310,7 @@ class DbQ extends nb {
 
     # NB 23.11.17: Handle format for /vi/ 
     if ($this->params['format'] != $this->format_html) {
-      #bye([$this->format_cli,$this->params['format']]);
-      if ($this->params['format'] == $this->format_cli) $this->db->format = $this->params['format'] = 'txt';
+
       $row = $this->db->query2h($this->table->sql_edit($values));
       if ($fields) {
         foreach ($row as $k=>$v) {
@@ -319,7 +318,8 @@ class DbQ extends nb {
         }
       }
 
-      $this->db->out->header(false);
+      if ($this->params['format'] == $this->format_cli) $this->db->format = $this->params['format'] = 'txt';
+      $this->db->out->header($this->p('header',false));
       $this->db->out($row);
       return;
     }
@@ -882,7 +882,8 @@ EOF;
         [ 'ssha512_password', 'Encrypt a password' ],
         [ 'logout', 'Clear Basic Auth' ],
         [ 'status', 'Status infos page' ],
-        [ 'json', 'Dump json infos' ],
+        [ 'conf', 'Dump json infos' ],
+        [ 'types', 'Available mime types' ],
       ] + (
         ($this->perm < self::ADMIN) ? [] :
       [
@@ -910,28 +911,21 @@ EOF;
         $r['id'] = $this->page->tag('a',$r['id'],'href="'.$this->db->base.'/'.$r['id'].'"');
       });
 
-    } elseif ($action == 'logout') {
-
-      #$this->logout();
-      $this->page($this,'logout');
-
-    } elseif ($action == 'ssha_password') {
-      $this->page($this,'ssha_password');
-
-    } elseif ($action == 'ssha512_password') {
-      $this->page($this,'ssha512_password');
-
-    } elseif ($action == 'cryptkey') {
-      $this->page($this->db,'cryptkey',['key']);
-
-    } elseif ($action == 'status') {
-      $this->page($this,'status');
-
-    } elseif ($action == 'json') {
-      $this->page($this,'json');
+    } elseif ($action == 'logout') { $this->page($this,'logout'); 
+    } elseif ($action == 'ssha_password') { $this->page($this,'ssha_password');
+    } elseif ($action == 'ssha512_password') { $this->page($this,'ssha512_password');
+    } elseif ($action == 'cryptkey') { $this->page($this->db,'cryptkey',['key']);
+    } elseif ($action == 'status') { $this->page($this,'status');
+    } elseif ($action == 'conf') { $this->page($this,'conf');
+    } elseif ($action == 'types') {
+      $types = [];
+      foreach (array_keys($this->db->out->types()) as $type) {
+        $types[] = [ 'type' => $type ];
+      }
+      $this->page($types);
 
+    // NOW ONLY FOR ADMIN !
     } elseif ($this->perm < self::ADMIN) {
-      // NOW ONLY FOR ADMIN !
 
     } elseif ($action == 'phpinfo') {
       $this->rows_table($action,$this->phpinfo_rows());