<?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>等待喝彩_OnEcho &#187; 网络编程</title>
	<atom:link href="http://www.onecho.com/category/program/feed" rel="self" type="application/rss+xml" />
	<link>http://www.onecho.com</link>
	<description>http://www.onecho.com  回声的启示</description>
	<lastBuildDate>Fri, 16 Jul 2010 14:18:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>网站优化：压缩篇</title>
		<link>http://www.onecho.com/2010-03-09/648.html</link>
		<comments>http://www.onecho.com/2010-03-09/648.html#comments</comments>
		<pubDate>Tue, 09 Mar 2010 04:45:32 +0000</pubDate>
		<dc:creator>Kenami</dc:creator>
				<category><![CDATA[网络编程]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[mod_deflate]]></category>
		<category><![CDATA[优化]]></category>
		<category><![CDATA[压缩]]></category>

		<guid isPermaLink="false">http://www.onecho.com/2010-03-09/648.html</guid>
		<description><![CDATA[今天在站长站看到PHP如何使用gzip压缩页面的文章，自己研究了一下，基本有两种压缩页面的方法：]]></description>
			<content:encoded><![CDATA[<p>今天在站长站看到PHP如何使用gzip压缩页面的文章，自己研究了一下，基本有两种压缩页面的方法：</p>
<p>一、使用PHP，开启gzip功能进行压缩</p>

<div class="wp_syntax"><table><tr><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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">Extension_Loaded</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'zlib'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">Ob_Start</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ob_gzhandler'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">Header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: text/html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;无标题文档&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">10000</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Hello World!'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/body&gt;
&lt;/html&gt;
<span style="color: #000000; font-weight: bold;">&lt;?PHP</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">Extension_Loaded</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'zlib'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">Ob_End_Flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>这种方法只能压缩html页面，对css、js等文件没有压缩<span id="more-648"></span></p>
<p>二、利用apache的mod_deflate模块</p>
<p>mod_deflate的安装：</p>
<p>找到mod_deflate.c文件，执行：</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">/usr/local/apache2/bin/apxs -i -c -a mod_deflate.c</pre></div></div>

<p>此时在apache的配置文件httpd.conf 里面会加了这样一行：</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">LoadModule deflate_module     modules/mod_deflate.so</pre></div></div>

<p>说明mod_deflate模块加载成功，此时要重启apache</p>
<p>我们在.htaccess 文件里面设置，开启对mod_deflate 的支持</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">&lt;/IfModule&gt;
&lt;ifmodule mod_deflate.c&gt;
AddOutputFilter DEFLATE html xml php js css
&lt;/ifmodule&gt;</pre></div></div>

<p> 或者</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">&lt;/IfModule&gt;
&lt;ifmodule mod_deflate.c&gt;
AddOutputFilterByType DEFLATE text/html text/xml application/x-httpd-php application/x-javascript text/css
&lt;/ifmodule&gt;</pre></div></div>

<p>另外如果方便可以在httpd.conf里面设置，当然自己要有主机的root权限：</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">&lt;IfModule mod_deflate.c&gt;
DeflateCompressionLevel 7
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
AddOutputFilter DEFLATE css js
#DeflateFilterNote Input instream
#DeflateFilterNote Output outstream
#DeflateFilterNote Ratio ratio
#LogFormat '&quot;%r&quot; %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
#CustomLog logs/deflate_log.log deflate
&lt;/IfModule&gt;</pre></div></div>

<p> </p>
<p>或者：</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">&lt;IfModule mod_deflate.c&gt;
DeflateCompressionLevel 9
SetOutputFilter DEFLATE
#DeflateFilterNote Input instream
#DeflateFilterNote Output outstream
#DeflateFilterNote Ratio ratio
#LogFormat '&quot;%r&quot; %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
#CustomLog logs/deflate_log.log deflate
&lt;/IfModule&gt;</pre></div></div>

<p>如果将#号去掉，可以在logs/deflate_log.log日志文件中看到文件压缩前后的字节数、压缩比<br />
例如：&#8221;GET /index.html HTTP/1.1&#8243; 49373/276249 (17%)<br />
压缩前的字节数为276249，压缩后的字节数为49373，压缩比为17%</p>
]]></content:encoded>
			<wfw:commentRss>http://www.onecho.com/2010-03-09/648.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OneApp开发环境搭建</title>
		<link>http://www.onecho.com/2010-01-19/614.html</link>
		<comments>http://www.onecho.com/2010-01-19/614.html#comments</comments>
		<pubDate>Tue, 19 Jan 2010 09:36:52 +0000</pubDate>
		<dc:creator>Kenami</dc:creator>
				<category><![CDATA[OneApp]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[开发环境]]></category>

		<guid isPermaLink="false">http://www.onecho.com/2010-01-19/614.html</guid>
		<description><![CDATA[OneApp开发环境搭建]]></description>
			<content:encoded><![CDATA[<p><strong>操作系统</strong></p>
<p>Windows7 旗舰版</p>
<p><strong>开发工具</strong></p>
<p>Microsoft Visual Studio 2010 Ultimate</p>
<p>Version 10.0.21006.1 B2rel</p>
<p><strong>OneApp </strong><strong>版本</strong></p>
<p>OneApp 2.0 SDK Beta</p>
<p><strong>开发环境需求</strong></p>
<p>Microsoft .NET Framework 3.5  </p>
<p>下载地址: <a href="http://www.microsoft.com/downloads/">http://www.microsoft.com/downloads/</a></p>
<p> Microsoft Visual Studio 2010 Beta 2 </p>
<p>下载地址: <a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx">http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx</a><span id="more-614"></span></p>
<p style="text-align: center;"> <img class="size-full wp-image-616  aligncenter" title="oneapp_1" src="http://www.onecho.com/wp-content/uploads/2010/01/oneapp_1.jpg" alt="oneapp_1" width="529" height="285" /></p>
<p align="center">（图-1）</p>
<p style="text-align: left;"> OneApp 2.0 SDK Beta</p>
<p>下载地址: <a href="http://appdev.ctfactory.com/attach/OneApp%20V2.rar">http://appdev.ctfactory.com/attach/OneApp%20V2.rar</a></p>
<p> <img class="size-full wp-image-618 alignnone" title="oneapp_2" src="http://www.onecho.com/wp-content/uploads/2010/01/oneapp_21.jpg" alt="oneapp_2" width="558" height="94" /></p>
<p> </p>
<p align="center">（图-2）</p>
<p><strong>OneApp</strong><strong>开发环境配置安装</strong></p>
<p>双击OneAppVSIX.vsix，开始微软OneApp 2.0 SDK安装程序向导</p>
<p> </p>
<p> <img class="size-full wp-image-619 alignnone" title="oneapp_3" src="http://www.onecho.com/wp-content/uploads/2010/01/oneapp_3.jpg" alt="oneapp_3" width="500" height="391" /></p>
<p align="center">（图-3）</p>
<p>点击Install，提示OneApp成功安装</p>
<p> <img class="size-full wp-image-621 alignnone" title="oneapp_4" src="http://www.onecho.com/wp-content/uploads/2010/01/oneapp_4.jpg" alt="oneapp_4" width="508" height="399" /></p>
<p> </p>
<p align="center">（图-4）</p>
<p>打开Visual Studio 2010 （安装OneApp的时候如果Visual Studio 2010 是启动的状态时，需重启Visual Studio 2010），进入 Tools-&gt;Extension Manager</p>
<p> </p>
<p style="text-align: center;"> <img class="aligncenter" title="oneapp_5" src="http://www.onecho.com/wp-content/uploads/2010/01/oneapp_5.jpg" alt="oneapp_5" width="558" height="165" /></p>
<p align="center">（图-5）</p>
<p> </p>
<p> </p>
<p>这个时候如果用户帐户控制（UAC）被禁用，则需要手动设置一下，点击下面的“Load per user extensions when running as administrator”，设置后，重启Visual Studio 2010</p>
<p><strong>创建第一个OneApp </strong><strong>程序</strong></p>
<p>打开Visual Studio 2010，File-&gt;New-&gt;Project，选择OneApp</p>
<p> </p>
<p> <img class="size-full wp-image-622 alignnone" title="oneapp_6" src="http://www.onecho.com/wp-content/uploads/2010/01/oneapp_6.jpg" alt="oneapp_6" width="558" height="247" /></p>
<p align="center">（图-6）</p>
<p> </p>
<p> Visual Studio 2010 默认给出一小段测试程序main.js，我们运行一下：</p>
<p> <img class="size-full wp-image-623 alignnone" title="oneapp_7" src="http://www.onecho.com/wp-content/uploads/2010/01/oneapp_7.jpg" alt="oneapp_7" width="558" height="242" /></p>
<p> </p>
<p align="center">（图-7）</p>
<p>此时开发工具自带的手机模拟器打开，并打印出一个Label ，显示文本“Inside main.js</p>
<p>”，这就说明第一个OneApp 程序运行成功。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.onecho.com/2010-01-19/614.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP用ob_start() 方法判断输出结果</title>
		<link>http://www.onecho.com/2009-12-17/567.html</link>
		<comments>http://www.onecho.com/2009-12-17/567.html#comments</comments>
		<pubDate>Thu, 17 Dec 2009 08:35:26 +0000</pubDate>
		<dc:creator>Kenami</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ob_start()]]></category>

		<guid isPermaLink="false">http://www.onecho.com/2009-12-17/567.html</guid>
		<description><![CDATA[今天遇到一个问题，PHP的一个方法返回的是一个打印信息，我在页面调用此方法就不能判断如果它打印空的情况（我想把方法打印空的情况用其他字符串代替）]]></description>
			<content:encoded><![CDATA[<p>今天遇到一个问题，PHP的一个方法返回的是一个打印信息，我在页面调用此方法就不能判断如果它打印空的情况（我想把方法打印空的情况用其他字符串代替）</p>
<p>因为这是一个通用的方法，也不是我写的，所以不能去更改方法本身。当然也不能用 if ( functionName() == NULL) 来判断，因为方法只是来输出一个字符串或者空值。</p>
<p>最后自己用了一个拙劣的方法，用ob_start() 来解决。下面是代码</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
previous_post_link<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%link'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%title'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$previous_link</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ob_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ob_end_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
next_post_link<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%link'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%title'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$next_link</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ob_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ob_end_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>前一篇<span style="color: #339933;">:&amp;</span>nbsp<span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">&lt;?=</span> <span style="color: #000088;">$previous_link</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">NULL</span> ? <span style="color: #0000ff;">&quot;没有了&quot;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$previous_link</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;br /&gt;后一篇:&amp;nbsp;<span style="color: #000000; font-weight: bold;">&lt;?=</span> <span style="color: #000088;">$next_link</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">NULL</span> ? <span style="color: #0000ff;">&quot;没有了&quot;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$next_link</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/p&gt;
?&gt;</pre></td></tr></table></div>

<p>如果有某位大虾更好的方法，请留言告诉我～谢谢！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.onecho.com/2009-12-17/567.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>爱上Python</title>
		<link>http://www.onecho.com/2009-12-02/539.html</link>
		<comments>http://www.onecho.com/2009-12-02/539.html#comments</comments>
		<pubDate>Wed, 02 Dec 2009 14:28:32 +0000</pubDate>
		<dc:creator>Kenami</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Djnago]]></category>
		<category><![CDATA[mod_pyton]]></category>

		<guid isPermaLink="false">http://www.onecho.com/2009-12-02/539.html</guid>
		<description><![CDATA[想学Python有段日子了，一直静不下心来，想想也应该多学一门语言了，所以，就从现在开始学吧。]]></description>
			<content:encoded><![CDATA[<p>想学Python有段日子了，一直静不下心来，想想也应该多学一门语言了，所以，就从现在开始学吧。<br />
因为之前搞php的，所以我也从 Python 的web编程学起。<br />
这是 Python 的测试页面：<a href="http://py.onecho.com" target="_blank">http://py.onecho.com</a></p>
<p><img src="http://www.onecho.com/wp-content/uploads/2009/12/Djnago.jpg" alt="Djnago" title="Djnago" width="868" height="244" class="aligncenter size-full wp-image-543" /></p>
<p>服务器环境：<br />
Linux(CentOs5.2) + Apache + Python2.62 + mod_pyton，用的 Djnago 框架</p>
]]></content:encoded>
			<wfw:commentRss>http://www.onecho.com/2009-12-02/539.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP 使用 cURL 函数验证 NTLM</title>
		<link>http://www.onecho.com/2009-11-30/535.html</link>
		<comments>http://www.onecho.com/2009-11-30/535.html#comments</comments>
		<pubDate>Mon, 30 Nov 2009 03:18:50 +0000</pubDate>
		<dc:creator>Kenami</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[curl_setopt]]></category>
		<category><![CDATA[NTML]]></category>

		<guid isPermaLink="false">http://www.onecho.com/2009-11-30/535.html</guid>
		<description><![CDATA[最近同事做了一个手机接口，对方的短信业务接口平台是.net，并使用NTLM登录，因为以前都没有做过此类的接口，所以，我也来帮着找找解决方法。]]></description>
			<content:encoded><![CDATA[<p>最近同事做了一个手机接口，对方的短信业务接口平台是.net，并使用NTLM登录，因为以前都没有做过此类的接口，所以，我也来帮着找找解决方法。<br />
先看看什么是NTLM</p>
<p>NTLM是NT LAN Manager的缩写，这也说明了协议的来源。NTLM 是 Windows NT 早期版本的标准安全协议，Windows 2000 支持 NTLM 是为了保持向后兼容。Windows 2000内置三种基本安全协议之一</p>
<p>用php如何在页面程序里面登录NTLM呢？网上说了要用到cURL，自己在查了一下，获得了以下的方法：<br />
<span id="more-535"></span></p>

<div class="wp_syntax"><table><tr><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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$param</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;bstrMoMessageID=12231707088395410640&quot;</span> <span style="color: #339933;">.</span>
		<span style="color: #0000ff;">&quot;&amp;bstrBusinessCode=4668&quot;</span> <span style="color: #339933;">.</span>
		<span style="color: #0000ff;">&quot;&amp;bstrLongCode=3&quot;</span> <span style="color: #339933;">.</span>
		<span style="color: #0000ff;">&quot;&amp;bstrFeeMsisdn=15800394478&quot;</span> <span style="color: #339933;">.</span>
		<span style="color: #0000ff;">&quot;&amp;bstrDesMsisdn=15800394478&quot;</span> <span style="color: #339933;">.</span>
		<span style="color: #0000ff;">&quot;&amp;bstrMessageContent=你好&quot;</span> <span style="color: #339933;">.</span>
		<span style="color: #0000ff;">&quot;&amp;lTpPid=0&quot;</span> <span style="color: #339933;">.</span>
		<span style="color: #0000ff;">&quot;&amp;lTpUdhi=0&quot;</span> <span style="color: #339933;">.</span>
		<span style="color: #0000ff;">&quot;&amp;lSendDate=20091127&quot;</span> <span style="color: #339933;">.</span>
		<span style="color: #0000ff;">&quot;&amp;lSendTime=122320&quot;</span> <span style="color: #339933;">.</span>
		<span style="color: #0000ff;">&quot;&amp;lExpireDate=20091&quot;</span> <span style="color: #339933;">.</span>
		<span style="color: #0000ff;">&quot;&amp;lExpireTime=122320&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://*****/SmbpHttpAgent/SmbpHttpAgent.asmx/SmbppSendUnicodeMessage&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;4668&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;******&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$action</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://*****.com/SmbpHttpAgent/SmbppSendASCIIMessage&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$headers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'Method: POST'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'Connection: Keep-Alive'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'User-Agent: PHP-SOAP-CURL'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'Content-Type: application/x-www-form-urlencoded'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'SOAPAction: &quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$action</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">,</span><span style="color: #666666; font-style: italic;">//对应说明文档的action</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_HTTPHEADER<span style="color: #339933;">,</span> <span style="color: #000088;">$headers</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_HTTP_VERSION<span style="color: #339933;">,</span> CURL_HTTP_VERSION_1_1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_HTTPAUTH<span style="color: #339933;">,</span> CURLAUTH_NTLM<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//post 的参数</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_USERPWD<span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">.</span><span style="color: #0000ff;">':'</span><span style="color: #339933;">.</span><span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>另外附上.net实现NTLM的方法：</p>

<div class="wp_syntax"><table><tr><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
</pre></td><td class="code"><pre class="asp" style="font-family:monospace;"><span style="color: #ff6600;">//向短信业务平台提交数据</span>
<span style="color: #990099; font-weight: bold;">private</span> <span style="color: #990099; font-weight: bold;">int</span> SendDataToWapdm<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #990099; font-weight: bold;">string</span> destURL,<span style="color: #990099; font-weight: bold;">string</span> paramStr<span style="color: #006600; font-weight:bold;">&#41;</span>
<span style="color: #006600; font-weight:bold;">&#123;</span>
	<span style="color: #990099; font-weight: bold;">int</span> Result <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">0</span><span style="color: #006600; font-weight: bold;">;</span>
	WebResponse <span style="color: #990099; font-weight: bold;">response</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">null</span><span style="color: #006600; font-weight: bold;">;</span>
	try 
	<span style="color: #006600; font-weight:bold;">&#123;</span>				
		<span style="color: #ff6600;">//短信业务平台为商户提供的连接ID</span>
		<span style="color: #990099; font-weight: bold;">string</span> username <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;4648&quot;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #ff6600;">//短信业务平台为商户提供的连接密码</span>
		<span style="color: #990099; font-weight: bold;">string</span> password <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;******&quot;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #ff6600;">//为基于密码的身份验证方案提供凭据</span>
		System.<span style="color: #9900cc;">Net</span>.<span style="color: #9900cc;">NetworkCredential</span> credentials <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> NetworkCredential<span style="color: #006600; font-weight:bold;">&#40;</span>username,password<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>	
		<span style="color: #ff6600;">//提供向 URI 标识的资源发送数据和从 URI 标识的资源接收数据的公共方法</span>
		System.<span style="color: #9900cc;">Net</span>.<span style="color: #9900cc;">WebClient</span> Client <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> System.<span style="color: #9900cc;">Net</span>.<span style="color: #9900cc;">WebClient</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #ff6600;">//存储 Internet 资源的凭据</span>
		System.<span style="color: #9900cc;">Net</span>.<span style="color: #9900cc;">CredentialCache</span> myCache <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> System.<span style="color: #9900cc;">Net</span>.<span style="color: #9900cc;">CredentialCache</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #ff6600;">//向凭据缓存添加 NetworkCredential 实例</span>
		myCache.<span style="color: #9900cc;">Add</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #0000ff; font-weight: bold;">new</span> Uri<span style="color: #006600; font-weight:bold;">&#40;</span>destURL<span style="color: #006600; font-weight:bold;">&#41;</span>, <span style="color: #cc0000;">&quot;NTLM&quot;</span>, credentials<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
&nbsp;
		WebRequest req <span style="color: #006600; font-weight: bold;">=</span> WebRequest.<span style="color: #9900cc;">Create</span><span style="color: #006600; font-weight:bold;">&#40;</span>destURL<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		req.<span style="color: #9900cc;">Credentials</span> <span style="color: #006600; font-weight: bold;">=</span> myCache<span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #ff6600;">//使用post方式传递参数</span>
		req.<span style="color: #9900cc;">Method</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;POST&quot;</span><span style="color: #006600; font-weight: bold;">;</span>
		req.<span style="color: #330066;">ContentType</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;application/x-www-form-urlencoded&quot;</span><span style="color: #006600; font-weight: bold;">;</span>
		StringBuilder UrlEncoded <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> StringBuilder<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		Char<span style="color: #006600; font-weight:bold;">&#91;</span><span style="color: #006600; font-weight:bold;">&#93;</span> reserved <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #006600; font-weight:bold;">&#123;</span><span style="color: #008000;">'?', '=', '&amp;'};</span>
		<span style="color: #990099; font-weight: bold;">byte</span><span style="color: #006600; font-weight:bold;">&#91;</span><span style="color: #006600; font-weight:bold;">&#93;</span> SomeBytes <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">null</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #ff6600;">//分析传递给短信业务平台的参数并写入到Stream中</span>
		<span style="color: #990099; font-weight: bold;">if</span> <span style="color: #006600; font-weight:bold;">&#40;</span>paramStr <span style="color: #006600; font-weight: bold;">!=</span> <span style="color: #0000ff; font-weight: bold;">null</span><span style="color: #006600; font-weight:bold;">&#41;</span> 
		<span style="color: #006600; font-weight:bold;">&#123;</span>
			<span style="color: #990099; font-weight: bold;">int</span> i<span style="color: #006600; font-weight: bold;">=</span><span style="color: #800000;">0</span>, j<span style="color: #006600; font-weight: bold;">;</span>
			<span style="color: #990099; font-weight: bold;">while</span><span style="color: #006600; font-weight:bold;">&#40;</span>i<span style="color: #006600; font-weight: bold;">&lt;</span>paramStr.<span style="color: #9900cc;">Length</span><span style="color: #006600; font-weight:bold;">&#41;</span>
			<span style="color: #006600; font-weight:bold;">&#123;</span>
				j<span style="color: #006600; font-weight: bold;">=</span>paramStr.<span style="color: #9900cc;">IndexOfAny</span><span style="color: #006600; font-weight:bold;">&#40;</span>reserved, i<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
				<span style="color: #990099; font-weight: bold;">if</span> <span style="color: #006600; font-weight:bold;">&#40;</span>j<span style="color: #006600; font-weight: bold;">==</span>-<span style="color: #800000;">1</span><span style="color: #006600; font-weight:bold;">&#41;</span>
				<span style="color: #006600; font-weight:bold;">&#123;</span>
					UrlEncoded.<span style="color: #9900cc;">Append</span><span style="color: #006600; font-weight:bold;">&#40;</span>HttpUtility.<span style="color: #9900cc;">UrlEncode</span><span style="color: #006600; font-weight:bold;">&#40;</span>paramStr.<span style="color: #9900cc;">Substring</span><span style="color: #006600; font-weight:bold;">&#40;</span>i, paramStr.<span style="color: #9900cc;">Length</span>-i<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
					break<span style="color: #006600; font-weight: bold;">;</span>
				<span style="color: #006600; font-weight:bold;">&#125;</span>
				UrlEncoded.<span style="color: #9900cc;">Append</span><span style="color: #006600; font-weight:bold;">&#40;</span>HttpUtility.<span style="color: #9900cc;">UrlEncodeUnicode</span><span style="color: #006600; font-weight:bold;">&#40;</span>paramStr.<span style="color: #9900cc;">Substring</span><span style="color: #006600; font-weight:bold;">&#40;</span>i, j-i<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span><span style="color: #ff6600;">//这个地方需要UrlEncodeUnicode</span>
				<span style="color: #990099; font-weight: bold;">string</span> s <span style="color: #006600; font-weight: bold;">=</span> UrlEncoded.<span style="color: #9900cc;">ToString</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
				UrlEncoded.<span style="color: #9900cc;">Append</span><span style="color: #006600; font-weight:bold;">&#40;</span>paramStr.<span style="color: #9900cc;">Substring</span><span style="color: #006600; font-weight:bold;">&#40;</span>j,<span style="color: #800000;">1</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
				i <span style="color: #006600; font-weight: bold;">=</span> j+<span style="color: #800000;">1</span><span style="color: #006600; font-weight: bold;">;</span>
			<span style="color: #006600; font-weight:bold;">&#125;</span>
			SomeBytes <span style="color: #006600; font-weight: bold;">=</span> Encoding.<span style="color: #9900cc;">UTF8</span>.<span style="color: #9900cc;">GetBytes</span><span style="color: #006600; font-weight:bold;">&#40;</span>UrlEncoded.<span style="color: #9900cc;">ToString</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
			req.<span style="color: #9900cc;">ContentLength</span> <span style="color: #006600; font-weight: bold;">=</span> SomeBytes.<span style="color: #9900cc;">Length</span><span style="color: #006600; font-weight: bold;">;</span>
			Stream newStream <span style="color: #006600; font-weight: bold;">=</span> req.<span style="color: #9900cc;">GetRequestStream</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
			newStream.<span style="color: #330066;">Write</span><span style="color: #006600; font-weight:bold;">&#40;</span>SomeBytes, <span style="color: #800000;">0</span>, SomeBytes.<span style="color: #9900cc;">Length</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
			newStream.<span style="color: #330066;">Close</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #006600; font-weight:bold;">&#125;</span> 
		<span style="color: #990099; font-weight: bold;">else</span> 
		<span style="color: #006600; font-weight:bold;">&#123;</span>
			req.<span style="color: #9900cc;">ContentLength</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">0</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #006600; font-weight:bold;">&#125;</span>
&nbsp;
		<span style="color: #ff6600;">//获取短信业务平台的response</span>
		<span style="color: #990099; font-weight: bold;">response</span> <span style="color: #006600; font-weight: bold;">=</span> req.<span style="color: #9900cc;">GetResponse</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #ff6600;">//获取response数据流</span>
		Stream ReceiveStream <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #990099; font-weight: bold;">response</span>.<span style="color: #9900cc;">GetResponseStream</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		Encoding encode <span style="color: #006600; font-weight: bold;">=</span> System.<span style="color: #9900cc;">Text</span>.<span style="color: #9900cc;">Encoding</span>.<span style="color: #9900cc;">GetEncoding</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;utf-8&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		StreamReader sr <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> StreamReader<span style="color: #006600; font-weight:bold;">&#40;</span> ReceiveStream, encode <span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #ff6600;">//Console.WriteLine(&quot;\r\n已接收到响应流&quot;);</span>
		Char<span style="color: #006600; font-weight:bold;">&#91;</span><span style="color: #006600; font-weight:bold;">&#93;</span> read <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> Char<span style="color: #006600; font-weight:bold;">&#91;</span><span style="color: #800000;">256</span><span style="color: #006600; font-weight:bold;">&#93;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #990099; font-weight: bold;">int</span> count <span style="color: #006600; font-weight: bold;">=</span> sr.<span style="color: #9900cc;">Read</span><span style="color: #006600; font-weight:bold;">&#40;</span> read, <span style="color: #800000;">0</span>, <span style="color: #800000;">256</span> <span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		StringBuilder buf <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> StringBuilder<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #990099; font-weight: bold;">while</span> <span style="color: #006600; font-weight:bold;">&#40;</span>count <span style="color: #006600; font-weight: bold;">&gt;</span> <span style="color: #800000;">0</span><span style="color: #006600; font-weight:bold;">&#41;</span> 
		<span style="color: #006600; font-weight:bold;">&#123;</span>
			<span style="color: #990099; font-weight: bold;">String</span> str <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> <span style="color: #990099; font-weight: bold;">String</span><span style="color: #006600; font-weight:bold;">&#40;</span>read, <span style="color: #800000;">0</span>, count<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
			buf.<span style="color: #9900cc;">Append</span><span style="color: #006600; font-weight:bold;">&#40;</span>str<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
			count <span style="color: #006600; font-weight: bold;">=</span> sr.<span style="color: #9900cc;">Read</span><span style="color: #006600; font-weight:bold;">&#40;</span>read, <span style="color: #800000;">0</span>, <span style="color: #800000;">256</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #006600; font-weight:bold;">&#125;</span>
		buf.<span style="color: #330066;">Replace</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;\r\n&quot;</span>,<span style="color: #cc0000;">&quot;&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span><span style="color: #ff6600;">//不知道为什么用C#处理的流中含有\r\n（在java中没有这种情况的）</span>
		<span style="color: #ff6600;">//在这个地方调用分析短信业务平台发送消息后的回应的方法</span>
		Result <span style="color: #006600; font-weight: bold;">=</span> this.<span style="color: #9900cc;">parseWAPDMResponse</span><span style="color: #006600; font-weight:bold;">&#40;</span>buf.<span style="color: #9900cc;">ToString</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #006600; font-weight:bold;">&#125;</span> 
	catch<span style="color: #006600; font-weight:bold;">&#40;</span>UriFormatException ex<span style="color: #006600; font-weight:bold;">&#41;</span> 
	<span style="color: #006600; font-weight:bold;">&#123;</span>
		Result <span style="color: #006600; font-weight: bold;">=</span> CONNECT_ERROR<span style="color: #006600; font-weight: bold;">;</span>
		Console.<span style="color: #9900cc;">WriteLine</span><span style="color: #006600; font-weight:bold;">&#40;</span> ex.<span style="color: #9900cc;">ToString</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #ff6600;">//Page.Response.Write(e.StackTrace);</span>
		<span style="color: #ff6600;">//Page.Response.Write(e.Message);</span>
		Console.<span style="color: #9900cc;">WriteLine</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;\r\n找不到请求 URI，或者它的格式不正确&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
	<span style="color: #006600; font-weight:bold;">&#125;</span> 
	catch<span style="color: #006600; font-weight:bold;">&#40;</span>IOException ex<span style="color: #006600; font-weight:bold;">&#41;</span>
	<span style="color: #006600; font-weight:bold;">&#123;</span>
		Result <span style="color: #006600; font-weight: bold;">=</span> IO_ERROR<span style="color: #006600; font-weight: bold;">;</span>
		Console.<span style="color: #9900cc;">WriteLine</span><span style="color: #006600; font-weight:bold;">&#40;</span>ex.<span style="color: #9900cc;">ToString</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
	<span style="color: #006600; font-weight:bold;">&#125;</span>
	finally 
	<span style="color: #006600; font-weight:bold;">&#123;</span>
		<span style="color: #990099; font-weight: bold;">if</span> <span style="color: #006600; font-weight:bold;">&#40;</span> <span style="color: #990099; font-weight: bold;">response</span> <span style="color: #006600; font-weight: bold;">!=</span> <span style="color: #0000ff; font-weight: bold;">null</span> <span style="color: #006600; font-weight:bold;">&#41;</span> 
		<span style="color: #006600; font-weight:bold;">&#123;</span>
			<span style="color: #990099; font-weight: bold;">response</span>.<span style="color: #330066;">Close</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight: bold;">;</span>
		<span style="color: #006600; font-weight:bold;">&#125;</span>
	<span style="color: #006600; font-weight:bold;">&#125;</span>
	return Result<span style="color: #006600; font-weight: bold;">;</span>
<span style="color: #006600; font-weight:bold;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.onecho.com/2009-11-30/535.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>两台服务器间数据移植</title>
		<link>http://www.onecho.com/2009-11-20/513.html</link>
		<comments>http://www.onecho.com/2009-11-20/513.html#comments</comments>
		<pubDate>Thu, 19 Nov 2009 18:08:05 +0000</pubDate>
		<dc:creator>Kenami</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[服务器]]></category>
		<category><![CDATA[APACHE]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[数据库备份]]></category>
		<category><![CDATA[数据移植]]></category>

		<guid isPermaLink="false">http://www.onecho.com/?p=513</guid>
		<description><![CDATA[因为小说站24note(http://www.24note.cn) 所在的服务器的压力大，再加上软件的问题，导致服务器不稳定，虽然现在的方法是每隔1小时重启下apache，但是也不是长久之计，所以，今天晚上就加班把24note 上面的数据都移植到另外一台服务器上面。]]></description>
			<content:encoded><![CDATA[<p>因为小说站24note(<a href="http://www.24note.cn">http://www.24note.cn</a>) 所在的服务器的压力大，再加上软件的问题，导致服务器不稳定，虽然现在的方法是每隔1小时重启下apache，但是也不是长久之计，所以，今天晚上就加班把24note 上面的数据都移植到另外一台服务器上面。</p>
<p>其实数据移植并不困难，但是数据量真的太大了，小说站上面有大量的静态页、txt文件、手机小说书的jrd 文件等等，还有一个几百兆的数据库，所以就不能用传统的ftp来操作了。</p>
<p>linux 有很多很好的工具，来实现不同服务器间的数据移植。我用的是scp命令：</p>
<p>#scp -r 用户名@原数据所在服务器IP : 原数据的局对路径 当前服务器的数据存放位置<br />
<span id="more-513"></span></p>
<p>例如：</p>
<p>#scp -r <a href="mailto:root@122.193.111.220:/data/wwwroot/24note">root@122.193.111.220:/data/wwwroot/24note</a> /home/</p>
<p>参数 -r 表示复制文件夹，如果是单独的文件可以不加</p>
<p>两台服务器在同一局域网内，但是这条命令已经执行了2个多小时，可见里面的数据可以说是海量了。</p>
<p>其次我有时间来转移下数据库</p>
<p>现在原来的服务器上面做备份：</p>
<p>#mysqldump -uuser -ppasswd db_name &#8211;add-drop-table &gt; /home/**.sql</p>
<p>再用scp 命令将刚备份的sql文件复制到新服务器，然后执行命令，先要保证创建库db_name</p>
<p>#mysql -uuer -p db_name &lt; **.sql</p>
<p>用phpMyAdmin 查看，数据已经完整的过来了，剩下的就是给这些库按照原先的服务器的权限配置来配置权限；</p>
<p>进入mysql命令行</p>
<p>mysql&gt; grant all on db_name.*  to db_user<a href="mailto:kenami@localhost">@localhost</a> identified by <a href="mailto:'eiJ3@3*eO2N9'">&#8216;passwd&#8217;</a>;</p>
<p>在这里localhost 表示此数据库只能在本地访问，如果要其他的服务器能访问这个数据库，把localhost 换成 另一台服务器的IP即可；</p>
<p>夜里两点了，该休息了。明天早上又要睡懒觉了</p>
]]></content:encoded>
			<wfw:commentRss>http://www.onecho.com/2009-11-20/513.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>最近做PHP采集，发几个实用的函数</title>
		<link>http://www.onecho.com/2008-12-04/441.html</link>
		<comments>http://www.onecho.com/2008-12-04/441.html#comments</comments>
		<pubDate>Wed, 03 Dec 2008 16:09:57 +0000</pubDate>
		<dc:creator>Kenami</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[采集]]></category>

		<guid isPermaLink="false">http://www.onecho.com/2008-12-04/441.html</guid>
		<description><![CDATA[最近做PHP采集，发几个实用的函数]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//获得当前的脚本网址</span>
<span style="color: #000000; font-weight: bold;">function</span> get_php_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;REQUEST_URI&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$scriptName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;REQUEST_URI&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$nowurl</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$scriptName</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$scriptName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;PHP_SELF&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;QUERY_STRING&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$nowurl</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$scriptName</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span> <span style="color: #000088;">$nowurl</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$scriptName</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;?&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;QUERY_STRING&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$nowurl</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;</span>span id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;more-441&quot;</span><span style="color: #339933;">&gt;&lt;/</span>span<span style="color: #339933;">&gt;</span><span style="color: #666666; font-style: italic;">//把全角数字转为半角数字</span>
<span style="color: #000000; font-weight: bold;">function</span> GetAlabNum<span style="color: #009900;">&#40;</span><span style="color: #000088;">$fnum</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$nums</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;０&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;１&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;２&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;３&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;４&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;５&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;６&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;７&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;８&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;９&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fnums</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0123456789&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span><span style="color: #cc66cc;">9</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$fnum</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nums</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$fnums</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$fnum</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fnum</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ereg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[^0-9\.]|^0{1,}&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$fnum</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fnum</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$fnum</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$fnum</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//去除HTML标记</span>
<span style="color: #000000; font-weight: bold;">function</span> Text2Html<span style="color: #009900;">&#40;</span><span style="color: #000088;">$txt</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$txt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;  &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;　&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$txt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$txt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;lt;&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&amp;amp;lt;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$txt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$txt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;gt;&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&amp;amp;gt;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$txt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$txt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>]{1,}/isU&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&amp;lt;br/&amp;gt;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$txt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$txt</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//清除HTML标记</span>
<span style="color: #000000; font-weight: bold;">function</span> ClearHtml<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;lt;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&amp;amp;lt;'</span><span style="color: #339933;">,</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;gt;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&amp;amp;gt;'</span><span style="color: #339933;">,</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$str</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//相对路径转化成绝对路径</span>
<span style="color: #000000; font-weight: bold;">function</span> relative_to_absolute<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$feed_url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/(http|https|ftp):\/\//'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$feed_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$protocol</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$server_url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/(http|https|ftp|news):\/\//&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$feed_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$server_url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\/.*/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$server_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$server_url</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$protocol</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$new_content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/href=&quot;\//'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$protocol</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #000088;">$server_url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$new_content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/src=&quot;\//'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$protocol</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #000088;">$server_url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$new_content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$new_content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$new_content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//取得所有链接</span>
<span style="color: #000000; font-weight: bold;">function</span> get_all_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&amp;lt;a\s+href=[&quot;|\']?([^&amp;gt;&quot;\' ]+)[&quot;|\']?\s*[^&amp;gt;]*&amp;gt;([^&amp;gt;]+)&amp;lt;\/a&amp;gt;/i'</span><span style="color: #339933;">,</span><span style="color: #000088;">$code</span><span style="color: #339933;">,</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'url'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//获取指定标记中的内容</span>
<span style="color: #000000; font-weight: bold;">function</span> get_tag_data<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$start</span><span style="color: #339933;">,</span> <span style="color: #000088;">$end</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$start</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$end</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$start</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$end</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//HTML表格的每行转为CSV格式数组</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_tr_array<span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;'&amp;lt;td[^&amp;gt;]*?&amp;gt;'si&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;lt;/td&amp;gt;&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&quot;,'</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;lt;/tr&amp;gt;&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;{tr}&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//去掉 HTML 标记</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;'&amp;lt;[\/\!]*?[^&amp;lt;&amp;gt;]*?&amp;gt;'si&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//去掉空白字符</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;'([<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>])[\s]+'&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,{tr}&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$table</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//将HTML表格的每行每列转为数组，采集表格数据</span>
<span style="color: #000000; font-weight: bold;">function</span> get_td_array<span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;'&amp;lt;table[^&amp;gt;]*?&amp;gt;'si&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;'&amp;lt;tr[^&amp;gt;]*?&amp;gt;'si&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;'&amp;lt;td[^&amp;gt;]*?&amp;gt;'si&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;lt;/tr&amp;gt;&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;{tr}&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;lt;/td&amp;gt;&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;{td}&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//去掉 HTML 标记</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;'&amp;lt;[\/\!]*?[^&amp;lt;&amp;gt;]*?&amp;gt;'si&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//去掉空白字符</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;'([<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>])[\s]+'&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{tr}'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #000088;">$tr</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$td</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{td}'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$td</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$td_array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$td</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$td_array</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//返回字符串中的所有单词 $distinct=true 去除重复</span>
<span style="color: #000000; font-weight: bold;">function</span> split_en_str<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span><span style="color: #000088;">$distinct</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/([a-zA-Z]+)/'</span><span style="color: #339933;">,</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$distinct</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_unique</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.onecho.com/2008-12-04/441.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress标题不显示中文标签的解决办法</title>
		<link>http://www.onecho.com/2008-09-17/381.html</link>
		<comments>http://www.onecho.com/2008-09-17/381.html#comments</comments>
		<pubDate>Wed, 17 Sep 2008 08:41:28 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[中文标签]]></category>

		<guid isPermaLink="false">http://www.onecho.com/2008-09-17/381.html</guid>
		<description><![CDATA[最近发现wordpress的一个bug，就是按标签查看时，如果标签含有中文，在页面的标题，也就是title没有显示所选标签。那如何解决呢？]]></description>
			<content:encoded><![CDATA[<p>最近发现wordpress的一个bug，就是按标签查看时，如果标签含有中文，在页面的标题，也就是title没有显示所选标签。那如何解决呢？</p>
<p>下面是我的方法：</p>
<p>首先修改.htaccess 文件加上<br />
RewriteRule ^tag/(.*)$ /index.php?tag=$1 [L] <br />
#说明：(.*)即使匹配所有包括中文和英文的标签值，然后把匹配后的值放在$1里面</p>
<p>也就是每个标签的页面跳转到index.php?tag=$1，这样我们就能通过GET方法等到这个标签的title了</p>
<p>然后我们打开主题对应文件夹下面的header.php页面,在&lt;title&gt;标签里面加上这段，如</p>
<pre class="ruby" name="code">&lt;title&gt;
&lt;?php wp_title('');
if ($_GET['tag']) echo $_GET['tag'];
if (is_search() ) { ?&gt;
 搜索 &lt;?php echo $s; }
if ( !(is_404()) and (is_search()) or (is_single()) or (is_page()) or (function_exists('is_tag') and is_tag()) or (is_archive()) ) { ?&gt;
&amp;raquo; &lt;?php }  ?&gt;
&lt;?php bloginfo('name'); ?&gt;
&lt;/title&gt;</pre>
<p>这时不管打开的是中文或者英文的标签，都可以在标题上面正常显示了^_^ Good Luck</p>
]]></content:encoded>
			<wfw:commentRss>http://www.onecho.com/2008-09-17/381.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>解决WordPress 2.6日志ID不连续的方法</title>
		<link>http://www.onecho.com/2008-09-14/349.html</link>
		<comments>http://www.onecho.com/2008-09-14/349.html#comments</comments>
		<pubDate>Sun, 14 Sep 2008 08:36:37 +0000</pubDate>
		<dc:creator>Kenami</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.onecho.com/?p=349</guid>
		<description><![CDATA[核心提示：请注意这两个操作缺一不可，如果不启用“禁用WordPress自动保存的插件”，那么每篇文章都会出现一个自动保存的记录。

已经发布的WordPress 2.6版有一个很讨厌的功能，就是Post Revisions(文章的版本控制)，在默认的情况下，日志的ID将不再连续，使用ID做为Permalink结构的用户将会看到一个地址越来越混乱的 WordPress，现在我给一个解决WordPress的ID不连续的方法。]]></description>
			<content:encoded><![CDATA[<div id="textbody" class="content">
<table style="border: 1px dotted #cccccc; table-layout: fixed;" border="0" cellspacing="0" cellpadding="6" width="95%" align="center">
<tbody>
<tr>
<td bgcolor="#fdfddf"><span style="color: #ff0000;">核心提示：</span><span style="color: #000000;">请注意这两个操作缺一不可，如果不启用“禁用WordPress自动保存的插件”，那么每篇文章都会出现一个自动保存的记录。</span></td>
</tr>
</tbody>
</table>
<p>已经发布的WordPress 2.6版有一个很讨厌的功能，就是Post  Revisions(文章的版本控制)，在默认的情况下，日志的ID将不再连续，使用ID做为Permalink结构的用户将会看到一个地址越来越混乱的WordPress，现在我给一个解决WordPress的ID不连续的方法。</p>
<p>按照此文的方法，在wp-config.php文件中增加一行define(&#8217;WP_POST_REVISIONS&#8217;,  false)，同时安装“禁用WordPress自动保存的插件”，在WordPress后台启用此插件。</p>
<p>请注意这两个操作缺一不可，如果不启用“禁用WordPress自动保存的插件”，那么每篇文章都会出现一个自动保存的记录。</p>
<p>另外，对于数据库有“洁癖”的WordPress用户来说，可能想要删除由于Post  Revisions导致的表内的垃圾信息，同时将ID设置为连续，下面是我写的一段SQL脚本，请在phpmyadmin中使用。</p>
<p>删除是Post Revisions垃圾信息，请执行：</p>
<p>delete from wp_posts where post_type = &#8216;revision&#8217;;</p>
<p>将ID重新设置为连续，这个比较麻烦，设置一个ID就要4条SQL语句，我仅仅举一个例子，将ID为59的文章修改为ID为58，需要执行以下语句。</p>
<p>update wp_posts set id = 58 where id = 59;</p>
<p>update wp_term_relationships set object_id = 58 where object_id = 59;</p>
<p>update wp_postmeta set post_id = 58 where post_id = 59;</p>
<p>update wp_comments set comment_post_ID = 58 where comment_post_ID = 59;</p>
<p>如果用户需要修改的文章较多，需要批量复制、修改和执行上面四行。</p>
<p>原创文章如转载，请注明：转载自月光博客 williamlong.info/</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.onecho.com/2008-09-14/349.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[SEO]WordPress 优化之 robots.txt</title>
		<link>http://www.onecho.com/2008-09-13/341.html</link>
		<comments>http://www.onecho.com/2008-09-13/341.html#comments</comments>
		<pubDate>Sat, 13 Sep 2008 08:16:06 +0000</pubDate>
		<dc:creator>Kenami</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[robots.txt]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[WordPress 优化]]></category>

		<guid isPermaLink="false">http://www.onecho.com/?p=341</guid>
		<description><![CDATA[由于链接的的指向，而导致网站内容重复，一直是网站SEO的大忌。不同的链接指向同一个网页，就会被搜索引擎判定为作弊。昨天提到的WordPress重定向插件，在一定意义上也是为了阻止重复内容。然而，由于WordPress的结构原因，往往就会发生网页内容重复的状况。例如：http://www.domain.com/archive/1 和 http://www.domain.com/archive/1/feed两个网址下的内容就是一样的，所以，我们就必须想办法阻止这样的情况发生。 ]]></description>
			<content:encoded><![CDATA[<p>由于链接的的指向，而导致网站内容重复，一直是网站SEO的大忌。不同的链接指向同一个网页，就会被搜索引擎判定为作弊。昨天提到的<strong style="color: black; background-color: #ffff66;">WordPress</strong>重定向插件，在一定意义上也是为了阻止重复内容。然而，由于<strong style="color: black; background-color: #ffff66;">WordPress</strong>的结构原因，往往就会发生网页内容重复的状况。例如：http://www.domain.com/archive/1  和 http://www.domain.com/archive/1/feed两个网址下的内容就是一样的，所以，我们就必须想办法阻止这样的情况发生。</p>
<p>通常，解决重复内容的方法有：使用noindex标签，利用excerpt实现内容摘要，以及配置<strong style="color: black; background-color: #99ff99;">robots.txt</strong>。今天就主要说说在<strong style="color: black; background-color: #ffff66;">WordPress</strong>下使用<strong style="color: black; background-color: #99ff99;">robots.txt</strong>文件。</p>
<p><strong style="color: black; background-color: #99ff99;">robots.txt</strong>文件就像一个网站的大门，它会告诉搜索引擎的蜘蛛，可以抓取哪里的网页内容，哪里的不能抓取。因此，配置好<strong style="color: black; background-color: #99ff99;">robots.txt</strong>文件，完全可以理想的组织blog内容重复的问题。<strong style="color: black; background-color: #99ff99;">robots.txt</strong>的具体文法和使用方法，可以参考robotstxt.org。在国内，此类的<strong style="color: black; background-color: #ffff66;">WordPress</strong> <strong style="color: black; background-color: #99ff99;">robots.txt</strong>比较流行：<br />
<span id="more-341"></span></p>
<p>User-agent: *<br />
Disallow: /wp-<br />
Disallow: /feed/<br />
Disallow:  /comments/feed<br />
Disallow: /trackback/<br />
Disallow: /?s=</p>
<p>刚才看到  filination.com上面提到的一个robots文件，并且提供了简短的解释。刚刚接触<strong style="color: black; background-color: #99ff99;">robots.txt</strong>文件的朋友，可以参考一下：</p>
<p>User-agent: Googlebot</p>
<p># Disallow all directories and files  within<br />
Disallow: /cgi-bin/<br />
Disallow: /wp-admin/<br />
Disallow:  /wp-includes/</p>
<p># Disallow all files ending with these extensions<br />
Disallow: /*.php$<br />
Disallow: /*.js$<br />
Disallow: /*.inc$<br />
Disallow:  /*.css$</p>
<p># Disallow parsing individual post feeds, categories and  trackbacks..<br />
Disallow: */trackback/<br />
Disallow: */feed/<br />
Disallow:  /category/*</p>
<p><strong style="color: black; background-color: #99ff99;">Robots.txt</strong>因人而异，不同的人对robots有不同的理解，在加上SEO一直是一个热门话题，所以<strong style="color: black; background-color: #ffff66;">WordPress</strong>的robots文件不会是唯一的，也不会有一个最好的。大家要是有觉得更好的，不妨分享一下。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.onecho.com/2008-09-13/341.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
