EOF
}
+id="${PATH_INFO%/*}"; id="${id#/}"
+admin=${PATH_INFO##*/}
+file="$_DATA/$id"
+
+if [ "$(DBM "$file" get adminkey)" != "$admin" ]; then
+ REDIRECT "$_BASE/#ERRO_INVALIDKEY"
+elif expr match "$bookmarks" ".*${id}/${admin}.*" >/dev/null; then
+ :
+elif expr match "$bookmarks" ".*${id}.*" >/dev/null; then
+ bookmarks="$(printf %s "$bookmarks" |tr \ \\n |grep -vxF "${id}")"
+ bookmarks="$(printf %s "$bookmarks" |tr \\n \ )"
+ SET_COOKIE +$((182 * 86400)) bookmarks="${bookmarks}${bookmarks:+ }${id}/${admin}" Path="${_BASE}/"
+elif [ "$bookmarks" ]; then
+ SET_COOKIE +$((182 * 86400)) bookmarks="${bookmarks} ${id}/${admin}" Path="${_BASE}/"
+fi
+
if [ "$REQUEST_METHOD" = POST ]; then
- id="${PATH_INFO%/newdate}"; id="${id#/}"
- file="$_DATA/$id"
month="$(POST month |grep -m 1 -xE '[0-9]{4}-(0[1-9]|1[012])')"
todremove="$(POST todremove |grep -m 1 -xE '[0-9]+')"
splittimes="$(POST splittimes |grep -m 1 -xE 'yes|no')"
REDIRECT "$_BASE/"
elif [ "$(POST post)" = post ]; then
REDIRECT "$_BASE${PATH_INFO%/*}"
+ elif [ "$(POST bookmark)" -a ! "$bookmarks" ]; then
+ SET_COOKIE +$((182 * 86400)) bookmarks="${id}/${admin}" Path="${_BASE}/"
+ REDIRECT "$_BASE$PATH_INFO${month:+?month=}${month}"
else
REDIRECT "$_BASE$PATH_INFO${month:+?month=}${month}"
fi
else
- id="${PATH_INFO%/newdate}"; id="${id#/}"
- file="$_DATA/$id"
month="$(GET month |grep -m1 -xE '[0-9]{4}-(0[1-9]|1[012])' || date +%Y-%m)"
Y="${month%-*}"; m="${month#*-}"; Y=${Y#0}; m=${m#0};
[ "$m" = 1 ] && prev=$(printf '%04i-%02i' $((Y - 1)) 12) || prev=$(printf '%04i-%02i' $Y $((m - 1)))
$([ "$splittimes" = "yes" ] && fs_splittimes || fs_timeofday )
[submit "cancel" "cancel" Cancel]
[submit "post" "post" Post Event]
+ $(if [ "$bookmarks" ]; then
+ printf '[section .bookmark This admin page is accessible via the link [a href="%s" %s]. You must copy this link and keep it safe, so you can modify this poll later! The poll has also been bookmarked and will be listed on the front page.' \
+ "$(URL "//$(HEADER Host)/${_BASE}/${id}/${admin}")" \
+ "$(HTML "${HTTPS:+https:}${HTTPS:-http:}//$(HEADER Host)$(PATH "/${_BASE}/${id}/${admin}")")"
+ else
+ printf '[section .bookmark This admin page is accessible via the link [a href="%s" %s]. You must copy this link and keep it safe, so you can modify this poll later! You can also set a Cookie to bookmark all polls you visit, including this admin page. Bookmarked polls will be listed on the frontpage.<br/> [submit "bookmark" "add" Set Cookie]]' \
+ "$(URL "//$(HEADER Host)/${_BASE}/${id}/${admin}")" \
+ "$(HTML "${HTTPS:+https:}${HTTPS:-http:}//$(HEADER Host)$(PATH "/${_BASE}/${id}/${admin}")")"
+ fi)
]
EOF
fi
#cancel if poll is invalid
[ "$id" -a -f "$file" ] || REDIRECT "$_BASE/"
+if expr match "$bookmarks" ".*${id}.*" >/dev/null; then
+ :
+elif [ "$bookmarks" ]; then
+ SET_COOKIE +$((182 * 86400)) bookmarks="${bookmarks} ${id}" Path="${_BASE}/"
+fi
+
+admin="$(expr match "$bookmarks" ".*$id/\([a-zA-Z0-9:=]\{16\}\).*")"
+admin="$(DBM "$file" get adminkey |grep -xF "$admin")"
+
tkey() {
# convert time stamps for use in POST keys
local str="$1" out
if [ "$splittimes" = yes -o "$todall" ]; then
printf '[tr .tod [th]'
for time in $timelist; do
- [ "${time#*_}" = "${time}" ] && time="${time}_"
+ [ "${time#*_}" = "${time}" ] && time="_${time}"
printf '[th . %s]' "${time#*_}"
done
printf '[th]]\n'
DBM "$file" delete "reply_yes_${delete}"
DBM "$file" delete "reply_no_${delete}"
DBM "$file" delete "reply_maybe_${delete}"
+
+ elif [ "$(POST bookmark)" -a ! "$bookmarks" ]; then
+ SET_COOKIE +$((182 * 86400)) bookmarks="${id}" Path="${_BASE}/"
+
fi
REDIRECT "${_BASE}${PATH_INFO}"
$(DBM "$file" get description |markdown)
]
$(table_poll || printf '[p Poll parameters are invalid]')
+ $(if [ "$admin" ]; then
+ printf '[section .bookmark You have bookmarked the admin page of this poll: [a href="./%s" modify poll]]' "$(URL ${id}/${admin})"
+ elif [ "$bookmarks" ]; then
+ printf '[section .bookmark This poll has been bookmarked and is accessible via a link on the front page.]'
+ else
+ printf '[section .bookmark Polls are accessible only via their URL. You can set a Cookie to bookmark all polls you visit. Bookmarked polls will be listed on the frontpage.<br/> [submit "bookmark" "add" Set Cookie]]'
+ fi)
]
EOF
fi
text-align: center;
max-width: 95%;
}
-body.poll .description {
- text-align: left;
+body section {
max-width: 50em;
- padding: 1pt 1em 1em 1em;
- margin: auto;
- margin-bottom: 1em;
+ padding: 1em;
+ margin: 1em auto;
background-color: rgba(255,255,255,.5);
+ word-wrap: break-word;
+}
+body.poll .description .title {
+ margin-top: 0;
+ text-align: left;
}
body.poll .description .title {
text-align: center;
body.poll table tbody tr th.name button[name=delete] { font-size: .625em; line-height: 1.5em; background-color: #FAA; }
body.poll table tbody tr.new td:first-child { text-align: right; }
-body.poll table tbody tr.new td input[name=name] { min-width: 100%; width: 4em; }
+body.poll table tbody tr.new td input[name=name] { min-width: 100%; width: 8em; }
body.poll table td input[type=radio] { display: none; }
body.poll table td input[type=radio] + label {