-#!/bin/zsh
+#!/bin/sh
-# Copyright 2014, 2017 Paul Hänsch
+# Copyright 2019 Paul Hänsch
#
# This file is part of Confetti.
#
# You should have received a copy of the GNU Affero General Public License
# along with Confetti. If not, see <http://www.gnu.org/licenses/>.
-cgi_post
+locktimeout=900
+. "$_EXEC"/session_lock.sh
-if [ "${_POST[choice]}" = new_filter ]; then
- filter="$(
- for n in filter{0..100}; do
- # [ -z "${_POST[$n]:+x}" ] && break
- printf %s "${_POST[$n]}"
- done \
- | sed -r 's;\|+;\|;g; s;\^+;\^;g; s;:\|;:;g; :X; s;\^[^:]*:\^;\^;g; /\^[^:]*:\^/bX; s;^\^;;; s;\^[^:]*:$;;;'
- )"
- printf 'Location: ?p=cards&order=%s&filter=%s\n\n' "${_POST[order]}" "$filter"
+card="$(GET card |PATH)"
+cardfile="$_DATA/vcard/${card##*/}"
+filter="$(REF f)"
+order="$(REF o)"
+
+if tempfile="$(SLOCK "$cardfile" "$locktimeout")"; then
+ REDIRECT "/cards/?o=${order}&f=${filter}&e=${card}"
+elif [ -f "$tempfile" ]; then
+ SET_COOKIE session message="SESSLOCK"
+ REDIRECT "/cards/?o=${order}&f=${filter}#${card}"
else
- printf 'Location: ?p=cards\n\n'
+ SET_COOKIE session message="EDITLOCK"
+ REDIRECT "/cards/?o=${order}&f=${filter}#${card}"
fi