<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A18制造 &#187; 编程</title>
	<atom:link href="http://a18zhizao.com/ycategory/works/feed" rel="self" type="application/rss+xml" />
	<link>http://a18zhizao.com</link>
	<description>梦想的种子飞入了大地，所需要的只有时间。</description>
	<lastBuildDate>Tue, 24 Jan 2012 11:50:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>移动手机详单通话时长公式</title>
		<link>http://a18zhizao.com/y2011/8266_details-of-a-single-mobile-phone-talk-time-formula.html</link>
		<comments>http://a18zhizao.com/y2011/8266_details-of-a-single-mobile-phone-talk-time-formula.html#comments</comments>
		<pubDate>Mon, 27 Jun 2011 05:33:58 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[编程]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[公式]]></category>
		<category><![CDATA[移动]]></category>
		<category><![CDATA[详单]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=8266</guid>
		<description><![CDATA[最近琢磨换联通的卡，不知道别的地方，反正我这里是移动总没有信号，联通信号却很好。所以想换一换。所以就研究了一下自己每个月打多少电话，需要多少时长。但是移动自带的通化详单不统计通话时长。这时候我就想起来excel的公式。（我也是第一次写，所以不是很好，又高手完善更好~~，我是不完善了。我是能用万岁~）。 这个公式替换掉所有详单中的汉字“秒” 再具体就自己琢磨吧。不可能拿来就用，行号什么的都会需要改改的。呵呵~~ =IF(B4="主叫",SUM(MID(C4,IF(ISERROR(FIND("分",C4,1)+1),1,FIND("分",C4,1)+1),LEN(C4)),IF(MID(C4,1,IF(ISERROR(FIND("分",C4,1)-1),0,FIND("分",C4,1)-1))="",0,MID(C4,1,IF(ISERROR(FIND("分",C4,1)-1),0,FIND("分",C4,1)-1)))*60),0)]]></description>
			<content:encoded><![CDATA[<p>    最近琢磨换联通的卡，不知道别的地方，反正我这里是移动总没有信号，联通信号却很好。所以想换一换。所以就研究了一下自己每个月打多少电话，需要多少时长。但是移动自带的通化详单不统计通话时长。这时候我就想起来excel的公式。（我也是第一次写，所以不是很好，又高手完善更好~~，我是不完善了。我是能用万岁~）。</p>
<p>这个公式替换掉所有详单中的汉字“秒” 再具体就自己琢磨吧。不可能拿来就用，行号什么的都会需要改改的。呵呵~~</p>
<p><code>=IF(B4="主叫",SUM(MID(C4,IF(ISERROR(FIND("分",C4,1)+1),1,FIND("分",C4,1)+1),LEN(C4)),IF(MID(C4,1,IF(ISERROR(FIND("分",C4,1)-1),0,FIND("分",C4,1)-1))="",0,MID(C4,1,IF(ISERROR(FIND("分",C4,1)-1),0,FIND("分",C4,1)-1)))*60),0)</code></p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2011/8266_details-of-a-single-mobile-phone-talk-time-formula.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Snow Leopard Virtuabox Install WindowsXp Error with Vt－x</title>
		<link>http://a18zhizao.com/y2010/1413_snow-leopard-virtuabox-install-windowsxp-error-with-vt-x.html</link>
		<comments>http://a18zhizao.com/y2010/1413_snow-leopard-virtuabox-install-windowsxp-error-with-vt-x.html#comments</comments>
		<pubDate>Tue, 11 May 2010 08:11:46 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[virtuabox]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1413</guid>
		<description><![CDATA[Today I installed Windows Xp in Virtuabox however happen an error. VT-x is not available Unknown error creating VM So How to solve this problem？Do it： In VirtualBox 3.0.2, this option no longer appears in the Advanced pane. Nevertheless I managed to find a workaround to deselect the option despite it no longer appearing in [...]]]></description>
			<content:encoded><![CDATA[<p>Today I installed Windows Xp in Virtuabox however happen an error.</p>
<blockquote><p>VT-x is not available<br />
Unknown error creating VM</p></blockquote>
<p>So How to solve this problem？Do it：</p>
<p>In VirtualBox 3.0.2, this option no longer appears in the Advanced pane. Nevertheless I managed to find a workaround to deselect the option despite it no longer appearing in the UI:</p>
<p>Under the ~/Library/VirtualBox/Machines directory you will find a folder for each virtual machine you have created. Within this directly you will find an XML file with the machine settings.</p>
<p>It looks like:</p>
<pre class="brush: xml; title: ; notranslate">
 13     &lt;/ExtraData&gt;
 14     &lt;Hardware version=&quot;2&quot;&gt;
 15       &lt;CPU count=&quot;1&quot;&gt;
 16         &lt;HardwareVirtEx enabled=&quot;true&quot; exclusive=&quot;false&quot;/&gt;
 17         &lt;HardwareVirtExNestedPaging enabled=&quot;true&quot;/&gt;
 18         &lt;HardwareVirtExVPID enabled=&quot;true&quot;/&gt;
 19         &lt;PAE enabled=&quot;true&quot;/&gt;
 20       &lt;/CPU&gt;
</pre>
<p>Just change the 'enabled="true"' part to 'enabled="false"'.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1413_snow-leopard-virtuabox-install-windowsxp-error-with-vt-x.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bash_completion install in Mac OS X Snow Leopard</title>
		<link>http://a18zhizao.com/y2010/1410_bash_completion-install-in-mac-os-x-snow-leopard.html</link>
		<comments>http://a18zhizao.com/y2010/1410_bash_completion-install-in-mac-os-x-snow-leopard.html#comments</comments>
		<pubDate>Wed, 05 May 2010 04:24:55 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[completion]]></category>
		<category><![CDATA[雪豹]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1410</guid>
		<description><![CDATA[Recently，I Try to use the Snow Leopard ,But it lacks a feature. Debian-like bash_completion! I missed you! So I Seached with Google! To install it just do: Tip: You must have MacPorts installed to run the first command. MacPorts Form http://www.macports.org . If you don’t know yet what is bash_completion, it is  a feature for [...]]]></description>
			<content:encoded><![CDATA[<p>Recently，I Try to use the Snow Leopard ,But it lacks a feature.</p>
<p>Debian-like bash_completion! I missed you! So I Seached with Google!</p>
<p>To install it just do:</p>
<pre class="brush: bash; title: ; notranslate">
sudo port install bash-completion
echo &quot;source /opt/local/etc/bash_completion&quot; &gt;&gt; ~/.bash_profile
chmod +x ~/.bash_profile
</pre>
<p>Tip: You must have MacPorts installed to run the first command. MacPorts Form <a href="http://www.macports.org/" target="_blank">http://www.macports.org</a> .</p>
<p>If you don’t know yet what is bash_completion, it is  a feature for  shells to autocomplete commands. Example: You are on a git repository.  You type git fe and press TAB, bash_completion will fill “fetch” for  you. If you have branches, they are autocompleted too. GNU Tar only  shows files compatible with the filters you selected. So if you tar xvzf  my-softw TAB, it will complete only filenames that are on tar.gz or tgz  format and that starts with the string you already typed.</p>
<p>It is heaven again.</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1410_bash_completion-install-in-mac-os-x-snow-leopard.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>tar打包排除某个或多个子目录 &#124; AWK命令</title>
		<link>http://a18zhizao.com/y2010/1406_tar-package-exclude-one-or-more-subdirectories-awk-command.html</link>
		<comments>http://a18zhizao.com/y2010/1406_tar-package-exclude-one-or-more-subdirectories-awk-command.html#comments</comments>
		<pubDate>Sun, 25 Apr 2010 15:01:47 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[tar]]></category>
		<category><![CDATA[子目录]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1406</guid>
		<description><![CDATA[下午遇到一个小问题：文件目录结构如下 /dir0- -/dir1         &#60;---该文件很大，欲排除 -/dir2         &#60;---该文件很大，欲排除 -/dir3         &#60;---目标目录之一 -index.php  &#60;---目标文件之一 .............以下省略N个子目录和子文件............. 目录下很多子目录，而我需要打包。目标是   /wwwroot 下所有子文件+/dir3 ，于是那些多余的子目录就让我头疼， 怎样在不影响文件结构的情况下打包呢，搜索网上，很多人用下面这个方法： 但是并不好，要是排除的部分是多出，要是子目录过多，语句该要写多久啊，后来又发现网上说可以直接使用排除参数X 新建文件excludefiles在当前目录中，内容为 注意： tar命令里面的目标文件是绝对路径格式，excludefile里面就也必须是绝对路径； tar命令里面的目标文件是相对路径格式，excludefile里面就也必须是相对路径； 后来 搜索找到了自力博客的一样问题的文章 说可以用 AWK 于是去搜索了一下它：Awk学习笔记 发现它提供的语句可以精简，可以这样写： 这个语句很好理解： ls -l 列出所有文件和目录； awk '\^-\ {print $8}' 正则只保留文件行，获得第八列的所有文件名； xargs tar 把上一步得到的名称传参给tar命令。 一切OK，轻松完成打包喽！]]></description>
			<content:encoded><![CDATA[<p><strong>下午遇到一个小问题：</strong>文件目录结构如下</p>
<blockquote><p>/dir0-<br />
-/dir1         &lt;---该文件很大，欲排除<br />
-/dir2         &lt;---该文件很大，欲排除<br />
-/dir3         &lt;---目标目录之一<br />
-index.php  &lt;---目标文件之一<br />
.............以下省略N个子目录和子文件.............</p></blockquote>
<p>目录下很多子目录，而我需要打包。目标是   /wwwroot 下所有<strong>子文件</strong>+/dir3  ，于是那些多余的子目录就让我头疼，<br />
怎样在不影响文件结构的情况下打包呢，搜索网上，很多人用下面这个方法：<br />
<span id="more-1406"></span></p>
<pre class="brush: bash; title: ; notranslate">
tar cvzf \home\all.tar.gz dir0  --exclude dir1 --exclude dir2
</pre>
<p>但是并不好，要是排除的部分是多出，要是子目录过多，语句该要写多久啊，后来又发现网上说可以直接使用排除参数X</p>
<p>新建文件excludefiles在当前目录中，内容为</p>
<pre class="brush: bash; title: ; notranslate">
cat excludefiles
dir1
dir2
tar -cvzf \home\all.tar.gz -X excludefile dir1
</pre>
<blockquote><p><strong>注意：</strong><br />
tar命令里面的目标文件是绝对路径格式，excludefile里面就也必须是绝对路径；<br />
tar命令里面的目标文件是相对路径格式，excludefile里面就也必须是相对路径；</p></blockquote>
<p>后来 搜索找到了<a href="http://www.hzlzh.com/ssh-tar-awk/" target="_blank">自力博客的一样问题的文章</a> 说可以用 <strong>AWK</strong> 于是去搜索了一下它：<a href="http://www.linux.gov.cn/shell/awk.htm" target="_blank">Awk学习笔记</a> 发现它提供的语句可以精简，可以这样写：</p>
<pre class="brush: bash; title: ; notranslate">
ls -l | awk '\^-\ {print  $8}' | xargs tar cvfz \home\dir0.tar.gz
</pre>
<p>这个语句很好理解：</p>
<p><strong>ls -l </strong>列出所有文件和目录<strong>；</strong><br />
<strong>awk '\^-\ {print $8}'</strong> 正则只保留文件行，获得第八列的所有文件名；<br />
<strong>xargs tar</strong> 把上一步得到的名称传参给tar命令。<br />
一切OK，轻松完成打包喽！</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1406_tar-package-exclude-one-or-more-subdirectories-awk-command.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>为什么优秀开发者进入Google后就不参与开源了</title>
		<link>http://a18zhizao.com/y2010/1387_why-good-developers-into-google-is-not-involved-in-open-source-after-the.html</link>
		<comments>http://a18zhizao.com/y2010/1387_why-good-developers-into-google-is-not-involved-in-open-source-after-the.html#comments</comments>
		<pubDate>Fri, 09 Apr 2010 05:28:25 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[编程]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[开发]]></category>
		<category><![CDATA[开源]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1387</guid>
		<description><![CDATA[很多优秀的开发者在进入Google之前都是非常活跃的开源贡献者，但是进入Google之后往往就销声匿迹了，包括嘲笑了此现象的 Memcached 作者Brad在进入Google之后也无法逃脱此规律。Brad在最近一篇文章Contributing to Open Source projects谈到相关原因。(建议阅读英文原文) Brad总结的三个原因: 许多优秀开发者都很喜欢编程，他们喜欢研究有趣有挑战的问题，并不特别在意这些项目是否开源。 大家都太忙，Google似乎用尽了每个人的空余时间。并不是说Google强迫大家一天到晚都在干活，而是由于Google里面太多有 趣的东西 做了，Brad经常挂在口头一句话就是“现在手头有7个属于20%空余时间的项目”。 Google的开发环境太好了，源代码控制，build系统，code review工具，debugger调试工具，profiler调优工具，submit queues, continuous builds, test bots, 文档以及所有相关的自动化工具及流程非常完善。因此很容易hack任何项目，在任何地方，或者给任何人提交patch，并且值得一提的是，很容易找到对应 的人或者list去提交patch。通常说来，提交patch是参与特性讨论，表达诚意的最好方式，即使你的patch是有问题的。 从上面尤其是第3点来看，Google确实是技术人员的理想环境。 vim TIM yang]]></description>
			<content:encoded><![CDATA[<p>很多优秀的开发者在进入Google之前都是非常活跃的开源贡献者，但是进入Google之后往往就销声匿迹了，包括嘲笑了此现象的  Memcached 作者Brad在进入Google之后也无法逃脱此规律。<strong>Brad在最近一篇文章</strong><a href="http://brad.livejournal.com/2409049.html"><strong>Contributing to  Open  Source projects</strong></a><strong>谈到相关原因。(建议阅读英文原文)</strong><br />
<span id="more-1387"></span><br />
Brad总结的三个原因:</p>
<ul>
<li>许多优秀开发者都很喜欢编程，他们喜欢研究有趣有挑战的问题，并不特别在意这些项目是否开源。</li>
<li>大家都太忙，Google似乎用尽了每个人的空余时间。并不是说Google强迫大家一天到晚都在干活，而是由于Google里面太多有 趣的东西 做了，Brad经常挂在口头一句话就是“现在手头有7个属于20%空余时间的项目”。</li>
<li>Google的开发环境太好了，源代码控制，build系统，code   review工具，debugger调试工具，profiler调优工具，submit queues, continuous builds,   test bots,   文档以及所有相关的自动化工具及流程非常完善。因此很容易hack任何项目，在任何地方，或者给任何人提交patch，并且值得一提的是，很容易找到对应  的人或者list去提交patch。通常说来，提交patch是参与特性讨论，表达诚意的最好方式，即使你的patch是有问题的。</li>
</ul>
<p>从上面尤其是第3点来看，Google确实是技术人员的理想环境。</p>
<p>vim <a href="http://timyang.net/google/open-source/" target="_blank">TIM  yang</a></p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1387_why-good-developers-into-google-is-not-involved-in-open-source-after-the.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用PreparedStatement向数据库插入数据</title>
		<link>http://a18zhizao.com/y2010/1365_insert-data-to-the-database-using-preparedstatement.html</link>
		<comments>http://a18zhizao.com/y2010/1365_insert-data-to-the-database-using-preparedstatement.html#comments</comments>
		<pubDate>Wed, 31 Mar 2010 02:01:57 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[preparedstatement]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/y2010/1365_insert-data-to-the-database-using-preparedstatement.html</guid>
		<description><![CDATA[使用PreparedStatement进行数据保存，主要我用这个对HTML代码保存进数据库 进行操作。 这个是对CLOB类型进行操作。 还有一种方法，是首先插入时使用EMPTY_CLOB() 之后再UPDATE 这个段 使用数据流更新数据。]]></description>
			<content:encoded><![CDATA[<p>使用PreparedStatement进行数据保存，主要我用这个对HTML代码保存进数据库 进行操作。<br />
这个是对CLOB类型进行操作。<br />
还有一种方法，是首先插入时使用EMPTY_CLOB() 之后再UPDATE 这个段 使用数据流更新数据。<br />
<span id="more-1365"></span></p>
<pre class="brush: java; title: ; notranslate">
package net.java2000.sql;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;

/**
 * 使用PreparedStatement向数据库插入数据。
 *
 * @author 赵学庆，Java世纪网(java2000.net)
 *
 */
public class DBInsertPreparedStatement {

  public static void main(String[] args) {
    Connection connection = null; // 从其它地方获取链接
    try {
      // INSERT语句
      String sql = &quot;INSERT INTO my_table (col_string) VALUES(?)&quot;;
      // 构造PerparedStatement
      PreparedStatement pstmt = connection.prepareStatement(sql);

      // 循环插入10行数据
      for (int i = 0; i &lt; 10; i++) {
        // 设置参数的值
        pstmt.setString(1, &quot;row &quot; + i);

        // 插入数据
        pstmt.executeUpdate();
      }
    } catch (SQLException e) {
    }

    // 演示各种参数的设置方法。
    try {
      // Prepare a statement to insert a record
      String sql = &quot;INSERT INTO mysql_all_table(&quot;
        + &quot;col_boolean,&quot;
        + &quot;col_byte,&quot;
        + &quot;col_short,&quot;
        + &quot;col_int,&quot;
        + &quot;col_long,&quot;
        + &quot;col_float,&quot;
        + &quot;col_double,&quot;
        + &quot;col_bigdecimal,&quot;
        + &quot;col_string,&quot;
        + &quot;col_date,&quot;
        + &quot;col_time,&quot;
        + &quot;col_timestamp,&quot;
        + &quot;col_asciistream,&quot;
        + &quot;col_binarystream,&quot;
        + &quot;col_blob) &quot;
        + &quot;VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)&quot;;

      PreparedStatement pstmt = connection.prepareStatement(sql);

      // Set the values
      pstmt.setBoolean(1, true);
      pstmt.setByte(2, (byte) 123);
      pstmt.setShort(3, (short) 123);
      pstmt.setInt(4, 123);
      pstmt.setLong(5, 123L);
      pstmt.setFloat(6, 1.23F);
      pstmt.setDouble(7, 1.23D);
      pstmt.setBigDecimal(8, new BigDecimal(1.23));
      pstmt.setString(9, &quot;a string&quot;);
      pstmt.setDate(10, new java.sql.Date(System.currentTimeMillis()));
      pstmt.setTime(11, new Time(System.currentTimeMillis()));
      pstmt.setTimestamp(12, new Timestamp(System.currentTimeMillis()));

      // 设置字符流
      File file = new File(&quot;infilename1&quot;);
      FileInputStream is = new FileInputStream(file);
      pstmt.setAsciiStream(13, is, (int) file.length());

      // 设置二进制字节流
      file = new File(&quot;infilename2&quot;);
      is = new FileInputStream(file);
      pstmt.setBinaryStream(14, is, (int) file.length());

      // 设置blob
      file = new File(&quot;infilename3&quot;);
      is = new FileInputStream(file);
      pstmt.setBinaryStream(15, is, (int) file.length());

      // 插入数据
      pstmt.executeUpdate();
    } catch (SQLException e) {
    } catch (FileNotFoundException e) {
    }
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1365_insert-data-to-the-database-using-preparedstatement.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[视频]Visual Studio最新广告 - 让我做你下一行code</title>
		<link>http://a18zhizao.com/y2010/1363_video-visual-studio-latest-ads-let-me-be-your-next-line-of-code.html</link>
		<comments>http://a18zhizao.com/y2010/1363_video-visual-studio-latest-ads-let-me-be-your-next-line-of-code.html#comments</comments>
		<pubDate>Mon, 29 Mar 2010 07:28:48 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[编程]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[广告]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1363</guid>
		<description><![CDATA[Visual Studio2010发布了最新的广告.大打程序员煽情……也算是开发软件推广的一次有益尝试。 至少，身为程序员的我看的内牛满面..]]></description>
			<content:encoded><![CDATA[<p>Visual Studio2010发布了最新的广告.大打程序员煽情……也算是开发软件推广的一次有益尝试。<br />
至少，身为程序员的我看的内牛满面..<br />
<span id="more-1363"></span><br />
<embed src="http://player.youku.com/player.php/sid/XMTYwMjk0ODA0/v.swf" quality="high" width="480" height="400" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"></embed></p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1363_video-visual-studio-latest-ads-let-me-be-your-next-line-of-code.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.htaccess文件使用权威指南</title>
		<link>http://a18zhizao.com/y2010/1339_htaccess-file-uses-the-authority-of-the-guide.html</link>
		<comments>http://a18zhizao.com/y2010/1339_htaccess-file-uses-the-authority-of-the-guide.html#comments</comments>
		<pubDate>Wed, 24 Mar 2010 13:47:43 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[编程]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[指南]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1339</guid>
		<description><![CDATA[.htaccess可以做大量范围的事情，包括：文件夹密码保护、用 户自动重新指向、自定义错误页面、变更你的文件扩展名、屏蔽特定的用户IP地址、只允许特定的IP地址、停止目录表以及使用其他文件作为index文件， 等等……。希望这个.htaccess文件使用权威指南可以帮助到你。 如 果你还不知道.htaccess是什么的话，可以看这里： .htaccess文件(或者"分布式配置文件"）提供了针对目录改变配置的方法，即，在一个特定的 文档目录中放置一个包含一个或多个指令的文件， 以作用于此目录及其所有子目录。作为用户，所能使用的命令受到限制。管理员可以通过Apache的AllowOverride指令来设置。 Unix、 Linux系统或者是任何版本的Apache Web服务器都是支持.htaccess的，但是有的主机服务商可能不允许你自定义自己的.htaccess文件。 笼统地说，.htaccess可以帮我们实现包括：文件夹密码保护、用户自动重定向、自定义错误 页面、改变你的文件扩展名、封禁特定IP地址的用户、只允许特定IP地址的用户、禁止目录列表，以及使用其他文件作为index文件等一些功能。（更多介绍） 1. Introduction 介绍 文件名 .htaccess 属性 644 (RW-R–R–) htaccess会 影响它所在目录下的所有子目录 注意大多数内容都要求保持在一行之内，不要换行，否则会引起错误 2. Error Documents 错误文档 Official document: ErrorDocument Directive ErrorDocument code document 例 子 ErrorDocument 400 /errors/badrequest.html ErrorDocument 404 http://yoursite/errors/notfound.html ErrorDocument 401 "Authorization Required" (注意之后内容如果出现的双引号需要转义为 \") 常 见HTTP状态码 Successful Client Requests 200 [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>.htaccess可以做大量范围的事情，包括：文件夹密码保护、用 户自动重新指向、自定义错误页面、变更你的文件扩展名、屏蔽特定的用户IP地址、只允许特定的IP地址、停止目录表以及使用其他文件作为index文件， 等等……。希望这个.htaccess文件使用权威指南可以帮助到你。</p>
<p>如 果你还不知道.htaccess是什么的话，可以看这里：</p>
<p>.htaccess文件(或者"分布式配置文件"）提供了针对目录改变配置的方法，即，在一个特定的 文档目录中放置一个包含一个或多个指令的文件，  以作用于此目录及其所有子目录。作为用户，所能使用的命令受到限制。管理员可以通过Apache的AllowOverride指令来设置。</p>
<p>Unix、 Linux系统或者是任何版本的Apache  Web服务器都是支持.htaccess的，但是有的主机服务商可能不允许你自定义自己的.htaccess文件。</p>
<p>笼统地说，.htaccess可以帮我们实现包括：文件夹密码保护、用户自动重定向、自定义错误 页面、改变你的文件扩展名、封禁特定IP地址的用户、只允许特定IP地址的用户、禁止目录列表，以及使用其他文件作为index文件等一些功能。（<a href="http://baike.baidu.com/view/91163.htm" target="_blank">更多介绍</a>）
</div>
<p><span id="more-1339"></span></p>
<div>
<strong>1.  Introduction 介绍</strong><br />
文件名 .htaccess 属性 644 (RW-R–R–)<br />
htaccess会 影响它所在目录下的所有子目录<br />
注意大多数内容都要求保持在一行之内，不要换行，否则会引起错误<br />
<strong>2. Error  Documents 错误文档</strong></p>
<blockquote><p>Official document:  ErrorDocument Directive<br />
ErrorDocument code document</p></blockquote>
<p>例 子</p>
<blockquote><p>ErrorDocument 400 /errors/badrequest.html<br />
ErrorDocument 404 http://yoursite/errors/notfound.html<br />
ErrorDocument 401 "Authorization Required"</p></blockquote>
<p>(注意之后内容如果出现的双引号需要转义为 \")<br />
常 见HTTP状态码<br />
Successful Client Requests<br />
200 OK<br />
201 Created<br />
202  Accepted<br />
203 Non-Authorative Information<br />
204 No Content<br />
205  Reset Content<br />
206 Partial Content<br />
Client Request Redirected<br />
300  Multiple Choices<br />
301 Moved Permanently<br />
302 Moved Temporarily<br />
303  See Other<br />
304 Not Modified<br />
305 Use Proxy<br />
Client Request Errors<br />
400  Bad Request<br />
401 Authorization Required<br />
402 Payment Required (not  used yet)<br />
403 Forbidden<br />
404 Not Found<br />
405 Method Not Allowed<br />
406  Not Acceptable (encoding)<br />
407 Proxy Authentication Required<br />
408  Request Timed Out<br />
409 Conflicting Request<br />
410 Gone<br />
411 Content  Length Required<br />
412 Precondition Failed<br />
413 Request Entity Too  Long<br />
414 Request URI Too Long<br />
415 Unsupported Media Type<br />
Server  Errors<br />
500 Internal Server Error<br />
501 Not Implemented<br />
502 Bad  Gateway<br />
503 Service Unavailable<br />
504 Gateway Timeout<br />
505 HTTP  Version Not Supported<br />
<strong>3. Password Protection 密码保护</strong><br />
Official  document: Authentication, Authorization and Access Control<br />
假设密码文件 为.htpasswd</p>
<blockquote><p>AuthUserFile /usr/local/safedir/.htpasswd  (这里必须使用全路径名)<br />
AuthName EnterPassword<br />
AuthType Basic</p></blockquote>
<p>两 种常见验证方式:</p>
<blockquote><p>Require user windix</p></blockquote>
<p>(仅允许用户 windix登陆)</p>
<blockquote><p>Require valid-user</p></blockquote>
<p>(所有合法用 户都可登陆)<br />
Tip: 如何生成密码文件<br />
使用htpasswd命令(apache自带)<br />
第一次生成需要创建密码文件</p>
<blockquote><p>htpasswd  -c .htpasswd user1</p></blockquote>
<p>之后增加新用户</p>
<blockquote><p>htpasswd  .htpasswd user2</p></blockquote>
<p><strong>4. Enabling SSI Via htaccess  通过htaccess允许SSI(Server Side Including)功能</strong></p>
<blockquote><p>AddType  text/html .shtml<br />
AddHandler server-parsed .shtml<br />
Options Indexes  FollowSymLinks Includes<br />
DirectoryIndex index.shtml index.html</p></blockquote>
<p><strong>5.  Blocking users by IP 根据IP阻止用户访问</strong></p>
<blockquote><p>order  allow,deny<br />
deny from 123.45.6.7<br />
deny from 12.34.5. (整个C类地址)<br />
allow  from all</p></blockquote>
<p><strong>6. Blocking users/sites by referrer  根据referrer阻止用户/站点访问</strong><br />
需要mod_rewrite模块<br />
例1. 阻止单一referrer:  badsite.com</p>
<blockquote><p>RewriteEngine on<br />
# Options  +FollowSymlinks<br />
RewriteCond %{HTTP_REFERER} badsite\.com [NC]<br />
RewriteRule  .* – [F]</p></blockquote>
<p>例2. 阻止多个referrer: badsite1.com,  badsite2.com</p>
<blockquote><p>RewriteEngine on<br />
# Options  +FollowSymlinks<br />
RewriteCond %{HTTP_REFERER} badsite1\.com [NC,OR]<br />
RewriteCond  %{HTTP_REFERER} badsite2\.com<br />
RewriteRule .* – [F]</p></blockquote>
<p>[NC]  – 大小写不敏感(Case-insensite)<br />
[F] – 403 Forbidden<br />
注意以上代码注释掉了"Options  +FollowSymlinks"这个语句。如果服务器未在 httpd.conf 的 段落设置 FollowSymLinks,  则需要加上这句，否则会得到"500 Internal Server error"错误。<br />
<strong>7. Blocking bad  bots and site rippers (aka offline browsers) 阻止坏爬虫和离线浏览器</strong><br />
需要 mod_rewrite模块<br />
坏爬虫? 比如一些抓垃圾email地址的爬虫和不遵守robots.txt的爬虫(如baidu?)<br />
可以根 据 HTTP_USER_AGENT 来判断它们<br />
(但是还有更无耻的如"中搜 zhongsou.com"之流把自己的agent设置为  "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)" 太流氓了，就无能为力了)</p>
<blockquote><p>RewriteEngine  On<br />
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^ChinaClaw [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^Custo [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Download\ Demon [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^eCatch [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^EirGrabber [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^EmailWolf [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^Express\ WebPictures [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^ExtractorPro [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^FlashGet [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^GetRight [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Go!Zilla [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^Go-Ahead-Got-It [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Grafula [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^HMView [OR]<br />
RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Image\ Stripper [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Image\ Sucker [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  Indy\ Library [NC,OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^JetCar [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^JOC\  Web\ Spider [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^LeechFTP [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^Mass\ Downloader [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool  [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Navroad [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^NearSite [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^NetSpider [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^Net\ Vampire [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Octopus [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^Offline\ Explorer [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^Offline\  Navigator [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Papa\ Foto [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^pavuk [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^RealDownload [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^ReGet [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^SmartDownload [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^SuperBot [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^SuperHTTP [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^tAkeOut [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^Teleport\ Pro [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Web\ Sucker [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^WebAuto [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^WebFetch [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^WebGo\ IS [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^WebReaper [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^WebSauger [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor  [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^WebStripper [OR]<br />
RewriteCond %{HTTP_USER_AGENT}  ^WebWhacker [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Wget [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^Widow  [OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]<br />
RewriteCond  %{HTTP_USER_AGENT} ^Zeus<br />
RewriteRule ^.* – [F,L]</p></blockquote>
<p>[F]  – 403 Forbidden<br />
[L] – 连接(Link)<br />
<strong>8. Change your default  directory page 改变缺省目录页面</strong></p>
<blockquote><p>DirectoryIndex  index.html index.php index.cgi index.pl</p></blockquote>
<p><strong>9.  Redirects 转向</strong><br />
单个文件</p>
<blockquote><p>Redirect  /old_dir/old_file.html http://yoursite.com/new_dir/new_file.html</p></blockquote>
<p>整 个目录</p>
<blockquote><p>Redirect /old_dir http://yoursite.com/new_dir</p></blockquote>
<p>效 果: 如同将目录移动位置一样</p>
<blockquote><p>http://yoursite.com/old_dir -&gt;  http://yoursite.com/new_dir<br />
http://yoursite.com/old_dir/dir1/test.html  -&gt; http://yoursite.com/new_dir/dir1/test.html</p></blockquote>
<p>Tip:  使用用户目录时Redirect不能转向的解决方法<br />
当你使用Apache默认的用户目录，如  http://mysite.com/~windix，当你想转向  http://mysite.com/~windix/jump时，你会发现下面这个Redirect不工作:</p>
<blockquote><p>Redirect  /jump http://www.google.com</p></blockquote>
<p>正确的方法是改成</p>
<blockquote><p>Redirect  /~windix/jump http://www.google.com<br />
(source: .htaccess Redirect in  "Sites" not redirecting: why?<br />
)</p></blockquote>
<p><strong>10.  Prevent viewing of .htaccess file 防止.htaccess文件被查看</strong></p>
<blockquote><p>order  allow,deny<br />
deny from all</p></blockquote>
<p><strong>11. Adding MIME  Types 添加 MIME 类型</strong></p>
<blockquote><p>AddType  application/x-shockwave-flash swf</p></blockquote>
<p>Tips: 设置类型为  application/octet-stream 将提示下载<br />
<strong>12. Preventing hot linking of  images and other file types 防盗链</strong><br />
需要mod_rewrite模块</p>
<blockquote><p>RewriteEngine  on<br />
RewriteCond %{HTTP_REFERER} !^$<br />
RewriteCond %{HTTP_REFERER}  !^http://(www/\.)?mydomain.com/.*$ [NC]<br />
RewriteRule  \.(gif|jpg|js|css)$ – [F]</p></blockquote>
<p>解析:<br />
若 HTTP_REFERER 非空  (来源为其他站点，非直接连接) 并且<br />
若 HTTP_REFERER 非(www.)mydomain.com开头(忽略大小写[NC])  (来源非本站)<br />
对于所有含有 .gif/.jpg/.js/.css 结尾的文件给出 403 Forbidden 错误[F]<br />
也可指定 响应，如下例显示替换图片<br />
RewriteRule \.(gif|jpg)$ [R,L]<br />
[R] – 转向(Redirect)<br />
[L]  – 连接(Link)<br />
<strong>13. Preventing Directory Listing 防止目录列表时显示</strong></p>
<blockquote><p>IndexIgnore  *<br />
IndexIgnore *.jpg *.gif</p></blockquote>
<p>Tips:<br />
允许目录列表显示:  Options +Indexes<br />
禁止目录列表显示: Options -Indexes<br />
显示提示信息: 页首 文件HEADER,  页尾 文件README</p>
</div>
<p>本文转自：夜火&#038;轨迹's Blog 链接地址： http://www.15897.com/blog/post/htaccess-shiyongzhinan.html</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1339_htaccess-file-uses-the-authority-of-the-guide.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HTTP头的Expires与Cache-control区别</title>
		<link>http://a18zhizao.com/y2010/1338_http-header-expires-and-cache-control.html</link>
		<comments>http://a18zhizao.com/y2010/1338_http-header-expires-and-cache-control.html#comments</comments>
		<pubDate>Wed, 24 Mar 2010 02:09:15 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[编程]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[Expires]]></category>
		<category><![CDATA[http]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1338</guid>
		<description><![CDATA[今天在群里聊天。说道了Expires。这里来说明下这两个的区别吧。 1.概念 Cache-control 用于控制HTTP缓存（在HTTP/1.0中可能部分没实现，仅仅实现了 Pragma: no-cache） Expires 表示存在时间，允许客户端在这个时间之前不去检查（发请求），等同max-age的效果。但是如果同时存在，则被Cache-Control的max-age覆盖。 2格式 Cache-control: 数据包中的格式： Cache-Control: cache-directive cache-directive可以为以下： request时用到： &#124; "no-cache" &#124; "no-store" &#124; "max-age" "=" delta-seconds &#124; "max-stale" [ "=" delta-seconds ] &#124; "min-fresh" "=" delta-seconds &#124; "no-transform" &#124; "only-if-cached" &#124; "cache-extension" response时用到： &#124; "public" &#124; "private" [ "=" ] &#124; "no-cache" [ "=" ] &#124; "no-store" &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>    今天在群里聊天。说道了Expires。这里来说明下这两个的区别吧。<br />
1.概念<br />
Cache-control 用于控制HTTP缓存（在HTTP/1.0中可能部分没实现，仅仅实现了 Pragma: no-cache）<br />
Expires 表示存在时间，允许客户端在这个时间之前不去检查（发请求），等同max-age的效果。但是如果同时存在，则被Cache-Control的max-age覆盖。</p>
<p>2格式<br />
<strong>Cache-control:</strong><br />
数据包中的格式：<br />
<span id="more-1338"></span><br />
Cache-Control: cache-directive</p>
<p>cache-directive可以为以下：</p>
<p>request时用到：</p>
<p>| "no-cache"<br />
| "no-store"<br />
| "max-age" "=" delta-seconds<br />
| "max-stale" [ "=" delta-seconds ]<br />
| "min-fresh" "=" delta-seconds<br />
| "no-transform"<br />
| "only-if-cached"<br />
| "cache-extension"</p>
<p>response时用到：</p>
<p>| "public"<br />
| "private" [ "=" <"> field-name <"> ]<br />
| "no-cache" [ "=" <"> field-name <"> ]<br />
| "no-store"<br />
| "no-transform"<br />
| "must-revalidate"<br />
| "proxy-revalidate"<br />
| "max-age" "=" delta-seconds<br />
| "s-maxage" "=" delta-seconds<br />
| "cache-extension"</p>
<p>部分说明：<br />
根据是否可缓存分为<br />
Public  指示响应可被任何缓存区缓存。<br />
Private  指示对于单个用户的整个或部分响应消息，不能被共享缓存处理。这允许服务器仅仅描述当用户的<br />
部分响应消息，此响应消息对于其他用户的请求无效。<br />
no-cache  指示请求或响应消息不能缓存（HTTP/1.0用Pragma的no-cache替换）<br />
根据什么能被缓存<br />
no-store  用于防止重要的信息被无意的发布。在请求消息中发送将使得请求和响应消息都不使用缓存。<br />
根据缓存超时<br />
max-age  指示客户机可以接收生存期不大于指定时间（以秒为单位）的响应。<br />
min-fresh  指示客户机可以接收响应时间小于当前时间加上指定时间的响应。<br />
max-stale  指示客户机可以接收超出超时期间的响应消息。如果指定max-stale消息的值，那么客户机可以接收超出超时期指定值之内的响应消息。</p>
<p><strong>Expires: </strong><br />
数据包中的格式：<br />
<code>Expires = "Expires" ":" HTTP-date</code><br />
例如<br />
<code>Expires: Thu, 01 Dec 1994 16:00:00 GMT</code> （必须是GMT格式）</p>
<p>3.应用<br />
通过HTTP的META设置expires和cache-control</p>
<pre class="brush: xml; title: ; notranslate">
&lt;meta http-equiv=&quot;Cache-Control&quot; content=&quot;max-age=7200&quot; /&gt;
&lt;meta http-equiv=&quot;Expires&quot; content=&quot;Mon, 20 Jul 2009 23:00:00 GMT&quot; /&gt;
</pre>
<p>上述设置仅为举例，实际使用其一即可。这样写的话仅对该网页有效，对网页中的图片或其他请求无效，并不会做任何cache。<br />
这样客户端的请求就多了，尽管只是检查Last-modified状态的东西，但是请求一多对浏览速度必定有影响。</p>
<p>如果要对文件添加cache可以通过apache的mod_expire模块，写法为</p>
<pre class="brush: bash; title: ; notranslate">
&lt;IfModule mod_expires.c&gt;
ExpiresActive On
ExpiresDefault &quot;access plus 1 days&quot;
&lt;/IfModule&gt;
</pre>
<p>记得ExpiresActive设为On，我起先没设置On，似乎怎样YSlow都查不到缓存机制。这样添加的话就是默认所有的。</p>
<p>如果要针对个别MIME类型则可以：<br />
<code>ExpiresByType image/gif "access plus 5 hours 3 minutes"</code><br />
见 <a href="http://httpd.apache.org/docs/2.2/mod/mod_expires.html">Apache Module mod_expires</a><br />
另外，当点击浏览器上的刷新，客户端发送的请求中均是max-age=0，表示validate操作，发送请求到服务器<br />
要求检查cache，再更新cache，一般得到的是304 Not Modified，表示没变动。</p>
<p>参考：<br />
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32">HTTP RFC2616 HeaderField</a></p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1338_http-header-expires-and-cache-control.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>aMule下载短信通知的飞信实现</title>
		<link>http://a18zhizao.com/y2010/1330_amule-download-the-sms-flight-notification-letter-to-achieve-the.html</link>
		<comments>http://a18zhizao.com/y2010/1330_amule-download-the-sms-flight-notification-letter-to-achieve-the.html#comments</comments>
		<pubDate>Mon, 22 Mar 2010 02:43:33 +0000</pubDate>
		<dc:creator>a18ccms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[短信]]></category>
		<category><![CDATA[通知]]></category>
		<category><![CDATA[飞信]]></category>

		<guid isPermaLink="false">http://a18zhizao.com/?p=1330</guid>
		<description><![CDATA[文章转载自： aMule下载短信通知的飞信实现 因为它不让IE访问。。。。 上回用GCalcli实现了给aMule增加下载完成短信通知功能，不过由于GCal的短信格式问题并不完美，在Druggo的提示下转而使用飞信来实现这个吧。 飞信虽然在linux下已经有libfetion和linux-fetion for purple了，不过都没有直观的纯CLI操作方式。找来找去只找到个闭源的飞信机器人，这软件优点是:纯命令操作，简单快捷。 不爽的地方是: 闭源，依赖的库文件有版本要求。而且从主页来看，商业味比较浓，怕有猫腻 初次运行后会生成数个当前用户无访问权限的文件夹，强行删除再运行又会重新生成 唉，我又开始二了，用人家的东西还这么多牢骚。下面是实现方法： 在此处下载飞信机器人的linux版，运行程序依赖的库文件有4个:libcrypto.so.0.9.8, libssl.so.0.9.8, libACE.so.5.6.8, libACE_SSL.so.5.6.8。前两个属于 openssh，后两个可以# emerge dev-libs/ace得到，鉴于版本问题和libACE 8MB的体积问题，还是直接下载它提供的库文件包吧。 建议解压后放到自己的$HOME目录下，例如我把它解压到$HOME/fetion-cli下，把解压的4个库文件也放到此目录下。 飞信机器人支持config文件读取帐户信息，创建一个$HOME/.fetion-cli.conf，按以下格式输入你的帐户信息: # ID Mobile Password 1 你的手机号码 你的飞信密码 然后是建立一个bash脚本fetion-sms.sh #!/bin/bash #usage: fetion-sms.sh MobileNum. ENTRY cd /home/punkid/fetion-cli LD_LIBRARY_PATH=. ./fetion --config=$HOME/.fetion-cli.conf --index=1 --to=$1 --msg-utf8="$2" 这个脚本用法很简单，输入$ sh fetion-sms.sh 接收方的手机好码 飞信消息内容就完成了。 所以在aMule的Download completed event里配置如下就行了: sh /home/punkid/scripts/fetion-sms.sh 你的手机号码 "%NAME 下载完成" 这回算是比较满意了，飞信接收速度快而且不像GCal那样分两条不完整短信发过来。 [...]]]></description>
			<content:encoded><![CDATA[<p>文章转载自： <a href="http://blog.punkid.org/2009/03/27/free-sms-notification-via-fetion-on-amule-completed-download/">aMule下载短信通知的飞信实现</a> 因为它不让IE访问。。。。</p>
<p>上回用GCalcli实现了<a title="给aMule增加下载完成短信通知功能" href="http://blog.punkid.org/2009/03/23/free-sms-notification-on-amule-completed-download">给aMule增加下载完成短信通知功能</a>，不过由于GCal的短信格式问题并不完美，在<a title="Comment by Druggo" href="http://blog.punkid.org/2009/03/23/free-sms-notification-on-amule-completed-download/comment-page-1/#comment-1470">Druggo的提示</a>下转而使用飞信来实现这个吧。<br />
<span id="more-1330"></span><br />
飞信虽然在linux下已经有libfetion和linux-fetion for purple了，不过都没有直观的纯CLI操作方式。找来找去只找到个闭源的<a title="飞信机器人" href="http://www.it-adv.net/">飞信机器人</a>，这软件优点是:纯命令操作，简单快捷。</p>
<p>不爽的地方是:</p>
<ol>
<li>闭源，依赖的库文件有版本要求。而且从主页来看，商业味比较浓，怕有猫腻</li>
<li>初次运行后会生成数个当前用户无访问权限的文件夹，强行删除再运行又会重新生成</li>
</ol>
<p>唉，我又开始二了，用人家的东西还这么多牢骚。下面是实现方法：</p>
<p>在<a title="下载飞信机器人" href="http://bbs.it-adv.net/viewthread.php?tid=155">此处下载飞信机器人的linux版</a>，运行程序依赖的库文件有4个:<code>libcrypto.so.0.9.8</code>, <code>libssl.so.0.9.8</code>, <code>libACE.so.5.6.8</code>, <code>libACE_SSL.so.5.6.8</code>。前两个属于 openssh，后两个可以<code># emerge dev-libs/ace</code>得到，鉴于版本问题和libACE 8MB的体积问题，还是直接下载它提供的<a title="飞信机器人 Linux库文件包" href="http://www.it-adv.net/fetion/downng/library_linux.tar.gz">库文件包</a>吧。</p>
<p>建议解压后放到自己的<code>$HOME</code>目录下，例如我把它解压到<code>$HOME/fetion-cli</code>下，把解压的4个库文件也放到此目录下。</p>
<p>飞信机器人支持config文件读取帐户信息，创建一个<code>$HOME/.fetion-cli.conf</code>，按以下格式输入你的帐户信息:</p>
<pre># ID    Mobile          Password
1        你的手机号码   你的飞信密码</pre>
<p>然后是建立一个bash脚本<code>fetion-sms.sh</code></p>
<pre>#!/bin/bash
#usage: fetion-sms.sh MobileNum. ENTRY

cd /home/punkid/fetion-cli
LD_LIBRARY_PATH=. ./fetion --config=$HOME/.fetion-cli.conf --index=1 --to=$1 --msg-utf8="$2"</pre>
<p>这个脚本用法很简单，输入<code>$ sh fetion-sms.sh 接收方的手机好码 飞信消息内容</code>就完成了。</p>
<p>所以在aMule的Download completed event里配置如下就行了:</p>
<pre>sh /home/punkid/scripts/fetion-sms.sh 你的手机号码 "%NAME 下载完成"</pre>
<p>这回算是比较满意了，飞信接收速度快而且不像GCal那样分两条不完整短信发过来。</p>
<p>上回用GCalcli实现了<a title="给aMule增加下载完成短信通知功能" href="http://blog.punkid.org/2009/03/23/free-sms-notification-on-amule-completed-download">给aMule增加下载完成短信通知功能</a>，不过由于GCal的短信格式问题并不完美，在<a title="Comment by Druggo" href="http://blog.punkid.org/2009/03/23/free-sms-notification-on-amule-completed-download/comment-page-1/#comment-1470">Druggo的提示</a>下转而使用飞信来实现这个吧。</p>
<p>飞信虽然在linux下已经有libfetion和linux-fetion for purple了，不过都没有直观的纯CLI操作方式。找来找去只找到个闭源的<a title="飞信机器人" href="http://www.it-adv.net/">飞信机器人</a>，这软件优点是:纯命令操作，简单快捷。</p>
<p>不爽的地方是:</p>
<ol>
<li>闭源，依赖的库文件有版本要求。而且从主页来看，商业味比较浓，怕有猫腻</li>
<li>初次运行后会生成数个当前用户无访问权限的文件夹，强行删除再运行又会重新生成</li>
</ol>
<p>唉，我又开始二了，用人家的东西还这么多牢骚。下面是实现方法：<br />
<span id="more-303"> </span><br />
在<a title="下载飞信机器人" href="http://bbs.it-adv.net/viewthread.php?tid=155">此处下载飞信机器人的linux版</a>，运行程序依赖的库文件有4个:<code>libcrypto.so.0.9.8</code>, <code>libssl.so.0.9.8</code>, <code>libACE.so.5.6.8</code>, <code>libACE_SSL.so.5.6.8</code>。前两个属于 openssh，后两个可以<code># emerge dev-libs/ace</code>得到，鉴于版本问题和libACE 8MB的体积问题，还是直接下载它提供的<a title="飞信机器人 Linux库文件包" href="http://www.it-adv.net/fetion/downng/library_linux.tar.gz">库文件包</a>吧。</p>
<p>建议解压后放到自己的<code>$HOME</code>目录下，例如我把它解压到<code>$HOME/fetion-cli</code>下，把解压的4个库文件也放到此目录下。</p>
<p>飞信机器人支持config文件读取帐户信息，创建一个<code>$HOME/.fetion-cli.conf</code>，按以下格式输入你的帐户信息:</p>
<pre># ID    Mobile          Password
1        你的手机号码   你的飞信密码</pre>
<p>然后是建立一个bash脚本<code>fetion-sms.sh</code></p>
<pre class="bash"><span style="font-style: italic; color: #666666;">#!/bin/bash</span>
<span style="font-style: italic; color: #666666;">#usage: fetion-sms.sh MobileNum. ENTRY</span>

<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>punkid<span style="color: #000000; font-weight: bold;">/</span>fetion-cli
<span style="color: #007800;">LD_LIBRARY_PATH</span>=. .<span style="color: #000000; font-weight: bold;">/</span>fetion <span style="color: #660033;">--config</span>=<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.fetion-cli.conf <span style="color: #660033;">--index</span>=<span style="color: #000000;">1</span> <span style="color: #660033;">--to</span>=$<span style="color: #000000;">1</span> <span style="color: #660033;">--msg-utf8</span>=<span style="color: #ff0000;">"$2"</span></pre>
<p>这个脚本用法很简单，输入<code>$ sh fetion-sms.sh 接收方的手机好码 飞信消息内容</code>就完成了。</p>
<p>所以在aMule的Download completed event里配置如下就行了:</p>
<pre class="bash"><span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>punkid<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>fetion-sms.sh 你的手机号码 <span style="color: #ff0000;">"%NAME 下载完成"</span></pre>
<p>这回算是比较满意了，飞信接收速度快而且不像GCal那样分两条不完整短信发过来。</p>
]]></content:encoded>
			<wfw:commentRss>http://a18zhizao.com/y2010/1330_amule-download-the-sms-flight-notification-letter-to-achieve-the.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

