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