X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=actions%2Fmultitag.sh;h=36f396680af3435393f1180b21d5066ed5c8d206;hb=b2720657620708b249cd2c71cf4e2324b15a911c;hp=ddd96c3f47a20666b165d749a6ee8e5efb1e6436;hpb=714fa51adcec29b6373f3cd94bc79c1e8dca0d30;p=serve0 diff --git a/actions/multitag.sh b/actions/multitag.sh index ddd96c3..36f3966 100755 --- a/actions/multitag.sh +++ b/actions/multitag.sh @@ -1,9 +1,22 @@ #!/bin/zsh +# Copyright 2014 - 2017 Paul Hänsch +# +# This file is part of Serve0 +# +# Serve0 is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Serve0 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Serve0 If not, see . -filter="$_GET[\"f\"]" -search="$_GET[\"s\"]" -order=$(echo "$_GET[\"o\"]" |egrep '^(Name|Date|Length)$') -page=$(echo "$_GET[\"pn\"]" |egrep '^[0-9]+$') +backlink="${_POST[page]}" addtag(){ meta="$1" @@ -25,17 +38,18 @@ $description EOF } -cgi_post n='' -while [ -n "$_POST[\"tagsel$n\"]" ]; do - tagsel="$_POST[\"tagsel$n\"]" +while [ -n "${_POST[tagsel$n]}" ]; do + tagsel="${_POST[tagsel$n]}" ( t='' - while [ -n "$_POST[\"ctag$t\"]" ]; do - echo "$_POST[\"ctag$t\"]" + while [ -n "${_POST[ctag$t]}" ]; do + htmlsafe "${_POST[ctag$t]}" + printf \\n [ -z "$t" ] && t=0 || t=$(($t + 1)) done - echo "$_POST[\"tags\"]" - ) |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s//\>\;/g' \ + htmlsafe "${_POST[tags]}" + printf \\n + ) | sed -r 's:\t: :g;s:^!|[\r\$\^\|]::g;' \ | while read tag; do addtag "${_DATA}/meta/$tagsel.meta" "$tag" done @@ -45,6 +59,6 @@ while [ -n "$_POST[\"tagsel$n\"]" ]; do done rm "${_DATA}"/cache/\?* 2>/dev/null -[ -n "$_POST[\"tags\"]" ] && rm "${_DATA}"/cache/taglist 2>/dev/null +[ -n "${_POST[tags]}" ] && rm "${_DATA}"/cache/taglist_set "${_DATA}"/cache/taglist_filter 2>/dev/null -echo -n "Location: ?o=$order&s=$search&f=$filter&pn=$page\n\n" +redirect "$backlink"