]> git.plutz.net Git - confetti/blobdiff - cgi.sh
basic update functions for vcards
[confetti] / cgi.sh
diff --git a/cgi.sh b/cgi.sh
index cf0023c3c90949f7677bb72b0b2c108e7dac1220..676dbc581abcccf9a4da74c979b227e176fd5624 100755 (executable)
--- a/cgi.sh
+++ b/cgi.sh
@@ -3,7 +3,6 @@
 declare -A _GET
 declare -A _POST
 
-
 cgi_get() {  # parse HTTP GET string
   echo "$QUERY_STRING" |tr '&' '\n' |while read query; do
     key="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')"
@@ -17,7 +16,15 @@ cgi_post() {  # parse HTTP POST string
   sed -u 1q |tr '&' '\n' |while read query; do
     key="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')"
     val="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')"
-    _POST["$key"]="$(echo -e "$(echo "$val" |sed 's:+: :g;s:%:\\x:g')")"
+    value="$(echo -e "$(echo "$val" |sed 's:+: :g;s:%:\\x:g')")"
+    if [ -n "$_POST[\"$key\"]" ]; then
+      n=0
+      while [ -n "$_POST[\"$key$n\"]" ]; do n=$(($n + 1)); done
+      _POST["$key$n"]="$value"
+    else
+      _POST["$key"]="$value"
+    fi
+    debug "post($key$n) => $value"
   done
   debug "$_POST"
 }