]> git.plutz.net Git - busy/blobdiff - constants.sh
porting busy to confetti framework
[busy] / constants.sh
diff --git a/constants.sh b/constants.sh
new file mode 100755 (executable)
index 0000000..2636e0b
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/zsh
+
+# Copyright 2014 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 <http://www.gnu.org/licenses/>. 
+
+umask=002
+#alias _wiki="stx2any --no-template --link-abbrevs --quote -T html"
+_wiki(){
+  markdown $* |sed -r 's:<(h[1-6])>(.+)</h[1-6]>:<\1><a name="\2">\2</a></\1>:g'
+}
+
+LOGIN=false
+USER="#NONE#"
+_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