From 6e0b5036f4fbfe606fba8b7f69b9b34536fd568c Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 22 Sep 2014 01:55:08 +0000 Subject: [PATCH] use new cgi engine for multitagging svn path=/trunk/; revision=16 --- actions/multitag.sh | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/actions/multitag.sh b/actions/multitag.sh index fcf56d9..7c5b252 100755 --- a/actions/multitag.sh +++ b/actions/multitag.sh @@ -25,31 +25,26 @@ $description EOF } -n=0 -if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then -(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do - if expr "$line" : "tagsel=" >/dev/null; then - n=$(($n + 1)) - tagsel[$n]="$(echo -e "$(sed -nr 's:(^|&)tagsel=(.*)(&|$):\2:;s:&.*$::;s:\+: :g;s:%:\\x:g;p' <<<"$line" )")" - elif expr "$line" : "ctag=" >/dev/null; then - tag="$(sed -r 's:^ctag=(.*)$:\1:;s:\+:_:g;s:%:\\x:g' <<<"$line")" - tag="$(echo -e "${tag}" |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s//\>\;/g')" - for i in {1..$n}; do - addtag "${_DATA}/meta/$tagsel[$i].meta" "$tag" - rm "${_DATA}/cache/$tagsel[$i].cache" 2>/dev/null +cgi_post +n='' +while [ -n "$_POST[\"tagsel$n\"]" ]; do + tagsel="$_POST[\"tagsel$n\"]" + ( t='' + while [ -n "$_POST[\"ctag$t\"]" ]; do + echo "$_POST[\"ctag$t\"]" + [ -z "$t" ] && t=0 || t=$(($t + 1)) done - elif expr "$line" : 'tags=.\+' >/dev/null; 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//\>\;/g')" - for i in {1..$n}; do echo "$tags" |while read tag; do - addtag "${_DATA}/meta/$tagsel[$i].meta" "$tag" - rm "${_DATA}/cache/$tagsel[$i].cache" 2>/dev/null - done; done - fi + echo "$_POST[\"tags\"]" + ) |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s//\>\;/g' \ + | while read tag; do + addtag "${_DATA}/meta/$tagsel.meta" "$tag" + done + rm "${_DATA}/cache/$tagsel.cache" 2>/dev/null + + [ -z "$n" ] && n=0 || n=$(($n + 1)) done -fi rm "${_DATA}"/cache/\?* 2>/dev/null -rm "${_DATA}"/cache/taglist 2>/dev/null +[ -n "$_POST[\"tags\"]" ] && rm "${_DATA}"/cache/taglist 2>/dev/null -echo -n "Location: ?o=$order&s=$search&f=$filter&p=$page#$info\n\n" +echo -n "Location: ?o=$order&s=$search&f=$filter&p=$page\n\n" -- 2.39.2