]> git.plutz.net Git - serve0/blob - actions/meta.sh
reenable broken tag modification
[serve0] / actions / meta.sh
1 #!/bin/zsh
2
3 cgi_refdata
4
5   info="${_GET[i]:-$_REF[i]}"
6  order="${_GET[o]}"
7 search="${_GET[s]}"
8 filter="${_GET[f]}"
9   page="${_GET[pn]}"
10 file="${_DATA}/meta/$info.meta"
11
12 cgi_post
13 length="${_POST[length]}"
14  width="${_POST[width]}"
15 height="${_POST[height]}"
16  trash="${_POST[trash]}"
17 cancel="${_POST[cancel]}"
18 tagacc="${_POST[tag]}"
19 tags="$(echo "${_POST[tags]}" \
20         | sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s/</\&lt\;/g;s/>/\&gt\;/g'
21 )"
22 description="$(echo -e "${_POST[description]}" \
23                |sed 's/\r//g;s/\\/\\\\/g;s/</\&lt\;/g;s/>/\&gt\;/g'
24 )"
25 n=0; while [ -n "${_POST[tag$n]}" ]; do
26   tagacc="${_POST[tag$n]}|$tagacc"
27   n=$(($n + 1))
28 done
29
30 [ -z "$cancel" -a -n "$info" ] && if [ -n "$trash" ]; then
31   rm "${_DATA}/thumbs/$info.jpg" 2>/dev/null
32   mv "${_DATA}/videos/$info" "${_DATA}/meta/$info.meta" "${_DATA}/trash/" 2>/dev/null
33   rm "${_DATA}/cache/$info.cache" 2>/dev/null
34   rm ${_DATA}/cache/\?* 2>/dev/null
35 else
36   echo -e "$length\t$width\t$height\t$info" > "$file"
37   echo -e "${tagacc}|${tags}" |tr '\n' '|' >> "$file"
38   echo >>"$file"
39   echo -e "${description}" >> "$file"
40   rm "${_DATA}/cache/$info.cache" 2>/dev/null
41   rm ${_DATA}/cache/*[0-9]\?* 2>/dev/null
42   rm ${_DATA}/cache/taglist 2>/dev/null
43 fi
44
45 echo -n "Location: ?i=&pn=${page}&s=${search}&f=${filter}&o=${order}#$info\n\n"