<?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>Timothy&#039;s Space</title>
	<atom:link href="http://www.xiaozhou.net/feed" rel="self" type="application/rss+xml" />
	<link>http://www.xiaozhou.net</link>
	<description>君看一叶舟，出没风波里</description>
	<lastBuildDate>Tue, 09 Mar 2010 17:04:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>VOA Special English MP3 Downloader</title>
		<link>http://www.xiaozhou.net/python/voa_special_english_mp3_downloader-2010-03-10.htm</link>
		<comments>http://www.xiaozhou.net/python/voa_special_english_mp3_downloader-2010-03-10.htm#comments</comments>
		<pubDate>Tue, 09 Mar 2010 17:01:00 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[downloader]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[special]]></category>
		<category><![CDATA[VOA]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/python/voa-special-english-mp3-downloader-2010-03-10.htm</guid>
		<description><![CDATA[最近上下班开车挺无聊，听腻了各式音乐，打算利用上下班的时间学学英语，锻炼下生锈的耳朵，听听English MP3。以前一直比较喜欢VOA Special English的慢速版，虽然还是有一定的难度，但听起来多少能找到点感觉。今天突然心血来潮，google了下VOA的老家，很不幸，网页无法打开，第一直觉就是VOA被伟大的wall给挡住了。搜索了一下，果然如此……不过咱有SSH，怕啥？通过SSH果然可以正常访问，这也印证了前面的猜想。不过VOA的mp3貌似每天都出，一个一个点链接下载，实在是个体力活，人本来就有惰性，俺也不例外！于是，有了下面的想法……
咱IT民工，比较拿手的就是让电脑帮俺们去完成一些重复劳动，减轻体力负担，如果能让电脑自动帮俺下载mp3该多好！加之最近又在看python的东东，python很强大，几行代码就能完成复杂的工作。于是开始手痒，何不用python搞个下载器试试呢？ 对了，有wall，怎么办？不怕！咱有VPS，哈哈哈！
开工！在VOA的页面，上找到RSS页面地址(RSS页面包含有最新发布的文章以及mp3下载链接)，然后对RSS进行分析，写python脚本，调试，运行，效果还不错！最近发布文章的mp3被啪啪啪的拖到了VPS上。脚本十分简单：

?View Code PYTHON1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/python
#VOA Special English MP3 Downloader.
#Written by Timothy 2010.3.10
import urllib,time;
from xml.dom import minidom
from os import system
url = &#34;http://www1.voanews.com/templates/Articles.rss?sectionPath=/learningenglish/home&#34;
link = urllib.urlopen&#40;url&#41;
#content=link.read()
rss = minidom.parse&#40;link&#41;
elements = rss.getElementsByTagName&#40;'media:content'&#41;
for element in elements:
	if element.hasAttribute&#40;'type'&#41;:
		print 'Now downloading:' + element.getAttribute&#40;'url'&#41;
		system&#40;'wget -nc  ' + element.getAttribute&#40;'url'&#41;&#41;

运行效果：

?View Code BASH1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
timothy@vps:~$ ls
VOAEnglish.py
timothy@vps:~$ chmod +x VOAEnglish.py
timothy@vps:~$ ./VOAEnglish.py 
Now downloading:http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-sin-2578-smoking-09mar10.Mp3
--2010-03-09 16:37:40--  http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-sin-2578-smoking-09mar10.Mp3
Resolving www.voanews.com... [...]]]></description>
			<content:encoded><![CDATA[<p>最近上下班开车挺无聊，听腻了各式音乐，打算利用上下班的时间学学英语，锻炼下生锈的耳朵，听听English MP3。以前一直比较喜欢VOA Special English的慢速版，虽然还是有一定的难度，但听起来多少能找到点感觉。今天突然心血来潮，google了下VOA的老家，很不幸，网页无法打开，第一直觉就是VOA被伟大的wall给挡住了。搜索了一下，果然如此……不过咱有SSH，怕啥？通过SSH果然可以正常访问，这也印证了前面的猜想。不过VOA的mp3貌似每天都出，一个一个点链接下载，实在是个体力活，人本来就有惰性，俺也不例外！于是，有了下面的想法……</p>
<p>咱IT民工，比较拿手的就是让电脑帮俺们去完成一些重复劳动，减轻体力负担，如果能让电脑自动帮俺下载mp3该多好！加之最近又在看python的东东，python很强大，几行代码就能完成复杂的工作。于是开始手痒，何不用python搞个下载器试试呢？ 对了，有wall，怎么办？不怕！咱有VPS，哈哈哈！</p>
<p>开工！在VOA的页面，上找到<a href="http://www1.voanews.com/templates/Articles.rss?sectionPath=/learningenglish/home" target="_blank">RSS页面地址</a>(RSS页面包含有最新发布的文章以及mp3下载链接)，然后对RSS进行分析，写python脚本，调试，运行，效果还不错！最近发布文章的mp3被啪啪啪的拖到了VPS上。脚本十分简单：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p558code3'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p5583"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p558code3"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
<span style="color: #808080; font-style: italic;">#VOA Special English MP3 Downloader.</span>
<span style="color: #808080; font-style: italic;">#Written by Timothy 2010.3.10</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib</span>,<span style="color: #dc143c;">time</span><span style="color: #66cc66;">;</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">xml</span>.<span style="color: black;">dom</span> <span style="color: #ff7700;font-weight:bold;">import</span> minidom
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">os</span> <span style="color: #ff7700;font-weight:bold;">import</span> system
url = <span style="color: #483d8b;">&quot;http://www1.voanews.com/templates/Articles.rss?sectionPath=/learningenglish/home&quot;</span>
link = <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>url<span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;">#content=link.read()</span>
rss = minidom.<span style="color: black;">parse</span><span style="color: black;">&#40;</span>link<span style="color: black;">&#41;</span>
elements = rss.<span style="color: black;">getElementsByTagName</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'media:content'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">for</span> element <span style="color: #ff7700;font-weight:bold;">in</span> elements:
	<span style="color: #ff7700;font-weight:bold;">if</span> element.<span style="color: black;">hasAttribute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'type'</span><span style="color: black;">&#41;</span>:
		<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Now downloading:'</span> + element.<span style="color: black;">getAttribute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'url'</span><span style="color: black;">&#41;</span>
		system<span style="color: black;">&#40;</span><span style="color: #483d8b;">'wget -nc  '</span> + element.<span style="color: black;">getAttribute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'url'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>运行效果：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p558code4'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p5584"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
</pre></td><td class="code" id="p558code4"><pre class="bash" style="font-family:monospace;">timothy<span style="color: #000000; font-weight: bold;">@</span>vps:~$ <span style="color: #c20cb9; font-weight: bold;">ls</span>
VOAEnglish.py
timothy<span style="color: #000000; font-weight: bold;">@</span>vps:~$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x VOAEnglish.py
timothy<span style="color: #000000; font-weight: bold;">@</span>vps:~$ .<span style="color: #000000; font-weight: bold;">/</span>VOAEnglish.py 
Now downloading:http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-sin-2578-smoking-09mar10.Mp3
<span style="color: #660033;">--<span style="color: #000000;">2010</span>-03-09</span> 16:37:40--  http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-sin-2578-smoking-09mar10.Mp3
Resolving www.voanews.com... 72.247.217.25, 72.247.217.9
Connecting to www.voanews.com<span style="color: #000000; font-weight: bold;">|</span>72.247.217.25<span style="color: #000000; font-weight: bold;">|</span>:80... connected.
HTTP request sent, awaiting response... <span style="color: #000000;">200</span> OK
Length: <span style="color: #000000;">7765680</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>7.4M<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>audio<span style="color: #000000; font-weight: bold;">/</span>mpeg<span style="color: #7a0874; font-weight: bold;">&#93;</span>
Saving to: <span style="color: #000000; font-weight: bold;">`</span>se-sin-<span style="color: #000000;">2578</span>-smoking-09mar10.Mp3<span style="color: #ff0000;">'
&nbsp;
100%[==========================&gt;] 7,765,680   10.0M/s   in 0.7s    
&nbsp;
2010-03-09 16:37:41 (10.0 MB/s) - `se-sin-2578-smoking-09mar10.Mp3'</span> saved <span style="color: #7a0874; font-weight: bold;">&#91;</span>7765680<span style="color: #000000; font-weight: bold;">/</span>7765680<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Now downloading:http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-ag-broccoli-9mar10.Mp3
<span style="color: #660033;">--<span style="color: #000000;">2010</span>-03-09</span> 16:37:41--  http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-ag-broccoli-9mar10.Mp3
Resolving www.voanews.com... 72.247.217.25, 72.247.217.9
Connecting to www.voanews.com<span style="color: #000000; font-weight: bold;">|</span>72.247.217.25<span style="color: #000000; font-weight: bold;">|</span>:80... connected.
HTTP request sent, awaiting response... <span style="color: #000000;">200</span> OK
Length: <span style="color: #000000;">1905683</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.8M<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>audio<span style="color: #000000; font-weight: bold;">/</span>mpeg<span style="color: #7a0874; font-weight: bold;">&#93;</span>
Saving to: <span style="color: #000000; font-weight: bold;">`</span>se-ag-broccoli-9mar10.Mp3<span style="color: #ff0000;">'
&nbsp;
100%[==========================&gt;] 1,905,683   9.44M/s   in 0.2s    
&nbsp;
2010-03-09 16:37:41 (9.44 MB/s) - `se-ag-broccoli-9mar10.Mp3'</span> saved <span style="color: #7a0874; font-weight: bold;">&#91;</span>1905683<span style="color: #000000; font-weight: bold;">/</span>1905683<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Now downloading:http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-dev-int-womens-day-8mar10.Mp3
<span style="color: #660033;">--<span style="color: #000000;">2010</span>-03-09</span> 16:37:41--  http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-dev-int-womens-day-8mar10.Mp3
Resolving www.voanews.com... 72.247.217.25, 72.247.217.9
Connecting to www.voanews.com<span style="color: #000000; font-weight: bold;">|</span>72.247.217.25<span style="color: #000000; font-weight: bold;">|</span>:80... connected.
HTTP request sent, awaiting response... <span style="color: #000000;">200</span> OK
Length: <span style="color: #000000;">1907146</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.8M<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>audio<span style="color: #000000; font-weight: bold;">/</span>mpeg<span style="color: #7a0874; font-weight: bold;">&#93;</span>
Saving to: <span style="color: #000000; font-weight: bold;">`</span>se-dev-int-womens-day-8mar10.Mp3<span style="color: #ff0000;">'
&nbsp;
100%[==========================&gt;] 1,907,146   8.81M/s   in 0.2s    
&nbsp;
2010-03-09 16:37:41 (8.81 MB/s) - `se-dev-int-womens-day-8mar10.Mp3'</span> saved <span style="color: #7a0874; font-weight: bold;">&#91;</span>1907146<span style="color: #000000; font-weight: bold;">/</span>1907146<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Now downloading:http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-tia-molly-brown-05mar10.Mp3
<span style="color: #660033;">--<span style="color: #000000;">2010</span>-03-09</span> 16:37:41--  http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-tia-molly-brown-05mar10.Mp3
Resolving www.voanews.com... 72.247.217.9, 72.247.217.25
Connecting to www.voanews.com<span style="color: #000000; font-weight: bold;">|</span>72.247.217.9<span style="color: #000000; font-weight: bold;">|</span>:80... connected.
HTTP request sent, awaiting response... <span style="color: #000000;">200</span> OK
Length: <span style="color: #000000;">7429432</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>7.1M<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>audio<span style="color: #000000; font-weight: bold;">/</span>mpeg<span style="color: #7a0874; font-weight: bold;">&#93;</span>
Saving to: <span style="color: #000000; font-weight: bold;">`</span>se-tia-molly-brown-05mar10.Mp3<span style="color: #ff0000;">'
&nbsp;
100%[==========================&gt;] 7,429,432   8.68M/s   in 0.8s    
&nbsp;
2010-03-09 16:37:42 (8.68 MB/s) - `se-tia-molly-brown-05mar10.Mp3'</span> saved <span style="color: #7a0874; font-weight: bold;">&#91;</span>7429432<span style="color: #000000; font-weight: bold;">/</span>7429432<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Now downloading:http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-pia-todd-duncan-7mar10.Mp3
<span style="color: #660033;">--<span style="color: #000000;">2010</span>-03-09</span> 16:37:42--  http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-pia-todd-duncan-7mar10.Mp3
Resolving www.voanews.com... 72.247.217.9, 72.247.217.25
Connecting to www.voanews.com<span style="color: #000000; font-weight: bold;">|</span>72.247.217.9<span style="color: #000000; font-weight: bold;">|</span>:80... connected.
HTTP request sent, awaiting response... <span style="color: #000000;">200</span> OK
Length: <span style="color: #000000;">7470601</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>7.1M<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>audio<span style="color: #000000; font-weight: bold;">/</span>mpeg<span style="color: #7a0874; font-weight: bold;">&#93;</span>
Saving to: <span style="color: #000000; font-weight: bold;">`</span>se-pia-todd-duncan-7mar10.Mp3<span style="color: #ff0000;">'
&nbsp;
100%[==========================&gt;] 7,470,601   6.06M/s   in 1.2s    
&nbsp;
2010-03-09 16:37:43 (6.06 MB/s) - `se-pia-todd-duncan-7mar10.Mp3'</span> saved <span style="color: #7a0874; font-weight: bold;">&#91;</span>7470601<span style="color: #000000; font-weight: bold;">/</span>7470601<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Now downloading:http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-itn-tea-party-6mar10.Mp3
<span style="color: #660033;">--<span style="color: #000000;">2010</span>-03-09</span> 16:37:43--  http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-itn-tea-party-6mar10.Mp3
Resolving www.voanews.com... 72.247.217.25, 72.247.217.9
Connecting to www.voanews.com<span style="color: #000000; font-weight: bold;">|</span>72.247.217.25<span style="color: #000000; font-weight: bold;">|</span>:80... connected.
HTTP request sent, awaiting response... <span style="color: #000000;">200</span> OK
Length: <span style="color: #000000;">2405145</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>2.3M<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>audio<span style="color: #000000; font-weight: bold;">/</span>mpeg<span style="color: #7a0874; font-weight: bold;">&#93;</span>
Saving to: <span style="color: #000000; font-weight: bold;">`</span>se-itn-tea-party-6mar10.Mp3<span style="color: #ff0000;">'
&nbsp;
100%[==========================&gt;] 2,405,145   3.98M/s   in 0.6s    
&nbsp;
2010-03-09 16:37:44 (3.98 MB/s) - `se-itn-tea-party-6mar10.Mp3'</span> saved <span style="color: #7a0874; font-weight: bold;">&#91;</span>2405145<span style="color: #000000; font-weight: bold;">/</span>2405145<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Now downloading:http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-econ-corp-history-5mar10.Mp3
<span style="color: #660033;">--<span style="color: #000000;">2010</span>-03-09</span> 16:37:44--  http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-econ-corp-history-5mar10.Mp3
Resolving www.voanews.com... 72.247.217.9, 72.247.217.25
Connecting to www.voanews.com<span style="color: #000000; font-weight: bold;">|</span>72.247.217.9<span style="color: #000000; font-weight: bold;">|</span>:80... connected.
HTTP request sent, awaiting response... <span style="color: #000000;">200</span> OK
Length: <span style="color: #000000;">1940583</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.9M<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>audio<span style="color: #000000; font-weight: bold;">/</span>mpeg<span style="color: #7a0874; font-weight: bold;">&#93;</span>
Saving to: <span style="color: #000000; font-weight: bold;">`</span>se-econ-corp-history-5mar10.Mp3<span style="color: #ff0000;">'
&nbsp;
100%[==========================&gt;] 1,940,583   6.77M/s   in 0.3s    
&nbsp;
2010-03-09 16:37:44 (6.77 MB/s) - `se-econ-corp-history-5mar10.Mp3'</span> saved <span style="color: #7a0874; font-weight: bold;">&#91;</span>1940583<span style="color: #000000; font-weight: bold;">/</span>1940583<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Now downloading:http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-mosaic-05mar10.Mp3
<span style="color: #660033;">--<span style="color: #000000;">2010</span>-03-09</span> 16:37:44--  http:<span style="color: #000000; font-weight: bold;">//</span>www.voanews.com<span style="color: #000000; font-weight: bold;">/</span>MediaAssets2<span style="color: #000000; font-weight: bold;">/</span>learningenglish<span style="color: #000000; font-weight: bold;">/</span>dalet<span style="color: #000000; font-weight: bold;">/</span>se-mosaic-05mar10.Mp3
Resolving www.voanews.com... 72.247.217.9, 72.247.217.25
Connecting to www.voanews.com<span style="color: #000000; font-weight: bold;">|</span>72.247.217.9<span style="color: #000000; font-weight: bold;">|</span>:80... connected.
HTTP request sent, awaiting response... <span style="color: #000000;">200</span> OK
Length: <span style="color: #000000;">7341034</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>7.0M<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>audio<span style="color: #000000; font-weight: bold;">/</span>mpeg<span style="color: #7a0874; font-weight: bold;">&#93;</span>
Saving to: <span style="color: #000000; font-weight: bold;">`</span>se-mosaic-05mar10.Mp3<span style="color: #ff0000;">'
&nbsp;
100%[==========================&gt;] 7,341,034   9.01M/s   in 0.8s    
&nbsp;
2010-03-09 16:37:45 (9.01 MB/s) - `se-mosaic-05mar10.Mp3'</span> saved <span style="color: #7a0874; font-weight: bold;">&#91;</span>7341034<span style="color: #000000; font-weight: bold;">/</span>7341034<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
timothy<span style="color: #000000; font-weight: bold;">@</span>vps:~$ <span style="color: #c20cb9; font-weight: bold;">ls</span>
se-ag-broccoli-9mar10.Mp3         se-pia-todd-duncan-7mar10.Mp3
se-dev-int-womens-day-8mar10.Mp3  se-sin-<span style="color: #000000;">2578</span>-smoking-09mar10.Mp3
se-econ-corp-history-5mar10.Mp3   se-tia-molly-brown-05mar10.Mp3
se-itn-tea-party-6mar10.Mp3       VOAEnglish.py
se-mosaic-05mar10.Mp3
timothy<span style="color: #000000; font-weight: bold;">@</span>vps:~$</pre></td></tr></table></div>

<p>VPS和VOA都在米国，下载速度很快啊……几秒钟的功夫…… </p>
<p>最后，再想办法把mp3统统拖回来本地即可。此脚本适合拥有VPS的、有兴趣的同学使用，后续会慢慢改进脚本。</p>
<h3  class="related_post_title">你可能也对下列文章感兴趣</h3><ul class="related_post"><li>2009年12月28日 -- <a href="http://www.xiaozhou.net/ittech/software/using_ucweb_en_version-2009-12-28.htm" title="使用英文版UCWEB">使用英文版UCWEB</a> (4)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/python/voa_special_english_mp3_downloader-2010-03-10.htm/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
<enclosure url="http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-pia-todd-duncan-7mar10.Mp3" length="7470601" type="audio/mpeg" />
<enclosure url="http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-tia-molly-brown-05mar10.Mp3" length="7429432" type="audio/mpeg" />
<enclosure url="http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-sin-2578-smoking-09mar10.Mp3" length="7765680" type="audio/mpeg" />
<enclosure url="http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-ag-broccoli-9mar10.Mp3" length="1905683" type="audio/mpeg" />
<enclosure url="http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-dev-int-womens-day-8mar10.Mp3" length="1907146" type="audio/mpeg" />
<enclosure url="http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-itn-tea-party-6mar10.Mp3" length="2405145" type="audio/mpeg" />
<enclosure url="http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-econ-corp-history-5mar10.Mp3" length="1940583" type="audio/mpeg" />
<enclosure url="http://www.voanews.com/MediaAssets2/learningenglish/dalet/se-mosaic-05mar10.Mp3" length="7341034" type="audio/mpeg" />
		</item>
		<item>
		<title>俺的VPS正式上线了</title>
		<link>http://www.xiaozhou.net/ittech/vps-ittech/my_vps_is_online-2010-03-05.htm</link>
		<comments>http://www.xiaozhou.net/ittech/vps-ittech/my_vps_is_online-2010-03-05.htm#comments</comments>
		<pubDate>Thu, 04 Mar 2010 17:03:00 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[vps]]></category>
		<category><![CDATA[online]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/ittech/vps-ittech/%e4%bf%ba%e7%9a%84vps%e6%ad%a3%e5%bc%8f%e4%b8%8a%e7%ba%bf%e4%ba%86-2010-03-05.htm</guid>
		<description><![CDATA[VPS正式上线，先恭喜下自己 ，嘿嘿。   经过多方比较，最后选了BurstNET的VPS最低配置的那一款，具体配置如下：    
VPS Software: vePortal™ / OpenVZ™    CPU: 1000MHZ GUARANTEED    Memory: 512MB GUARANTEED    Disk Space: 20GB (RAID BASED CONFIG)    Bandwidth: 1000GB/MONTH    IP Addresses: 2    Management: BASIC MANAGED    DDOS [...]]]></description>
			<content:encoded><![CDATA[<p>VPS正式上线，先恭喜下自己 ，嘿嘿。   <br />经过多方比较，最后选了BurstNET的<a href="https://www.burst.net/linvps.shtml" target="_blank">VPS</a>最低配置的那一款，具体配置如下：    </p>
<p>VPS Software: <a href="http://www.veportal.com">vePortal™ / OpenVZ™</a>    <br />CPU: 1000MHZ GUARANTEED    <br />Memory: 512MB GUARANTEED    <br />Disk Space: 20GB (RAID BASED CONFIG)    <br />Bandwidth: 1000GB/MONTH    <br />IP Addresses: 2    <br />Management: <a href="https://www.burst.net/policy/managed.shtml">BASIC MANAGED</a>    <br />DDOS Protection: <a href="http://www.cisco.com/en/US/prod/collateral/modules/ps2706/ps6235/product_data_sheet0900aecd80220a7c.html">CISCO™ GUARD</a>    </p>
<p>可惜是基于OpenVZ的，不支持PPTP的VPN，只能架OpenVPN。其他的地方还比较满意，2个IP，1TB月流量是亮点。装上了Ubuntu 9.10 32bit系统，用PHP+MySql+Nginx+FastCGI 搭建了WordPress环境自上次重启后，用uptime命令查询了一下，运行了两天又十小时，还算稳定。free -m命令，显示剩余内存131MB，为了测试速度，打开了到vps的ping,自家的成都电信ADSL，自测速度如下：    <br /><a href="http://www.xiaozhou.net/pics/VPS_E72/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.xiaozhou.net/pics/VPS_E72/image_thumb.png" width="580" height="263" /></a>&#160; <br />麻烦各位天南地北的同学帮我测试一下速度(<font color="#ff0000">ping vps.xiaozhou.net</font>)，在回帖中告诉下我你的宽带是网通、电信还是其他，ping平均多少ms延时。非常感谢！    </p>
<h3  class="related_post_title">你可能也对下列文章感兴趣</h3><ul class="related_post"><li>2010年02月26日 -- <a href="http://www.xiaozhou.net/ittech/linux-ittech/vps_iptables_setting_example-2010-02-26.htm" title="vps中的iptables规则设置范例">vps中的iptables规则设置范例</a> (6)</li><li>2009年12月20日 -- <a href="http://www.xiaozhou.net/essay/%e5%85%b3%e9%94%ae%e8%af%8d%ef%bc%9a%e5%91%a8%e6%9c%ab-%e7%b3%bb%e7%bb%9f%e4%b8%8a%e7%ba%bf-%e5%8a%a0%e7%8f%ad-%e9%80%9a%e5%ae%b5-2009-12-20.htm" title="关键词：周末 系统上线 加班 通宵">关键词：周末 系统上线 加班 通宵</a> (3)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/ittech/vps-ittech/my_vps_is_online-2010-03-05.htm/feed</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>周末踏青</title>
		<link>http://www.xiaozhou.net/essay/photo-essay/weekend_journey-2010-02-28.htm</link>
		<comments>http://www.xiaozhou.net/essay/photo-essay/weekend_journey-2010-02-28.htm#comments</comments>
		<pubDate>Sun, 28 Feb 2010 15:56:00 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[随影随行]]></category>
		<category><![CDATA[photo]]></category>
		<category><![CDATA[weekend]]></category>
		<category><![CDATA[三圣乡]]></category>
		<category><![CDATA[踏青]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/unsorted/%e5%91%a8%e6%9c%ab%e8%b8%8f%e9%9d%92-2010-02-28.htm</guid>
		<description><![CDATA[天气终于逐渐暖和了，整个冬天在家里都快发霉了。趁着天气晴朗的周末，带上家人和孩子，去了成都的三圣花乡，算是新年第一次外出游玩。顺便带上了相机，瞎拍了几张，练练手，欢迎大家拍砖。
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
 
 

&#160; 

随机日志2004年09月7日 -- 另一个特殊矩阵的Java实现 (1)2004年12月28日 -- 获取磁盘使用空间和剩余空间 (3)2004年10月27日 -- 用.DEF文件导出DLL中的函数 (1)2010年01月29日 -- 一个不错的Firefox Add-ons: AutoProxy (12)2007年09月1日 -- 周末的榴莲大餐 (6)2005年02月21日 -- 如何把一个程序注册成系统服务 (1)2004年12月15日 -- 截获系统注销时候的消息 (0)2004年11月17日 -- Windows 任务管理器如何确定应用程序&#34;没有响应&#34; (1)2004年12月29日 -- 获取CPU序列号 (1)2006年11月20日 -- Wake On Lan 远程唤醒 (5)]]></description>
			<content:encoded><![CDATA[<p>天气终于逐渐暖和了，整个冬天在家里都快发霉了。趁着天气晴朗的周末，带上家人和孩子，去了成都的三圣花乡，算是新年第一次外出游玩。顺便带上了相机，瞎拍了几张，练练手，欢迎大家拍砖。</p>
<p>&#160;<a href="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/1.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="1" border="0" alt="1" align="left" src="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/1_thumb.jpg" width="753" height="504" /></a></p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p><a href="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/2.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2" border="0" alt="2" src="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/2_thumb.jpg" width="755" height="502" /></a> </p>
<p><a href="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/3.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="3" border="0" alt="3" src="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/3_thumb.jpg" width="754" height="501" /></a> </p>
<p><a href="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/4.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="4" border="0" alt="4" src="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/4_thumb.jpg" width="451" height="675" /></a></p>
<p><a href="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/5.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="5" border="0" alt="5" src="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/5_thumb.jpg" width="463" height="680" /></a>&#160; </p>
<p><a href="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/6.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="6" border="0" alt="6" src="http://www.xiaozhou.net/pics/b815d7f92eeb_1507A/6_thumb.jpg" width="755" height="501" /></a></p>
<h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2006年08月2日 -- <a href="http://www.xiaozhou.net/dotnetdevelopment/net-files-in-the-surveillance-category-2006-08-02.htm" title=".NET中的文件监视类">.NET中的文件监视类</a> (2)</li><li>2005年11月28日 -- <a href="http://www.xiaozhou.net/vcdevelopment/examples-of-msxml-to-read-and-write-2005-11-28.htm" title="MSXML读写的例子">MSXML读写的例子</a> (0)</li><li>2010年03月10日 -- <a href="http://www.xiaozhou.net/python/voa_special_english_mp3_downloader-2010-03-10.htm" title="VOA Special English MP3 Downloader">VOA Special English MP3 Downloader</a> (10)</li><li>2004年12月15日 -- <a href="http://www.xiaozhou.net/vcdevelopment/when-the-news-of-cancellation-of-interception-system-2004-12-15.htm" title="截获系统注销时候的消息">截获系统注销时候的消息</a> (0)</li><li>2005年01月4日 -- <a href="http://www.xiaozhou.net/vcdevelopment/vc-in-the-ado-connection-string-collection-2005-01-04.htm" title="VC中ADO连接字符串收集">VC中ADO连接字符串收集</a> (0)</li><li>2007年08月30日 -- <a href="http://www.xiaozhou.net/dotnetdevelopment/pjblog-adware-post-vulnerability-testing-and-repair-2007-08-30.htm" title="PJBlog恶意广告POST漏洞之测试与修复">PJBlog恶意广告POST漏洞之测试与修复</a> (1)</li><li>2004年12月28日 -- <a href="http://www.xiaozhou.net/vcdevelopment/how-to-control-a-static-display-jpg-file-picture-2004-12-28.htm" title="怎么在一个静态Picture控件中显示JPG文件">怎么在一个静态Picture控件中显示JPG文件</a> (0)</li><li>2009年07月7日 -- <a href="http://www.xiaozhou.net/vcdevelopment/htc-touch-pro-of-gravity-sensing-2009-07-07.htm" title="HTC Touch Pro 的重力感应功能">HTC Touch Pro 的重力感应功能</a> (3)</li><li>2004年10月26日 -- <a href="http://www.xiaozhou.net/vcdevelopment/overloading-the-main-message-loop-code-2004-10-26.htm" title="重载消息循环主要代码">重载消息循环主要代码</a> (0)</li><li>2004年10月26日 -- <a href="http://www.xiaozhou.net/vcdevelopment/real-time-display-2004-10-26.htm" title="实时时间显示">实时时间显示</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/essay/photo-essay/weekend_journey-2010-02-28.htm/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>没有四肢也能震撼世人&#8211;尼克·胡哲（Nick Vujicic）</title>
		<link>http://www.xiaozhou.net/essay/nick_vujicic-2010-02-28.htm</link>
		<comments>http://www.xiaozhou.net/essay/nick_vujicic-2010-02-28.htm#comments</comments>
		<pubDate>Sat, 27 Feb 2010 16:45:43 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[随笔]]></category>
		<category><![CDATA[Nick]]></category>
		<category><![CDATA[Vujicic]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/?p=549</guid>
		<description><![CDATA[
看完这段视频，感觉很震撼人心，也感到自己很惭愧，特地拿来跟同学们分享一下。想到自己在平时生活中遇到困难或者难题的时候，常常会感到沮丧、失望、懊恼、怨天尤人，而Nick Vujicic虽然天生就没了四肢，却能够有着一种异于常人的积极、向上的乐观，能够活出更加丰盛的生命，甚至能影响他人，各位同学们，也许你不认同他的信仰，但四肢健全的我们如果都能像他一样，那困难也不复存在了，感谢主！
随机日志2010年01月24日 -- 最近二三事 (10)2009年12月20日 -- Linq to Sql 之延迟加载与立即加载 (0)2004年10月10日 -- 调整本进程权限核心代码 (0)2005年02月4日 -- 枚举特定进程的所有线程列表 (0)2008年11月26日 -- 云计算杂谈&#8211;Windows Azure Service Platform (2)2005年01月11日 -- 定制自己的EXE文件 (0)2007年05月7日 -- Dopod D600 , I got it! (3)2006年03月6日 -- VC中调节系统音量 (0)2005年01月20日 -- ShellExecute用法种种 (0)2007年06月30日 -- 小福很受伤 (2)]]></description>
			<content:encoded><![CDATA[<p><embed src="http://player.youku.com/player.php/sid/XMTMwNzczODQw/v.swf" quality="high" width="480" height="400" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"></embed></p>
<p>看完这段视频，感觉很震撼人心，也感到自己很惭愧，特地拿来跟同学们分享一下。想到自己在平时生活中遇到困难或者难题的时候，常常会感到沮丧、失望、懊恼、怨天尤人，而Nick Vujicic虽然天生就没了四肢，却能够有着一种异于常人的积极、向上的乐观，能够活出更加丰盛的生命，甚至能影响他人，各位同学们，也许你不认同他的信仰，但四肢健全的我们如果都能像他一样，那困难也不复存在了，感谢主！</p>
<h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2005年01月16日 -- <a href="http://www.xiaozhou.net/vcdevelopment/boot-to-run-automatically-2005-01-16.htm" title="开机自动运行">开机自动运行</a> (0)</li><li>2006年01月10日 -- <a href="http://www.xiaozhou.net/essay/the-movie-u0026quotthe-classicu0026quot-can-not-not-believe-in-fate-2006-01-10.htm" title="电影《爱有天意》（不可不信缘）">电影《爱有天意》（不可不信缘）</a> (5)</li><li>2007年04月8日 -- <a href="http://www.xiaozhou.net/essay/the-words-written-on-easter-2007-04-08.htm" title="写在复活节的话">写在复活节的话</a> (0)</li><li>2006年06月21日 -- <a href="http://www.xiaozhou.net/essay/march-of-the-northern-trip-2006-06-21.htm" title="3月的北国之行">3月的北国之行</a> (3)</li><li>2008年03月29日 -- <a href="http://www.xiaozhou.net/myworks/dynamic-plugins-manager-2008-03-29.htm" title="Dynamic Plugins Manager">Dynamic Plugins Manager</a> (1)</li><li>2010年01月13日 -- <a href="http://www.xiaozhou.net/aboutsite/sitelog/album_created-2010-01-13.htm" title="相册正式开通">相册正式开通</a> (6)</li><li>2010年02月1日 -- <a href="http://www.xiaozhou.net/aboutsite/wordpress/blog_modification_ajax_comment_enabled-2010-02-01.htm" title="Blog再次改动&#8211;启用Ajax评论">Blog再次改动&#8211;启用Ajax评论</a> (18)</li><li>2005年01月16日 -- <a href="http://www.xiaozhou.net/vcdevelopment/programming-the-computer-hibernation-2005-01-16.htm" title="编程使计算机休眠">编程使计算机休眠</a> (0)</li><li>2008年03月29日 -- <a href="http://www.xiaozhou.net/myworks/dynamic-plugins-manager-3-demo-2008-03-29.htm" title="Dynamic Plugins Manager (三) Demo">Dynamic Plugins Manager (三) Demo</a> (6)</li><li>2006年04月24日 -- <a href="http://www.xiaozhou.net/myworks/multi-media-key-2006-04-24.htm" title="Multi Media Key">Multi Media Key</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/essay/nick_vujicic-2010-02-28.htm/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>vps中的iptables规则设置范例</title>
		<link>http://www.xiaozhou.net/ittech/linux-ittech/vps_iptables_setting_example-2010-02-26.htm</link>
		<comments>http://www.xiaozhou.net/ittech/linux-ittech/vps_iptables_setting_example-2010-02-26.htm#comments</comments>
		<pubDate>Fri, 26 Feb 2010 14:25:33 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[setting]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/?p=543</guid>
		<description><![CDATA[忙乎了一两天，俺的VPS算是上线了，基于Ubuntu Linux的，512MB内存，20G硬盘，1TB月流量，赠送2个IP，还不错。不过，现在还没有把博客迁移过去的打算，此VPS仅作为练手而用，只是建了一些ssh账号，供自己和同事跨栏用，还简单的搭建了基于Nginx+MySql+PHP+FastCGI的WordPress环境，并成功拉过来俺的一位同事在上面安了个blog，嘿嘿。
提到VPS，最重要的还是安全，毕竟你的系统是直接面向公网，如果不加强防范，很容易成为别人手里的肉鸡。Linux中的iptables，用过的同学都知道，是一个基于Linux内核的防火墙，功能比较强大，下面是iptable的一些常用的规则设置：

?View Code BASH1
2
3
4
5
6
7
8
9
10
11
12
        /sbin/iptables -P INPUT DROP              #禁止掉服务器所有入口请求，后面的规则只允许部分常用的服务端口
        /sbin/iptables -P OUTPUT ACCEPT          #允许服务器访问出口请求
      [...]]]></description>
			<content:encoded><![CDATA[<p>忙乎了一两天，俺的VPS算是上线了，基于Ubuntu Linux的，512MB内存，20G硬盘，1TB月流量，赠送2个IP，还不错。不过，现在还没有把博客迁移过去的打算，此VPS仅作为练手而用，只是建了一些ssh账号，供自己和同事跨栏用，还简单的搭建了基于Nginx+MySql+PHP+FastCGI的WordPress环境，并成功拉过来俺的一位同事在上面安了个blog，嘿嘿。<br />
提到VPS，最重要的还是安全，毕竟你的系统是直接面向公网，如果不加强防范，很容易成为别人手里的肉鸡。Linux中的iptables，用过的同学都知道，是一个基于Linux内核的防火墙，功能比较强大，下面是iptable的一些常用的规则设置：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p543code7'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p5437"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p543code7"><pre class="bash" style="font-family:monospace;">        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-P</span> INPUT DROP              <span style="color: #666666; font-style: italic;">#禁止掉服务器所有入口请求，后面的规则只允许部分常用的服务端口</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-P</span> OUTPUT ACCEPT          <span style="color: #666666; font-style: italic;">#允许服务器访问出口请求</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> lo <span style="color: #660033;">-j</span> ACCEPT    <span style="color: #666666; font-style: italic;">#允许本地接口访问</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-m</span> icmp <span style="color: #660033;">--icmp-type</span> 8 <span style="color: #660033;">-j</span> DROP <span style="color: #666666; font-style: italic;">#禁止ping，因为ping是基于icmp协议的</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 20 <span style="color: #660033;">-j</span> ACCEPT    <span style="color: #666666; font-style: italic;">#允许部分常用端口入口请求访问</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 21 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 25 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 53 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">-m</span> udp <span style="color: #660033;">--dport</span> 53 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 80 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> all <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT  <span style="color: #666666; font-style: italic;">#允许所有已经连接端口请求</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> all <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> INVALID,NEW <span style="color: #660033;">-j</span> DROP              <span style="color: #666666; font-style: italic;">#DROP掉所有失效或者新的请求</span></pre></td></tr></table></div>

<p>可以把上述脚本保存起来，执行，然后用命令/sbin/iptables -L -n查看规则是否生效</p>
<p>把上述脚本再完善一下:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p543code8'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p5438"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code" id="p543code8"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>sbin:~<span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #7a0874; font-weight: bold;">export</span> PATH
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Staring to write your Iptbales:...&quot;</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-P</span> INPUT DROP
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-P</span> OUTPUT ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> lo <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-m</span> icmp <span style="color: #660033;">--icmp-type</span> 8 <span style="color: #660033;">-j</span> DROP
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 20 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 21 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 25 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 53 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">-m</span> udp <span style="color: #660033;">--dport</span> 53 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 80 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> all <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> all <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> INVALID,NEW <span style="color: #660033;">-j</span> DROP
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Ok&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">;;</span>
stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Cleaning your Iptables:...&quot;</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-F</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-X</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-Z</span>
	<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-P</span> INPUT ACCEPT
	<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-P</span> OUTPUT ACCEPT
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Ok&quot;</span>
<span style="color: #000000; font-weight: bold;">;;</span>
restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Cleaning your Iptables:...&quot;</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-F</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-X</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-Z</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Ok&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Staring to write your Iptbales:...&quot;</span>
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-P</span> INPUT DROP
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-P</span> OUTPUT ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> lo <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-m</span> icmp <span style="color: #660033;">--icmp-type</span> 8 <span style="color: #660033;">-j</span> DROP
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 20 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 21 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 25 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 53 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">-m</span> udp <span style="color: #660033;">--dport</span> 53 <span style="color: #660033;">-j</span> ACCEPT       
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> 80 <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> all <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> all <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> INVALID,NEW <span style="color: #660033;">-j</span> DROP
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Ok&quot;</span>
<span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: $0          {start|stop|restart}&quot;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></td></tr></table></div>

<p>这样，我们就可以用start/stop/restart的参数来启用、禁止iptables防护了，很方便。另外，可以把此脚本放入/etc/init.d，让它像系统服务一样，在VPS启动的时候自动运行。</p>
<p>PS:<br />
1.此脚本参考自网上，并作了部分修改<br />
2.搜狗云输入法，也有郁闷的时候，在写文章的时候，候选词半天不出来，很卡，囧rz 是我打字速度太快，还是网速很慢？……</p>
<h3  class="related_post_title">你可能也对下列文章感兴趣</h3><ul class="related_post"><li>2010年03月5日 -- <a href="http://www.xiaozhou.net/ittech/vps-ittech/my_vps_is_online-2010-03-05.htm" title="俺的VPS正式上线了">俺的VPS正式上线了</a> (31)</li><li>2010年02月21日 -- <a href="http://www.xiaozhou.net/ittech/software/installation_of_ubuntu-2010-02-21.htm" title="台式机换上了Ubuntu">台式机换上了Ubuntu</a> (8)</li><li>2010年02月12日 -- <a href="http://www.xiaozhou.net/ittech/software/wm65_sms_mode_switch-2010-02-12.htm" title="WM6.5 短信聊天模式切换">WM6.5 短信聊天模式切换</a> (8)</li><li>2009年12月4日 -- <a href="http://www.xiaozhou.net/ittech/software/dns_setting_recommendation-2009-12-04.htm" title="上网推荐的DNS设置">上网推荐的DNS设置</a> (5)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/ittech/linux-ittech/vps_iptables_setting_example-2010-02-26.htm/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>台式机换上了Ubuntu</title>
		<link>http://www.xiaozhou.net/ittech/software/installation_of_ubuntu-2010-02-21.htm</link>
		<comments>http://www.xiaozhou.net/ittech/software/installation_of_ubuntu-2010-02-21.htm#comments</comments>
		<pubDate>Sun, 21 Feb 2010 09:57:00 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[软件使用]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Edition]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[老牛机]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/ittech/software/%e5%8f%b0%e5%bc%8f%e6%9c%ba%e6%8d%a2%e4%b8%8a%e4%ba%86ubuntu-2010-02-21.htm</guid>
		<description><![CDATA[这段时间对Linux相当痴迷，玩了下CentOS，现在又看上了Ubuntu。对Ubuntu偶早有所闻了，以前也在虚拟机上装过，那漂亮的UI是各个Linux版本中相当出众的，安装、维护的简单和方便，也是至今都Ubuntu拥有众多追随者的原因。正好，俺家中有一台老牛机(以前大学时候用的台式机)，这机器历史算长久了，从大二一直跟随俺到现在，有7、8年历史了。毕业后把这台机器略升级了一下，到现在都一直闲置在书房中，完全成了摆设。自从用上了笔记本，老婆也用上了上网本，这台台式机更是没人用了。昨天突然心血来潮，决定在老牛机上装个Ubuntu玩玩，没事了还可以开着下下高清BT，充分利用下闲置资源。    
老牛机配置如下：&#160; CPU:&#160; Athlon 1700+&#160; 内存:&#160; KingSton 1.5GB(1G*1+256*2)     硬盘:&#160; 希捷80G IDE接口     显卡:&#160; Geforce 6200     主板:&#160; nForce2
开始行动
说干就干，首先在Ubuntu的老家拖了个最新的Ubuntu 9.10 32bit Desktop Edition的ISO。老牛机的光驱，经久失修，已经是个残废了。本来想扔掉的，但机箱面板那个挡板也被我搞掉了，扔掉光驱就有个缺口，不美观，只有留下了。主板支持4个USB接口，两个坏掉了，剩下两个还可用，刚好偶又有个2G的U盘(捡来的)，所以打算通过U盘来安装系统。用U盘装系统好处多多，不用刻盘，并且速度比光驱快，嘿嘿。     
用Ultra ISO利器，把安装镜像写入到U盘：
     写完后的U盘驱动器图标：     &#160;
安装系统
拔下U盘，插上老牛机器，一步一步安装，Ubuntu从此跑在了老牛机上，发现比以前的XP快不少。并且Ubuntu支持大部分硬件，无须驱动，显卡驱动可以用Ubuntu默认的，也可以自己单独安装。安装界面也相当的友好，即使是第一次使用的用户，也能根据向导来完成安装。
一点使用体验
1.5G的内存，运行Linux当然会快很多，从开机和系统加载的速度就可以感受到，比以前的XP快不少。装上显卡驱动后，能打开一些可视化特效，比较炫。    由于Ubuntu自带Firefox浏览器，于是立马装上了AutoProxy插件，再用Linux自带的ssh命令，加上一个国外的SSH帐号，立马实现了跨栏的效果……为了以后方便，做了个简单的shell脚本：

?View [...]]]></description>
			<content:encoded><![CDATA[<p>这段时间对Linux相当痴迷，玩了下CentOS，现在又看上了Ubuntu。对Ubuntu偶早有所闻了，以前也在虚拟机上装过，那漂亮的UI是各个Linux版本中相当出众的，安装、维护的简单和方便，也是至今都Ubuntu拥有众多追随者的原因。正好，俺家中有一台老牛机(以前大学时候用的台式机)，这机器历史算长久了，从大二一直跟随俺到现在，有7、8年历史了。毕业后把这台机器略升级了一下，到现在都一直闲置在书房中，完全成了摆设。自从用上了笔记本，老婆也用上了上网本，这台台式机更是没人用了。昨天突然心血来潮，决定在老牛机上装个Ubuntu玩玩，没事了还可以开着下下高清BT，充分利用下闲置资源。    </p>
<p>老牛机配置如下：&#160; <br />CPU:&#160; Athlon 1700+&#160; <br />内存:&#160; KingSton 1.5GB(1G*1+256*2)     <br />硬盘:&#160; 希捷80G IDE接口     <br />显卡:&#160; Geforce 6200     <br />主板:&#160; nForce2</p>
<h4>开始行动</h4>
<p>说干就干，首先在<a href="http://www.ubuntu.com/getubuntu/download" target="_blank">Ubuntu的老家</a>拖了个最新的Ubuntu 9.10 32bit Desktop Edition的ISO。老牛机的光驱，经久失修，已经是个残废了。本来想扔掉的，但机箱面板那个挡板也被我搞掉了，扔掉光驱就有个缺口，不美观，只有留下了。主板支持4个USB接口，两个坏掉了，剩下两个还可用，刚好偶又有个2G的U盘(捡来的)，所以打算通过U盘来安装系统。用U盘装系统好处多多，不用刻盘，并且速度比光驱快，嘿嘿。     </p>
<p>用Ultra ISO利器，把安装镜像写入到U盘：</p>
<p><a href="http://www.xiaozhou.net/pics/Ubuntu_FC85/ubuntu.jpg"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="ubuntu" border="0" alt="ubuntu" src="http://www.xiaozhou.net/pics/Ubuntu_FC85/ubuntu_thumb.jpg" width="569" height="449" /></a>     <br />写完后的U盘驱动器图标：     <br /><a href="http://www.xiaozhou.net/pics/Ubuntu_FC85/ubuntu2.jpg"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="ubuntu2" border="0" alt="ubuntu2" src="http://www.xiaozhou.net/pics/Ubuntu_FC85/ubuntu2_thumb.jpg" width="266" height="73" /></a>&#160;</p>
<h4>安装系统</h4>
<p>拔下U盘，插上老牛机器，一步一步安装，Ubuntu从此跑在了老牛机上，发现比以前的XP快不少。并且Ubuntu支持大部分硬件，无须驱动，显卡驱动可以用Ubuntu默认的，也可以自己单独安装。安装界面也相当的友好，即使是第一次使用的用户，也能根据向导来完成安装。</p>
<h4>一点使用体验</h4>
<p>1.5G的内存，运行Linux当然会快很多，从开机和系统加载的速度就可以感受到，比以前的XP快不少。装上显卡驱动后，能打开一些可视化特效，比较炫。    <br />由于Ubuntu自带Firefox浏览器，于是立马装上了AutoProxy插件，再用Linux自带的ssh命令，加上一个国外的SSH帐号，立马实现了跨栏的效果……为了以后方便，做了个简单的shell脚本：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p537code10'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p53710"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p537code10"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ssh -N -D 127.0.0.1:7070 ssh-account@server-address&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> connect.sh
<span style="color: #c20cb9; font-weight: bold;">chmod</span> +x connect.sh</pre></td></tr></table></div>

<p>-N: 不需要shell登陆 </p>
<p>-D: 建立本地端口映射，这里使用的7070端口，把这端口配置到AutoProxy里面去，就OK了</p>
<p>后面是ssh-username@server-ip</p>
<p>控制台运行此脚本后，会提示输入ssh密码，输入后，连接完毕，可以打开Firefox畅游了</p>
<p>关于BT下载工具，偶用<a href="http://www.transmissionbt.com/download.php" target="_blank">Transmission</a>，貌似Ubuntu已经自带了，没有的也可以单独安装。</p>
<p>关于中文输入法，偶一般是在浏览网页时输入中文，Firefox可以装一个搜狗的<a href="http://pinyin.sogou.com/cloud/ff.html" target="_blank">云输入插件</a>，方便、绿色、环保，强烈推荐下。</p>
<h4></h4>
<h4>小结一下</h4>
<p>老牛机器装上Linux感觉挺赞，如同重新焕发了活力一般。家有闲置老牛机的同学不妨试一试。</p>
<h3  class="related_post_title">你可能也对下列文章感兴趣</h3><ul class="related_post"><li>2010年02月26日 -- <a href="http://www.xiaozhou.net/ittech/linux-ittech/vps_iptables_setting_example-2010-02-26.htm" title="vps中的iptables规则设置范例">vps中的iptables规则设置范例</a> (6)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/ittech/software/installation_of_ubuntu-2010-02-21.htm/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>WordPress本地测试环境搭建</title>
		<link>http://www.xiaozhou.net/aboutsite/wordpress/wordpress_local_test_environment_setup-2010-02-17.htm</link>
		<comments>http://www.xiaozhou.net/aboutsite/wordpress/wordpress_local_test_environment_setup-2010-02-17.htm#comments</comments>
		<pubDate>Wed, 17 Feb 2010 12:43:00 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/aboutsite/wordpress/wordpress%e6%9c%ac%e5%9c%b0%e6%b5%8b%e8%af%95%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba-2010-02-17.htm</guid>
		<description><![CDATA[为了Blog日后的改进和完善，偶越来越需要一个本地的测试环境。毕竟，直接在本地改程序，再上传到线上看修改后的效果，这是比较有风险的做法，并且也很不规范。由于WordPress是基于PHP的，而偶的操作系统又是Win7，首选的做法，就是用IIS+PHP+MySQL来搭建测试环境。并且，Windows下面配置起来没什么难度。不过我更倾向于Linux，所以选择了CentOS 5.4 + MySQL + PHP + Nginx，装在VirtualBox的虚拟机中。一来为了熟悉下Linux，二来是为了以后搞VPS先热点身，嘿嘿。
装好CentOS，没选择X Windows，直接用了Licess同学的一键安装包，非常方便。Licess同学为我们写好的Shell脚本里面，能自动完成下载、编译、安装的过程，省去很多繁琐的过程。安好后，需要根据自己的喜好更改一下设置即可。其中也遇到很多莫名其妙的问题，偶又是Linux新手，所以只有询问google老师，不过还好都找到了答案。待基础的几个软件都搞好之后，就可以安装WordPress了，然后将线上的博客内容通过PHPMyAdmin导出，再在虚拟机中导入即可，一个测试环境就OK了。另外，为了传文件的方便，还在CentOS上装了个vsftp，用以和Windows交换文件。经过这次折腾，发现原来Linux下面也这样好玩，打算以后多学习和折腾一下Linux，把家里那台N久没开过机的老台式机，也装个Ubuntu玩玩。     


你可能也对下列文章感兴趣2010年02月4日 -- Blog评论功能再次改进 (20)2010年02月1日 -- Blog再次改动&#8211;启用Ajax评论 (18)2009年12月2日 -- Blog 皮肤下载&#8212;Minyx 2.0 Lite (4)2009年10月25日 -- WordPress下的第一篇日志 :-) (7)]]></description>
			<content:encoded><![CDATA[<p>为了Blog日后的改进和完善，偶越来越需要一个本地的测试环境。毕竟，直接在本地改程序，再上传到线上看修改后的效果，这是比较有风险的做法，并且也很不规范。由于WordPress是基于PHP的，而偶的操作系统又是Win7，首选的做法，就是用IIS+PHP+MySQL来搭建测试环境。并且，Windows下面配置起来没什么难度。不过我更倾向于Linux，所以选择了CentOS 5.4 + MySQL + PHP + Nginx，装在VirtualBox的虚拟机中。一来为了熟悉下Linux，二来是为了以后搞VPS先热点身，嘿嘿。</p>
<p>装好CentOS，没选择X Windows，直接用了Licess同学的<a href="http://blog.licess.org/lnmp/" target="_blank">一键安装包</a>，非常方便。Licess同学为我们写好的Shell脚本里面，能自动完成下载、编译、安装的过程，省去很多繁琐的过程。安好后，需要根据自己的喜好更改一下设置即可。其中也遇到很多莫名其妙的问题，偶又是Linux新手，所以只有询问google老师，不过还好都找到了答案。待基础的几个软件都搞好之后，就可以安装WordPress了，然后将线上的博客内容通过PHPMyAdmin导出，再在虚拟机中导入即可，一个测试环境就OK了。另外，为了传文件的方便，还在CentOS上装了个vsftp，用以和Windows交换文件。经过这次折腾，发现原来Linux下面也这样好玩，打算以后多学习和折腾一下Linux，把家里那台N久没开过机的老台式机，也装个Ubuntu玩玩。     </p>
<p><a href="http://www.xiaozhou.net/pics/WordPress_12364/linux1.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="linux1" border="0" alt="linux1" src="http://www.xiaozhou.net/pics/WordPress_12364/linux1_thumb.jpg" width="740" height="485" /></a></p>
<p><a href="http://www.xiaozhou.net/pics/WordPress_12364/linux2.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="linux2" border="0" alt="linux2" src="http://www.xiaozhou.net/pics/WordPress_12364/linux2_thumb.jpg" width="720" height="460" /></a></p>
<h3  class="related_post_title">你可能也对下列文章感兴趣</h3><ul class="related_post"><li>2010年02月4日 -- <a href="http://www.xiaozhou.net/aboutsite/wordpress/modify_blog_comment_again-2010-02-04.htm" title="Blog评论功能再次改进">Blog评论功能再次改进</a> (20)</li><li>2010年02月1日 -- <a href="http://www.xiaozhou.net/aboutsite/wordpress/blog_modification_ajax_comment_enabled-2010-02-01.htm" title="Blog再次改动&#8211;启用Ajax评论">Blog再次改动&#8211;启用Ajax评论</a> (18)</li><li>2009年12月2日 -- <a href="http://www.xiaozhou.net/aboutsite/wordpress/blog_skin_download_minyx_lite-2009-12-02.htm" title="Blog 皮肤下载&mdash;Minyx 2.0 Lite">Blog 皮肤下载&mdash;Minyx 2.0 Lite</a> (4)</li><li>2009年10月25日 -- <a href="http://www.xiaozhou.net/aboutsite/wordpress/first_article_on_wordpress-2009-10-25.htm" title="WordPress下的第一篇日志 :-)">WordPress下的第一篇日志 :-)</a> (7)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/aboutsite/wordpress/wordpress_local_test_environment_setup-2010-02-17.htm/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Happy New Year！2010</title>
		<link>http://www.xiaozhou.net/essay/happy_new_year_2010-2-2010-02-13.htm</link>
		<comments>http://www.xiaozhou.net/essay/happy_new_year_2010-2-2010-02-13.htm#comments</comments>
		<pubDate>Sat, 13 Feb 2010 12:56:00 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[随笔]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[happy]]></category>
		<category><![CDATA[new]]></category>
		<category><![CDATA[year]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/essay/happy-new-year%ef%bc%812010-2010-02-13.htm</guid>
		<description><![CDATA[冬去春来，飞雪无痕，满目江山满目春；雪散雨淋，放歌高吟，满腔情愫咏新春；鞭炮炸鸣，灯红夜银，普天同乐闹新春！祝各位新老博友同学新春快乐！ 送上自己拍的照片一张，献丑了~~

你可能也对下列文章感兴趣2010年01月4日 -- Happy New Year 2010 &#38; 2009回顾 (9)2009年05月26日 -- Visual Studio 2010 Beta1 is available for download (0)2009年05月2日 -- Windows 7 新特性体验 (1)]]></description>
			<content:encoded><![CDATA[<p>冬去春来，飞雪无痕，满目江山满目春；雪散雨淋，放歌高吟，满腔情愫咏新春；鞭炮炸鸣，灯红夜银，普天同乐闹新春！祝各位新老博友同学新春快乐！ 送上自己拍的照片一张，献丑了~~</p>
<p><a href="http://www.xiaozhou.net/pics/HappyNewYear2010_1268D/happynewyear.jpg"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="happynewyear" border="0" alt="happynewyear" src="http://www.xiaozhou.net/pics/HappyNewYear2010_1268D/happynewyear_thumb.jpg" width="804" height="501" /></a></p>
<h3  class="related_post_title">你可能也对下列文章感兴趣</h3><ul class="related_post"><li>2010年01月4日 -- <a href="http://www.xiaozhou.net/essay/happy_new_year_2010-2010-01-04.htm" title="Happy New Year 2010 &amp; 2009回顾">Happy New Year 2010 &amp; 2009回顾</a> (9)</li><li>2009年05月26日 -- <a href="http://www.xiaozhou.net/ittech/software/visual-studio-2010-beta1-is-available-for-download-2009-05-26.htm" title="Visual Studio 2010 Beta1 is available for download">Visual Studio 2010 Beta1 is available for download</a> (0)</li><li>2009年05月2日 -- <a href="http://www.xiaozhou.net/ittech/software/windows-7-new-features-experience-2009-05-02.htm" title="Windows 7 新特性体验">Windows 7 新特性体验</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/essay/happy_new_year_2010-2-2010-02-13.htm/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>WM6.5 短信聊天模式切换</title>
		<link>http://www.xiaozhou.net/ittech/software/wm65_sms_mode_switch-2010-02-12.htm</link>
		<comments>http://www.xiaozhou.net/ittech/software/wm65_sms_mode_switch-2010-02-12.htm#comments</comments>
		<pubDate>Fri, 12 Feb 2010 15:06:00 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[软件使用]]></category>
		<category><![CDATA[6.5]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[setting]]></category>
		<category><![CDATA[SMS]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/ittech/software/wm6-5-%e7%9f%ad%e4%bf%a1%e8%81%8a%e5%a4%a9%e6%a8%a1%e5%bc%8f%e5%88%87%e6%8d%a2-2010-02-12.htm</guid>
		<description><![CDATA[自从手机刷了WM6.5的最新版系统后，以前常用的短信聊天模式没了，变成了普通模式，感觉很是不习惯。于是请教了下Google老师，很快找到了答案。原来，WM6.5的短信聊天模式，是在注册表中设定的。二话不说，打开注册表编辑器，定位到注册表的如下路径：HKEY_CURRENT_USER\Software\Microsoft\Inbox\Settings ，将SMSavailable这个键的值，由默认的0(普通模式)，改为1(聊天模式)即可。保存修改，重启手机，熟悉的聊天模式又回来了。
你可能也对下列文章感兴趣2009年12月30日 -- 手机ROM更新至WM6.5-28011 (8)2009年10月29日 -- 手机刷机到WM 6.5-23502 (3)2010年02月26日 -- vps中的iptables规则设置范例 (6)2009年12月4日 -- 上网推荐的DNS设置 (5)2009年05月29日 -- C# IDE Mobile – Write your C# code anywhere! (0)2004年11月17日 -- Windows 任务管理器如何确定应用程序&#34;没有响应&#34; (1)]]></description>
			<content:encoded><![CDATA[<p>自从手机刷了WM6.5的最新版系统后，以前常用的短信聊天模式没了，变成了普通模式，感觉很是不习惯。于是请教了下Google老师，很快找到了答案。原来，WM6.5的短信聊天模式，是在注册表中设定的。二话不说，打开注册表编辑器，定位到注册表的如下路径：HKEY_CURRENT_USER\Software\Microsoft\Inbox\Settings ，将SMSavailable这个键的值，由默认的0(普通模式)，改为1(聊天模式)即可。保存修改，重启手机，熟悉的聊天模式又回来了。</p>
<h3  class="related_post_title">你可能也对下列文章感兴趣</h3><ul class="related_post"><li>2009年12月30日 -- <a href="http://www.xiaozhou.net/ittech/software/mobile_phone_rom_upgrade_to_wm6_5_28011-2009-12-30.htm" title="手机ROM更新至WM6.5-28011">手机ROM更新至WM6.5-28011</a> (8)</li><li>2009年10月29日 -- <a href="http://www.xiaozhou.net/ittech/software/mobile_phone_rom_upgrade_to_wm_65_23502-2009-10-29.htm" title="手机刷机到WM 6.5-23502">手机刷机到WM 6.5-23502</a> (3)</li><li>2010年02月26日 -- <a href="http://www.xiaozhou.net/ittech/linux-ittech/vps_iptables_setting_example-2010-02-26.htm" title="vps中的iptables规则设置范例">vps中的iptables规则设置范例</a> (6)</li><li>2009年12月4日 -- <a href="http://www.xiaozhou.net/ittech/software/dns_setting_recommendation-2009-12-04.htm" title="上网推荐的DNS设置">上网推荐的DNS设置</a> (5)</li><li>2009年05月29日 -- <a href="http://www.xiaozhou.net/dotnetdevelopment/c-ide-mobile-write-your-c-code-anywhere-2009-05-29.htm" title="C# IDE Mobile – Write your C# code anywhere!">C# IDE Mobile – Write your C# code anywhere!</a> (0)</li><li>2004年11月17日 -- <a href="http://www.xiaozhou.net/vcdevelopment/windows-task-manager-to-determine-the-application-u0026quotnot-respondingu0026quot-2004-11-17.htm" title="Windows 任务管理器如何确定应用程序&quot;没有响应&quot;">Windows 任务管理器如何确定应用程序&quot;没有响应&quot;</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/ittech/software/wm65_sms_mode_switch-2010-02-12.htm/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Blog评论功能再次改进</title>
		<link>http://www.xiaozhou.net/aboutsite/wordpress/modify_blog_comment_again-2010-02-04.htm</link>
		<comments>http://www.xiaozhou.net/aboutsite/wordpress/modify_blog_comment_again-2010-02-04.htm#comments</comments>
		<pubDate>Thu, 04 Feb 2010 14:11:00 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Comment]]></category>
		<category><![CDATA[ctrl]]></category>
		<category><![CDATA[Enter]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/aboutsite/wordpress/blog%e8%af%84%e8%ae%ba%e5%8a%9f%e8%83%bd%e5%86%8d%e6%ac%a1%e6%94%b9%e8%bf%9b-2010-02-04.htm</guid>
		<description><![CDATA[自从实现了Ajax的评论后，俺还是对评论部分有点不太满意，于是又开始拿评论开刀了。
1.首先想到的，是评论没有分页显示的功能，如果评论数量太多，会把页面拖得很长，在google搜索了一下，原来WordPress原生已经支持评论分页的功能了，所以一不做二不休，继续改动。
其实改动很简单，打开模板的comments.php，在类似wp_list_comments();列出评论的代码后面，加入下面的代码即可:

?View Code PHP1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&#60;?php
	// 如果用户在后台选择要显示评论分页
	if &#40;get_option&#40;'page_comments'&#41;&#41;
	&#123;
		// 获取评论分页的 HTML
		$comment_pages = paginate_comments_links&#40;'echo=0'&#41;;
		// 如果评论分页的 HTML 不为空, 显示导航式分页
		if &#40;$comment_pages&#41;
		&#123;
?&#62;
&#160;
&#60;div id=&#34;commentnavi&#34;&#62;
		&#60;?php echo $comment_pages; ?&#62;&#60;/div&#62;
&#160;
&#160;
&#60;?php
		&#125;
	&#125;
?&#62;

2. 实现Enter+Ctrl快捷回复，这个比较简单，用jQuery实现，正好这两天也在学jQuery，就当练练手吧。为了增加代码可读性，方便以后维护，将这部分自定义的jQuery代码放在单独的js文件中：timothy.js

?View Code JAVASCRIPT1
2
3
4
5
6
7
8
9
10
11
$&#40;document&#41;.ready&#40;function&#40;&#41;&#123;
&#160;
    //Ctrl+Enter for fast submit
    $&#40;&#34;#comment&#34;&#41;.keydown&#40;
    	function&#40;event&#41;&#123;
        	if&#40;event.ctrlKey &#38;&#38; event.keyCode == 13&#41;
        [...]]]></description>
			<content:encoded><![CDATA[<p>自从实现了Ajax的评论后，俺还是对评论部分有点不太满意，于是又开始拿评论开刀了。</p>
<p>1.首先想到的，是评论没有分页显示的功能，如果评论数量太多，会把页面拖得很长，在google搜索了一下，原来WordPress原生已经支持评论分页的功能了，所以一不做二不休，继续改动。<br />
其实改动很简单，打开模板的comments.php，在类似wp_list_comments();列出评论的代码后面，加入下面的代码即可:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p525code15'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p52515"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p525code15"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #666666; font-style: italic;">// 如果用户在后台选择要显示评论分页</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page_comments'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// 获取评论分页的 HTML</span>
		<span style="color: #000088;">$comment_pages</span> <span style="color: #339933;">=</span> paginate_comments_links<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'echo=0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// 如果评论分页的 HTML 不为空, 显示导航式分页</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment_pages</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;commentnavi&quot;</span><span style="color: #339933;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$comment_pages</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>2. 实现Enter+Ctrl快捷回复，这个比较简单，用jQuery实现，正好这两天也在学jQuery，就当练练手吧。为了增加代码可读性，方便以后维护，将这部分自定义的jQuery代码放在单独的js文件中：timothy.js</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p525code16'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p52516"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p525code16"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//Ctrl+Enter for fast submit</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#comment&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keydown</span><span style="color: #009900;">&#40;</span>
    	<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>event.<span style="color: #660066;">ctrlKey</span> <span style="color: #339933;">&amp;&amp;</span> event.<span style="color: #660066;">keyCode</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">13</span><span style="color: #009900;">&#41;</span>
        	<span style="color: #009900;">&#123;</span>
            		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#submit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        	<span style="color: #009900;">&#125;</span>
    	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>代码比较简单，检测评论框的keydown时间，并判断是否同时按下了Ctrl键和Enter键，如果条件成立，则直接出发提交按钮的点击事件。将此部分js代码上传，并在header.php引入此脚本文件，效果立马就有了。这下同学们可以通过Ctrl+Enter快捷提交评论了。不过后来发现一个问题，这种用Ctrl+Enter快捷提交的评论，不会触发Ajax评论的效果，后来仔细找了找原因，发现Ajax评论的jQuery脚本中，并没有绑定提交按钮的点击事件，而是绑定的整个Form的submit事件，所以把刚才的脚本小小修改一下即可：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p525code17'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p52517"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p525code17"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//Ctrl+Enter for fast submit</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#comment&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keydown</span><span style="color: #009900;">&#40;</span>
    	<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>event.<span style="color: #660066;">ctrlKey</span> <span style="color: #339933;">&amp;&amp;</span> event.<span style="color: #660066;">keyCode</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">13</span><span style="color: #009900;">&#41;</span>
        	<span style="color: #009900;">&#123;</span>
            		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#commentform&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        	<span style="color: #009900;">&#125;</span>
    	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>这下就搞定了，支持Ctrl+Enter提交的Ajax评论，呵呵。</p>
<p>3.这个修改源自<a href="http://zww.me" target="_blank">Zww</a>同学的提议，在每条评论中增加”回复”按钮，原以为我的皮肤不支持嵌套评论的，尝试着在WordPress的设置项中，把嵌套评论给Enable了，这样的话，每条评论就自动有了个回复按钮。接下来，想实现点击回复的时候，自动把评论的同学的名字填入到评论框中，也就是类似 @XXX: 的形式。大体思路是通过jQuery来实现，绑定这些回复按钮的click事件，获取评论的同学的名称，设置到评论框中。其实<a href="http://zww.me" target="_blank">Zww</a>同学早就实现了这样的功能(<a href="http://zww.me/archives/24817" target="_blank">前去围观</a>)，所以jQuery也可以偷师过来了：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p525code18'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p52518"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p525code18"><pre class="javascript" style="font-family:monospace;">    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.reply&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span>
	<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066;">name</span> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">prevAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;cite:first&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#comment&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;@&quot;</span><span style="color: #339933;">+</span><span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;:&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>同样，放在$(document).ready里面即可。这次改动，俺意外的发现，原来我的皮肤支持嵌套评论……或许是加入了Ajax评论组件的原因，嘿嘿。</p>
<p>此文很菜，没啥技术含量， 算是学习jQuery的一点心得吧，前路茫茫，吾将继续折腾下去……</p>
<h3  class="related_post_title">你可能也对下列文章感兴趣</h3><ul class="related_post"><li>2010年02月1日 -- <a href="http://www.xiaozhou.net/aboutsite/wordpress/blog_modification_ajax_comment_enabled-2010-02-01.htm" title="Blog再次改动&#8211;启用Ajax评论">Blog再次改动&#8211;启用Ajax评论</a> (18)</li><li>2010年02月17日 -- <a href="http://www.xiaozhou.net/aboutsite/wordpress/wordpress_local_test_environment_setup-2010-02-17.htm" title="WordPress本地测试环境搭建">WordPress本地测试环境搭建</a> (18)</li><li>2009年12月29日 -- <a href="http://www.xiaozhou.net/aboutsite/wordpress/new_blog_plugin_comment_info_detector-2009-12-29.htm" title="新增博客插件&#8211;Comment Info Detector">新增博客插件&#8211;Comment Info Detector</a> (8)</li><li>2009年12月2日 -- <a href="http://www.xiaozhou.net/aboutsite/wordpress/blog_skin_download_minyx_lite-2009-12-02.htm" title="Blog 皮肤下载&mdash;Minyx 2.0 Lite">Blog 皮肤下载&mdash;Minyx 2.0 Lite</a> (4)</li><li>2009年10月25日 -- <a href="http://www.xiaozhou.net/aboutsite/wordpress/first_article_on_wordpress-2009-10-25.htm" title="WordPress下的第一篇日志 :-)">WordPress下的第一篇日志 :-)</a> (7)</li><li>2004年09月25日 -- <a href="http://www.xiaozhou.net/vcdevelopment/procedures-to-prevent-the-dialog-box-press-enter-and-esc-to-quit-countermeasures-2004-09-25.htm" title="防止对话框程序按Enter和ESC退出的对策">防止对话框程序按Enter和ESC退出的对策</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/aboutsite/wordpress/modify_blog_comment_again-2010-02-04.htm/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>
