]> git.nbdom.net Git - nb.git/commitdiff
etc/profile.d/net.sh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 19 Dec 2017 03:42:17 +0000 (03:42 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 19 Dec 2017 03:42:17 +0000 (03:42 +0000)
etc/profile.d/git.sh
etc/profile.d/net.sh
lib/php/db/table.php
lib/php/db/types/pgsql.php
www/dbq/dbq.php

index c4a55a11f5cf18f1da5637dfff46c6208ca3a6b5..d60579dfa2b193e0ca8e1f3b9961059368b1efc9 100644 (file)
@@ -103,7 +103,7 @@ git_create() {
   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
index 1e001a20c5158614cc30ef8c13e4a5e4a7e9ac1b..172f166841a4909914d5af76ef11e2d3fbcf70a8 100644 (file)
@@ -1,35 +1,34 @@
 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
@@ -38,6 +37,10 @@ html2txt() {
        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 $@
 }
index a53903be447af9560bb19bccc6884754c7b6ce4c..02afb3c8037b162bb0bcbe42c497f939d184a2f2 100644 (file)
@@ -923,6 +923,7 @@ Class Table extends nb {
   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;
   }
 
index d9cb1508e15fd4bb4d9c003e94401827673e82df..41b50837adc1c7cdee252ca1d19b60ae18c9d6b9 100644 (file)
@@ -1,6 +1,10 @@
 <?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')) {
index 65f9128509510afc01c2433090efb9f3bb08874f..20c01d5a0f12e5cef6a04ed21e4c57ae473c9237 100644 (file)
@@ -372,13 +372,14 @@ class DbQ extends nb {
                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));
@@ -422,24 +423,24 @@ class DbQ extends nb {
 
                                $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>'