]> git.nbdom.net Git - nb.git/commitdiff
bin/nb-run-parts
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 12 Jun 2018 02:46:45 +0000 (03:46 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 12 Jun 2018 02:46:45 +0000 (03:46 +0100)
bin/nb-run-parts [new file with mode: 0755]
lib/php/db.php
lib/php/db/table.php
www/dbq/dbq.php

diff --git a/bin/nb-run-parts b/bin/nb-run-parts
new file mode 100755 (executable)
index 0000000..95e9d29
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+#####################################################################
+#
+# bin/nb-run-parts
+#
+#####################################################################
+
+USAGE="nb-run-parts PATH"
+DIR=${1:?$USAGE}
+LOG_DIR="/var/log/nb"
+LOCK_DIR="/var/run/nb"
+#run-parts --report $NB_ROOT/etc/cron.daily
+
+for script in $DIR/*; do
+
+  [ -r "$script" -a -x "$script" ] || continue
+  name=$(basename "$script")
+  name=${name%%.*}
+  lock="$LOCK_DIR/$name.lock"
+  [ -e "$lock" ] && continue
+
+  log="$LOG_DIR/$name.log"
+
+  echo $name $script
+
+done
index 48ae1df2d221af077c2a4f71e702182951ebeabb..60295d78ff3adc8892d7c7cbb6c22603df3ddce5 100644 (file)
@@ -125,6 +125,8 @@ class Db extends nb {
        public $formats = [ 'table','div','csv','xml','json','yaml','sh','sql','php' ];
        public $limits = ['20','50','100','500','1000'];
        public $limit; # Here not in Table becouse of Db::out()
+       public $base;
+       public $html_base;
 
        # Classes
        public $out;
index 4f5e6911a6f9609a224df23c856d6ca91d228206..aaa0affbe6a5c7335ce9c087bc7dfd0b62392c58 100644 (file)
@@ -669,7 +669,8 @@ Class Table extends nb {
 
                $flat = [];
                foreach ($params as $k=>$v) { $flat[] = $k.'='.urlencode($v); }
-               return $flat ? '?'. join('&amp;',$flat) : ''; 
+               #debug( $this->db()->base.'?'. join('&amp;',$flat) );
+               return $flat ? $this->request_uri().'?'. join('&amp;',$flat) : ''; 
 
        }
 
@@ -2138,7 +2139,8 @@ Class Table extends nb {
                if (!empty($opt['buttons'])) $buttons = $opt['buttons'];
 
                #$r = '<form class="menu" method="get" action="?">'.NB_EOL;
-               $r = '<form class="menu" method="get" action="'.preg_replace('/\?.*$/','',$_SERVER["REQUEST_URI"]).'">'.NB_EOL;
+               $r = '<form class="menu" method="get" action="'.$this->request_uri().'">'.NB_EOL;
+               #$r = '<form class="menu" method="get" action="'.$this->db()->base.preg_replace('/\?.*$/','',$_SERVER["REQUEST_URI"]).'">'.NB_EOL;
 
                # See: http://html5doctor.com/html5-forms-input-types/
                #$r .= '<input id="skill" type="range" min="1" max="100" value="0" />';
@@ -2431,5 +2433,8 @@ Class Table extends nb {
                $row = $new_row;
        }
 
+       function request_uri() {
+               return $this->db()->html_base.preg_replace('/\?.*$/','',$_SERVER["REQUEST_URI"]);
+       }
 } # < Class
 ?>
index 8ba5bfbee7a695bf235396b4160d04acbc8eff6e..b8809b371203ade3dbfcb4b6c4fd3c594fd052a0 100644 (file)
@@ -393,6 +393,7 @@ class DbQ extends nb {
 
                        $this->db->__construct($connect);
                        $this->db->connect();
+                       $this->db->html_base = $this->base;
                        $this->db->base = $this->base.'/'.$this->db->id;
                        return $this->db;
                }
@@ -410,7 +411,6 @@ class DbQ extends nb {
                }
 
                $this->db = new Db(['conf'=>$DB_CONFS]);
-               $this->db->base = $this->base;
 
                return $this->db;
        }