[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
AutoGen is now capable of acting as a CGI forms server.
It behaves as a CGI server if the definitions input is from stdin
and the environment variable REQUEST_METHOD
is defined
and set to either "GET" or "POST". If set to anything else,
AutoGen will exit with a failure message. When set to one of those
values, the CGI data will be converted to AutoGen definitions
(see section Definitions File) and the template named "cgi.tpl
"
will be processed.
This works by including the name of the real template to process
in the form data and having the "cgi.tpl
" template include
that template for processing. I do this for processing the form
http://autogen.sourceforge.net/conftest.html. The "cgi.tpl
"
looks approximately like this:
<? AutoGen5 Template ?> <? IF (not (exist? "template")) ?><? form-error ?><? ELIF (=* (get "template") "/") ?><? form-error ?><? ELIF (define tpl-file (string-append "cgi-tpl/" (get "template"))) (access? tpl-file R_OK) ?><? INCLUDE (. tpl-file) ?><? ELIF (set! tpl-file (string-append tpl-file ".tpl")) (access? tpl-file R_OK) ?><? INCLUDE (. tpl-file) ?><? ELSE ?><? form-error ?><? ENDIF ?> |
This forces the template to be found in the "cgi-tpl/
"
directory. Note also that there is no suffix specified in the
pseudo macro (see section Format of the Pseudo Macro). That tells AutoGen to emit
the output to stdout.
The output is actually spooled until it is complete so that, in the case of an error, the output can be discarded and a proper error message can be written in its stead.
Please also note that it is advisable, especially for network
accessible machines, to configure AutoGen (see section Configuring AutoGen) with
shell processing disabled (--disable-shell
). That will make it
impossible for any referenced template to hand data to a subshell for
interpretation.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Bruce Korb on September, 30 2006 using texi2html 1.76.