SSI use details 1

xiaoxiao2021-03-06  104

SSI use details 2000

-

05

-

28. Lu Xiaobo, CPCW, have you been distressed in how you can complete the changes to a website containing thousands of pages in the shortest time

?

So you can look at this paper

,

Perhaps you can help you. What is SSI

?

SSI is an abbreviation in English Server Side Includes

,

Translated into Chinese is the meaning of the server side. From the technical perspective

,

SSI is in the HTML file

,

You can call the command or pointer that is called by the comment line. SSI has a powerful function

,

Just use a simple SSI command to realize the content update of the entire website

,

Dynamic display time and date

,

And complex features such as SHELL and CGI scripts. SSI can be said to be the best helper for website developers who have a shortage of funds, time, and workload. SSI is initially launched on the NCSA server platform

,

Extension and strengthen in the Apache server

,

It is now possible to run on almost all servers. This article will mainly bind to the APACHE server to introduce the use of SSI. How to start SSI

?

Under the Apache server

,

You can create a direct editing server profile or create in a directory you need to use SSI

.

The HTACcess file launches SSI. Specifically

,

The process is as follows

:

1

.

Server profile If the user has access to the server profile

,

You can edit file Access

.

CONF and SRM

.

Conf started SSI. First use the Telnet remote login server

,

Find the storage directory of the configuration file. Generally

,

The configuration file of the Apache server is saved "

/

USR

/

Local

/

ETC

/

httpd

/

Conf "Copy Directory. Use any text editor to open the file SRM

.

CONF

,

Found a few of the following lines

:

#

IF

You Want To

USE

Server Side Includes

,

oral

CGI Outside # ScriptaliaSed Directories

,

Uncomment the folowing lines

.

#Addtype text

/

x

-

Server

-

parse

-

HTML

.

SHTML # addtype copLication

/

x

-

httpd

-

Cgi

.

CGI users may not have the above note instruction line

,

But just find two rows starting with ADDTYPE and remove the "#" symbol of each row. Save the modification

,

Then open the file access

.

CONF. Users need to find DocumentRoot in the file

(

Root file

)

part. Generally, the text is as follows.

,

But do not exclude

<

Directory

>

with

<

/

Directory

>

Other settings are also included between the tags. # This kind be change to whatver you set documentroot to

.

<

Directory

/

USR

/

Local

/

ETC

/

httpd

/

HTDOCS

>

# This may also be

"None"

,

"All"

,

oral

Any Combination of

"中 ES"

,

#

Includes "

,

oral

"FOLLOWSYMLINKS"

Options INDEXES FOLLOWSYMLINKS INCLUDES <

/

Directory

>

If the user does not want to execute a script or shell command

,

You can add keyword in the Options option row. Includesnoexec

,

This allows SSI to allow SSI

,

However, the CGI or script command cannot be performed.

(

Note

:

The latest version of the Apache server has only one profile httpd

.

CONF

,

The content mentioned above has been included in this file.

)

2

.

Create a file

.

HTACCESS If the user can't access the server profile directly

,

You can use the file editor to create a named

.

HTACCESS file. note

,

There must be symbols before the file name "."

,

This way the server can know that the file is hidden file.

,

Thereby improving the security of documents

,

Avoid error operations. in

.

The following three lines of text need to be added in the HTACcess file

:

Options Indexes Followsymlinks IncludesaddType Application

/

x

-

httpd

-

Cgi

.

Cgiaddtype text

/

x

-

Server

-

parse

-

HTML

.

After the SHTML is completed, you can

.

HTACCESS file upload to the corresponding directory of the server

,

This file is valid for all subdirectories. If the user wants to disable the CGI or shell command on the directory level

,

allowable

.

The Options option line in the htaccess file is added to the keyword includesnoexec. 3

.

use

.

SHTML or

.

HTML

?

Any file containing SSI before it is submitted to the client

,

All must be parsed by the server. Although this will increase the load of the server from some extent

,

But unless the user's website has millions of access users every day

,

The performance of a server does not have a significant decline. but

,

If it is not necessary to use SSI in each page

,

It doesn't have the need to let the server parses each page. If users only want to use SSI in several special pages

,

Can change the file's suffix name to

.

SHTML

,

Such a server can only be parsed contains SSI

.

SHTML file. on the other hand

,

If there are multiple pages to use SSI

,

But users don't want to use

.

SHTML's suffix time

,

allowable

.

Use the following command line in the HTACcess file

:

AddType Text

/

x

-

Server

-

parse

-

HTML

.

HTMLSSI syntax SSI follows the following formats

:

<

!

-

-

# Directive Parameter

=

Value

-

-

>

among them

,

Directive is the directive name sent to the server

,

Parameter is the operation object of the instruction

,

Value is the instruction processing result that the user wants. All SSI commands are "

<

!

-

-

#"Start

,

among them"

<

!

- "and" # "can't have any spaces

,

Otherwise, the server will use the SSI command as a normal file annotation process.

,

No results will be displayed

,

Nor does not generate an error message. In addition

,

"SSI command" "

=

"No spaces on both sides

,

The value on the right must be included in double quotes.

,

Once you can follow the space

,

Lastly the end of the label "-

-

>

".Ssi command contains six major classes and their respective parameters

,

details as follows

:

Directives Parameters config errmsg

,

Timefmt

,

Sizefmt

Include

Virtual

,

File

echo

VAR

Fsize File FlastMod File Exec CMD

,

Under CGI, we will introduce one by one. 1

.

The config command config command is primarily used to modify the default settings of the SSI. among them

:

Errmsg

:

Set the default error message. In order to be able to return the user setting error information normally

,

In the html file, the errmsg parameter must be placed in front of other SSI commands.

,

Otherwise the client can only display the default error message

,

Instead of being customized by the user.

<

!

-

-

#Config errmsg

=

"Error! Please email webmaster@mydomain.com -> timefmt: Define the date and time of the time pattern. Timefmt parameter must be used before the echo command.

%

A

,

%

B

%

di

,

%

Y

"->

Last_Modified

"-> The result is: Wednesday, April 12, 2000 may be very unfamiliar with the% a% b% D used in the previous example, and we will summarize some of the more commonly used in SSI in the form of forms. Time format. Format Description Instance %%%% A week seven days of abbreviation form ThursDay a week. Thursday% B Month Abbreviation Form APR% B month April% d 13% D mm / dd / yy Date format 04/13/00% h hours (24-hour system, from 00 to 23) 01% i hour (12 small system, from 00 to 11) 01% J For the first few days in the year, from 01 to 365 104% M. The first few minutes from 01 to 12 04% M. from 00 to 59 10% P AM or PM% R 12 hourly, format 01:10: 18 AM% i:% m:% s AM | PM% S in the first few seconds from 00 to 59 18% T 24 hour% h:% m:% s time format 01:10:18% U One year in the year, from 00 to 15 52, Sunday as the first day of each week, the first day of each week, from 0 By 6 4% W Word from 00 15 to 53, as a first day of the first day of each week, from 00 to 99 00% Y, from 00 to 99,00% y in Monday. Year 2000% Z Time Zone Name MDT Sizefmt: Decision file size is represented by bytes, killed or megabytes. If in bytes, the parameter value is "BYTES"; the abbreviated form can be used for kilobytes and megabytes. Similarly, the SIZEFMT parameter must be placed in front of the fsize command.

"->

Index

.

HTML

"-> 2.include command The include command can insert the text or image in other documents into the currently resolved document, is the key to the entire SSI. You can instantly update the entire site with you through the include command! The include command has two different parameters. If you use the wrong parameter update site, you will not only get the original intention, but you will get a lot of error messages. Virtual: Give the virtual path to the server side. For example:

Includes

/

HEADER

.

HTML

"-> In order to more reasonable organizational site, users can create an incrudes subdirectory in the root directory to store all the included files .virtual parameters can notify the server to include a virtual file, that is, the file and the current parsed The document is not located in the same directory, but stores in other directories. The server will find the incrudes subdirectory in the root directory based on the value of this parameter. Use this method, the user can put all the HTML documents contained in a directory in a directory And save different pages in different directories or subdirectories, depending on the relationship between each other. Regardless of which documentation can find the files contained, there will be no errors. However, there is a small problem to solve it. Generally we have added some Title and Meta tags in the page. If we specify that all pages call the same header file, it is very unflexible. When the user encounters such a problem, you can use two containing files, A section set before setting the Title tag and the part after setting the Meta tag, and any custom content can be added between the two containing files. For example:

/

Includes

/

HEADER1

.

HTML

"-> Your page title </ title> <link rel = stylesheet href ="</p> <p>HTTP</p> <p>:</p> <p>/</p> <p>/</p> <p>Domain</p> <p>.</p> <p>COM</p> <p>/</p> <p>Styles</p> <p>/</p> <p>MY</p> <p>.</p> <p>CSS</p> <p>"Type ="</p> <p>TEXT</p> <p>/</p> <p>CSS</p> <p>"> <Meta name ="</p> <p>Description</p> <p>"Content ="</p> <p>Description of Page</p> <p>"> <Meta name ="</p> <p>Keywords</p> <p>"Content ="</p> <p>Keywords</p> <p>for</p> <p>page</p> <p>"> - # include virtual ="</p> <p>/</p> <p>Includes</p> <p>/</p> <p>HEADER2</p> <p>.</p> <p>HTML</p> <p>"-> Let's place the page content <! - # include virtual =</p> <p>/</p> <p>Includes</p> <p>/</p> <p>Footer</p> <p>.</p> <p>HTML</p> <p>"-> From the top we can see how to reduce the workload of the site update by including the header and footer in the page. But if we want to dynamically display some content, such as what should I do if the last update time of the page is? No problem, we can use the containment file to save, so you can call other include files in the included file. File: Give it to the relative path to the current directory, where "../" cannot be used. Absolute path. For example: <! - # include file = "</p> <p>HEADER</p> <p>.</p> <p>HTML</p> <p>"-> This requires every directory containing a header.html file. Of course, this method is not more simple than the update, but if the user is only updated, the two files are still very convenient. For example, if we don't want a person who is not familiar with HTML directly to change the news page in the website, you can only update a separate text file, and then contain this file into the HMTL document, so you won't damage it. Original page, at the same time, the content is updated, two all the beautiful .3.echo: echo command can display the following environment variables: Document_name: Displays the name of the current document. <! - # echo var = "Document_name</p> <p>"-> The result is: index.html document_uri: Displays the virtual path of the current document. For example: <! - # echo var ="</p> <p>Document_uri</p> <p>"-> The result is: /yordirectory/yourfilename.html With the continuous development of the website, those increasingly long URL addresses will definitely make people a headache. If you use SSI, everything will be solved. Because we can put the site The domain name and SSI command are combined to display the complete URL, namely: http:// your3omain <! - # echo var = "</p> <p>Document_uri</p> <p>"-> query_string_unescaped: Displays the query string sent by the client unsubmitted by the client, all of which have essential characters" / ". For example: <! - # echo var =</p> <p>Query_string_unescaped</p> <p>"-> DATE_LOCAL: Display the date and time of the server setting time zone. The user can customize the output information in conjunction with the TIMEFMT parameter of the config command. For example: <! - # config timefmt ="</p> <p>%</p> <p>A</p> <p>,</p> <p>THE</p> <p>%</p> <p>D of</p> <p>%</p> <p>B</p> <p>,</p> <p>In the year</p> <p>%</p> <p>Y</p> <p>"-> <! - # echo var ="</p> <p>Date_local</p> <p>"-> The result is: Saturday, The 15 of April, in the year 2000 date_gmt: The function is the same as DATE_LOCAL, but returns to the date based on the Greenwich standard time. For example: <! - # echo var = "</p> <p>Date_gmt</p> <p>"-> Last_Modified: Displays the last update time of the current document. Similarly, this is a very practical feature in SSI, as long as the following simple text is added to the HTML document, you can update the update time on the page. <! - # echo var = "</p> <p>Last_Modified</p> <p>"-> CGI Environment Variable In addition to the SSI environment variable, the echo command can also display the following CGI environment variables: server_software: Displays the name and version of the server software. For example: <! - # echo var ="</p> <p>Server_software</p> <p>"-> Server_name: Display the host name, DNS align name, or IP address of the server. For example: <! - # echo var ="</p> <p>Server_name "-> Server_Protocol: Displays the protocol name and version used by the client request, such as http / 1.0. For example: <! - # echo var =</p> <p>Server_Protocol</p> <p>"-> Server_port: Displays the response port of the server. For example: <! - # echo var ="</p> <p>Server_port</p> <p>"-> Request_method: Display the client's document request method, including get, head, and post. For example: <! - # echo var =</p> <p>Request_method</p> <p>"-> Remote_host: Display the client host name that issues request information. <! - # echo var ="</p> <p>REMOTE_HOST</p> <p>"-> Remote_addr: Display the client IP address of the request information. <! - # echo var =</p> <p>REMOTE_ADDR</p> <p>"-> auth_type: Display the authentication method of user identity. <! - # echo var ="</p> <p>Auth_type</p> <p>"-> Remote_user: Display the account name used by the user who is accessing the protected page. <! - # echo var =</p> <p>Remote_user</p> <p>"-> 4.FSIZE: Displays the size of the specified file, you can customize the output format in conforming the SIZEFMT parameter of the config command. <! - # fsize file ="</p> <p>INDEX_WORKING</p> <p>.</p> <p>HTML</p> <p>"-> 5.FlastMod: Display the final modification date of the specified file, can combine the TIMEFMT parameter control output format of the config command. <! - # config timefmt ="</p> <p>%</p> <p>A</p> <p>,</p> <p>THE</p> <p>%</p> <p>D of</p> <p>%</p> <p>B</p> <p>,</p> <p>In the year</p> <p>%</p> <p>Y</p> <p>"-> <! - # FlastMod file ="</p> <p>File</p> <p>.</p> <p>HTML</p> <p>"-> Here we can use the FLASTMOD parameter to display the update date of all links on a page. The method is as follows: <! - # config timefmt ="</p> <p>%</p> <p>B</p> <p>%</p> <p>di</p> <p>,</p> <p>%</p> <p>Y</p> <p>"-> <a href ="</p> <p>/</p> <p>Directory</p> <p>/</p> <p>File</p> <p>.</p> <p>HTML</p> <p>"> File </a> <! - # FlastMod Virtual ="</p> <p>/</p> <p>Directory</p> <p>/</p> <p>File</p> <p>.</p> <p>HTML</p> <p>"-> <a href ="</p> <p>/</p> <p>Another_directory</p> <p>/</p> <p>Another_file</p> <p>.</p> <p>HTML</p> <p>"> Another file </a> <! - # FlastMod Virtual ="</p> <p>/</p> <p>Another_directory</p> <p>/</p> <p>Another_file</p> <p>.</p> <p>HTML</p> <p>"-> The result is: File April 19, 2000another File January 08, 2000 maybe some readers will think that two links are so complicated, it is not convenient. In fact, there are 20 or more links on the page, And each link is regularly updated, you can see the role of using FLASTMOD to display the modification date. 6.execexec command can execute a CGI script or shell command. The method is as follows: CMD: Use / bin / SH to perform the specified string. If the SSI uses the IncludDesNoexec option, the command will be blocked. CGI: You can use the CGI script. For example, in the following example, the Counter.pl scripter under the server CGI-BIN directory is placed in each page. : <! - # EXEC CGI = "/</p> <p>cgi</p> <p>-</p> <p>bin</p> <p>/</p> <p>Counter</p> <p>.</p> <p>PL "</p> <p>-</p> <p>-</p> <p>></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-104163.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="104163" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.047</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'RX6reqLbZZgibImUt38Jf5HrmtDuNMVFdgrvwzZtWg9S5m36Px5JNeFFyUjyqaLL48uGENax7_2B21seHK0c6xbw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>