}
function bye($msg='__bye__',$backtrace_deep=0) {
- #if ($msg) err($msg,'bye',$backtrace_deep === 0 ? 1 : $backtrace_deep);
-
- if ($msg!=='__bye__') {
- #throw new Exception($msg);
- err($msg,'bye',( $backtrace_deep !== false ? (1+-1+$backtrace_deep) : $backtrace_deep ));
- exit(1);
- }
-
- #if ($msg) err($msg,'bye',1+$backtrace_deep);
- exit;
- #die("Can't exit from BYE!!!");
+ return nb::bye($msg,$backtrace_deep);
}
function warn ($msg) {
return $id.' '.self::Status[$id];
}
- public function bye($id,$body_msg='') {
+ public function bye($status_code,$body_msg='') {
header('Content-type: text/plain');
- $msg = self::msg($id);
+ $msg = self::msg($status_code);
header((empty($_SERVER['SERVER_PROTOCOL']) ? 'HTTP/1.0' : $_SERVER['SERVER_PROTOCOL']).' '.$msg);
echo "$msg\n";
if (!empty($body_msg)) echo "$body_msg\n";
* Function: bye
* Set a value for param, delete it if null
*/
- public static function bye($msg='',$backtrace_deep=0) {
- #throw new Exception($msg);
- return bye($msg,$backtrace_deep+1);
+# NB 30.10.17 public static function bye($msg='',$backtrace_deep=0) {
+# NB 30.10.17 #throw new Exception($msg);
+# NB 30.10.17 return bye($msg,$backtrace_deep+1);
+# NB 30.10.17 }
+ # # NB 30.10.17: From function.php
+ public function bye($msg='__bye__',$backtrace_deep=0) {
+ #if ($msg) err($msg,'bye',$backtrace_deep === 0 ? 1 : $backtrace_deep);
+
+ if ($msg!=='__bye__') {
+ #throw new Exception($msg);
+ err($msg,'bye',( $backtrace_deep !== false ? (1+-1+$backtrace_deep) : $backtrace_deep ));
+ exit(1);
+ }
+
+ #if ($msg) err($msg,'bye',1+$backtrace_deep);
+ exit;
+ #die("Can't exit from BYE!!!");
}
/*
$args = $GLOBALS['dbq_args'];
$r = ['view' => join(' ',[
- '<a class="button select" href="'.$this->table->base.'/vi/'.$args.'/">View</a>'
+ '<a class="button select vi" href="'.$this->table->base.'/vi/'.$args.'/">View</a>'
]) ] + $r;
if ($this->perm < self::DELETE) return;
$rm = $this->table->base.'/rm/'.$args;
$r['delete'] = ''
.'<form action="'.$rm.'" method="post">'
- .'<a class="button" href="'.$rm.'" onclick="parentNode.submit();return false;">Delete</a>'
+ .'<a class="button rm" href="'.$rm.'" onclick="parentNode.submit();return false;">Delete</a>'
.$this->form_hidden($r)
.'</form>'
;
$rows[] = [ 'name' => 'server.'.$k, 'value' => $v ];
}
- // User
- if ($user = $this->logged()) {
- $rows[] = [ 'name' => 'user.name', 'value' => $user ];
- $rows[] = [ 'name' => 'user.perm', 'value' => $this->perm2h() ];
- }
-
// Client headers
foreach ($this->client_header() as $k=>$v) {
if ( preg_match('/^(' . $this->hide_keys_exp . ')$/', $k)) $v = $this->hide_keys_value;
+ if ($k == 'Host') continue;
$rows[] = [
'name' => 'client.header.'.$k,
'name' => 'dbq.page.is.html',
'value' => ($this->page->is('html') ? 1 : 0),
];
+ $user = '';
+ if (true or $user = $this->logged()) {
+ if ($user) $rows[] = [ 'name' => 'dbq.user.name', 'value' => $user ];
+ $rows[] = [ 'name' => 'dbq.user.perm', 'value' => $this->perm2h() ];
+ }
// Machine
- #if ($this->perm >= self::ADMIN) {}
+ if ($this->perm >= self::ADMIN)
if (function_exists('posix_uname')) {
foreach (posix_uname() as $k => $v) {
if ($k == 'domainname' and $v == '(none)') continue;
.'"');
});
- } elseif ($action == 'ls') {
+ } elseif ($action == 'ls' and $this->perm >= self::READ) {
$this->page($this,'table_rows');
} elseif ($action == 'fields') {
} elseif ($action == 'status') {
$this->page($this->table->status()+$this->table->status(['fields']));
- } elseif ($action == 'add') {
+ } elseif ($action == 'add' and $this->perm >= self::WRITE) {
$this->page($this,'table_html_add');
- } elseif ($action == 'vi') {
+ } elseif ($action == 'vi' and $this->perm >= self::READ) {
$this->page($this,'table_html_edit');
} elseif ($action == 'insert' and $this->perm >= self::WRITE) {
--- /dev/null
+index index.php index.html;
+
+charset utf-8;
+
+sendfile off;
+
+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; }
+
+#--------------------------------------------------------------#
+# Deny
+location ~ /\.ht { deny all; }
+
+#--------------------------------------------------------------#
+# All to index.php
+location / {
+ try_files $uri $uri/ /index.php?$query_string;
+}
+
+#--------------------------------------------------------------#
+# FastCGI
+
+location ~ /index\.php$ {
+ fastcgi_split_path_info ^(.+\.php)(/.+)$;
+ fastcgi_pass php-handler;
+ 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;
+
+ if ($DBQ_CONF_FILE = "") { set $DBQ_CONF_FILE $document_root/../../../etc/dbq/000-local.php; }
+ fastcgi_param DBQ_TITLE $DBQ_TITLE;
+ fastcgi_param DBQ_CONF_FILE $DBQ_CONF_FILE;
+ fastcgi_param DBQ_PERM $DBQ_PERM;
+}
+++ /dev/null
-index index.php index.html;
-
-charset utf-8;
-
-sendfile off;
-
-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; }
-
-#--------------------------------------------------------------#
-# Deny
-location ~ /\.ht { deny all; }
-
-#--------------------------------------------------------------#
-# All to index.php
-location / {
- try_files $uri $uri/ /index.php?$query_string;
-}
-
-#--------------------------------------------------------------#
-# FastCGI
-
-location ~ /index\.php$ {
- fastcgi_split_path_info ^(.+\.php)(/.+)$;
- fastcgi_pass php-handler;
- 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;
-}
});
-// NB 13.10.17 if (document.querySelector("h1")) {
-// NB 13.10.17 document.querySelector("h1 .table").insertAdjacentHTML("afterbegin",'zaza');
-// NB 13.10.17 }
-
if (document.querySelector(".nav.bottom") && document.querySelector("table.rows")) {
document.querySelector("table.rows").insertAdjacentHTML("beforebegin","<div class=\"nav top\">"+document.querySelector(".nav.bottom").innerHTML+"</div>");
}
+html{font:90% 'Trebuchet MS',sans-serif;background-color:#eee}body{display:table;margin-left:auto;margin-right:auto;padding-left:1em;padding-right:1em;color:#444}h1{margin:0 0 .2em 0;font-size:180%;padding-bottom:.3em;margin-bottom:.5em;border-bottom:dashed 1px #444}a{color:inherit}div>a,li a,p a,td a{color:#3572b0}a,a:visited{text-decoration:none}.button:hover,a:hover{opacity:.8}ul{padding:0;margin:0}li{list-style:none;padding:0 0 0 .3em}table{border-collapse:collapse}td,th{padding:.2em .7em}th a.sort{padding:0 .3em}input:not([type]),input[type=''],input[type=date],input[type=email],input[type=password],input[type=text],input[type=url],select,textarea{border-radius:3px;border:solid 1px #ddd;padding:.3em .4em;box-shadow:0 1px 1px #eee}input[size]{max-width:70%}div.row div label:after,form label:after{content:':'}form input,form label,form select{vertical-align:middle;margin:.2em .4em .2em 0}.block,.menu,div.row,form.edit,iframe,object,pre,table.rows,ul.row{border-radius:4px;border-spacing:0;padding:.5em .2em;margin-bottom:.5em;border:solid 1px #ddd;background-color:#fafafa;box-shadow:0 1px 2px #eee}.rows{padding:0}table.rows{border-style:hidden;border-collapse:collapse;box-shadow:0 0 0 1px #ddd;table-layout:fixed}table.rows.fixed{width:100%}table.rows tr:nth-child(even) td{background-color:#fefefe}div.row div,table.rows td,table.rows th,ul.row li{border-bottom:solid 1px #ddd}div.row div,table.rows tr:last-child td,ul.row li{border-bottom:none}table.rows td,table.rows th{border-right:dashed 1px #ddd}table.rows th{text-align:left}table.rows td{padding:.3em .3em}table.rows.fixed td{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}table.rows td.delete,table.rows td.view{width:1%;white-space:nowrap}table.rows.fixed th.view{width:2em}table.rows.fixed th.delete{width:2.7em}div.row div{margin:0}div.row div label,ul.row li label{padding:.1em .5em .1em 0;min-width:20%;display:inline-block}.button{font:inherit;display:inline-block;text-decoration:none;line-height:1.5em;cursor:pointer;border-radius:4px;white-space:nowrap;box-sizing:border-box;margin:0 .1em 0 0;cursor:pointer;padding:0 .3em;border:none;color:#3572b0;background-color:#eee;background:linear-gradient(to bottom right,#eee,#ddd);box-shadow:0 1px 1px #bbb}.buttons,.center,.menu,.nav,.rows,td.button{margin-left:auto;margin-right:auto;display:table}form.menu{padding:.5em;background-color:#fafafa}form.menu .button.add{float:right;margin-top:.3ex;display:inline}form.menu .criterias{border-top:dashed 1px #ddd;margin-top:.3em;padding-top:.3em}form.menu .criterias span.label{border-right:solid 1px #fff;padding:.2em .1em;margin:.2em .2em 0 0;border-radius:3px}form.menu .criterias span.label:last-child{border-right:none}form.menu select:focus{max-width:auto}form.menu select{max-width:20%}form.menu .criterias input[type=text]:focus{width:auto}form.menu .criterias input[type=text]{width:4em}form.edit .fields label{width:25%;text-align:right;display:inline-block;margin-right:1em;vertical-align:top}form.edit .fields .label span{width:54%;display:inline-block;text-align:left;vertical-align:middle;margin-top:.2em}form.Wedit .fields .label span input{vertical-align:bottom!important}form.edit .fields input[size],form.edit .fields select,form.edit .fields textarea{width:65%}
+function form_clean(e){var t;for(i=0;i<e.length;i++)"none"!=(t=e.elements[i]).style.display&&("text"==t.type?t.value="":!t.type.match(/^select/)||"limit"!=t.name&&"format"!=t.name||(t.selectedIndex=0))}function form_submit_clean(e){var t=0,n="",o=e.getAttribute("action");if("get"!=e.getAttribute("method"))return!0;for(t=0;t<e.length;t++){var r=e[t];r.name&&(""!=r.value&&"undefined"!=r.value&&(n+=(n?"&":"?")+encodeURI(r.name)+"="+encodeURI(r.value)))}return n=("?"==o?"":o)+n,e.reset(),window.location=n,!1}document.addEventListener("DOMContentLoaded",function(){NodeList.prototype.forEach=Array.prototype.forEach,document.querySelectorAll("form").forEach(function(e){e.onsubmit=function(){if(this.elements.limit){var e=this.elements.limit;"undefined"!=window._dbq.default_limit&&e.value==window._dbq.default_limit&&e.removeAttribute("value")}return form_submit_clean(this)}}),document.querySelectorAll("form.menu").forEach(function(e){e.setAttribute("action",window.location.toString().replace(/\?.*$/,"")),e.querySelectorAll("form.menu select.format").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["table.base"]+"."+this.value),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.tables").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["db.base"]+"/"+this.value+".html"),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.limit").forEach(function(e){e.onchange=function(){return this.form.onsubmit()}})}),document.querySelector(".nav.bottom")&&document.querySelector("table.rows")&&document.querySelector("table.rows").insertAdjacentHTML("beforebegin",'<div class="nav top">'+document.querySelector(".nav.bottom").innerHTML+"</div>"),document.querySelectorAll("table").forEach(function(e){parseInt(e.offsetWidth)>parseInt(window.innerWidth)&&(e.className=e.className.replace(/(^| +)fixed($| )/,"")+" fixed",e.className=e.className.trim())}),window._dbq.perm<window._dbq.perms.write&&(document.querySelectorAll("form.edit").forEach(function(e){e.setAttribute("onsubmit","return false")}),document.querySelectorAll("form.edit input[type=submit],form.edit input[type=reset]").forEach(function(e){e.setAttribute("style","display:none")})),document.querySelectorAll("form.menu input[type=submit]").forEach(function(e){e.insertAdjacentHTML("afterend",' <input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)" value="'+window._dbq["text.clear"]+'" />'+(window._dbq.perm>=window._dbq.perms.write?' <input type="button" class="add '+e.className+'" onclick="window.location=\''+window._dbq["table.base"]+'/add/\'" value="'+window._dbq["text.add"]+'"/>':""))})});