From: Nicolas Boisselier Date: Sun, 25 Dec 2016 03:22:06 +0000 (+0000) Subject: Bed X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=0d2c07043df80fba8b35a1436b070139b0c76df1;p=nb.git Bed --- diff --git a/lib/php/out.php b/lib/php/out.php index 5ce0c058..d716404d 100644 --- a/lib/php/out.php +++ b/lib/php/out.php @@ -134,7 +134,7 @@ Class Out extends Nb { 'tag' => 'div', 'tag_key' => 'label', 'row' => 'out_tag', - 'head' => 'out_tag_head', +# NB 25.12.16 'head' => 'out_tag_head', ), 'center' => array( @@ -143,7 +143,7 @@ Class Out extends Nb { 'tag_enclose' => 'div class="row"', 'tag' => 'div', 'row' => 'out_tag', - 'head' => 'out_tag_head', +# NB 25.12.16 'head' => 'out_tag_head', ), 'table' => array( diff --git a/lib/php/page.php b/lib/php/page.php index f636b100..26113fe7 100644 --- a/lib/php/page.php +++ b/lib/php/page.php @@ -318,7 +318,7 @@ class Page extends nb { if ( empty($this->title) and !empty($title) ) $this->title = join($this->sep,$title); if ( empty($this->h1) and !empty($html) ) $this->h1 = join($this->sep,$html); if ( empty($this->h1) and !empty($this->title) ) $this->h1 = $this->title; - if (self::is('xtml')) { + if (self::is('html')) { echo $this->head(); @@ -337,10 +337,10 @@ class Page extends nb { public static function end() { - if (self::is('xtml')) { + if (self::is('html')) { self::tag_end(); echo '' . NB_EOL; - if (preg_match('/html$/',self::$content_type)) echo '' . NB_EOL; + echo '' . NB_EOL; } } diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 9227aef9..9819a2c6 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -25,7 +25,7 @@ class DbQ extends nb { const HTML_FORMAT = 'table'; const CLI_FORMAT = 'human'; public $human_ua_exp = '/^\S+\s+.Windows|iPhone|Android|Macintosh|Linux/'; - public $formats = []; + public $formats = []; # for Db web list const PARAM_ARGS_SEP = '|'; @@ -102,29 +102,38 @@ class DbQ extends nb { public function page($obj,$meth=null,$head=[],$fct=null) { + // Write output + if (empty($this->_nopage)) { - // Write output + $this->page->headers_no_cache(); $this->page->js = $this->js; - $this->page->js_code = trim(' -window._dbq = { - "HTML_FORMAT": "'.self::HTML_FORMAT.'" -}; - '); + $this->page->js_code = 'window._dbq = ' + . json_encode([ + 'HTML_FORMAT' => self::HTML_FORMAT, + 'param.format' => $this->params['format'], + 'param.db' => $this->params['db'], + 'param.table' => $this->params['table'], + 'param.action' => $this->params['action'], + 'param.args' => $this->params['args'], + ]) + .''; $this->page->begin(); } #die($obj); #if (is_scalar($obj)) { + $conf = ['row_parse_post'=>$fct]; + if(is_array($obj)) { - $this->db->out($obj,$head,['row_parse_post'=>$fct]); + $this->db->out($obj,$head,$conf); } elseif (empty($meth)) { echo $obj; } elseif(is_array($meth)) { - $this->db->out($meth,$head,['row_parse_post'=>$fct]); + $this->db->out($meth,$head,$conf); } else { # Objects Method @@ -132,10 +141,8 @@ window._dbq = { if (!empty($out)) { # bye([$this->params['format'],$this->page->content_type()]); #bye($out); array_shift($out); - #self::pdef('header',$this->page->is('xtml')); - #self::pdef('header',0); - self::pdef('header',(string)preg_match('/html/',$this->params['format'])); - $this->db->out($out,$head,['row_parse_post'=>$fct]); + + $this->db->out($out,$head,$conf); } } @@ -189,6 +196,7 @@ window._dbq = { } $this->db = new Db(['conf'=>$DB_CONFS]); $this->db->base = '/'; + return $this->db; } @@ -264,6 +272,7 @@ window._dbq = { 'db' => $this->db, 'show_hidden_params' => false, 'show_buttons' => false, + 'show_header' => ($this->params['format'] == 'html'), #'params' => [], #'params' => [ 'limit' ], ]); @@ -308,10 +317,12 @@ window._dbq = { public function uri_params() { $values = []; + $path = ''; + $args = ''; if (empty($_SERVER['REQUEST_URI'])) $_SERVER['REQUEST_URI'] = join('/',( count($GLOBALS['argv'])>0 ) ? array_slice($GLOBALS['argv'],1) : []); - list ($path,$args) = explode('?',$_SERVER['REQUEST_URI']); + list ($path,$args) = strpos($_SERVER['REQUEST_URI'],'?') ? explode('?',$_SERVER['REQUEST_URI']) : [$_SERVER['REQUEST_URI'],'']; $this->uri = $path; $this->uri_params = $args; @@ -394,7 +405,7 @@ window._dbq = { $rows = []; // - $rows[] = [ 'name' => $this->page->tag('h4','*APP'), 'value' => '' ]; +# NB 25.12.16 $rows[] = [ 'name' => $this->page->tag('h4','*APP'), 'value' => '' ]; // if ($this->client_content_type()) $rows[] = [ 'name' => 'dbq.client_content_type', @@ -414,23 +425,45 @@ window._dbq = { ]; // - $rows[] = [ 'name' => $this->page->tag('h4','*CLIENT HEADERS'), 'value' => '' ]; +# NB 25.12.16 $rows[] = [ 'name' => $this->page->tag('h4','*CLIENT HEADERS'), 'value' => '' ]; // + foreach ([ + 'addr', + ] as $k) { + $v = 'REMORE_'.strtoupper($k); + $v = isset($_SERVER[$v]) ? $_SERVER[$v] : ''; + if ($v==='') continue; + $rows[] = [ 'name' => 'server.'.$k, 'value' => $v ]; + } foreach ($this->client_header() as $k=>$v) $rows[] = [ - 'name' => $k, + 'name' => 'client.header.'.$k, 'value' => ( is_scalar($v) ? $v : json_encode($v) ), ]; // - $rows[] = [ 'name' => $this->page->tag('h4','*SERVER HEADERS'), 'value' => '' ]; +# NB 25.12.16 $rows[] = [ 'name' => $this->page->tag('h4','*SERVER HEADERS'), 'value' => '' ]; + // + foreach ([ + 'addr', + 'port', + 'software', + ] as $k) { + $v = 'SERVER_'.strtoupper($k); + $v = isset($_SERVER[$v]) ? $_SERVER[$v] : ''; + if ($v==='') continue; + $rows[] = [ 'name' => 'server.'.$k, 'value' => $v ]; + } foreach (headers_list() as $v) { list($k,$v) = explode(': ',$v); $rows[] = [ - 'name' => $k, + 'name' => 'server.header.'.$k, 'value' => ( is_scalar($v) ? $v : json_encode($v) ), ]; } + + // + return $rows; } @@ -463,6 +496,7 @@ window._dbq = { // Then content type if (empty($content_type)) $content_type = Mime::fromExt($format==self::CLI_FORMAT ? 'txt' : $format); + if (empty($content_type) and $this->db->out->is_html($format)) $content_type = 'text/html'; if (empty($content_type)) $content_type = 'text/plain'; if ($content_type) $this->page->content_type($content_type); @@ -527,9 +561,11 @@ window._dbq = { $this->init(); # - # Root actions pre conn + # Actions pre Db # $action = $this->params['db']; + #$this->params = [ 'action' => $action ]; + if ($action == 'help') { $this->page($this->db,[ [ 'help', 'This help' ], @@ -543,7 +579,6 @@ window._dbq = { } elseif ($action == 'ls') { $this->page($this->db,'ls',[],function(&$r){ $r['id'] = $this->page->tag('a',$r['id'],'href="'.$this->db->base.$r['id'].'.'.$this->ext.'"'); - #$r['id'] = $this->page->tag('a',$r['id'],'href="'.$r['id'].'.'.$this->ext.'"'); }); } elseif ($action == 'cryptkey') { @@ -574,14 +609,17 @@ window._dbq = { } # - # Connections + # Db Connections # + $this->params['db'] = $action; $this->db(true); # # Db actions # $action = $this->params['table']; + $this->params['table'] = ''; + if ($action == 'help') { $this->page($this->db,[ [ 'help', 'This help' ], @@ -612,6 +650,7 @@ window._dbq = { # # Table Init # + $this->params['table'] = $action; $this->table(); # @@ -648,7 +687,7 @@ window._dbq = { header('Location: '.$this->table->base); } elseif ($action == 'update' and $this->perm >= self::WRITE) { - # NB 19.12.16: TODO NOT WORKING using replace + # NB 19.12.16: TODO NOT WORKING with update using replace if (!$this->table->replace($_POST,$info)) $this->error('update: '.print_r($info,true)); header('Location: '.$this->table->base);