public $formats = [ 'html','div.html','csv','xml','json','yaml','sh','sql','php' ];
public $format_cli = 'csv';
public $format_html = 'table';
- public $format_html_ua_exp = '/^\S+\s+.Windows|iPhone|Android|Macintosh|Linux/';
+ private $format_html_ua_exp = '/^\S+\s+.Windows|iPhone|Android|Macintosh|Linux/';
- public $hide_keys_exp = 'PHP_AUTH_DIGEST|PHP_AUTH_PW|PHP_AUTH_USER|REMOTE_PASSWORD|Authorization|HTTP_AUTHORIZATION';
- public $hide_keys_value = '****************';
+ private $hide_keys_exp = 'PHP_AUTH_DIGEST|PHP_AUTH_PW|PHP_AUTH_USER|REMOTE_PASSWORD|Authorization|HTTP_AUTHORIZATION';
+ private $hide_keys_value = '****************';
public $uri;
public $uri_params;
$arg = [];
foreach (['table','action','args'] as $k) { if (!empty($this->params[$k])) $arg[] = $this->params[$k]; }
$arg = join('/',$arg);
+ $help = array_merge(
+ [
+ [ 'help', 'This help' ],
+ [ 'ls', 'List configured 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' ],
+ [ 'random_str', 'Generate a random str' ],
+ [ 'logout', 'Clear Basic Auth' ],
+ [ 'status', 'Status infos page' ],
+ [ 'conf', 'Dump api infos and params' ],
+ [ 'types', 'Available mime types for output' ],
+ ],
+ (
+ ($this->perm < self::ADMIN) ? [] :
+ [
+ [ 'phpinfo', 'Phpinfo' ],
+ [ '_SERVER', 'Dump _SERVER' ],
+ [ '_REQUEST', 'Dump _REQUEST' ],
+ ]
+ )
+ );
if ($action == 'help') {
$this->page($this->db
# Rows
- ,array_merge(
- [
- [ 'help', 'This help' ],
- [ 'ls', 'List configured 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' ],
- [ 'ssha512_password', 'Encrypt a password' ],
- [ 'random_str', 'Generate a random str' ],
- [ 'logout', 'Clear Basic Auth' ],
- [ 'status', 'Status infos page' ],
- [ 'conf', 'Dump api infos and params' ],
- [ 'types', 'Available mime types for output' ],
- ],
- (
- ($this->perm < self::ADMIN) ? [] :
- [
- [ 'phpinfo', 'Phpinfo' ],
- [ '_SERVER', 'Dump _SERVER' ],
- [ '_REQUEST', 'Dump _REQUEST' ],
- ]
- )
- )
+ ,$help
# Head
,['command','description']
# Print
})
;
+ } elseif ($action == 'ls') {
+
+ $rows = [];
+ foreach ($this->db->ls() as $i) {
+ #$rows[] = [ 'id' => $i['id'], 'name' => $i['name'] ];
+ $rows[] = $i;
+ }
+
+ if ($this->perm >= self::ADMIN) {
+ #$rows[] = [ 'id' => '----------', 'name' => '----------' ];
+ foreach ($help as $i) {
+ if ($i[0] === 'ls') continue;
+ $rows[] = [
+ 'id' => $i[0],
+ 'name' => $i[0],
+ 'title' => $i[1],
+ 'type' => 'function',
+ 'host' => '',
+ ];
+ }
+ }
+
+ #$rows = $this->db->ls();
+ $this->page($rows,'',[],function(&$r){
+ if ($this->perm < self::ADMIN) unset($r['host'],$r['type']);
+ $r['id'] = $this->page->tag('a',$r['id'],'href="'.$this->db->base.'/'.$r['id'].'"');
+ });
+
} elseif ($action == 'ls') {
$this->page($this->db,'ls',[],function(&$r){
$action = $this->params['table'];
if (!$action and self::PARAM_DB_DEFAULT) $action = self::PARAM_DB_DEFAULT;
+ $help = [
+ [ 'help', 'This help' ],
+ [ 'status', 'Database status' ],
+ [ 'ls', 'List tables [type,name,count,fields]' ],
+ [ 'databases', 'List databases' ],
+ [ 'schema', 'Dump database structure only [/DB_TYPE]' ],
+ [ 'dump', 'Dump database structure with datas [/DB_TYPE]' ],
+ [ 'csv', 'Dump database data in csv with table name as first colum' ],
+ ];
+
if ($action == 'help') {
- $this->page($this->db,[
- [ 'help', 'This help' ],
- [ 'status', 'Database status' ],
- [ 'ls', 'List tables [type,name,count,fields]' ],
- [ 'databases', 'List databases' ],
- [ 'schema', 'Dump database structure only [/DB_TYPE]' ],
- [ 'dump', 'Dump database structure with datas [/DB_TYPE]' ],
- [ 'csv', 'Dump database data in csv with table name as first colum' ],
- ],['command','description'],function(&$r){
+ $this->page($this->db,$help,['command','description'],function(&$r){
$r['command'] = $this->page->tag('a',$r['command'],'href="'
.$this->db->base.'/'.($r['command'] == self::PARAM_DB_DEFAULT
? ''