docs.roxen.comView this page in a printer friendly mode
DocsRoxen2.1Programmer ManualCGI
Copyright © 2001, Roxen Internet Software
Suggestions, comments & compliments
manuals@roxen.com
 DEMO  DOCS  PIKE
 COMMUNITY  DOWNLOAD
www.roxen.com

   

What is a CGI Script?
Available Environment Variables
I/O Via the Standard Streams

Available Environment Variables

The use of environment variables for argument passing, as well as the handy roxen extensions to the standard.

A CGI script receives all of its parameters via environment variables. Since most of the variables received this way could be altered by a malicious cracker, it is a sound practice never to trust the content of these variables blindly and be sure to use proper quoting at all times. This reminder being said, here are the variables sent and their contents:

  • AUTH_TYPE

    When the browser authenticates itself, this variable contains the authentication type in use. The most common value is Basic.

  • CONFIGS

    If any RoxenConfig configuration options were set, this is a space-separated array of them all.

  • CONTENT_LENGTH

    For requests which have attached information, such as HTTP POST and PUT, this is the length of the said content given by the client (available to read from stdin). This value may safely be trusted, since it is computed by roxen (and not fetched from the HTTP headers).

  • CONTENT_TYPE

    This is the content type of the data provided; see CONTENT_LENGTH.

  • COOKIES

    A space-separated list of all cookie names sent with this request.

  • COOKIE_name

    The value of the cookie name.

  • DOCUMENT_NAME

    The filename of the CGI script.

  • DOCUMENT_URI

    The path part of the URL to the CGI script.

  • GATEWAY_INTERFACE

    The version of the CGI protocol used, which is CGI/1.1 for Roxen 2.1.

  • HTTP_ACCEPT

    The contents of the HTTP Accept header of the request.

  • HTTP_ACCEPT_CHARSET

    The contents of the HTTP Accept-Charset header of the request.

  • HTTP_ACCEPT_ENCODING

    The contents of the HTTP Accept-Encoding header of the request.

  • HTTP_ACCEPT_LANGUAGE

    The contents of the HTTP Accept-Language header of the request.

  • HTTP_AUTHORIZATION

    The contents of the HTTP Authorization header of the request. It will only be available if the Raw user info variable has been set to Yes by the server administrator.

  • HTTP_HOST

    The net_loc part of the URL, as sent in the HTTP Host header, for instance localhost:4711.

  • HTTP_PROXY_CONNECTION

    The contents of the HTTP Proxy-Connection header of the request.

  • HTTP_PRAGMA

    If the client sent any pragma header(s), they are provided here. For practical purposes, the only pragma header you're likely to encounter is no-cache, which some browsers (Netscape comes to mind) send when the user reloads the page.

  • HTTP_CONNECTION

    A lowercased version of the HTTP Connection header; typically keep-alive.

  • HTTP_REFERER

    The HTTP Referer header, if one was sent.

  • HTTP_USER_AGENT

    The full name of the browser used.

  • INDEX

    The query part of the URL, if present.

  • LAST_MODIFIED

    The last modification date, HTTP formatted.

  • PATH_INFO

    If your server has the Path Info Support module loaded and the script was fed path info parameters, it is provided in this variable. The path info is the rest of the path segment in the URL following the pathname of your script.

  • PATH_TRANSLATED

    When the PATH_INFO variable is present, so is PATH_TRANSLATED. It contains a full filesystem path to the file that would be accessed when combining the directory name of the CGI script itself and the PATH_INFO variable.

  • PRESTATES

    If roxen found prestates in the URL, this is a space-separated array of those present.

  • PRESTATE_name

    The value true if that prestate was present.

  • QUERY_STRING

    The query part of the URL, if present.

  • QUERY_name

    The value of the form variable name.

  • REMOTE_ADDR

    The IP number of the client machine.

  • REMOTE_HOST

    The domain name of the client machine, if roxen has had time to find it. Since it takes some time to find what domain name a computer has this information will not be available the first time a certain computer connects to the server.

  • REMOTE_PORT

    The port number used by the client.

  • REMOTE_USER

    The login name used by the user.

  • REMOTE_PASSWORD

    The password used by the user, only available if the Send decoded password variable is set to Yes by the administrator and the client authenticated itself.

  • REQUEST_METHOD

    The method given in the HTTP request. In most cases, this will probably be GET or POST, but other HTTP methods, like PUT, are also possible. When using special protocols, such as WebDAV, other request methods may also occur.

  • ROXEN_AUTHENTICATED

    If the client authenticated itself ok with roxen's authentication module, this variable will contain the value 1.

  • ROXEN_USER_ID

    If your server is setup to give all users user id cookies, this is the number of the user which requested the script right now.

  • SCRIPT_FILENAME

    The complete path in the real file system to the CGI script.

  • SCRIPT_NAME

    The path part in the URL.

  • SERVER_NAME

    The domain name of the web server.

  • SERVER_PORT

    The port number of the web servers. The default is 80 for HTTP or 443 for HTTPS, but it can be almost any value. If the server has several ports this variable will contain the port used to access the script.

  • SERVER_PROTOCOL

    The protocol used.

  • SERVER_SOFTWARE

    The name and version information of the web server.

  • SERVER_URL

    The URL to the web server. Together with SCRIPT_NAME, this makes up the complete URL for the script.

  • SUPPORTS

    A list of words, separated with spaces, of all features for which support information is available. See the supports chapter in the Website Creator manual for more information.

  • SUPPORTS_feature

    The value true if that feature is supported by the current browser. See the supports chapter in the Website Creator manual for more information.

  • VARIABLES

    A list of all form variables.

  • VAR_name

    The value of the form variable name.

  • WANTS_name

    The value true if that RoxenConfig configuration option was set. See also CONFIGS.