Fix cookie parsing if more than one cookie present, add optional user/loggin-info sidebar

This commit is contained in:
uriel 2009-01-17 03:43:05 +01:00
parent 6aac4ce54c
commit 6271d7a81a

View File

@ -136,12 +136,9 @@ fn set_cookie {
fn get_cookie {
ifs=';' { co = `{ echo $HTTP_COOKIE } }
#for(c in $co)
# if(~ $c $1^'='*) # This matching doesn't work
# echo $c|sed 's/[^=]*=//'
# WARNING: we might be adding a trailing new line
{ for(c in $co) echo $c } | sed -n 's/[^=]*=//p'
# XXX: we might be adding a trailing new line?
# The ' ?' is needed to deal with '; ' inter-cookie delimiter
{ for(c in $co) echo $c } | sed -n 's/^ ?'$1'=//p'
}
fn select_mime {
@ -189,7 +186,7 @@ fn login_user {
# Check loggin status, if called with group arg we check membership too
fn check_user {
if(! get_user)
status='Not logged in'
status='Not logged in:' $status
if not if(~ $#1 1 && ! grep -s '^'^$logged_user^'$' etc/groups/$1)
status=User $logged_user not in group $1
if not
@ -240,6 +237,11 @@ fn auth_user {
}
}
fn user_controls {
echo User: $"logged_user
}
# .md '(meta-)data' extract
fn get_md_file_attr {
sed -n '/^\* '$2': /p; /^\* '$2': /q; /^$/q' < $1