]> git.plutz.net Git - serve0/blob - actions/meta.sh
605d8099d6c2b20720d4f31003984e070d5996dc
[serve0] / actions / meta.sh
1 #!/bin/zsh
2
3 info="$_GET[\"i\"]"
4 order="$_GET[\"o\"]"
5 search="$_GET[\"s\"]"
6 filter="$_GET[\"f\"]"
7 page="$_GET[\"p\"]"
8 file="${_DATA}/meta/$info.meta"
9
10 cgi_post
11 length="$_POST[\"length\"]"
12 width="$_POST[\"width\"]"
13 height="$_POST[\"height\"]"
14 trash="$_POST[\"trash\"]"
15 cancel="$_POST[\"cancel\"]"
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"