Technical data
8. Documentation for Developers
8.6.4. Construction of a CGI script
The headers
All web server scripts are simple shell scripts (interpreter as e.g. Perl, PHP, etc. are much too
big in filesize for fli4l). You should start with the mandatory script header (reference to the
interpreter, name, what does the script, author, license).
Helper Script cgi-helper
After the header you should include the helper script cgi-helper with the following call:
. /srv/www/include/cgi-helper
A space between the dot and the slash is important!
This script provides several helper functions that should greatly simplify the creation of
CGIs for fli4l. With the integration some standard tasks are performed, such as the parsing of
variables that were passed via forms or via the URL or loading of language and CSS files.
Here is a small function overview:
Table 8.4.: Functions of the cgi-helper script
Name Function
check_rights Check for user access rights
http_header Creation of a standard HTTP header or a special header, e.g. for file download
show_html_header Creation of a complete page header (inc. HTTP header, headline and menu)
show_html_footer Creation of a footer for the HTML page
show_tab_header Creation of a content window with tabs
show_tab_footer Creation of a footer for the content window
show_error Creation of a box for error messages (background color: red)
show_warn Creation of a box for warning messages (background color: yellow)
show_info Creation of a box for information/ success messages (background color: green)
Contents of a CGI script
To ensure consistency in design and especially the compatibility with future versions of fli4l
it is highly recommended to use the functions of the cgi-helper script even if theoretically
everything in a CGI could be generated from scratch.
A simple CGI script might look like this:
#!/bin/sh
# --------------------
# Header (c) Author Date
# --------------------
# get main helper functions
. /srv/www/include/cgi-helper
show_html_header "My first CGI"
echo ' <h2>Welcome</h2>'
echo ' <h3>This is a CGI script example</h3>'
show_html_footer
325










