]> git.plutz.net Git - serve0/commitdiff
use global post parser for tagging (untested)
authorpaul <paul@plutz.net>
Mon, 15 Sep 2014 02:11:12 +0000 (02:11 +0000)
committerpaul <paul@plutz.net>
Mon, 15 Sep 2014 02:11:12 +0000 (02:11 +0000)
svn path=/trunk/; revision=10

actions/meta.sh

index 5824d8f0947560cb5d312d263f6e9b9efa241bc7..a5f578cc8d4fb6cc81bb91a47ce4edf09ecb1afd 100755 (executable)
@@ -3,41 +3,29 @@
 info="$_GET[\"i\"]"
 file="{$DATA}/meta/$info.meta"
 
-if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
-(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
-  if (egrep -xq 'length=[0-9]{1,5}' <<<"${line}"); then
-    length="$(cut -d= -f2 <<<"${line}")"
-  elif (egrep -xq 'width=[0-9]{1,5}' <<<"${line}"); then
-    width="$(cut -d= -f2 <<<"${line}")"
-  elif (egrep -xq 'height=[0-9]{1,5}' <<<"${line}"); then
-    height="$(cut -d= -f2 <<<"${line}")"
-  elif (egrep -xq 'tag=.+' <<<"${line}"); then
-    tag="$(sed -r 's:^tag=(.*)$:\1:;s:\+:_:g;s:%:\\x:g' <<<"$line")"
-    tag="$(echo -e "${tag}" |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s/</\&lt\;/g;s/>/\&gt\;/g')"
-    tagacc="$tag|$tagacc"
-  elif (egrep -xq 'tags=.+' <<<"${line}"); then
-    tags="$(sed -r 's:^tags=(.*)$:\1:;s:\+:_:g;s:%:\\x:g' <<<"$line")"
-    tags="$(echo -e "${tags}" |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s/</\&lt\;/g;s/>/\&gt\;/g')"
-  elif (egrep -xq 'description=.+' <<<"${line}"); then
-    description="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
-    description="$(echo -e "${description}" |sed 's/\r//g;s/\\/\\\\/g;s/</\&lt\;/g;s/>/\&gt\;/g')"
-  elif (egrep -xq 'trash=.+' <<<"${line}"); then
-    trash="true"
-  elif (egrep -xq 'cancel=.+' <<<"${line}"); then
-    cancel="true"
-  elif (egrep -xq 'f=.+' <<<"${line}"); then
-    filter="$(cut -d= -f2- <<<"${line}")"
-  elif (egrep -xq 's=.+' <<<"${line}"); then
-    search="$(cut -d= -f2- <<<"${line}")"
-  elif (egrep -xq 'p=.+' <<<"${line}"); then
-    page="$(cut -d= -f2- <<<"${line}")"
-  elif (egrep -xq 'o=.+' <<<"${line}"); then
-    order="$(cut -d= -f2- <<<"${line}")"
-  fi
+cgi_post
+length="$_POST[\"length\"]"
+width="$_POST[\"width\"]"
+height="$_POST[\"height\"]"
+trash="$_POST[\"trash\"]"
+cancel="$_POST[\"cancel\"]"
+filter="$_POST[\"f\"]"
+search="$_POST[\"s\"]"
+page="$_POST[\"p\"]"
+order="$_POST[\"o\"]"
+tagacc="$_POST[\"tag\"]"
+tags="$(echo "$_POST[\"tags\"]" \
+        | sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s/</\&lt\;/g;s/>/\&gt\;/g'
+)"
+description="$(echo -e "$_POST[\"description\"]" \
+               |sed 's/\r//g;s/\\/\\\\/g;s/</\&lt\;/g;s/>/\&gt\;/g'
+)"
+n=0; while [ -n "$_POST[\"tag$n\"]" ]; do
+  tagacc="$_POST[\"tag$n\"]|$tagacc"
+  n=$(($n + 1))
 done
-fi
 
-[ -z "$cancel" ] && if [ "$trash" = "true" ]; then
+[ -z "$cancel" ] && if [ -n "$trash" ]; then
   rm "${_DATA}/thumbs/$info.jpg" 2>/dev/null
   mv "${_DATA}/videos/$info" "${_DATA}/meta/$info.meta" "${_DATA}/trash/" 2>/dev/null
   rm "${_DATA}/cache/$info.cache" 2>/dev/null