From 252fa28d9cbb6c82562b0b21bf1e377ca407351a Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 22 Sep 2014 00:31:07 +0000 Subject: [PATCH] use new cgi engine for filter processing svn path=/trunk/; revision=12 --- actions/filter.sh | 60 +++++++++++++++++------------------- templates/filterdiag.html.sh | 12 ++++++-- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/actions/filter.sh b/actions/filter.sh index 94b87f2..32f867d 100755 --- a/actions/filter.sh +++ b/actions/filter.sh @@ -1,37 +1,35 @@ #!/bin/zsh -if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then -(head -c "${CONTENT_LENGTH}"; echo)|sed 's:&:\n:g;s:\r::g' |while read line; do - case "$line" in - type[0-9]=neg) - [ -z "$filters" ] && filters="!" - [ -n "$filters" ] && egrep -q '(^|\^|\||!)$' <<<"$filters" || filters="${filters}^!" - ;; - type[0-9]=pos) - egrep -q '(^|\^|\||!)$' <<<"$filters" || filters="${filters}^" - ;; - category=*) - category="$(sed 's/^category=//;s/+/ /g;s/%/\\x/g' <<<"$line")" - category="$(echo -e "${category}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)" - ;; - filter=*) - filter="$(sed 's/^filter=//;s/+/ /g;s/%/\\x/g' <<<"$line")" - filter="$(echo -e "${filter}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)" - egrep -q '(^|\^|\||!)$' <<<"${filters}" || filters="${filters}|" - filters="${filters}${filter}" - ;; - cfilter=*) - cfilter="$(sed 's/^cfilter=//;s/+/ /g;s/%/\\x/g' <<<"$line")" - cfilter="$(echo -e "${cfilter}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)" - egrep -q '(^|\^|\||!)$' <<<"${filters}" || filters="${filters}|" - [ -n "$cfilter" ] && filters="${filters}${category}:${cfilter}" - ;; - o=Name) order=Name;; - o=Date) order=Date;; - o=Length) order=Length;; - esac +cgi_post +order="$_POST[\"o\"]" + +for fn in {0..9}; do + type="$_POST[\"type${fn}\"]" + category="$(echo "$_POST[\"category${fn}\"]" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)" + + if [ "$type" = "neg" ]; then + [ -z "$filters" ] && filters="!" + [ -n "$filters" ] && egrep -q '(^|\^|\||!)$' <<<"$filters" || filters="${filters}^!" + elif [ "$type" = "pos" ]; then + egrep -q '(^|\^|\||!)$' <<<"$filters" || filters="${filters}^" + fi + + n='' + while [ -n "$_POST[\"filter${fn}_$n\"]" ]; do + filter="$(echo "$_POST[\"filter${fn}_$n\"]" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)" + egrep -q '(^|\^|\||!)$' <<<"${filters}" || filters="${filters}|" + filters="${filters}${filter}" + [ -z "$n" ] && n=0 || n=$(($n + 1)) + done + + n='' + while [ -n "$_POST[\"cfilter${fn}_$n\"]" ]; do + cfilter="$(echo "$_POST[\"cfilter${fn}_$n\"]" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)" + egrep -q '(^|\^|\||!)$' <<<"${filters}" || filters="${filters}|" + filters="${filters}${category}:${cfilter}" + [ -z "$n" ] && n=0 || n=$(($n + 1)) + done done -fi echo "?o=${order}&f=${filters}" >>${_DATA}/meta/recent echo -n "Location: ?o=${order}&f=${filters}\n\n" diff --git a/templates/filterdiag.html.sh b/templates/filterdiag.html.sh index 2ebb22e..9a38888 100755 --- a/templates/filterdiag.html.sh +++ b/templates/filterdiag.html.sh @@ -27,6 +27,12 @@ cat <