| CODE | PURPOSE OF CODE | OUTPUT |
| ALL_HTTP | All the name/value pairs for HTTP environment variables. | (none) |
| QUERY_STRING_UNESCAPED | holds unaltered query string with all shell metacharacters escaped with a "\" | (none) |
| AUTH_PASSWORD | The password provided by the user to the server if this page denied anonymous access and the client authenticated using the Basic method. | (none) |
| AUTH_TYPE | client authorization method if any | (none) |
| AUTH_USER | The username provided by the user to the server if this page denied anonymous access under both Basic and NTLM methods. | (none) |
| CONTENT_LENGTH | The number of bytes of data sent as a POST to the server. | (none) |
| CONTENT_TYPE | The MIME type of the data sent as a POST to the server. | (none) |
| DATE_GMT | The current GMT (greenwich, UK) can be formatted using #config | Friday, 18-May-2012 06:46:29 GMT |
| DATE_LOCAL | current time/date, can be formatted using #config | Thursday, 17-May-2012 23:46:29 PDT |
| DOCUMENT_NAME | document name that was requested - holds the current filename | ssi.shtml |
| DOCUMENT_ROOT | The root directory of the site. | /home/infotech/sbotte/info-techs.com/data |
| DOCUMENT_URI | URL of the document -holds path of file from server root to filename | /ssi.shtml |
| GATEWAY_INTERFACE | The type of gateway used to handle the request, e.g. CGI/1.1 | CGI/1.1 |
| HTTP_ACCEPT | A comma-delimited list of MIME types that the client application has notified the server that it can accept. | text/html,application/xhtml+xml,text/xml;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 |
| HTTP_ACCEPT_CHARSET | The Servers accepted character set. | ISO-8859-1,utf-8;q=0.7,*;q=0.7 |
| HTTP_ACCEPT_ENCODING | A comma-delimited list of MIME types that the client application has notified the server that it can accept. | gzip |
| HTTP_ACCEPT_LANGUAGE | The LANGUAGE types the server is requested to accept as defined in the HTTP header and typically used for content negotiation. | en-us,en;q=0.5 |
| HTTP_CACHE_CONTROL | Cache age | no-cache |
| HTTP_CONNECTION | The type of connection as defined in the HTTP header. | close |
| HTTP_COOKIE | Cookie | (none) |
| HTTP_DNT | DNT | (none) |
| HTTP_HOST | The type of connection as defined in the HTTP header. | www.info-techs.com |
| HTTP_REFERER | The URL of the page that made the request. | (none) |
| HTTP_USER_AGENT | The browser id or user-agent string identifying the browser. | CCBot/1.0 (+http://www.commoncrawl.org/bot.html) |
| LAST_MODIFIED | The document modified date, can be formatted using #config | Wednesday, 09-Nov-2011 13:05:13 PST |
| PAGE_COUNT | Number of accesses to current document since server was brought on line | (none) |
| PATH | The path to the current document | /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/bin:HOME/bin |
| PATH_INFO | The full virtual path and filename of the document requested, in relation to the root folder of the web site. | (none) |
| PATH_TRANSLATED | The full physical path and filename of the document requested. | (none) |
| QUERY_STRING | The value of any query string appended to the URL of the document requested, after translation from the URL-encoded format. | |
| QUERY_STRING_UNESCAPED | The value of any query string appended to the URL of the document requested, before translation from the URL-encoded format. | (none) |
| REFERRER | The URL of the document the viewer came from. | (none) |
| REMOTE_ADDR | Numeric IP address of the client | 38.107.179.242 |
| REMOTE_HOST | Domain name of the client (DNS option must be active on server) | (none) |
| REMOTE_PORT | The port number used by the remote host when making this request. | 43498 |
| REMOTE_USER | ID of user, rarely ever found | (none) |
| REQUEST_METHOD | HTTP method: the method used when requesting the page, 'Get' 'Head' or 'Post' | GET |
| REQUEST_URI | The URI of the requested page, relevant to the document root. | /ssi.shtml |
| SCRIPT_NAME | The full virtual path and filename of the document requested in relation to the root folder of the web site. | /ssi.shtml |
| SCRIPT_FILENAME | The full virtual path and filename of the document requested in relation to the root folder of the web site. | /home/infotech/sbotte/info-techs.com/data/ssi.shtml |
| SERVER_ADDR | The IP address of the server for this URL. | 173.51.243.71 |
| SERVER_ADMIN | The administrators email address for this server. | scott@info-tech.com |
| SERVER_NAME | The network name or URL host name of the server that received the request. | www.info-techs.com |
| SERVER_PORT | The port used by httpd (usually 80) | 80 |
| SERVER_PORT_SECURE | The port number if the request was over a secure protocol. | (none) |
| SERVER_PROTOCOL | The HTTP protocol that the request was passed under, HTTP/1.1 | HTTP/1.1 |
| SERVER_SIGNATURE | The HTML string that may be embedded in the page to identify this host. | |
| SERVER_SOFTWARE | The name/version of the web server. | Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8q PHP/5.3.13 |
| TOTAL_HITS | The total pages served by server since brought on line | (none) |
| URL | The complete URL that the user specified when requesting the document. | (none) |
| USER_NAME | The current user name. | sbotte |
The original purpose of SSI was to be able to "include" or copy files into an HTML document. This is one of the truely powerful function SSI can perform, allowing the server to assemble HTML documents from separate include files into a single HTML page which is displayed to the user.
As an example, on this server there exist a file, header.txt, which is in the same directory as the this page (ssi.shtml). The header.txt file contains the following text:<center>This is the text at the top of the HTML page called a header.</center> By using SSI we can include that text in the body of this (or any SSI enabled .shtml) page by using the include file directive:<!--#include file="header.txt" --> This would yield the following output:This is the text at the top of the HTML page called a header. Note that the browser has interpreted the HTML code (the center commnad) as well displaying the text. To see this, view this pages source code.
The above example assumes that the SSI include file is in the same directory as the HTML file calling it. If we wanted to put all of the include files into a folder such as /includes, we would have to use the include virtual directive:
<!--#include virtual="/includes/header.txt" -->This is the text at the top of the HTML page called a header. The SSI include directive can be used as a substitute for the rather complected Cascading Style Sheets (CSS), which currently is not well supported across various browsers, ASP, CGI, PERL, or PHP, allowing dynamic web page content to be assembled from separate files. As an example, this could be used change the theme for a domain. Setting up a Christmas, New Years, 4th of July, etc. set of SSI files which change the background colors and images for all web pages could be automated by using cron to copy the necessary files into the /includes folder.
|
Use the following code to create a "Back Button" link. This will take the viewer back to the page they came here from. Code: <A HREF="<!--#echo var="HTTP_REFERER"-->">BACK BUTTON</A> BACK BUTTON |
Files size can also be displayed using the fsize directive. The code: <!--#config sizefmt="bytes" --><!--#fsize file="ssi.shtml" --> bytes yields the size of this page: 20,544 bytes |
The date and time output for: - DATE_GMT
- DATE_LOCAL
- LAST_MODIFIED
can be formatted using the below listed SSI variables. For example, the standard output for <!--#echo var="DATE_LOCAL" --> looks like:Thursday, 17-May-2012 23:46:29 PDT If we place a format code modifier in front of the directive such as <!--#config timefmt="%m/%d/%y" --><!--#echo var="DATE_LOCAL" --> the modified output yields:05/17/12 |
| %a | Abbreviated weekday name | Thu |
| %A | Full weekday name | Thursday |
| %b | Abbreviated month name | May |
| %B | Full month name | May |
| %c | Locale's appropriate date and time | Thu May 17 23:46:29 2012 |
| %C | Default date and time format | 20 |
| %d | Day of month - 01 to 31 | 17 |
| %D | Date as %m/%d/%y | 05/17/12 |
| %e | Day of month - 1 to 31 | 17 |
| %H | Hour - 00 to 23 | 23 |
| %I | Hour - 01 to 12 | 11 |
| %j | Day of year - 001 to 366 | 138 |
| %m | Month of year - 01 to 12 | 05 |
| %M | Minute - 00 to 59 | 46 |
| %n | Insert a newline character | Line beforeMiddle
Line after |
| %p | String containing AM or PM | PM |
| %r | Time as %I:%M:%S %p | 11:46:29 PM |
| %R | Time as %H:%M | 23:46 |
| %S | Second - 00 to 59 | 29 |
| %t | Insert a tab character | Before TabMiddle After Tab |
| %T | Time as %H:%M:%S | 23:46:29 |
| %U | Week number of year (Sunday is the first day of the week) - 00 to 53 | 20 |
| %w | Day of week - Sunday=0 | 4 |
| %W | Week number of year (Monday is the first day of the week) - 00 to 53 | 20 |
| %x | Country-specific date format | 05/17/12 |
| %X | Current time formatted for servers locale | 23:46:29 |
| %y | Year within century - 00 to 99 | 12 |
| %Y | Year as CCYY (4 digits) | 2012 |
| %z | Time zone name/abbrev of servers time zone. | -0700 |
| %Z | Time zone name/abbrev of servers time zone. | PDT |
| %+ | The national representation of the date and time | Thu May 17 23:46:29 PDT 2012 |
| %% | A percent character. | % |