git init
# Create files
- [ -e README.md ] || printf "\n=============\n## Synopsis\n\nDESCRIPTION\n" > README.md
+ [ -e README.md ] || printf "${dir}=============\n## Synopsis\n\nDESCRIPTION\n" > README.md
echo ">git add README.md"
git add README.md
resolve() {
- (
- if [ -t 0 ]; then
- while [ $# -gt 0 ]; do
- printf '%s\n' "$1"
- shift
- done
- else
- cat
- fi
- ) | perl -MSocket -pe 'BEGIN{sub ip2host{$i=shift;return $c{$i} if $c{$i};$h=gethostbyaddr(inet_aton($i),AF_INET);%c=()if keys(%c)>10000;return $c{$i}=$h?$h:$i;};}; s/(\b)(\d+(?:\.\d+){3})(\b)/$1.ip2host($2).$3/ge'
+ (
+ if [ -t 0 ]; then
+ while [ $# -gt 0 ]; do
+ printf '%s\n' "$1"
+ shift
+ done
+ else
+ cat
+ fi
+ ) | perl -MSocket -pe 'BEGIN{sub ip2host{$i=shift;return $c{$i} if $c{$i};$h=gethostbyaddr(inet_aton($i),AF_INET);%c=()if keys(%c)>10000;return $c{$i}=$h?$h:$i;};}; s/(\b)(\d+(?:\.\d+){3})(\b)/$1.ip2host($2).$3/ge'
}
-mask2cdr() {
- # Assumes there's no "255." after a non-255 byte in the mask
- local x=${1##*255.}
- set -- 0^^^128^192^224^240^248^252^254^ $(( (${#1} - ${#x})*2 )) ${x%%.*}
- x=${1%%$3*}
- echo $(( $2 + (${#x}/4) ))
+cdr2mask() {
+ # Number of args to shift, 255..255, first non-255 byte, zeroes
+ eval 'set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0'
+ [ $1 -gt 1 ] && shift $1 || shift
+ echo ${1-0}.${2-0}.${3-0}.${4-0}
}
-
-cdr2mask() {
- # Number of args to shift, 255..255, first non-255 byte, zeroes
- set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
- [ $1 -gt 1 ] && shift $1 || shift
- echo ${1-0}.${2-0}.${3-0}.${4-0}
+mask2cdr() {
+ # Assumes there's no "255." after a non-255 byte in the mask
+ local x=${1##*255.}
+ set -- 0^^^128^192^224^240^248^252^254^ $(( (${#1} - ${#x})*2 )) ${x%%.*}
+ x=${1%%$3*}
+ echo $(( $2 + (${#x}/4) ))
}
html2txt() {
if which lynx > /dev/null; then
- lynx -pseudo_inlines -nomargins -display_charset=utf8 -nocolor -nolist -width=999999 -dump "$1"
+ lynx -pseudo_inlines -nomargins -display_charset=utf8 -nocolor -nolist -width=999999 -dump "$1"
elif which w3m > /dev/null; then
w3m -dump -cols 999999 "$1"
else
fi
}
+html2pdf() {
+ iconv -f utf-8 -t iso-8859-1 -c | htmldoc --encryption --webpage --continuous --no-title --header '...' --footer '...' -
+}
+
xml2csv() {
xsltproc lib/xslt/xml2csv.xslt $@
}
public function buttons() {
if (!$this->show_buttons or empty(self::$params)) return false;
if (!preg_match('/(table|view)/',$this->type())) return false;
+ if ($fct = $this->db()->conf_type('print_buttons')) { $r = $fct($this); if ($r!==null) return $r; }
return true;
}
<?php
$DB_TYPES['pgsql'] = array (
'delete_no_limit' => true,
+# NB 19.12.17 'print_buttons' => function(&$t) {
+# NB 19.12.17 if ($t->type = 'view' and preg_match('/GROUP BY/i',$t->sql())) return false;
+# NB 19.12.17 return true;
+# NB 19.12.17 },
'replace_insert' => function(&$sql,&$table,$fields=[]) {
$keys = $table->fields_keys($others);
#if ($table->p('debug')) {
if (!$keys) $keys = $all;
$keys = array_keys($keys);
- $fields = $this->vi_extract_fields();
+ #$fields = $this->vi_extract_fields();
$values = ($_SERVER['REQUEST_METHOD'] == 'POST') ? $_POST : explode($this->param_args_sep,$this->params['args']);
$values = $add ? array_fill(0,count($keys),'') : $values;
+#bye([$this->params['args'],$keys,$values]);
$values = array_combine($keys,$values);
- # NB 23.11.17: Handle format for /vi/
+ # NB 23.11.17: Handle format for /vi
if ($this->params['format'] != $this->format_html) {
$row = $this->db->query2h($this->table->sql_edit($values));
$args = $GLOBALS['dbq_args'];
- if (1) {
- $r = ['view' => join(' ',[
- '<a class="button select vi" href="'.$this->table->base.'/vi/'.$args.'/">View</a>'
- ]) ] + $r;
- } else {
+# NB 19.12.17 if (0) {
+# NB 19.12.17 $r = ['view' => join(' ',[
+# NB 19.12.17 '<a class="button select vi" href="'.$this->table->base.'/vi'.$args.'/">View</a>'
+# NB 19.12.17 ]) ] + $r;
+# NB 19.12.17 } else {
$r = ['view' => join(' ',[''
- .'<form action="'.$this->table->base.'/vi/'.'" method="post">'
- .'<a class="button select vi" href="'.$this->table->base.'/vi/'.'" onclick="parentNode.submit();return false;">View</a>'
+ .'<form action="'.$this->table->base.'/vi'.'" method="post">'
+ .'<a class="button select vi" href="'.$this->table->base.'/vi'.'" onclick="parentNode.submit();return false;">View</a>'
.$this->form_hidden($r)
.'</form>'
]) ] + $r;
- }
+# NB 19.12.17 }
if ($this->perm < self::DELETE) return;
if ($this->db->type == 'sqlite' and !is_writeable($this->db->host)) return;
-# NB 11.12.17 $rm = $this->table->base.'/rm/'.$args;
- $rm = $this->uri_add_referer($this->table->base.'/rm/');
+# NB 11.12.17 $rm = $this->table->base.'/rm'.$args;
+ $rm = $this->uri_add_referer($this->table->base.'/rm');
$r['delete'] = ''
.'<form action="'.$rm.'" method="post">'
.'<a class="button rm" href="'.$rm.'" onclick="parentNode.submit();return false;">Delete</a>'