]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 3 Jan 2018 01:59:18 +0000 (01:59 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 3 Jan 2018 01:59:18 +0000 (01:59 +0000)
lib/php/db/field.php
www/dbq/dbq.php

index 5695a2cf77453f348b09f2b8ced78d5e8920f718..e2b6a0ebe658561c922ab942731a210299e4f77b 100644 (file)
@@ -304,8 +304,9 @@ class field extends nb {
       or empty($this->db()->encrypt)
       or empty($this->db()->encrypt['tables'])
       or empty($this->db()->encrypt['tables'][$this->table->name])
-    )
-    return false;
+    ) {
+                       return false;
+               }
     return in_array($this->name,$this->db()->encrypt['tables'][$this->table->name]);
   }
 
index 0d34a159d0c136e2eece18343a83f972ad731100..e825383ae35ab34d01db73506671d9dd82478abb 100644 (file)
@@ -6,17 +6,17 @@ require_once(NB_ROOT.'/lib/php/config.php');
 require_once(NB_ROOT.'/lib/php/http.php');
 require_once(NB_ROOT.'/lib/php/mime.php');
 
-if (false) set_error_handler( function ($errNo, $errStr, $errFile, $errLine) {
-               $msg = "$errStr in $errFile on line $errLine\n";
-               if ($errNo == E_NOTICE || $errNo == E_WARNING) {
-                               header("HTTP/1.0 500 Internal Server Error");
-                               #Revel args from function which could be passwords !!!
-                               #throw new ErrorException($msg, $errNo);
-                               nb::bye("$errNo: $msg");
-               } else {
-                               echo $msg;
-               }
-});
+# NB 03.01.18 if (false) set_error_handler( function ($errNo, $errStr, $errFile, $errLine) {
+# NB 03.01.18          $msg = "$errStr in $errFile on line $errLine\n";
+# NB 03.01.18          if ($errNo == E_NOTICE || $errNo == E_WARNING) {
+# NB 03.01.18                          header("HTTP/1.0 500 Internal Server Error");
+# NB 03.01.18                          #Revel args from function which could be passwords !!!
+# NB 03.01.18                          #throw new ErrorException($msg, $errNo);
+# NB 03.01.18                          nb::bye("$errNo: $msg");
+# NB 03.01.18          } else {
+# NB 03.01.18                          echo $msg;
+# NB 03.01.18          }
+# NB 03.01.18 });
 
 class DbQ extends nb {
 
@@ -371,18 +371,18 @@ class DbQ extends nb {
                $this->vi(true);
        }
 
-       private function vi_extract_fields() {
-               $sep = $this->param_args_sep . $this->param_args_sep;
-               #$sep ='@';
-
-               $fields = [];
-               if (strpos($this->params['args'],$sep) !== false) {
-                       list($fields,$this->params['args']) = explode($sep, $this->params['args']);
-                       $fields = explode(',',$fields);
-               }
-
-               return $fields;
-       }
+# NB 03.01.18  private function vi_extract_fields() {
+# NB 03.01.18          $sep = $this->param_args_sep . $this->param_args_sep;
+# NB 03.01.18          #$sep ='@';
+# NB 03.01.18 
+# NB 03.01.18          $fields = [];
+# NB 03.01.18          if (strpos($this->params['args'],$sep) !== false) {
+# NB 03.01.18                  list($fields,$this->params['args']) = explode($sep, $this->params['args']);
+# NB 03.01.18                  $fields = explode(',',$fields);
+# NB 03.01.18          }
+# NB 03.01.18 
+# NB 03.01.18          return $fields;
+# NB 03.01.18  }
 
        public function vi($add=false) {
                $all = [];
@@ -391,11 +391,16 @@ class DbQ extends nb {
                if (!$keys) $keys = $all;
                $keys = array_keys($keys);
 
-               #$fields = $this->vi_extract_fields();
+# NB 03.01.18          #$fields = $this->vi_extract_fields();
 
                $values = ($_SERVER['REQUEST_METHOD'] == 'POST') ? $_POST : explode($this->param_args_sep,$this->params['args']);
+               foreach ($values as $k=>$v) {
+                       if (!in_array($k,$keys)) unset($values[$k]);
+               }
+
+               if (empty($values)) $this->error('Missing values');
+               #debug([$keys,$values,$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