Home >Web Front-end >CSS Tutorial >shtml streamlined tutorial lets you know what shtml is_Basic Tutorial

shtml streamlined tutorial lets you know what shtml is_Basic Tutorial

WBOY
WBOYOriginal
2016-05-16 12:08:551612browse

At present, it mainly has the following uses: ​
1. Display server-side environment variables ​
2. Insert text content directly into the document ​
3. Display WEB document related information (such as file creation date/size etc.)
4. Directly execute various programs on the server (such as CGI or other executable programs)
5. Set the SSI information display format (such as file creation date/size display method) Advanced SSI can set variables to use if conditional statement.​
What is the use of SSI? The reason why we have to talk about ssi is because of the acronym of shtml--server-parsed HTML. Contains HTML text containing embedded server-side include commands. The SHTML document is completely read, analyzed, and modified by the server before being sent to the browser.
shtml is somewhat similar to asp. Files named shtml use some SSI instructions, just like the instructions in asp. You can write SSI instructions in SHTML files when the client accesses these shtml files. ,
The server will read and interpret these SHTML files, and interpret the SSI instructions contained in the SHTML files. For example: you can use SSI instructions in the SHTML file to reference other html files (#include), and the server transmits them. The file given to the client is already interpreted SHTML and will not have SSI directives. It realizes functions that HTML does not have, that is, it can realize dynamic SHTML. It can be said to be an evolution of HTML. Sina's news system is like this. The news content is fixed, but the advertisements and menus on it are referenced using #include.
At present, there are mainly the following uses:
1. Display server-side environment variables
2. Insert text content directly into the document
3. Display WEB documents Related information
(such as file creation date/size, etc.) 4. Directly execute various programs on the server
(such as CGI or other executable programs) 5. Set SSI information Display format
(such as file creation date/size display method) Advanced SSI
You can set variables using if conditional statements.
Using SSI
SSI is a set of commands provided for the WEB server. These commands only need to be directly embedded into the comment content of the HTML document. For example:
 
 It is an SSI command, its function is to copy the content of "info.htm" to the current page. When visitors come to browse, they will see info displayed like other HTML documents. .htm content.
The usage form of other SSI commands is basically the same as the example just now. It can be seen that SSI usage only requires inserting a little code, and the usage form is very simple.
Of course, if the WEB server does not support SSI, it will just treat it as annotation information and skip the content directly; the browser will also ignore this information.
 
How to configure the SSI function on my WEB server?
On some WEB servers (such as IIS 4.0/SAMBAR 4.2), files containing #include directives must use an extension that has been mapped to the SSI interpreter; otherwise, the Web server will not process the SSI directive; by default , the extensions .stm, .shtm and .shtml are mapped to the interpreter (Ssinc.dll).
Apache depends on your settings. Modify srm.conf such as:
AddType text/x-server-parsed-html .shtml will only parse SSI instructions for files with the .shtml extension
AddType text/x-server-parsed-html .html will parse SSI instructions for all HTML documents
Netscape WEB server can directly use the Administration Server to turn on the SSI function.
The website uses the Mapping tag in the Server Admin program, and the content type added to the extension is: wwwserver/html-ssi
The Cern server does not support SSI. You can use the SSI fraud method, go to http://sw.cse.bris. Download a PERL script from ac.uk/WebTools/fakessi.html to make your CERN server use some SSI commands. (The exec command is not supported.)

Basic format of SSI command
Basic format of SSI command:
Program code:


Such as
Program code:


Description:
1. is a comment in HTML syntax. When the WEB server does not support SSI, this information will be ignored.
2. #include is one of the SSI directives.
3. file is the parameter of include, info.htm is the parameter value, which in this command refers to the name of the document to be included.
Note:
1. There is no space between


Name of this document: Program code:

## #Now time: Program code:


Your IP address is the program code:


#include Demonstration ## #Function:
Insert the content of the text file directly into the document page.
Syntax:
Program code:




file The file name is a relative path, which is relative to The directory where the document using the #include directive is located. The included file can be in the same level directory or its subdirectory, but not in the upper level directory. For example, if it represents the nav_head.htm document in the current directory, it is file="nav_head.htm".
virtual file name is the full path to the virtual directory on the Web site. If it means relative to the nav_head.htm file in the hoyi directory under the server document root directory; then it is file="/hoyi/nav_head.htm"
Parameters:
file specifies the location of the included file relative to this document ## #virtual Specifies the location relative to the server document root directory
Note:
1. The file name must have an extension.
2. The included files can have any file extension. I think it is most convenient to directly use the htm extension. Microsoft recommends using the .inc extension (it depends on your preference).
Example:
Program code:

Insert the header file into the current page
Insert the tail file into the current page
Insert the header file into the current page
Insert the tail file into the current page #flastmod and #fsize Demonstration
Function: #flastmod The last update date of the file
#fsize The length of the file
Syntax:
Program Code:




Parameters:
file specifies the location of the included file relative to this document, such as info.txt represents the current The info.txt document under the directory
virtual specifies the location relative to the server document root directory, such as /hoyi/info.txt means
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 into the current page
Program code: #
##

Insert the file size of news.htm in the current directory into the current page
#exec demonstration
Function:
Insert an external program The output is inserted into the page. It can be inserted into CGI programs or as input to regular applications, depending on whether the parameters used are cmd or cgi.
Syntax:
Program code:




Parameters:
cmd Regular application
cgi CGI script program
Example:
Program code:
will display the password file
will display the file list in the current directory
will execute CGI Program gb.cgi.
The CGI program access_log.cgi will be executed.
The password file will be displayed
The file list in the current directory will be displayed
The CGI program gb.cgi will be executed.
The CGI program access_log.cgi will be executed.
Note:
As you can see from the above example, this command is quite convenient, but it also has security issues.
Prohibition method:
. Apache, delete the "Options Includes ExecCGI" line in access.conf;
. In IIS, to disable the #exec command, you can modify the SSIExecDisable metabase;

#config
Function: Specify the format of the error message, date and file size returned to the client browser.
Grammar:
Program code:






Parameters:
errmsg Customize SSI execution error message in any way you like.
sizefmt File size display mode, the default is byte mode ("bytes") and can be changed to kilobyte mode ("abbrev")
timefmt Time display mode, the most flexible configuration attribute.
Example: Display the size of a non-existent file
Program code:




In kilobytes Display file size
Program code:




Display time in a specific time format
Program code: #
##
Display the day of the week, month and time zone today is



Display the day of the week today is , months, time zone

XSSI
XSSI (Extended SSI) is a set of advanced SSI instructions built into the mod-include module of Apache 1.2 or higher middle.
The available instructions are:
#printenv
#set
#if
#printenv
Function: Display all environment variables currently existing in the WEB server environment.
Grammar: Program code:


Parameters: None
Example:
Program code:


# set

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn