From: Nicolas Boisselier Date: Sat, 3 Dec 2016 21:22:11 +0000 (+0000) Subject: www/dbq X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=b14cece6201ca1381ac6554ab6832675fe2351e3;p=nb.git www/dbq --- diff --git a/etc/profile.d/mac.sh b/etc/profile.d/mac.sh index 4749e8db..395f054e 100644 --- a/etc/profile.d/mac.sh +++ b/etc/profile.d/mac.sh @@ -131,6 +131,7 @@ mac_install() { local os=$(mac_version) local vers="8.2_beta_2" open "http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_macOS_${os}_for_Xcode_${vers}/Command_Line_Tools_macOS_${os}_for_Xcode_${vers}.dmg" + return ;; virtualbox) @@ -138,8 +139,13 @@ mac_install() { ;; macport) + #prg="https://github.com"$(getexp_url '[^"]+'$(mac_version_name)'.*?pkg' "https://github.com/macports/macports-base/releases") prg=$(getexp_url 'https?://.*'$(mac_version_name)'[^"\s]+pkg' https://www.macports.org/install.php) + echo 'Please visit https://www.macports.org/install.php' + return + #echo ">$prg"; return; ;; + esac #echo ">$prg"; return @@ -152,7 +158,9 @@ mac_install() { #type mac_install|perl -ne '/^\s*([\w-_]+)\)/&&push(@a,$1);END{print join("|",@a)}' return ;; - *.pkg) udo installer -verbose -pkg "$prg" -target / ;; + *.pkg) + sudo installer -verbose -pkg "$prg" -target / + ;; *) local MOUNTDIR=$(echo `sudo hdiutil mount "$prg" | tail -1 | awk '{$1=$2=""; print $0}'` | xargs -0 echo) diff --git a/etc/profile.d/sys.sh b/etc/profile.d/sys.sh index 3560eecb..5d6522a1 100644 --- a/etc/profile.d/sys.sh +++ b/etc/profile.d/sys.sh @@ -1,6 +1,6 @@ case "$OSTYPE" in linux*) [ 1 ] ;; - *) return ;; + #*) return ;; esac sys_is_vm() { @@ -14,6 +14,10 @@ sys_watch() { watch --no-title $opt bash -c "sys_activity" } +sys_logs() { + true +} + sys_activity() { local tmp=/tmp/ @@ -21,13 +25,13 @@ sys_activity() { tmp="$tmp/$FUNCNAME.$$" netstat -autpn > $tmp.netstat - echo 'Load:' - w | head -1 - echo - - echo 'IO:' - iostat -c -m -d -x `df -hT -x tmpfs|perl -ane 'm:^/: and print $F[0]."\n"'` | tail -n +3 | grep -vFx ''| sed 's/^/ /' - echo + case "$OSTYPE" in + linux*) + echo 'IO:' + iostat -c -m -d -x `df -hT -x tmpfs|perl -ane 'm:^/: and print $F[0]."\n"'` | tail -n +3 | grep -vFx ''| sed 's/^/ /' + echo + ;; + esac echo 'Mem:' free -hm | sed 's/^/ /' @@ -37,13 +41,21 @@ sys_activity() { cat "$tmp.netstat" | tail -n +2 | awk '$5~/^[0-9]/{gsub(/:.*/,"",$5);print $5}' | sort | uniq -c| sed 's/^ *//'|sort -nr -k 1 |head | sed 's/^/ /' echo - echo 'dmeg:' - dmesg -T | tail | sed 's/^/ /' + echo 'dmesg:' + ( dmesg -T 2>/dev/null || dmesg ) | tail -4 | sed 's/^/ /' echo - echo 'auth:' - tail /var/log/auth.log | sed 's/^/ /' - echo + if [ -e /var/log/auth.log ]; then + echo 'auth:' + tail -2 /var/log/auth.log | sed 's/^/ /' + echo + fi + + if [ -e /var/log/system.log ]; then + echo 'system:' + tail -5 /var/log/system.log | sed 's/^/ /' + echo + fi rm -rf "$tmp"* } diff --git a/lib/php/db.php b/lib/php/db.php index 80eb96d8..9d995226 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -49,7 +49,6 @@ class Db extends nb { public $title; public $notice; public $type; - public $table; # table name public $tables = []; public $types = []; public $conf = []; @@ -380,7 +379,7 @@ class Db extends nb { */ public function table($name='',$params=[]) { #if (!array_key_exists($name,$this->tables)) { - if (!$name and !empty($this->table)) $name = $this->table; + if (!$name and !empty($this->default_table)) $name = $this->default_table; if (!$name) bye('table name is empty'); if (empty($this->tables[$name])) { $this->tables[$name] = new Table($name,['db'=>$this]+$params); @@ -1267,7 +1266,7 @@ class Db extends nb { } } public function page($opt=[]) { - return new Page([ + return new Page(array_merge([ 'title' => ($this->title ? $this->title : this::prettyText($this->name)), 'css' => [ 'css/*.css', @@ -1281,29 +1280,9 @@ class Db extends nb { 'nav' => [ [ (!empty($this) and !empty($this->title)) ? $this->title : 'Home', '/'], ( (!empty($this->table()) and !empty($this->table()->name)) ? [Page::prettyText($this->table()->name),Page::path().'?table='.urlencode($this->table()->name)] : '' ), - ( Page::p('action') ? Page::prettyText(Page::p('action')) : '' ), + ( Page::p('action') ? Page::prettyText(preg_replace('/^\w+\./','',Page::p('action'))) : '' ), ], - 'call' => array( - 'begin', - #['out', "Hello World !!!\n"], - - function($page){ - $this->pdef('format',$this->content_type2format($page->content_type())); - if (!$page->action()) return $this->action($this->p('action'),$this->table()); - }, - - function($page){ - #if (!$page->is('html')) return; - if (!empty($this)) echo $page->tag('p class="db-infos"',join(' | ',[ - $this->type, - $this->host, - ($this->name ? $this->name : null), - ])); - }, - - 'end', - ), - ]); + ],$opt)); } #public function default_table() { return $this->default_table; } diff --git a/www/dbq/etc/nginx/default.conf b/www/dbq/etc/nginx/default.conf index 66782431..9f614b03 100644 --- a/www/dbq/etc/nginx/default.conf +++ b/www/dbq/etc/nginx/default.conf @@ -5,13 +5,6 @@ server { 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; } - #access_log off; #error_log /var/log/nginx/error.log error; @@ -21,6 +14,34 @@ server { client_max_body_size 100m; + ############################################################### + # All to index.php + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + ############################################################### + # Ignore + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + + ############################################################### + # Deny + location ~ /\. { + deny all; + access_log off; + log_not_found off; + } + + ############################################################### + # serve static files directly + location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ { + access_log off; + expires 30d; + } + + ############################################################### + # FastCGI location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass php:9000; @@ -32,7 +53,4 @@ server { fastcgi_buffers 4 16k; } - location ~ /\.ht { - deny all; - } } diff --git a/www/dbq/html/index.php b/www/dbq/html/index.php index c2280d32..298c2d6d 100644 --- a/www/dbq/html/index.php +++ b/www/dbq/html/index.php @@ -1,6 +1,63 @@ 0 and $values[0]==='') { + array_shift($values); +} +#for ($i=count($values);$i>0 and $values[ require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/page.php'); +#debug($_SERVER['REQUEST_URI']); + +foreach ($values as $k=>$v) { + if ($v!=='') Page::pdef($params[$k],$v); +} + +Page::pdef('format','human'); Page::pdef('action','ls'); -require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/db/page.php'); + +require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/db/init.php'); +$Db->page([ + 'call' => [ + 'begin', + #['out', "Hello World !!!\n"], + + function($page) use($Db){ + if (!$page->action()) return $Db->action($Db->p('action'),$Db->table()); + }, + + function($page) use($Db){ + #global $values; debug($values); + if (!$page->is('html')) return; + if (!empty($Db)) echo $page->tag('p class="db-infos"',join(' | ',[ + $Db->type, + $Db->host, + ($Db->name ? $Db->name : null), + ])); + }, + + 'end', + ], +]); +#require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/db/page.php'); +# /DB/ACTION/[TABLE]/[FORMAT] +# /ACTION/DB/[TABLE]/[FORMAT] +#debug($_SERVER['REQUEST_URI']); +#debug($_SERVER['QUERY_STRING']); #debug($_SERVER); ?>