Home  >  Article  >  Web Front-end  >  STHML tutorial(2)

STHML tutorial(2)

巴扎黑
巴扎黑Original
2017-04-05 09:40:291385browse

Basic format of SSI command

code:

illustrate:

  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.

Notice:

  1. Example:

    The name of this document
    Current time
    Your IP address

    #include demonstration

    Function: Insert the content of the text file directly into the document page.

    grammar:


    file The filename is a relative path 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 means the nav_head.htm file in the hoyi directory relative to 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

    Notice:

    1. The file name must have an extension.


    2. The included files can have any file extension. I find it most convenient to use the htm extension directly. Microsoft recommends using the .inc extension (it depends on your preference).

    Example:

    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
    #fsize file length

    grammar:


    Parameters:

    file specifies the location of the included file relative to this document. For example, info.txt represents the info.txt document in the current 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:

    Insert the latest update date of the news.htm file in the current directory into the current page
    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.

    grammar:


    Parameters:

    cmd regular application
    cgi CGI script program

    Example:

    The password file will be displayed
    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.

    Note: As you can see from the above example, this command is quite convenient, but it also has security issues.

    Prohibited methods:

    1. Apache, delete the "Options Includes ExecCGI" line in access.conf;


    2. In IIS, to disable the #exec command, modify the SSIExecDisable metabase;

    #config

    Function: Specify the format of error information, date and file size returned to the client browser.

    grammar:



    Parameters:

    errmsg Customize SSI execution error messages 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


    Display file size in kilobytes

    grammar:


    Display time in a specific time format


    Display today’s day of the week, month, and time zone


The above is the detailed content of STHML tutorial(2). For more information, please follow other related articles on the PHP Chinese website!

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
Previous article:STHML tutorial (1)Next article:STHML tutorial (1)