# NB 09.04.16 'h' => 'header',
);
-## Vim: r!% --curl_help_hash | grep X
my @H;
my %CURL_OPT = (
+#>_SHELL_REPLACE dbq --curl_help
'compressed|z!' => 1, # Request compressed response (using deflate or gzip)
'dump-header|D=s' => undef, # FILE Write the headers to FILE
'get|G!' => undef, # Send the -d data with a HTTP GET (H)
'insecure|k!' => undef, # Allow connections to SSL sites without certs (H)
'user-agent|A=s' => undef, # STRING User-Agent to send to server (H)
'user|u=s' => undef, # USER[:PASSWORD] Server user and password
+#<_SHELL_REPLACE
);
my @CURL_OPT = keys %CURL_OPT;
my $CURL_OPT_EXP = join('|',map{ /^(.*?)\|/ ? $1 : $_ } @CURL_OPT);
dbq2pgsql() {
dbq f=txt a=db.dump db.type=pgsql $@
}
+
+dbq_data_src() {
+ eval $(dbq t=data_src header=0 format=csv rows.fields=src name=$1)
+}
echo "Can't find web client" 1>&2
fi
}
-alias Get=http_get
+# NB 07.01.17 alias Get=http_get
http_head() {
if which curl 1>/dev/null; then
public function html_edit($value,$type=null) {
$size = ($this->size() and is_scalar($this->size())) ? $this->size() : 0;
- $tag = ( ($size>$this->textarea_size) or preg_match('/^(text|binary)/i',$this->type) ) ? 'textarea' : 'input';
+ $tag = ( ($size>$this->textarea_size) or preg_match('/^(text|binary|blob)/i',$this->type) ) ? 'textarea' : 'input';
return '<div class="label '.$this->name.'"><label for="'.$this->name.'">'.htmlspecialchars(prettyText($this->name)).'</label>'
.($this->extras
? '<span class="extra" id="'.$this->name.'">'.$this->out($value).'</span>'
: '<'.$tag
.' name="'.$this->name.'"'
.' id="'.$this->name.'"'
- .( $size ? ' size="'.$size.'"' : '')
+ .( ($size and $tag != 'textarea') ? ' size="'.$size.'"' : '')
#.' value="'.$value.'"'
.($tag == 'textarea' ? '>'.$value.'</textarea>' : ' type="'
.($type ? $type : $this->html_type())
}
# NB 22.12.16: TODEL
- $this->show_header =
- (bool)$this->p('header',$this->show_header)
- ;
- # TODE FOR out::
+ $this->show_header = (bool)$this->p('header',$this->show_header);
+
+ # TODEL WHEN NOT NEEDED ????
$this->pdef('header',$this->show_header);
+ #bye((int)$this->show_header);
}
# Run query
#
$this->create_temporary();
+
+ $this->show_header = (bool)$this->p('rows.header',$this->show_header);
$this->db()->out->header($this->show_header);
+ # TODEL WHEN NOT NEEDED ????
+ $this->pdef('header',$this->show_header);
if ($opt_by_val !== null) $opt = $opt_by_val;
'525' => 'SSL Handshake Failed',
'526' => 'Invalid SSL Certificate',
'527' => 'Railgun Error',
+'103' => 'Checkpoint',
+'419' => 'I',
#<SHELL_REPLACE
];
protected static $header = true;
public static function init() {
- self::$header =
- (bool)self::p('header',self::$header)
- ;
+ self::$header = (bool)self::p('header',self::$header);
+ #self::$header = (bool)self::p('out.header',self::$header);
+
self::$types = [
'sql' => [], # Code still in db/table.php !
foreach ($r as $k=>$v) {
if (!preg_match('/^[a-zA-Z\w_]+$/',$k)) continue;
$v = str_replace('"','\\"',$v);
+ $v = str_replace('$','\\$',$v);
+ $v = str_replace('`','\\`',$v);
$line[] = $o['preff']."$k=\"$v\"";
}
if ($line) echo join(' ',$line).";\n";
foreach ([
'charset',
'type',
+ 'header',
] as $k) {
if (isset($opt[$k])) self::$k($opt[$k]);
unset($opt[$k]);
}
public static function charset($set=null) { if (!empty($set)) self::$charset = $set; return self::$charset; }
+ public static function type($set=null) { if (!empty($set)) self::$type = $set; return self::$type; }
+ public static function header($set=null) { if (!empty($set)) self::$header = $set; return self::$header; }
public static function types($type=null) {
if ($type === '_web_') return array_filter(self::$types,function($v){return !isset($v['_web_']) or (bool)$v['_web_'];});
return self::$types;
}
- public static function type($set=null) { if (!empty($set)) self::$type = $set; return self::$type; }
- public static function header($set=null) { if (!empty($set)) self::$header = $set; return self::$header; }
-
public static function scalar($v) {
if ($v === null) return '';
if (is_scalar($v)) return $v;
--- /dev/null
+--DROP TABLE IF EXISTS service;
+CREATE TABLE IF NOT EXISTS service (
+ name VARCHAR(100),
+ description VARCHAR(200),
+ PRIMARY KEY (port,name)
+);
+
+--DROP TABLE IF EXISTS service_port;
+DROP TABLE IF EXISTS service_port;
+DROP TABLE IF EXISTS port;
+CREATE TABLE IF NOT EXISTS port (
+ port INT,
+ proto VARCHAR(3),
+ name VARCHAR(100),
+ PRIMARY KEY (port,proto,name),
+ FOREIGN KEY(name) REFERENCES service(name)
+);
+
+--DROP TABLE IF EXISTS http_status;
+CREATE TABLE IF NOT EXISTS http_status (
+ id int PRIMARY KEY,
+ name varchar(100),
+ description varchar(1000)
+);
+
+DROP TABLE IF EXISTS shell_function;
+CREATE TABLE shell_function (
+ name VARCHAR(255) PRIMARY KEY,
+ code BLOB
+);
#!/usr/bin/env bash --login
-set -e
-cd "$(dirname "$0")"
+set +e
+dir=$(dirname "$0")
+tmp=`mktemp -d`
+
+csv2table() {
+ local name="$1"; shift
+ local file="$1"; shift
+
+ cat << EOF
+DELETE FROM _var;
+DROP TABLE IF EXISTS ${name}_tmp;
+CREATE TEMPORARY TABLE ${name}_tmp AS SELECT * FROM $name WHERE 0;
+
+INSERT INTO _var VALUES('pre',(SELECT count(*) FROM ${name}));
+
+-- SELECT 'Update $name ('||(SELECT count(*) FROM ${name})||')';
+
+BEGIN TRANSACTION;
+.import "$file" ${name}_tmp
+COMMIT;
+INSERT INTO _var VALUES('import',(SELECT count(*) FROM ${name}_tmp));
+
+INSERT OR IGNORE INTO $name SELECT * FROM ${name}_tmp;
+INSERT INTO _var VALUES('post',(SELECT count(*) FROM ${name}));
+
+SELECT 'Update sys:$name ('
+ || ((SELECT v FROM _var WHERE k='post')-(SELECT v FROM _var WHERE k='pre'))
+ || '/'
+ ||(SELECT v FROM _var WHERE k='import')
+||')'
+||' = ('||(SELECT count(*) FROM ${name})||')'
+;
+EOF
+}
+
+data_src() {
+ #pwd
+
+ perl -ne 'm,^(\w+)\s+\d+/\w+\s+#\s*(.*?)$, and $_=join(qq|\t|,map(/^\s*(.*?)\s*$/,$1,$2)).qq|\n| and !$h{$_}++ and print' \
+ /etc/services \
+ > "$tmp/service.csv"
+ csv2table service "$tmp/service.csv"
+
+ perl -ne 'm,^(\w+)\s+(\d+)/(\w+)\s+#\s*(.*?)$, and print join(qq|\t|,map(/^\s*(.*?)\s*$/,$2,$3,$1)).qq|\n|' \
+ /etc/services \
+ > "$tmp/port.csv"
+ csv2table port "$tmp/port.csv"
+
+ return 0
+ w3m -dump -cols 999999 https://en.wikipedia.org/wiki/List_of_HTTP_status_codes| \
+ perl -ne 'next unless /^\d\d\d / .. /^ /;s/.\[\d+\]//g; s/^ *//; s/^(\d+) ([\w _-]+).*?\n$/$1\t$2\t/;print' \
+ > "$tmp/http_status.csv"
+ csv2table http_status "$tmp/http_status.csv"
+
+ curl -s http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml \
+ > "$tmp/adservers.csv"
+ csv2table adservers "$tmp/adservers.csv"
+
+ curl -s 'http://www.user-agents.org/' | perl -e '$_=join(qq||,<>); print map {s/^\s*(.*?)(?:.nbsp.)?\s*$/$1/;qq|$_\n|} m,<td class=.right.>([^<]+),g'
+ > "$tmp/useragent.csv"
+ csv2table useragent "$tmp/useragent.csv"
+
+}
+
(
+cat "$dir/sys.sql"
cat << EOF
PRAGMA foreign_keys=OFF;
-BEGIN TRANSACTION;
+.separator \t
+CREATE TEMPORARY TABLE _var (k varchar(10),v varhcar(10));
-SELECT 'Update sys.shell_function';
-`shell_functions2sql shell_function`
+`data_src`
+SELECT 'Update sys:shell_function';
+BEGIN TRANSACTION;
+`shell_functions2sql shell_function`
COMMIT;
+
+VACUUM;
EOF
-) | sqlite3 sys.db
+) | sqlite3 "$dir/sys.db"
+
+#cp -a "$tmp/" /Users/nico/Downloads/commit/
+rm -rf "$tmp"
-IFS=$'\n'
-for f in $(grep -lrI SHELL_REPLACE $NB_ROOT); do
+for f in $(grep -ErlI '^.{1,3}<SHELL_REPLACE' $NB_ROOT); do
- echo "Update $f"
+ echo "Update $f" | sed "s; $NB_ROOT/; ;"
shell_replace -i "$f"
done
EXPOSE 9000
#CMD ["/usr/local/bin/php", "-a"]
+#ENTRYPOINT printf "[www]\n\nuser = $USER\n" > /usr/local/etc/php-fpm.d/www.conf.default && /usr/local/sbin/php-fpm
ENTRYPOINT /usr/local/sbin/php-fpm
public $uri_params;
public $param_args_sep = '|';
public $param_exp_value = '[\w\._:-]{2,100}';
+ const ACTIONS_NO_TITLE = ['ls','vi'];
const PARAM_DB_DEFAULT = 'ls';
public $params = [
'format' => '',
if (!$keys) $keys = $all;
$keys = array_keys($keys);
- $values = explode($this->param_args_sep,$this->params['args']);
+ $values = $add ? array_fill(0,count($keys),'') : explode($this->param_args_sep,$this->params['args']);
$this->table->html_edit(array_combine($keys,$values),$this->table->base.($add ? 'insert/' : 'update/').$this->params['args'],$add);
}
$params = $this->params;
$ext = $this->ext;
- /*
- $title = array_unique(array_slice(array_values($params),1));
- */
$title = array_filter(array_unique(array_slice(array_values($params),1)),
function($v){
- return($v==self::PARAM_DB_DEFAULT ? '' : $v);
+ return(in_array($v,self::ACTIONS_NO_TITLE) ? '' : $v);
+# NB 07.01.17 return($v==self::PARAM_DB_DEFAULT ? '' : $v);
}
);
- $HOME/.dbq:/etc/dbq
- $HOME/ownCloud/var/lib/sqlite:/var/lib/sqlite
# NB 16.12.16 network_mode: "host"
- entrypoint: sh -c "echo . $NB_ROOT/etc/profile > /etc/profile.d/nb.sh && /usr/local/sbin/php-fpm"
+ #entrypoint: sh -c "echo . $NB_ROOT/etc/profile > /etc/profile.d/nb.sh && /usr/local/sbin/php-fpm"
+ entrypoint: sh -c "echo . $NB_ROOT/etc/profile > /etc/profile.d/nb.sh && echo _www:x:50:www-data >> /etc/group && /usr/local/sbin/php-fpm"
#entrypoint: "/usr/local/sbin/php-fpm"
nginx:
border: solid 1px #ddd;
padding: 0.3em 0.4em;
}
+
input[size] {
max-width: 70%;
}
text-align: left;
}
-form.edit .fields input, form.edit .fields textarea, form.edit .fields select {
- width: 65%;
-}