From: Nicolas Boisselier Date: Fri, 6 Sep 2024 16:10:48 +0000 (+0200) Subject: bin/dbq-vi X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=a26970905a83f22b6496099fa5f5d80621858189;p=nb.git bin/dbq-vi --- diff --git a/bin/dbq-vi b/bin/dbq-vi index 769ec1c0..d2b11684 100755 --- a/bin/dbq-vi +++ b/bin/dbq-vi @@ -14,11 +14,13 @@ EOF if [ -z "$id" ] then + echo "# ADD MODE" >> "$tmp" dbq.php "$path/add.yaml" >> "$tmp" || return sed -i -e 's/"//g' "$tmp" else dbq.php "$path/vi/$id.yaml" >> "$tmp" || return fi + md5=$(md5sum "$tmp") vi "$tmp" diff --git a/bin/dbq.php b/bin/dbq.php index 2c1ff7f6..5d83bf7e 100755 --- a/bin/dbq.php +++ b/bin/dbq.php @@ -23,17 +23,30 @@ if (isset($GLOBALS['argv']) and count($GLOBALS['argv'])>1) { if ($k == '__YAML__') { $str = file_get_contents($v); - $_GET = Nb::yaml_decode($str)[0]; + if (empty($str)) bye('Empty file'); + + $data = Nb::yaml_decode($str); + if (empty($data)) bye('No datas'); + if (is_array($data[0])) $data = $data[0]; + + $_GET = $data; } elseif ($k == '__JSON__') { $str = file_get_contents($v); - $_GET = Nb::json_decode($str)[0]; + if (empty($str)) bye('Empty file'); + + $data = Nb::json_decode($str); + if (empty($data)) bye('No datas'); + if (is_array($data[0])) $data = $data[0]; + + $_GET = $data; } else { $_GET[$k]= $v; # NB 05.09.24 $_SERVER['QUERY_STRING'] .= (empty($_SERVER['QUERY_STRING']) ? '' : '&').trim($GLOBALS['argv'][$i]); } + #unset($GLOBALS['argv'][$i]); } @@ -41,6 +54,7 @@ if (isset($GLOBALS['argv']) and count($GLOBALS['argv'])>1) { } #bye($_GET); -$GLOBALS['argv'] = []; # to cancel argv2request +$GLOBALS['argv'] = [$GLOBALS['argv'][1]]; # to cancel argv2request +#$GLOBALS['argv'] = []; # to cancel argv2request require(realpath(dirname(__FILE__).'/../www/dbq/dbq.php')); ?>