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, 25-Apr-2024 02:20:10 CDT

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

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

...results in...

Thursday, April 25 2024

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

Display Full Display Abbreviated
Code Results Example Code Results Example
%B Month April %b Month Apr
%A Weekday  Thursday %a Weekday Thu
%Y Year 2024 %y Year 24
%D Date 04/25/24 %d Day of the Month 25
Other Customizations
%H Current Hour
(1-24)
02 %I Current Hour
(1-12)
02
%M Current Minutes
(0-60)
20 %S Current Seconds
(0-60)
10
%p AM or PM AM %Z Time Zone CDT
%m Month (1-12) 04      
Time Saving Commands
%R Time
(24 hours)
Displayed as...
(%H:%M)
02:20 %r Time
(12 hours)
Displayed as...
%I:%M:%S:%p
02:20:10 AM
%T Time
(24 hours)
Displayed as...
(%H:%M:%S)
02:20:10      

 

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

 

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...
  18.117.153.38
<!--#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, 25-Apr-2024 02:20:10 CDT
<!--#echo var="DATE_GMT" --> Current GMT Date and Time...
  Thursday, 25-Apr-2024 07:20:10 GMT
Miscellaneous...
<!--#include file="folder/name.txt" --> You can include a text file or some other file to be displayed.  Thursday, 25-Apr-2024 02:20:10 CDT

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