#!/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"
<form class="panel" id="advfilter" style="display: none;"
action="?action=filter" method="post" accept-charset="UTF-8">
<input disabled type="text" name="s" value="$search" placeholder="Search">
+ <span class="label order">Order by:</span>
+ <select disabled class="order" size="1" name="o">
+ <option>Name</option>
+ <option>Date</option>
+ <option>Length</option>
+ </select>
<input disabled type="submit" name="submit" value="Find">
<a class="panel clearsearch" href="?">Clear All</a>
<input type=\"radio\" name=\"type$n\" value=\"neg\"><span class=\"label conjunction\">None</span>
<span class=\"help\">of the tags selected here:</span>
<span class=\"label category\">Category:</span>
- <select class=\"input category\" name=\"category\" size=\"1\" onchange=\"${hideall}show_block('${n}_'+this.options[this.options.selectedIndex].value)\">
+ <select class=\"input category\" name=\"category$n\" size=\"1\" onchange=\"${hideall}show_block('${n}_'+this.options[this.options.selectedIndex].value)\">
<option>none</option>
$(sed -rn 's;^([^:]+):.*$;<option>\1</option>;p' <<<"$taglist" |sort -u)
</select>
- <select class=\"input tagfilter\" name=\"filter\" size=\"12\" multiple id=\"${n}_none\"
+ <select class=\"input tagfilter\" name=\"filter${n}_\" size=\"12\" multiple id=\"${n}_none\"
onchange=\"show_iblock('filter$((1+$n))')\">
$(sed -rn 's;^([^:]+)$;<option>\1</option>;p' <<<"$taglist")
</select>
$(sed -rn 's;^([^:]+):.*$;\1;p' <<<"$taglist" |sort -u |while read cat; do echo "
- <select class=\"input tagfilter\" name=\"cfilter\" size=\"12\" multiple id=\"${n}_$cat\" style=\"display:none;\"
+ <select class=\"input tagfilter\" name=\"cfilter${n}_\" size=\"12\" multiple id=\"${n}_$cat\" style=\"display:none;\"
onchange=\"show_iblock('filter$((1+$n))')\">
$(sed -rn "s;^$cat:(.*)$;<option>\\1</option>;p" <<<"$taglist")
</select>"