]> git.plutz.net Git - webpoll/commitdiff
clear deleted polls from bookmarks
authorPaul Hänsch <paul@plutz.net>
Wed, 28 Jul 2021 20:59:45 +0000 (22:59 +0200)
committerPaul Hänsch <paul@plutz.net>
Wed, 28 Jul 2021 20:59:45 +0000 (22:59 +0200)
index.cgi

index 1bfc2b7e3231b27c2af4cbeb1653daa5322aba6d..e0f8a1cb10189a5916afbf82b3237dac55207658 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -13,8 +13,14 @@ _BASE="${_BASE%/}"
 
 PATH_INFO="$(PATH "/${PATH_INFO#${_BASE}}")"
 
-#git init "$_DATA" >/dev/null &
-bookmarks="$(COOKIE bookmarks |grep -xE '[0-9a-zA-Z:=]{16}(/[0-9a-zA-Z:=]{16})?( [0-9a-zA-Z:=]{16}(/[0-9a-zA-Z:=]{16})?)*')"
+# bookmarks_cookie="$(COOKIE bookmarks |grep -xE '[0-9a-zA-Z:=]{16}(/[0-9a-zA-Z:=]{16})?( [0-9a-zA-Z:=]{16}(/[0-9a-zA-Z:=]{16})?)*')"
+bookmarks=''
+for bm in $(COOKIE bookmarks); do
+  [ -f "${_DATA}/$(checkid "${bm%/*}")" ] && bookmarks="${bookmarks}${bookmarks:+ }${bm}"
+done
+if [ "$bookmarks" ]; then
+  SET_COOKIE +$((182 * 86400)) bookmarks="${bm}" Path="${_BASE}/"
+fi
 
 yield_page(){
   title="${1:-Webpoll}" page="$2"