From a7dfa165ba1b3763c5c47e1a8b8322716a1831b1 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 14 Dec 2022 21:55:03 +0100 Subject: [PATCH] Fix /help --- www/dbq/dbq.php | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index eac80a7e..eb6c9a36 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -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']); -- 2.47.3