shithub: werc

ref: 0ad15583db1d6bc6f7d23c6278c7ef51be42252a
dir: /apps/bridge/app.rc/

View raw version
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) {
            dprint POST COMMNET $"comment_text
            d=`{date -n} # FIXME Obvious race
            d=$local_path^'_werc/comments/'^$d/

            u=$logged_user
            if(~ $#logged_user 0) {
                get_post_args comment_user_name comment_user_password
                # XXX Should do this too if user not in required group
                if(! login_user $comment_user_name $comment_user_password) {
                    u=$comment_user_name':'$comment_user_password
                    d=$d^'_pending'
                }
                if not
                    u = $logged_user
            }

            umask 002
            if(mkdir -m 775 -p $d) { # Rudimentary perm checking
                echo $u > $d/user
                echo $comment_text > $d/body
            }
        }
    }

}

fn bridge_body_foot {
    template apps/bridge/foot.tpl
}