SSI and SHTML

SSI (Server Side Includes) and SHTML Setup

By using SSI, you can utilize dynamic features for your web site.  For example, by placing the following code...

<!--#echo var="DATE_LOCAL" -->

...inside your HTML and naming your HTML file with the extension .shtml, when the .shtml file is called via a browser, the server will scan (parse) the HTML code for special commands.  The command above generated the following date when you "called" for this web page via your browser...

Thursday, 14-Dec-2017 02:18:37 CST

We can easily change how the date looks such as...

<!--#config timefmt="%A, %B %d %Y" --> <!--#echo var="DATE_LOCAL" -->

...results in...

Thursday, December 14 2017

So what commands are available regarding the date?  Here they are...

Display Full Display Abbreviated
Code Results Example Code Results Example
%B Month December %b Month Dec
%A Weekday  Thursday %a Weekday Thu
%Y Year 2017 %y Year 17
%D Date 12/14/17 %d Day of the Month 14
Other Customizations
%H Current Hour
(1-24)
02 %I Current Hour
(1-12)
02
%M Current Minutes
(0-60)
18 %S Current Seconds
(0-60)
37
%p AM or PM AM %Z Time Zone CST
%m Month (1-12) 12      
Time Saving Commands
%R Time
(24 hours)
Displayed as...
(%H:%M)
02:18 %r Time
(12 hours)
Displayed as...
%I:%M:%S:%p
02:18:37 AM
%T Time
(24 hours)
Displayed as...
(%H:%M:%S)
02:18:37      

 

Date and Time Examples...
<!--#config timefmt="%A %B %d %Y" --> <!--#echo var="DATE_LOCAL" --> Thursday December 14 2017
<!--#config timefmt="%I %p" --> <!--#echo var="DATE_LOCAL" --> 02 AM
<!--#config timefmt="%B %d" --> <!--#echo var="DATE_LOCAL" --> December 14

 

Additional SSI Commands
Web Page Related...
<!--#echo var="HTTP_REFERER" --> The page that brought you here was...
  (none)
<!--#echo var="REMOTE_ADDR" --> Your IP address is...
  54.83.122.227
<!--#echo var="DOCUMENT_NAME" --> The name of the web page you are currently viewing is...
  ssi_and_shtml.shtml
<!--#fsize file="ssi_and_shtml.shtml" --> The size of the web page you are currently viewing is...
   30K
<!--#flastmod file="ssi_and_shtml.shtml" --> The page you are currently viewing was last modified on...
  Tuesday, 24-Jan-2006 10:16:26 CST
Date Related...
<!--#echo var="DATE_LOCAL" --> Current Date and Time...
  Thursday, 14-Dec-2017 02:18:37 CST
<!--#echo var="DATE_GMT" --> Current GMT Date and Time...
  Thursday, 14-Dec-2017 08:18:37 GMT
Miscellaneous...
<!--#include file="folder/name.txt" --> You can include a text file or some other file to be displayed.  Thursday, 14-Dec-2017 02:18:37 CST

Running a CGI or PL program from .shtml

If you call or run a CGI or PL program from an HTML document in a statement such as...

<!--#exec cgi="/cgi-bin/counter/counter.cgi" -->

...make sure you name the HTML file with the extension ".shtml" or it will not run the requested CGI program.

Because the server scans the SHTML file for special codes, this scan will result in two side effects.  1. A pause in display while the server scans the HTML file and performs any requested actions it finds embedded within the HTML, and 2. More server resources are naturally required to parse a .shtml page.  Keep this in mind as to not overuse .shtml pages on a busy web site.

Common Questions About SSI (SHTML)

PROBLEM:  When I view the .shtml page in the browser, and then view the HTML source code, the SSI command is still there and the expected results aren't displayed.

WHAT IS HAPPENING:  The server does not recognize the SSI command.

SOLUTION:  For all SSI commands, make sure there is ONE SPACE before the closing symbol --> as follows...
<!--#exec cgi="/cgi-bin/counter/counter.cgi" -->

PROBLEM:  The page shows the following...
[an error occurred while processing this directive]

WHAT IS HAPPENING:  The server recognizes the SSI command, however, there is an error in the SSI command and the server doesn't know what to do.

SOLUTION:  Make sure the path and filename in the SSI command is correct.

PROBLEM:  When I view the .shtml page in the browser, and then view the HTML source code, the SSI is no longer there, but the are no results displayed in its place.

WHAT IS HAPPENING:  The server has recognized the SSI command and has attempted to run the CGI or PL program.  However, there is either an error in the CGI program, or no output is defined in the CGI program.

SOLUTION:

 

Please note that scripts can enter infinite loops and cause problems for any server.  Please edit scripts with care!

For additional assistance visit our CGI-bin Applications Page.

[Manual Index]

 

Copyright 2000-2006 ActiveWebHost.com. All Rights Reserved. Terms and Conditions of Use and Privacy Policy. ActiveWebHost.com - Your Success Is Our Success