From f87339e98b6c24d9ab9a8ac93ef607750142ce44 Mon Sep 17 00:00:00 2001 From: Uriel Date: Sat, 24 Jan 2009 07:11:39 +0100 Subject: [PATCH] Add some comments and replace get_post_args with load_post_args --- apps/bridge/app.rc | 8 +++++--- bin/cgilib.rc | 9 ++++----- bin/werc.rc | 5 +++-- lib/_debug.tpl | 33 ++++++++++++++++++++++++++++----- lib/_users/login.tpl | 17 +++++++++-------- 5 files changed, 49 insertions(+), 23 deletions(-) diff --git a/apps/bridge/app.rc b/apps/bridge/app.rc index 7fba807..9fc6991 100644 --- a/apps/bridge/app.rc +++ b/apps/bridge/app.rc @@ -1,4 +1,5 @@ fn bridge_init { + # XXX: Should avoid running for 404s, dir lists, etc. if(! ~ $#enable_comments 0) { ll_add handlers_body_foot bridge_body_foot if(get_post_args comment_text) { @@ -19,9 +20,10 @@ fn bridge_init { } umask 002 - mkdir -m 775 -p $d - echo $u > $d/user - echo $comment_text > $d/body + if(mkdir -m 775 -p $d) { # Rudimentary perm checking + echo $u > $d/user + echo $comment_text > $d/body + } } } diff --git a/bin/cgilib.rc b/bin/cgilib.rc index e7984a6..156dc92 100644 --- a/bin/cgilib.rc +++ b/bin/cgilib.rc @@ -186,11 +186,10 @@ 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 - if not if(~ $#1 1 && ! grep -s '^'^$logged_user^'$' etc/groups/$1) - status=User $logged_user not in group $1 - if not - status=() + _status='Not logged in:' $status + if not if(! ~ $#* 0 && ! grep -s '^'^$logged_user^'$' etc/groups/$*) + _status=User $logged_user not in groups $* + status=$_status } # If not logged in, try to get user login info from POST or from cookie diff --git a/bin/werc.rc b/bin/werc.rc index 0ecc116..9e992ce 100755 --- a/bin/werc.rc +++ b/bin/werc.rc @@ -98,7 +98,8 @@ fn setup_handlers { if not if(test -f $local_path.txt) handler_body_main=(txt_handler $local_path.txt) - # Apps, XXX: Maybe we should check that $enabled_apps exist in $werc_apps. + # XXX Should check that $enabled_apps exist in $werc_apps? + # XXX Should split init of apps that provide main handler (eg., blog) and apps that don't (eg., comments)? if(! ~ $#enabled_apps 0) for(a in $enabled_apps) $a^'_init' @@ -162,7 +163,7 @@ ifs='/' { args=`{echo -n $req_path} } # Hack: preload post data so we can access it from templates where cgi's stdin is not accesible if(~ $REQUEST_METHOD POST) { - get_post_args + load_post_args login_user } diff --git a/lib/_debug.tpl b/lib/_debug.tpl index 4d224d9..f71c3a8 100644 --- a/lib/_debug.tpl +++ b/lib/_debug.tpl @@ -1,6 +1,29 @@ -
-% env | escape_html
----------------------
-% umask
-
+% if(! ~ $#debug_shell 0) { +
+ + +
+ + +%{ +fn evl { + # Buffering is probably messing this up: + #rc -c 'flag x +;{'^$post_arg_command'} |[2] awk ''{print ">> "$0}''' + rc -c 'flag x +;'^$post_arg_command +} + if(! ~ $#post_arg_command 0 && ! ~ $#post_arg_command '') { + echo '
'
+        evl | escape_html |[2] awk '{print ""$0""}' 
+        echo '
' + } +%} +% } + +
+% env | escape_html
+

+ +% umask diff --git a/lib/_users/login.tpl b/lib/_users/login.tpl index 9f463a4..a2474e1 100644 --- a/lib/_users/login.tpl +++ b/lib/_users/login.tpl @@ -1,13 +1,14 @@ -%{ - -if(check_user) - echo 'You are logged in as' $logged_user -if not if (~ $REQUEST_METHOD POST) - echo 'Login failed!' - -%} +

User login

+
+% if(check_user) { + You are logged in as: %($logged_user%) +% } +% if not { +% if (~ $REQUEST_METHOD POST) +% echo 'Login failed!'
User name:
User password:
+% }