Home > Web Front-end > HTML Tutorial > Shtml streamlined tutorial_HTML/Xhtml_Web page production

Shtml streamlined tutorial_HTML/Xhtml_Web page production

WBOY
Release: 2016-05-16 16:42:15
Original
2070 people have browsed it

There are some similarities between shtml and asp. In the file named shtml, some SSI instructions are used, just like the instructions in asp. You can write SSI instructions in the SHTML file. 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 sends them to the client. Files that are already interpreted SHTML will not have SSI directives. It realizes a function that HTML does not have, that is, SHTML that can realize dynamic
, which 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.
Currently, 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 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:

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 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 .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.
Website uses the Mapping tag in the Server Admin program, and the content type added to the extension is: wwwserver/html-ssi
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:



Instructions:
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 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, the The path is relative to the directory containing the document using the #include directive. 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".
The virtual filename is the full path to the virtual directory on the Web site. For example, it represents the nav_head.htm file in the hoyi directory under the server document root directory; 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 file last updated date
#fsize file length
Syntax:
Program code:





Parameters:
file specifies the location of the included file relative to this document, such as info.txt represents the info.txt document in the current directory
virtual specifies the location relative to the server document root directory A location 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 the output of an external program 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
The CGI program gb.cgi will be executed.
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 error information, date and file size returned to the client browser.
Syntax:
Program code:







Parameters:
errmsg Customize SSI execution error messages any way you like.
sizefmt file size display mode, the default is bytes 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 thousands Display file size in bytes



Program code:








Display the 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, month and time zone today is



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



Parameters: None
Example:
Program code:




#set
Function: You can assign a value to a variable for use in the subsequent if statement.
Syntax: Program code:



Parameters: None
Example: Program code:




#if
Function: Create a page that can change data. The data is displayed according to the requirements calculated when using the if statement.
Syntax: Program code:


Display content

Display content

Display content


Display content

Display content

Display content

Example:
Program code:


Welcome to the server security discussion forum http://www.31896.net/.

Welcome to Fineacer Computer Network Security Online http://www.fineacer.org/.

Welcome to the server security discussion forum!


Welcome to the server security discussion forum http://www.31896.net/.

Welcome to Fineacer Computer Network Security Online http://www.fineacer.org/.

Welcome to the server security discussion forum!

Note: The backslash used in the previous directive is used to replace internal quotes so that they are not interpreted as terminating the expression. Cannot be omitted.


1. Config command

The Config command is mainly used to modify the default settings of SSI. Among them:

Errmsg: Set the default error message. In order to return the user-set error message normally, the Errmsg parameter must be placed in front of other SSI commands in the HTML file. Otherwise, the client can only display the default error message instead of the custom message set by the user.



Timefmt: Define the format used for date and time. The Timefmt parameter must be used before the echo command.






The result is:

Wednesday, April 12, 2000

Maybe Users are very unfamiliar with the %A %B %d used in the above example. Below we will summarize some of the more commonly used date and time formats in SSI in table form.

Sizefmt: Determines whether the file size is expressed in bytes, kilobytes or megabytes. If in bytes, the parameter value is "bytes"; abbreviations may be used for kilobytes and megabytes. Similarly, the sizefmt parameter must be placed in front of the fsize command to be used.




2. Include command

The Include command can insert text or images from other documents into the currently parsed document , which is the key to the entire SSI. With the Include command, you only need to change one file to instantly update the entire site! The

Include command has two different parameters:

Virtual: gives a virtual path to a document on the server side. For example:



File: gives the relative path to the current directory, where "../" cannot be used, and absolute paths cannot be used. For example:



This requires each directory to contain a header.html file.

3. Echo command

The Echo command can display the following environment variables:

DOCUMENT_NAME: Displays the name of the current document.



The displayed result is:

index.html

DOCUMENT_URI: Displays the virtual path of the current document. For example:



The displayed result is:

/YourDirectory/YourFilename.html

As the website continues to develop, those longer and longer URL addresses will definitely make people Headache. If you use SSI, everything will be solved. Because we can combine the domain name of the website and the SSI command to display the complete URL, that is:

http://yourdomain

QUERY_STRING_UNESCAPED: Display the unescaped URL In the query string sent by the client, all special characters are preceded by the escape character "". For example:



DATE_LOCAL: Displays the date and time in the time zone set by the server. Users can customize the output information by combining the timefmt parameter of the config command. For example:


 

The displayed result is:

Saturday, the 15 of April, in the year 2000

DATE_GMT: The function is the same as DATE_LOCAL, except that it returns a date based on Greenwich Mean Time. For example:



LAST_MODIFIED: Displays the last update time of the current document. Similarly, this is a very practical function in SSI. As long as you add the following simple line of text to the HTML document, the update time can be displayed dynamically on the page.



CGI environment variables

In addition to SSI environment variables, the echo command can also display the following CGI environment variables:

SERVER_SOFTWARE: Display The name and version of the server software. For example:

SERVER_NAME: Displays the server’s hostname, DNS alias, or IP address. For example:

SERVER_PROTOCOL: Displays the protocol name and version used by the client request, such as HTTP/1.0. For example:

SERVER_PORT: Displays the server's response port. For example:

REQUEST_METHOD: Displays the client's document request method, including GET, HEAD, and POST. For example:

REMOTE_HOST: Displays the client host name that issued the requested information.

REMOTE_ADDR: Displays the IP address of the client that issued the request information.

AUTH_TYPE: Displays the verification method of user identity.

REMOTE_USER: Displays the account name used by the user who accessed the protected page.




4. Fsize: Displays the size of the specified file. The output format can be customized by combining the sizefmt parameter of the config command.






5. Flastmod: Displays the last modification date of the specified file, and can be combined with the timefmt parameter of the config command to control the output format.




Here, we can use the flashmod parameter to display the update date of all linked pages on a page. The method is as follows:


File

Another File

Display results For:
File April 19, 2000
Another File January 08, 2000

6. Exec

The Exec command can execute CGI scripts or shell commands. The usage is as follows:

Cmd: Use /bin/sh to execute the specified string. If SSI uses the IncludesNOEXEC option, this command will be blocked.

Cgi: Can be used to execute CGI scripts. For example, in the following example, the counter.pl script in the cgi-bin directory of the server is used to place a counter on each page:

 

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template