Shtml streamlined tutorials Let You Know What shtml _ basic tutorials

Source: Internet
Author: User
Tags netscape web server perl script
The shtml simplified tutorial shows you what shtml is currently for the following purposes:
1. Display Server Environment Variables
2. Insert text content directly into the document
3. display WEB document information (such as file creation date/size)
4. directly execute various programs on the server (such as CGI or other executable programs)
5. Set the SSI information display format (for example, the file creation date/Size Display Mode). Advanced SSI allows you to set variables to use the if Condition Statement.
What is SSI used? The reason we need to talk about ssi is the acronyms of shtml -- server-parsed HTML. Contains HTML text containing commands on the embedded server. Before being sent to a browser, the server will completely read, analyze, and modify the SHTML document.
Shtml is similar to asp. Some ssi commands are used in files named after shtml, just like asp commands. You can write ssi commands in the shtml file, when the client accesses these shtml files,
The server will read and interpret the SHTML files and explain the SSI commands contained in The SHTML files, for example: you can use the SSI command in the SHTML file to reference other html files (# include). The files sent by the server to the client are interpreted as SHTML without the SSI command. It implements functions not available in HTML, that is, it can achieve dynamic
SHTML is an evolution of HTML. Like Sina's news system, the news content is fixed, but the advertisements and menus on it are referenced by # include.
At present, it mainly has the following usage:
1. Display Server Environment Variables <# echo>
2. Insert text content directly into the document <# include>
3. Display WEB Document Information <# flastmod> <# fsize> (for example, file creation date/size)
4. directly execute various programs on the server <# exec> (for example, CGI or other executable programs)
5. Set SSI information display format <# config> (for example, file creation date/Size Display Mode)
Advanced SSI You can set variables to use the if Condition Statement.
 
Use SSI
SSI is a set of commands provided for WEB servers. These commands can be directly embedded in the comments of HTML documents. For example:
<# Include file = "info.htm" -->
It is an SSI command, which serves to bring the content of "info.htm" to the front page. When a visitor visits the page, his htmldocument displays the content of info.htm.
The usage of other SSI commands is similar to the previous example. It can be seen that SSI only inserts a little code, and the usage is very simple.
Of course, if the WEB server does not support SSI, it simply uses it as a comment and directly skips the content. The browser also ignores this information.
 
How can I configure the SSI function on my WEB server?
On some WEB servers (such as IIS 4.0/SAMBAR 4.2), files containing the # include command must use extensions that have been mapped to the SSI interpreter; otherwise, the Web server will not process the SSI command; by default, the extension. stm ,. shtm and. shtml is mapped to the interpreter (Ssinc. dll ).
Apache depends on your settings. Modify srm. conf as follows:
AddType text/x-server-parsed-html. shtml parses only the file with the .shtml extension SSI command
AddType text/x-server-parsed-html. html parses SSI commands for all HTML documents
The Netscape WEB Server directly uses the Administration Server to enable the SSI function.
Website uses the Mapping label in the Server Admin program. The content type added with the extension is wwwserver/html-ssi.
The Cern server does not support SSI. You can use the SSI fraud method to download a PERL script from the http://sw.cse.bris.ac.uk/WebTools/fakessi.html so that your CERN server can use some SSI commands. (Exec commands are not supported .)
 
SSI command basic format
SSI command basic format:
Program code:


For example
Program code:
<# Include file = "info.htm" -->
<# Include file = "info.htm" -->
Note:
1. Is an annotation in HTML syntax. When the WEB server does not support SSI, this information is ignored.
2. # include is one of the SSI commands.
3. file is the include parameter and info.htm is the parameter value. In this instruction, specify the document name to be included.
Note:
1.


This document name: program code:


Current Time: program code:


Your IP address is the program code:


# Include example
Purpose:
Insert the content of a text file to the document page.
Syntax:
Program code:
<# Include file = "file name" -->
<# Include virtual = "file name" -->
<# Include file = "file name" -->
<# Include virtual = "file name" -->
The file name is a relative path, which is relative to the directory of the document using the # include command. The contained file can be in the same level directory or its sub-directory, but not in the upper level directory. For example, the nav_head.htm document under the current directory is file = "nav_head.htm ".
The virtual File name is the complete path of the virtual directory on the Web site. For example, if the parameter is relative to the nav_head.htm file in the hoyidirectory under the Server file root directory, it is file = "/hoyi/nav_head.htm"
Parameters:
File specifies the location of the contained file relative to this document
Virtual specifies the location relative to the root directory of the server document
Note:
1. The file name must have an extension.
2. The contained file can have any file extension. I think it is most convenient to directly use the htm extension. Microsoft recommends using the. inc extension (this depends on your hobby ).
Example:
Program code:
<# Include file = "nav_head.htm" --> Insert the header file to the current page.
<# Include file = "nav_foot.htm" --> Insert the last file to the current page.
<# Include file = "nav_head.htm" --> Insert the header file to the current page.
<# Include file = "nav_foot.htm" --> Insert the last file to the current page.
# Flastmod and # fsize demonstration
Purpose: # The Last Update date of the flastmod File
# Fsize file length
Syntax:
Program code:




Parameters:
File specifies the position of the file to be included in this document, such as info.txt under the current directory.
Virtual specifies the location relative to the root directory of the server document, as shown in/hoyi/info.txt
Note:
The file name must have an extension.
Example:
Program code:


Insert the latest update date of the news.htm file in the current directory to the current page.
Program code:


Add the news.htm file in the current directory to the current page.
 
# Exec demonstration
Purpose:
Insert the output of an external program to the page. The input of a CGI program or a general application can be inserted, depending on whether the parameter is cmd or cgi.
Syntax:
Program code:




Parameters:
Cmd common application
Cgi CGI script program
Example:
Program code:
The password file is displayed.
The file list in the current directory is displayed.
The CGI program gb. cgi will be executed.
The CGI program access_log.cgi will be executed.
The password file is displayed.
The file list in the current directory is displayed.
The CGI program gb. cgi will be executed.
The CGI program access_log.cgi will be executed.
Note:
As shown in the preceding example, this command is quite convenient, but there are also security problems.
Method prohibited:
. Apache: Delete the "Options exist des ExecCGI" line of code in access. conf;
To disable the # exec command in IIS, you can modify the SSIExecDisable metadatabase;

# Config
Purpose: Specify the error message, date, and file size returned to the client browser.
Syntax:
Program code:






Parameters:
Errmsg custom SSI execution error message, which can be any method you like.
Display Mode of sizefmt file size. The default mode is byte mode ("bytes"), which can be changed to kilobytes ("abbrev ")
Timefmt time display mode, the most flexible configuration attributes.
Example: display the size of a non-existing file
Program code:




Display file size in kilobytes
Program code:




Display time in a specific time format
Program code:

Displays the day of the week, month, and time zone.



Displays the day of the week, month, and time zone.


XSSI
XSSI (Extended SSI) is a set of advanced SSI commands built into the mod-include module of Apache 1.2 or later.
The available Commands include:
# Printenv
# Set
# If
# Printenv
Purpose: Display All environment variables currently in the WEB server environment.
Syntax: program code:


Parameter: None
Example:
Program code:


# Set

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.