|
The following is just a sampling in the use of server side includes.
This sampling demonstrates the use of CGI Environment Variables using the
#echo Server Side Includes.
In order to pass data about the information request from the server to
the script, the server uses command line arguments as well as environment
variables. These environment variables are set when the server executes
the gateway program.
Some server configurations require the file containing SSI commands to
end with .shtml whereas others do not. You should check with your system
administrator concerning whether they support SSI. In many cases you can
put the following in your .htaccess document which resides in your root directory:
AddHandler server-parsed .html
AddType text/html shtml
- This variable is the complete local directory path of the current document.
<!--#echo var="DOCUMENT_NAME" -->
: ssi.html
- This web page file size.
<!--#config sizefmt="bytes" --><!--#fsize file="ssi.html" -->
: [an error occurred while processing this directive]
<!--#config sizefmt="abbrev" --><!--#fsize file="ssi.html" -->
: [an error occurred while processing this directive]
- This variable is the local path of the current document referenced to the base directory of the web space.
<!--#echo var="DOCUMENT_URI" -->
: /books/ssi.html
- This variable is the unescaped query string sent by the client browser with all shell-special characters replaced with local system equivalents.
<!--#echo var="QUERY_STRING_UNESCAPED" -->
: (none)
- This variable is the date and time of the last modification of the current document.
<!--#echo var="LAST_MODIFIED" -->
: Sunday, 30-May-2004 00:01:03 CDT
- This variable is the IP address of the remote client browser.
<!--#echo var="REMOTE_ADDR" -->
: 38.107.179.207
- This variable is the raw query string sent from the remote browser.
<!--#echo var="QUERY_STRING" -->
:
- This variable is the name of the HTTP server software.
<!--#echo var="SERVER_SOFTWARE" -->
: Apache
- This variable is the local computer name of the HTTP server.
<!--#echo var="SERVER_NAME" -->
: www.microcaddesign.com
- This variable is the name/version of the Common Gateway Interface served on this HTTP server.
<!--#echo var="GATEWAY_INTERFACE" -->
: CGI/1.1
- This variable is the name/version of HTTP served on this HTTP server
<!--#echo var="SERVER_PROTOCOL" -->
: HTTP/1.1
- This variable is the IP port the HTTP server is answering on.
<!--#echo var="SERVER_PORT" -->
: 80
- This variable is the method by which the current document was requested.
<!--#echo var="REQUEST_METHOD" -->
: GET
- This variable is the extra path info that is sent.
<!--#echo var="PATH_INFO" -->
: (none)
- This variable is the 'PATH_INFO' with all shell-special characters replaced with local system equivalents.
<!--#echo var="PATH_TRANSLATED" -->
: (none)
- This variable is the virtual path of the script being executed.
<!--#echo var="SCRIPT_NAME" -->
: /books/ssi.html
- This variable is the host name of the remote client.
<!--#echo var="REMOTE_HOST" -->
: (none)
- This variable is the authentication method used to validate the remote client.
<!--#echo var="AUTH_TYPE" -->
: (none)
- This variable is the user name used to validate authentication from the remote client.
<!--#echo var="REMOTE_USER" -->
: (none)
- This variable is the remote user name if supporting RFC931 identification.
<!--#echo var="REMOTE_IDENT" -->
: (none)
- This variable is the content type of the attached information in the case of a POST or PUT.
<!--#echo var="CONTENT_TYPE" -->
: (none)
- This variable is the length of the attached information in the case of a POST or PUT.
<!--#echo var="CONTENT_LENGTH" -->
: (none)
- This variable is a comma separated list of mime types that are accepted by the remote browser.
<!--#echo var="HTTP_ACCEPT" -->
: text/html,application/xhtml+xml,text/xml;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
- This variable is the name of the remote client browser software.
<!--#echo var="HTTP_USER_AGENT" -->
: CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
- This variable is the URL of the HTML document which referred the remote client to this document.
<!--#echo var="HTTP_REFERER" -->
: (none)
- This variable is the name (most likely the-mail address) of the remote client user.
<!--#echo var="FROM" -->
: (none)
- This variable is the name of the proxy server through which this document is being processed.
<!--#echo var="FORWARDED" -->
: (none)
- This variable lists the human languages that are acceptable to the remote client.
<!--#echo var="ACCEPT_LANGUGE" -->
: (none)
- This variable contains the cookie sent by the remote client.
<!--#echo var="HTTP_COOKIE" -->
: (none)
- Number of accesses to current document since server was brought on line.
<!--#echo var="PAGE_COUNT" -->
: (none)
- Total pages served by server since brought on line.
<!--#echo var="TOTAL_HITS" -->
: (none)
- Executes a given shell command or CGI script. It must be activated to be used.
<!--#exec cmd="ls -l" -->
:
Data and time modification.
- This variable is current local date and time.
<!--#echo var="DATE_LOCAL" -->
: Monday, 06-Feb-2012 08:14:36 CST
- This variable is the current Greenwich Mean date and time.
<!--#echo var="DATE_GMT" -->
: Monday, 06-Feb-2012 14:14:36 GMT
- Modified data and time.
<!--#config timefmt="%a, %d-%h-%Y at %I:%M:%S%p %Z" --><!--#echo var="DATE_LOCAL" -->
: Mon, 06-Feb-2012 at 08:14:36AM CST
- Modified data and time.
<!--#config timefmt="%A, %B %e, %Y" --><!--#echo var="DATE_LOCAL" -->
: Monday, February 6, 2012
- Modified data and time.
<!--#config timefmt="%D" --><!--#echo var="DATE_LOCAL" -->
: 02/06/12
- Modified data and time.
<!--#config timefmt="%r" --><!--#echo var="DATE_LOCAL" -->
: 08:14:36 AM
You can control the exact appearence of your time and date information
by setting the timefmt using a config such as the one below. Just
include this config before the actual include that calls the date.
<!--#config timefmt="%m/%d/%y" -->
Will give you a date such as 02/06/12
The complete list of unix style date format codes follow:
|
| CODE | PURPOSE OF CODE |
| %a | abbreviated weekday name |
| %A | full weekday name |
| %b | abbreviated month name |
| %B | full month name |
| %c | locale's appropriate date and time representation |
| %C | default date and time format |
| %d | day of month - 01 to 31 |
| %D | date as %m/%d/%y |
| %e | day of month - 1 to 31 (single digits are preceded by a blank) |
| %h | abbreviated month name (alias for %b) |
| %H | hour - 00 to 23 |
| %I | hour - 01 to 12 |
| %j | day of year - 001 to 366 |
| %m | month of year - 01 to 12 |
| %M | minute - 00 to 59 |
| %n | insert a newline character |
| %p | string containing AM or PM |
| %r | time as %I:%M:%S %p |
| %R | time as %H:%M |
| %S | second - 00 to 61 |
| %t | insert a tab character |
| %T | time as %H:%M:%S |
| %U | week number of year (Sunday is the first day of the week) - 00 to 53 |
| %w | day of week - Sunday=0 |
| %W | week number of year (Monday is the first day of the week) - 00 to 53 |
| %x | Country-specific date format |
| %X | Country-specific time format |
| %y | year within century - 00 to 99 |
| %Y | year as CCYY (4 digits) |
| %Z | timezone name |
For detailed SSI information, see:
NCSA HTTPd Server Side Includes
BigNoseBird.Com
Apache Tutorial
I don't know where you came from
<!--#if expr="${HTTP_REFERER} =/http/" -->
You came from: <!--#echo var="HTTP_REFERER" -->
<!--#else -->
I don't know where you came from
<!--#endif -->
Return to HSBB front page
<!--#if expr="${HTTP_REFERER} =/microcaddesign/" -->
Return to <A HREF="<!--#echo var="HTTP_REFERER" -->">previous page</A>
<!--#else -->
Return to <A HREF="http://www.microcaddesign.com/books/">HSBB front page</A>
<!--#endif -->
|