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 = '|';
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
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);
}
}
}
$this->db = new Db(['conf'=>$DB_CONFS]);
$this->db->base = '/';
+
return $this->db;
}
'db' => $this->db,
'show_hidden_params' => false,
'show_buttons' => false,
+ 'show_header' => ($this->params['format'] == 'html'),
#'params' => [],
#'params' => [ 'limit' ],
]);
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;
$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',
];
//
- $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;
}
// 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);
$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' ],
} 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') {
}
#
- # 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' ],
#
# Table Init
#
+ $this->params['table'] = $action;
$this->table();
#
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);