$this->out(self::$action_help,['action','description']);
$return = true;
- } elseif ($action == 'db.ryptkey') {
+ } elseif ($action == 'db.cryptkey') {
echo $this->out($this->cryptkey(),['key']);
} elseif ($action == 'db.exec') {
public $show_hidden_params = true;
public $show_buttons = true;
public $show_url_sort = true;
+ public $show_header = true;
public static $params = [ 'db', 'table', 'limit', 'debug', 'action'
, 'page', 'paged' # wordpress
];
// Add others
foreach ($opt as $k => $v) { $this->$k = $v; }
+ # NB 22.12.16: TODEL
+ if (!isset($this->show_header)) $this->show_header = (bool)$this->p('header');
+
}
/*
# Html
#
if (!isset($opt['is_html'])) $opt['is_html'] = preg_match('/^(table|div)$/',$format)
- ? ( $this->p('header')!=="0")
+ ? ( $this->show_header )
: false
;
} # < is_html
- if ($count === 0 and (
- $this->p('header') === 'force'
- or !$format
- )) {
+ if ($count === 0 and !$format) {
echo $this->{"rows_begin_$format"}($fields,$opt);
}
public function rows_begin_csv($fields) {
if (self::p('rows_head_char')!=='') echo self::p('rows_head_char');
- if ($this->p('header')==="0") return '';
+ if (!$this->show_header) return '';
return join(TABLE_CSV_SEP,array_keys($fields))."\n";
}
$html .= '<table class="rows wp-list-table widefat fixed striped">'.NB_EOL;
#if (!empty($opt)) $html .= '<caption>' . $this->nav($opt['count'],$opt['tot'],$opt['limit']) . '</caption>' .NB_EOL;
- if ($this->p('header')!=="0") {
+ if ($this->show_header) {
$html .= '<thead>'.NB_EOL.'<tr class="head">'.NB_EOL;
if ($this->buttons() and DB_HTML_EDIT) $html .= '<th class="edit"></th>'.NB_EOL;
}
#$opt['var']['rows']=[];
+ # Protect $_REQUEST !
$_REQUEST_BAK = $_REQUEST;
$_REQUEST = array_merge($_REQUEST,$ROW);
foreach (array_keys((array)$this) as $k) { if (isset($this->$k)) unset($this->$k); };
}
- /*
- * Function: p
- * Return a param
- */
- public static function p($name=null,$default=null) {
- if ($name === null) return isset($_REQUEST) ? $_REQUEST : [];
- return isset($_REQUEST[$name]) ? $_REQUEST[$name] : $default;
- }
-
/*
* Replace aliases by long name
*/
return self::p($name);
}
+ /*
+ * Function: p
+ * Return a param
+ */
+ public static function p($name=null,$default=null) {
+ if ($name === null) return isset($_REQUEST) ? $_REQUEST : [];
+ return isset($_REQUEST[$name]) ? $_REQUEST[$name] : $default;
+ }
+
/*
* Function: pset
* Set a value for param, delete it if null
*/
public static function pset($name,$value=null) {
+
+ # Brutal !
if (is_array($name)) return ($_REQUEST=$name);
+
+ # Delete key
if ($value === null or $value === '') {
unset ($_REQUEST[$name]);
return null;
}
+
+ # Set value
return ($_REQUEST[$name] = $value);
}
if (empty($_POST)) $_POST = $_REQUEST;
if (empty($_GET)) $_GET = $_REQUEST;
}
+
return $new_argv;
}
<?php
+// ownCloud Authentication
+
function oc_password_verify($pass) {
+
+ # NB 22.12.16: Change path too standards:
+ # - /var/lib/owncloud/config
+ # - /usr/share/owncloud/lib
+
require_once "/home/owncloud/config/config.php";
require_once '/opt/owncloud/lib/base.php';
require_once '/opt/owncloud/lib/private/Security/Hasher.php';
if ($is == 'html') return preg_match('/html$/',self::$content_type);
if ($is == 'xml') return preg_match('/xml$/',self::$content_type);
if ($is == 'xtml') return preg_match('/(x|ht)ml$/',self::$content_type);
- if ($is == 'text') return preg_match('/^text\//',self::$content_type);
- die("Db->is(): unknow argument '$is'. Accepted values are xhtml, html, xml");
+ if ($is == 'text' or $ls == 'txt') return preg_match('/^text\//',self::$content_type);
+ self::bye("Unknow argument '$is'. Accepted values are xhtml, html, xml, xtml, text|txt");
}
public static function path() {
charset utf-8;
- location / {
- try_files $uri $uri/ /index.php?$query_string;
- }
-
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
client_max_body_size 100m;
+ location ~ /\.ht {
+ deny all;
+ }
+
+ location / {
+ try_files $uri $uri/ /index.php?$query_string;
+ }
+
location ~ /index\.php$ {
#location index.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
-
- location ~ /\.ht {
- deny all;
- }
}
class DbQ extends nb {
+ public $perm = DBQ_PERM;
const ADMIN = 9;
const DELETE = 4;
const WRITE = 3;
const VIEW = 1;
- public $perm = DBQ_PERM;
- public $run = false;
- public $sep = ' / ';
public $title = DBQ_TITLE;
+ public $sep = ' / ';
- const PARAM_ARGS_SEP = '|';
- const PARAM_EXP = '[\w\._:-]{2,100}';
- const PARAM_DB_DEFAULT = DBQ_PARAM_DEFAULT;
-
+ const HTML_FORMAT = 'table';
+ const CLI_FORMAT = 'human';
public $formats = [
'table',
'csv',
'sh',
];
+
+ const PARAM_ARGS_SEP = '|';
+ const PARAM_EXP = '[\w\._:-]{2,100}';
+ const PARAM_DB_DEFAULT = DBQ_PARAM_DEFAULT;
public $params = [
'format' => DBQ_PARAM_FORMAT,
'db' => self::PARAM_DB_DEFAULT,
];
public $params_deep = [];
+ public $run = false; # call run() when __contruct
+
# NB 10.12.16 public $_colors = [
# NB 10.12.16 'body' => '#ddd',
# NB 10.12.16 'body-background' => '#009B9C',
form_clean(form);
form.submit();
}
+
function form_clean(form) {
var e;
for(i=0;i<form.length;i++) {
e.value = ""
}
}
+
function form_submit_clean(f) {
var i = 0;
var url = "";
window.location = url;
return false;
}
+
document.addEventListener("DOMContentLoaded", function() {
+
for (var e of document.querySelectorAll("form")) {
e.onsubmit = function() {
return form_submit_clean(this);
}
document.getElementById("table").removeAttribute("name");
document.getElementById("format").removeAttribute("name");
+
for (var e of document.querySelectorAll(".menu select.tables, .menu select.format")) {
e.onchange = function() {
var format = document.getElementById("format").value;
- if (format == "table") format = "html";
+ if (format == "'.self::HTML_FORMAT.'") format = "html";
window.location = "./" + document.getElementById("table").value + "." + format;
return false;
};
if (document.querySelector(".nav.bottom")) {
document.querySelector("table.rows").insertAdjacentHTML("beforebegin","<div class=\"nav top\">"+document.querySelector(".nav.bottom").innerHTML+"</div>");
}
+
});
');
+
$this->page->begin();
}
#die($obj);
#if (is_scalar($obj)) {
if(is_array($obj)) {
- $this->db->out($obj,$head,['row_parse_post'=>$fct]);
+ $this->db->out($obj,$head,['row_parse_post'=>$fct]);
+
} elseif (empty($meth)) {
echo $obj;
+
} elseif(is_array($meth)) {
- $this->db->out($meth,$head,['row_parse_post'=>$fct]);
+ $this->db->out($meth,$head,['row_parse_post'=>$fct]);
+
} else {
+ # Objects Method
$out = $obj->$meth();
if (!empty($out)) {
- #bye([$this->params['format'],$this->page->content_type()]);
+ # 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]);
}
+
}
if (empty($this->_nopage)) $this->page->end();
//
$rows[] = [ 'name' => $this->page->tag('h4','*APP'), 'value' => '' ];
//
- $rows[] = [
+ if ($this->client_content_type()) $rows[] = [
'name' => 'dbq.client_content_type',
'value' => $this->client_content_type(),
];
+ $rows[] = [
+ 'name' => 'dbq.page.content_type',
+ 'value' => $this->page->content_type(),
+ ];
$rows[] = [
'name' => 'dbq.params.format',
'value' => $this->params['format'],
];
+ if (0) $rows[] = [
+ 'name' => 'dbq.page.is.html',
+ 'value' => ($this->page->is('html') ? 1 : 0),
+ ];
//
$rows[] = [ 'name' => $this->page->tag('h4','*CLIENT HEADERS'), 'value' => '' ];
$format =
(!empty($_SERVER['HTTP_USER_AGENT']) and preg_match(DBQ_HUMAN_UA_EXP,$_SERVER['HTTP_USER_AGENT']))
? 'html'
- : 'human'
+ : self::CLI_FORMAT
;
}
$this->page->title = join($this->sep,$title);
$this->page->nav = $nav;
- if ($format == 'html') $format = 'table';
+ if ($format == 'html') $format = self::HTML_FORMAT;
$this->params['format'] = $format;
- $this->db->formats = $this->formats;
$this->db->format = $format;
+ if (!empty($this->formats)) $this->db->formats = $this->formats;
+
// Then content type
- if (empty($content_type)) $content_type = Mime::fromExt($format=='human' ? 'txt' : $format);
+ if (empty($content_type)) $content_type = Mime::fromExt($format==self::CLI_FORMAT ? 'txt' : $format);
if ($content_type) $this->page->content_type($content_type);
}
+ public function page_phpinfo() {
+ $txt = $this->page->is('html') ? 0 : 1;
+ if (1 or $txt) {
+ $rows = [];
+ $row = [];
+ $section = '';
+
+ foreach (explode("\n",$this->page->phpinfo()) as $line) {
+
+ if (preg_match(',<h2[^>]*>(.*?)</h2>,',$line,$m)) {
+ $section = strtoupper(strip_tags(preg_replace('/\W+/','_',$m[1])));
+
+ } elseif (preg_match_all(',<td>(.*?)</td>,',$line,$m)) {
+ $name = strip_tags($m[1][0]);
+ $value = isset($m[1][1]) ? strip_tags($m[1][1]) : '';
+
+ if (preg_match('/^\$_([A-Z_]+)\[["\']([^"\']+)["\']\]/',$name,$m)) {
+ $_section = $m[1];
+ $name = $m[2];
+ } else {
+ $_section = $section;
+ }
+
+ #debug($m);
+ $rows[] = [
+ 'section' => $_section,
+ 'name' => $name,
+ 'value' => $value,
+ ];
+
+ } else {
+ #debug($sec." ".$line);
+ }
+
+ }
+
+ return $this->page($rows);
+ return $rows;
+ exit;
+ }
+
+ #return $this->page->phpinfo();
+ return $this->page($this->page->phpinfo($txt));
+ }
+
public function run() {
#
} elseif ($this->perm < self::ADMIN) {
// NOW ONLY FOR ADMIN !
+
} elseif ($action == 'phpinfo') {
#$this->page(['phpinfo'=>$this->page->phpinfo(true)]);
- $this->page($this->page->phpinfo());
+ #$this->page($this->page->phpinfo());
+ #$this->page($this,'phpinfo');
+ $this->page_phpinfo();
} elseif (0
or $action == '_SERVER'
} elseif ($action == 'databases') {
$this->page($this->db,'databases');
+ } elseif ($action == 'dump') {
+ echo serialize($this->db->tables());
+ exit;
+ $this->page(array_values($this->db()->conf));
+
}
#
client_max_body_size 100m;
- ###############################################################
+ #--------------------------------------------------------------#
# Ignore
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
break;
}
- ###############################################################
+ #--------------------------------------------------------------#
# Deny
-# NB 13.12.16 location ~ /\. {
-# NB 13.12.16 deny all;
-# NB 13.12.16 access_log off;
-# NB 13.12.16 log_not_found off;
-# NB 13.12.16 }
+ location ~ /\.ht {
+ deny all;
+ }
- ###############################################################
+ #--------------------------------------------------------------#
# serve static files directly
#location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ {
# access_log off;
# expires 30d;
#}
- ###############################################################
+ #--------------------------------------------------------------#
# All to index.php
location / {
try_files $uri $uri/ /index.php?$query_string;
}
- ###############################################################
+ #--------------------------------------------------------------#
# FastCGI
- #location ~ \.php$ {
location ~ /index\.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
- #fastcgi_pass localhost:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ fastcgi_intercept_errors off;
+ fastcgi_buffer_size 16k;
+ fastcgi_buffers 4 16k;
+
fastcgi_param DBQ_CONF_FILE $document_root/../../../etc/dbq/000-local.php;
fastcgi_param DBQ_PERM 0;
fastcgi_param DBQ_PARAM_DEFAULT ls;
#fastcgi_param DBQ_TITLE 'Local Db';
- fastcgi_intercept_errors off;
- fastcgi_buffer_size 16k;
- fastcgi_buffers 4 16k;
}
}
max-width: 70%;
}
+div.row div label:after,
form label:after { content: ':'; }
form label,
}
table.rows,
-div.rows,
+div.row,
form.edit,
.menu,
.block,
}
-table.rows { padding: 0; }
-table.rows th, table.rows td { border-bottom: solid 1px #ccc; }
-table.rows tr:last-child td { border-bottom: none; }
+.rows { padding: 0; }
+div.row div, table.rows th, table.rows td { border-bottom: solid 1px #ccc; }
+div.row div, table.rows tr:last-child td { border-bottom: none; }
+div.row div {
+ margin: 0;
+}
+
+div.row div label {
+ padding: 0.1em 0.5em 0.1em 0;
+ min-width: 20%;
+ display: inline-block;
+}
.menu, .nav, .rows,
.buttons, .center {
opacity: 0.8;
}
-.menu { padding: 0.5em; width: 75%; }
+.menu { padding: 0.5em; }
form.menu .criterias {
border-top: dashed 1px #ccc;