shtml中的脚本 – SSI 服务器端包含 (Server Side Includes)




服务器端包含(Server Side Includes),通常简称为SSI,是HTML页面中的指令,在页面被提供时由服务器进行运算,以对现有HTML页面增加动态生成的内容,而无须通过CGI程序提供其整个页面,或者使用其他动态技术。


。将服务器信息添加到一个 HTML 文档。包括以下的形式:

<!--#command variablename="value"-->
Whether or not you can use SSI on your site depends on your provider. Ask your favourite support person if you can use SSI, what server software is used and if there are any special techniques, conditions or rules. For example, on my site I can only use SSI in files that have an .shtml extension instead of the normal .html one. You also have to ask what path to files to use.

Unfortunately, not all includes explained here work for all servers. For example, the #hide and #show includes are specific to WebStar. With Apache server software, you can achieve the same things by using #if and #endif.


Before starting to use server side includes, you need to configure a number of things. For starters, choose a format for date and time you like (the #echo command is explained later in this chapter).

<!–#config timefmt=”%A, %d %B %Y at %H:%M:%S”–>
<!–#echo var=”date_gmt”–>

Below is a table of many of the options you can use. You can also include things like colons, commas and slashes as well as bits of text and HTML. You can mix the elements below at will.

Element Value Example
%a Abbreviated day of the week Sun
%A Day of the week Sunday
%b Abbreviated month name Jan
%B Month in full January
%d Date 1 (and not 01)
%H 24-hour clock hour 13
%I 12-hour clock hour 1
%j Decimal day of the year 360
%m Month number 11
%M Minutes 08
%p AM or PM AM
%S Seconds 09
%U Week of the year (also %W) 49
%w Day of the week number 05
%y Year of the century 95
%Y Year 1995
%Z Time zone EST

Here are some more examples of different formats:

<!–#config timefmt=”Week %U of %y”–>
<!–#echo var=”date_gmt”–>

<!–#config timefmt=”%d/%m/%y, day %j of the year”–>
<!–#echo var=”date_gmt”–>

<!–#config timefmt=”%I:%S %p”–>
<!–#echo var=”date_gmt”–>

The last format you have set will remain valid throughout the rest of the page. However, unless you want to use the default format (which usually is something like 98/07/12:16:45:34) you will have to set your favourite time format in every page that uses server side includes that have to do with time.


You can also specify the way file sizes are displayed.

<!–#config sizefmt=”bytes”–>
<!–#fsize file=”top.gif”–>
<!–#config sizefmt=”abbrev”–>
<!–#fsize file=”top.gif”–>

The #fsize include is explained later in this chapter. You can see that the “bytes” option gives the size in full in bytes, the “abbrev” option gives the size in kilobytes.


You can change the default error message to anything you want. Here is an example of changing the error message and then trying to include the non-existent file “nosuchfile.html”:

<!–#config errmsg=”Sorry, an error occurred. Please mail your complaints to”–>

<!–#include file=”nosuchfile.html”–>

There is only one error message available. However, you can change the error message more than once in a single html file:

<!–#config errmsg=”Sorry, an error occurred including nosuchfile.html. Please mail your complaints to”–>

<!–#include file=”nosuchfile.html”–>

<!–#config errmsg=”Sorry, an error occurred including nosuchfileagain.html. Please mail your complaints to”–>

<!–#include file=”nosuchfileagain.html”–>

Specifying your own error messages will make it easier for you to spot and solve problems. If you want to use more than one error message, you have to make sure that you change the error message before the command it refers to.


The include command allows you to dynamically insert other HTML files into the current HTML file. Use it like this:

<!–#include file=”file.shtml”–>

What path to use, again, depends on your provider. Normally it will be a path that is local to the server, so it will not include http://etc. The most sensible use of this command is to take standard bits of your pages such as headers and footer and put them in a separate file. On all of your pages you use the include command to include that file. That way, in order to change the footer on all pages, you only need to change one file. For example, you could make a simple text file that contains:

<P ALIGN=”center”>Copyright 1998 Tom, Dick and Harry<BR>
Please mail us at</P

You save this file as ssifooter.html and include it in your other files by using:

<!–#include file=”ssifooter.html”–>

The files you include can be plain text files or can include HTML. You don’t need to give them <HEAD> and <BODY> tags, just put in whatever you want to insert. In these files you can use whatever HTML you want and you can make links, etc.

隐藏 / 显示

With the Hide and Show commands you can avoid that your reader sees certain parts of the document:

<P>Now you see me, <!–#hide–> This text is not shown. <!–#show–> now you don’t.</P

Show and Hide can be used to temporary exclude parts of your document. Hide and Show only work under WebStar, so I cannot show you an example here.


The next example shows how to display bits of HTML only after certain days. Comparisons like this always use the default time format of 1998/07/24:17:34:45 no matter what you have done with the timefmt option.

<!–#show after=”1998/06/30″–>
This text is shown after 30 June 1998.

<!–#show after=”1999/06/30″–>
This text is shown after 30 June 1999.

Or you can show and hide things on specific days using a combination of ‘hide after’ and ‘show after’:

<!–#show during=”1998/07/12″–>
This text is shown on 12 July 1998.

<!–#show during=”1998/07/13″–>
This text is shown on 13 July 1998.

<!–#show during=”1998/07/14″–>
This text is shown on 14 July 1998.

As you can see, you do not have to specify a full date and time but only what is relevant for you. If you would want to show something during 1998 you could use: during=”1998″.


Here is an example of how to show a bit of text only to a user of Netscape’s Navigator:

<!–#show var=”http_user_agent” operator=”contains”
Welcome Netscape Navigator user!

<!–#show var=”http_user_agent” operator=”contains”
Welcome Internet Explorer user!

As you can see in this example, the output of Webstar is by default on. That’s why you start any of these examples by switching the output of (#hide) and then switching it on again if the appropriate condition is fulfilled. At the end of the example you switch the output on again with a #show include. Again, show and hide do not work under Apache so I cannot show you the result here.


Show and Hide can also be used at random:

<!–#show var=”random” op=”<” value=”50″ –>
<!–#show var=”random” op=”=>” value=”50″ –>

If you do a couple of reloads, you should see the text change. Of course you can use the same thing to show and hide images or any other HTML. The number that is used by Webstar is a random number ranging from 1 to 99 inclusive. Here is an example for three random texts:

<!–#show var=”random” op=”<” value=”33″ –>
To be or not to be,
<!–#show var=”random” op=”=>” value=”34″ –>
<!–#hide var=”random” op=”>” value=”66″ –>
that’s the question,
<!–#show var=”random” op=”>” value=”66″ –>
my dear Watson.


In fact you can show and hide text at will using any of the environment variables (see the section on Echo below). This example shows a bit of text to a user with IP address

<!–#show var=”remote_addr” operator=”=” value=”″–>
Welcome BTinternet user!

If you have friends with fixed IP addresses you can leave messages especially for them in the same manner. Finally, you should know which operators are available:

Operator Meaning
“contains” or “con” variable contains the value string
“starts with” or “start” variable starts with the value string
“ends with” or “end” variable ends with the value string
“=” or “==” variable equals the value string
“!=” or “<>” variable does not equal the value string
“<“ variable is less than the value string
“<=” or “=<“ variable is less than or equal to the value string
“>” variable is greater than the value string
“>=” or “=>” variable is greater than or equal to the value string

If 和 Endif

Because this server runs Apache I could not show the examples of #hide and #show. I can, however, demonstrate the #if and #endif includes (if and endif, in turn, do not work under Webstar):

<!–#config timefmt=”%A”–>
<!–#if expr=”$date_gmt = Friday” –>
Hang in there, it’s almost weekend
<!–#elif expr=”($date_gmt = Saturday) || ($date_gmt = Sunday)” –>
Have a nice weekend
<!–#else –>
Have a good day
<!–#endif –>

Hang in there, it’s almost weekend Have a nice weekend Have a good day

The first thing you will notice is that the #if include, opposite to the #hide and #show, does use the date as formatted with timefmt. This has some clear advantages. You can also see that this example is a bit easier to understand the #show and #hide spaghetti that WebStar seems to need. Note that the #if and #endif are obligatory, the #elif and #else are optional. This example uses date_gmt which is London time -ignoring summertime- rather than date_local which depends on where the server is.

The following operators are available:

Operator Meaning
string1 = string2 string1 equals string2
string1 != string2 string1 does not equal string2
string1 < string2 string1 is less than string2
string1 <= string2 string1 is less than or equal to string2
string1 > string2 string1 is greater than string2
string1 >= string2 string1 is greater than or equal to string2

If, Endif 和环境变量

you can use the #if include to show different information to different browsers. Each browser sets the environment variable http_user_agent differently. This is how Netscape Navigator 4.04, Microsoft Internet Exploder and Apple’s Cyberdog respectively do it:

Mozilla/4.04 (Macintosh; I; PPC, Nav)
Mozilla/4.0 (compatible; MSIE 4.0; Mac_PowerPC)
Cyberdog/2.0 (Macintosh; PPC)

As you can see these are all the Macintosh versions. By the way, this is what your own browser makes of http_user_agent: . So this is how to show different information to different browsers:

<!–#if expr=”$HTTP_USER_AGENT=/MSIE/ ” –>
Fight the Microsoft Monopoly. Get Netscape!
<!–#elif expr=”$HTTP_USER_AGENT=/Nav/ ” –>
Welcome Netscape Navigator user!
<!–#elif expr=”$HTTP_USER_AGENT=/Cyberdog/ ” –>
Welcome Apple Cyberdog user!
<!–#else –>
Welcome! So what browser are you using?
<!–#endif –>

Fight the Microsoft Monopoly. Get Netscape! Welcome Netscape Navigator user! Welcome Apple Cyberdog user! Welcome! So what browser are you using?

Note that the /Nav/ I am looking for here is produced by Netscape Navigator, which is Communicator without the news, mail and webeditor modules. The above is obviously not an exhaustive list of browsers, which is why there is also an #else include for all the browsers that are not covered.

The two slashes around MSIE, Nav and Cyberdog in the example above means that the second string is interpreted as a regular expression, commonly used under Unix. In this case it checks if http_user_agent contains that string.


The #set include can be used to create your own variables and assign them a value. Variables can be printed or can be used in #if statements:

<!–#set var=”carmodel” value=”Mercedes” –>
<!–#echo var=”carmodel” –><BR>
<!–#if expr=”$carmodel = Mercedes” –>
That’s a jolly nice car
<!–#endif –>

That’s a jolly nice car

The $ sign in the #if include is needed to ensure that “carmodel” is interpreted as a variable, not as a string.


ECHO can be used to insert information from the browser and the server into your document, the so-called environment variables. The following possibilities are available:

Document Name: <!–#echo var=”document_name”–>
Document URI: <!–#echo var=”document_uri”–>
Local Date: <!–#echo var=”date_local”–>
GMT Date: <!–#echo var=”date_gmt”–>
Last Modified: <!–#echo var=”last_modified”–>
Server Software: <!–#echo var=”server_software”–>
Server Name: <!–#echo var=”server_name”–>
Server Protocol: <!–#echo var=”server_protocol”–>
Server Port: <!–#echo var=”server_port”–>
Gateway Interface: <!–#echo var=”gateway_interface”–>
Request Method: <!–#echo var=”request_method”–>
Script Name: <!–#echo var=”script_name”–>
Remote Host: <!–#echo var=”remote_host”–>
Remote Address: <!–#echo var=”remote_addr”–>
Remote User: <!–#echo var=”remote_user”–>
Content Type: <!–#echo var=”content_type”–>
Content Length: <!–#echo var=”content_length”–>
HTTP Accept: <!–#echo var=”http_accept”–>
HTTP User Agent (Browser): <!–#echo var=”http_user_agent”–>
HTTP Cookie: <!–#echo var=”http_cookie”–>
Unescaped query string: <!–#echo var=”query_string_unescaped”–>
Query String: <!–#echo var=”query_string”–>
Path Info: <!–#echo var=”path_info”–>
Path Translated: <!–#echo var=”path_translated”–>
Referer: <!–#echo var=”referer”–>
Forwarded: <!–#echo var=”forwarded”–>

Document Name:
Document URI:
Local Date:
GMT Date:
Last Modified:
Server Software:
Server Name:
Server Protocol:
Server Port:
Gateway Interface:
Request Method:
Script Name:
Remote Host:
Remote Address:
Remote User:
Content Type:
Content Length:
HTTP Accept:
HTTP User Agent (Browser):
HTTP Cookie:
Unescaped query string:
Query String:
Path Info:
Path Translated:

Not all ECHO commands always result in information being printed. This can depend on the server, on your browser and on the way you reached this page. The #echo include works both under WebStar and Apache.

Print Environment

If you want to print the entire environment, you do not need to use a whole list of #echo includes. Instead you can use this shortcut.

<PRE> <!–#printenv –> </PRE>

Note that the environment includes the variable “carmodel” that was defined in an earlier example.


You can use a server side include to run a script. This is what I use on my homepage:

<!–#exec cgi=”ssi.demo.cgi”–>

The CGI script (which is in Perl 5) opens a file with a dozen quotes, selects one at random and prints it to the page. The script, by the way, is courtesy of Matt Wright who offers a brilliant collection of scripts.


You can insert the size of a file in this way:

<!–#fsize file=”top.gif”–>

This inserts the size of the file top.gif (the logo at the top of this page). As explained earlier in this chapter, you can determine if the size is displayed in full bytes or abbreviated in kilobytes or megabytes.


You can insert the date of a file in this way:

<!–#flastmod file=”top.gif”–>

This inserts the date and the time the file top.gif (the logo at the top of this page) was last modified. The format of the date and time can be customized by you as explained earlier in this chapter.

This page has been translated into Spanish language by Maria Ramos from



Kloxo-MR 中安装 thirdparty phpMyAdmin


File not found.

yum install kloxomr-thirdparty-phpmyadmin

安装 Kloxo-MR 7.0.0.b 后发现在面板中点击20150425021410

Url地址 – /thirdparty/phpMyAdmin/

File not found.



之后在服务组件中也看不到有phpMyAdmin 的信息。

sftp上服务器上的 Kloxo下也确实没有.  也许thirdparty就是要自己装把, 那么就装吧.


yum list kloxomr-thirdparty*

| 列出以 kloxomr-thirdparty 打头 记得后面有个星号.


,找到全部的kloxomr第三方插件, 然后安装 phpMyAdmin

yum install kloxomr-thirdparty-phpmyadmin





了解一些帮助您轻松通过 Google 找到信息的提示和技巧。

提示 1:使用简单的搜索字词



提示 2:通过语音搜索

不想打字?点击 Google 应用或 Chrome 搜索框中的麦克风图标 ,通过语音执行搜索

提示 3:认真选择措辞


提示 4:不用担心输入方面的琐事

  • 拼写。 无论您的拼写是否正确,Google 的拼写检查工具都会自动使用给定字词的最常用拼写形式。
  • 大写。 搜索 QQqq 所得到的结果是一样的。

提示 5:查找快速解答

对于您进行的许多搜索,Google 都会替您完成相关工作,并会在您输入搜索字词后在搜索结果页上显示相关解答。有些功能(例如查询与球队有关的信息)并非在所有地区都提供。

  • 天气:搜索天气可查看您所在地点的天气信息,如果在“天气”后加上城市名(例如天气北京),则可查看相应城市的天气信息。
  • 字典:在任意字词前加上 define 即可查询其定义。
  • 计算:输入数学公式(例如 3*9123)或求解复杂的图形公式。
  • 单位换算:输入任何换算内容,例如 3 美元兑换欧元
  • 体育:搜索球队的名称,即可查看相关赛程和比赛得分等信息。
  • 快讯:搜索名人、地点、电影或歌曲的名称可看到相关重要信息。


您可以使用特殊的字符和字词来获取更具体的搜索结果。Google 会忽略大部分的标点符号(以下示例除外)。例如,搜索字词狗! 会被 Google 视为

Google 搜索可以识别的标点和符号


请注意:在使用符号进行搜索时,请勿在符号和搜索字词之间添加空格。我们可以识别-狗中的符号,但无法识别- 狗中的符号。

符号 用途
+ 搜索 Google+ 网页或血型 示例:+Chrome 和 AB+
@ 查找社交标记 示例:@agoogler
$ 查找价格
示例:尼康 $400
# 查找热门主题标签以搜索热门话题 示例:#throwbackthursday
- 移除字词在某个字词或网站之前添加一个短横可排除所有包含该字词或网站的搜索结果。在搜索有多种含义的字词(例如“汽车品牌捷豹”和“动物捷豹”)时,这种方法尤为实用。

示例:捷豹速度 -汽车熊猫

连字如果多个字词以短横相连,Google 便会知道这些字词是紧密关联的。

示例:twelve-year-old dog

_ 用于连接两个字词,例如 quick_sort。 您会在搜索结果中发现,这对字词要么组成一个字词 (quicksort),要么由下划线相连 (quick_sort)。
" 如果您将字词或词组置于引号中,则搜索结果中将仅显示以下网页:包含引号中的字词且字词顺序也与引号中相同。 请注意:请仅在需要搜索某个精确字词或词组时使用这种搜索方式,不然,可能会错误地排除掉很多有用的搜索结果。 示例:"想象一下所有人"
* 在搜索中添加一个星号,以表示任何未知或不确定的字词。与引号结合使用,可以查找具体词组的不同变体,或记住词组中间的字词。 示例:"省*就是赚*"
.. 使用不含空格的两个半角句号 (..) 隔开多个数字,即可查看日期、价格和尺寸等方面的数值在指定范围内的搜索结果。 示例:相机 $50..$100



请注意:使用运算符进行搜索时,请勿在运算符和搜索字词之间添加空格。搜索 可以获取相关搜索结果,而搜索 site: 则是行不通的。

运算符 用途
site: 仅从特定网站或网域获得搜索结果。例如,您可以查找 NBC 网站或任何 .gov 网站上所有提到“奥运”的内容。 示例:olympics 和 olympics
link: 查找链接到某个特定网页的页面。例如,您可以查找链接到 的所有页面。 示例
related: 查找与您已浏览过的网址类似的网站。当您搜索与 相关的网站时,会找到您可能感兴趣的其他新闻出版物网站。 示例
OR 如果您想搜索可能只包含多个搜索字词中某一个的页面,可以在这些字词之间加上 OR(大写)。如果不加 OR,您的搜索结果中通常只会显示与这些字词都匹配的页面。 示例:世界杯举办地2014年OR 2018年
info: 获取某网址的相关信息,包括网页的缓存版本、相似网页和链接至该网站的网页。 示例
cache: 查看 Google 上次抓取网站时网页的外观。 示例


Linux vps 中使用ntp包自动校准时间




1 apt-get install ntpdate


1 yum install ntp


1 ntpdate


1 00 12 * * * /sbin/ntpdate

* cn.pool.ntp.org是ntp网络授时组织的中国授时源


如果出现ntpdate: step-systime: Operation not permitted,说明vps不允许修改时间,可以使用:

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

附 OpenVZ VPS不能修改时间的母鸡解决办法

因为系统架构的原因,OpenVZ的linux vps默认是不允许在客户在vps自行修改系统时间,当执行修改时间的操作时,会出错

[root@root ~]# date -s 10:22:33
date: cannot set date: Operation not permitted



yum install ntp


vzctl set (veid) --capability sys_time:on --save


WARNING: Some of the parameters could not be applied to a running container.
        Please consider using --setmode option


vzctl stop (veid)
vzctl set (veid) --capability sys_time:on --save
vzctl start (veid)


[root@root ~]# date -s 11:17:40

Wed Feb 23 11:17:40 CST 2011










进入当前用户的用户目录:cd ~

进入根目录:cd /

进入上层目录:cd ../

进入上上层目录:cd ../../

进入当前目录下的photos目录:cd photos


删除readme文件:rm readme (然后系统会询问你是否删除,输入y表示确认,然后回车即可)

强制删除readme文件:rm readme -f (此时系统不会询问而是直接删除)

强制删除photos目录:rm photos -rf (后面的-rf表示强制删除目录)


在当前目录中创建photos目录:mkdir photos

在根目录中创建photos目录:mkdir /photos


创建空白文件readme:touch readme


将photos目录重命名为pictures: mv photos pictures

对于文件也是一样:mv oldfile newfile

将photos文件/目录移动到根目录:mv photos /

将photos文件/目录移动到上层目录:mv photos ../





将filename.tar.gz解压到当前目录:tar zxf filename.tar.gz

将photos目录打包成photos.tar.gz文件:tar zcf photos.tar.gz photos



查看所有分区剩余空间与占用情况:df -hl

[root@pt ~]# df -hl
文件系统 容量 已用 可用 已用% 挂载点
8.6G 3.9G 4.4G 47% /
/dev/sda1 99M 19M 76M 20% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sdb1 16G 3.3G 12G 22% /home/wwwroot
/dev/sdc1 16G 386M 15G 3% /usr/local/mysql/var



查看当前内存使用情况:free -m (m参数:用M为单位显示,该参数还可以为k、g)

[root@pt ~]# free -m
total used free shared buffers cached
Mem: 1010 978 31 0 275 360
-/+ buffers/cache: 342 667
Swap: 1023 0 1023


至于为什么会这样,请参考VPS管理百科的:Linux free命令实际内存占用全解析与内存工作方式





继续下载(断点续传):wget -c