Add some comments and replace get_post_args with load_post_args

This commit is contained in:
Uriel 2009-01-24 07:11:39 +01:00
parent ce23320a4d
commit f87339e98b
5 changed files with 49 additions and 23 deletions

View file

@ -1,4 +1,5 @@
fn bridge_init { fn bridge_init {
# XXX: Should avoid running for 404s, dir lists, etc.
if(! ~ $#enable_comments 0) { if(! ~ $#enable_comments 0) {
ll_add handlers_body_foot bridge_body_foot ll_add handlers_body_foot bridge_body_foot
if(get_post_args comment_text) { if(get_post_args comment_text) {
@ -19,11 +20,12 @@ fn bridge_init {
} }
umask 002 umask 002
mkdir -m 775 -p $d if(mkdir -m 775 -p $d) { # Rudimentary perm checking
echo $u > $d/user echo $u > $d/user
echo $comment_text > $d/body echo $comment_text > $d/body
} }
} }
}
} }

View file

@ -186,11 +186,10 @@ fn login_user {
# Check loggin status, if called with group arg we check membership too # Check loggin status, if called with group arg we check membership too
fn check_user { fn check_user {
if(! get_user) if(! get_user)
status='Not logged in:' $status _status='Not logged in:' $status
if not if(~ $#1 1 && ! grep -s '^'^$logged_user^'$' etc/groups/$1) if not if(! ~ $#* 0 && ! grep -s '^'^$logged_user^'$' etc/groups/$*)
status=User $logged_user not in group $1 _status=User $logged_user not in groups $*
if not status=$_status
status=()
} }
# If not logged in, try to get user login info from POST or from cookie # If not logged in, try to get user login info from POST or from cookie

View file

@ -98,7 +98,8 @@ fn setup_handlers {
if not if(test -f $local_path.txt) if not if(test -f $local_path.txt)
handler_body_main=(txt_handler $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) if(! ~ $#enabled_apps 0)
for(a in $enabled_apps) for(a in $enabled_apps)
$a^'_init' $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 # Hack: preload post data so we can access it from templates where cgi's stdin is not accesible
if(~ $REQUEST_METHOD POST) { if(~ $REQUEST_METHOD POST) {
get_post_args load_post_args
login_user login_user
} }

View file

@ -1,6 +1,29 @@
<pre> % if(! ~ $#debug_shell 0) {
% env | escape_html <form method="POST" name="prompt">
--------------------- <input type="text" name="command" />
% umask <input type="submit" Value="Run" />
</pre> </form>
<script language="javascript"><!--
document.prompt.command.focus()
//--></script>
%{
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 '<hr /><pre>'
evl | escape_html |[2] awk '{print "<b>"$0"</b>"}'
echo '</pre>'
}
%}
% }
<hr /><pre>
% env | escape_html
</pre><hr />
% umask

View file

@ -1,13 +1,14 @@
%{ <h1>User login</h1>
<br />
if(check_user) % if(check_user) {
echo 'You are logged in as' $logged_user You are logged in as: <b>%($logged_user%)</b>
if not if (~ $REQUEST_METHOD POST)
echo 'Login failed!'
% } % }
% if not {
% if (~ $REQUEST_METHOD POST)
% echo 'Login failed!'
<form method="POST"> <form method="POST">
User name: <input type="text" name="user_name" /><br /> User name: <input type="text" name="user_name" /><br />
User password: <input type="password" name="user_password" /><br /> User password: <input type="password" name="user_password" /><br />
<input name="s" type="submit" value="Login" /> <input name="s" type="submit" value="Login" />
</form> </form>
% }