From a29f2c97c4894d3708d0d8d8bfde9ab2b5fe8951 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 3 Jan 2018 01:59:18 +0000 Subject: [PATCH] lib/php/db.php --- lib/php/db/field.php | 5 ++-- www/dbq/dbq.php | 55 ++++++++++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/lib/php/db/field.php b/lib/php/db/field.php index 5695a2cf..e2b6a0eb 100644 --- a/lib/php/db/field.php +++ b/lib/php/db/field.php @@ -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]); } diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 0d34a159..e825383a 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -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 -- 2.47.3