]> git.nbdom.net Git - nb.git/commitdiff
Fix /help
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 14 Dec 2022 20:55:03 +0000 (21:55 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 14 Dec 2022 20:55:03 +0000 (21:55 +0100)
www/dbq/dbq.php

index eac80a7e183c79a749888a2932b29e88c260f29d..eb6c9a363d817e5680de193ae3b42d3e6e92129f 100644 (file)
@@ -1192,24 +1192,16 @@ EOF;
                foreach (['table','action','args'] as $k) { if (!empty($this->params[$k])) $arg[] = $this->params[$k]; }
                $arg = join('/',$arg);
 
-               ## NB 30.01.19: >>>>> 
-               ## NB 30.01.19: Test with config 
-               $conf_run = function($conf,$action) use ($arg) {
-                       foreach ($conf as $cmd) {
-                               $action_ = $cmd[0];
-                               $laius = $cmd[1];
-                               $fct = $cmd[2];
-                               $perm = empty($cmd[3]) ? 0 : $cmd[3];
-
-                               if ($action != $action_) continue;
-                               $this->deniedUnless(!$perm or $this->perm >= $perm);
-                               #debug($action_);
-                               $fct();
-                       }
+/*
+# NB 14.12.22: What use ???  
+               $conf = [];
+               $fct_help = function() use ($conf,$arg) {
+                       $this->page($this->db,$conf['root']);
                };
                $conf = [ 
                        'root' => [
-                               [ 'help', 'This help', function() { $this->page($this->db,$conf['root']); } ],
+                               [ 'help', 'This help', $fct_help ],
+                               # NB 14.12.22 [ 'help', 'This help', function() use ($conf) { $this->page($this->db,$conf['root']); } ],
                                [ 'ls', 'List configured databases', function() {
                                        $this->page($this->db,'ls',[],function(&$r){
                                                if ($this->perm < self::ADMIN) unset($r['host'],$r['type']);
@@ -1222,15 +1214,25 @@ EOF;
 # NB 30.01.19                          }, self::ADMIN ],
                        ],
                ];
-               $conf_run($conf['root'],$action);
-               ## NB 30.01.19: <<<<< 
-
+               #$conf['root'][0][2] = function() use ($conf) { $this->page($this->db,$conf['root']); };
+               foreach ($conf['root'] as $cmd) {
+                       $action_ = $cmd[0];
+                       $laius = $cmd[1];
+                       $fct = $cmd[2];
+                       $perm = empty($cmd[3]) ? 0 : $cmd[3];
+
+                       if ($action != $action_) continue;
+                       $this->deniedUnless(!$perm or $this->perm >= $perm);
+                       #debug($action_);
+                       $fct();
+               }
+*/
                if ($action == 'help') {
 
                        $this->page($this->db,[
                                [ 'help', 'This help' ],
                                [ 'ls', 'List configured databases' ],
-                               [ 'databases', 'List others databases' ],
+                               # NB 14.12.22 [ 'databases', 'List others databases' ],
                                [ 'random_str', 'Generate a random string' ],
                                [ 'ssha_password', 'Encrypt a password' ],
                                [ 'ssha512_password', 'Encrypt a password' ],
@@ -1278,6 +1280,10 @@ EOF;
                        }
                        $this->page($types);
 
+               # NB 14.12.22 } elseif ($action == 'databases') {
+                       # NB 14.12.22 $this->deniedUnless($this->perm >= self::ADMIN);
+                       # NB 14.12.22 $this->page($this->db->databases());
+
                } elseif ($action == 'ldap2') {
                        $table = $this->params['table'];
                        $attrs = ($this->params['action'] ? explode(',',$this->params['action']) : ['dn','objectClass']);