#!/bin/zsh
# Copyright 2014,2015 Paul Hänsch
#
# This file is part of Confetti.
#
# Confetti 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.
#
# Confetti 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 Confetti. If not, see .
data_dirs Home Tasks Wiki QRcodes
umask=002
#alias _wiki="stx2any --no-template --link-abbrevs --quote -T html"
_wiki(){
#markdown $* |sed -r 's:<(h[1-6])>(.+):<\1>\2\1>:g'
pandoc -f markdown -t html "$@" |sed -r 's:<(h[1-6])>(.+):<\1>\2\1>:g'
}
LOGIN=false
USER="#NONE#"
[ -z "${_GET[p]}" ] && _GET[p]=Home
sessfile="$_DATA/auth/session$(sed -rn 's:^.*session=([a-zA-Z0-9]{32}).*$:\1:p' <<<"$HTTP_COOKIE")"
if [ -r "$sessfile" ]; then
cat "$sessfile" |read user expire
if [ "$(date +%s)" -lt "$expire" ]; then
echo -E "$user $(($(date +%s) + 1800))" >"$sessfile"
USER="$user"
LOGIN=true
else
[ -f "$sessfile" ] && rm "$sessfile"
sess_msg="Your session has expired!"
fi
fi
unset sessfile user expire
. $_DATA/auth/permissions.sh